Skip to content

Commit

Permalink
and don't error if old entity is on a non-existent world
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Sep 5, 2017
1 parent 63f2198 commit a6ae7b2
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions fCraft/World/Entity.cs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ public static void OldLoad() {
string[] entityData = File.ReadAllLines(filename); string[] entityData = File.ReadAllLines(filename);
entity.Model = CpeCommands.ParseModel(Player.Console, entityData[2]) ?? "humanoid"; entity.Model = CpeCommands.ParseModel(Player.Console, entityData[2]) ?? "humanoid";
entity.World = entityData[4]; entity.World = entityData[4];
World world = entity.WorldIn();
if (entity.World == null) continue;


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


Position spawn = default(Position);
World world = entity.WorldIn();
if (world != null && world.map != null) spawn = world.map.Spawn;


if (!int.TryParse(entityData[5], out pos.X)) { if (!int.TryParse(entityData[5], out pos.X)) pos.X = spawn.X;
pos.X = world.map.Spawn.X; if (!int.TryParse(entityData[6], out pos.Y)) pos.Y = spawn.Y;
} if (!int.TryParse(entityData[7], out pos.Z)) pos.Z = spawn.Z;
if (!int.TryParse(entityData[6], out pos.Y)) { if (!byte.TryParse(entityData[8], out pos.L)) pos.L = spawn.L;
pos.Y = world.map.Spawn.Y; if (!byte.TryParse(entityData[9], out pos.R)) pos.R = spawn.R;
}
if (!int.TryParse(entityData[7], out pos.Z)) {
pos.Z = world.map.Spawn.Z;
}
if (!byte.TryParse(entityData[8], out pos.L)) {
pos.L = world.map.Spawn.L;
}
if (!byte.TryParse(entityData[9], out pos.R)) {
pos.R = world.map.Spawn.R;
}


entity.SetPos(pos); entity.SetPos(pos);
EntityList.Add(entity); EntityList.Add(entity);
Expand Down

0 comments on commit a6ae7b2

Please sign in to comment.