mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 06:43:01 +05:00
Mostly ready for multiple EXEs compatibility
TODO: RW calls
This commit is contained in:
parent
b80846091f
commit
abb1db6b44
10 changed files with 49 additions and 31 deletions
|
@ -128,9 +128,6 @@ public:
|
|||
class CAEWaveDecoder : public CAEStreamingDecoder
|
||||
{
|
||||
private:
|
||||
unsigned short nNumChannels;
|
||||
unsigned short nBitRate;
|
||||
unsigned int nSampleRate;
|
||||
unsigned int nDataSize;
|
||||
unsigned int nOffsetToData;
|
||||
//bool bInitialised;
|
||||
|
|
|
@ -2,18 +2,13 @@
|
|||
#include "GeneralSA.h"
|
||||
|
||||
// Wrappers
|
||||
WRAPPER bool CalcScreenCoors(const CVector& vecIn, CVector* vecOut) { WRAPARG(vecIn); WRAPARG(vecOut); EAXJMP(0x71DAB0); }
|
||||
WRAPPER void LoadingScreenLoadingFile(const char* pText) { WRAPARG(pText); EAXJMP(0x5B3680); }
|
||||
static void* EntityRender = AddressByVersion<void*>(0x534310, 0, 0);
|
||||
WRAPPER void CEntity::Render() { VARJMP(EntityRender); }
|
||||
|
||||
WRAPPER void CEntity::UpdateRW() { EAXJMP(0x446F90); }
|
||||
WRAPPER void CEntity::RegisterReference(CEntity** pAddress) { WRAPARG(pAddress); EAXJMP(0x571B70); }
|
||||
WRAPPER void CEntity::CleanUpOldReference(CEntity** pAddress) { WRAPARG(pAddress); EAXJMP(0x571A00); }
|
||||
WRAPPER void CEntity::Render() { EAXJMP(0x534310); }
|
||||
static RwTexture*& ms_pRemapTexture = **AddressByVersion<RwTexture***>(0x59F1BD, 0, 0);
|
||||
static unsigned char* ms_currentCol = *AddressByVersion<unsigned char**>(0x4C84C8, 0, 0);
|
||||
|
||||
static RwTexture*& ms_pRemapTexture = *(RwTexture**)0xB4E47C;
|
||||
static unsigned char* ms_currentCol = *(unsigned char**)0x4C84C8;
|
||||
|
||||
WRAPPER RpAtomic* SetEditableMaterialsCB(RpAtomic* pMaterial, void* pData) { WRAPARG(pMaterial); WRAPARG(pData); EAXJMP(0x4C83E0); }
|
||||
auto SetEditableMaterialsCB = AddressByVersion<RpAtomic*(*)(RpAtomic*,void*)>(0x4C83E0, 0, 0);
|
||||
|
||||
static void SetVehicleColour(unsigned char primaryColour, unsigned char secondaryColour, unsigned char tertiaryColour, unsigned char quaternaryColour)
|
||||
{
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#include "StdAfxSA.h"
|
||||
#include "ModelInfoSA.h"
|
||||
|
||||
WRAPPER void CBaseModelInfo::Shutdown() { EAXJMP(0x4C4D50); }
|
||||
static void* BaseModelInfoShutdown = AddressByVersion<void*>(0x4C4D50, 0, 0);
|
||||
WRAPPER void CBaseModelInfo::Shutdown() { VARJMP(BaseModelInfoShutdown); }
|
||||
|
||||
WRAPPER RwTexture* CCustomCarPlateMgr::CreatePlateTexture(const char* pText, signed char nDesign) { EAXJMP(0x6FDEA0); }
|
||||
WRAPPER bool CCustomCarPlateMgr::GeneratePlateText(char* pBuf, int nLen) { EAXJMP(0x6FD5B0); }
|
||||
WRAPPER signed char CCustomCarPlateMgr::GetMapRegionPlateDesign() { EAXJMP(0x6FD7A0); }
|
||||
WRAPPER void CCustomCarPlateMgr::SetupMaterialPlatebackTexture(RpMaterial* pMaterial, signed char nDesign) { EAXJMP(0x6FDE50); }
|
||||
RwTexture* (*CCustomCarPlateMgr::CreatePlateTexture)(const char* pText, signed char nDesign) = AddressByVersion<RwTexture*(*)(const char*,signed char)>(0x6FDEA0, 0, 0);
|
||||
bool (*CCustomCarPlateMgr::GeneratePlateText)(char* pBuf, int nLen) = AddressByVersion<bool(*)(char*,int)>(0x6FD5B0, 0, 0);
|
||||
signed char (*CCustomCarPlateMgr::GetMapRegionPlateDesign)() = AddressByVersion<signed char(*)()>(0x6FD7A0, 0, 0);
|
||||
void (*CCustomCarPlateMgr::SetupMaterialPlatebackTexture)(RpMaterial* pMaterial, signed char nDesign) = AddressByVersion<void(*)(RpMaterial*,signed char)>(0x6FDE50, 0, 0);
|
||||
|
||||
void CVehicleModelInfo::Shutdown()
|
||||
{
|
||||
|
|
|
@ -292,10 +292,10 @@ private:
|
|||
//static signed char m_nCurPlateDesign;
|
||||
|
||||
public:
|
||||
static RwTexture* CreatePlateTexture(const char* pText, signed char nDesign);
|
||||
static bool GeneratePlateText(char* pBuf, int nLen);
|
||||
static signed char GetMapRegionPlateDesign();
|
||||
static void SetupMaterialPlatebackTexture(RpMaterial* pMaterial, signed char nDesign);
|
||||
static RwTexture* (*CreatePlateTexture)(const char* pText, signed char nDesign);
|
||||
static bool (*GeneratePlateText)(char* pBuf, int nLen);
|
||||
static signed char (*GetMapRegionPlateDesign)();
|
||||
static void (*SetupMaterialPlatebackTexture)(RpMaterial* pMaterial, signed char nDesign);
|
||||
|
||||
static void SetupClump(RpClump* pClump, RpMaterial** pMatsArray);
|
||||
static void SetupClumpAfterVehicleUpgrade(RpClump* pClump, RpMaterial** pMatsArray, signed char nDesign);
|
||||
|
|
|
@ -24,10 +24,11 @@ RwTexture* CPNGFile::ReadFromFile(const char* pFileName)
|
|||
|
||||
RwTexture* CPNGFile::ReadFromMemory(const void* pMemory, unsigned int nLen)
|
||||
{
|
||||
static BYTE* pMem = AddressByVersion<BYTE*>(0x7CF9CA, 0, 0);
|
||||
RwTexture* pTexture = nullptr;
|
||||
|
||||
// TOOO: EXEs
|
||||
MemoryVP::Patch<BYTE>(0x7CF9CA, rwSTREAMMEMORY);
|
||||
MemoryVP::Patch<BYTE>(pMem, rwSTREAMMEMORY);
|
||||
|
||||
RwMemory PNGMemory;
|
||||
PNGMemory.start = const_cast<RwUInt8*>(static_cast<const RwUInt8*>(pMemory));
|
||||
|
@ -48,7 +49,7 @@ RwTexture* CPNGFile::ReadFromMemory(const void* pMemory, unsigned int nLen)
|
|||
RwImageDestroy(pImage);
|
||||
}
|
||||
|
||||
MemoryVP::Patch<BYTE>(0x7CF9CA, rwSTREAMFILENAME);
|
||||
MemoryVP::Patch<BYTE>(pMem, rwSTREAMFILENAME);
|
||||
|
||||
return pTexture;
|
||||
}
|
|
@ -77,6 +77,9 @@ CZoneInfo*& pCurrZoneInfo = **AddressByVersion<CZoneInfo***>(0x58ADB1, 0, 0);
|
|||
CRGBA* HudColour = *AddressByVersion<CRGBA**>(0x58ADF6, 0, 0);
|
||||
unsigned char* ZonesVisited = *AddressByVersion<unsigned char**>(0x57216A, 0, 0) - 9;
|
||||
|
||||
float& m_fDNBalanceParam = **AddressByVersion<float**>(0x4A9062, 0, 0);
|
||||
RpLight*& pAmbient = **AddressByVersion<RpLight***>(0x5BA53A, 0, 0);
|
||||
|
||||
CLinkListSA<CEntity*>& ms_weaponPedsForPC = **AddressByVersion<CLinkListSA<CEntity*>**>(0x53EACA, 0, 0);
|
||||
CLinkListSA<AlphaObjectInfo>& m_alphaList = **AddressByVersion<CLinkListSA<AlphaObjectInfo>**>(0x733A4D, 0, 0);
|
||||
|
||||
|
@ -537,10 +540,9 @@ void SetShader(RxD3D9InstanceData* pInstData)
|
|||
{
|
||||
if ( bRenderNVC )
|
||||
{
|
||||
// TODO: Daynight balance var
|
||||
D3DMATRIX outMat;
|
||||
float fEnvVars[2] = { *(float*)0x8D12C0, RpMaterialGetColor(pInstData->material)->alpha * (1.0f/255.0f) };
|
||||
RwRGBAReal* AmbientLight = RpLightGetColor(*(RpLight**)0xC886E8);
|
||||
float fEnvVars[2] = { m_fDNBalanceParam, RpMaterialGetColor(pInstData->material)->alpha * (1.0f/255.0f) };
|
||||
RwRGBAReal* AmbientLight = RpLightGetColor(pAmbient);
|
||||
|
||||
// Normalise the balance
|
||||
if ( fEnvVars[0] < 0.0f )
|
||||
|
@ -551,6 +553,7 @@ void SetShader(RxD3D9InstanceData* pInstData)
|
|||
RwD3D9SetVertexShader(pNVCShader);
|
||||
|
||||
_rwD3D9VSSetActiveWorldMatrix(RwFrameGetLTM(RpAtomicGetFrame(pRenderedAtomic)));
|
||||
//_rwD3D9VSSetActiveWorldMatrix(RwFrameGetMatrix(RpAtomicGetFrame(pRenderedAtomic)));
|
||||
_rwD3D9VSGetComposedTransformMatrix(&outMat);
|
||||
|
||||
RwD3D9SetVertexShaderConstant(0, &outMat, 4);
|
||||
|
@ -1307,6 +1310,7 @@ __forceinline void Patch_SA_10()
|
|||
// PS2 SUN!!!!!!!!!!!!!!!!!
|
||||
static const float fSunMult = (1050.0f * 0.95f) / 1500.0f;
|
||||
|
||||
// TODO: Use min()
|
||||
Nop(0x6FB17C, 3);
|
||||
Patch<const void*>(0x6FC5B0, &fSunMult);
|
||||
//Patch<WORD>(0x6FB172, 0x0BEB);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#pragma warning(disable:4401) // member is bit field
|
||||
#pragma warning(disable:4733) // handler not registered as safe handler
|
||||
#pragma warning(disable:4725) // instruction may be inaccurate on some Pentiums
|
||||
#pragma warning(disable:4201) // nonstandard extension used: nameless struct/union
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
#include "VehicleSA.h"
|
||||
#include "TimerSA.h"
|
||||
|
||||
WRAPPER void CVehicle::SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha) { WRAPARG(pAtomic); WRAPARG(nAlpha); EAXJMP(0x6D2960); }
|
||||
WRAPPER void CVehicle::Render() { EAXJMP(0x6D0E60); }
|
||||
WRAPPER bool CVehicle::IsLawEnforcementVehicle() { EAXJMP(0x6D2370); }
|
||||
void (*CVehicle::SetComponentAtomicAlpha)(RpAtomic* pAtomic, int nAlpha) = AddressByVersion<void(*)(RpAtomic*,int)>(0x6D2960, 0, 0);
|
||||
|
||||
static void* varVehicleRender = AddressByVersion<void*>(0x6D0E60, 0, 0);
|
||||
WRAPPER void CVehicle::Render() { VARJMP(varVehicleRender); }
|
||||
static void* varIsLawEnforcementVehicle = AddressByVersion<void*>(0x6D2370, 0, 0);
|
||||
WRAPPER bool CVehicle::IsLawEnforcementVehicle() { VARJMP(varIsLawEnforcementVehicle); }
|
||||
|
||||
static RwObject* GetCurrentAtomicObjectCB(RwObject* pObject, void* data)
|
||||
{
|
||||
|
|
|
@ -115,7 +115,7 @@ public:
|
|||
|
||||
bool IsLawEnforcementVehicle();
|
||||
|
||||
static void SetComponentAtomicAlpha(RpAtomic* pAtomic, int nAlpha);
|
||||
static void (*SetComponentAtomicAlpha)(RpAtomic* pAtomic, int nAlpha);
|
||||
};
|
||||
|
||||
class NOVMT CAutomobile : public CVehicle
|
||||
|
|
|
@ -29,6 +29,12 @@ inline bool* GetEuropean()
|
|||
return &bEuropean;
|
||||
}
|
||||
|
||||
inline void* GetDummy()
|
||||
{
|
||||
static DWORD dwDummy;
|
||||
return &dwDummy;
|
||||
}
|
||||
|
||||
// This function initially detects SA version then chooses the address basing on game version
|
||||
template<typename T>
|
||||
inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
|
||||
|
@ -64,10 +70,16 @@ inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
|
|||
*bEuropean = false;
|
||||
}
|
||||
}
|
||||
|
||||
switch ( *bVer )
|
||||
{
|
||||
case 1:
|
||||
assert(address11);
|
||||
|
||||
// Safety measures - if null, return dummy var pointer to prevent a crash
|
||||
if ( !address11 )
|
||||
return (T)GetDummy();
|
||||
|
||||
// Adjust to EU if needed
|
||||
if ( *bEuropean && address11 > 0x746FA0 )
|
||||
{
|
||||
|
@ -79,6 +91,10 @@ inline T AddressByVersion(DWORD address10, DWORD address11, DWORD addressSteam)
|
|||
return (T)address11;
|
||||
case 2:
|
||||
assert(addressSteam);
|
||||
// Safety measures - if null, return dummy var pointer to prevent a crash
|
||||
if ( !addressSteam )
|
||||
return (T)GetDummy();
|
||||
|
||||
return (T)addressSteam;
|
||||
default:
|
||||
assert(address10);
|
||||
|
|
Loading…
Reference in a new issue