Skip to content

Commit

Permalink
Merge pull request #2 from RedwoodMMO/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeseese authored Oct 29, 2024
2 parents 1550881 + 0da8615 commit 041268d
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 112 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/release.yaml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test

on:
workflow_call:
inputs:
branch:
required: true
type: string
secrets:
PAT:
description: 'Clone personal access token'
required: true

jobs:
test:
runs-on: [self-hosted, Windows]
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
lfs: true
submodules: "recursive"
set-safe-directory: false
repository: RedwoodMMO/RedwoodPlugins
ref: ${{ github.event_name == 'workflow_call' && 'refs/heads/' || '' }}${{ github.event_name == 'push' && github.ref || inputs.branch }}
token: ${{ secrets.PAT }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Binaries
Intermediate
*.zip
70 changes: 40 additions & 30 deletions RedwoodCore/Source/Redwood/Private/RedwoodCharacterComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,50 @@ void URedwoodCharacterComponent::RedwoodPlayerStateCharacterUpdated() {
RedwoodPlayerId = RedwoodCharacterBackend.PlayerId;
RedwoodCharacterId = RedwoodCharacterBackend.Id;

URedwoodCommonGameSubsystem::DeserializeBackendData(
bStoreDataInActor ? (UObject *)Pawn : (UObject *)this,
RedwoodCharacterBackend.CharacterCreatorData,
*CharacterCreatorDataVariableName,
LatestMetadataSchemaVersion
);
if (bUseCharacterCreatorData) {
URedwoodCommonGameSubsystem::DeserializeBackendData(
bStoreDataInActor ? (UObject *)Pawn : (UObject *)this,
RedwoodCharacterBackend.CharacterCreatorData,
*CharacterCreatorDataVariableName,
LatestMetadataSchemaVersion
);
}

URedwoodCommonGameSubsystem::DeserializeBackendData(
bStoreDataInActor ? (UObject *)Pawn : (UObject *)this,
RedwoodCharacterBackend.Metadata,
*MetadataVariableName,
LatestMetadataSchemaVersion
);
if (bUseMetadata) {
URedwoodCommonGameSubsystem::DeserializeBackendData(
bStoreDataInActor ? (UObject *)Pawn : (UObject *)this,
RedwoodCharacterBackend.Metadata,
*MetadataVariableName,
LatestMetadataSchemaVersion
);
}

URedwoodCommonGameSubsystem::DeserializeBackendData(
bStoreDataInActor ? (UObject *)Pawn : (UObject *)this,
RedwoodCharacterBackend.EquippedInventory,
*EquippedInventoryVariableName,
LatestEquippedInventorySchemaVersion
);
if (bUseEquippedInventory) {
URedwoodCommonGameSubsystem::DeserializeBackendData(
bStoreDataInActor ? (UObject *)Pawn : (UObject *)this,
RedwoodCharacterBackend.EquippedInventory,
*EquippedInventoryVariableName,
LatestEquippedInventorySchemaVersion
);
}

URedwoodCommonGameSubsystem::DeserializeBackendData(
bStoreDataInActor ? (UObject *)Pawn : (UObject *)this,
RedwoodCharacterBackend.NonequippedInventory,
*NonequippedInventoryVariableName,
LatestNonequippedInventorySchemaVersion
);
if (bUseNonequippedInventory) {
URedwoodCommonGameSubsystem::DeserializeBackendData(
bStoreDataInActor ? (UObject *)Pawn : (UObject *)this,
RedwoodCharacterBackend.NonequippedInventory,
*NonequippedInventoryVariableName,
LatestNonequippedInventorySchemaVersion
);
}

URedwoodCommonGameSubsystem::DeserializeBackendData(
bStoreDataInActor ? (UObject *)Pawn : (UObject *)this,
RedwoodCharacterBackend.Data,
*DataVariableName,
LatestDataSchemaVersion
);
if (bUseData) {
URedwoodCommonGameSubsystem::DeserializeBackendData(
bStoreDataInActor ? (UObject *)Pawn : (UObject *)this,
RedwoodCharacterBackend.Data,
*DataVariableName,
LatestDataSchemaVersion
);
}

OnRedwoodCharacterUpdated.Broadcast();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ FRedwoodGameServerProxy URedwoodCommonGameSubsystem::ParseServerProxy(

Server.ModeId = ServerProxy->GetStringField(TEXT("modeId"));

Server.MapId = ServerProxy->GetStringField(TEXT("mapId"));
ServerProxy->TryGetStringField(TEXT("mapId"), Server.MapId);

Server.bContinuousPlay = ServerProxy->GetBoolField(TEXT("continuousPlay"));

Expand Down
106 changes: 58 additions & 48 deletions RedwoodCore/Source/Redwood/Private/RedwoodServerGameSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,62 +857,72 @@ void URedwoodServerGameSubsystem::FlushPlayerCharacterData() {
// since we save the whole json to disk, we update all
// of the data here to ensure proper variable name serialization

USIOJsonObject *CharacterCreatorData =
URedwoodCommonGameSubsystem::SerializeBackendData(
CharacterComponent->bStoreDataInActor
? (UObject *)Pawn
: (UObject *)CharacterComponent,
CharacterComponent->CharacterCreatorDataVariableName
);
if (CharacterCreatorData) {
RedwoodPlayerState->RedwoodCharacter.CharacterCreatorData =
CharacterCreatorData;
if (CharacterComponent->bUseCharacterCreatorData) {
USIOJsonObject *CharacterCreatorData =
URedwoodCommonGameSubsystem::SerializeBackendData(
CharacterComponent->bStoreDataInActor
? (UObject *)Pawn
: (UObject *)CharacterComponent,
CharacterComponent->CharacterCreatorDataVariableName
);
if (CharacterCreatorData) {
RedwoodPlayerState->RedwoodCharacter.CharacterCreatorData =
CharacterCreatorData;
}
}

USIOJsonObject *Metadata =
URedwoodCommonGameSubsystem::SerializeBackendData(
CharacterComponent->bStoreDataInActor
? (UObject *)Pawn
: (UObject *)CharacterComponent,
CharacterComponent->MetadataVariableName
);
if (Metadata) {
RedwoodPlayerState->RedwoodCharacter.Metadata = Metadata;
if (CharacterComponent->bUseMetadata) {
USIOJsonObject *Metadata =
URedwoodCommonGameSubsystem::SerializeBackendData(
CharacterComponent->bStoreDataInActor
? (UObject *)Pawn
: (UObject *)CharacterComponent,
CharacterComponent->MetadataVariableName
);
if (Metadata) {
RedwoodPlayerState->RedwoodCharacter.Metadata = Metadata;
}
}

USIOJsonObject *EquippedInventory =
URedwoodCommonGameSubsystem::SerializeBackendData(
CharacterComponent->bStoreDataInActor
? (UObject *)Pawn
: (UObject *)CharacterComponent,
CharacterComponent->EquippedInventoryVariableName
);
if (EquippedInventory) {
RedwoodPlayerState->RedwoodCharacter.EquippedInventory =
EquippedInventory;
if (CharacterComponent->bUseEquippedInventory) {
USIOJsonObject *EquippedInventory =
URedwoodCommonGameSubsystem::SerializeBackendData(
CharacterComponent->bStoreDataInActor
? (UObject *)Pawn
: (UObject *)CharacterComponent,
CharacterComponent->EquippedInventoryVariableName
);
if (EquippedInventory) {
RedwoodPlayerState->RedwoodCharacter.EquippedInventory =
EquippedInventory;
}
}

USIOJsonObject *NonequippedInventory =
URedwoodCommonGameSubsystem::SerializeBackendData(
CharacterComponent->bStoreDataInActor
? (UObject *)Pawn
: (UObject *)CharacterComponent,
CharacterComponent->NonequippedInventoryVariableName
);
if (NonequippedInventory) {
RedwoodPlayerState->RedwoodCharacter.NonequippedInventory =
NonequippedInventory;
if (CharacterComponent->bUseNonequippedInventory) {
USIOJsonObject *NonequippedInventory =
URedwoodCommonGameSubsystem::SerializeBackendData(
CharacterComponent->bStoreDataInActor
? (UObject *)Pawn
: (UObject *)CharacterComponent,
CharacterComponent->NonequippedInventoryVariableName
);
if (NonequippedInventory) {
RedwoodPlayerState->RedwoodCharacter.NonequippedInventory =
NonequippedInventory;
}
}

USIOJsonObject *CharData =
URedwoodCommonGameSubsystem::SerializeBackendData(
CharacterComponent->bStoreDataInActor
? (UObject *)Pawn
: (UObject *)CharacterComponent,
CharacterComponent->DataVariableName
);
if (CharData) {
RedwoodPlayerState->RedwoodCharacter.Data = CharData;
if (CharacterComponent->bUseData) {
USIOJsonObject *CharData =
URedwoodCommonGameSubsystem::SerializeBackendData(
CharacterComponent->bStoreDataInActor
? (UObject *)Pawn
: (UObject *)CharacterComponent,
CharacterComponent->DataVariableName
);
if (CharData) {
RedwoodPlayerState->RedwoodCharacter.Data = CharData;
}
}

URedwoodCommonGameSubsystem::SaveCharacterToDisk(
Expand Down
35 changes: 30 additions & 5 deletions RedwoodCore/Source/Redwood/Public/RedwoodCharacterComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,45 @@ class REDWOOD_API URedwoodCharacterComponent : public UActorComponent {
UPROPERTY(Replicated, BlueprintReadOnly, Category = "Redwood")
FString RedwoodCharacterName;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
bool bUseCharacterCreatorData = true;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
FString CharacterCreatorDataVariableName = TEXT("CharacterCreatorData");

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
int32 LatestCharacterCreatorDataSchemaVersion = 0;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
bool bUseMetadata = true;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
FString MetadataVariableName = TEXT("Metadata");

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
int32 LatestMetadataSchemaVersion = 0;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
bool bUseEquippedInventory = true;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
FString EquippedInventoryVariableName = TEXT("EquippedInventory");

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
int32 LatestEquippedInventorySchemaVersion = 0;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
bool bUseNonequippedInventory = true;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
FString NonequippedInventoryVariableName = TEXT("NonequippedInventory");

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
int32 LatestNonequippedInventorySchemaVersion = 0;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
bool bUseData = true;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Redwood")
FString DataVariableName = TEXT("Data");

Expand All @@ -75,27 +90,37 @@ class REDWOOD_API URedwoodCharacterComponent : public UActorComponent {

UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Redwood")
void MarkCharacterCreatorDataDirty() {
bCharacterCreatorDataDirty = true;
if (bUseCharacterCreatorData) {
bCharacterCreatorDataDirty = true;
}
}

UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Redwood")
void MarkMetadataDirty() {
bMetadataDirty = true;
if (bUseMetadata) {
bMetadataDirty = true;
}
}

UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Redwood")
void MarkEquippedInventoryDirty() {
bEquippedInventoryDirty = true;
if (bUseEquippedInventory) {
bEquippedInventoryDirty = true;
}
}

UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Redwood")
void MarkNonequippedInventoryDirty() {
bNonequippedInventoryDirty = true;
if (bUseNonequippedInventory) {
bNonequippedInventoryDirty = true;
}
}

UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Redwood")
void MarkDataDirty() {
bDataDirty = true;
if (bUseData) {
bDataDirty = true;
}
}

UFUNCTION(BlueprintPure, Category = "Redwood")
Expand Down
Loading

0 comments on commit 041268d

Please sign in to comment.