Skip to content

Commit

Permalink
Merge pull request #13 from ArkServerApi/MovePDB
Browse files Browse the repository at this point in the history
PDB will automatically move to Win64 when plugin is attempting to load.
  • Loading branch information
Pelayori authored Sep 5, 2024
2 parents 8d1deea + 0feef66 commit f18a832
Show file tree
Hide file tree
Showing 12 changed files with 1,496 additions and 335 deletions.
10 changes: 9 additions & 1 deletion AsaApi/Core/Private/Ark/ArkBaseApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace API
{
constexpr float api_version = 1.16f;
constexpr float api_version = 1.17f;

ArkBaseApi::ArkBaseApi()
: commands_(std::make_unique<AsaApi::Commands>()),
Expand Down Expand Up @@ -60,6 +60,8 @@ namespace API
fs::create_directory(fs::path(exe_path).append(ArkBaseApi::GetApiName()+"/Cache"));

const fs::path apiDLL = fs::path(exe_path).append(ArkBaseApi::GetApiName() + "/AsaApi.dll");
const fs::path apiPDB = fs::path(exe_path).append(ArkBaseApi::GetApiName() + "/AsaApi.pdb");
const fs::path apiPDBDest = fs::path(exe_path).append("AsaApi.pdb");
const fs::path pdbIgnoreFile = fs::path(exe_path).append(ArkBaseApi::GetApiName() + "/pdbignores.txt");
const fs::path keyCacheFile = fs::path(exe_path).append(ArkBaseApi::GetApiName()+"/Cache/cached_key.cache");
const fs::path offsetsCacheFile = fs::path(exe_path).append(ArkBaseApi::GetApiName()+"/Cache/cached_offsets.cache");
Expand All @@ -71,6 +73,12 @@ namespace API
std::unordered_set<std::string> pdbIgnoreSet = Cache::readFileIntoSet(pdbIgnoreFile);
const std::string defaultCDNUrl = "https://cdn.pelayori.com/cache/";

if (fs::exists(apiPDB))
{
fs::copy_file(apiPDB, apiPDBDest, fs::copy_options::overwrite_existing);
fs::remove(apiPDB);
}

if (autoCacheConfig.value("Enable", true)
&& autoCacheConfig.value("DownloadCacheURL", defaultCDNUrl) != ""
&& (fileHash != storedHash || !fs::exists(offsetsCacheFile) || !fs::exists(bitfieldsCacheFile)))
Expand Down
22 changes: 22 additions & 0 deletions AsaApi/Core/Private/PluginManager/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ namespace API

std::shared_ptr<Plugin>& PluginManager::LoadPlugin(const std::string& plugin_name) noexcept(false)
{
MovePDB(plugin_name);

namespace fs = std::filesystem;

const std::string dir_path = Tools::GetCurrentDir() + "/" + game_api->GetApiName() + "/Plugins/" + plugin_name;
Expand Down Expand Up @@ -326,4 +328,24 @@ namespace API
}
}
}

void PluginManager::MovePDB(const std::string& pluginname)
{
try
{
namespace fs = std::filesystem;

std::string source = AsaApi::Tools::GetCurrentDir() + "/ArkApi/Plugins/" + pluginname + "/" + pluginname + ".pdb";
std::string destination = AsaApi::Tools::GetCurrentDir() + "/" + pluginname + ".pdb";

if (fs::exists(source))
{
fs::copy_file(source, destination, fs::copy_options::overwrite_existing);
fs::remove(source);
}
}
catch (const std::exception&) {
Log::GetLog()->error("Failed to move PDB for '{}'", pluginname);
}
}
} // namespace API
2 changes: 2 additions & 0 deletions AsaApi/Core/Private/PluginManager/PluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ namespace API

void DetectPluginChanges();

void MovePDB(const std::string& pluginname);

std::vector<std::shared_ptr<Plugin>> loaded_plugins_;

// Plugins auto reloading
Expand Down
1,194 changes: 879 additions & 315 deletions AsaApi/Core/Public/API/ARK/Actor.h

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion AsaApi/Core/Public/API/ARK/ExtensionsDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ FORCEINLINE FVector ActorExtensions::GetActorForwardVector()
return RootComponent->ComponentToWorldField().GetUnitAxis(EAxis::X);
}

return FVector::ZeroVector;
//return FVector::ZeroVector;
return FVector(0, 0, 0);
}

FORCEINLINE bool ActorExtensions::IsA(UClass* SomeBase)
Expand Down
14 changes: 9 additions & 5 deletions AsaApi/Core/Public/API/ARK/GameMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ struct FNetworkNotify {

};

struct FLevelExperienceRamp
{
TArray<float> ExperiencePointsForLevel;
};

struct AGameStateBase : AInfo
{
Expand Down Expand Up @@ -1130,7 +1134,7 @@ struct UPrimalGameData : UObject
static UPrimalGlobalUIData* BPGetGlobalUIData(bool* bIsPsOrXbUi) { return NativeCall<UPrimalGlobalUIData*, bool*>(nullptr, "UPrimalGameData.BPGetGlobalUIData(bool*)", bIsPsOrXbUi); }
USoundBase* GetGenericCombatMusic_Implementation(APrimalCharacter* forCharacter, APrimalCharacter* forEnemy) { return NativeCall<USoundBase*, APrimalCharacter*, APrimalCharacter*>(this, "UPrimalGameData.GetGenericCombatMusic_Implementation(APrimalCharacter*,APrimalCharacter*)", forCharacter, forEnemy); }
static void AddPartBoneModifiers(USkeletalMeshComponent* ForMesh, const TArray<FBoneModifierRange, TSizedDefaultAllocator<32> >* BoneModifierRanges, float Value, TArray<FBoneModifier, TSizedDefaultAllocator<32> >* BoneModifiers) { NativeCall<void, USkeletalMeshComponent*, const TArray<FBoneModifierRange, TSizedDefaultAllocator<32> >*, float, TArray<FBoneModifier, TSizedDefaultAllocator<32> >*>(nullptr, "UPrimalGameData.AddPartBoneModifiers(USkeletalMeshComponent*,TArray<FBoneModifierRange,TSizedDefaultAllocator<32>>*,float,TArray<FBoneModifier,TSizedDefaultAllocator<32>>*)", ForMesh, BoneModifierRanges, Value, BoneModifiers); }
//FLevelExperienceRamp* GetLevelExperienceRamp(ELevelExperienceRampType::Type levelType) { return NativeCall<FLevelExperienceRamp*, ELevelExperienceRampType::Type>(this, "UPrimalGameData.GetLevelExperienceRamp(ELevelExperienceRampType::Type)", levelType); }
FLevelExperienceRamp* GetLevelExperienceRamp(ELevelExperienceRampType::Type levelType) { return NativeCall<FLevelExperienceRamp*, ELevelExperienceRampType::Type>(this, "UPrimalGameData.GetLevelExperienceRamp(ELevelExperienceRampType::Type)", levelType); }
TArray<int, TSizedDefaultAllocator<32> >* GetPlayerLevelEngramPoints() { return NativeCall<TArray<int, TSizedDefaultAllocator<32> >*>(this, "UPrimalGameData.GetPlayerLevelEngramPoints()"); }
static TSubclassOf<UObject>* GetRemappedClass_HardHard(TSubclassOf<UObject>* result, const TArray<FClassRemapping, TSizedDefaultAllocator<32>>* RemappedClasses, TSubclassOf<UObject> ForClass) { return NativeCall<TSubclassOf<UObject>*, TSubclassOf<UObject>*, const TArray<FClassRemapping, TSizedDefaultAllocator<32>>*, TSubclassOf<UObject>>(nullptr, "UPrimalGameData.GetRemappedClass_HardHard(TArray<FClassRemapping,TSizedDefaultAllocator<32>>&,TSubclassOf<UObject>)", result, RemappedClasses, ForClass); }
static TSubclassOf<UObject>* GetRemappedClass_HardSoft(TSubclassOf<UObject>* result, const TArray<FClassRemapping, TSizedDefaultAllocator<32>>* RemappedClasses, const FSoftObjectPath* ForClass) { return NativeCall<TSubclassOf<UObject>*, TSubclassOf<UObject>*, const TArray<FClassRemapping, TSizedDefaultAllocator<32>>*, const FSoftObjectPath*>(nullptr, "UPrimalGameData.GetRemappedClass_HardSoft(TArray<FClassRemapping,TSizedDefaultAllocator<32>>&,FSoftObjectPath&)", result, RemappedClasses, ForClass); }
Expand Down Expand Up @@ -2462,7 +2466,7 @@ struct AShooterGameMode : APrimalGameMode
void CheckForDupedDinos() { NativeCall<void>(this, "AShooterGameMode.CheckForDupedDinos()"); }
bool IsPlayerControllerAllowedToJoinNoCheck(AShooterPlayerController* ForPlayer) { return NativeCall<bool, AShooterPlayerController*>(this, "AShooterGameMode.IsPlayerControllerAllowedToJoinNoCheck(AShooterPlayerController*)", ForPlayer); }
TSubclassOf<AGameSession> GetGameSessionClass()const { return NativeCall<TSubclassOf<AGameSession>>(this, "AShooterGameMode.GetGameSessionClass()"); }
void AddToTribeLog(int TribeId, const FString& NewLog) { NativeCall<void, int, const FString&>(this, "AShooterGameMode.AddToTribeLog(int,FString&)", TribeId, NewLog); }
void AddToTribeLog(int TribeId, const FString* NewLog) { NativeCall<void, int, const FString*>(this, "AShooterGameMode.AddToTribeLog(int,FString&)", TribeId, NewLog); }
void LoadedWorld_Implementation() { NativeCall<void>(this, "AShooterGameMode.LoadedWorld_Implementation()"); }
bool GetBoolOptionIni(const wchar_t* Section, const wchar_t* OptionName, bool bDefaultValue) { return NativeCall<bool, const wchar_t*, const wchar_t*, bool>(this, "AShooterGameMode.GetBoolOptionIni(wchar_t*,wchar_t*,bool)", Section, OptionName, bDefaultValue); }
TArray<APrimalDinoCharacter*, TSizedDefaultAllocator<32> > GetOverlappingDinoCharactersOfTeamAndClass(const UE::Math::TVector<double>& AtLocation, float OverlapRange, TSubclassOf<APrimalDinoCharacter> DinoClass, int DinoTeam, bool bExactClassMatch, bool bIgnoreClass) { return NativeCall<TArray<APrimalDinoCharacter*, TSizedDefaultAllocator<32> >, const UE::Math::TVector<double>&, float, TSubclassOf<APrimalDinoCharacter>, int, bool, bool>(this, "AShooterGameMode.GetOverlappingDinoCharactersOfTeamAndClass(UE::Math::TVector<double>&,float,TSubclassOf<APrimalDinoCharacter>,int,bool,bool)", AtLocation, OverlapRange, DinoClass, DinoTeam, bExactClassMatch, bIgnoreClass); }
Expand Down Expand Up @@ -2504,7 +2508,7 @@ struct AShooterGameMode : APrimalGameMode
void PlayEnded() { NativeCall<void>(this, "AShooterGameMode.PlayEnded()"); }
UObject* _getUObject()const { return NativeCall<UObject*>(this, "AShooterGameMode._getUObject()"); }
bool IsPlayerAllowedToJoinNoCheck(const FUniqueNetId* PlayerId) { return NativeCall<bool, const FUniqueNetId*>(this, "AShooterGameMode.IsPlayerAllowedToJoinNoCheck(FUniqueNetId&)", PlayerId); }
//TSharedPtr<FWriteFileTaskInfo, 1> SaveTribeData(const FTribeData* TribeData, bool bCanDeferToTick) { return NativeCall<TSharedPtr<FWriteFileTaskInfo, 1>, const FTribeData*, bool>(this, "AShooterGameMode.SaveTribeData(FTribeData&,bool)", TribeData, bCanDeferToTick); }
TSharedPtr<FWriteFileTaskInfo> SaveTribeData(const FTribeData* TribeData, bool bCanDeferToTick) { return NativeCall<TSharedPtr<FWriteFileTaskInfo>, const FTribeData*, bool>(this, "AShooterGameMode.SaveTribeData(FTribeData&,bool)", TribeData, bCanDeferToTick); }
void InitShooterPlayer(APlayerController* NewPlayer) { NativeCall<void, APlayerController*>(this, "AShooterGameMode.InitShooterPlayer(APlayerController*)", NewPlayer); }
FString GeneratePGMapFolderName(TMap<FString, FString, FDefaultSetAllocator, TDefaultMapHashableKeyFuncs<FString, FString, 0> >* PGMapOptionsString) { return NativeCall<FString, TMap<FString, FString, FDefaultSetAllocator, TDefaultMapHashableKeyFuncs<FString, FString, 0> >*>(this, "AShooterGameMode.GeneratePGMapFolderName(TMap<FString,FString,FDefaultSetAllocator,TDefaultMapHashableKeyFuncs<FString,FString,0>>)", PGMapOptionsString); }
void UpdateSaveBackupFiles() { NativeCall<void>(this, "AShooterGameMode.UpdateSaveBackupFiles()"); }
Expand All @@ -2518,7 +2522,7 @@ struct AShooterGameMode : APrimalGameMode
unsigned int GeneratePlayerDataId(TSharedPtr<FUniqueNetId const>* UniqueID) { return NativeCall<unsigned int, TSharedPtr<FUniqueNetId const>*>(this, "AShooterGameMode.GeneratePlayerDataId(TSharedPtr<FUniqueNetId,1>)", UniqueID); }
void PreInitializeComponents() { NativeCall<void>(this, "AShooterGameMode.PreInitializeComponents()"); }
float GetHarvestResourceItemAmountMultiplier(TSubclassOf<UPrimalItem> HarvestItemClass) { return NativeCall<float, TSubclassOf<UPrimalItem>>(this, "AShooterGameMode.GetHarvestResourceItemAmountMultiplier(TSubclassOf<UPrimalItem>)", HarvestItemClass); }
FString GetSaveDirectoryName(ESaveType::Type SaveType, bool RemoveSavedArksDir) { return NativeCall<FString, ESaveType::Type, bool>(this, "AShooterGameMode.GetSaveDirectoryName(ESaveType::Type,bool)", SaveType, RemoveSavedArksDir); }
FString& GetSaveDirectoryName(FString* result, ESaveType::Type SaveType, bool RemoveSavedArksDir) { return NativeCall<FString&, FString*, ESaveType::Type, bool>(this, "AShooterGameMode.GetSaveDirectoryName(ESaveType::Type,bool)", result, SaveType, RemoveSavedArksDir); }
void RemovePlayerFromTribe(unsigned long TribeID, unsigned long PlayerDataID, bool bDontUpdatePlayerState) { NativeCall<void, unsigned long, unsigned long, bool>(this, "AShooterGameMode.RemovePlayerFromTribe(unsigned__int64,unsigned__int64,bool)", TribeID, PlayerDataID, bDontUpdatePlayerState); }
void ChatLogFlushOnTick() { NativeCall<void>(this, "AShooterGameMode.ChatLogFlushOnTick()"); }
void LoadPlayerIds_Process(unsigned long InPlayerID, TArray<unsigned char, TSizedDefaultAllocator<32> >& ReadBytes) { NativeCall<void, unsigned long, TArray<unsigned char, TSizedDefaultAllocator<32> >&>(this, "AShooterGameMode.LoadPlayerIds_Process(unsigned__int64,TArray<unsignedchar,TSizedDefaultAllocator<32>>&)", InPlayerID, ReadBytes); }
Expand Down Expand Up @@ -2641,7 +2645,7 @@ struct AShooterGameMode : APrimalGameMode
FPrimalPlayerCharacterConfigStruct ValidateCharacterConfig(const FPrimalPlayerCharacterConfigStruct* charConfig) { return NativeCall<FPrimalPlayerCharacterConfigStruct, const FPrimalPlayerCharacterConfigStruct*>(this, "AShooterGameMode.ValidateCharacterConfig(FPrimalPlayerCharacterConfigStruct&)", charConfig); }
//void HttpGetBadWordListComplete(TSharedPtr<IHttpRequest, 1>* HttpRequest, TSharedPtr<IHttpResponse, 1>* HttpResponse, bool bSucceeded) { NativeCall<void, TSharedPtr<IHttpRequest, 1>*, TSharedPtr<IHttpResponse, 1>*, bool>(this, "AShooterGameMode.HttpGetBadWordListComplete(TSharedPtr<IHttpRequest,1>,TSharedPtr<IHttpResponse,1>,bool)", HttpRequest, HttpResponse, bSucceeded); }
bool BanPlayer(FString* PlayerSteamName, unsigned int DurationMinutes) { return NativeCall<bool, FString*, unsigned int>(this, "AShooterGameMode.BanPlayer(FString,unsignedint)", PlayerSteamName, DurationMinutes); }
unsigned __int64 AddNewTribe(AShooterPlayerState* PlayerOwner, const FString& TribeName, const FTribeGovernment* TribeGovernment, const FUserCosmeticInfo* UserCosmeticInfo) { return NativeCall<unsigned __int64, AShooterPlayerState*, const FString&, const FTribeGovernment*, const FUserCosmeticInfo*>(this, "AShooterGameMode.AddNewTribe(AShooterPlayerState*,FString&,FTribeGovernment&,FUserCosmeticInfo)", PlayerOwner, TribeName, TribeGovernment, UserCosmeticInfo); }
unsigned __int64 AddNewTribe(AShooterPlayerState* PlayerOwner, FTribeData* TribeName, const FTribeGovernment* TribeGovernment, const FUserCosmeticInfo* UserCosmeticInfo) { return NativeCall<unsigned __int64, AShooterPlayerState*, FTribeData*, const FTribeGovernment*, const FUserCosmeticInfo*>(this, "AShooterGameMode.AddNewTribe(AShooterPlayerState*,FString&,FTribeGovernment&,FUserCosmeticInfo)", PlayerOwner, TribeName, TribeGovernment, UserCosmeticInfo); }
int GetIntOption(const FString& Options, const FString& ParseString, int CurrentValue) { return NativeCall<int, const FString&, const FString&, int>(this, "AShooterGameMode.GetIntOption(FString&,FString&,int)", Options, ParseString, CurrentValue); }
void UpdateMemoryState(FString* PackageName, bool bSave, ULevel* Level) { NativeCall<void, FString*, bool, ULevel*>(this, "AShooterGameMode.UpdateMemoryState(FString,bool,ULevel*)", PackageName, bSave, Level); }
void SetMessageOfTheDay(const FString& Message, const FString& SetterID) { NativeCall<void, const FString&, const FString&>(this, "AShooterGameMode.SetMessageOfTheDay(FString&,FString&)", Message, SetterID); }
Expand Down
Loading

0 comments on commit f18a832

Please sign in to comment.