-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor map loading & saving #5572
Open
ElectroJr
wants to merge
25
commits into
space-wizards:master
Choose a base branch
from
ElectroJr:map-load-refactor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
ElectroJr
added
Area: Serialization
Status: Requires Content PR
This PR breaks content and requires both to be merged together.
Status: Needs Review
This PR needs to be reviewed before it can be merged.
labels
Dec 23, 2024
ElectroJr
requested review from
metalgearsloth,
PJB3005 and
DrSmugleaf
as code owners
December 23, 2024 04:36
shell yeah |
Also better handling for saving multiple entities individually
also fixes wrong v4 format
This was referenced Dec 27, 2024
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area: Serialization
Status: Needs Review
This PR needs to be reviewed before it can be merged.
Status: Requires Content PR
This PR breaks content and requires both to be merged together.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR reworks and tries to generalize entity serialization (i.e., map saving & loading). IMO the main shortcomings of the current system are that only files containing either a single root map or grid are properly supported and that there is no real support for null-space entities. We also need better multi-map support for full game saves. The current setup is also prone to introducing bugs due to the lack of distinction between whether a file is a "grid" or "map". This can lead people accidentally saving/loading maps as grids and vice versa, which has caused game breaking bugs that can remain undetected until a problematic file is loaded improperly.
This is a revival of a 1+ year old draft, and has had quite a few conflicts. I've tried to clean up any issues but I also wouldn't be too surprised if I missed something or accidentally reverted some serialization changes/bugfixes.
Requires space-wizards/space-station-14#34020 .
Overview of changes:
MapLoaderSystem
and associated classes & structs have been moved to shared to support single player games and serialization of client-side entities.EntitySerializer
andEntityDeserializer
classes.DataNode
MapLoadOptions
class has been replaced withMapLoadOptions
,SerializationOptions
, andDeserializationOptions
structsTryLoad()
andSave()
methods have been replaced with grid, map, generic entity variants. I.e,TrySaveGrid
,TrySaveMap
,TrySaveEntity
, andTrySaveGeneric()
.SwapRootNode()
.MapSerializationContext
.File format changes
Serialization auto-inclusion
Currently if an entity gets serialized, but has some component that references an EntityUid that is not being serialized, it will log an error and might lead to broken saves. The new default behaviour is that if the referenced entity is a non-map null-space entity, it will automatically include that entity in the save, otherwise it still logs an error.
This is intended to make it easier when saving a map/grid with entities that depends on null-space entities. The actual behaviour can be configured to also auto-include any referenced entity. So for example, saving a map that references a station or rule, which in turn references another map, would result in the file containing both maps.
Other Changes
when warnings are logged.
IServerEntityManagerInternal
has been removed. AFAICT it was just being used by entity serialization, and was internal anyways.MapChangedEvent
has been marked as obsolete, and should be replaced withMapCreatedEvent
and `MapRemovedEvent.ITileDefinitionManager.AssignAlias
and general tile alias functionality has been removed.TileAliasPrototype
still exist, but is only used during entity deserialization. This and related serialization changes fixes Tile Migration is not working #5565IEntitySystemManager
now exposes the systemIDependencyCollection
, mainly so that you can useInjectDependencies()
, which is used by the new serializer classes to resolve system dependencies.BeforeSaveEvent
has been replaced withBeforeSerializationEvent
, and there is a newAfterSerializationEvent
.