Revert "entity creation crash fixes"

This reverts commit 603c252c48.
This commit is contained in:
Kara D
2021-11-10 12:09:31 -07:00
parent 603c252c48
commit 0972601a43
2 changed files with 14 additions and 22 deletions

View File

@@ -69,29 +69,21 @@ namespace Robust.Server.GameObjects
if (!string.IsNullOrWhiteSpace(prototypeName))
{
if (PrototypeManager.TryIndex<EntityPrototype>(prototypeName, out var prototype))
{
var prototype = PrototypeManager.Index<EntityPrototype>(prototypeName);
// At this point in time, all data configure on the entity *should* be purely from the prototype.
// As such, we can reset the modified ticks to Zero,
// which indicates "not different from client's own deserialization".
// So the initial data for the component or even the creation doesn't have to be sent over the wire.
foreach (var (netId, component) in GetNetComponents(entity.Uid))
{
// Make sure to ONLY get components that are defined in the prototype.
// Others could be instantiated directly by AddComponent (e.g. ContainerManager).
// And those aren't guaranteed to exist on the client, so don't clear them.
if (prototype.Components.ContainsKey(component.Name)) ((Component) component).ClearTicks();
}
}
else
// At this point in time, all data configure on the entity *should* be purely from the prototype.
// As such, we can reset the modified ticks to Zero,
// which indicates "not different from client's own deserialization".
// So the initial data for the component or even the creation doesn't have to be sent over the wire.
foreach (var (netId, component) in GetNetComponents(entity.Uid))
{
Logger.Error($"Invalid prototypeId '{prototypeName}' passed to {nameof(CreateEntity)}.");
// Make sure to ONLY get components that are defined in the prototype.
// Others could be instantiated directly by AddComponent (e.g. ContainerManager).
// And those aren't guaranteed to exist on the client, so don't clear them.
if (prototype.Components.ContainsKey(component.Name)) ((Component) component).ClearTicks();
}
}
return entity;
}