Skip to content

Commit

Permalink
Cleaned up some additional files
Browse files Browse the repository at this point in the history
  • Loading branch information
ADRFranklin committed Nov 23, 2019
1 parent baab9d5 commit 0598519
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
25 changes: 13 additions & 12 deletions src/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "Versions.h"
#include "main.h"
#include <cmath>
#include <cstring>
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include <limits>
Expand Down Expand Up @@ -203,6 +204,16 @@ Packet *THISCALL CHookRakServer::Receive(void *ppRakServer)
return nullptr;
}

auto lastSyncData = &getLastSyncData<Structs>(playerid);
if (syncDataFrozen[playerid])
{
d = lastSyncData;
}
else
{
lastSyncData = d;
}

if (d->byteWeapon > 46 || (d->byteWeapon > 18 && d->byteWeapon < 22))
{
d->byteWeapon = 0;
Expand Down Expand Up @@ -399,16 +410,6 @@ Packet *THISCALL CHookRakServer::Receive(void *ppRakServer)
}
}

auto lastSyncData = &getLastSyncData<decltype(netGame)>(playerid);
if (syncDataFrozen[playerid])
{
d = lastSyncData;
}
else
{
lastSyncData = d;
}

if (blockKeySync[playerid])
{
d->wKeys = 0;
Expand Down Expand Up @@ -563,8 +564,8 @@ Packet *THISCALL CHookRakServer::Receive(void *ppRakServer)

void InstallPreHooks()
{
memset(&fakeHealth, 255, sizeof(fakeHealth));
memset(&fakeArmour, 255, sizeof(fakeArmour));
std::memset(&fakeHealth, 255, sizeof(fakeHealth));
std::memset(&fakeArmour, 255, sizeof(fakeArmour));

for (int i = 0; i < 1000; i++)
{
Expand Down
11 changes: 5 additions & 6 deletions src/Scripting.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
#define SCRIPTING_H

#include "main.h"
#include "Addresses.h"

#define CHECK_PARAMS(m, n) \
if (params[0] != (m * 4)) \
{ \
#define CHECK_PARAMS(m, n) \
if (params[0] != (m * 4)) \
{ \
logprintf("SKY: %s: Expecting %d parameter(s), but found %d", n, m, params[0] / sizeof(cell)); \
return 0; \
return 0; \
}

int InitScripting(AMX *amx, int version);
int InitScripting(AMX *amx);
#endif
11 changes: 5 additions & 6 deletions src/Versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
#include "CTypes.h"
#include "main.h"
#include <amx/amx.h>
#include <plugincommon.h>
#include <raknet/BitStream.h>
#include <raknet/NetworkTypes.h>
#include <samp-plugin-sdk/plugincommon.h>

#if !defined PAD
#define PAD(a, b) char a[b]
#endif

struct without_dl
{
#include "Structs.h"
Expand All @@ -35,19 +34,19 @@ auto getNetGame(Func func)
{
if (iVersion == eSAMPVersion::SAMP_VERSION_03DL_R1)
{
auto netGame = reinterpret_cast<with_dl::CNetGame *>(pNetGame);
static with_dl::CNetGame *netGame = reinterpret_cast<with_dl::CNetGame *>(pNetGame);
return func(netGame, with_dl());
}
else
{
auto netGame = reinterpret_cast<without_dl::CNetGame *>(pNetGame);
static without_dl::CNetGame *netGame = reinterpret_cast<without_dl::CNetGame *>(pNetGame);
return func(netGame, without_dl());
}
}

template <class NetGame>
template <typename Struct>
auto &getLastSyncData(int playerid)
{
static decltype(NetGame()->pPlayerPool->pPlayer[playerid]->syncData) data[MAX_PLAYERS];
static typename Struct::CSyncData data[MAX_PLAYERS];
return data[playerid];
}

0 comments on commit 0598519

Please sign in to comment.