diff options
author | gepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-01-09 23:18:01 +0000 |
---|---|---|
committer | gepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-01-09 23:18:01 +0000 |
commit | d1ef5355c484c6de06224551caf977b0ae1d3497 (patch) | |
tree | 9c7874175ab390678ce6797dba51b6a3f031d8da /src | |
parent | 77c0db2f2cf420d70ce9c00e46d72d3506f5c9df (diff) | |
download | hercules-d1ef5355c484c6de06224551caf977b0ae1d3497.tar.gz hercules-d1ef5355c484c6de06224551caf977b0ae1d3497.tar.bz2 hercules-d1ef5355c484c6de06224551caf977b0ae1d3497.tar.xz hercules-d1ef5355c484c6de06224551caf977b0ae1d3497.zip |
Fixed battle configs `boss_delay_spawn`, `plant_delay_spawn` and `mob_delay_spawn` not being properly applied if changed during runtime (with `@reloadbattleconf` or `setbattleflag`) (bugreport:5204)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15416 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/map/mob.c | 20 | ||||
-rw-r--r-- | src/map/npc.c | 25 |
2 files changed, 21 insertions, 24 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index 427b0ae5f..585ebf0af 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -789,7 +789,8 @@ int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data) *------------------------------------------*/ int mob_setdelayspawn(struct mob_data *md) { - unsigned int spawntime; + unsigned int spawntime, mode; + struct mob_db *db; if (!md->spawn) //Doesn't has respawn data! return unit_free(&md->bl,CLR_DEAD); @@ -798,6 +799,23 @@ int mob_setdelayspawn(struct mob_data *md) if (md->spawn->delay2) //random variance spawntime+= rand()%md->spawn->delay2; + //Apply the spawn delay fix [Skotlex] + db = mob_db(md->spawn->class_); + mode = db->status.mode; + if (mode & MD_BOSS) { //Bosses + if (battle_config.boss_spawn_delay != 100) { + // Divide by 100 first to prevent overflows + //(precision loss is minimal as duration is in ms already) + spawntime = spawntime/100*battle_config.boss_spawn_delay; + } + } else if (mode&MD_PLANT) { //Plants + if (battle_config.plant_spawn_delay != 100) { + spawntime = spawntime/100*battle_config.plant_spawn_delay; + } + } else if (battle_config.mob_spawn_delay != 100) { //Normal mobs + spawntime = spawntime/100*battle_config.mob_spawn_delay; + } + if (spawntime < 500) //Min respawn time (is it needed?) spawntime = 500; diff --git a/src/map/npc.c b/src/map/npc.c index 0d112b937..eb99d8243 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2852,7 +2852,7 @@ void npc_parse_mob2(struct spawn_data* mob) static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath) { - int num, class_, mode, m,x,y,xs,ys, i,j; + int num, class_, m,x,y,xs,ys, i,j; char mapname[32]; struct spawn_data mob, *data; struct mob_db* db; @@ -2917,28 +2917,6 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c mob.xs = mob.ys = -1; } - db = mob_db(class_); - //Apply the spawn delay fix [Skotlex] - mode = db->status.mode; - if (mode & MD_BOSS) { //Bosses - if (battle_config.boss_spawn_delay != 100) - { // Divide by 100 first to prevent overflows - //(precision loss is minimal as duration is in ms already) - mob.delay1 = mob.delay1/100*battle_config.boss_spawn_delay; - mob.delay2 = mob.delay2/100*battle_config.boss_spawn_delay; - } - } else if (mode&MD_PLANT) { //Plants - if (battle_config.plant_spawn_delay != 100) - { - mob.delay1 = mob.delay1/100*battle_config.plant_spawn_delay; - mob.delay2 = mob.delay2/100*battle_config.plant_spawn_delay; - } - } else if (battle_config.mob_spawn_delay != 100) - { //Normal mobs - mob.delay1 = mob.delay1/100*battle_config.mob_spawn_delay; - mob.delay2 = mob.delay2/100*battle_config.mob_spawn_delay; - } - if(mob.delay1>0xfffffff || mob.delay2>0xfffffff) { ShowError("npc_parse_mob: Invalid spawn delays %u %u (file '%s', line '%d').\n", mob.delay1, mob.delay2, filepath, strline(buffer,start-buffer)); return strchr(start,'\n');// skip and continue @@ -2960,6 +2938,7 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c } //Update mob spawn lookup database + db = mob_db(class_); for( i = 0; i < ARRAYLENGTH(db->spawn); ++i ) { if (map[mob.m].index == db->spawn[i].mapindex) |