Skip to content

Commit 75ff6ca

Browse files
set player controller on login, so that FindPlayerFromSteamId does not return nullptr if player doesn't have a character ingame
1 parent a5a0f39 commit 75ff6ca

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/libMinHook.x64.lib

-9.35 KB
Binary file not shown.

out_lib/ArkApi.lib

0 Bytes
Binary file not shown.

version/Core/Private/Ark/HooksImpl.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace ArkApi
2222
DECLARE_HOOK(AGameState_DefaultTimer, void, AGameState*);
2323
DECLARE_HOOK(AShooterGameMode_BeginPlay, void, AShooterGameMode*);
2424
DECLARE_HOOK(URCONServer_Init, bool, URCONServer*, FString, int, UShooterCheatManager*);
25+
DECLARE_HOOK(APlayerController_ServerReceivedPlayerControllerAck_Implementation, void, APlayerController*);
2526
DECLARE_HOOK(AShooterPlayerController_Possess, void, AShooterPlayerController*, APawn*);
2627
DECLARE_HOOK(AShooterGameMode_Logout, void, AShooterGameMode*, AController*);
2728

@@ -45,6 +46,8 @@ namespace ArkApi
4546
hooks->SetHook("AShooterGameMode.BeginPlay", &Hook_AShooterGameMode_BeginPlay,
4647
&AShooterGameMode_BeginPlay_original);
4748
hooks->SetHook("URCONServer.Init", &Hook_URCONServer_Init, &URCONServer_Init_original);
49+
hooks->SetHook("APlayerController.ServerReceivedPlayerControllerAck_Implementation", &Hook_APlayerController_ServerReceivedPlayerControllerAck_Implementation,
50+
&APlayerController_ServerReceivedPlayerControllerAck_Implementation_original);
4851
hooks->SetHook("AShooterPlayerController.Possess", &Hook_AShooterPlayerController_Possess,
4952
&AShooterPlayerController_Possess_original);
5053
hooks->SetHook("AShooterGameMode.Logout", &Hook_AShooterGameMode_Logout, &AShooterGameMode_Logout_original);
@@ -167,6 +170,17 @@ namespace ArkApi
167170
return URCONServer_Init_original(_this, Password, InPort, SCheatManager);
168171
}
169172

173+
void Hook_APlayerController_ServerReceivedPlayerControllerAck_Implementation(APlayerController* _this)
174+
{
175+
APlayerController_ServerReceivedPlayerControllerAck_Implementation_original(_this);
176+
177+
if (_this)
178+
{
179+
AShooterPlayerController* ASPC = static_cast<AShooterPlayerController*>(_this);
180+
dynamic_cast<ApiUtils&>(*API::game_api->GetApiUtils()).SetPlayerController(ASPC);
181+
}
182+
}
183+
170184
void Hook_AShooterPlayerController_Possess(AShooterPlayerController* _this, APawn* inPawn)
171185
{
172186
dynamic_cast<ApiUtils&>(*API::game_api->GetApiUtils()).SetPlayerController(_this);

0 commit comments

Comments
 (0)