Skip to content

Commit 2c12179

Browse files
Fix doing /portal create with no X/Y/Z argument at all, spawning you at 0,0,0 instead of map spawn
1 parent f5f946e commit 2c12179

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

fCraft/Commands/WorldCommands.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3714,13 +3714,14 @@ static void PortalCreate(Player player, CommandReader cmd) {
37143714

37153715
string portalName = cmd.Next();
37163716
if (string.IsNullOrEmpty(portalName)) {
3717-
} else if (!Portal.DoesNameExist(player.World, portalName)) {
3717+
} else if (!Portal.Exists(player.World, portalName)) {
37183718
player.PortalName = portalName;
37193719
} else {
37203720
player.Message("A portal with name {0} already exists in this world.", portalName);
37213721
return;
37223722
}
37233723

3724+
player.PortalTPPos = world.map == null ? default(Position) : world.map.Spawn;
37243725
if (cmd.HasNext) {
37253726
int x, y, z, rot = player.Position.R, lot = player.Position.L;
37263727
string next = cmd.Next();
@@ -3754,8 +3755,6 @@ static void PortalCreate(Player player, CommandReader cmd) {
37543755
}
37553756
}
37563757
player.PortalTPPos = new Position(x * 32, y * 32, z * 32, (byte)rot, (byte)lot);
3757-
} else {
3758-
player.PortalTPPos = world.map == null ? new Position(0, 0, 0) : world.map.Spawn;
37593758
}
37603759
}
37613760

fCraft/Portals/Portal.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,11 @@ public static string GenerateName(World world) {
107107
return "portal1";
108108
}
109109

110-
public static bool DoesNameExist(World world, string name) {
110+
public static bool Exists(World world, string name) {
111111
if (world.Portals != null) {
112112
if (world.Portals.Count > 0) {
113113
foreach (Portal portal in world.Portals) {
114-
if (portal.Name.Equals(name)) {
115-
return true;
116-
}
114+
if (portal.Name.Equals(name)) return true;
117115
}
118116
}
119117
}

0 commit comments

Comments
 (0)