-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add FFGDynamicStruct, update FInventoryItem, add object save version …
…to archive
- Loading branch information
Showing
9 changed files
with
165 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
libsave/include/SatisfactorySave/GameTypes/UE/Satisfactory/FGDynamicStruct.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
|
||
#include "../../../IO/Archive/Archive.h" | ||
#include "../../Properties/Base/PropertyList.h" | ||
#include "ObjectReference.h" | ||
#include "satisfactorysave_export.h" | ||
|
||
namespace SatisfactorySave { | ||
|
||
struct SATISFACTORYSAVE_API FFGDynamicStruct { | ||
public: | ||
FObjectReferenceDisc ScriptStruct; | ||
PropertyList StructInstance; | ||
|
||
void serialize(Archive& ar) { | ||
if (ar.isIArchive()) { | ||
bool bHasValidStruct = false; | ||
ar << bHasValidStruct; | ||
|
||
if (bHasValidStruct) { | ||
ar << ScriptStruct; | ||
|
||
int32_t savedPayloadSize = -1; | ||
ar << savedPayloadSize; | ||
|
||
const auto pos_before = ar.tell(); | ||
|
||
// Archive has flags to switch between binary, native and tagged property serialization, see | ||
// https://github.com/EpicGames/UnrealEngine/blob/5.3.2-release/Engine/Source/Runtime/CoreUObject/Private/UObject/Class.cpp#L2761 | ||
// We assume tagged properties here. | ||
ar << StructInstance; | ||
|
||
if (ar.tell() - pos_before != savedPayloadSize) { | ||
throw std::runtime_error("Invalid FFGDynamicStruct!"); | ||
} | ||
} | ||
} else { | ||
bool bHasValidStruct = !ScriptStruct.PathName.empty(); | ||
ar << bHasValidStruct; | ||
|
||
if (bHasValidStruct) { | ||
ar << ScriptStruct; | ||
|
||
const auto offsetBeforeSavedPayloadSize = ar.tell(); | ||
|
||
int32_t savedPayloadSize = -1; | ||
ar << savedPayloadSize; | ||
|
||
const auto offsetBeforeStructPayload = ar.tell(); | ||
|
||
ar << StructInstance; | ||
|
||
savedPayloadSize = static_cast<int32_t>(ar.tell() - offsetBeforeStructPayload); | ||
const auto currentArchiveOffset = ar.tell(); | ||
ar.seek(offsetBeforeSavedPayloadSize); | ||
ar << savedPayloadSize; | ||
ar.seek(currentArchiveOffset); | ||
} | ||
} | ||
} | ||
}; | ||
} // namespace SatisfactorySave |
11 changes: 8 additions & 3 deletions
11
libsave/include/SatisfactorySave/GameTypes/UE/Satisfactory/InventoryItem.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
#pragma once | ||
|
||
#include "../../../IO/Archive/Archive.h" | ||
#include "FGDynamicStruct.h" | ||
#include "ObjectReference.h" | ||
#include "satisfactorysave_export.h" | ||
|
||
namespace SatisfactorySave { | ||
|
||
// FInventoryItem | ||
struct SATISFACTORYSAVE_API FInventoryItem { | ||
public: | ||
FObjectReferenceDisc ItemClass; | ||
FObjectReferenceDisc ItemState; | ||
FFGDynamicStruct ItemState; | ||
FObjectReferenceDisc LegacyItemStateActor; | ||
|
||
void serialize(Archive& ar) { | ||
ar << ItemClass; | ||
ar << ItemState; | ||
if (ar.getSaveVersion() >= 43) { | ||
ar << ItemState; | ||
} else { | ||
ar << LegacyItemStateActor; | ||
} | ||
} | ||
}; | ||
} // namespace SatisfactorySave |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters