ToontownClient: CLIENT_LOGIN_TOONTOWN wip

This commit is contained in:
John Cote 2024-09-07 23:25:46 -04:00
parent f6cfeb48d5
commit c88aa79765
2 changed files with 29 additions and 1 deletions

View File

@ -5,4 +5,6 @@ CLIENT_HEARTBEAT = 52
-- new toontown specific login message, adds last logged in, and if child account has parent acount
CLIENT_LOGIN_TOONTOWN = 125
CLIENT_DISCONNECT_GENERIC = 1
CLIENT_DISCONNECT_GENERIC = 1
CLIENT_DISCONNECT_RELOGIN = 100
CLIENT_DISCONNECT_BAD_VERSION = 125

View File

@ -11,7 +11,33 @@ function receiveDatagram(client, dgi)
client:handleHeartbeat()
elseif msgType == CLIENT_DISCONNECT then
client:handleDisconnect()
elseif msgType == CLIENT_LOGIN_TOONTOWN then
handleLoginToontown(client, dgi)
else
client:sendDisconnect(CLIENT_DISCONNECT_GENERIC, string.format("Unknown message type: %d", msgType), true)
end
end
function handleLoginToontown(client, dgi)
local playToken = dgi:readString()
local version = dgi:readString()
local hash = dgi:readUint32()
local tokenType = dgi:readInt32()
local wantMagicWords = dgi:readString()
if client:authenticated() then
client:sendDisconnect(CLIENT_DISCONNECT_RELOGIN, "Authenticated client tried to login twice!", true)
return
end
-- Check if version and hash matches
if version ~= SERVER_VERSION then
client:sendDisconnect(CLIENT_DISCONNECT_BAD_VERSION, string.format("Client version mismatch: client=%s, server=%s", version, SERVER_VERSION), true)
return
end
if hash ~= DC_HASH then
client:sendDisconnect(CLIENT_DISCONNECT_BAD_VERSION, string.format("Client DC hash mismatch: client=%d, server=%d", hash, DC_HASH), true)
return
end
end