Skip to content

Commit

Permalink
Fix chat msg crash, header updates (ServersHub#7)
Browse files Browse the repository at this point in the history
* The most significant changes involve modifications to the `AddItem` and `ServerEquipItem` methods in the `UPrimalInventoryComponent` struct, and the `GetBlueprint` method in the `AsaApi` namespace. The parameters in the first two methods have been changed from pointers to references, enhancing the safety and readability of the code. The `GetBlueprint` method now handles null objects or classes more explicitly and modifies the path name of the blueprint.

Changes:

1. The `AddItem` method in the `UPrimalInventoryComponent` struct in `Inventory.h` has been modified. The parameter `theItemInfo` has been changed from a pointer to a reference. This change enhances the safety and readability of the code by ensuring that the parameter cannot be null and that it cannot be changed to point to a different object. (See `Inventory.h`)

2. The `ServerEquipItem` method in the `UPrimalInventoryComponent` struct in `Inventory.h` has been modified. The parameter `itemID` has been changed from a pointer to a reference. This change enhances the safety and readability of the code by ensuring that the parameter cannot be null and that it cannot be changed to point to a different object. (See `Inventory.h`)

3. The `GetBlueprint` method in the `AsaApi` namespace in `ArkApiUtils.h` has been modified. The method now replaces "Default__" with an empty string in the path name of the blueprint. If the object or its class is null, the method now explicitly returns an empty string. This change makes the method's behavior more predictable and its output more useful. (See `ArkApiUtils.h`)

* Fixed signatures and removed else statement

* Add null check to find property

* Fixed chat message crash and header updates

* FItemStatInfo updated for stat changes

---------

Co-authored-by: Lethalinjectionx <[email protected]>
  • Loading branch information
Pelayori and Lethalinjectionx authored Nov 27, 2023
1 parent 0571b3f commit 5d58d94
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
3 changes: 1 addition & 2 deletions AsaApi/Core/Private/UE/UE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

ARK_API FProperty* UObject::FindProperty(FName name)
{
for (FProperty* Property = this->ClassPrivateField()->PropertyLinkField(); ; Property = Property->PropertyLinkNextField())
for (FProperty* Property = this->ClassPrivateField()->PropertyLinkField(); Property != nullptr; Property = Property->PropertyLinkNextField())
{
//Log::GetLog()->info(Property->NamePrivateField().ToString().ToString());
if (Property->NamePrivateField().ToString().Equals(name.ToString()))
return Property;
}
Expand Down
5 changes: 3 additions & 2 deletions AsaApi/Core/Public/API/ARK/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ struct FPrimalChatMessage {
Message(""),
Receiver(""),
SenderTeamIndex(0),
ReceivedTime(-1),
ReceivedTime(0),
SendMode(EChatSendMode::GlobalChat),
RadioFrequency(0),
ChatType(EChatType::GlobalChat),
SenderIcon(nullptr),
UserId("")
UserId(""),
senderPlatform((unsigned char)1)
{
}
FPrimalChatMessage* operator=(FPrimalChatMessage* __that) { return NativeCall<FPrimalChatMessage*, FPrimalChatMessage*>(this, "FPrimalChatMessage.operator=(FPrimalChatMessage&)", __that); }
Expand Down
31 changes: 25 additions & 6 deletions AsaApi/Core/Public/API/ARK/Other.h
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,10 @@ struct FDinoBabySetup

struct FDinoBaseLevelWeightEntry
{
float EntryWeight;
float BaseLevelMinRange;
float BaseLevelMaxRange;

// Fields

float& EntryWeightField() { return *GetNativePointerField<float*>(this, "FDinoBaseLevelWeightEntry.EntryWeight"); }
Expand Down Expand Up @@ -1834,6 +1838,21 @@ struct FItemSetup

struct FItemStatInfo
{
unsigned __int32 bUsed : 1;
unsigned __int32 bCalculateAsPercent : 1;
unsigned __int32 bDisplayAsPercent : 1;
unsigned __int32 bRequiresSubmerged : 1;
unsigned __int32 bPreventIfSubmerged : 1;
unsigned __int32 bHideStatFromTooltip : 1;
int DefaultModifierValue;
int RandomizerRangeOverride;
float RandomizerRangeMultiplier;
float TheRandomizerPower;
float StateModifierScale;
float InitialValueConstant;
float RatingValueMultiplier;
float AbsoluteMaxValue;

// Fields

int& DefaultModifierValueField() { return *GetNativePointerField<int*>(this, "FItemStatInfo.DefaultModifierValue"); }
Expand All @@ -1847,12 +1866,12 @@ struct FItemStatInfo

// Bitfields

BitFieldValue<bool, unsigned __int32> bUsed() { return { this, "FItemStatInfo.bUsed" }; }
BitFieldValue<bool, unsigned __int32> bCalculateAsPercent() { return { this, "FItemStatInfo.bCalculateAsPercent" }; }
BitFieldValue<bool, unsigned __int32> bDisplayAsPercent() { return { this, "FItemStatInfo.bDisplayAsPercent" }; }
BitFieldValue<bool, unsigned __int32> bRequiresSubmerged() { return { this, "FItemStatInfo.bRequiresSubmerged" }; }
BitFieldValue<bool, unsigned __int32> bPreventIfSubmerged() { return { this, "FItemStatInfo.bPreventIfSubmerged" }; }
BitFieldValue<bool, unsigned __int32> bHideStatFromTooltip() { return { this, "FItemStatInfo.bHideStatFromTooltip" }; }
BitFieldValue<bool, unsigned __int32> bUsedField() { return { this, "FItemStatInfo.bUsed" }; }
BitFieldValue<bool, unsigned __int32> bCalculateAsPercentField() { return { this, "FItemStatInfo.bCalculateAsPercent" }; }
BitFieldValue<bool, unsigned __int32> bDisplayAsPercentField() { return { this, "FItemStatInfo.bDisplayAsPercent" }; }
BitFieldValue<bool, unsigned __int32> bRequiresSubmergedField() { return { this, "FItemStatInfo.bRequiresSubmerged" }; }
BitFieldValue<bool, unsigned __int32> bPreventIfSubmergedField() { return { this, "FItemStatInfo.bPreventIfSubmerged" }; }
BitFieldValue<bool, unsigned __int32> bHideStatFromTooltipField() { return { this, "FItemStatInfo.bHideStatFromTooltip" }; }

// Functions

Expand Down
4 changes: 4 additions & 0 deletions AsaApi/Core/Public/Ark/ArkApiUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace AsaApi
FPrimalChatMessage chat_message;
chat_message.SenderName = sender_name;
chat_message.Message = text;
chat_message.UserId = GetEOSIDFromController(player_controller);
player_controller->ClientChatMessage(chat_message);
}
}
Expand Down Expand Up @@ -177,7 +178,10 @@ namespace AsaApi
{
AShooterPlayerController* shooter_pc = static_cast<AShooterPlayerController*>(player_controller.Get());
if (shooter_pc)
{
chat_message.UserId = GetEOSIDFromController(shooter_pc);
shooter_pc->ClientChatMessage(chat_message);
}
}
}

Expand Down

0 comments on commit 5d58d94

Please sign in to comment.