Skip to content

Commit

Permalink
R8, before release
Browse files Browse the repository at this point in the history
  • Loading branch information
kurta999 committed Jul 6, 2014
1 parent c0fd376 commit 8a04be6
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 62 deletions.
4 changes: 3 additions & 1 deletion Addresses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
#ifdef _WIN32
DWORD CAddress::FUNC_Logprintf_03Z = 0x00486CB0;
DWORD CAddress::FUNC_Logprintf_03ZR2_2 = 0x00487310;
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;
#endif

// Pointers
Expand Down Expand Up @@ -57,7 +59,7 @@ void CAddress::Initialize(eSAMPVersion sampVersion)
ADDR_RECEIVE_HOOKPOS = FindPattern("\x8B\x4E\x10\x8A\x01\x3C\x16\x74\x10\x83\x7E", "xx?xxxx??xx"); // R2-2: 0x458A20
ADDR_CScriptTimers__ProcessCall = FindPattern("\x50\x8B\xCF\xE8\x46\x39\xFF\xFF\x8B\x4E\x34\x85\xC9", "xxx????xx?xx"); // R2-2: 0x48BC22

logprintf("ADDR_CScriptTimers__ProcessCall: %x", ADDR_CScriptTimers__ProcessCall);
//logprintf("ADDR_CScriptTimers__ProcessCall: %x", ADDR_CScriptTimers__ProcessCall);
switch(sampVersion)
{
case SAMP_VERSION_03Z:
Expand Down
2 changes: 2 additions & 0 deletions Addresses.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum eSAMPVersion
SAMP_VERSION_UNKNOWN,
SAMP_VERSION_03Z,
SAMP_VERSION_03Z_R2_2,
SAMP_VERSION_03Z_R3,

SAMP_VERSION_SKIPPED,
};
Expand All @@ -51,6 +52,7 @@ class CAddress

static DWORD FUNC_Logprintf_03Z;
static DWORD FUNC_Logprintf_03ZR2_2;
static DWORD FUNC_Logprintf_03ZR3;

// Pointers
static DWORD VAR_ppNetGame;
Expand Down
12 changes: 1 addition & 11 deletions CServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,9 @@ BYTE CServer::GetWeather(void)
return m_byteWeather;
}

void CServer::RemoveAttachedObjects(WORD playerid)
{

}

void CServer::RestoreAttachedObjects(WORD playerid)
{

}

void CServer::OnPlayerPauseStateChange(int playerid, bool afkstate)
{
logprintf("OnPlayerPauseStateChange %d - %d", playerid, afkstate);
//logprintf("OnPlayerPauseStateChange %d - %d", playerid, afkstate);
int idx = -1;
std::list<AMX*>::iterator second;
for(second = pAMXList.begin(); second != pAMXList.end(); ++second)
Expand Down
3 changes: 0 additions & 3 deletions CServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ class CServer
void SetWeather(unsigned char byteWeather);
unsigned char GetWeather(void);

void RemoveAttachedObjects(unsigned short playerid);
void RestoreAttachedObjects(unsigned short playerid);

void OnPlayerPauseStateChange(int playerid, bool afkstate);
private:
float m_fGravity;
Expand Down
1 change: 1 addition & 0 deletions RPCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ int RPC_HideGangZone = 0x78;
int RPC_FlashGangZone = 0x79;
int RPC_StopFlashGangZone = 0x55;
int RPC_UpdateScoresPingsIPs = 0x9B;
int RPC_RemovePlayerAttachedObject = 0x71;

void UpdateScoresPingsIPs(RPCParameters *rpcParams);

Expand Down
1 change: 1 addition & 0 deletions RPCs.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern int RPC_HideGangZone;
extern int RPC_FlashGangZone;
extern int RPC_StopFlashGangZone;
extern int RPC_UpdateScoresPingsIPs;
extern int RPC_RemovePlayerAttachedObject;

void InitRPCs();

Expand Down
15 changes: 8 additions & 7 deletions Scripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,9 @@ static cell AMX_NATIVE_CALL n_GetActiveTimers(AMX *amx, cell *params)
if(!pServer)
return 0;

return pNetGame->pScriptTimers->GetTimerCount();
return pNetGame->pScriptTimers->m_dwTimerCount;
}

/*
// native IsTimerActive(timerid);
static cell AMX_NATIVE_CALL n_IsTimerActive(AMX *amx, cell *params)
{
Expand Down Expand Up @@ -879,7 +879,7 @@ static cell AMX_NATIVE_CALL n_IsTimerRepeating(AMX *amx, cell *params)
return pNetGame->pScriptTimers->IsTimerRepeating((DWORD)params[1]);
}

*/
// native SetGravity(Float:gravity);
static cell AMX_NATIVE_CALL n_FIXED_SetGravity( AMX* amx, cell* params )
{
Expand Down Expand Up @@ -4607,7 +4607,7 @@ static cell AMX_NATIVE_CALL n_FIXED_GetWeaponName( AMX* amx, cell* params )

return set_amxstring(amx, params[2], GetWeaponName((BYTE)params[1]), params[3]);
}

/*
// native SetTimer(funcname[], interval, repeating)
static cell AMX_NATIVE_CALL n_YSF_SetTimer(AMX *amx, cell *params)
{
Expand Down Expand Up @@ -4645,7 +4645,7 @@ static cell AMX_NATIVE_CALL n_YSF_KillTimer(AMX *amx, cell *params)
pNetGame->pScriptTimers->Kill(params[1]);
return 1;
}

*/
// And an array containing the native function-names and the functions specified with them
AMX_NATIVE_INFO YSINatives [] =
{
Expand Down Expand Up @@ -4684,16 +4684,17 @@ AMX_NATIVE_INFO YSINatives [] =
{ "GetAvailableClasses", n_GetAvailableClasses}, // R6
{ "GetPlayerClass", n_GetPlayerClass}, // R6
{ "EditPlayerClass", n_EditPlayerClass}, // R6

// Timers
{ "GetActiveTimers", n_GetActiveTimers}, // R8
/*
{ "IsTimerActive", n_IsTimerActive}, // R8
{ "GetTimerFunctionName", n_GetTimerFunctionName}, // R8
{ "SetTimerInterval", n_SetTimerInterval}, // R8
{ "GetTimerInterval", n_GetTimerInterval}, // R8
{ "GetTimerRemainingTime", n_GetTimerRemainingTime}, // R8
{ "IsTimerRepeating", n_IsTimerRepeating}, // R8

*/
// Special
{ "SetPlayerGravity", n_SetPlayerGravity },
{ "GetPlayerGravity", n_GetPlayerGravity },
Expand Down
16 changes: 13 additions & 3 deletions Structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class CPassengerSyncData
#pragma pack(pop)

#pragma pack(push, 1)
class CAttachedObject
class CAttachedObject // sizeof = 52 - 0x34
{
public:
int iModelID;
Expand Down Expand Up @@ -715,7 +715,17 @@ class CMenuPool
private:
};

// 89 = iGameState
typedef std::map<DWORD, ScriptTimer_s*> DwordTimerMap;

#pragma pack(push, 1)
class CScriptTimers_
{
public:
DwordTimerMap m_Timers;
DWORD m_dwTimerCount;
};
#pragma pack(pop)

#pragma pack(push, 1)
class CNetGame
{
Expand All @@ -734,7 +744,7 @@ class CNetGame
int iCurrentGameModeRepeat; // 44 - 48
BOOL bFirstGameModeLoaded; // 48 - 52
BOOL bLanMode; // 52 - 56
CScriptTimers *pScriptTimers; // 56 - 60
CScriptTimers_ *pScriptTimers; // 56 - 60
RakServer *pRak; // 60 - 64
BYTE pad2[61]; // 64 - 125
int iSpawnsAvailable; // 125 - 129
Expand Down
50 changes: 13 additions & 37 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ PLUGIN_EXPORT bool PLUGIN_CALL Load(void ** ppData)
version = SAMP_VERSION_03Z_R2_2;
strcpy(szVersion, "0.3z R2-2");
}
else if(logprintf == (logprintf_t)CAddress::FUNC_Logprintf_03ZR3)
{
version = SAMP_VERSION_03Z_R3;
strcpy(szVersion, "0.3z R3");
}

// If not unknown, then initalize things
if(version != SAMP_VERSION_UNKNOWN)
Expand Down Expand Up @@ -166,7 +171,15 @@ PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX * amx)
}
else
{
/*
DwordTimerMap *myMap = reinterpret_cast<DwordTimerMap *>(&pNetGame->pScriptTimers->m_Timers);
DwordTimerMap::iterator itor;
for (itor = myMap->begin(); itor != myMap->end(); itor++)
{
logprintf("remaining time: %d", itor->second->iRemainingTime);
}
*/
#ifdef pina
logprintf("infernus used: %d", pNetGame->pVehiclePool->modelsUsed[11]);
/*
Expand Down Expand Up @@ -384,43 +397,6 @@ PLUGIN_EXPORT void PLUGIN_CALL ProcessTick()

// Process player
pPlayerPointer->Process();

// R7 - TODO
CPlayer *pPlayer = pNetGame->pPlayerPool->pPlayer[playerid];
switch(pPlayer->aimSyncData.byteCameraMode)
{
case 7:
case 8:
case 16:
case 46:
case 51:
{
// Remove objects
if(!pPlayerPointer->bObjectsRemoved)
{
logprintf("remove attacahed objects");
// Remove every attached objects from player - but ONLY for given player
pServer->RemoveAttachedObjects(playerid);

pPlayerPointer->bObjectsRemoved = true;
}
break;
}

default:
{
// Restore player objects
if(pPlayerPointer->bObjectsRemoved)
{
logprintf("restore attacahed objects");
// Re-attach removed objects
pServer->RestoreAttachedObjects(playerid);

pPlayerPointer->bObjectsRemoved = false;
}
break;
}
}
}
}
}

0 comments on commit 8a04be6

Please sign in to comment.