ReadByte has special behavior for return value in case of EOF, and in case of
reading data fields it's more clear to indicate an integer of particular size.
From upstream 47a21109c4ef35226fbc89f06c8527db6eaad480
This fixes a mistake introduced in commit 4be1556, which in turn followed b02814b
The problem is, that CCStaticArray does not work as intended, and seems won't (at
least not without some extra workarounds).
When the script compiler is told to get an Nth element of a global struct array, such
as character[n], it calculates the memory address as
Character* ptr = (array address + sizeof(Character) * n).
If this address is used for the read/write operations, these ops can be intercepted by
interpreter and remapped into the real fields (see IScriptObject::ReadN, WriteN
interface).
But if this address is used IN POINTER COMPARISON BY VALUE, then we cannot do
anything. And if our real struct in the engine is stored on a different relative memory
offset than one expected by compiler, then this pointer comparison will fail.
This breaks script expressions like e.g.:
if (player == character[n])
From upstream 97ed18e95b587544ae47497f0a5f1d1ba00a7e29
AlignedStream was used initially in attempt to automate reading legacy formats,
where structs were dumped from memory into filestream directly,
resulting in alignment padding inserted into the file format.
While using AlignedStream made working with old formats easier, this approach also has certain problems:
1. This makes extra padding in file formats implicit and non-obvious.
2. Object Read/Write functions will depend on the type of the passed stream.
3. Adding anything into Read/Write functions will also be affected by AlignedStream,
and in theory may lead to additional unnecessary padding inserted simply by keeping same serialization logic.
4. AlignedStream does not support Seek, and in general you cannot trivially skip parts of struct by skipping
or reading N bytes, you'll have to read it out step by step to keep alignment calculation working.
These concerns made me make the decision to remove AlignedStream, and restore hardcoded padding instead.
It's explicit and honest.
From upstream ffc59e82029bed4da9dd595dac015374681fd2e4
This is not as important in case of game quit, as it is in case of RunAGSGame().
* Adjusted order of data release in unload_game_file() to be in sync with 3.6.1 (as much as possible).
* Fixed GameSetupStruct not releasing some of the data in Free().
Noteably this fixes font infos to not getting fully reset on RunAGSGame().
from upstream 1cc9d22095d0ee90541ce506fa54c538de7ca4ad