[bot] Implement CNetGame::Packet_ConnectionSucceeded(...)

This commit is contained in:
RD42 2024-05-17 22:48:32 +08:00
parent d7b168a939
commit b1c34872bf
2 changed files with 45 additions and 0 deletions

View File

@ -2,6 +2,8 @@
#include "../main.h"
#include "../../raknet/SocketDataEncryptor.h"
#define NETGAME_VERSION 4057
char szGameModeFile[256];
#define PLAYER_STATE_NONE 0
@ -269,6 +271,9 @@ void CNetGame::UpdateNetwork()
Packet_ModifiedPacket(pkt);
break;
case ID_CONNECTION_REQUEST_ACCEPTED:
Packet_ConnectionSucceeded(pkt);
break;
case ID_PASSENGER_SYNC:
Packet_PassengerSync(pkt);
break;
@ -361,6 +366,43 @@ void CNetGame::Packet_ModifiedPacket(Packet* packet)
{
}
//----------------------------------------------------
// Connection Success
void CNetGame::Packet_ConnectionSucceeded(Packet *p)
{
m_iGameState = GAMESTATE_AWAIT_JOIN;
RakNet::BitStream bsReturnParams((PCHAR)p->data, p->length, true);
BYTE bytePacketID=0;
unsigned int binaryAddr=0;
unsigned short port=0;
unsigned short playerId=0;
unsigned int uiChallenge=0;
bsReturnParams.Read(bytePacketID);
bsReturnParams.Read(binaryAddr);
bsReturnParams.Read(port);
bsReturnParams.Read(playerId);
bsReturnParams.Read(uiChallenge);
uiChallenge ^= NETGAME_VERSION;
int iVersion = NETGAME_VERSION;
BYTE byteMod = 1;
BYTE byteNameLen = (BYTE)strlen(m_pPlayerPool->GetLocalPlayerName());
RakNet::BitStream bsSend;
bsSend.Write(iVersion);
bsSend.Write(byteMod);
bsSend.Write(byteNameLen);
bsSend.Write(m_pPlayerPool->GetLocalPlayerName(),byteNameLen);
bsSend.Write(uiChallenge);
m_pRakClient->RPC(RPC_NPCJoin,&bsSend,HIGH_PRIORITY,RELIABLE,0,FALSE);
}
//----------------------------------------------------
void CNetGame::sub_415EA0(PLAYERID playerId, BOOL a2)

View File

@ -1,8 +1,10 @@
#pragma once
#define GAMESTATE_NONE 0 // used for debugging modes and such
#define GAMESTATE_CONNECTING 1
#define GAMESTATE_CONNECTED 2
#define GAMESTATE_AWAIT_JOIN 3
//----------------------------------------------------
@ -20,6 +22,7 @@ private:
// Packet handlers
void Packet_AimSync(Packet *p);
void Packet_PassengerSync(Packet *p);
void Packet_ConnectionSucceeded(Packet *p);
void Packet_ConnectionBanned(Packet* packet);
void Packet_DisconnectionNotification(Packet* packet);
void Packet_ModifiedPacket(Packet* packet);