Skip to content

Commit 1fe8459

Browse files
authored
API 1.01 (#9)
1 parent 8340a77 commit 1fe8459

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

AsaApi/Core/Private/Ark/ArkBaseApi.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace API
1515
{
16-
constexpr float api_version = 1.00;
16+
constexpr float api_version = 1.01;
1717

1818
ArkBaseApi::ArkBaseApi()
1919
: commands_(std::make_unique<AsaApi::Commands>()),
@@ -37,22 +37,26 @@ namespace API
3737

3838
try
3939
{
40-
const fs::path filepath = fs::current_path().append("ArkAscendedServer.pdb");
40+
TCHAR buffer[MAX_PATH];
41+
GetModuleFileName(NULL, buffer, sizeof(buffer));
42+
fs::path exe_path = std::filesystem::path(buffer).parent_path();
4143

42-
if (!fs::exists(fs::current_path().append(ArkBaseApi::GetApiName())))
43-
fs::create_directory(fs::current_path().append(ArkBaseApi::GetApiName()));
44+
const fs::path filepath = fs::path(exe_path).append("ArkAscendedServer.pdb");
4445

45-
if (!fs::exists(fs::current_path().append(ArkBaseApi::GetApiName() + "/Plugins")))
46-
fs::create_directory(fs::current_path().append(ArkBaseApi::GetApiName() + "/Plugins"));
46+
if (!fs::exists(fs::path(exe_path).append(ArkBaseApi::GetApiName())))
47+
fs::create_directory(fs::path(exe_path).append(ArkBaseApi::GetApiName()));
4748

48-
if (!fs::exists(fs::current_path().append(ArkBaseApi::GetApiName()+"/Cache")))
49-
fs::create_directory(fs::current_path().append(ArkBaseApi::GetApiName()+"/Cache"));
49+
if (!fs::exists(fs::path(exe_path).append(ArkBaseApi::GetApiName() + "/Plugins")))
50+
fs::create_directory(fs::path(exe_path).append(ArkBaseApi::GetApiName() + "/Plugins"));
5051

51-
const fs::path pdbIgnoreFile = fs::current_path().append(ArkBaseApi::GetApiName() + "/pdbignores.txt");
52-
const fs::path keyCacheFile = fs::current_path().append(ArkBaseApi::GetApiName()+"/Cache/cached_key.cache");
53-
const fs::path offsetsCacheFile = fs::current_path().append(ArkBaseApi::GetApiName()+"/Cache/cached_offsets.cache");
54-
const fs::path bitfieldsCacheFile = fs::current_path().append(ArkBaseApi::GetApiName()+"/Cache/cached_bitfields.cache");
55-
const fs::path offsetsCacheFilePlain = fs::current_path().append(ArkBaseApi::GetApiName() + "/Cache/cached_offsets.txt");
52+
if (!fs::exists(fs::path(exe_path).append(ArkBaseApi::GetApiName()+"/Cache")))
53+
fs::create_directory(fs::path(exe_path).append(ArkBaseApi::GetApiName()+"/Cache"));
54+
55+
const fs::path pdbIgnoreFile = fs::path(exe_path).append(ArkBaseApi::GetApiName() + "/pdbignores.txt");
56+
const fs::path keyCacheFile = fs::path(exe_path).append(ArkBaseApi::GetApiName()+"/Cache/cached_key.cache");
57+
const fs::path offsetsCacheFile = fs::path(exe_path).append(ArkBaseApi::GetApiName()+"/Cache/cached_offsets.cache");
58+
const fs::path bitfieldsCacheFile = fs::path(exe_path).append(ArkBaseApi::GetApiName()+"/Cache/cached_bitfields.cache");
59+
const fs::path offsetsCacheFilePlain = fs::path(exe_path).append(ArkBaseApi::GetApiName() + "/Cache/cached_offsets.txt");
5660
const std::string fileHash = Cache::calculateSHA256(filepath);
5761
const std::string storedHash = Cache::readFromFile(keyCacheFile);
5862
std::unordered_set<std::string> pdbIgnoreSet = Cache::readFileIntoSet(pdbIgnoreFile);

AsaApi/Core/Private/Ark/HooksImpl.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace AsaApi
3737
DECLARE_HOOK(URCONServer_Init, bool, URCONServer*, FString*, unsigned int, UShooterCheatManager*);
3838
DECLARE_HOOK(AShooterPlayerController_OnPossess, void, AShooterPlayerController*, APawn*);
3939
DECLARE_HOOK(AShooterGameMode_Logout, void, AShooterGameMode*, AController*);
40+
DECLARE_HOOK(UShooterCheatManager_Broadcast, void, UShooterCheatManager*, FString*);
4041
DECLARE_HOOK(AShooterGameMode_HandleNewPlayer_Implementation, bool, AShooterGameMode*, AShooterPlayerController*, UPrimalPlayerData*, AShooterCharacter*, bool);
4142

4243
void InitHooks()
@@ -53,6 +54,7 @@ namespace AsaApi
5354
hooks->SetHook("URCONServer.Init(FString,int,UShooterCheatManager*)", &Hook_URCONServer_Init, &URCONServer_Init_original);
5455
hooks->SetHook("AShooterPlayerController.OnPossess(APawn*)", &Hook_AShooterPlayerController_OnPossess, &AShooterPlayerController_OnPossess_original);
5556
hooks->SetHook("AShooterGameMode.Logout(AController*)", &Hook_AShooterGameMode_Logout, &AShooterGameMode_Logout_original);
57+
hooks->SetHook("UShooterCheatManager.Broadcast(FString&)", &Hook_UShooterCheatManager_Broadcast, &UShooterCheatManager_Broadcast_original);
5658
hooks->SetHook("AShooterGameMode.HandleNewPlayer_Implementation(AShooterPlayerController*,UPrimalPlayerData*,AShooterCharacter*,bool)", &Hook_AShooterGameMode_HandleNewPlayer_Implementation, &AShooterGameMode_HandleNewPlayer_Implementation_original);
5759

5860
Log::GetLog()->info("Initialized hooks\n");
@@ -189,6 +191,17 @@ namespace AsaApi
189191
AShooterGameMode_Logout_original(_this, Exiting);
190192
}
191193

194+
void Hook_UShooterCheatManager_Broadcast(UShooterCheatManager* _this, FString* msg)
195+
{
196+
if (!_this->MyPCField())
197+
{
198+
if (AsaApi::GetApiUtils().GetWorld()->GetFirstPlayerController())
199+
AsaApi::GetApiUtils().GetShooterGameMode()->SendServerChatMessage(msg, FColorList::Yellow, false, -1, -1, AsaApi::IApiUtils::GetEOSIDFromController(AsaApi::GetApiUtils().GetWorld()->GetFirstPlayerController()));
200+
}
201+
else
202+
return UShooterCheatManager_Broadcast_original(_this, msg);
203+
}
204+
192205
bool Hook_AShooterGameMode_HandleNewPlayer_Implementation(AShooterGameMode* _this, AShooterPlayerController* NewPlayer, UPrimalPlayerData* PlayerData, AShooterCharacter* PlayerCharacter, bool bIsFromLogin)
193206
{
194207
dynamic_cast<ApiUtils&>(*API::game_api->GetApiUtils()).SetPlayerController(NewPlayer);

AsaApi/Core/Public/API/ARK/GameMode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,9 +2358,9 @@ struct AShooterGameMode : APrimalGameMode
23582358
FLeaderboardEntry* GetOrCreateLeaderboardEntry(FName MissionTag) { return NativeCall<FLeaderboardEntry*, FName>(this, "AShooterGameMode.GetOrCreateLeaderboardEntry(FName)", MissionTag); }
23592359
//void GetActorSaveGameTypes(//TArray<TSubclassOf<AActor>, TSizedDefaultAllocator<32> >* saveGameTypes) { NativeCall<void, //TArray<TSubclassOf<AActor>, TSizedDefaultAllocator<32> >*>(this, "AShooterGameMode.GetActorSaveGameTypes(//TArray<TSubclassOf<AActor>,TSizedDefaultAllocator<32>>*)", saveGameTypes); }
23602360
FString* InitNewPlayer(FString* result, APlayerController* NewPlayerController, const FUniqueNetIdRepl* UniqueId, const FString* Options, const FString* Portal) { return NativeCall<FString*, FString*, APlayerController*, const FUniqueNetIdRepl*, const FString*, const FString*>(this, "AShooterGameMode.InitNewPlayer(FString&,APlayerController*,FUniqueNetIdRepl*,FString&,FString&)", result, NewPlayerController, UniqueId, Options, Portal); }
2361-
static void SendServerDirectMessage() { NativeCall<void>(nullptr, "AShooterGameMode.SendServerDirectMessage()"); }
2362-
static void SendServerChatMessage() { NativeCall<void>(nullptr, "AShooterGameMode.SendServerChatMessage()"); }
2363-
static void SendServerNotification() { NativeCall<void>(nullptr, "AShooterGameMode.SendServerNotification()"); }
2361+
void SendServerDirectMessage(FString* PlayerSteamID, FString* MessageText, FLinearColor MessageColor, bool bIsBold, int ReceiverTeamId, int ReceiverPlayerID, FString* PlayerName, FString* SenderId) { NativeCall<void, FString*, FString*, FLinearColor, bool, int, int, FString*, FString*>(this, "AShooterGameMode.SendServerDirectMessage(FString&,FString&,FLinearColor,bool,int,int,FString&,FString&)", PlayerSteamID, MessageText, MessageColor, bIsBold, ReceiverTeamId, ReceiverPlayerID, PlayerName, SenderId); }
2362+
void SendServerChatMessage(FString* MessageText, FLinearColor MessageColor, bool bIsBold, int ReceiverTeamId, int ReceiverPlayerID, FString SenderID) { NativeCall<void, FString*, FLinearColor, bool, int, int, FString>(this, "AShooterGameMode.SendServerChatMessage(FString&,FLinearColor,bool,int,int,FString)", MessageText, MessageColor, bIsBold, ReceiverTeamId, ReceiverPlayerID, SenderID); }
2363+
void SendServerNotification(FString* MessageText, FLinearColor MessageColor, float DisplayScale, float DisplayTime, UTexture2D* MessageIcon, USoundBase* SoundToPlay, int ReceiverTeamId, int ReceiverPlayerID, bool bDoBillboard) { NativeCall<void, FString*, FLinearColor, float, float, UTexture2D*, USoundBase*, int, int, bool>(this, "AShooterGameMode.SendServerNotification(FString&,FLinearColor,float,float,UTexture2D*,USoundBase*,int,int,bool)", MessageText, MessageColor, DisplayScale, DisplayTime, MessageIcon, SoundToPlay, ReceiverTeamId, ReceiverPlayerID, bDoBillboard); }
23642364
void InitGameState() { NativeCall<void>(this, "AShooterGameMode.InitGameState()"); }
23652365
void PreInitializeComponents() { NativeCall<void>(this, "AShooterGameMode.PreInitializeComponents()"); }
23662366
void CheckIsOfficialServer() { NativeCall<void>(this, "AShooterGameMode.CheckIsOfficialServer()"); }

0 commit comments

Comments
 (0)