Commit Graph

14 Commits

Author SHA1 Message Date
Lorenz Junglas
7b853ce569 Serialization floating point inaccuracy fixes (#4493) 2026-04-09 08:46:42 +02:00
Lorenz Junglas
73eb8b7dba Fix issues when referencing deleted prefabs (#4487)
* Log warning isntead of asserting when a prefab file is missing

* Prefab Instances with missing prefab files now show up as broken in the hierarchy

Their data is retained similar to missing components so if the file gets restored the instance will recreate properly

https://files.facepunch.com/lolleko/2026/April/07_15-50-CarelessIraniangroundjay.png
2026-04-08 09:48:06 +01:00
Lorenz Junglas
238425e6d3 Omit nulls when serializing for network (#4376)
When serializing and deserializing to/from JSON we need to explicitly write nulls.
Because for development/editing we need to differentiate the following cases:
1. JSON is of an older version (field missing) -> initialize with code defined default
2. JSON is of the current version and field is actually null -> initialize with null

For networking we don't need to differentiate between those cases since client and server have the same version of the code at runtime.

So in networking case we can omit nulls from the JSON and skip all of these:

```
          "OnComponentDestroy": null,
          "OnComponentDisabled": null,
          "OnComponentEnabled": null,
          "OnComponentFixedUpdate": null,
          "OnComponentStart": null,
          "OnComponentUpdate": null,
          "OnPropBreak": null,
          "OnPropTakeDamage": null,
```

However, this wont reduce the amount of data that ends up on the wire, because compression already does a good job at deduplicating those strings.

```
Raw JSON    with nulls :      41Kb
Raw JSON    skip nulls :      27Kb  (13Kb saved, 33.6% smaller, 1.51x ratio)
LZ4 fast    with nulls :       7Kb  (34Kb saved, 81.9% smaller, 5.54x ratio)
LZ4 fast    skip nulls :       7Kb  (34Kb saved, 82.6% smaller, 5.76x ratio)
```

The main benefit instead comes from saving CPU resources as this makes compression/decompression faster, because there is less data to process.

```
LZ4  with nulls          compress :    0.210 ms/op
LZ4  with nulls          decomp   :    0.232 ms/op
 
LZ4  skip nulls          compress :    0.165 ms/op
LZ4  skip nulls          decomp   :    0.074 ms/op
```
2026-03-27 10:59:06 +01:00
Sol Williams
093bb474b2 Add GameObject to missing component log (#4286) 2026-03-12 11:57:05 +00:00
Lorenz Junglas
5ce8f82713 Avoid CallbackBatch action allocations (#4201)
* Avoid callbackbatch aciton allocation and closure

Store the CommonCallback and GameObject/Comonent Instance instead of an action

* Scene push uses struct instead of DisposeAction

Avoids action allocation
2026-03-05 08:24:26 +01:00
Lorenz Junglas
5517a11f95 Minor prefab improvements (#4155)
* Use ToArray to avoid collection modified while iterated exception

Not sure this ever actually happened but better to be save.

* Remove ValidatePrefabLookup from SerializePrefabInstance

ValidatePrefabLookup may have modified GUIDs incorrectly on undo/redo.
Also Serialize should be read-only op.
ValidatePrefabLookup  is still called at enough other places.
2026-02-27 09:59:21 +01:00
Lorenz Junglas
aeae9e0aa6 Fix native resource reference networking (#4137)
* Fix native resource networking

Native resource networking never properly worked, because it relied on ids that may not exist on a connecting client.

- `Resource.ResourceId` is now Obsolete
- Added `internal Resource.ResourceIdLong`
- Networking now uses the 64 bit id
- Register all Resource Paths during package load, so networking for native packages works even if they are not loaded
- Client automatically loads networked resource if not cached
- Clothing container now serializes path instead of ID but maintains backwards compatibility.
- Drop ResourceId usage in tools
2026-02-25 12:07:02 +01:00
Lorenz Junglas
5a18042ef6 Improve error handling for nested prefabs when prefab is missing (#3980)
Before InitMappingsForNestedInstance would fail when encountering a missing prefab in the hierarchy and crash serialization.
Now Serialization will continue ad a descriptive warning will be logged.
2026-02-03 11:13:15 +01:00
Conna Wiles
59e26d3d6f Fixed Join via New Instance Disconnection Crash (#3799) 2026-01-15 17:01:51 +00:00
Lorenz Junglas
a321becdab Dont break prefabs on networkspawn (#3736)
* Remove remnants of last attempt
* Add tests that checks if prefab source is retained after network spawn
* Stop breaking prefab instances on network spawn
* Serialize & Serialize prefab path in JSON for NetworkObjects
2026-01-12 17:05:17 +01:00
Conna Wiles
fd1af240f3 NetworkFlags + Transform Sync Flags (#3634) 2026-01-05 17:42:25 +00:00
Lorenz Junglas
9551e9844e Cache (De)SerializeOptions in hot paths (#3547)
They are essentially compile time constants, so we shouldn't allocate them
2025-12-03 19:36:51 +00:00
Jusvit
d6e72110b5 Fix various public-facing XML comments 2025-11-27 12:37:51 +00:00
s&box team
71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00