From 436313b0e5c3bc6f0d04cfdcf9d2c9db5964ce15 Mon Sep 17 00:00:00 2001 From: skotlex Date: Mon, 12 Jun 2006 14:55:35 +0000 Subject: - Made guild member exp an unsigned int. - Modified npc_click to receive the bl that was clicked directly. Also cleaned it up so it isn't as easy to crash the server with invalid ids <.< - Moved npc_checknear to npc_checknear2 and added npc_checknear. The near version receives a bl, checks it's validity, and returns a TBL_NPC object, near2 does the same but doesn't checks for type NPC. The first returns a pointer, the second returns 1 on fail, 0 success. - Also uncommented various npc_checknear calls in the code, who's idea was to comment them out so you could exploit npcs from afar with custom packets? - Added overflow checks for bonus settings mdef_rate/def_rate. - Added missing update of INT after a buf. - Small cleanup of how SC_BLEEDING works. - Fixed party_foreach_samemap invoking the function on the CASTER instead of on the party members. - Added clif_parse_ActionRequest_sub to handle player commands, is used from npc_click or any other function that needs to "re-route" a player's request. - Modified clif_parse_NpcClicked to handle the different situations with different bl-objects (attack on players/mobs, click on npcs or mobs with npc attached) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7103 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/clif.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index bfa90ff8d..16714e21b 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8804,16 +8804,9 @@ void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) { WFIFOSET(fd,packet_len_table[0xc2]); } -/*========================================== - * - *------------------------------------------ - */ -void clif_parse_ActionRequest(int fd, struct map_session_data *sd) { - unsigned int tick; +static void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick) +{ unsigned char buf[64]; - int action_type, target_id; - RFIFOHEAD(fd); - if (pc_isdead(sd)) { clif_clearchar_area(&sd->bl, 1); return; @@ -8825,14 +8818,9 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) { sd->sc.data[SC_BLADESTOP].timer != -1)) return; - tick = gettick(); - pc_stop_walking(sd, 1); pc_stop_attack(sd); - target_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); - action_type = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); - if(target_id<0 && -target_id == sd->bl.id) // for disguises [Valaris] target_id = sd->bl.id; @@ -8895,7 +8883,7 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) { return; } pc_setstand(sd); - skill_gangsterparadise(sd, 0); // ギャングスターパラダイス解除 fixed Valaris + skill_gangsterparadise(sd, 0); skill_rest(sd, 0); // TK_HPTIME standing up mode [Dralnu] WBUFW(buf, 0) = 0x8a; WBUFL(buf, 2) = sd->bl.id; @@ -8905,6 +8893,18 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) { } } +/*========================================== + * + *------------------------------------------ + */ +void clif_parse_ActionRequest(int fd, struct map_session_data *sd) { + clif_parse_ActionRequest_sub(sd, + RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]), + RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]), + gettick() + ); +} + /*========================================== * *------------------------------------------ @@ -9310,6 +9310,7 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd) */ void clif_parse_NpcClicked(int fd,struct map_session_data *sd) { + struct block_list *bl; RFIFOHEAD(fd); if(pc_isdead(sd)) { @@ -9320,7 +9321,23 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd) if (clif_cant_act(sd)) return; - npc_click(sd,RFIFOL(fd,2)); + bl = map_id2bl(RFIFOL(fd,2)); + if (!bl) return; + switch (bl->type) { + case BL_MOB: + if (((TBL_MOB *)bl)->nd) + npc_click(sd, bl); + else + clif_parse_ActionRequest_sub(sd, 0x07, bl->id, gettick()); + break; + case BL_PC: + clif_parse_ActionRequest_sub(sd, 0x07, bl->id, gettick()); + break; + case BL_NPC: + npc_click(sd,bl); + break; + } + return; } /*========================================== -- cgit v1.2.3-70-g09d2