Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new world special property (vehicle sun glare effect) #2495

Merged
merged 21 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e770a69
add
gta191977649 Dec 31, 2021
39f3d39
Implmented Global hook without using client render
gta191977649 Jan 1, 2022
c5628c8
Revert "Improve addEvent when sharing events over multiple resources …
gta191977649 Jan 2, 2022
002f1ce
Revert "Implmented Global hook without using client render"
gta191977649 Jan 2, 2022
d93f019
Revert "add"
gta191977649 Jan 2, 2022
5005d0e
add
gta191977649 Jan 2, 2022
ba0e288
Add "vehiclesunglare" property to setWorldSpecialPropertyEnabled
gta191977649 Jan 2, 2022
991c4cb
Revert "Improve addEvent when sharing events over multiple resources …
gta191977649 Jan 2, 2022
590de57
Merge branch 'master' into feature/vehicle-sun-glare
gta191977649 Jan 2, 2022
a6d0d83
Revert "Revert "Improve addEvent when sharing events over multiple re…
TheNormalnij Jan 3, 2022
e39274e
Merge remote-tracking branch 'mta_main/master' into feature/vehicle-s…
TheNormalnij Jan 3, 2022
eaac514
Put the Hook Address to header
gta191977649 Jan 6, 2022
a190a3a
Refactor moved the hooks to CVehicleSA
gta191977649 Jan 8, 2022
17cb168
should initialize it prevent memory leak
gta191977649 Jan 8, 2022
198a8b6
Added spaces between blocks
gta191977649 Jan 12, 2022
ea1b5e3
changed int to BOOL
gta191977649 Jan 12, 2022
029419a
fixed the naming convention
gta191977649 Jan 12, 2022
eba69be
Merge remote-tracking branch 'mta_main/master' into feature/vehicle-s…
TheNormalnij Jan 19, 2022
9dab410
Merge remote-tracking branch 'mta_main/master' into feature/vehicle-s…
TheNormalnij Jan 22, 2022
ec8edcb
Remove some extra spaces
TheNormalnij Jan 22, 2022
15f6575
fix comment
TheNormalnij Jan 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ unsigned long* CGameSA::VAR_Framelimiter;

unsigned int OBJECTDYNAMICINFO_MAX = *(uint32_t*)0x59FB4C != 0x90909090 ? *(uint32_t*)0x59FB4C : 160; // default: 160


/**
* \todo allow the addon to change the size of the pools (see 0x4C0270 - CPools::Initialise) (in start game?)
*/
CGameSA::CGameSA()
{

pGame = this;
m_bAsyncScriptEnabled = false;
m_bAsyncScriptForced = false;
Expand Down Expand Up @@ -222,6 +224,8 @@ CGameSA::CGameSA()
CFxSystemSA::StaticSetHooks();
CFileLoaderSA::StaticSetHooks();
D3DResourceSystemSA::StaticSetHooks();
CVehicleSA::StaticSetHooks();

}

CGameSA::~CGameSA()
Expand Down Expand Up @@ -603,6 +607,9 @@ bool CGameSA::IsCheatEnabled(const char* szCheatName)
if (!strcmp(szCheatName, PROP_UNDERWORLD_WARP))
return IsUnderWorldWarpEnabled();

if (!strcmp(szCheatName, PROP_VEHICLE_SUNGLARE))
return IsVehicleSunGlareEnabled();

std::map<std::string, SCheatSA*>::iterator it = m_Cheats.find(szCheatName);
if (it == m_Cheats.end())
return false;
Expand Down Expand Up @@ -635,6 +642,13 @@ bool CGameSA::SetCheatEnabled(const char* szCheatName, bool bEnable)
return true;
}

if (!strcmp(szCheatName, PROP_VEHICLE_SUNGLARE))
{
SetVehicleSunGlareEnabled(bEnable);
return true;
}


std::map<std::string, SCheatSA*>::iterator it = m_Cheats.find(szCheatName);
if (it == m_Cheats.end())
return false;
Expand Down Expand Up @@ -724,6 +738,17 @@ void CGameSA::SetJetpackWeaponEnabled(eWeaponType weaponType, bool bEnabled)
}
}

void CGameSA::SetVehicleSunGlareEnabled(bool bEnabled)
{
// State turning will be handled in hooks handler
CVehicleSA::SetVehiclesSunGlareEnable(bEnabled);
}

bool CGameSA::IsVehicleSunGlareEnabled()
{
return CVehicleSA::GetVehiclesSunGlareEnable();
}

bool CGameSA::PerformChecks()
{
std::map<std::string, SCheatSA*>::iterator it;
Expand Down
8 changes: 8 additions & 0 deletions Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ extern unsigned int OBJECTDYNAMICINFO_MAX; // default: 160
#define PROP_SNIPER_MOON "snipermoon"
#define PROP_EXTRA_AIR_RESISTANCE "extraairresistance"
#define PROP_UNDERWORLD_WARP "underworldwarp"
#define PROP_VEHICLE_SUNGLARE "vehiclesunglare"


struct SCheatSA
{
Expand Down Expand Up @@ -391,6 +393,11 @@ class CGameSA : public CGame
void SetJetpackWeaponEnabled(eWeaponType weaponType, bool bEnabled);
bool GetJetpackWeaponEnabled(eWeaponType weaponType);

void SetVehicleSunGlareEnabled(bool bEnabled);
bool IsVehicleSunGlareEnabled();



unsigned long GetMinuteDuration();
void SetMinuteDuration(unsigned long ulTime);

Expand Down Expand Up @@ -507,6 +514,7 @@ class CGameSA : public CGame
int m_iCheckStatus;
bool m_bUnderworldWarp;


static unsigned int& ClumpOffset;
static unsigned long* VAR_SystemTime;
static unsigned long* VAR_IsAtMenu;
Expand Down
38 changes: 38 additions & 0 deletions Client/game_sa/CVehicleSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@ bool g_bVehiclePointerInvalid = false;

#include "gamesa_renderware.h"

static int m_iVehicleSunGlare = 0;
_declspec(naked) void DoVehicleSunGlare(void* this_)
{
_asm {
mov eax, FUNC_CVehicle_DoSunGlare
jmp eax
}
}

void _declspec(naked) HOOK_Vehicle_PreRender(void)
{
_asm {
mov ecx, m_iVehicleSunGlare
cmp ecx, 0
jle noglare
mov ecx, esi
call DoVehicleSunGlare
noglare:
mov [esp+0D4h], edi
push 6ABD04h
retn
}
}

namespace
{
bool ClumpDumpCB(RpAtomic* pAtomic, void* data)
Expand Down Expand Up @@ -2318,6 +2342,20 @@ void CVehicleSA::OnChangingPosition(const CVector& vecNewPosition)
}
}

void CVehicleSA::StaticSetHooks()
{
// Setup Vehicle Sun Glare Hook
HookInstall(FUNC_CAutomobile_OnVehiclePreRender, (DWORD)HOOK_Vehicle_PreRender, 5);
}

void CVehicleSA::SetVehiclesSunGlareEnable(bool bEnabled)
{
m_iVehicleSunGlare = bEnabled ? 1 : 0;
}
bool CVehicleSA::GetVehiclesSunGlareEnable()
{
return m_iVehicleSunGlare == 1 ? true : false;
}
namespace
TheNormalnij marked this conversation as resolved.
Show resolved Hide resolved
{
VOID _MatrixConvertFromEulerAngles(CMatrix_Padded* matrixPadded, float fX, float fY, float fZ)
Expand Down
8 changes: 8 additions & 0 deletions Client/game_sa/CVehicleSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ class CVehicleSA;
#define VAR_CVehicle_Variation1 0x8A6458
#define VAR_CVehicle_Variation2 0x8A6459

// for vehicle sun glare
#define FUNC_CAutomobile_OnVehiclePreRender 0x6ABCFD
#define FUNC_CVehicle_DoSunGlare 0x6DD6F0

struct SRailNodeSA
{
short sX; // x coordinate times 8
Expand Down Expand Up @@ -769,6 +773,10 @@ class CVehicleSA : public virtual CVehicle, public virtual CPhysicalSA
CVector* GetDummyPositions() { return m_dummyPositions.data(); }
const CVector* GetDummyPositions() const override { return m_dummyPositions.data(); }

static void StaticSetHooks();
static void SetVehiclesSunGlareEnable(bool bEnabled);
static bool GetVehiclesSunGlareEnable();

private:
static void SetAutomobileDummyPosition(CAutomobileSAInterface* automobile, eVehicleDummies dummy, const CVector& position);

Expand Down