From 2d8dd9049a22034d6727f082d428f8c10c8c8606 Mon Sep 17 00:00:00 2001 From: mekolat Date: Tue, 16 Jun 2015 18:19:51 -0400 Subject: also send (towards) when enter area --- src/map/clif.cpp | 156 ++++++++++++++++++++++++++----------------------------- 1 file changed, 73 insertions(+), 83 deletions(-) (limited to 'src') diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 015c703..c120428 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -217,7 +217,7 @@ AString clif_validate_chat(dumb_ptr sd, ChatType type, XString */ static void clif_send_sub(dumb_ptr bl, const Buffer& buf, - dumb_ptr src_bl, SendWho type) + dumb_ptr src_bl, SendWho type, short min_version) { nullpo_retv(bl); dumb_ptr sd = bl->is_player(); @@ -246,6 +246,7 @@ void clif_send_sub(dumb_ptr bl, const Buffer& buf, if (sd->sess != nullptr) { { + if (sd->client_version >= min_version) { send_buffer(sd->sess, buf); } @@ -258,7 +259,7 @@ void clif_send_sub(dumb_ptr bl, const Buffer& buf, *------------------------------------------ */ static -int clif_send(const Buffer& buf, dumb_ptr bl, SendWho type) +int clif_send(const Buffer& buf, dumb_ptr bl, SendWho type, short min_version) { int x0 = 0, x1 = 0, y0 = 0, y1 = 0; @@ -323,14 +324,14 @@ int clif_send(const Buffer& buf, dumb_ptr bl, SendWho type) break; case SendWho::AREA: case SendWho::AREA_WOS: - map_foreachinarea(std::bind(clif_send_sub, ph::_1, buf, bl, type), + map_foreachinarea(std::bind(clif_send_sub, ph::_1, buf, bl, type, min_version), bl->bl_m, bl->bl_x - AREA_SIZE, bl->bl_y - AREA_SIZE, bl->bl_x + AREA_SIZE, bl->bl_y + AREA_SIZE, BL::PC); break; case SendWho::AREA_CHAT_WOC: - map_foreachinarea(std::bind(clif_send_sub, ph::_1, buf, bl, SendWho::AREA_CHAT_WOC), + map_foreachinarea(std::bind(clif_send_sub, ph::_1, buf, bl, SendWho::AREA_CHAT_WOC, min_version), bl->bl_m, bl->bl_x - (AREA_SIZE), bl->bl_y - (AREA_SIZE), bl->bl_x + (AREA_SIZE), bl->bl_y + (AREA_SIZE), @@ -380,6 +381,7 @@ int clif_send(const Buffer& buf, dumb_ptr bl, SendWho type) (sd->bl_x < x0 || sd->bl_y < y0 || sd->bl_x > x1 || sd->bl_y > y1)) continue; + if (sd->client_version >= min_version) { send_buffer(sd->sess, buf); } @@ -395,6 +397,7 @@ int clif_send(const Buffer& buf, dumb_ptr bl, SendWho type) { if (sd->partyspy == p.party_id) { + if (sd->client_version >= min_version) { send_buffer(sd->sess, buf); } @@ -410,7 +413,8 @@ int clif_send(const Buffer& buf, dumb_ptr bl, SendWho type) dumb_ptr sd = bl->is_player(); { - send_buffer(sd->sess, buf); + if (sd->client_version >= min_version) + send_buffer(sd->sess, buf); } } break; @@ -528,7 +532,7 @@ int clif_dropflooritem(dumb_ptr fitem) Buffer buf; clif_set009e(fitem, buf); - clif_send(buf, fitem, SendWho::AREA); + clif_send(buf, fitem, SendWho::AREA, MIN_CLIENT_VERSION); return 0; } @@ -547,7 +551,7 @@ int clif_clearflooritem(dumb_ptr fitem, Session *s) if (!s) { Buffer buf = create_fpacket<0x00a1, 6>(fixed_a1); - clif_send(buf, fitem, SendWho::AREA); + clif_send(buf, fitem, SendWho::AREA, MIN_CLIENT_VERSION); } else { @@ -572,14 +576,14 @@ int clif_clearchar(dumb_ptr bl, BeingRemoveWhy type) { fixed_80.type = BeingRemoveWhy::GONE; Buffer buf = create_fpacket<0x0080, 7>(fixed_80); - clif_send(buf, bl, SendWho::AREA); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); } else { fixed_80.type = type; Buffer buf = create_fpacket<0x0080, 7>(fixed_80); clif_send(buf, bl, - type == BeingRemoveWhy::DEAD ? SendWho::AREA : SendWho::AREA_WOS); + type == BeingRemoveWhy::DEAD ? SendWho::AREA : SendWho::AREA_WOS, MIN_CLIENT_VERSION); } return 0; @@ -834,21 +838,6 @@ void clif_mob007b(dumb_ptr md, Buffer& buf) * Packet to send server's mob walkpath data *------------------------------------------ */ -static -void clif_0225_being_move3_sub(dumb_ptr bl, const Buffer& buf) -{ - nullpo_retv(bl); - dumb_ptr sd = bl->is_player(); - - if (sd->sess != nullptr) - { - if(sd->client_version >= 3) // require 1.5.5.23 or above - { - send_buffer(sd->sess, buf); - } - } -} - static int clif_0225_being_move3(dumb_ptr md) { @@ -869,11 +858,7 @@ int clif_0225_being_move3(dumb_ptr md) Buffer buf = create_vpacket<0x0225, 14, 1>(head_225, repeat_225); - map_foreachinarea(std::bind(clif_0225_being_move3_sub, ph::_1, buf), - md->bl_m, - md->bl_x - AREA_SIZE, md->bl_y - AREA_SIZE, - md->bl_x + AREA_SIZE, md->bl_y + AREA_SIZE, - BL::PC); + clif_send(buf, md, SendWho::AREA, 3); return 0; } @@ -928,7 +913,7 @@ int clif_spawnpc(dumb_ptr sd) Buffer buf; clif_set0078_alt_1d9(sd, buf); - clif_send(buf, sd, SendWho::AREA_WOS); + clif_send(buf, sd, SendWho::AREA_WOS, MIN_CLIENT_VERSION); clif_pvpstatus(sd); @@ -967,17 +952,17 @@ int clif_spawnnpc(dumb_ptr nd) fixed_7c.pos.y = nd->bl_y; Buffer buf = create_fpacket<0x007c, 41>(fixed_7c); - clif_send(buf, nd, SendWho::AREA); + clif_send(buf, nd, SendWho::AREA, MIN_CLIENT_VERSION); */ Buffer buf; clif_npc0078(nd, buf); - clif_send(buf, nd, SendWho::AREA); + clif_send(buf, nd, SendWho::AREA, MIN_CLIENT_VERSION); if(nd->sit == DamageType::SIT) { Buffer buff; clif_sitnpc_sub(buff, nd, nd->sit); - clif_send(buff, nd, SendWho::AREA); + clif_send(buff, nd, SendWho::AREA, MIN_CLIENT_VERSION); } return 0; @@ -1036,12 +1021,12 @@ int clif_spawnmob(dumb_ptr md) fixed_7c.pos.x = md->bl_x; fixed_7c.pos.y = md->bl_y; Buffer buf = create_fpacket<0x007c, 41>(fixed_7c); - clif_send(buf, md, SendWho::AREA); + clif_send(buf, md, SendWho::AREA, MIN_CLIENT_VERSION); } Buffer buf; clif_mob0078(md, buf); - clif_send(buf, md, SendWho::AREA); + clif_send(buf, md, SendWho::AREA, MIN_CLIENT_VERSION); return 0; } @@ -1095,7 +1080,7 @@ int clif_movechar(dumb_ptr sd) Buffer buf; clif_set007b(sd, buf); - clif_send(buf, sd, SendWho::AREA_WOS); + clif_send(buf, sd, SendWho::AREA_WOS, MIN_CLIENT_VERSION); if (battle_config.save_clothcolor == 1 && sd->status.clothes_color > 0) clif_changelook(sd, LOOK::CLOTHES_COLOR, @@ -1187,7 +1172,7 @@ void clif_fixpos(dumb_ptr bl) fixed_88.y = bl->bl_y; Buffer buf = create_fpacket<0x0088, 10>(fixed_88); - clif_send(buf, bl, SendWho::AREA); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); } /*========================================== @@ -1865,9 +1850,9 @@ int clif_changelook_towards(dumb_ptr bl, LOOK type, int val, Buffer buf = create_fpacket<0x01d7, 11>(fixed_1d7); if (dstsd) - clif_send(buf, dstsd, SendWho::SELF); + clif_send(buf, dstsd, SendWho::SELF, MIN_CLIENT_VERSION); else - clif_send(buf, bl, SendWho::AREA); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); } else { @@ -1879,9 +1864,9 @@ int clif_changelook_towards(dumb_ptr bl, LOOK type, int val, Buffer buf = create_fpacket<0x01d7, 11>(fixed_1d7); if (dstsd) - clif_send(buf, dstsd, SendWho::SELF); + clif_send(buf, dstsd, SendWho::SELF, MIN_CLIENT_VERSION); else - clif_send(buf, bl, SendWho::AREA); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); } return 0; } @@ -2045,7 +2030,7 @@ int clif_misceffect(dumb_ptr bl, int type) fixed_19b.type = type; Buffer buf = create_fpacket<0x019b, 10>(fixed_19b); - clif_send(buf, bl, SendWho::AREA); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); return 0; } @@ -2054,30 +2039,31 @@ void clif_map_pvp(dumb_ptr sd) { nullpo_retv(sd); - if (sd->client_version < 2) // require 1.5.5.9 or above - return; - Packet_Fixed<0x0199> fixed_199; fixed_199.status = sd->bl_m->flag.get(MapFlag::PVP)? 1: 0; Buffer buf = create_fpacket<0x0199, 4>(fixed_199); - clif_send(buf, sd, SendWho::SELF); + clif_send(buf, sd, SendWho::SELF, 2); } -void clif_pvpstatus(dumb_ptr sd) +static +void clif_pvpstatus_towards(Buffer& buf, dumb_ptr sd) { nullpo_retv(sd); - if (sd->client_version < 2) // require 1.5.5.9 or above - return; - Packet_Fixed<0x019a> fixed_19a; fixed_19a.block_id = sd->bl_id; fixed_19a.rank = sd->state.pvp_rank; fixed_19a.channel = sd->state.pvpchannel; - Buffer buf = create_fpacket<0x019a, 14>(fixed_19a); + buf = create_fpacket<0x019a, 14>(fixed_19a); +} - clif_send(buf, sd, SendWho::AREA); +void clif_pvpstatus(dumb_ptr sd) +{ + nullpo_retv(sd); + Buffer buf; + clif_pvpstatus_towards(buf, sd); + clif_send(buf, sd, SendWho::AREA, 2); } /*========================================== @@ -2101,7 +2087,7 @@ int clif_changeoption(dumb_ptr bl) fixed_119.zero = 0; Buffer buf = create_fpacket<0x0119, 13>(fixed_119); - clif_send(buf, bl, SendWho::AREA); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); return 0; } @@ -2133,7 +2119,7 @@ int clif_useitemack(dumb_ptr sd, IOff0 index, int amount, fixed_1c8.amount = amount; fixed_1c8.ok = ok; Buffer buf = create_fpacket<0x01c8, 13>(fixed_1c8); - clif_send(buf, sd, SendWho::SELF); + clif_send(buf, sd, SendWho::SELF, MIN_CLIENT_VERSION); } return 0; @@ -2388,6 +2374,10 @@ void clif_getareachar_pc(dumb_ptr sd, } send_buffer(sd->sess, buf); + Buffer buff; + clif_pvpstatus_towards(buff, dstsd); + clif_send(buff, sd, SendWho::SELF, 2); + if (battle_config.save_clothcolor == 1 && dstsd->status.clothes_color > 0) clif_changelook(dstsd, LOOK::CLOTHES_COLOR, dstsd->status.clothes_color); @@ -2431,7 +2421,7 @@ int clif_movemob(dumb_ptr md) Buffer buf; clif_mob007b(md, buf); - clif_send(buf, md, SendWho::AREA); + clif_send(buf, md, SendWho::AREA, MIN_CLIENT_VERSION); clif_0225_being_move3(md); return 0; @@ -2449,13 +2439,13 @@ int clif_fixmobpos(dumb_ptr md) { Buffer buf; clif_mob007b(md, buf); - clif_send(buf, md, SendWho::AREA); + clif_send(buf, md, SendWho::AREA, MIN_CLIENT_VERSION); } else { Buffer buf; clif_mob0078(md, buf); - clif_send(buf, md, SendWho::AREA); + clif_send(buf, md, SendWho::AREA, MIN_CLIENT_VERSION); } return 0; @@ -2473,13 +2463,13 @@ int clif_fixpcpos(dumb_ptr sd) { Buffer buf; clif_set007b(sd, buf); - clif_send(buf, sd, SendWho::AREA); + clif_send(buf, sd, SendWho::AREA, MIN_CLIENT_VERSION); } else { Buffer buf; clif_set0078_main_1d8(sd, buf); - clif_send(buf, sd, SendWho::AREA); + clif_send(buf, sd, SendWho::AREA, MIN_CLIENT_VERSION); } clif_changelook_accessories(sd, nullptr); @@ -2512,7 +2502,7 @@ int clif_damage(dumb_ptr src, dumb_ptr dst, fixed_8a.damage_type = type; fixed_8a.damage2 = 0; Buffer buf = create_fpacket<0x008a, 29>(fixed_8a); - clif_send(buf, src, SendWho::AREA); + clif_send(buf, src, SendWho::AREA, MIN_CLIENT_VERSION); return 0; } @@ -2834,7 +2824,7 @@ int clif_skill_damage(dumb_ptr src, dumb_ptr dst, fixed_1de.div = div; fixed_1de.type_or_hit = (type > 0) ? type : skill_get_hit(skill_id); Buffer buf = create_fpacket<0x01de, 33>(fixed_1de); - clif_send(buf, src, SendWho::AREA); + clif_send(buf, src, SendWho::AREA, MIN_CLIENT_VERSION); return 0; } @@ -2852,7 +2842,7 @@ int clif_status_change(dumb_ptr bl, StatusChange type, int flag) fixed_196.block_id = bl->bl_id; fixed_196.flag = flag; Buffer buf = create_fpacket<0x0196, 9>(fixed_196); - clif_send(buf, bl, SendWho::AREA); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); return 0; } @@ -2882,7 +2872,7 @@ void clif_GMmessage(dumb_ptr bl, XString mes, int flag) (flag == 1) ? SendWho::ALL_SAMEMAP : (flag == 2) ? SendWho::AREA : (flag == 3) ? SendWho::SELF : - SendWho::ALL_CLIENT); + SendWho::ALL_CLIENT, MIN_CLIENT_VERSION); } /*========================================== @@ -2899,7 +2889,7 @@ void clif_resurrection(dumb_ptr bl, int type) Buffer buf = create_fpacket<0x0148, 8>(fixed_148); clif_send(buf, bl, - type == 1 ? SendWho::AREA : SendWho::AREA_WOS); + type == 1 ? SendWho::AREA : SendWho::AREA_WOS, MIN_CLIENT_VERSION); } /*========================================== @@ -2986,7 +2976,7 @@ int clif_party_info(PartyPair p, Session *s) if (sd != nullptr) { Buffer buf = create_vpacket<0x00fb, 28, 46>(head_fb, repeat_fb); - clif_send(buf, sd, SendWho::PARTY); + clif_send(buf, sd, SendWho::PARTY, MIN_CLIENT_VERSION); } return 0; } @@ -3063,7 +3053,7 @@ void clif_party_option(PartyPair p, dumb_ptr sd, int flag) if (flag == 0) { Buffer buf = create_fpacket<0x0101, 6>(fixed_101); - clif_send(buf, sd, SendWho::PARTY); + clif_send(buf, sd, SendWho::PARTY, MIN_CLIENT_VERSION); } else { @@ -3097,7 +3087,7 @@ void clif_party_leaved(PartyPair p, dumb_ptr sd, if (sd != nullptr) { Buffer buf = create_fpacket<0x0105, 31>(fixed_105); - clif_send(buf, sd, SendWho::PARTY); + clif_send(buf, sd, SendWho::PARTY, MIN_CLIENT_VERSION); } } else if (sd != nullptr) @@ -3127,7 +3117,7 @@ void clif_party_message(PartyPair p, AccountId account_id, XString mes) Packet_Head<0x0109> head_109; head_109.account_id = account_id; Buffer buf = create_vpacket<0x0109, 8, 1>(head_109, mes); - clif_send(buf, sd, SendWho::PARTY); + clif_send(buf, sd, SendWho::PARTY, MIN_CLIENT_VERSION); } } @@ -3144,7 +3134,7 @@ int clif_party_xy(PartyPair , dumb_ptr sd) fixed_107.x = sd->bl_x; fixed_107.y = sd->bl_y; Buffer buf = create_fpacket<0x0107, 10>(fixed_107); - clif_send(buf, sd, SendWho::PARTY_SAMEMAP_WOS); + clif_send(buf, sd, SendWho::PARTY_SAMEMAP_WOS, MIN_CLIENT_VERSION); return 0; } @@ -3162,7 +3152,7 @@ int clif_party_hp(PartyPair , dumb_ptr sd) fixed_106.max_hp = (sd->status.max_hp > 0x7fff) ? 0x7fff : sd->status.max_hp; Buffer buf = create_fpacket<0x0106, 10>(fixed_106); - clif_send(buf, sd, SendWho::PARTY_AREA_WOS); + clif_send(buf, sd, SendWho::PARTY_AREA_WOS, MIN_CLIENT_VERSION); return 0; } @@ -3199,7 +3189,7 @@ void clif_emotion(dumb_ptr bl, int type) fixed_c0.block_id = bl->bl_id; fixed_c0.type = type; Buffer buf = create_fpacket<0x00c0, 7>(fixed_c0); - clif_send(buf, bl, SendWho::AREA); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); } void clif_emotion_towards(dumb_ptr bl, @@ -3232,7 +3222,7 @@ void clif_sitting(Session *, dumb_ptr sd) fixed_8a.src_id = sd->bl_id; fixed_8a.damage_type = DamageType::SIT; Buffer buf = create_fpacket<0x008a, 29>(fixed_8a); - clif_send(buf, sd, SendWho::AREA); + clif_send(buf, sd, SendWho::AREA, MIN_CLIENT_VERSION); } static @@ -3256,7 +3246,7 @@ void clif_sitnpc_towards(dumb_ptr sd, dumb_ptr nd, D Buffer buf; clif_sitnpc_sub(buf, nd, dmg); - clif_send(buf, sd, SendWho::SELF); + clif_send(buf, sd, SendWho::SELF, MIN_CLIENT_VERSION); } void clif_sitnpc(dumb_ptr nd, DamageType dmg) @@ -3265,7 +3255,7 @@ void clif_sitnpc(dumb_ptr nd, DamageType dmg) Buffer buf; clif_sitnpc_sub(buf, nd, dmg); - clif_send(buf, nd, SendWho::AREA); + clif_send(buf, nd, SendWho::AREA, MIN_CLIENT_VERSION); } static @@ -3302,7 +3292,7 @@ void clif_setnpcdirection_towards(dumb_ptr sd, dumb_ptr nd, DIR direction) @@ -3311,7 +3301,7 @@ void clif_setnpcdirection(dumb_ptr nd, DIR direction) Buffer buf; clif_setnpcdirection_sub(buf, nd, direction); - clif_send(buf, nd, SendWho::AREA); + clif_send(buf, nd, SendWho::AREA, MIN_CLIENT_VERSION); } /*========================================== @@ -3370,9 +3360,9 @@ int clif_specialeffect(dumb_ptr bl, int type, int flag) } } else if (flag == 1) - clif_send(buf, bl, SendWho::SELF); + clif_send(buf, bl, SendWho::SELF, MIN_CLIENT_VERSION); else if (!flag) - clif_send(buf, bl, SendWho::AREA); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); return 0; @@ -3792,7 +3782,7 @@ RecvResult clif_parse_GlobalMessage(Session *s, dumb_ptr sd) XString repeat_8d = mbuf; Buffer sendbuf = create_vpacket<0x008d, 8, 1>(head_8d, repeat_8d); - clif_send(sendbuf, sd, SendWho::AREA_CHAT_WOC); + clif_send(sendbuf, sd, SendWho::AREA_CHAT_WOC, MIN_CLIENT_VERSION); } /* Send the message back to the speaker. */ @@ -3813,7 +3803,7 @@ void clif_message(dumb_ptr bl, XString msg) head_8d.block_id = bl->bl_id; Buffer buf = create_vpacket<0x008d, 8, 1>(head_8d, msg); - clif_send(buf, bl, SendWho::AREA); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); } /*========================================== @@ -3857,7 +3847,7 @@ RecvResult clif_parse_ChangeDir(Session *s, dumb_ptr sd) fixed_9c.client_dir = client_dir; Buffer buf = create_fpacket<0x009c, 9>(fixed_9c); - clif_send(buf, sd, SendWho::AREA_WOS); + clif_send(buf, sd, SendWho::AREA_WOS, MIN_CLIENT_VERSION); return rv; } @@ -3882,7 +3872,7 @@ RecvResult clif_parse_Emotion(Session *s, dumb_ptr sd) fixed_c0.block_id = sd->bl_id; fixed_c0.type = emote; Buffer buf = create_fpacket<0x00c0, 7>(fixed_c0); - clif_send(buf, sd, SendWho::AREA); + clif_send(buf, sd, SendWho::AREA, MIN_CLIENT_VERSION); } else clif_skill_fail(sd, SkillID::ONE, 0, 1); @@ -3953,7 +3943,7 @@ RecvResult clif_parse_ActionRequest(Session *s, dumb_ptr sd) fixed_8a.src_id = sd->bl_id; fixed_8a.damage_type = DamageType::STAND; Buffer buf = create_fpacket<0x008a, 29>(fixed_8a); - clif_send(buf, sd, SendWho::AREA); + clif_send(buf, sd, SendWho::AREA, MIN_CLIENT_VERSION); break; } -- cgit v1.2.3-60-g2f50