Load grid error related changes (#10817)
This commit is contained in:
@@ -72,7 +72,7 @@ namespace Content.IntegrationTests.Tests.Body
|
|||||||
await server.WaitPost(() =>
|
await server.WaitPost(() =>
|
||||||
{
|
{
|
||||||
mapId = mapManager.CreateMap();
|
mapId = mapManager.CreateMap();
|
||||||
grid = mapLoader.LoadBlueprint(mapId, testMapName).gridId;
|
grid = mapLoader.LoadGrid(mapId, testMapName).gridId;
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.NotNull(grid, $"Test blueprint {testMapName} not found.");
|
Assert.NotNull(grid, $"Test blueprint {testMapName} not found.");
|
||||||
@@ -144,7 +144,7 @@ namespace Content.IntegrationTests.Tests.Body
|
|||||||
await server.WaitPost(() =>
|
await server.WaitPost(() =>
|
||||||
{
|
{
|
||||||
mapId = mapManager.CreateMap();
|
mapId = mapManager.CreateMap();
|
||||||
grid = mapLoader.LoadBlueprint(mapId, testMapName).gridId;
|
grid = mapLoader.LoadGrid(mapId, testMapName).gridId;
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.NotNull(grid, $"Test blueprint {testMapName} not found.");
|
Assert.NotNull(grid, $"Test blueprint {testMapName} not found.");
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ namespace Content.IntegrationTests.Tests
|
|||||||
{
|
{
|
||||||
// TODO: Properly find the "main" station grid.
|
// TODO: Properly find the "main" station grid.
|
||||||
var grid0 = mapManager.GetAllGrids().First();
|
var grid0 = mapManager.GetAllGrids().First();
|
||||||
mapLoader.SaveBlueprint(grid0.GridEntityId, "save load save 1.yml");
|
mapLoader.SaveGrid(grid0.GridEntityId, "save load save 1.yml");
|
||||||
var mapId = mapManager.CreateMap();
|
var mapId = mapManager.CreateMap();
|
||||||
var grid = mapLoader.LoadBlueprint(mapId, "save load save 1.yml").gridId;
|
var grid = mapLoader.LoadGrid(mapId, "save load save 1.yml").gridId;
|
||||||
mapLoader.SaveBlueprint(grid!.Value, "save load save 2.yml");
|
mapLoader.SaveGrid(grid!.Value, "save load save 2.yml");
|
||||||
});
|
});
|
||||||
|
|
||||||
await server.WaitIdleAsync();
|
await server.WaitIdleAsync();
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ public sealed partial class CargoSystem
|
|||||||
var possibleNames = _protoMan.Index<DatasetPrototype>(prototype.NameDataset).Values;
|
var possibleNames = _protoMan.Index<DatasetPrototype>(prototype.NameDataset).Values;
|
||||||
var name = _random.Pick(possibleNames);
|
var name = _random.Pick(possibleNames);
|
||||||
|
|
||||||
var (_, shuttleUid) = _loader.LoadBlueprint(CargoMap.Value, prototype.Path.ToString());
|
var (_, shuttleUid) = _loader.LoadGrid(CargoMap.Value, prototype.Path.ToString());
|
||||||
var xform = Transform(shuttleUid!.Value);
|
var xform = Transform(shuttleUid!.Value);
|
||||||
MetaData(shuttleUid!.Value).EntityName = name;
|
MetaData(shuttleUid!.Value).EntityName = name;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace Content.Server.GameTicking
|
|||||||
{
|
{
|
||||||
private const string ObserverPrototypeName = "MobObserver";
|
private const string ObserverPrototypeName = "MobObserver";
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), Obsolete("Due for removal when observer spawning is refactored.")]
|
[ViewVariables(VVAccess.ReadWrite), Obsolete("Due for removal when observer spawning is refactored.")] // See also: MindComponent's OnShutdown shitcode
|
||||||
private EntityCoordinates _spawnPoint;
|
private EntityCoordinates _spawnPoint;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -280,7 +280,11 @@ namespace Content.Server.GameTicking
|
|||||||
#region Spawn Points
|
#region Spawn Points
|
||||||
public EntityCoordinates GetObserverSpawnPoint()
|
public EntityCoordinates GetObserverSpawnPoint()
|
||||||
{
|
{
|
||||||
var location = _spawnPoint;
|
// TODO rename this to TryGetObserverSpawnPoint to make it clear that the result might be invalid. Or at
|
||||||
|
// least try try more fallback values, like randomly spawning them in any available map or just creating a
|
||||||
|
// "we fucked up" map. Its better than dumping them into the void.
|
||||||
|
|
||||||
|
var location = _spawnPoint.IsValid(EntityManager) ? _spawnPoint : EntityCoordinates.Invalid;
|
||||||
|
|
||||||
_possiblePositions.Clear();
|
_possiblePositions.Clear();
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
var shuttlePath = "/Maps/infiltrator.yml";
|
var shuttlePath = "/Maps/infiltrator.yml";
|
||||||
var mapId = _mapManager.CreateMap();
|
var mapId = _mapManager.CreateMap();
|
||||||
|
|
||||||
var (_, outpost) = _mapLoader.LoadBlueprint(mapId, "/Maps/nukieplanet.yml");
|
var (_, outpost) = _mapLoader.LoadGrid(mapId, "/Maps/nukieplanet.yml");
|
||||||
|
|
||||||
if (outpost == null)
|
if (outpost == null)
|
||||||
{
|
{
|
||||||
@@ -204,7 +204,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Listen I just don't want it to overlap.
|
// Listen I just don't want it to overlap.
|
||||||
var (_, shuttleId) = _mapLoader.LoadBlueprint(mapId, shuttlePath, new MapLoadOptions()
|
var (_, shuttleId) = _mapLoader.LoadGrid(mapId, shuttlePath, new MapLoadOptions()
|
||||||
{
|
{
|
||||||
Offset = Vector2.One * 1000f,
|
Offset = Vector2.One * 1000f,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem
|
|||||||
aabb.Union(aabbs[i]);
|
aabb.Union(aabbs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var (_, gridId) = _mapLoader.LoadBlueprint(GameTicker.DefaultMap, map, new MapLoadOptions
|
var (_, gridId) = _mapLoader.LoadGrid(GameTicker.DefaultMap, map, new MapLoadOptions
|
||||||
{
|
{
|
||||||
Offset = aabb.Center + MathF.Max(aabb.Height / 2f, aabb.Width / 2f) * 2.5f
|
Offset = aabb.Center + MathF.Max(aabb.Height / 2f, aabb.Width / 2f) * 2.5f
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -80,8 +80,11 @@ public sealed class MindSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
else if (mind.GhostOnShutdown)
|
else if (mind.GhostOnShutdown)
|
||||||
{
|
{
|
||||||
|
// Changing an entities parents while deleting is VERY sus. This WILL throw exceptions.
|
||||||
|
// TODO: just find the applicable spawn position dirctly without actually updating the transform's parent.
|
||||||
Transform(uid).AttachToGridOrMap();
|
Transform(uid).AttachToGridOrMap();
|
||||||
var spawnPosition = Transform(uid).Coordinates;
|
var spawnPosition = Transform(uid).Coordinates;
|
||||||
|
|
||||||
// Use a regular timer here because the entity has probably been deleted.
|
// Use a regular timer here because the entity has probably been deleted.
|
||||||
Timer.Spawn(0, () =>
|
Timer.Spawn(0, () =>
|
||||||
{
|
{
|
||||||
@@ -96,6 +99,13 @@ public sealed class MindSystem : EntitySystem
|
|||||||
spawnPosition = _gameTicker.GetObserverSpawnPoint();
|
spawnPosition = _gameTicker.GetObserverSpawnPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO refactor observer spawning.
|
||||||
|
if (!spawnPosition.IsValid(EntityManager))
|
||||||
|
{
|
||||||
|
Logger.ErrorS("mind", $"Entity \"{ToPrettyString(uid)}\" for {mind.Mind?.CharacterName} was deleted, and no applicable spawn location is available.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var ghost = Spawn("MobObserver", spawnPosition);
|
var ghost = Spawn("MobObserver", spawnPosition);
|
||||||
var ghostComponent = Comp<GhostComponent>(ghost);
|
var ghostComponent = Comp<GhostComponent>(ghost);
|
||||||
_ghostSystem.SetCanReturnToBody(ghostComponent, false);
|
_ghostSystem.SetCanReturnToBody(ghostComponent, false);
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ namespace Content.Server.Salvage
|
|||||||
Offset = spl.Position
|
Offset = spl.Position
|
||||||
};
|
};
|
||||||
|
|
||||||
var (_, salvageEntityId) = _mapLoader.LoadBlueprint(spl.MapId, map.MapPath.ToString(), opts);
|
var (_, salvageEntityId) = _mapLoader.LoadGrid(spl.MapId, map.MapPath.ToString(), opts);
|
||||||
if (salvageEntityId == null)
|
if (salvageEntityId == null)
|
||||||
{
|
{
|
||||||
Report(component.Owner, component.SalvageChannel, "salvage-system-announcement-spawn-debris-disintegrated");
|
Report(component.Owner, component.SalvageChannel, "salvage-system-announcement-spawn-debris-disintegrated");
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ public sealed partial class ShuttleSystem
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(centComPath))
|
if (!string.IsNullOrEmpty(centComPath))
|
||||||
{
|
{
|
||||||
var (_, centcomm) = _loader.LoadBlueprint(_centComMap.Value, "/Maps/centcomm.yml");
|
var (_, centcomm) = _loader.LoadGrid(_centComMap.Value, "/Maps/centcomm.yml");
|
||||||
_centCom = centcomm;
|
_centCom = centcomm;
|
||||||
|
|
||||||
if (_centCom != null)
|
if (_centCom != null)
|
||||||
@@ -426,7 +426,7 @@ public sealed partial class ShuttleSystem
|
|||||||
if (!_emergencyShuttleEnabled || _centComMap == null || component.EmergencyShuttle != null) return;
|
if (!_emergencyShuttleEnabled || _centComMap == null || component.EmergencyShuttle != null) return;
|
||||||
|
|
||||||
// Load escape shuttle
|
// Load escape shuttle
|
||||||
var (_, shuttle) = _loader.LoadBlueprint(_centComMap.Value, component.EmergencyShuttlePath.ToString(), new MapLoadOptions()
|
var (_, shuttle) = _loader.LoadGrid(_centComMap.Value, component.EmergencyShuttlePath.ToString(), new MapLoadOptions()
|
||||||
{
|
{
|
||||||
// Should be far enough... right? I'm too lazy to bounds check CentCom rn.
|
// Should be far enough... right? I'm too lazy to bounds check CentCom rn.
|
||||||
Offset = new Vector2(500f + _shuttleIndex, 0f)
|
Offset = new Vector2(500f + _shuttleIndex, 0f)
|
||||||
|
|||||||
@@ -835,6 +835,13 @@ namespace Content.Shared.Interaction
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Exists(userEntity))
|
||||||
|
{
|
||||||
|
Logger.WarningS("system.interaction",
|
||||||
|
$"Client attempted interaction with a non-existent attached entity. Session={session}, entity={userEntity}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,14 +66,14 @@
|
|||||||
- Flags: MAPPING
|
- Flags: MAPPING
|
||||||
Commands:
|
Commands:
|
||||||
- addmap
|
- addmap
|
||||||
- loadbp
|
- loadgrid
|
||||||
- loadmap
|
- loadmap
|
||||||
- pausemap
|
- pausemap
|
||||||
- querymappaused
|
- querymappaused
|
||||||
- rmgrid
|
- rmgrid
|
||||||
- rmmap
|
- rmmap
|
||||||
- mapinit
|
- mapinit
|
||||||
- savebp
|
- savegrid
|
||||||
- savemap
|
- savemap
|
||||||
- tpgrid
|
- tpgrid
|
||||||
- gridtc
|
- gridtc
|
||||||
|
|||||||
Reference in New Issue
Block a user