diff options
-rw-r--r-- | src/char/char.cpp | 23 | ||||
-rw-r--r-- | src/char/char.hpp | 5 | ||||
-rw-r--r-- | src/map/chrif.cpp | 4 | ||||
-rw-r--r-- | src/map/clif.cpp | 30 | ||||
-rw-r--r-- | src/map/map.hpp | 2 | ||||
-rw-r--r-- | src/map/pc.cpp | 4 | ||||
-rw-r--r-- | src/map/pc.hpp | 2 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 8 | ||||
-rwxr-xr-x | tools/protocol.py | 4 |
9 files changed, 64 insertions, 18 deletions
diff --git a/src/char/char.cpp b/src/char/char.cpp index ed9e369..7ad6dff 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -62,6 +62,7 @@ #include "../proto2/any-user.hpp" #include "../proto2/login-admin.hpp" #include "../proto2/login-char.hpp" +#include "../proto2/login-user.hpp" #include "../proto2/char-map.hpp" #include "../proto2/char-user.hpp" @@ -98,7 +99,7 @@ struct char_session_data : SessionData AccountId account_id; int login_id1, login_id2; SEX sex; - unsigned short packet_tmw_version; + unsigned short packet_client_version; AccountEmail email; }; } // namespace char_ @@ -1673,10 +1674,10 @@ void parse_frommap(Session *ms) payload_fd.account_id = account_id; payload_fd.login_id2 = afi.login_id2; cd->sex = afi.sex; - payload_fd.packet_tmw_version = afi.packet_tmw_version; + payload_fd.packet_client_version = afi.packet_client_version; FPRINTF(stderr, "From queue index %zd: recalling packet version %d\n"_fmt, - (&afi - &auth_fifo.front()), afi.packet_tmw_version); + (&afi - &auth_fifo.front()), afi.packet_client_version); payload_fd.char_key = *ck; payload_fd.char_data = *cd; send_ppacket<0x2afd>(ms, payload_fd); @@ -2180,7 +2181,7 @@ void handle_x0066(Session *s, struct char_session_data *sd, uint8_t rfifob_2, IP auth_fifo_iter->delflag = 0; auth_fifo_iter->sex = sd->sex; auth_fifo_iter->ip = s->client_ip; - auth_fifo_iter->packet_tmw_version = sd->packet_tmw_version; + auth_fifo_iter->packet_client_version = sd->packet_client_version; auth_fifo_iter++; } } @@ -2251,7 +2252,7 @@ void parse_char(Session *s) sd->account_id = account_id; sd->login_id1 = fixed.login_id1; sd->login_id2 = fixed.login_id2; - sd->packet_tmw_version = fixed.packet_tmw_version; + sd->packet_client_version = fixed.packet_client_version; sd->sex = fixed.sex; // formerly: send back account_id @@ -2259,6 +2260,14 @@ void parse_char(Session *s) special.magic_packet_length = 4; send_ppacket<0x8000>(s, special); + if(sd->packet_client_version < MIN_CLIENT_VERSION) + { + Packet_Fixed<0x006a> fixed_6a; + fixed_6a.error_code = 5; + send_fpacket<0x006a, 23>(s, fixed_6a); + goto x65_out; + } + // search authentification for (AuthFifoEntry& afi : auth_fifo) { @@ -2280,8 +2289,8 @@ void parse_char(Session *s) send_fpacket<0x2716, 6>(login_session, fixed_16); } // Record client version - afi.packet_tmw_version = - sd->packet_tmw_version; + afi.packet_client_version = + sd->packet_client_version; // send characters to player mmo_char_send006b(s, sd); } diff --git a/src/char/char.hpp b/src/char/char.hpp index 4f55c04..8adac4d 100644 --- a/src/char/char.hpp +++ b/src/char/char.hpp @@ -42,6 +42,9 @@ std::chrono::seconds DEFAULT_AUTOSAVE_INTERVAL = 5_min; constexpr GmLevel default_gm_level = GmLevel::from(0_u32); +// increase the min version when the protocol is incompatible with old m+ versions +#define MIN_CLIENT_VERSION 1 + struct AuthFifoEntry { AccountId account_id; @@ -50,7 +53,7 @@ struct AuthFifoEntry IP4Address ip; int delflag; SEX sex; - unsigned short packet_tmw_version; + unsigned short packet_client_version; }; struct mmo_map_server diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index 8127f20..ce5669e 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -867,11 +867,11 @@ void chrif_parse(Session *s) AccountId id = payload.account_id; int login_id2 = payload.login_id2; - short tmw_version = payload.packet_tmw_version; + short client_version = payload.packet_client_version; CharKey st_key = payload.char_key; CharData st_data = payload.char_data; pc_authok(id, login_id2, - tmw_version, + client_version, &st_key, &st_data); break; } diff --git a/src/map/clif.cpp b/src/map/clif.cpp index b7c047c..897244e 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -826,6 +826,21 @@ void clif_mob007b(dumb_ptr<mob_data> md, Buffer& buf) *------------------------------------------ */ static +void clif_0225_being_move3_sub(dumb_ptr<block_list> bl, const Buffer& buf) +{ + nullpo_retv(bl); + dumb_ptr<map_session_data> sd = bl->is_player(); + + if (sd->sess != nullptr) + { + if(sd->client_version >= 3) + { + send_buffer(sd->sess, buf); + } + } +} + +static int clif_0225_being_move3(dumb_ptr<mob_data> md) { Packet_Head<0x0225> head_225; @@ -844,7 +859,12 @@ int clif_0225_being_move3(dumb_ptr<mob_data> md) } Buffer buf = create_vpacket<0x0225, 14, 1>(head_225, repeat_225); - clif_send(buf, md, SendWho::AREA); + + 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); return 0; } @@ -2654,7 +2674,7 @@ void clif_skillinfoblock(dumb_ptr<map_session_data> sd) std::vector<Packet_Repeat<0x010f>> repeat_10f; for (SkillID i : erange(SkillID(), MAX_SKILL)) { - if (sd->status.skill[i].lv && sd->tmw_version >= 1) + if (sd->status.skill[i].lv && sd->client_version >= 1) { Packet_Repeat<0x010f> info; // [Fate] Version 1 and later don't crash because of bad skill IDs anymore @@ -4705,6 +4725,9 @@ void clif_sendallquest(dumb_ptr<map_session_data> sd) if (!sd->sess) return; + if(sd->client_version < 2) + return; + Session *s = sd->sess; Packet_Head<0x0215> head_215; std::vector<Packet_Repeat<0x0215>> repeat_215; @@ -4739,6 +4762,9 @@ void clif_sendquest(dumb_ptr<map_session_data> sd, QuestId questid, int value) if (!sd->sess) return; + if(sd->client_version < 2) + return; + Session *s = sd->sess; Packet_Fixed<0x0214> fixed; diff --git a/src/map/map.hpp b/src/map/map.hpp index f57dcee..ce434fa 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -153,7 +153,7 @@ struct map_session_data : block_list, SessionData CharId char_id_; int login_id1, login_id2; SEX sex; - unsigned char tmw_version; // tmw client version + int client_version; // tmw client version CharKey status_key; CharData status; GenericArray<Option<Borrowed<struct item_data>>, InventoryIndexing<IOff0, MAX_INVENTORY>> inventory_data = diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 1179792..d2b2f44 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -641,7 +641,7 @@ int pc_isequip(dumb_ptr<map_session_data> sd, IOff0 n) *------------------------------------------ */ int pc_authok(AccountId id, int login_id2, - short tmw_version, const CharKey *st_key, const CharData *st_data) + short client_version, const CharKey *st_key, const CharData *st_data) { dumb_ptr<map_session_data> sd = nullptr; @@ -652,7 +652,7 @@ int pc_authok(AccountId id, int login_id2, return 1; sd->login_id2 = login_id2; - sd->tmw_version = tmw_version; + sd->client_version = client_version; sd->status_key = *st_key; sd->status = *st_data; diff --git a/src/map/pc.hpp b/src/map/pc.hpp index d100938..fc0bdb0 100644 --- a/src/map/pc.hpp +++ b/src/map/pc.hpp @@ -80,7 +80,7 @@ int pc_counttargeted(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> src, int pc_setrestartvalue(dumb_ptr<map_session_data> sd, int type); void pc_makesavestatus(dumb_ptr<map_session_data>); int pc_setnewpc(dumb_ptr<map_session_data>, AccountId, CharId, int, uint32_t /*tick_t*/, SEX); -int pc_authok(AccountId, int, short tmw_version, const CharKey *, const CharData *); +int pc_authok(AccountId, int, short client_version, const CharKey *, const CharData *); int pc_authfail(AccountId accid); EPOS pc_equippoint(dumb_ptr<map_session_data> sd, IOff0 n); diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 744f2c3..9020203 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -971,6 +971,13 @@ void builtin_delitem(ScriptState *st) } +static +void builtin_getversion(ScriptState *st) +{ + dumb_ptr<map_session_data> sd = script_rid2sd(st);; + push_int<ScriptDataInt>(st->stack, sd->client_version); +} + /*========================================== *キャラ関係のID取得 *------------------------------------------ @@ -3028,6 +3035,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(makeitem, "IiMxy"_s, '\0'), BUILTIN(delitem, "Ii"_s, '\0'), BUILTIN(getcharid, "i?"_s, 'i'), + BUILTIN(getversion, ""_s, 'i'), BUILTIN(strcharinfo, "i"_s, 's'), BUILTIN(getequipid, "i"_s, 'i'), BUILTIN(bonus, "ii"_s, '\0'), diff --git a/tools/protocol.py b/tools/protocol.py index 688821f..f13d627 100755 --- a/tools/protocol.py +++ b/tools/protocol.py @@ -1984,7 +1984,7 @@ def build_context(): at(2, account_id, 'account id'), at(6, u32, 'login id1'), at(10, u32, 'login id2'), - at(14, u16, 'packet tmw version'), + at(14, u16, 'packet client version'), at(16, sex, 'sex'), ], fixed_size=17, @@ -5124,7 +5124,7 @@ def build_context(): at(4, account_id, 'account id'), at(8, u32, 'login id2'), at(12, time32, 'unused connect until'), - at(16, u16, 'packet tmw version'), + at(16, u16, 'packet client version'), at(18, char_key, 'char key'), at(None, char_data, 'char data'), ], |