Supply Lines streaming fix (SA 1.0)

This commit is contained in:
Silent 2018-01-11 21:45:59 +01:00
parent 75b512764b
commit 62ed9242bc
7 changed files with 93 additions and 3 deletions

View File

@ -314,6 +314,15 @@ public:
void RenderForShadow();
};
class NOVMT CPlayerPed : public CPed
{
private:
CPed* m_pMouseLockOnRecruitPed;
int m_iMouseLockOnRecruitTimer;
};
static_assert(sizeof(CPed) == 0x79C, "Wrong size: CPed");
static_assert(sizeof(CPlayerPed) == 0x7A4, "Wrong size: CPlayerPed");
#endif

View File

@ -0,0 +1,40 @@
#include "StdAfxSA.h"
#include "PlayerInfoSA.h"
uint8_t& PlayerInFocus = **AddressByVersion<uint8_t**>( 0x56E218 + 3, 0, 0 ); // TODO: DO
CPlayerInfo* const Players = *AddressByVersion<CPlayerInfo**>( 0x56E225 + 2, 0, 0 );
CPlayerPed* FindPlayerPed( int playerID )
{
return Players[ playerID < 0 ? PlayerInFocus : playerID ].GetPlayerPed();
}
CEntity* FindPlayerEntityWithRC( int playerID )
{
CPlayerInfo* player = &Players[ playerID < 0 ? PlayerInFocus : playerID ];
CPlayerPed* ped = player->GetPlayerPed();
CVehicle* remoteVehicle = player->GetControlledVehicle();
if ( remoteVehicle != nullptr ) return remoteVehicle;
if ( ped->GetPedFlags().bInVehicle )
{
CVehicle* normalVehicle = ped->GetVehiclePtr();
if ( normalVehicle != nullptr ) return normalVehicle;
}
return ped;
}
CVehicle* FindPlayerVehicle( int playerID, bool withRC )
{
CPlayerInfo* player = &Players[ playerID < 0 ? PlayerInFocus : playerID ];
CPlayerPed* ped = player->GetPlayerPed();
if ( ped == nullptr ) return nullptr;
if ( !ped->GetPedFlags().bInVehicle ) return nullptr;
CVehicle* vehicle = player->GetControlledVehicle();
if ( !withRC || vehicle == nullptr )
{
vehicle = ped->GetVehiclePtr();
}
return vehicle;
}

View File

@ -0,0 +1,23 @@
#pragma once
#include "PedSA.h"
#include "VehicleSA.h"
class CPlayerInfo
{
private:
CPlayerPed* m_pPed;
uint8_t __pad2[0xAC];
CVehicle* m_pControlledVehicle;
uint8_t __pad[0xDC];
public:
CPlayerPed* GetPlayerPed() const { return m_pPed; }
CVehicle* GetControlledVehicle() const { return m_pControlledVehicle; }
};
CPlayerPed* FindPlayerPed( int playerID = -1 );
CEntity* FindPlayerEntityWithRC( int playerID = -1 );
CVehicle* FindPlayerVehicle( int playerID = -1, bool withRC = false );
static_assert(sizeof(CPlayerInfo) == 0x190, "Wrong size: CPlayerInfo");

View File

@ -14,6 +14,7 @@
#include "AudioHardwareSA.h"
#include "LinkListSA.h"
#include "PNGFile.h"
#include "PlayerInfoSA.h"
#include "WaveDecoderSA.h"
#include "FLACDecoderSA.h"
@ -1335,6 +1336,11 @@ namespace FakeQPC
}
}
static CVehicle* FindPlayerVehicle_RCWrap( int playerID, bool )
{
return FindPlayerVehicle( playerID, true );
}
#endif
#if MEM_VALIDATORS
@ -3407,6 +3413,11 @@ void Patch_SA_10()
// unnamed CdStream semaphore
Patch( 0x406945, { 0x6A, 0x00 } ); // push 0 \ nop
Nop( 0x406945 + 2, 3 );
// Correct streaming when using RC vehicles
InjectHook( 0x55574B, FindPlayerEntityWithRC );
InjectHook( 0x5557C3, FindPlayerVehicle_RCWrap );
}
void Patch_SA_11()

View File

@ -198,6 +198,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
<ClCompile Include="GeneralSA.cpp" />
<ClCompile Include="ModelInfoSA.cpp" />
<ClCompile Include="PedSA.cpp" />
<ClCompile Include="PlayerInfoSA.cpp" />
<ClCompile Include="PNGFile.cpp" />
<ClCompile Include="PoolsSA.cpp" />
<ClCompile Include="ScriptSA.cpp" />
@ -232,6 +233,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
<ClInclude Include="Maths.h" />
<ClInclude Include="ModelInfoSA.h" />
<ClInclude Include="PedSA.h" />
<ClInclude Include="PlayerInfoSA.h" />
<ClInclude Include="PNGFile.h" />
<ClInclude Include="PoolsSA.h" />
<ClInclude Include="resource.h" />

View File

@ -66,6 +66,9 @@
<ClCompile Include="PoolsSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="PlayerInfoSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\MemoryMgr.h">
@ -155,6 +158,9 @@
<ClInclude Include="..\SilentPatch\ModuleList.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PlayerInfoSA.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc">

View File

@ -7,6 +7,7 @@
#include "TimerSA.h"
#include "PedSA.h"
#include "DelimStringReader.h"
#include "PlayerInfoSA.h"
static constexpr float PHOENIX_FLUTTER_PERIOD = 70.0f;
static constexpr float PHOENIX_FLUTTER_AMP = 0.13f;
@ -28,8 +29,6 @@ WRAPPER void CVehicle::Render() { VARJMP(varVehicleRender); }
static void* varIsLawEnforcementVehicle = AddressByVersion<void*>(0x6D2370, 0x6D2BA0, 0x70D8C0);
WRAPPER bool CVehicle::IsLawEnforcementVehicle() { VARJMP(varIsLawEnforcementVehicle); }
auto FindPlayerPed = AddressByVersion<CPed*(*)(int)>( 0x56E210, 0, 0 ); // TODO: DO
void (CVehicle::*CVehicle::orgVehiclePreRender)();
void (CAutomobile::*CAutomobile::orgAutomobilePreRender)();
void (CPlane::*CPlane::orgPlanePreRender)();
@ -472,7 +471,7 @@ CVehicle* CStoredCar::RestoreCar_SilentPatch()
if ( vehicle->GetClass() == VEHICLE_AUTOMOBILE || vehicle->GetClass() == VEHICLE_BIKE )
{
vehicle->SetBombOnBoard( m_bombType );
vehicle->SetBombOwner( FindPlayerPed(-1) );
vehicle->SetBombOwner( FindPlayerPed() );
}
}