summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2018-11-10 18:58:47 -0500
committergumi <git@gumi.ca>2018-11-10 18:58:47 -0500
commit3285ec99df4a6cc50f960e688afa1a1efbc901ad (patch)
tree541919edb3dc56b90dea755014f0a713cd1a61bc
parent4eb51fdec1f3c29f171ba07068dac50c64a2e57a (diff)
downloadtmwa-3285ec99df4a6cc50f960e688afa1a1efbc901ad.tar.gz
tmwa-3285ec99df4a6cc50f960e688afa1a1efbc901ad.tar.bz2
tmwa-3285ec99df4a6cc50f960e688afa1a1efbc901ad.tar.xz
tmwa-3285ec99df4a6cc50f960e688afa1a1efbc901ad.zip
add support for CMSG_ONLINE_LIST
-rw-r--r--src/map/clif.cpp44
-rwxr-xr-xtools/protocol.py41
2 files changed, 79 insertions, 6 deletions
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 75d98e4..d287f4d 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -3641,6 +3641,48 @@ RecvResult clif_parse_LoadEndAck(Session *s, dumb_ptr<map_session_data> sd)
return rv;
}
+static
+int clif_send_online_list(dumb_ptr<map_session_data> sd)
+{
+ Packet_Head<0x0211> head_211;
+ std::vector<Packet_Repeat<0x0211>> repeat_211;
+
+ for (io::FD i : iter_fds())
+ {
+ Session *s = get_session(i);
+ if (!s || !s->session_data)
+ continue;
+
+ dumb_ptr<map_session_data> p_sd = dumb_ptr<map_session_data>(static_cast<map_session_data *>(s->session_data.get()));
+ if (p_sd->state.auth && !bool(p_sd->status.option & Opt0::HIDE)) {
+ Packet_Repeat<0x0211> info;
+ info.account_id = p_sd->status_key.account_id;
+ info.char_name = p_sd->status_key.name;
+ info.level = p_sd->status.base_level;
+ info.gm_level = GmLevel::from(static_cast<uint32_t>(pc_isGM(p_sd).get_public_word()));
+ info.gender = p_sd->status.sex;
+ repeat_211.push_back(info);
+ }
+ }
+
+ Buffer buf = create_vpacket<0x0211, 4, 31>(head_211, repeat_211);
+ clif_send(buf, sd, SendWho::SELF, wrap<ClientVersion>(8));
+ return 0;
+}
+
+static
+RecvResult clif_parse_OnlineListRequest(Session *s, dumb_ptr<map_session_data> sd)
+{
+ Packet_Fixed<0x0210> fixed;
+ RecvResult rv = recv_fpacket<0x0210, 2>(s, fixed);
+ if (rv != RecvResult::Complete)
+ return rv;
+
+ clif_send_online_list(sd);
+
+ return rv;
+}
+
/*==========================================
*
*------------------------------------------
@@ -5715,7 +5757,7 @@ func_table clif_parse_func_table[0x0220] =
{0, VAR,nullptr, }, // 0x020d
{0, 24, nullptr, }, // 0x020e
{0, 0, nullptr, }, // 0x020f
- {0, 0, nullptr, }, // 0x0210
+ {-1, 2, clif_parse_OnlineListRequest, }, // 0x0210
{0, 0, nullptr, }, // 0x0211
{0, 0, nullptr, }, // 0x0212
{0, 0, nullptr, }, // 0x0213
diff --git a/tools/protocol.py b/tools/protocol.py
index a6a9e39..9820056 100755
--- a/tools/protocol.py
+++ b/tools/protocol.py
@@ -1992,7 +1992,7 @@ def build_context():
],
fixed_size=17,
pre=[0x0069, 0x0092, 0x00b3],
- post=[0x006b, 0x006c, 0x2712, 0x2716],
+ post=[0x006b, 0x006c, 0x2712, 0x2715, 0x2716],
desc='''
Begin connection to the char server, based on keys the login
server gave us.
@@ -2117,7 +2117,7 @@ def build_context():
at(0, char_select, 'char select'),
],
repeat_size=106,
- pre=[0x0065, 0x2713],
+ pre=[0x0065, 0x2713, 0x2715],
post=[PRETTY],
xpost=[0x0066, 0x0067, 0x0068],
desc='''
@@ -2131,7 +2131,7 @@ def build_context():
at(2, u8, 'code'),
],
fixed_size=3,
- pre=[0x0065, 0x2713],
+ pre=[0x0065, 0x2713, 0x2715],
post=[PRETTY],
desc='''
Refuse connection.
@@ -4634,8 +4634,39 @@ def build_context():
The hash is rerandomized every restart.
''',
)
- # 0x0210 define='CMSG_ONLINE_LIST',
- # 0x0211 define='SMSG_ONLINE_LIST',
+ map_user.r(0x0210, 'online list request',
+ define='CMSG_ONLINE_LIST',
+ fixed=[
+ at(0, u16, 'packet id'),
+ ],
+ fixed_size=2,
+ pre=[HUMAN],
+ post=[0x0211],
+ desc='''
+ Request the online list
+ ''',
+ )
+ map_user.s(0x0211, 'advanced online list',
+ define='SMSG_ONLINE_LIST',
+ head=[
+ at(0, u16, 'packet id'),
+ at(2, u16, 'packet length'),
+ ],
+ head_size=4,
+ repeat=[
+ at(0, account_id, 'account id'),
+ at(4, char_name, 'char name'),
+ at(28, u8, 'level'),
+ at(29, gm1, 'gm level'),
+ at(30, sex, 'gender'),
+ ],
+ repeat_size=31,
+ pre=[0x0210],
+ post=[PRETTY],
+ desc='''
+ Info about all players.
+ ''',
+ )
map_user.s(0x0212, 'npc command',
define='SMSG_NPC_COMMAND',
fixed=[