diff --git a/bot/net/netrpc.cpp b/bot/net/netrpc.cpp index 81cd27a..517363e 100644 --- a/bot/net/netrpc.cpp +++ b/bot/net/netrpc.cpp @@ -1,5 +1,10 @@ #include "../main.h" +using namespace RakNet; + +#define REJECT_REASON_BAD_VERSION 1 +#define REJECT_REASON_BAD_NICKNAME 2 +#define REJECT_REASON_BAD_MOD 3 void EnterVehicle(RPCParameters *rpcParams) {} void ExitVehicle(RPCParameters *rpcParams) {} @@ -24,9 +29,24 @@ void GameModeRestart(RPCParameters *rpcParams) pNetGame->ShutdownForGameModeRestart(); } -void Unk82(RPCParameters *rpcParams) +void ConnectionRejected(RPCParameters *rpcParams) { - // TODO: Unk82 + PCHAR Data = reinterpret_cast(rpcParams->input); + int iBitLength = rpcParams->numberOfBitsOfData; + RakNet::BitStream bsData(Data,(iBitLength/8)+1,false); + BYTE byteRejectReason; + + bsData.Read(byteRejectReason); + + if(byteRejectReason==REJECT_REASON_BAD_VERSION) { + //logprintf("BOT: CONNECTION REJECTED. INCORRECT SA-MP VERSION!"); + } + else if(byteRejectReason==REJECT_REASON_BAD_NICKNAME) { + //logprintf("BOT: CONNECTION REJECTED. BAD NICKNAME!"); + } + + pNetGame->GetRakClient()->Disconnect(500); + exit(1); } void ClientMessage(RPCParameters *rpcParams) @@ -111,7 +131,7 @@ void RegisterRPCs(RakClientInterface * pRakClient) REGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs); REGISTER_STATIC_RPC(pRakClient,SvrStats); REGISTER_STATIC_RPC(pRakClient,GameModeRestart); - REGISTER_STATIC_RPC(pRakClient,Unk82); + REGISTER_STATIC_RPC(pRakClient,ConnectionRejected); REGISTER_STATIC_RPC(pRakClient,ClientMessage); REGISTER_STATIC_RPC(pRakClient,WorldTime); REGISTER_STATIC_RPC(pRakClient,Unk5F); @@ -147,7 +167,7 @@ void UnRegisterRPCs(RakClientInterface * pRakClient) UNREGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs); UNREGISTER_STATIC_RPC(pRakClient,SvrStats); UNREGISTER_STATIC_RPC(pRakClient,GameModeRestart); - UNREGISTER_STATIC_RPC(pRakClient,Unk82); + UNREGISTER_STATIC_RPC(pRakClient,ConnectionRejected); UNREGISTER_STATIC_RPC(pRakClient,ClientMessage); UNREGISTER_STATIC_RPC(pRakClient,WorldTime); UNREGISTER_STATIC_RPC(pRakClient,Unk5F); diff --git a/raknet/SAMPRPC.h b/raknet/SAMPRPC.h index 51c5707..ed9bfca 100644 --- a/raknet/SAMPRPC.h +++ b/raknet/SAMPRPC.h @@ -24,8 +24,8 @@ #define RPC_Unk27 "\x27" #define RPC_UpdateScoresPingsIPs "\x9B" #define RPC_SvrStats "\x66" -#define RPC_Unk82 "\x82" #define RPC_GameModeRestart "\x28" +#define RPC_ConnectionRejected "\x82" #define RPC_ClientMessage "\x5D" #define RPC_WorldTime "\x5E" #define RPC_Unk5F "\x5F" diff --git a/saco/net/netrpc.cpp b/saco/net/netrpc.cpp index 6c19aac..6489da6 100644 --- a/saco/net/netrpc.cpp +++ b/saco/net/netrpc.cpp @@ -13,8 +13,8 @@ void Unk26(RPCParameters *rpcParams) {} void Unk27(RPCParameters *rpcParams) {} void UpdateScoresPingsIPs(RPCParameters *rpcParams) {} void SvrStats(RPCParameters *rpcParams) {} -void Unk82(RPCParameters *rpcParams) {} void GameModeRestart(RPCParameters *rpcParams) {} +void ConnectionRejected(RPCParameters *rpcParams) {} void ClientMessage(RPCParameters *rpcParams) {} void WorldTime(RPCParameters *rpcParams) {} void Unk5F(RPCParameters *rpcParams) {} @@ -64,8 +64,8 @@ void RegisterRPCs(RakClientInterface * pRakClient) REGISTER_STATIC_RPC(pRakClient,Unk27); REGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs); REGISTER_STATIC_RPC(pRakClient,SvrStats); - REGISTER_STATIC_RPC(pRakClient,Unk82); REGISTER_STATIC_RPC(pRakClient,GameModeRestart); + REGISTER_STATIC_RPC(pRakClient,ConnectionRejected); REGISTER_STATIC_RPC(pRakClient,ClientMessage); REGISTER_STATIC_RPC(pRakClient,WorldTime); REGISTER_STATIC_RPC(pRakClient,Unk5F); @@ -132,8 +132,8 @@ void UnRegisterRPCs(RakClientInterface * pRakClient) UNREGISTER_STATIC_RPC(pRakClient,Unk27); UNREGISTER_STATIC_RPC(pRakClient,UpdateScoresPingsIPs); UNREGISTER_STATIC_RPC(pRakClient,SvrStats); - UNREGISTER_STATIC_RPC(pRakClient,Unk82); UNREGISTER_STATIC_RPC(pRakClient,GameModeRestart); + UNREGISTER_STATIC_RPC(pRakClient,ConnectionRejected); UNREGISTER_STATIC_RPC(pRakClient,ClientMessage); UNREGISTER_STATIC_RPC(pRakClient,WorldTime); UNREGISTER_STATIC_RPC(pRakClient,Unk5F);