Skip to content

Commit

Permalink
fix: Some issues with EEPROM state change update propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
Panakotta00 committed Oct 17, 2024
1 parent b084cba commit 41e8802
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 1 deletion.
Binary file not shown.
2 changes: 2 additions & 0 deletions Source/FicsItNetworksComputer/Private/FINComputerCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "FINAdvancedNetworkConnectionComponent.h"
#include "FINComputerEEPROMDesc.h"
#include "FINComputerFloppyDesc.h"
#include "FINComputerRCO.h"
#include "FINFileSystemSubsystem.h"
#include "FINUtils.h"
#include "Components/AudioComponent.h"
Expand Down Expand Up @@ -105,6 +106,7 @@ void AFINComputerCase::OnConstruction(const FTransform& transform) {
FInventoryStack stack;
if (DataStorage->GetStackFromIndex(0, stack) || stack.HasItems()) {
DataStorage->SetStateOnIndex(0, state);
GetWorld()->GetFirstPlayerController<AFGPlayerController>()->GetRemoteCallObjectOfClass<UFINComputerRCO>()->Multicast_ItemStateUpdated(DataStorage, stack.Item.GetItemClass());
return true;
}
return false;
Expand Down
4 changes: 4 additions & 0 deletions Source/FicsItNetworksComputer/Private/FINComputerRCO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,7 @@ void UFINComputerRCO::SetLabel_Implementation(UFGInventoryComponent* Inventory,
Inventory->SetStateOnIndex(Index, state);
}
}

void UFINComputerRCO::Multicast_ItemStateUpdated_Implementation(class UFGInventoryComponent* Inventory, TSubclassOf<UFGItemDescriptor> Item) {
Inventory->OnItemAddedDelegate.Broadcast(Item, 0, Inventory);
}
3 changes: 3 additions & 0 deletions Source/FicsItNetworksComputer/Public/FINComputerRCO.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ class FICSITNETWORKSCOMPUTER_API UFINComputerRCO : public UFGRemoteCallObject {

UFUNCTION(Server, Reliable)
void SetLabel(UFGInventoryComponent* Inventory, int32 Index, const FString& Label);

UFUNCTION(NetMulticast, Unreliable)
void Multicast_ItemStateUpdated(class UFGInventoryComponent* Inventory, TSubclassOf<UFGItemDescriptor> Item);
};
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ namespace FINLua {

FString code = luaFIN_checkFString(L, 1);

if (Cast<UFINLuaProcessor>(kernel->GetProcessor())->SetEEPROM(code)) {
if (!Cast<UFINLuaProcessor>(kernel->GetProcessor())->SetEEPROM(code)) {
return luaL_error(L, "no eeprom set");
}

Expand Down
4 changes: 4 additions & 0 deletions Source/FicsItNetworksLua/Private/FINLuaRCO.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "FINLuaRCO.h"

#include "FGInventoryComponent.h"
#include "FGPlayerController.h"
#include "FINComputerEEPROMDesc.h"
#include "FINComputerRCO.h"
#include "FINItemStateEEPROMLua.h"
#include "Engine/World.h"
#include "Net/UnrealNetwork.h"

void UFINLuaRCO::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const {
Expand All @@ -19,5 +22,6 @@ void UFINLuaRCO::SetLuaEEPROMCode_Implementation(UFGInventoryComponent* Inventor
FFINItemStateEEPROMLua state = *luaState;
state.Code = NewCode;
Inventory->SetStateOnIndex(Index, FFGDynamicStruct(state));
GetWorld()->GetFirstPlayerController<AFGPlayerController>()->GetRemoteCallObjectOfClass<UFINComputerRCO>()->Multicast_ItemStateUpdated(Inventory, stack.Item.GetItemClass());
}
}
2 changes: 2 additions & 0 deletions Source/FicsItNetworksLua/Public/FINLuaRCO.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "FGRemoteCallObject.h"
#include "FINLuaRCO.generated.h"

class UFGItemDescriptor;

UCLASS()
class FICSITNETWORKSLUA_API UFINLuaRCO : public UFGRemoteCallObject {
GENERATED_BODY()
Expand Down

0 comments on commit 41e8802

Please sign in to comment.