Fix object corruption loading save game
Saved games dump robot ai_local state for all objects, regardless of whether the object is a robot. Loading a game restored all ai_local values, regardless of whether the object was a robot on restore. This caused memory corruption in objects that were not robots when the `ctype.`_T_ for that object was large enough to overlap `ctype.ai_info.ail`. Fix this by loading the ai_local into a junk buffer when the object is not a robot. It would be better to skip over the bogus ai_local entirely, but the structure of ai_local_read_swap makes that difficult. Use the easy fix for now.
This commit is contained in:
parent
b195b3077b
commit
5114b8f8b6
|
@ -4659,7 +4659,10 @@ int ai_restore_state(PHYSFS_File *fp, int version, int swap)
|
|||
PHYSFSX_readSXE32(fp, swap);
|
||||
Overall_agitation = PHYSFSX_readSXE32(fp, swap);
|
||||
range_for (object &obj, Objects)
|
||||
ai_local_read_swap(&obj.ctype.ai_info.ail, swap, fp);
|
||||
{
|
||||
ai_local discard;
|
||||
ai_local_read_swap(obj.type == OBJ_ROBOT ? &obj.ctype.ai_info.ail : &discard, swap, fp);
|
||||
}
|
||||
PHYSFSX_serialize_read(fp, Point_segs);
|
||||
ai_cloak_info_read_n_swap(Ai_cloak_info.data(), Ai_cloak_info.size(), swap, fp);
|
||||
tmptime32 = PHYSFSX_readSXE32(fp, swap);
|
||||
|
|
Loading…
Reference in a new issue