summaryrefslogtreecommitdiff
path: root/src/map/unit.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-13 22:09:58 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-13 22:09:58 +0000
commit06bff5ca4d55db05bd46868e551b60807920b29f (patch)
tree3c32ace32f5afe43b7003b363efaff53db20bc22 /src/map/unit.c
parentc19d2cbb159a3f9ac7d5568c7c9b39008ca244e1 (diff)
downloadhercules-06bff5ca4d55db05bd46868e551b60807920b29f.tar.gz
hercules-06bff5ca4d55db05bd46868e551b60807920b29f.tar.bz2
hercules-06bff5ca4d55db05bd46868e551b60807920b29f.tar.xz
hercules-06bff5ca4d55db05bd46868e551b60807920b29f.zip
Replaced some foreach-based functions by their inlined iterator equivalents.
Changed the dynamic mobs system, so that the flag that indicates whether a particular mob can be unloaded is stored in the mob's respawn data structure. Cleaned up related parts of the source code. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12358 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/unit.c')
-rw-r--r--src/map/unit.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/map/unit.c b/src/map/unit.c
index ed5980786..5a7a62b96 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1883,18 +1883,23 @@ int unit_free(struct block_list *bl, int clrtype)
aFree(md->lootitem);
md->lootitem=NULL;
}
- if (md->guardian_data)
+ if(md->guardian_data)
{
if (md->guardian_data->number < MAX_GUARDIANS)
md->guardian_data->castle->guardian[md->guardian_data->number].id = 0;
aFree(md->guardian_data);
md->guardian_data = NULL;
}
- if (md->spawn && !md->special_state.cached && --(md->spawn->num) == 0)
- { //Spawning data is not attached to the map, so free it
- //if this is the last mob who is pointing at it.
- aFree(md->spawn);
- md->spawn = NULL;
+ if(md->spawn)
+ {
+ md->spawn->active--;
+ md->spawn->num--;
+
+ if( !md->spawn->state.dynamic && md->spawn->num == 0 )
+ {// Last freed mob is responsible for deallocating the group's spawn data.
+ aFree(md->spawn);
+ md->spawn = NULL;
+ }
}
if(md->base_status) {
aFree(md->base_status);