summaryrefslogtreecommitdiff
path: root/src/map/map.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/map.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/map.c')
-rw-r--r--src/map/map.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 30e16aa55..a956952b8 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2004,7 +2004,7 @@ void map_spawnmobs(int m)
if(map[m].moblist[i]!=NULL)
{
k+=map[m].moblist[i]->num;
- npc_parse_mob2(map[m].moblist[i],true);
+ npc_parse_mob2(map[m].moblist[i]);
}
if (battle_config.etc_log && k > 0)
@@ -2013,22 +2013,18 @@ void map_spawnmobs(int m)
}
}
-int mob_cache_cleanup_sub(struct block_list *bl, va_list ap)
+int map_removemobs_sub(struct block_list *bl, va_list ap)
{
struct mob_data *md = (struct mob_data *)bl;
nullpo_retr(0, md);
//When not to remove:
- //Mob is not in cache
- if (!md->special_state.cached)
+ //Mob respawn data is not in cache
+ if( md->spawn && !md->spawn->state.dynamic )
return 0;
//Mob is damaged and mob_remove_damaged is off
- if (!battle_config.mob_remove_damaged && md->status.hp < md->status.max_hp)
- {
- if( md->spawn ) //Do not respawn mob later.
- md->spawn->skip++;
+ if( !battle_config.mob_remove_damaged && md->status.hp < md->status.max_hp )
return 0;
- }
unit_free(&md->bl,0);
@@ -2037,24 +2033,27 @@ int mob_cache_cleanup_sub(struct block_list *bl, va_list ap)
int map_removemobs_timer(int tid, unsigned int tick, int id, int data)
{
- int k;
- if (id < 0 || id >= MAX_MAP_PER_SERVER)
+ int count;
+ const int m = id;
+
+ if (m < 0 || m >= MAX_MAP_PER_SERVER)
{ //Incorrect map id!
- ShowError("map_removemobs_timer error: timer %d points to invalid map %d\n",tid, id);
+ ShowError("map_removemobs_timer error: timer %d points to invalid map %d\n",tid, m);
return 0;
}
- if (map[id].mob_delete_timer != tid)
+ if (map[m].mob_delete_timer != tid)
{ //Incorrect timer call!
- ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",map[id].mob_delete_timer, tid, map[id].name);
+ ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",map[m].mob_delete_timer, tid, map[m].name);
return 0;
}
- map[id].mob_delete_timer = -1;
- if (map[id].users > 0) //Map not empty!
+ map[m].mob_delete_timer = -1;
+ if (map[m].users > 0) //Map not empty!
return 1;
- k = map_foreachinmap(mob_cache_cleanup_sub, id, BL_MOB);
- if (battle_config.etc_log && k > 0)
- ShowStatus("Map %s: Removed '"CL_WHITE"%d"CL_RESET"' mobs.\n",map[id].name, k);
+ count = map_foreachinmap(map_removemobs_sub, m, BL_MOB);
+
+ if (battle_config.etc_log && count > 0)
+ ShowStatus("Map %s: Removed '"CL_WHITE"%d"CL_RESET"' mobs.\n",map[m].name, count);
return 1;
}