Skip to content

Commit

Permalink
Merge pull request #8 from CrabJounrnal/master
Browse files Browse the repository at this point in the history
Return control after autopilot and MakeUserCall fix
  • Loading branch information
nlgxzef authored May 16, 2021
2 parents 13c287c + 6752a25 commit 2a78858
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
7 changes: 7 additions & 0 deletions NFSUExtraOptions/GlobalVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@
#define _PlayersByNumber 0x7361B4
#define _pCurrentRace 0x73619C
#define _Camera_StopUpdating 0x735F5C

enum InputMode :DWORD {
IM_menu = 1,
IM_game = 2,
//...
IM_unk_mb_last = 8
};
12 changes: 11 additions & 1 deletion NFSUExtraOptions/HotkeyStuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ void Thing()
else
{
MakeUserCall(Player_AutoPilotOff, 1, edi, PlayerThing);
// can't use MakeUserCall because ChangeInputMode is stdcall like function as most functions in game
//MakeUserCall(SetInputMode, 2, eax, *(void**)_PlayersByIndex, esp, InputMode::IM_game);
_asm
{
mov ebx, _PlayersByIndex
mov ebx, [ebx]
mov eax, ebx
push IM_game
call SetInputMode
}
}
}
}
Expand All @@ -121,4 +131,4 @@ void Thing()
}

_asm popad;
}
}
3 changes: 2 additions & 1 deletion NFSUExtraOptions/InGameFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ int(*FEngSetScript)(char const* EAX_pkg, char const* EDX_obj_name, char const* s
int(*PreRaceStatsScreen_SetVisibility)(DWORD* PreRaceStatsScreen, bool EAX_visible) = (int(*)(DWORD*, bool))0x4959D0;
bool(*FEngIsScriptRunning)(char const* EAX_pkg, int EDI_hash, char const* script) = (bool(*)(char const*, int, char const*))0x4F6C80;
int(*FEngSetVisible)(char const* EDI_pkg,char const* EDX_obj) = (int(*)(char const*, char const*))0x414A60;
DWORD QRModeSelectScreen_MaybeMakeGameModeAvailable = 0x4B6FE0;
DWORD QRModeSelectScreen_MaybeMakeGameModeAvailable = 0x4B6FE0;
void(_stdcall* SetInputMode)(void* EAX_Player, InputMode stack_mode) = (void(_stdcall*)(void*, InputMode))0x42D520;
8 changes: 4 additions & 4 deletions NFSUExtraOptions/UserCalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ R MakeUserCall(R _func, int _numArgs, ...)

va_end(ap);

// get stack difference
int _stack = _pushArgs.size() * 4;

// move args to the register struct
for (FuncArg i : _args)
{
Expand Down Expand Up @@ -120,6 +117,9 @@ R MakeUserCall(R _func, int _numArgs, ...)

// push args in reverse order
reverse(_pushArgs.begin(), _pushArgs.end());

DWORD esp_target;
_asm mov [esp_target], esp

for (FuncArg s : _pushArgs)
{
Expand All @@ -138,7 +138,7 @@ R MakeUserCall(R _func, int _numArgs, ...)

// invoke the call
call _func;
add esp, _stack;
mov esp, [esp_target]
mov _retval, eax;
}

Expand Down

0 comments on commit 2a78858

Please sign in to comment.