Skip to content

Commit

Permalink
Fix doing /portal create with no X/Y/Z argument at all, spawning you …
Browse files Browse the repository at this point in the history
…at 0,0,0 instead of map spawn
  • Loading branch information
UnknownShadow200 committed Sep 1, 2018
1 parent f5f946e commit 2c12179
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions fCraft/Commands/WorldCommands.cs
Expand Up @@ -3714,13 +3714,14 @@ static void WorldClearHandler(Player player, CommandReader cmd)

string portalName = cmd.Next();
if (string.IsNullOrEmpty(portalName)) {
} else if (!Portal.DoesNameExist(player.World, portalName)) {
} else if (!Portal.Exists(player.World, portalName)) {
player.PortalName = portalName;
} else {
player.Message("A portal with name {0} already exists in this world.", portalName);
return;
}

player.PortalTPPos = world.map == null ? default(Position) : world.map.Spawn;
if (cmd.HasNext) {
int x, y, z, rot = player.Position.R, lot = player.Position.L;
string next = cmd.Next();
Expand Down Expand Up @@ -3754,8 +3755,6 @@ static void WorldClearHandler(Player player, CommandReader cmd)
}
}
player.PortalTPPos = new Position(x * 32, y * 32, z * 32, (byte)rot, (byte)lot);
} else {
player.PortalTPPos = world.map == null ? new Position(0, 0, 0) : world.map.Spawn;
}
}

Expand Down
6 changes: 2 additions & 4 deletions fCraft/Portals/Portal.cs
Expand Up @@ -107,13 +107,11 @@ public class Portal {
return "portal1";
}

public static bool DoesNameExist(World world, string name) {
public static bool Exists(World world, string name) {
if (world.Portals != null) {
if (world.Portals.Count > 0) {
foreach (Portal portal in world.Portals) {
if (portal.Name.Equals(name)) {
return true;
}
if (portal.Name.Equals(name)) return true;
}
}
}
Expand Down

0 comments on commit 2c12179

Please sign in to comment.