- [FIX] Solventats els problemes de memòria al eliminar un actor
This commit is contained in:
@@ -33,6 +33,7 @@ namespace actor
|
||||
|
||||
int walk_channel = -1;
|
||||
bool push_sound_already_playing = false;
|
||||
std::vector<actor_t*> purgatory;
|
||||
|
||||
void resetTag()
|
||||
{
|
||||
@@ -69,6 +70,7 @@ namespace actor
|
||||
act->surface = draw::getSurface(bmp.c_str());
|
||||
act->bmp_rect = r;
|
||||
act->bmp_offset = o;
|
||||
act->alive = true;
|
||||
return act;
|
||||
}
|
||||
|
||||
@@ -89,6 +91,8 @@ namespace actor
|
||||
act->react_mask = act->react_push = 0;
|
||||
act->flags = FLAG_NONE;
|
||||
act->template_category = 0;
|
||||
act->alive = true;
|
||||
|
||||
return act;
|
||||
}
|
||||
|
||||
@@ -233,7 +237,7 @@ namespace actor
|
||||
newactor->prev = act->prev;
|
||||
newactor->next = act->next;
|
||||
act->prev = act->next = nullptr;
|
||||
remove(act);
|
||||
sendToPurgatory(act);
|
||||
return newactor;
|
||||
}
|
||||
|
||||
@@ -1229,7 +1233,7 @@ namespace actor
|
||||
room::load(room::getExit(XP));
|
||||
if (llevar_abad)
|
||||
{
|
||||
actor::remove(actor::find("ABAD"));
|
||||
actor::sendToPurgatory(actor::find("ABAD"));
|
||||
}
|
||||
act->pos.x = room::getMin().x - 3;
|
||||
act->pos.z = room::getDoor(XN) * 4;
|
||||
@@ -1427,7 +1431,7 @@ namespace actor
|
||||
{
|
||||
if (act->name[0] == '_')
|
||||
{
|
||||
actor::remove(act);
|
||||
actor::sendToPurgatory(act);
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -1672,6 +1676,26 @@ namespace actor
|
||||
free(act);
|
||||
}
|
||||
|
||||
void sendToPurgatory(actor_t *act)
|
||||
{
|
||||
if (!act) return;
|
||||
if (act->prev) act->prev->next = act->next;
|
||||
if (act == first) first = act->next;
|
||||
if (act == dirty) dirty = act->next;
|
||||
if (act->next) act->next->prev = act->prev;
|
||||
if (act == selected) selected = nullptr;
|
||||
if (act->below) act->below->above = nullptr;
|
||||
if (act->above) act->above->below = nullptr;
|
||||
act->alive = false;
|
||||
purgatory.push_back(act);
|
||||
}
|
||||
|
||||
void cleanPurgatory()
|
||||
{
|
||||
for (auto act : purgatory) remove(act);
|
||||
purgatory.clear();
|
||||
}
|
||||
|
||||
void pick(actor_t *act)
|
||||
{
|
||||
if (!act)
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace actor
|
||||
|
||||
int tag;
|
||||
int template_category;
|
||||
bool alive;
|
||||
};
|
||||
|
||||
void resetTag();
|
||||
@@ -169,6 +170,10 @@ namespace actor
|
||||
|
||||
void remove(actor_t *act);
|
||||
|
||||
void sendToPurgatory(actor_t *act);
|
||||
|
||||
void cleanPurgatory();
|
||||
|
||||
void pick(actor_t *act);
|
||||
|
||||
actor_t *getPicked();
|
||||
|
||||
Reference in New Issue
Block a user