Skip to content

Commit a6ae7b2

Browse files
and don't error if old entity is on a non-existent world
1 parent 63f2198 commit a6ae7b2

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

fCraft/World/Entity.cs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ public static void OldLoad() {
228228
string[] entityData = File.ReadAllLines(filename);
229229
entity.Model = CpeCommands.ParseModel(Player.Console, entityData[2]) ?? "humanoid";
230230
entity.World = entityData[4];
231-
World world = entity.WorldIn();
232-
if (entity.World == null) continue;
233231

234232
sbyte id;
235233
if (!sbyte.TryParse(entityData[3], out id)) id = NextFreeID(entity.World);
@@ -240,22 +238,15 @@ public static void OldLoad() {
240238
entity.Skin = entityData[1] ?? entity.Name;
241239
Position pos;
242240

241+
Position spawn = default(Position);
242+
World world = entity.WorldIn();
243+
if (world != null && world.map != null) spawn = world.map.Spawn;
243244

244-
if (!int.TryParse(entityData[5], out pos.X)) {
245-
pos.X = world.map.Spawn.X;
246-
}
247-
if (!int.TryParse(entityData[6], out pos.Y)) {
248-
pos.Y = world.map.Spawn.Y;
249-
}
250-
if (!int.TryParse(entityData[7], out pos.Z)) {
251-
pos.Z = world.map.Spawn.Z;
252-
}
253-
if (!byte.TryParse(entityData[8], out pos.L)) {
254-
pos.L = world.map.Spawn.L;
255-
}
256-
if (!byte.TryParse(entityData[9], out pos.R)) {
257-
pos.R = world.map.Spawn.R;
258-
}
245+
if (!int.TryParse(entityData[5], out pos.X)) pos.X = spawn.X;
246+
if (!int.TryParse(entityData[6], out pos.Y)) pos.Y = spawn.Y;
247+
if (!int.TryParse(entityData[7], out pos.Z)) pos.Z = spawn.Z;
248+
if (!byte.TryParse(entityData[8], out pos.L)) pos.L = spawn.L;
249+
if (!byte.TryParse(entityData[9], out pos.R)) pos.R = spawn.R;
259250

260251
entity.SetPos(pos);
261252
EntityList.Add(entity);

0 commit comments

Comments
 (0)