Skip to content

Commit 88de52c

Browse files
committed
API 3.54. ArkApi plugin reload files
1 parent 2ce6182 commit 88de52c

8 files changed

Lines changed: 55 additions & 11 deletions

File tree

out_lib/ArkApi.lib

0 Bytes
Binary file not shown.

version/Core/Private/Ark/ArkBaseApi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace API
1818
{
19-
constexpr float api_version = 3.53f;
19+
constexpr float api_version = 3.54f;
2020

2121
ArkBaseApi::ArkBaseApi()
2222
: commands_(std::make_unique<ArkApi::Commands>()),

version/Core/Private/Ark/HooksImpl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ namespace ArkApi
153153
command->CheckOnTimerCallbacks();
154154
}
155155

156+
API::PluginManager::DetectPluginChangesTimerCallback(); // We call this here to avoid UnknownModule crashes
157+
156158
AGameState_DefaultTimer_original(_this);
157159
}
158160

version/Core/Private/PluginManager/PluginManager.cpp

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace API
1414
{
1515
PluginManager::PluginManager()
1616
{
17-
ArkApi::GetCommands().AddOnTimerCallback(L"PluginManager.DetectPluginChangesTimerCallback", &DetectPluginChangesTimerCallback);
17+
//ArkApi::GetCommands().AddOnTimerCallback(L"PluginManager.DetectPluginChangesTimerCallback", &DetectPluginChangesTimerCallback);
1818
}
1919

2020
PluginManager& PluginManager::Get()
@@ -347,9 +347,10 @@ namespace API
347347
// Save the world in case the unload/load procedure causes crash
348348
if (save_world)
349349
{
350-
//Log::GetLog()->info("Saving world before reloading plugins ...");
351-
//ArkApi::GetApiUtils().GetShooterGameMode()->SaveWorld();
352-
//Log::GetLog()->info("World saved.");
350+
Log::GetLog()->info("Saving world before reloading plugins ...");
351+
ArkApi::GetApiUtils().GetShooterGameMode()->SaveWorld();
352+
Log::GetLog()->info("World saved.");
353+
353354
save_world = false; // do not save again if multiple plugins are reloaded in this loop
354355
}
355356

@@ -360,16 +361,43 @@ namespace API
360361
copy_file(new_plugin_file_path, plugin_file_path, fs::copy_options::overwrite_existing);
361362
fs::remove(new_plugin_file_path);
362363

364+
// Wait 1 second before loading to let things clean up correctly...
365+
// This will load the plugin in the next timer callback
366+
//auto_reload_pending_plugins_.emplace_back(filename);
367+
363368
LoadPlugin(filename);
369+
370+
Log::GetLog()->info("Reloaded plugin - {}", filename);
364371
}
365372
catch (const std::exception& error)
366373
{
367374
Log::GetLog()->warn("({}) {}", __FUNCTION__, error.what());
368375
continue;
369376
}
377+
}
378+
}
379+
}
380+
381+
void PluginManager::ProcessPendingAutoReload()
382+
{
383+
if (auto_reload_pending_plugins_.size() == 0)
384+
return;
370385

371-
Log::GetLog()->info("Reloaded plugin - {}", filename);
386+
for (auto it = auto_reload_pending_plugins_.begin(); it != auto_reload_pending_plugins_.end(); it++)
387+
{
388+
const std::string filename = *it;
389+
390+
try
391+
{
392+
393+
}
394+
catch (const std::exception& ex)
395+
{
396+
Log::GetLog()->warn("({}) {}", __FUNCTION__, ex.what());
397+
continue;
372398
}
373399
}
400+
401+
auto_reload_pending_plugins_.empty();
374402
}
375403
} // namespace API

version/Core/Private/PluginManager/PluginManager.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ namespace API
7878
*/
7979
bool IsPluginLoaded(const std::string& plugin_name);
8080

81+
/**
82+
* \brief Checks for auto plugin reloads
83+
*/
84+
static void DetectPluginChangesTimerCallback();
8185
private:
8286
PluginManager();
8387
~PluginManager() = default;
@@ -88,8 +92,8 @@ namespace API
8892

8993
void CheckPluginsDependencies();
9094

91-
static void DetectPluginChangesTimerCallback();
9295
void DetectPluginChanges();
96+
void ProcessPendingAutoReload();
9397

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

@@ -98,5 +102,8 @@ namespace API
98102
int reload_sleep_seconds_{5};
99103
bool save_world_before_reload_{true};
100104
time_t next_reload_check_{5};
105+
106+
// Auto reload variable to delay auto loading of the plugin
107+
std::vector<std::string> auto_reload_pending_plugins_;
101108
};
102109
} // namespace API

version/Core/Public/API/ARK/Actor.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ struct AActor : UObject
11661166
void K2_OnBecomeViewTarget(APlayerController* PC) { NativeCall<void, APlayerController*>(this, "AActor.K2_OnBecomeViewTarget", PC); }
11671167
void K2_OnEndViewTarget(APlayerController* PC) { NativeCall<void, APlayerController*>(this, "AActor.K2_OnEndViewTarget", PC); }
11681168
void ModifyHudMultiUseLoc(FVector2D* theVec, APlayerController* PC, int index) { NativeCall<void, FVector2D*, APlayerController*, int>(this, "AActor.ModifyHudMultiUseLoc", theVec, PC, index); }
1169-
void MulticastDrawDebugArrow(FVector LineStart, FVector LineEnd, float ArrowSize, FLinearColor LineColor, float Duration) { NativeCall<void, FVector, FVector, float, FLinearColor, float>(this, "AActor.MulticastDrawDebugArrow", LineStart, LineEnd, ArrowSize, LineColor, Duration); }
1169+
void MulticastDrawDebugArrow(FVector LineStart, FVector LineEnd, float ArrowSize, FLinearColor LineColor, float Duration, bool enableInShipping) { NativeCall<void, FVector, FVector, float, FLinearColor, float, bool>(this, "AActor.MulticastDrawDebugArrow", LineStart, LineEnd, ArrowSize, LineColor, Duration, enableInShipping); }
11701170
void MulticastDrawDebugBox(FVector Center, FVector Extent, FLinearColor LineColor, FRotator Rotation, float Duration, bool enableInShipping) { NativeCall<void, FVector, FVector, FLinearColor, FRotator, float, bool>(this, "AActor.MulticastDrawDebugBox", Center, Extent, LineColor, Rotation, Duration, enableInShipping); }
11711171
void MulticastDrawDebugCapsule(FVector Center, float HalfHeight, float Radius, FRotator Rotation, FLinearColor LineColor, float Duration, bool enableInShipping) { NativeCall<void, FVector, float, float, FRotator, FLinearColor, float, bool>(this, "AActor.MulticastDrawDebugCapsule", Center, HalfHeight, Radius, Rotation, LineColor, Duration, enableInShipping); }
11721172
void MulticastDrawDebugCapsuleWithExtents(FVector Top, FVector Bottom, float Radius, FLinearColor LineColor, float Duration, bool bPersistent) { NativeCall<void, FVector, FVector, float, FLinearColor, float, bool>(this, "AActor.MulticastDrawDebugCapsuleWithExtents", Top, Bottom, Radius, LineColor, Duration, bPersistent); }
@@ -1175,7 +1175,7 @@ struct AActor : UObject
11751175
void MulticastDrawDebugLine(FVector LineStart, FVector LineEnd, FLinearColor LineColor, float Duration, float Thickness, bool enableInShipping) { NativeCall<void, FVector, FVector, FLinearColor, float, float, bool>(this, "AActor.MulticastDrawDebugLine", LineStart, LineEnd, LineColor, Duration, Thickness, enableInShipping); }
11761176
void MulticastDrawDebugPoint(FVector Position, float Size, FLinearColor PointColor, float Duration, bool enableInShipping) { NativeCall<void, FVector, float, FLinearColor, float, bool>(this, "AActor.MulticastDrawDebugPoint", Position, Size, PointColor, Duration, enableInShipping); }
11771177
void MulticastDrawDebugSphere(FVector Center, float Radius, int Segments, FLinearColor LineColor, float Duration, bool enableInShipping) { NativeCall<void, FVector, float, int, FLinearColor, float, bool>(this, "AActor.MulticastDrawDebugSphere", Center, Radius, Segments, LineColor, Duration, enableInShipping); }
1178-
void MulticastDrawDebugString(FVector TextLocation, FString* Text, AActor* TestBaseActor, FLinearColor TextColor, float Duration) { NativeCall<void, FVector, FString*, AActor*, FLinearColor, float>(this, "AActor.MulticastDrawDebugString", TextLocation, Text, TestBaseActor, TextColor, Duration); }
1178+
void MulticastDrawDebugString(FVector TextLocation, FString* Text, AActor* TestBaseActor, FLinearColor TextColor, float Duration, bool enableInShipping) { NativeCall<void, FVector, FString*, AActor*, FLinearColor, float, bool>(this, "AActor.MulticastDrawDebugString", TextLocation, Text, TestBaseActor, TextColor, Duration, enableInShipping); }
11791179
void NetAttachRootComponentTo(USceneComponent* InParent, FName InSocketName, FVector RelativeLocation, FRotator RelativeRotation) { NativeCall<void, USceneComponent*, FName, FVector, FRotator>(this, "AActor.NetAttachRootComponentTo", InParent, InSocketName, RelativeLocation, RelativeRotation); }
11801180
void OnInventoryItemGrind() { NativeCall<void>(this, "AActor.OnInventoryItemGrind"); }
11811181
void PerformanceThrottledTick() { NativeCall<void>(this, "AActor.PerformanceThrottledTick"); }
@@ -8594,6 +8594,9 @@ struct ANPCZoneManager
85948594

85958595
struct AShooterProjectile : AActor
85968596
{
8597+
TWeakObjectPtr<AActor>& DamageCauserField() { return *GetNativePointerField<TWeakObjectPtr<AActor>*>(this, "AShooterProjectile.DamageCauser"); }
8598+
// Functions
8599+
85978600
static UClass* GetPrivateStaticClass() { return NativeCall<UClass*>(nullptr, "AShooterProjectile.GetPrivateStaticClass"); }
85988601
};
85998602

@@ -8877,7 +8880,11 @@ struct APrimalBuff : AActor
88778880

88788881
struct APrimalBuff_Grappled : APrimalBuff
88798882
{
8883+
TArray<FGrappleTether>& CurrentGrappleTethersField() { return *GetNativePointerField<TArray<FGrappleTether>*>(this, "APrimalBuff_Grappled.CurrentGrappleTethers"); }
8884+
8885+
// Functions
88808886

8887+
void BreakAllTethers() { NativeCall<void>(this, "APrimalBuff_Grappled.BreakAllTethers"); }
88818888
};
88828889

88838890
struct FHarvestResourceEntry

version/Core/Public/API/ARK/PrimalStructure.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct APrimalTargetableActor : AActor
9292
bool IsInvincible() { return NativeCall<bool>(this, "APrimalTargetableActor.IsInvincible"); }
9393
void HarvestingDepleted(UPrimalHarvestingComponent* fromComponent) { NativeCall<void, UPrimalHarvestingComponent*>(this, "APrimalTargetableActor.HarvestingDepleted", fromComponent); }
9494
static void StaticRegisterNativesAPrimalTargetableActor() { NativeCall<void>(nullptr, "APrimalTargetableActor.StaticRegisterNativesAPrimalTargetableActor"); }
95-
static UClass* GetPrivateStaticClass(const wchar_t* Package) { return NativeCall<UClass*, const wchar_t*>(nullptr, "APrimalTargetableActor.GetPrivateStaticClass", Package); }
95+
static UClass* GetPrivateStaticClass() { return NativeCall<UClass*>(nullptr, "APrimalTargetableActor.GetPrivateStaticClass"); }
9696
void BPDied(float KillingDamage, FDamageEvent* DamageEvent, AController* Killer, AActor* DamageCauser) { NativeCall<void, float, FDamageEvent*, AController*, AActor*>(this, "APrimalTargetableActor.BPDied", KillingDamage, DamageEvent, Killer, DamageCauser); }
9797
void BPHitEffect(float DamageTaken, FDamageEvent* DamageEvent, APawn* PawnInstigator, AActor* DamageCauser, bool bIsLocalPath, UPrimitiveComponent* HitComponent, FVector DamageLoc, FRotator HitNormal) { NativeCall<void, float, FDamageEvent*, APawn*, AActor*, bool, UPrimitiveComponent*, FVector, FRotator>(this, "APrimalTargetableActor.BPHitEffect", DamageTaken, DamageEvent, PawnInstigator, DamageCauser, bIsLocalPath, HitComponent, DamageLoc, HitNormal); }
9898
bool BPSupressImpactEffects(float DamageTaken, FDamageEvent* DamageEvent, APawn* PawnInstigator, AActor* DamageCauser, bool bIsLocalPath, UPrimitiveComponent* HitComponent) { return NativeCall<bool, float, FDamageEvent*, APawn*, AActor*, bool, UPrimitiveComponent*>(this, "APrimalTargetableActor.BPSupressImpactEffects", DamageTaken, DamageEvent, PawnInstigator, DamageCauser, bIsLocalPath, HitComponent); }

version/Core/Public/API/UE/Math/Vector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ FORCEINLINE FVector FVector::GetSafeNormal(float Tolerance) const
15281528
}
15291529
else if(SquareSum < Tolerance)
15301530
{
1531-
return FVector::ZeroVector;
1531+
return FVector(0);
15321532
}
15331533
const float Scale = FMath::InvSqrt(SquareSum);
15341534
return FVector(X*Scale, Y*Scale, Z*Scale);

0 commit comments

Comments
 (0)