From 8a411126b03bf31a6fb09087e5e195d8243c869d Mon Sep 17 00:00:00 2001 From: John Cote Date: Sun, 8 Sep 2024 16:35:23 -0400 Subject: [PATCH] ToontownClient: Update receiveDatagram --- otpgo/lua/MsgTypes.lua | 18 ++++++++++++------ otpgo/lua/ToontownClient.lua | 9 +++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/otpgo/lua/MsgTypes.lua b/otpgo/lua/MsgTypes.lua index fe94a98..dcdfdf3 100644 --- a/otpgo/lua/MsgTypes.lua +++ b/otpgo/lua/MsgTypes.lua @@ -1,15 +1,21 @@ -CLIENT_DISCONNECT = 37 +CLIENT_GET_AVATARS = 3 -CLIENT_HEARTBEAT = 52 +CLIENT_DISCONNECT = 37 + +CLIENT_HEARTBEAT = 52 + +CLIENT_ADD_INTEREST = 97 +CLIENT_REMOVE_INTEREST = 99 -- new toontown specific login message, adds last logged in, and if child account has parent acount CLIENT_LOGIN_TOONTOWN = 125 CLIENT_LOGIN_TOONTOWN_RESP = 126 -CLIENT_DISCONNECT_GENERIC = 1 -CLIENT_DISCONNECT_RELOGIN = 100 -CLIENT_DISCONNECT_ACCOUNT_ERROR = 122 -CLIENT_DISCONNECT_BAD_VERSION = 125 +CLIENT_DISCONNECT_GENERIC = 1 +CLIENT_DISCONNECT_RELOGIN = 100 +CLIENT_DISCONNECT_OVERSIZED_DATAGRAM = 106 +CLIENT_DISCONNECT_ACCOUNT_ERROR = 122 +CLIENT_DISCONNECT_BAD_VERSION = 125 DATABASE_OBJECT_TYPE_ACCOUNT = 1 diff --git a/otpgo/lua/ToontownClient.lua b/otpgo/lua/ToontownClient.lua index dd36ad3..3f29148 100644 --- a/otpgo/lua/ToontownClient.lua +++ b/otpgo/lua/ToontownClient.lua @@ -48,9 +48,16 @@ function receiveDatagram(client, dgi) client:handleDisconnect() elseif msgType == CLIENT_LOGIN_TOONTOWN then handleLoginToontown(client, dgi) + -- We have reached the only message types unauthenticated clients can use. + elseif not client:authenticated() then + client:sendDisconnect(CLIENT_DISCONNECT_GENERIC, "First datagram is not CLIENT_LOGIN_TOONTOWN", true) else client:sendDisconnect(CLIENT_DISCONNECT_GENERIC, string.format("Unknown message type: %d", msgType), true) end + + if dgi:getRemainingSize() ~= 0 then + client:sendDisconnect(CLIENT_DISCONNECT_OVERSIZED_DATAGRAM, string.format("Datagram contains excess data.\n%s", tostring(dgi)), true) + end end function handleLoginToontown(client, dgi) @@ -190,11 +197,13 @@ function loginAccount(client, account, accountId, playToken, openChat, isPaid, d resp:addString(os.date("%Y-%m-%d %H:%M:%S")) -- lastLoggedInStr resp:addInt32(math.floor(date.diff(account.LAST_LOGIN, account.CREATED):spandays())) -- accountDays + if linkedToParent then resp:addString("WITH_PARENT_ACCOUNT") -- toonAccountType else resp:addString("NO_PARENT_ACCOUNT") -- toonAccountType end + resp:addString(playToken) -- userName -- Dispatch the response to the client.