Rename OBJECT_NO_SAVE flag

This commit is contained in:
Alexander Batalov 2022-12-22 16:49:17 +03:00
parent 96296417c6
commit c7ca358295
8 changed files with 37 additions and 26 deletions

View File

@ -1610,7 +1610,7 @@ int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object*
}
objectHide(explosion, NULL);
explosion->flags |= OBJECT_TEMPORARY;
explosion->flags |= OBJECT_NO_SAVE;
objectSetLocation(explosion, tile, elevation, NULL);
@ -1628,7 +1628,7 @@ int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object*
}
objectHide(adjacentExplosions[rotation], NULL);
adjacentExplosions[rotation]->flags |= OBJECT_TEMPORARY;
adjacentExplosions[rotation]->flags |= OBJECT_NO_SAVE;
int adjacentTile = tileGetTileInDirection(tile, rotation, 1);
objectSetLocation(adjacentExplosions[rotation], adjacentTile, elevation, NULL);
@ -1915,7 +1915,7 @@ void actionDamage(int tile, int elevation, int minDamage, int maxDamage, int dam
objectHide(attacker, NULL);
attacker->flags |= OBJECT_TEMPORARY;
attacker->flags |= OBJECT_NO_SAVE;
objectSetLocation(attacker, tile, elevation, NULL);

View File

@ -3248,7 +3248,7 @@ int _gdialog_barter_create_win()
_barterer_table_obj->flags |= OBJECT_HIDDEN;
if (objectCreateWithFidPid(&_barterer_temp_obj, gGameDialogSpeaker->fid, -1) != -1) {
_barterer_temp_obj->flags |= OBJECT_HIDDEN | OBJECT_TEMPORARY;
_barterer_temp_obj->flags |= OBJECT_HIDDEN | OBJECT_NO_SAVE;
_barterer_temp_obj->sid = -1;
return 0;
}

View File

@ -1976,13 +1976,13 @@ int gameMouseObjectsInit()
}
gGameMouseBouncingCursor->flags |= OBJECT_LIGHT_THRU;
gGameMouseBouncingCursor->flags |= OBJECT_TEMPORARY;
gGameMouseBouncingCursor->flags |= OBJECT_NO_SAVE;
gGameMouseBouncingCursor->flags |= OBJECT_NO_REMOVE;
gGameMouseBouncingCursor->flags |= OBJECT_SHOOT_THRU;
gGameMouseBouncingCursor->flags |= OBJECT_NO_BLOCK;
gGameMouseHexCursor->flags |= OBJECT_NO_REMOVE;
gGameMouseHexCursor->flags |= OBJECT_TEMPORARY;
gGameMouseHexCursor->flags |= OBJECT_NO_SAVE;
gGameMouseHexCursor->flags |= OBJECT_LIGHT_THRU;
gGameMouseHexCursor->flags |= OBJECT_SHOOT_THRU;
gGameMouseHexCursor->flags |= OBJECT_NO_BLOCK;
@ -2038,8 +2038,8 @@ void gameMouseObjectsFree()
if (gGameMouseObjectsInitialized) {
gameMouseActionMenuFree();
gGameMouseBouncingCursor->flags &= ~OBJECT_TEMPORARY;
gGameMouseHexCursor->flags &= ~OBJECT_TEMPORARY;
gGameMouseBouncingCursor->flags &= ~OBJECT_NO_SAVE;
gGameMouseHexCursor->flags &= ~OBJECT_NO_SAVE;
objectDestroy(gGameMouseBouncingCursor, NULL);
objectDestroy(gGameMouseHexCursor, NULL);

View File

@ -1030,7 +1030,7 @@ static void opDestroyObject(Program* program)
if (isSelf) {
object->sid = -1;
object->flags |= (OBJECT_HIDDEN | OBJECT_TEMPORARY);
object->flags |= (OBJECT_HIDDEN | OBJECT_NO_SAVE);
} else {
reg_anim_clear(object);
objectDestroy(object, NULL);
@ -4485,7 +4485,7 @@ static void opDestroyMultipleObjects(Program* program)
if (isSelf) {
object->sid = -1;
object->flags |= (OBJECT_HIDDEN | OBJECT_TEMPORARY);
object->flags |= (OBJECT_HIDDEN | OBJECT_NO_SAVE);
} else {
reg_anim_clear(object);
objectDestroy(object, NULL);

View File

@ -953,7 +953,7 @@ static int mapLoad(File* stream)
Object* object;
int fid = buildFid(OBJ_TYPE_MISC, 12, 0, 0, 0);
objectCreateWithFidPid(&object, fid, -1);
object->flags |= (OBJECT_LIGHT_THRU | OBJECT_TEMPORARY | OBJECT_HIDDEN);
object->flags |= (OBJECT_LIGHT_THRU | OBJECT_NO_SAVE | OBJECT_HIDDEN);
objectSetLocation(object, 1, 0, NULL);
object->sid = gMapSid;
scriptSetFixedParam(gMapSid, (gMapHeader.flags & 1) == 0);
@ -1361,7 +1361,7 @@ static int _map_save_file(File* stream)
Object* object = objectFindFirstAtElevation(elevation);
if (object != NULL) {
// TODO: Implementation is slightly different, check in debugger.
while (object != NULL && (object->flags & OBJECT_TEMPORARY)) {
while (object != NULL && (object->flags & OBJECT_NO_SAVE)) {
object = objectFindNextAtElevation();
}
@ -1637,7 +1637,7 @@ static void _map_place_dude_and_mouse()
}
objectSetLight(gDude, 4, 0x10000, 0);
gDude->flags |= OBJECT_TEMPORARY;
gDude->flags |= OBJECT_NO_SAVE;
_dude_stand(gDude, gDude->rotation, gDude->fid);
_partyMemberSyncPosition();

View File

@ -44,7 +44,18 @@ typedef enum OutlineType {
typedef enum ObjectFlags {
OBJECT_HIDDEN = 0x01,
OBJECT_TEMPORARY = 0x04,
// Specifies that the object should not be saved to the savegame file.
//
// This flag is used in these situations:
// - To prevent saving of system objects like dude (which has separate
// saving routine), egg, mouse cursors, etc.
// - To prevent saving of temporary objects (projectiles, explosion
// effects, etc.).
// - To prevent saving of objects which cannot be removed for some reason,
// like objects trying to delete themselves from scripting engine (used
// together with `OBJECT_HIDDEN` to prevent affecting game world).
OBJECT_NO_SAVE = 0x04,
OBJECT_FLAT = 0x08,
OBJECT_NO_BLOCK = 0x10,
OBJECT_LIGHTING = 0x20,

View File

@ -337,7 +337,7 @@ int objectsInit(unsigned char* buf, int width, int height, int pitch)
objectCreateWithFidPid(&gDude, dudeFid, 0x1000000);
gDude->flags |= OBJECT_NO_REMOVE;
gDude->flags |= OBJECT_TEMPORARY;
gDude->flags |= OBJECT_NO_SAVE;
gDude->flags |= OBJECT_HIDDEN;
gDude->flags |= OBJECT_LIGHT_THRU;
objectSetLight(gDude, 4, 0x10000, NULL);
@ -350,7 +350,7 @@ int objectsInit(unsigned char* buf, int width, int height, int pitch)
eggFid = buildFid(OBJ_TYPE_INTERFACE, 2, 0, 0, 0);
objectCreateWithFidPid(&gEgg, eggFid, -1);
gEgg->flags |= OBJECT_NO_REMOVE;
gEgg->flags |= OBJECT_TEMPORARY;
gEgg->flags |= OBJECT_NO_SAVE;
gEgg->flags |= OBJECT_HIDDEN;
gEgg->flags |= OBJECT_LIGHT_THRU;
@ -690,7 +690,7 @@ int objectSaveAll(File* stream)
continue;
}
if ((object->flags & OBJECT_TEMPORARY) != 0) {
if ((object->flags & OBJECT_NO_SAVE) != 0) {
continue;
}
@ -3523,7 +3523,7 @@ static void _obj_blend_table_exit()
// 0x48D348
static int _obj_save_obj(File* stream, Object* object)
{
if ((object->flags & OBJECT_TEMPORARY) != 0) {
if ((object->flags & OBJECT_NO_SAVE) != 0) {
return 0;
}
@ -3561,7 +3561,7 @@ static int _obj_save_obj(File* stream, Object* object)
return -1;
}
if ((inventoryItem->item->flags & OBJECT_TEMPORARY) != 0) {
if ((inventoryItem->item->flags & OBJECT_NO_SAVE) != 0) {
return -1;
}
}
@ -3645,13 +3645,13 @@ int _obj_save_dude(File* stream)
{
int field_78 = gDude->sid;
gDude->flags &= ~OBJECT_TEMPORARY;
gDude->flags &= ~OBJECT_NO_SAVE;
gDude->sid = -1;
int rc = _obj_save_obj(stream, gDude);
gDude->sid = field_78;
gDude->flags |= OBJECT_TEMPORARY;
gDude->flags |= OBJECT_NO_SAVE;
if (fileWriteInt32(stream, gCenterTile) == -1) {
fileClose(stream);
@ -3677,7 +3677,7 @@ int _obj_load_dude(File* stream)
memcpy(gDude, temp, sizeof(*gDude));
gDude->flags |= OBJECT_TEMPORARY;
gDude->flags |= OBJECT_NO_SAVE;
scriptsClearDudeScript();

View File

@ -395,7 +395,7 @@ int partyMemberAdd(Object* object)
partyMember->vars = NULL;
object->id = (object->pid & 0xFFFFFF) + 18000;
object->flags |= (OBJECT_NO_REMOVE | OBJECT_TEMPORARY);
object->flags |= (OBJECT_NO_REMOVE | OBJECT_NO_SAVE);
gPartyMembersLength++;
@ -453,7 +453,7 @@ int partyMemberRemove(Object* object)
gPartyMembers[index].object = gPartyMembers[gPartyMembersLength - 1].object;
}
object->flags &= ~(OBJECT_NO_REMOVE | OBJECT_TEMPORARY);
object->flags &= ~(OBJECT_NO_REMOVE | OBJECT_NO_SAVE);
gPartyMembersLength--;
@ -482,7 +482,7 @@ int _partyMemberPrepSave()
STRUCT_519DA8* ptr = &(gPartyMembers[index]);
if (index > 0) {
ptr->object->flags &= ~(OBJECT_NO_REMOVE | OBJECT_TEMPORARY);
ptr->object->flags &= ~(OBJECT_NO_REMOVE | OBJECT_NO_SAVE);
}
Script* script;
@ -501,7 +501,7 @@ int _partyMemberUnPrepSave()
STRUCT_519DA8* ptr = &(gPartyMembers[index]);
if (index > 0) {
ptr->object->flags |= (OBJECT_NO_REMOVE | OBJECT_TEMPORARY);
ptr->object->flags |= (OBJECT_NO_REMOVE | OBJECT_NO_SAVE);
}
Script* script;