Revert "AGS: fixed object cache may sometimes keep an old dynsprite ref"

This reverts commit f380e3edda.

The commit uses other changes that were not merged in branch-2-6 and
will therefore need to be reworked if we want it in the branch.
This commit is contained in:
Thierry Crozat 2022-10-10 02:06:04 +01:00
parent f380e3edda
commit 83ccb69a75
3 changed files with 6 additions and 11 deletions

View file

@ -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();
}
}

View file

@ -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();

View file

@ -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) {