diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-12-22 18:08:37 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-12-22 18:08:37 +0000 |
commit | 66be3d8e66260ca148d768b887695729ded98abb (patch) | |
tree | c33bb1ccfd358b98cec22e750a395285ba5df31e /src/map | |
parent | 23d8fb13a79b0378db2ef6860d9b0b68cfacb9d6 (diff) | |
download | hercules-66be3d8e66260ca148d768b887695729ded98abb.tar.gz hercules-66be3d8e66260ca148d768b887695729ded98abb.tar.bz2 hercules-66be3d8e66260ca148d768b887695729ded98abb.tar.xz hercules-66be3d8e66260ca148d768b887695729ded98abb.zip |
- Corrected mob spawn utilization of the delay1/delay2 values (one is respawn delay base, the second is random variance added on top of it). Cleaned up related code.
- Changed abit map_add_block to prevent adding a player object which is invalid (not authed, waiting to be disconnected)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11964 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/map.c | 22 | ||||
-rw-r--r-- | src/map/map.h | 3 | ||||
-rw-r--r-- | src/map/mob.c | 23 | ||||
-rw-r--r-- | src/map/npc.c | 5 |
4 files changed, 22 insertions, 31 deletions
diff --git a/src/map/map.c b/src/map/map.c index e3c5aacbe..6050d6ed4 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -349,10 +349,6 @@ int map_addblock_sub (struct block_list *bl, int flag) return 1; } -#ifdef CELL_NOSTACK - map_addblcell(bl); -#endif - pos = x/BLOCK_SIZE+(y/BLOCK_SIZE)*map[m].bxs; if (bl->type == BL_MOB) { bl->next = map[m].block_mob[pos]; @@ -361,14 +357,13 @@ int map_addblock_sub (struct block_list *bl, int flag) map[m].block_mob[pos] = bl; map[m].block_mob_count[pos]++; } else { - bl->next = map[m].block[pos]; - bl->prev = &bl_head; - if (bl->next) bl->next->prev = bl; - map[m].block[pos] = bl; - map[m].block_count[pos]++; if (bl->type == BL_PC && flag) { struct map_session_data* sd; + if (!sd->state.auth) { + ShowError("map_addblock: Attempted to add a non-authed player (%d:%d)!\n", sd->status.account_id, sd->status.char_id); + return 1; + } if (map[m].users++ == 0 && battle_config.dynamic_mobs) //Skotlex map_spawnmobs(m); sd = (struct map_session_data*)bl; @@ -378,8 +373,17 @@ int map_addblock_sub (struct block_list *bl, int flag) pet_menu(sd, 3); //Option 3 is return to egg. } } + bl->next = map[m].block[pos]; + bl->prev = &bl_head; + if (bl->next) bl->next->prev = bl; + map[m].block[pos] = bl; + map[m].block_count[pos]++; } +#ifdef CELL_NOSTACK + map_addblcell(bl); +#endif + return 0; } diff --git a/src/map/map.h b/src/map/map.h index 6d06bc599..32b3ed6d5 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -924,8 +924,7 @@ struct mob_data { unsigned int tdmg; //Stores total damage given to the mob, for exp calculations. [Skotlex] int level; int target_id,attacked_id; - unsigned int next_walktime; - unsigned int last_deadtime,last_spawntime,last_thinktime,last_linktime; + unsigned int next_walktime,last_thinktime,last_linktime; short move_fail_count; short lootitem_count; short min_chase; diff --git a/src/map/mob.c b/src/map/mob.c index 1c28584d3..9830dff0e 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -612,24 +612,19 @@ static int mob_delayspawn(int tid, unsigned int tick, int m, int n) *------------------------------------------*/ int mob_setdelayspawn(struct mob_data *md) { - unsigned int spawntime, spawntime1, spawntime2, spawntime3; - + unsigned int spawntime; if (!md->spawn) //Doesn't has respawn data! return unit_free(&md->bl,1); - spawntime1 = md->last_spawntime + md->spawn->delay1; - spawntime2 = md->last_deadtime + md->spawn->delay2; - spawntime3 = gettick() + 5000 + rand()%5000; //Lupus - // spawntime = max(spawntime1,spawntime2,spawntime3); - if (DIFF_TICK(spawntime1, spawntime2) > 0) - spawntime = spawntime1; - else - spawntime = spawntime2; - if (DIFF_TICK(spawntime3, spawntime) > 0) - spawntime = spawntime3; + spawntime = md->spawn->delay1; //Base respawn time + if (md->spawn->delay2) //random variance + spawntime+= rand()%md->spawn->delay2; + + if (spawntime < 5000) //Min respawn time (is it needed?) + spawntime = 5000; - add_timer(spawntime, mob_delayspawn, md->bl.id, 0); + add_timer(gettick()+spawntime, mob_delayspawn, md->bl.id, 0); return 0; } @@ -646,7 +641,6 @@ int mob_spawn (struct mob_data *md) int i=0; unsigned int c =0, tick = gettick(); - md->last_spawntime = md->last_thinktime = tick; if (md->bl.prev != NULL) unit_remove_map(&md->bl,2); else @@ -2221,7 +2215,6 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) } mob_deleteslave(md); - md->last_deadtime=tick; map_freeblock_unlock(); diff --git a/src/map/npc.c b/src/map/npc.c index 3b9acc89c..e95a32c71 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2182,11 +2182,6 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c return strchr(start,'\n');// skip and continue } - //Fixed according to latest kRO update (needs optimization) - temp = mob.delay1; - mob.delay1 += mob.delay2; - mob.delay2 = temp; - mob.num = (unsigned short)num; mob.class_ = (short) class_; mob.x = (unsigned short)x; |