xray-16 icon indicating copy to clipboard operation
xray-16 copied to clipboard

[Fix] Binder net packet reader io

Open Neloreck opened this issue 1 year ago • 6 comments

Changes

  • Fixing case when writing size_t to net packet, but reading u32, creates issues with custom binders for weapon objects and try to read data

Neloreck avatar Oct 16 '23 19:10 Neloreck

~~Ohhh, this will introduce incompatibility between x64 and x86 game saves (they won't be identical after this change)~~ Oh, they aren't compatible already. This needs to be fixed.

Xottab-DUTY avatar Oct 16 '23 23:10 Xottab-DUTY

Can't look at the engine code right now to find the place where we actually write size_t to a net packet, so I just briefly say that we should never use size_t in net packets and binary formats, so we need to change the code to write u32 as it was before. (or u64 if it's reaaally necessary)

Xottab-DUTY avatar Oct 16 '23 23:10 Xottab-DUTY

I would stick with u32. Then save method should be modified instead

Neloreck avatar Oct 17 '23 17:10 Neloreck

We write size of magazine here

    save_data(m_magazine2.size(), output_packet);

And get

    _NODISCARD _CONSTEXPR20 size_type size() const noexcept {
        auto& _My_data = _Mypair._Myval2;
        return static_cast<size_type>(_My_data._Mylast - _My_data._Myfirst);
    }

Should I just do static cast to u32 to make it work? I believe it is very unlikely to get overflow here + it will match original 32bit engine

Neloreck avatar Oct 17 '23 17:10 Neloreck

@Neloreck I agree!

Xottab-DUTY avatar Oct 17 '23 17:10 Xottab-DUTY

Now we need to analyze all changes we have and merge everything that breaks saves compatibility within one time period (e.g. a day?)

Xottab-DUTY avatar Oct 18 '23 14:10 Xottab-DUTY