diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2009-01-13 10:38:54 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2009-01-13 10:38:54 +0000 |
commit | 9d1b39d3facc6d9f1268e036e7b23bd410c683ec (patch) | |
tree | 355fc27fb7d8431737b6d5fd2b62b3b00c7baf21 /src/map/npc.c | |
parent | 4ae49e2bfd82567f5747eaed81f02f515e556441 (diff) | |
download | hercules-9d1b39d3facc6d9f1268e036e7b23bd410c683ec.tar.gz hercules-9d1b39d3facc6d9f1268e036e7b23bd410c683ec.tar.bz2 hercules-9d1b39d3facc6d9f1268e036e7b23bd410c683ec.tar.xz hercules-9d1b39d3facc6d9f1268e036e7b23bd410c683ec.zip |
Mobs with nonzero spawn time can now be cached as well, saving some more cpu/memory (bugreport:1197).
Fixed dynamic mobs being unloaded without stopping their respawn timer.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13445 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r-- | src/map/npc.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/src/map/npc.c b/src/map/npc.c index fd44ded3a..49ffa8e89 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2531,34 +2531,27 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c } } - //Now that all has been validated. We allocate the actual memory - //that the re-spawn data will use. + //Now that all has been validated. We allocate the actual memory that the re-spawn data will use. data = (struct spawn_data*)aMalloc(sizeof(struct spawn_data)); memcpy(data, &mob, sizeof(struct spawn_data)); - - if( !battle_config.dynamic_mobs || data->delay1 || data->delay2 ) { + + // spawn / cache the new mobs + if( battle_config.dynamic_mobs && map_addmobtolist(data->m, data) >= 0 ) + { + data->state.dynamic = true; + npc_cache_mob += data->num; + + // check if target map has players + // (usually shouldn't occur when map server is just starting, + // but not the case when we do @reloadscript + if( map[data->m].users > 0 ) + npc_parse_mob2(data); + } + else + { data->state.dynamic = false; npc_parse_mob2(data); npc_delay_mob += data->num; - } else { - int index = map_addmobtolist(data->m, data); - if( index >= 0 ) { - data->state.dynamic = true; - // check if target map has players - // (usually shouldn't occur when map server is just starting, - // but not the case when we do @reloadscript - if (map[data->m].users > 0) - npc_parse_mob2(data); - npc_cache_mob += data->num; - } else { - // mobcache is full - // create them as delayed with one second - data->state.dynamic = false; - data->delay1 = 1000; - data->delay2 = 1000; - npc_parse_mob2(data); - npc_delay_mob += data->num; - } } npc_mob++; |