Skip to content

Commit

Permalink
ChangeLevel: Ingore inventory show flag in save files
Browse files Browse the repository at this point in the history
Only set it if the entity is actually in an inventory.

Fixes: issue #1618
  • Loading branch information
dscharrer committed Dec 22, 2022
1 parent e20a61a commit f933b8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -68,6 +68,7 @@ Other Fixes:
* Fixed a crash when dragging an entity without a 3D object (bug #1592)
* Fixed a crash when an equipped candle is destroyed (bug #1622)
* Fixed a crash with negative (or zero with -i) intervals in the `timer` command
* Fixed a crash when loading save files with linked items inside an inventory

Technical Changes:

Expand Down
7 changes: 4 additions & 3 deletions src/scene/ChangeLevel.cpp
Expand Up @@ -912,7 +912,7 @@ static bool ARX_CHANGELEVEL_Push_IO(const Entity * io, AreaId area) {
switch(io->show) {
case SHOW_FLAG_IN_SCENE: return SAVED_SHOW_FLAG_IN_SCENE;
case SHOW_FLAG_LINKED: return SAVED_SHOW_FLAG_LINKED;
case SHOW_FLAG_IN_INVENTORY: return SAVED_SHOW_FLAG_IN_INVENTORY;
case SHOW_FLAG_IN_INVENTORY: return SAVED_SHOW_FLAG_IN_INVENTORY; // Ignored by us, for compat only
case SHOW_FLAG_HIDDEN: return SAVED_SHOW_FLAG_HIDDEN;
case SHOW_FLAG_TELEPORTING: return SAVED_SHOW_FLAG_TELEPORTING;
case SHOW_FLAG_MEGAHIDE: return SAVED_SHOW_FLAG_MEGAHIDE;
Expand Down Expand Up @@ -1787,7 +1787,7 @@ static Entity * ARX_CHANGELEVEL_Pop_IO(std::string_view idString, EntityInstance
switch(ais->show) {
case SAVED_SHOW_FLAG_IN_SCENE: return SHOW_FLAG_IN_SCENE;
case SAVED_SHOW_FLAG_LINKED: return SHOW_FLAG_LINKED;
case SAVED_SHOW_FLAG_IN_INVENTORY: return SHOW_FLAG_IN_INVENTORY;
case SAVED_SHOW_FLAG_IN_INVENTORY: return SHOW_FLAG_IN_SCENE; // Real flag is restored along with link
case SAVED_SHOW_FLAG_HIDDEN: return SHOW_FLAG_HIDDEN;
case SAVED_SHOW_FLAG_TELEPORTING: return SHOW_FLAG_TELEPORTING;
case SAVED_SHOW_FLAG_KILLED: arx_unreachable();
Expand Down Expand Up @@ -2141,10 +2141,11 @@ static Entity * ARX_CHANGELEVEL_Pop_IO(std::string_view idString, EntityInstance
if(!item || locateInInventories(item).io == io->index()) {
continue;
}
arx_assert(item->show == SHOW_FLAG_IN_INVENTORY);
if(!insertIntoInventoryAtNoEvent(item, InventoryPos(io->index(), 0, slot.x, slot.y))) {
LogWarning << "Could not load item " << item->idString() << " into inventory of " << io->idString();
PutInFrontOfPlayer(item);
} else {
arx_assert(item->show == SHOW_FLAG_IN_INVENTORY);
}
}

Expand Down

0 comments on commit f933b8f

Please sign in to comment.