Skip to content

Commit

Permalink
Merge branch 'master' into 220523_Fix_#2965
Browse files Browse the repository at this point in the history
  • Loading branch information
TracerDS committed Jun 15, 2024
2 parents bfd26d6 + 9e3fbc2 commit 22048bb
Show file tree
Hide file tree
Showing 392 changed files with 96,385 additions and 46,846 deletions.
23 changes: 23 additions & 0 deletions Client/game_sa/CBuildingsPoolSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ bool CBuildingsPoolSA::Resize(int size)
pGame->GetPools()->GetDummyPool().UpdateBuildingLods(oldPool, newObjects);

RemoveVehicleDamageLinks();
RemovePedsContactEnityLinks();

return true;
}
Expand Down Expand Up @@ -310,6 +311,28 @@ void CBuildingsPoolSA::RemoveVehicleDamageLinks()
}
}

void CBuildingsPoolSA::RemovePedsContactEnityLinks()
{
const int count = pGame->GetPools()->GetPedCount();
for (int i = 0; i < count; i++)
{
auto* pedLinks = pGame->GetPools()->GetPed(i);
if (pedLinks->pEntity)
{
CPedSAInterface* ped = pedLinks->pEntity->GetPedInterface();
ped->m_pCollidedEntity = nullptr;
ped->pContactEntity = nullptr;
ped->pLastContactEntity = nullptr;
ped->pLastContactedEntity[0] = nullptr;
ped->pLastContactedEntity[1] = nullptr;
ped->pLastContactedEntity[2] = nullptr;
ped->pLastContactedEntity[3] = nullptr;
ped->m_ucCollisionState = 0;
ped->pTargetedEntity = nullptr;
}
}
}

bool CBuildingsPoolSA::HasFreeBuildingSlot()
{
return (*m_ppBuildingPoolInterface)->GetFreeSlot() != -1;
Expand Down
1 change: 1 addition & 0 deletions Client/game_sa/CBuildingsPoolSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class CBuildingsPoolSA : public CBuildingsPool
void UpdateIplEntrysPointers(uint32_t offset);
void UpdateBackupLodPointers(uint32_t offset);
void RemoveVehicleDamageLinks();
void RemovePedsContactEnityLinks();

private:
SPoolData<CBuildingSA, CBuildingSAInterface, MAX_BUILDINGS> m_buildingPool;
Expand Down
90 changes: 90 additions & 0 deletions Client/game_sa/CFxSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,93 @@ void CFxSA::TriggerFootSplash(CVector& vecPosition)
call dwFunc
}
}

void CFxSA::AddParticle(eFxParticleSystems eFxParticle, const CVector& vecPosition, const CVector& vecDirection, float fR, float fG, float fB, float fA, bool bRandomizeColors, std::uint32_t iCount, float fBrightness, float fSize, bool bRandomizeSizes, float fLife)
{
// Init our own FxPrtMult struct
FxPrtMult_c fxPrt{{fR,fG,fB,fA}, fSize, 0, fLife};
CVector newDirection;

FxSystem_c* fxParticleSystem;

switch (eFxParticle)
{
case eFxParticleSystems::PRT_BLOOD:
fxParticleSystem = m_pInterface->m_fxSysBlood;
break;
case eFxParticleSystems::PRT_BOATSPLASH:
fxParticleSystem = m_pInterface->m_fxSysBoatSplash;
break;
case eFxParticleSystems::PRT_BUBBLE:
fxParticleSystem = m_pInterface->m_fxSysBubble;
break;
case eFxParticleSystems::PRT_DEBRIS:
fxParticleSystem = m_pInterface->m_fxSysDebris;
break;
case eFxParticleSystems::PRT_GUNSHELL:
fxParticleSystem = m_pInterface->m_fxSysGunshell;
break;
case eFxParticleSystems::PRT_SAND:
fxParticleSystem = m_pInterface->m_fxSysSand;
break;
case eFxParticleSystems::PRT_SAND2:
fxParticleSystem = m_pInterface->m_fxSysSand2;
break;
case eFxParticleSystems::PRT_SMOKE:
fxParticleSystem = m_pInterface->m_fxSysSmoke;
break;
case eFxParticleSystems::PRT_SMOKEHUGE:
fxParticleSystem = m_pInterface->m_fxSysSmokeHuge;
break;
case eFxParticleSystems::PRT_SMOKE2:
fxParticleSystem = m_pInterface->m_fxSysSmoke2;
break;
case eFxParticleSystems::PRT_SPARK:
fxParticleSystem = m_pInterface->m_fxSysSpark;
break;
case eFxParticleSystems::PRT_SPARK2:
fxParticleSystem = m_pInterface->m_fxSysSpark2;
break;
case eFxParticleSystems::PRT_SPLASH:
fxParticleSystem = m_pInterface->m_fxSysSplash;
break;
case eFxParticleSystems::PRT_WAKE:
fxParticleSystem = m_pInterface->m_fxSysWake;
break;
case eFxParticleSystems::PRT_WATERSPLASH:
fxParticleSystem = m_pInterface->m_fxSysWaterSplash;
break;
case eFxParticleSystems::PRT_WHEELDIRT:
fxParticleSystem = m_pInterface->m_fxSysWheelDirt;
break;
case eFxParticleSystems::PRT_GLASS:
fxParticleSystem = m_pInterface->m_fxSysGlass;
break;
default:
fxParticleSystem = m_pInterface->m_fxSysBlood;
}

for (size_t i = 0; i < iCount; i++)
{
if (bRandomizeColors)
{
// 0x49EECB
fxPrt.m_color.red = (rand() % 10000) * 0.0001f * fR + 0.13f;
fxPrt.m_color.green = (rand() % 10000) * 0.0001f * fG + 0.12f;
fxPrt.m_color.blue = (rand() % 10000) * 0.0001f * fB + 0.04f;
}

if (bRandomizeSizes)
// 0x49EF21 - Calculate random size for each particle
fxPrt.m_fSize = (rand() % 10000) * 0.0001f * fSize + 0.3f;

// 0x49EF4C - Calculate random direction for each particle
newDirection = CVector(vecDirection.fX * 4, vecDirection.fY * 4, vecDirection.fZ * 4);
newDirection.fX = (rand() % 10000) * 0.0001f * 4 - 2 + newDirection.fX;
newDirection.fY = (rand() % 10000) * 0.0001f * 4 - 2 + newDirection.fY;
newDirection.fZ = (rand() % 10000) * 0.0001f * 4 - 2 + newDirection.fZ;

// Call FxSystem_c::AddParticle
((int(__thiscall*)(FxSystem_c*, const CVector*, const CVector*, float, FxPrtMult_c*, float, float, float, int))FUNC_FXSystem_c_AddParticle)(fxParticleSystem, &vecPosition, &newDirection, 0, &fxPrt, -1.0f, fBrightness, 0, 0);
}
}
37 changes: 37 additions & 0 deletions Client/game_sa/CFxSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <game/CFx.h>

struct RwColor;
class FxSystem_c;

#define FUNC_CFx_AddBlood 0x49eb00
#define FUNC_CFx_AddWood 0x49ee10
Expand All @@ -29,10 +30,30 @@ struct RwColor;
#define FUNC_CFx_TriggerWaterSplash 0x4a1070
#define FUNC_CFx_TriggerBulletSplash 0x4a10e0
#define FUNC_CFx_TriggerFootSplash 0x4a1150
#define FUNC_FXSystem_c_AddParticle 0x4AA440

class CFxSAInterface
{
public:
FxSystem_c* m_fxSysBlood;
FxSystem_c* m_fxSysBoatSplash;
FxSystem_c* m_fxSysBubble;
FxSystem_c* m_fxSysDebris;
FxSystem_c* m_fxSysSmoke;
FxSystem_c* m_fxSysGunshell;
FxSystem_c* m_fxSysSand;
FxSystem_c* m_fxSysSand2;
FxSystem_c* m_fxSysSmokeHuge;
FxSystem_c* m_fxSysSmoke2;
FxSystem_c* m_fxSysSpark;
FxSystem_c* m_fxSysSpark2;
FxSystem_c* m_fxSysSplash;
FxSystem_c* m_fxSysWake;
FxSystem_c* m_fxSysWaterSplash;
FxSystem_c* m_fxSysWheelDirt;
FxSystem_c* m_fxSysGlass;

private:
};

class CFxSA : public CFx
Expand All @@ -55,7 +76,23 @@ class CFxSA : public CFx
void TriggerWaterSplash(CVector& vecPosition);
void TriggerBulletSplash(CVector& vecPosition);
void TriggerFootSplash(CVector& vecPosition);
void AddParticle(eFxParticleSystems eFxParticle, const CVector& vecPosition, const CVector& vecDirection, float fR, float fG, float fB, float fA, bool bRandomizeColors, std::uint32_t iCount, float fBrightness, float fSize, bool bRandomizeSizes, float fLife);

private:
CFxSAInterface* m_pInterface;

struct FxPrtMult_c
{
struct
{
float red;
float green;
float blue;
float alpha;
} m_color;

float m_fSize;
float unk;
float m_fLife;
};
};
13 changes: 11 additions & 2 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ void CGameSA::RemoveAllBuildings()

m_pPools->GetDummyPool().RemoveAllBuildingLods();
m_pPools->GetBuildingsPool().RemoveAllBuildings();
m_isBuildingsRemoved = true;
}

void CGameSA::RestoreGameBuildings()
Expand All @@ -991,15 +992,23 @@ void CGameSA::RestoreGameBuildings()
m_pPools->GetDummyPool().RestoreAllBuildingsLods();

m_pIplStore->SetDynamicIplStreamingEnabled(true, [](CIplSAInterface* ipl) { return memcmp("barriers", ipl->name, 8) != 0; });
m_isBuildingsRemoved = false;
}

bool CGameSA::SetBuildingPoolSize(size_t size)
{
RemoveAllBuildings();
const bool shouldRemoveBuilding = !m_isBuildingsRemoved;
if (shouldRemoveBuilding)
{
RemoveAllBuildings();
}

bool status = m_pPools->GetBuildingsPool().Resize(size);

RestoreGameBuildings();
if (shouldRemoveBuilding)
{
RestoreGameBuildings();
}

return status;
}
Expand Down
1 change: 1 addition & 0 deletions Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ class CGameSA : public CGame
bool m_isBurnFlippedCarsEnabled{true};
bool m_isFireballDestructEnabled{true};
bool m_isRoadSignsTextEnabled{true};
bool m_isBuildingsRemoved{false};
bool m_isExtendedWaterCannonsEnabled{false};

static unsigned int& ClumpOffset;
Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/CPedSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ CVehicle* CPedSA::GetVehicle()
{
if (((CPedSAInterface*)GetInterface())->pedFlags.bInVehicle)
{
CVehicleSAInterface* vehicle = (CVehicleSAInterface*)(((CPedSAInterface*)GetInterface())->CurrentObjective);
CVehicleSAInterface* vehicle = (CVehicleSAInterface*)(((CPedSAInterface*)GetInterface())->pVehicle);
if (vehicle)
{
SClientEntity<CVehicleSA>* pVehicleClientEntity = pGame->GetPools()->GetVehicle((DWORD*)vehicle);
Expand Down
16 changes: 12 additions & 4 deletions Client/game_sa/CPedSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ class CPedWeaponAudioEntitySAInterface
public:
};

class CVehicleSAInterface;

class CPedSAInterface : public CPhysicalSAInterface // +1420 = current vehicle 312 first byte
{
public:
Expand Down Expand Up @@ -239,11 +241,17 @@ class CPedSAInterface : public CPhysicalSAInterface // +1420 = curre
float fCurrentRotation;
float fTargetRotation;
float fRotationSpeed;
BYTE bPad8[4];
float fMoveAnim;
CEntitySAInterface* pContactEntity;
BYTE bPad3[32];
CEntitySAInterface* CurrentObjective; // current vehicle 1420
BYTE bPad2[8]; // 1424
CVector unk_56C;
CVector unk_578;

CEntitySAInterface* pLastContactEntity;
CVehicleSAInterface* pLastVehicle;
CVehicleSAInterface* pVehicle;

int unk_590;
int unk_594;
BYTE bPedType; // ped type? 0 = player, >1 = ped? // 1432
BYTE bPad9[7];
CWeaponSAInterface Weapons[WEAPONSLOT_MAX];
Expand Down
1 change: 1 addition & 0 deletions Client/game_sa/CPoolsSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class CPoolsSA : public CPools
public:
void RemovePed(CPed* ped, bool bDelete = true);
SClientEntity<CPedSA>* GetPed(DWORD* pGameInterface);
SClientEntity<CPedSA>* GetPed(size_t pos) { return &m_pedPool.arrayOfClientEntities[pos]; };
CPed* GetPedFromRef(DWORD dwGameRef);
CPedSAInterface* GetPedInterface(DWORD dwGameRef); // game_sa specific
unsigned long GetPedCount() { return m_pedPool.ulCount; }
Expand Down
3 changes: 3 additions & 0 deletions Client/loader/Install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,9 @@ static int RunInstall()
// If the first attempt didn't work, check if any process is locking one of the files.
TerminateFileLockingProcesses(file.targetFile.absolutePath, file.relativePath);
TerminateFileLockingProcesses(file.sourceFile.absolutePath, file.relativePath);

// Ensure the checksum of the source file is correct (in case the archive reported checksum is invalid).
file.sourceFile.ComputeChecksum();
}

Sleep(OPERATION_RETRY_DELAY_IN_MS);
Expand Down
12 changes: 3 additions & 9 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2041,13 +2041,11 @@ void CClientGame::UpdateStunts()
// Did we finish a stunt?
else if (ulLastCarTwoWheelCounter != 0 && ulTemp == 0)
{
float fDistance = g_pGame->GetPlayerInfo()->GetCarTwoWheelDist();

// Call our stunt event
CLuaArguments Arguments;
Arguments.PushString("2wheeler");
Arguments.PushNumber(ulLastCarTwoWheelCounter);
Arguments.PushNumber(fDistance);
Arguments.PushNumber(fLastCarTwoWheelDist);
m_pLocalPlayer->CallEvent("onClientPlayerStuntFinish", Arguments, true);
}
ulLastCarTwoWheelCounter = ulTemp;
Expand All @@ -2068,13 +2066,11 @@ void CClientGame::UpdateStunts()
// Did we finish a stunt?
else if (ulLastBikeRearWheelCounter != 0 && ulTemp == 0)
{
float fDistance = g_pGame->GetPlayerInfo()->GetBikeRearWheelDist();

// Call our stunt event
CLuaArguments Arguments;
Arguments.PushString("wheelie");
Arguments.PushNumber(ulLastBikeRearWheelCounter);
Arguments.PushNumber(fDistance);
Arguments.PushNumber(fLastBikeRearWheelDist);
m_pLocalPlayer->CallEvent("onClientPlayerStuntFinish", Arguments, true);
}
ulLastBikeRearWheelCounter = ulTemp;
Expand All @@ -2095,13 +2091,11 @@ void CClientGame::UpdateStunts()
// Did we finish a stunt?
else if (ulLastBikeFrontWheelCounter != 0 && ulTemp == 0)
{
float fDistance = g_pGame->GetPlayerInfo()->GetBikeFrontWheelDist();

// Call our stunt event
CLuaArguments Arguments;
Arguments.PushString("stoppie");
Arguments.PushNumber(ulLastBikeFrontWheelCounter);
Arguments.PushNumber(fDistance);
Arguments.PushNumber(fLastBikeFrontWheelDist);
m_pLocalPlayer->CallEvent("onClientPlayerStuntFinish", Arguments, true);
}
ulLastBikeFrontWheelCounter = ulTemp;
Expand Down
4 changes: 4 additions & 0 deletions Client/mods/deathmatch/logic/CClientSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ bool CClientSound::Create()
m_pAudio->SetPanEnabled(m_bPan);
m_pAudio->SetPan(m_fPan);

// Also check and transfer if paused
if (m_bPaused)
m_pAudio->SetPaused(m_bPaused);

// Transfer play position if it was being simulated
EndSimulationOfPlayPositionAndApply();

Expand Down
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/CNetAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,8 @@ void CNetAPI::ReadBulletsync(CClientPlayer* pPlayer, NetBitStreamInterface& BitS
// Read the bulletsync data
uchar ucWeapon = 0;
BitStream.Read(ucWeapon);
if (!CClientPickupManager::IsValidWeaponID(ucWeapon))
return;
eWeaponType weaponType = (eWeaponType)ucWeapon;

CVector vecStart, vecEnd;
Expand Down
7 changes: 7 additions & 0 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2719,6 +2719,7 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream)
// CVector (12) - scale
// bool (1) - static
// SObjectHealthSync (?) - health
// bool (1) - is break

// Pickups:
// CVector (12) - position
Expand Down Expand Up @@ -3079,6 +3080,12 @@ void CPacketHandler::Packet_EntityAdd(NetBitStreamInterface& bitStream)
if (bitStream.Read(&health))
pObject->SetHealth(health.data.fValue);

if (bitStream.Can(eBitStreamVersion::BreakObject_Serverside))
{
if (bitStream.ReadBit())
pObject->Break();
}

pObject->SetCollisionEnabled(bCollisonsEnabled);
if (ucEntityTypeID == CClientGame::WEAPON)
{
Expand Down
Loading

0 comments on commit 22048bb

Please sign in to comment.