summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--src/map/clif.c10
-rw-r--r--src/map/map.c53
-rw-r--r--src/map/map.h6
-rw-r--r--src/map/unit.c41
5 files changed, 63 insertions, 49 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 81387859a..6e372f5f4 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2008/01/03
+ * Moved extra junk from map_addblock/map_delblock to where it logically
+ belongs (loadendack/unit_remove_map), removed flags and _sub macros
* Removed map_data's block_count, as (quote Yor/ja2160),
"Perhaps useful for debug, but uses memory AND CPU for nothing."
(block lists are linked lists, they don't need count tracking)
diff --git a/src/map/clif.c b/src/map/clif.c
index 9f1625b7a..4d5533be8 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7724,6 +7724,9 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
pc_setinvincibletimer(sd,battle_config.pc_invincible_time);
}
+ if (map[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs) //Skotlex
+ map_spawnmobs(sd->bl.m);
+
map_addblock(&sd->bl);
clif_spawn(&sd->bl);
@@ -7768,6 +7771,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
// must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange)
map_foreachinarea(clif_getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd);
+ //TODO: merge it with the code below
+ if (battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m) && sd->pd)
+ { //Return the pet to egg. [Skotlex]
+ clif_displaymessage(sd->fd, "Pets are not allowed in Guild Wars.");
+ pet_menu(sd, 3); //Option 3 is return to egg.
+ }
+
// pet
if(sd->pd) {
map_addblock(&sd->pd->bl);
diff --git a/src/map/map.c b/src/map/map.c
index 0a7bd952d..0115bb02b 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -275,11 +275,9 @@ void map_delblcell(struct block_list *bl)
/*==========================================
* Adds a block to the map.
- * If flag is 1, then the block was just added,
- * otherwise it is part of a transition.
* Returns 0 on success, 1 on failure (illegal coordinates).
*------------------------------------------*/
-int map_addblock_sub (struct block_list *bl, int flag)
+int map_addblock(struct block_list* bl)
{
int m, x, y, pos;
@@ -287,7 +285,7 @@ int map_addblock_sub (struct block_list *bl, int flag)
if (bl->prev != NULL) {
ShowError("map_addblock: bl->prev != NULL\n");
- return 0;
+ return 1;
}
m = bl->m;
@@ -303,29 +301,15 @@ int map_addblock_sub (struct block_list *bl, int flag)
ShowError("map_addblock: out-of-bounds coordinates (\"%s\",%d,%d), map is %dx%d\n", map[m].name, x, y, map[m].xs, map[m].ys);
return 1;
}
-
+
pos = x/BLOCK_SIZE+(y/BLOCK_SIZE)*map[m].bxs;
+
if (bl->type == BL_MOB) {
bl->next = map[m].block_mob[pos];
bl->prev = &bl_head;
if (bl->next) bl->next->prev = bl;
map[m].block_mob[pos] = bl;
} else {
- if (bl->type == BL_PC && flag)
- {
- struct map_session_data* sd = (struct map_session_data*)bl;
- 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);
- if (battle_config.pet_no_gvg && map_flag_gvg(m) && sd->pd)
- { //Return the pet to egg. [Skotlex]
- clif_displaymessage(sd->fd, "Pets are not allowed in Guild Wars.");
- 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;
@@ -341,12 +325,10 @@ int map_addblock_sub (struct block_list *bl, int flag)
/*==========================================
* Removes a block from the map.
- * If flag is 1, then the block is removed for good
- * otherwise it is part of a transition.
*------------------------------------------*/
-int map_delblock_sub (struct block_list *bl, int flag)
+int map_delblock(struct block_list* bl)
{
- int b;
+ int pos;
nullpo_retr(0, bl);
// ?にblocklistから?けている
@@ -362,20 +344,16 @@ int map_delblock_sub (struct block_list *bl, int flag)
map_delblcell(bl);
#endif
- b = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*map[bl->m].bxs;
-
- if (bl->type == BL_PC && flag)
- if (--map[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex]
- map_removemobs(bl->m);
+ pos = bl->x/BLOCK_SIZE+(bl->y/BLOCK_SIZE)*map[bl->m].bxs;
if (bl->next)
bl->next->prev = bl->prev;
if (bl->prev == &bl_head) {
// リストの頭なので、map[]のblock_listを更新する
if (bl->type == BL_MOB) {
- map[bl->m].block_mob[b] = bl->next;
+ map[bl->m].block_mob[pos] = bl->next;
} else {
- map[bl->m].block[b] = bl->next;
+ map[bl->m].block[pos] = bl->next;
}
} else {
bl->prev->next = bl->next;
@@ -403,6 +381,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
bl->y = y1;
return 0;
}
+
//TODO: Perhaps some outs of bounds checking should be placed here?
if (bl->type&BL_CHAR) {
skill_unit_move(bl,tick,2);
@@ -422,18 +401,20 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
status_change_end(bl, SC_MAGICROD, -1);
}
} else
- if (bl->type == BL_NPC) npc_unsetcells((TBL_NPC*)bl);
+ if (bl->type == BL_NPC)
+ npc_unsetcells((TBL_NPC*)bl);
- if (moveblock) map_delblock_sub(bl,0);
+ if (moveblock) map_delblock(bl);
#ifdef CELL_NOSTACK
else map_delblcell(bl);
#endif
bl->x = x1;
bl->y = y1;
- if (moveblock) map_addblock_sub(bl,0);
+ if (moveblock) map_addblock(bl);
#ifdef CELL_NOSTACK
else map_addblcell(bl);
#endif
+
if (bl->type&BL_CHAR) {
skill_unit_move(bl,tick,3);
if (sc) {
@@ -447,7 +428,9 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
}
}
} else
- if (bl->type == BL_NPC) npc_setcells((TBL_NPC*)bl);
+ if (bl->type == BL_NPC)
+ npc_setcells((TBL_NPC*)bl);
+
return 0;
}
diff --git a/src/map/map.h b/src/map/map.h
index 611b19f42..fa165609d 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1275,10 +1275,8 @@ int map_freeblock(struct block_list *bl);
int map_freeblock_lock(void);
int map_freeblock_unlock(void);
// block関連
-int map_addblock_sub(struct block_list *, int);
-int map_delblock_sub(struct block_list *, int);
-#define map_addblock(bl) map_addblock_sub(bl,1)
-#define map_delblock(bl) map_delblock_sub(bl,1)
+int map_addblock(struct block_list* bl);
+int map_delblock(struct block_list* bl);
int map_moveblock(struct block_list *, int, int, unsigned int);
int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int range, int type, ...);
int map_foreachinshootrange(int (*func)(struct block_list*,va_list), struct block_list* center, int range, int type, ...);
diff --git a/src/map/unit.c b/src/map/unit.c
index c8ae55bc3..b1ee72a2f 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1652,7 +1652,10 @@ int unit_remove_map(struct block_list *bl, int clrtype)
skill_cleartimerskill(bl); // タイマースキルクリア
}
- if(bl->type == BL_PC) {
+ switch( bl->type )
+ {
+ case BL_PC:
+ {
struct map_session_data *sd = (struct map_session_data*)bl;
//Leave/reject all invitations.
@@ -1695,28 +1698,41 @@ int unit_remove_map(struct block_list *bl, int clrtype)
}
party_send_dot_remove(sd);//minimap dot fix [Kevin]
guild_send_dot_remove(sd);
- } else if(bl->type == BL_MOB) {
+
+ if (--map[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex]
+ map_removemobs(bl->m);
+
+ break;
+ }
+ case BL_MOB:
+ {
struct mob_data *md = (struct mob_data*)bl;
md->target_id=0;
md->attacked_id=0;
md->state.skillstate= MSS_IDLE;
- } else if (bl->type == BL_PET) {
+
+ break;
+ }
+ case BL_PET:
+ {
struct pet_data *pd = (struct pet_data*)bl;
- if(pd->pet.intimate <= 0 &&
- !(pd->msd && pd->msd->state.waitingdisconnect)
- ) { //If logging out, this is deleted on unit_free
+ if( pd->pet.intimate <= 0 && !(pd->msd && pd->msd->state.waitingdisconnect) )
+ { //If logging out, this is deleted on unit_free
clif_clearunit_area(bl,clrtype);
map_delblock(bl);
unit_free(bl,0);
map_freeblock_unlock();
return 0;
}
- } else if (bl->type == BL_HOM) {
+
+ break;
+ }
+ case BL_HOM:
+ {
struct homun_data *hd = (struct homun_data *) bl;
ud->canact_tick = ud->canmove_tick; //It appears HOM do reset the can-act tick.
- if(!hd->homunculus.intimacy &&
- !(hd->master && hd->master->state.waitingdisconnect)
- ) { //If logging out, this is deleted on unit_free
+ if(!hd->homunculus.intimacy && !(hd->master && hd->master->state.waitingdisconnect) )
+ { //If logging out, this is deleted on unit_free
clif_emotion(bl, 28) ; //sob
clif_clearunit_area(bl,clrtype);
map_delblock(bl);
@@ -1724,7 +1740,12 @@ int unit_remove_map(struct block_list *bl, int clrtype)
map_freeblock_unlock();
return 0;
}
+
+ break;
}
+ default: ;// do nothing
+ }
+
clif_clearunit_area(bl,clrtype);
map_delblock(bl);
map_freeblock_unlock();