From da0347115c869bca492a9370ead4933852e4bb5f Mon Sep 17 00:00:00 2001 From: kurta999 Date: Mon, 7 Jul 2014 20:41:11 +0200 Subject: [PATCH] - Fixed linux raknet structures - Fixed linux raknet structures - Added ShowPlayerForPlayer, HidePlayerForPlayer - Added forplayer parameter to SendBulletData --- Addresses.cpp | 23 +++++++- CServer.cpp | 1 + RPCs.cpp | 4 +- RPCs.h | 2 + Scripting.cpp | 78 ++++++++++++++++++++++---- Structs.h | 150 ++++++++++++++++++++++++-------------------------- main.cpp | 4 ++ main.h | 6 +- 8 files changed, 172 insertions(+), 96 deletions(-) diff --git a/Addresses.cpp b/Addresses.cpp index 75e43a3..e7b22e3 100644 --- a/Addresses.cpp +++ b/Addresses.cpp @@ -9,7 +9,7 @@ DWORD CAddress::FUNC_Logprintf_03ZR3 = 0x00487460; #else DWORD CAddress::FUNC_Logprintf_03Z = 0x080A7440; DWORD CAddress::FUNC_Logprintf_03ZR2_2 = 0x080A77D0; -DWORD CAddress::FUNC_Logprintf_03ZR3 = 0x080A77D0; +DWORD CAddress::FUNC_Logprintf_03ZR3 = 0x080A78E0; #endif // Pointers @@ -84,6 +84,7 @@ void CAddress::Initialize(eSAMPVersion sampVersion) FUNC_CConsole_AddStringVariable = 0x0809F590; FUNC_CConsole_SetStringVariable = 0x0809EDB0; + FUNC_CConsole_SetIntVariable = 0x0809ED10; FUNC_CConsole_ModifyVariableFlags = 0x0809EE60; FUNC_CFilterscripts_LoadFilterscript = 0x0809FDB0; @@ -100,6 +101,7 @@ void CAddress::Initialize(eSAMPVersion sampVersion) FUNC_CConsole_AddStringVariable = 0x809F760; FUNC_CConsole_SetStringVariable = 0x809F000; + FUNC_CConsole_SetIntVariable = 0x809EEE0; FUNC_CConsole_ModifyVariableFlags = 0x809F030; FUNC_CFilterscripts_LoadFilterscript = 0x0809FF80; @@ -109,7 +111,24 @@ void CAddress::Initialize(eSAMPVersion sampVersion) FUNC_ContainsInvalidChars = 0x080D2F50; ADDR_RECEIVE_HOOKPOS = 0x80645D6; break; - } + } + case SAMP_VERSION_03Z_R3: + { + VAR_pRestartWaitTime = 0x8150B60; + + FUNC_CConsole_AddStringVariable = 0x809F760; + FUNC_CConsole_SetStringVariable = 0x809F000; + FUNC_CConsole_SetIntVariable = 0x809EEE0; + FUNC_CConsole_ModifyVariableFlags = 0x809F030; + + FUNC_CFilterscripts_LoadFilterscript = 0x0809FF80; // done + FUNC_CFilterscripts_UnLoadFilterscript = 0x080A03B0; // done + + ADDR_CNetGame_GMX_GangZoneDelete = NULL; + FUNC_ContainsInvalidChars = 0x080D2F50; + ADDR_RECEIVE_HOOKPOS = 0x80645D6; + break; + } } #endif diff --git a/CServer.cpp b/CServer.cpp index 4351653..0b98eba 100644 --- a/CServer.cpp +++ b/CServer.cpp @@ -189,6 +189,7 @@ BYTE CServer::GetWeather(void) return m_byteWeather; } +// forward OnPlayerPauseStateChange(playerid, pausestate); void CServer::OnPlayerPauseStateChange(int playerid, bool afkstate) { //logprintf("OnPlayerPauseStateChange %d - %d", playerid, afkstate); diff --git a/RPCs.cpp b/RPCs.cpp index 248b6d0..b7b5e3c 100644 --- a/RPCs.cpp +++ b/RPCs.cpp @@ -21,8 +21,8 @@ int RPC_FlashGangZone = 0x79; int RPC_StopFlashGangZone = 0x55; int RPC_UpdateScoresPingsIPs = 0x9B; int RPC_RemovePlayerAttachedObject = 0x71; - -void UpdateScoresPingsIPs(RPCParameters *rpcParams); +int RPC_WorldPlayerAdd = 32; +int RPC_WorldPlayerRemove = 163; void UpdateScoresPingsIPs(RPCParameters *rpcParams) { diff --git a/RPCs.h b/RPCs.h index 270c705..e3c30bc 100644 --- a/RPCs.h +++ b/RPCs.h @@ -51,6 +51,8 @@ extern int RPC_FlashGangZone; extern int RPC_StopFlashGangZone; extern int RPC_UpdateScoresPingsIPs; extern int RPC_RemovePlayerAttachedObject; +extern int RPC_WorldPlayerAdd; +extern int RPC_WorldPlayerRemove; void InitRPCs(); diff --git a/Scripting.cpp b/Scripting.cpp index ce851db..264c682 100644 --- a/Scripting.cpp +++ b/Scripting.cpp @@ -581,10 +581,6 @@ static cell AMX_NATIVE_CALL n_GetFilterScriptName(AMX *amx, cell *params) return set_amxstring(amx, params[2], pNetGame->pFilterScriptPool->m_szFilterScriptName[id], params[3]); } -#define CON_VARFLAG_DEBUG 1 -#define CON_VARFLAG_READONLY 2 -#define CON_VARFLAG_RULE 4 - // native AddServerRule(name[], value[], flags = CON_VARFLAG_RULE); static cell AMX_NATIVE_CALL n_AddServerRule(AMX *amx, cell *params) { @@ -665,6 +661,7 @@ static cell AMX_NATIVE_CALL n_ModifyFlag(AMX *amx, cell *params) return 0; } +// native IsValidNickName(name[]); static cell AMX_NATIVE_CALL n_IsValidNickName(AMX *amx, cell *params) { // If unknown server version @@ -693,7 +690,7 @@ static cell AMX_NATIVE_CALL n_AllowNickNameCharacter(AMX *amx, cell *params) char character = (char)params[1]; - // Enable %s is disabled for security + // Enable %s is disallowed if(character == '%') return 0; if(params[2]) @@ -1427,18 +1424,24 @@ static cell AMX_NATIVE_CALL n_GetPlayerSpectateType( AMX* amx, cell* params ) return pNetGame->pPlayerPool->pPlayer[playerid]->byteSpectateType; } -// native SendBulletData(sender, hitid, hittype, Float:fHitOriginX, Float:fHitOriginY, Float:fHitOriginZ, Float:fHitTargetX, Float:fHitTargetY, Float:fHitTargetZ, Float:fCenterOfHitX, Float:fCenterOfHitY, Float:fCenterOfHitZ); +// native SendBulletData(sender, hitid, hittype, Float:fHitOriginX, Float:fHitOriginY, Float:fHitOriginZ, Float:fHitTargetX, Float:fHitTargetY, Float:fHitTargetZ, Float:fCenterOfHitX, Float:fCenterOfHitY, Float:fCenterOfHitZ, forplayerid = -1); static cell AMX_NATIVE_CALL n_SendBulletData( AMX* amx, cell* params ) { // If unknown server version if(!pServer) return 0; - CHECK_PARAMS(12, "SendBulletData"); - + CHECK_PARAMS(13, "SendBulletData"); + int playerid = (int)params[1]; + int forplayerid = (int)params[12]; if(!IsPlayerConnected(playerid)) return 0; + if(forplayerid != -1) + { + if(!IsPlayerConnected(forplayerid)) return 0; + } + BULLET_SYNC_DATA bulletSync; bulletSync.byteHitType = (BYTE)params[3]; bulletSync.wHitID = (WORD)params[2]; @@ -1450,12 +1453,61 @@ static cell AMX_NATIVE_CALL n_SendBulletData( AMX* amx, cell* params ) bs.Write((BYTE)ID_BULLET_SYNC); bs.Write((WORD)playerid); bs.Write((char*)&bulletSync, sizeof(BULLET_SYNC_DATA)); - pRakServer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_PLAYER_ID, true); + + if(forplayerid == -1) + { + pRakServer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_PLAYER_ID, true); + } + else + { + pRakServer->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, pRakServer->GetPlayerIDFromIndex(forplayerid), false); + } return 1; } -// Scoreboard manipulation +// native ShowPlayerForPlayer(forplayerid, playerid); +static cell AMX_NATIVE_CALL n_ShowPlayerForPlayer( AMX* amx, cell* params ) +{ + // If unknown server version + if(!pServer) + return 0; + + CHECK_PARAMS(2, "ShowPlayerForPlayer"); + + int forplayerid = (int)params[1]; + if(!IsPlayerConnected(forplayerid)) return 0; + + int playerid = (int)params[2]; + if(!IsPlayerConnected(playerid)) return 0; + RakNet::BitStream bs; + bs.Write((WORD)playerid); + pRakServer->RPC(&RPC_WorldPlayerAdd, &bs, HIGH_PRIORITY, RELIABLE_ORDERED, 2, pRakServer->GetPlayerIDFromIndex(forplayerid), 0, 0); + return 1; +} + +// native HidePlayerForPlayer(forplayerid, playerid); +static cell AMX_NATIVE_CALL n_HidePlayerForPlayer( AMX* amx, cell* params ) +{ + // If unknown server version + if(!pServer) + return 0; + + CHECK_PARAMS(2, "HidePlayerForPlayer"); + + int forplayerid = (int)params[1]; + if(!IsPlayerConnected(forplayerid)) return 0; + + int playerid = (int)params[2]; + if(!IsPlayerConnected(playerid)) return 0; + + RakNet::BitStream bs; + bs.Write((WORD)playerid); + pRakServer->RPC(&RPC_WorldPlayerRemove, &bs, HIGH_PRIORITY, RELIABLE_ORDERED, 2, pRakServer->GetPlayerIDFromIndex(forplayerid), 0, 0); + return 1; +} + +// Scoreboard manipulation // native TogglePlayerScoresPingsUpdate(playerid, bool:toggle); static cell AMX_NATIVE_CALL n_TogglePlayerScoresPingsUpdate(AMX *amx, cell *params) { @@ -4661,8 +4713,8 @@ AMX_NATIVE_INFO YSINatives [] = // Generic {"SetModeRestartTime", n_SetModeRestartTime}, {"GetModeRestartTime", n_GetModeRestartTime}, - {"SetMaxPlayers", n_SetMaxPlayers}, - {"SetMaxNPCs", n_SetMaxNPCs}, + {"SetMaxPlayers", n_SetMaxPlayers}, // R8 + {"SetMaxNPCs", n_SetMaxNPCs}, // R8 {"SetPlayerAdmin", n_SetPlayerAdmin}, {"LoadFilterScript", n_LoadFilterScript}, @@ -4712,6 +4764,8 @@ AMX_NATIVE_INFO YSINatives [] = { "GetPlayerWorldBounds", n_GetPlayerWorldBounds }, // R5 { "IsPlayerInModShop", n_IsPlayerInModShop }, // R4 { "SendBulletData", n_SendBulletData }, // R6 + { "ShowPlayerForPlayer", n_ShowPlayerForPlayer }, // R8 + { "HidePlayerForPlayer", n_HidePlayerForPlayer }, // R8 // Special things from syncdata { "GetPlayerSirenState", n_GetPlayerSirenState }, diff --git a/Structs.h b/Structs.h index 9ba02c5..3617881 100644 --- a/Structs.h +++ b/Structs.h @@ -940,90 +940,83 @@ struct Packet bool deleteData; }; -//#ifdef WIN32 - +#ifdef WIN32 class RakServer { public: - //~RakServer(); -#ifndef WIN32 - virtual void _00(); - virtual void _04(); -#endif - virtual bool Start( unsigned short AllowedPlayers, unsigned int depreciated, int threadSleepTimer, unsigned short port, const char *forceHostAddress=0 ); // 0 - linux: 8 + ~RakServer(); + virtual bool Start( unsigned short AllowedPlayers, unsigned int depreciated, int threadSleepTimer, unsigned short port, const char *forceHostAddress=0 ); // 0 virtual void InitializeSecurity( const char *privateKeyE, const char *privateKeyN ); // 4 virtual void DisableSecurity( void ); // 8 - virtual void SetPassword( const char *_password ); // 12 - linux: 20 + virtual void SetPassword( const char *_password ); // 12 virtual bool HasPassword( void ); // 16 - virtual void Disconnect( unsigned int blockDuration, unsigned char orderingChannel=0 ); // 20 - linux: 28 + virtual void Disconnect( unsigned int blockDuration, unsigned char orderingChannel=0 ); // 20 virtual bool Send_ASD(const char *data, const int length, int priority, int reliability, char orderingChannel, PlayerID playerId, bool broadcast); // 24 virtual bool Send(RakNet::BitStream* parameters, int priority, int reliability, unsigned orderingChannel, PlayerID playerId, bool broadcast); // 28 - virtual void _20(); // 32 - virtual void Kick( const PlayerID playerId ); // 36 - virtual Packet* Receive( void ); // 40 -#ifdef WIN32 - virtual void DeallocatePacket( Packet *packet );(); // 44 -#endif - virtual void _30(); // 48 - virtual void SetAllowedPlayers(unsigned short numberAllowed); // 52 - linux: 56 - virtual unsigned short GetAllowedPlayers( void ) ; // 56 - virtual unsigned short GetConnectedPlayers( void ); // 60 - virtual void GetPlayerIPFromID( const PlayerID playerId, char returnValue[ 22 ], unsigned short *port ); // 64 - virtual void PingPlayer( const PlayerID playerId ); // 68 - virtual int GetAveragePing( const PlayerID playerId ); // 72 - virtual int GetLastPing( const PlayerID playerId ); // 76 - linux: 80 - virtual int GetLowestPing( const PlayerID playerId ); // 80 - virtual void SetOccasionalPing( bool doPing ); // 84 - linux: 88 - virtual void _58(); // 88 - virtual void _5C(); // 92 - virtual void _60(); // 96 - virtual void _64(); // 100 - virtual void _68(); // 104 - virtual void _6C(); // 108 - virtual void anyad(); // 112 - virtual void RegisterAsRemoteProcedureCall( int* uniqueID, void ( *functionPointer ) ( RPCParameters *rpcParms ) ); // 116 - linux: 120 - virtual void RegisterClassMemberRPC( int* uniqueID, void *functionPointer ); // 120 - virtual void UnregisterAsRemoteProcedureCall( int* uniqueID ); // 124 - virtual bool RPC(int* uniqueID, RakNet::BitStream* parameters, PacketPriority priority, PacketReliability reliability, unsigned orderingChannel, PlayerID playerId, bool broadcast, bool shiftTimestamp); // 128 - virtual void _84(); // 132 - virtual void _88(); // 136 - virtual void _8C(); // 140 - virtual void _90(); // 144 - virtual void _94(); // 148 - virtual void _98(); // 152 - virtual void _9C(); // 156 - virtual void _A0(); // 160 - virtual void _A4(); // 164 - virtual void _A8(); // 168 - virtual void _AC(); // 172 - virtual void _B0(); // 176 - virtual void _B4(); // 180 - virtual void _B8(); // 184 - virtual void _BC(); // 188 - virtual void _C0(); // 192 - virtual void _C4(); // 196 - virtual void _C8(); // 200 - virtual void _CC(); // 204 - virtual const char* GetLocalIP( unsigned int index ); // 208 - virtual PlayerID GetInternalID( void ) const; // 212 - virtual void PushBackPacket( Packet *packet, bool pushAtHead ); // 216 - virtual void SetRouterInterface( void *routerInterface ); // 220 - virtual void RemoveRouterInterface( void *routerInterface ); // 224 - virtual int GetIndexFromPlayerID( PlayerID playerId ); // 228 - virtual PlayerID GetPlayerIDFromIndex( int index ); // 232 - virtual void AddToBanList( const char *IP, unsigned int milliseconds=0 ); // 236 - linux: 240 - virtual void RemoveFromBanList( const char *IP ); // 240 - virtual void ClearBanList( void ); // 244 - virtual bool IsBanned( const char *IP ); // 248 - virtual bool IsActivePlayerID( const PlayerID playerId ); // 252 - virtual void SetTimeoutTime( RakNetTime timeMS, const PlayerID target ); // 256 - virtual bool SetMTUSize( int size ); // 260 - virtual int GetMTUSize( void ) const; // 264 - virtual void AdvertiseSystem( const char *host, unsigned short remotePort, const char *data, int dataLength ); // 268 - virtual RakNetStatisticsStruct * const GetStatistics( const PlayerID playerId ); // 272 - virtual void ApplyNetworkSimulator( double maxSendBPS, unsigned short minExtraPing, unsigned short extraPingVariance); // 276 + virtual void _20(); // + virtual void _24(); + virtual Packet* Receive( void ); + virtual void Kick( const PlayerID playerId ); // 0x2C + virtual void DeallocatePacket(Packet* asd); + virtual void SetAllowedPlayers(unsigned short numberAllowed); // 0x34 + virtual unsigned short GetAllowedPlayers( void ) const; + virtual unsigned short GetConnectedPlayers( void ); + virtual void GetPlayerIPFromID( const PlayerID playerId, char returnValue[ 22 ], unsigned short *port ); + virtual void PingPlayer( const PlayerID playerId ); + virtual int GetAveragePing( const PlayerID playerId ); + virtual int GetLastPing( const PlayerID playerId ); // 4C + virtual int GetLowestPing( const PlayerID playerId ); + virtual void _54(); + virtual void _58(); + virtual void _5C(); + virtual void _60(); + virtual void _64(); + virtual void _68(); + virtual void _6C(); + virtual void _70(); + virtual void RegisterAsRemoteProcedureCall( int* uniqueID, void ( *functionPointer ) ( RPCParameters *rpcParms ) ); // 74 + virtual void RegisterClassMemberRPC( int* uniqueID, void *functionPointer ); // 78 + virtual void UnregisterAsRemoteProcedureCall( int* uniqueID ); // 7C + virtual bool RPC(int* uniqueID, RakNet::BitStream* parameters, PacketPriority priority, PacketReliability reliability, unsigned orderingChannel, PlayerID playerId, bool broadcast, bool shiftTimestamp); // 80 + virtual void _84(); + virtual void _88(); + virtual void _8C(); + virtual void _90(); + virtual void _94(); + virtual void _98(); + virtual void _9C(); + virtual void _A0(); + virtual void _A4(); + virtual void _A8(); + virtual void _AC(); + virtual void _B0(); + virtual void _B4(); + virtual void _B8(); + virtual void _BC(); + virtual void _C0(); + virtual void _C4(); + virtual void _C8(); + virtual void _CC(); + virtual const char* GetLocalIP( unsigned int index ); + virtual PlayerID GetInternalID( void ) const; + virtual void PushBackPacket( Packet *packet, bool pushAtHead ); + virtual void SetRouterInterface( void *routerInterface ); + virtual void RemoveRouterInterface( void *routerInterface ); + virtual int GetIndexFromPlayerID( PlayerID playerId ); // E4 + virtual PlayerID GetPlayerIDFromIndex( int index ); // E8 + virtual void AddToBanList( const char *IP, unsigned int milliseconds=0 ); + virtual void RemoveFromBanList( const char *IP ); + virtual void ClearBanList( void ); + virtual bool IsBanned( const char *IP ); + virtual bool IsActivePlayerID( const PlayerID playerId ); + virtual void SetTimeoutTime( RakNetTime timeMS, const PlayerID target ); + virtual bool SetMTUSize( int size ); + virtual int GetMTUSize( void ) const; + virtual void AdvertiseSystem( const char *host, unsigned short remotePort, const char *data, int dataLength ); + virtual RakNetStatisticsStruct * const GetStatistics( const PlayerID playerId ); + virtual void ApplyNetworkSimulator( double maxSendBPS, unsigned short minExtraPing, unsigned short extraPingVariance); }; -/* + #else class RakServer @@ -1044,13 +1037,13 @@ class RakServer virtual void _2C(); virtual void _30(); virtual void _34(); - virtual void _38(); + virtual void SetAllowedPlayers(unsigned short numberAllowed); virtual void _3C(); virtual void _40(); virtual void _44(); virtual void _48(); virtual void _4C(); - virtual void _50(); + virtual int GetLastPing( const PlayerID playerId ); // 0x50 virtual void _54(); virtual void _58(); virtual void _5C(); @@ -1102,7 +1095,6 @@ class RakServer virtual RakNetStatisticsStruct * const GetStatistics( const PlayerID playerId ); virtual void ApplyNetworkSimulator( double maxSendBPS, unsigned short minExtraPing, unsigned short extraPingVariance); }; - #endif -*/ + #endif diff --git a/main.cpp b/main.cpp index 773e351..7efe976 100644 --- a/main.cpp +++ b/main.cpp @@ -81,8 +81,12 @@ PLUGIN_EXPORT bool PLUGIN_CALL Load(void ** ppData) } else if(logprintf == (logprintf_t)CAddress::FUNC_Logprintf_03ZR3) { +#ifndef WIN32 + logprintf("Error: 0.3z R3 is not supported on linux! Use R2."); +#else version = SAMP_VERSION_03Z_R3; strcpy(szVersion, "0.3z R3"); +#endif } // If not unknown, then initalize things diff --git a/main.h b/main.h index 8d853c3..b477014 100644 --- a/main.h +++ b/main.h @@ -1,7 +1,6 @@ #ifndef __YSF_MAINH #define __YSF_MAINH - #include #include #include @@ -18,6 +17,11 @@ #include "Scripting.h" #include "CModelSizes.h" +// Defines +#define CON_VARFLAG_DEBUG 1 +#define CON_VARFLAG_READONLY 2 +#define CON_VARFLAG_RULE 4 + #ifdef WIN32 #define OS_NAME "Windows" #else