Skip to content

Commit

Permalink
Merge pull request #350 from Panakotta00/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Panakotta00 authored Nov 5, 2024
2 parents 019801f + 1cf51fb commit 55185f7
Show file tree
Hide file tree
Showing 25 changed files with 758 additions and 119 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/deploy-to-smr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:
core.setFailed('Found Release is a draft!');
return;
}
core.setOutput('body_encoded', btoa(release.body));
core.setOutput('body', btoa(release.body.replaceAll("*", "\\*")));
core.setOutput('name', release.name);
- name: Download FicsIt-Networks Version
if: ${{inputs.should_upload}}
Expand All @@ -56,36 +57,38 @@ jobs:
- name: Upload to SMR
if: ${{inputs.should_upload}}
env:
BODY_ENCODED: ${{steps.find-release.outputs.body_encoded}}
run: |
BODY=$(echo "$BODY_ENCODED" | base64 --decode)
ficsit --api-key "${{secrets.SMR_API_KEY}}" smr upload 8d8gk4imvFanRs FicsItNetworks.zip $BODY
BODY: ${{steps.find-release.outputs.body}}
run: ficsit --api-key "${{secrets.SMR_API_KEY}}" smr upload 8d8gk4imvFanRs FicsItNetworks.zip $BODY

- name: Wait for Approval
uses: actions/github-script@v7
with:
script: |
while (true) {
await new Promise(resolve => setTimeout(resolve, 5000));
let response = await fetch("https://api.ficsit.app/v2/query", {
method: "POST",
headers: {"Cookies": "token=${{secrets.SMR_API_KEY}}", "Content-Type":"application/json"},
body: JSON.stringify({
query: '{getModByReference(modReference:"FicsItNetworks"){versions(filter:{order_by:created_at}){approved virustotal_results{safe}}}}'
query: '{getModByReference(modReference:"FicsItNetworks"){versions(filter:{order_by:created_at}){version approved virustotal_results{safe}}}}'
})
})
if (!response.ok) {
console.log(`Checking Fetch: Response is not OK: ${response.status}`);
} else {
const json = await response.json();
let mod = json.data.getModByReference.versions[0];
if (mod.version != '${{steps.find-release.outputs.name}}') {
console.log("Version not yet found...");
continue;
}
let unsafe = mod.virustotal_results.find(virus => !virus.safe);
if (mod.approved && !unsafe) {
console.log("Version got approved!");
return;
}
console.log("Version not approved yet");
}
await new Promise(resolve => setTimeout(resolve, 5000));
}
send-discord-release-message:
needs: deploy-to-smr
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Content/Equipment/NetworkManager/Equip_NetworkManager.uasset
Binary file not shown.
2 changes: 1 addition & 1 deletion FicsItNetworks.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"FileVersion": 3,
"Version": 0,
"VersionName": "0.3",
"SemVersion": "0.3.24",
"SemVersion": "0.3.25",
"FriendlyName": "FicsIt-Networks",
"Description": "Adds a computer network and programmable computers to the Game.",
"Category": "Modding",
Expand Down
13 changes: 13 additions & 0 deletions SML_Patch.patch
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ index c00ac8d210..3bb40273cd 100644
public:
/**
* Called bu the tracks when a vehicle enters and exits a section of track.
diff --git a/Source/FactoryGame/Public/Buildables/FGBuildableRailroadSwitchControl.h b/Source/FactoryGame/Public/Buildables/FGBuildableRailroadSwitchControl.h
index 99025de9bf..13945dbd65 100644
--- a/Source/FactoryGame/Public/Buildables/FGBuildableRailroadSwitchControl.h
+++ b/Source/FactoryGame/Public/Buildables/FGBuildableRailroadSwitchControl.h
@@ -7,6 +7,8 @@
#include "FGUseableInterface.h"
#include "FGBuildableRailroadSwitchControl.generated.h"

+class UFGRailroadTrackConnectionComponent;
+
/**
* Struct containing packaged switch data so we can get an OnRep for them as a group.
*/
12 changes: 6 additions & 6 deletions Source/FicsItFileSystem/Private/FileSystemSerializationInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace CodersFileSystem {
#define CheckKeepDisk(Condition) \
if (bIsLoading && KeepDisk == -1) { \
if (Condition) KeepDisk = AskForDiskOrSave(Name); \
if (KeepDisk == 1) return; \
if (KeepDisk == FIFS_KEEP_CHANGES) return; \
}

void SerializePath(TSharedRef<Device> SerializeDevice, FStructuredArchive::FRecord Record, Path Path, FString Name, int& KeepDisk, const TFunction<int(FString)>& AskForDiskOrSave) {
Expand All @@ -36,7 +36,7 @@ namespace CodersFileSystem {
FStructuredArchive::FArray ChildNodes = Record.EnterArray(SA_FIELD_NAME(TEXT("ChildNodes")), ChildNodeNum);
std::unordered_set<std::string> DiskChilds = SerializeDevice->children(Path);
CheckKeepDisk(DiskChilds.size() != ChildNodeNum);
if (KeepDisk == 0) {
if (KeepDisk == FIFS_OVERRIDE_CHANGES) {
for (std::string DiskChild : DiskChilds) {
SerializeDevice->remove(Path / DiskChild, true);
}
Expand All @@ -53,7 +53,7 @@ namespace CodersFileSystem {
std::string stdChildName = TCHAR_TO_UTF8(*UChildName);

CheckKeepDisk(DiskChilds.find(stdChildName) == DiskChilds.end())
if (DiskChilds.size() > 0 && KeepDisk == 0) {
if (DiskChilds.size() > 0 && KeepDisk == FIFS_OVERRIDE_CHANGES) {
for (std::string DiskChild : DiskChilds) {
SerializeDevice->remove(Path / DiskChild, true);
}
Expand All @@ -70,7 +70,7 @@ namespace CodersFileSystem {
TOptional<FileType> existingType = SerializeDevice->fileType(Path / stdChildName);
if (Type == 1) {
CheckKeepDisk(!existingType.IsSet() || *existingType != File_Regular)
if (KeepDisk == 0) {
if (KeepDisk == FIFS_OVERRIDE_CHANGES) {
SerializeDevice->remove(Path / stdChildName, true);
}
FStructuredArchive::FSlot Content = Child.EnterField(SA_FIELD_NAME(TEXT("FileContent")));
Expand All @@ -84,7 +84,7 @@ namespace CodersFileSystem {
std::string stdData(reinterpret_cast<char*>(Data.GetData()), Data.Num());

CheckKeepDisk(diskData != stdData)
if (KeepDisk == 0) {
if (KeepDisk == FIFS_OVERRIDE_CHANGES) {
TSharedRef<CodersFileSystem::FileStream> Stream = SerializeDevice->open(Path / stdChildName, CodersFileSystem::OUTPUT | CodersFileSystem::TRUNC | CodersFileSystem::BINARY).ToSharedRef();
Stream->write(stdData);
Stream->close();
Expand All @@ -99,7 +99,7 @@ namespace CodersFileSystem {
}
} else if (Type == 2) {
CheckKeepDisk(!existingType.IsSet() || *existingType != File_Directory)
if (KeepDisk == 0) {
if (KeepDisk == FIFS_OVERRIDE_CHANGES) {
SerializeDevice->remove(Path / stdChildName, true);
}
SerializeDevice->createDir(Path / stdChildName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void UFINNetworkConnectionComponent::RemoveConnectedCable(AFINNetworkCable* Cabl

if (ConnectedCables.Remove(Cable) > 0) {
if (UFINNetworkConnectionComponent* OtherConnector = Cable->GetOtherConnector(this)) {
OtherConnector->ConnectedCables.Remove(Cable);
OtherConnector->RemoveConnectedCable(Cable);
AFINNetworkCircuit::DisconnectNodes(OtherConnector->Circuit, this, OtherConnector);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@

AFINComputerDriveHolder::AFINComputerDriveHolder() {
DriveInventory = CreateDefaultSubobject<UFGInventoryComponent>("DriveInventory");
DriveInventory->Resize();
DriveInventory->OnItemAddedDelegate.AddDynamic(this, &AFINComputerDriveHolder::OnDriveInventoryUpdate);
DriveInventory->OnItemRemovedDelegate.AddDynamic(this, &AFINComputerDriveHolder::OnDriveInventoryUpdate);
DriveInventory->SetIsReplicated(true);
DriveInventory->SetDefaultSize(1);
DriveInventory->Resize(1);

bReplicates = true;
NetDormancy = DORM_Awake;
}

AFINComputerDriveHolder::~AFINComputerDriveHolder() {}
void AFINComputerDriveHolder::BeginPlay() {
Super::BeginPlay();

DriveInventory->OnSlotUpdatedDelegate.AddDynamic(this, &AFINComputerDriveHolder::OnDriveSlotUpdate);

DriveInventory->mItemFilter.BindLambda([](TSubclassOf<UObject> Item, int32 Index) {
//return Item->IsChildOf(UFINComputerDriveDesc::StaticClass());
return true;
});
if (HasAuthority()) {
DriveInventory->SetReplicationRelevancyOwner(this);
DriveInventory->Resize(1);
}
}

void AFINComputerDriveHolder::EndPlay(EEndPlayReason::Type reason) {
SetLocked(false);
Expand All @@ -25,7 +38,6 @@ void AFINComputerDriveHolder::EndPlay(EEndPlayReason::Type reason) {
void AFINComputerDriveHolder::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const {
Super::GetLifetimeReplicatedProps(OutLifetimeProps);

DOREPLIFETIME(AFINComputerDriveHolder, DriveInventory);
DOREPLIFETIME(AFINComputerDriveHolder, bLocked);
}

Expand Down Expand Up @@ -63,17 +75,20 @@ bool AFINComputerDriveHolder::SetLocked(bool NewLocked) {
return true;
}

void AFINComputerDriveHolder::OnDriveSlotUpdate(int index) {
FGuid drive = GetDrive();
if (HasAuthority()) {
NetMulti_OnDriveUpdate(drive);
SetLocked(drive.IsValid());
} else {
OnDriveUpdate.Broadcast(drive);
}
}

void AFINComputerDriveHolder::NetMulti_OnDriveUpdate_Implementation(const FGuid& Drive) {
OnDriveUpdate.Broadcast(Drive);
}

void AFINComputerDriveHolder::NetMulti_OnLockedUpdate_Implementation(bool bOldLocked, const FGuid& NewOrOldDrive) {
OnLockedUpdate.Broadcast(bOldLocked, NewOrOldDrive);
}

void AFINComputerDriveHolder::OnDriveInventoryUpdate_Implementation(TSubclassOf<UFGItemDescriptor> drive, int32 count, UFGInventoryComponent* sourceInventory) {
if (HasAuthority()) {
NetMulti_OnDriveUpdate(GetDrive());
if (!IsValid(drive)) SetLocked(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
#include "Engine/Engine.h"
#include "FicsItKernel/FicsItFS/FINItemStateFileSystem.h"

FCriticalSection AFINFileSystemSubsystem::DevicesMutex;
TMap<FGuid, TSharedRef<CodersFileSystem::Device>> AFINFileSystemSubsystem::Devices;

TSharedPtr<CodersFileSystem::Device> AFINFileSystemSubsystem::GetDevice(const FGuid& FileSystemID, bool bInForceUpdate, bool bInForceCreate) {
if (!FileSystemID.IsValid()) return nullptr;

FScopeLock Lock(&DevicesMutex);

TSharedPtr<CodersFileSystem::Device> Device;
TSharedRef<CodersFileSystem::Device>* DevicePtr = Devices.Find(FileSystemID);
if (DevicePtr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FICSITNETWORKSCOMPUTER_API AFINComputerDriveHolder : public AFINComputerMo
bool bLocked = false;

public:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, SaveGame, Replicated)
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
UFGInventoryComponent* DriveInventory = nullptr;

UPROPERTY(BlueprintReadWrite, BlueprintAssignable)
Expand All @@ -30,9 +30,9 @@ class FICSITNETWORKSCOMPUTER_API AFINComputerDriveHolder : public AFINComputerMo
FFINDriveHolderLockedUpdateDelegate OnLockedUpdate;

AFINComputerDriveHolder();
~AFINComputerDriveHolder();

// Begin AActor
virtual void BeginPlay() override;
virtual void EndPlay(EEndPlayReason::Type reason) override;
// End AActor

Expand All @@ -44,13 +44,16 @@ class FICSITNETWORKSCOMPUTER_API AFINComputerDriveHolder : public AFINComputerMo
UFUNCTION(BlueprintSetter)
bool SetLocked(bool NewLocked);

UFUNCTION(NetMulticast, Unreliable)
UFUNCTION(NetMulticast, Reliable)
void NetMulti_OnDriveUpdate(const FGuid& Drive);

UFUNCTION(NetMulticast, Unreliable)
UFUNCTION(NetMulticast, Reliable)
void NetMulti_OnLockedUpdate(bool bOldLocked, const FGuid& NewOrOldDrive);

protected:
UFUNCTION(BlueprintNativeEvent, Category="Computer|Drive")
void OnDriveInventoryUpdate(TSubclassOf<UFGItemDescriptor> drive, int32 count, UFGInventoryComponent* sourceInventory);
UFUNCTION()
void OnDriveSlotUpdate(int index);

UFUNCTION(BlueprintImplementableEvent, Category="Computer|Drive")
void OnDriveInventoryUpdate();
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ class FICSITNETWORKSCOMPUTER_API AFINFileSystemSubsystem : public AFGSubsystem {
}

private:
static FCriticalSection DevicesMutex;
static TMap<FGuid, TSharedRef<CodersFileSystem::Device>> Devices;

// TODO: FileSystem Usage
FCriticalSection UsageMutex;
TMap<FGuid, double> Usage;

FTimerHandle UsageUpdateHandler;
Expand Down
1 change: 1 addition & 0 deletions Source/FicsItNetworksLua/Private/FINEventFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ bool FFINEventFilter::Matches(UObject* Sender, const FFINSignalData& Signal) con
bool FFINEventFilterExpression::Matches(UObject* Sender, const FFINSignalData& Signal) const {
switch (Operator) {
case FIN_EventFilter_None:
if (!IsValid(Operand1.GetStruct())) return true;
if (Operand1.GetStruct() != FFINEventFilter::StaticStruct()) return false;
return Operand1.Get<FFINEventFilter>().Matches(Sender, Signal);
case FIN_EventFilter_AND:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "FINLuaProcessor.h"
#include "FINNetworkUtils.h"
#include "NetworkController.h"
#include "FINLua/FINLuaModule.h"
#include "FINLua/Reflection/LuaClass.h"
#include "FINLua/Reflection/LuaObject.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ namespace FINLua {
*/)", attentionPing) {
LuaFunc();

FVector Position = luaFIN_checkStruct<FVector>(L, 1, true);
FVector Position = *luaFIN_checkStruct<FVector>(L, 1, true);
TOptional<FString> Player;
if (lua_isstring(L, 2)) Player = luaFIN_checkFString(L, 2);
for (auto players = kernel->GetWorld()->GetPlayerControllerIterator(); players; players++) {
Expand Down
Loading

0 comments on commit 55185f7

Please sign in to comment.