diff --git a/src/actions.cc b/src/actions.cc index 416b930..2ea5559 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -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); diff --git a/src/game_dialog.cc b/src/game_dialog.cc index 7e73867..295a96e 100644 --- a/src/game_dialog.cc +++ b/src/game_dialog.cc @@ -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; } diff --git a/src/game_mouse.cc b/src/game_mouse.cc index bafbf82..ddd42bd 100644 --- a/src/game_mouse.cc +++ b/src/game_mouse.cc @@ -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); diff --git a/src/interpreter_extra.cc b/src/interpreter_extra.cc index 221f4a5..efbd190 100644 --- a/src/interpreter_extra.cc +++ b/src/interpreter_extra.cc @@ -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); diff --git a/src/map.cc b/src/map.cc index 79dc317..9836774 100644 --- a/src/map.cc +++ b/src/map.cc @@ -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(); diff --git a/src/obj_types.h b/src/obj_types.h index 02d9e7f..6ae7e13 100644 --- a/src/obj_types.h +++ b/src/obj_types.h @@ -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, diff --git a/src/object.cc b/src/object.cc index 01ea0ed..5d264f3 100644 --- a/src/object.cc +++ b/src/object.cc @@ -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(); diff --git a/src/party_member.cc b/src/party_member.cc index 3425ba3..b01e441 100644 --- a/src/party_member.cc +++ b/src/party_member.cc @@ -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;