Skip to content

Commit 86cc0ce

Browse files
1.3.1
1 parent f2be270 commit 86cc0ce

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <sautils.h>
77

88
/* Same name but can be used for VC too! (!!!not working currently!!!) */
9-
MYMOD(net.rusjj.gtasa.utils, SAUtils, 1.3.0, RusJJ)
9+
MYMOD(net.rusjj.gtasa.utils, SAUtils, 1.3.1, RusJJ)
1010
//NEEDGAME(com.rockstargames.gtasa)
1111

1212
uintptr_t pGameLib = 0;

sautils.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ std::vector<OnPlayerProcessFn> gPlayerUpdateFns;
2020
std::vector<OnPlayerProcessFn> gPlayerUpdatePostFns;
2121

2222
/* Saves */
23-
std::vector<AdditionalSetting*> gMoreSettings;
24-
std::vector<AdditionalTexDB*> gMoreTexDBs;
25-
std::vector<const char*> gMoreIMGs;
23+
std::vector<AdditionalSetting*> gMoreSettings;
24+
std::vector<AdditionalTexDB*> gMoreTexDBs;
25+
std::vector<const char*> gMoreIMGs;
2626
std::vector<AdditionalSettingsButton*> gMoreSettingButtons;
27-
int nNextSettingNum = MODS_SETTINGS_STARTING_FROM - 1;
28-
int nCurrentSliderId = 0;
27+
int nNextSettingNum = MODS_SETTINGS_STARTING_FROM - 1;
28+
int nCurrentSliderId = 0;
2929
eTypeOfSettings nCurrentItemTab = SetType_Mods;
30-
bool g_bIsGameStartedAlready = false;
30+
bool g_bIsGameStartedAlready = false;
3131

3232
/* Patched vars */
33-
int pNewSettings[8 * MAX_SETTINGS] {0}; // A new char MobileSettings::settings[37*8*4]
34-
CWidget* pNewWidgets[MAX_WIDGETS] {NULL};
35-
char pNewStreamingFiles[48 * (MAX_IMG_ARCHIVES + 2)] {0}; // A new char CStreaming::ms_files[48 * 8]; // 0 and 1 are used for player and something
33+
int pNewSettings[8 * MAX_SETTINGS] {0}; // A new char MobileSettings::settings[37*8*4]
34+
CWidget* pNewWidgets[MAX_WIDGETS] {NULL};
35+
char pNewStreamingFiles[48 * (MAX_IMG_ARCHIVES + 2)] {0}; // A new char CStreaming::ms_files[48 * 8]; // 0 and 1 are used for player and something
3636

3737
/* Funcs */
3838
typedef void* (*SettingsAddItemFn)(void* a1, uintptr_t a2);
@@ -72,6 +72,7 @@ unsigned short* gxtErrorString;
7272
uintptr_t OnRestoreDefaultsFn, OnRestoreDefaultsAudioFn;
7373
unsigned int* m_snTimeInMilliseconds;
7474
float* game_FPS;
75+
CWidget** orgWidgetsPtr;
7576

7677
/* SAUtils */
7778
void AddRestoreDefaultsItem(void* screen, bool isAudio = false)
@@ -117,17 +118,13 @@ void AddSettingsToScreen(void* screen)
117118
DECL_HOOKv(CreateAllWidgets)
118119
{
119120
CreateAllWidgets();
121+
memcpy(orgWidgetsPtr, pNewWidgets, sizeof(void*) * 150); // Hack to support old dumb CLEO's that cannot work the better way...
120122
int size = gCreateWidgetFns.size();
121123
for(int i = 0; i < size; ++i)
122124
{
123125
gCreateWidgetFns[i]();
124126
}
125127
}
126-
DECL_HOOKv(WidgetButtonUpdate, CWidgetButton* self)
127-
{
128-
if(self->enabled) return;
129-
WidgetButtonUpdate(self);
130-
}
131128

132129
DECL_HOOK(unsigned short*, AsciiToGxtChar, const char* txt, unsigned short* ret)
133130
{
@@ -333,21 +330,24 @@ DECL_HOOKv(InitialiseGame_SecondPass)
333330
g_bIsGameStartedAlready = true;
334331
}
335332

336-
DECL_HOOKv(PlayerProcess, CPlayerInfo* self, int a1)
333+
DECL_HOOKv(PlayerProcess, CPlayerInfo* self, uint32_t playerIndex)
337334
{
338-
if(self == &WorldPlayers[0])
335+
int size;
336+
if(playerIndex == 0 && (size = gPlayerUpdateFns.size()) > 0)
339337
{
340-
int size = gPlayerUpdateFns.size();
341338
for(int i = 0; i < size; ++i) gPlayerUpdateFns[i]((uintptr_t)self);
342339

343-
PlayerProcess(self, a1);
340+
PlayerProcess(self, playerIndex);
344341

345342
size = gPlayerUpdatePostFns.size();
346343
for(int i = 0; i < size; ++i) gPlayerUpdatePostFns[i]((uintptr_t)self);
347344

348345
return;
349346
}
350-
PlayerProcess(self, a1);
347+
else
348+
{
349+
PlayerProcess(self, playerIndex);
350+
}
351351
}
352352

353353
uintptr_t NewScreen_Controls_backto, NewScreen_Game_backto, NewScreen_Display_backto, NewScreen_Audio_backto;
@@ -479,7 +479,6 @@ void SAUtils::InitializeSAUtils()
479479
aml->Unprot(pGameLib + 0x2B0C34, sizeof(char)); *(unsigned char*)(pGameLib + 0x2B0C34) = (unsigned char)MAX_WIDGETS; // Draw All
480480
aml->Unprot(pGameLib + 0x2B28E8, sizeof(char)); *(unsigned char*)(pGameLib + 0x2B28E8) = (unsigned char)MAX_WIDGETS-1; // AnyWidgetsUsingAltBack
481481
HOOKPLT(CreateAllWidgets, pGameLib + 0x6734E4);
482-
//HOOK(WidgetButtonUpdate, aml->GetSym(pGameHandle, "_ZN13CWidgetButton6UpdateEv"));
483482

484483
// Hook functions
485484
HOOKPLT(AsciiToGxtChar, pGameLib + 0x6724F8);
@@ -538,6 +537,7 @@ void SAUtils::InitializeSAUtils()
538537
SET_TO(gMobileMenu, aml->GetSym(pGameHandle, "gMobileMenu"));
539538
SET_TO(m_snTimeInMilliseconds, aml->GetSym(pGameHandle, "_ZN6CTimer22m_snTimeInMillisecondsE"));
540539
SET_TO(game_FPS, aml->GetSym(pGameHandle, "_ZN6CTimer8game_FPSE"));
540+
SET_TO(orgWidgetsPtr, aml->GetSym(pGameHandle, "_ZN15CTouchInterface10m_pWidgetsE"));
541541
SET_TO(WorldPlayers, *(void**)(pGameLib + 0x6783C8));
542542
}
543543
void SAUtils::InitializeVCUtils()

0 commit comments

Comments
 (0)