diff --git a/engines/ags/engine/ac/draw.cpp b/engines/ags/engine/ac/draw.cpp index 28d82e17b70..b598a3d1c82 100644 --- a/engines/ags/engine/ac/draw.cpp +++ b/engines/ags/engine/ac/draw.cpp @@ -603,24 +603,19 @@ void mark_object_changed(int objid) { _G(objcache)[objid].y = -9999; } -void reset_objcache_for_sprite(int sprnum, bool deleted) { - // Check if this sprite is assigned to any game object, and mark these for update; - // if the sprite was deleted, also dispose shared textures +void reset_objcache_for_sprite(int sprnum) { + // Check if this sprite is assigned to any game object, and update them if necessary // room objects cache if (_G(croom) != nullptr) { for (size_t i = 0; i < (size_t)_G(croom)->numobj; ++i) { - if (_G(objcache)[i].sppic == sprnum) + if (_G(objs)[i].num == sprnum) _G(objcache)[i].sppic = -1; - if (deleted && (_GP(actsps)[i].SpriteID == sprnum)) - _GP(actsps)[i] = ObjTexture(); } } // character cache for (size_t i = 0; i < (size_t)_GP(game).numcharacters; ++i) { if (_GP(charcache)[i].sppic == sprnum) _GP(charcache)[i].sppic = -1; - if (deleted && (_GP(actsps)[ACTSP_OBJSOFF + i].SpriteID == sprnum)) - _GP(actsps)[i] = ObjTexture(); } } diff --git a/engines/ags/engine/ac/draw.h b/engines/ags/engine/ac/draw.h index 9b750871e51..6c032b51edb 100644 --- a/engines/ags/engine/ac/draw.h +++ b/engines/ags/engine/ac/draw.h @@ -130,7 +130,7 @@ void on_roomcamera_changed(Camera *cam); // Marks particular object as need to update the texture void mark_object_changed(int objid); // Resets all object caches which reference this sprite -void reset_objcache_for_sprite(int sprnum, bool deleted); +void reset_objcache_for_sprite(int sprnum); // whether there are currently remnants of a DisplaySpeech void mark_screen_dirty(); diff --git a/engines/ags/engine/ac/game.cpp b/engines/ags/engine/ac/game.cpp index ec72f72a984..3a1908ed4ba 100644 --- a/engines/ags/engine/ac/game.cpp +++ b/engines/ags/engine/ac/game.cpp @@ -1336,7 +1336,7 @@ bool unserialize_audio_script_object(int index, const char *objectType, Stream * void game_sprite_updated(int sprnum) { // character and object draw caches - reset_objcache_for_sprite(sprnum, false); + reset_objcache_for_sprite(sprnum); // gui backgrounds for (auto &gui : _GP(guis)) { @@ -1365,7 +1365,7 @@ void game_sprite_updated(int sprnum) { void game_sprite_deleted(int sprnum) { // character and object draw caches - reset_objcache_for_sprite(sprnum, true); + reset_objcache_for_sprite(sprnum); // room object graphics if (_G(croom) != nullptr) { for (size_t i = 0; i < (size_t)_G(croom)->numobj; ++i) {