From 21745a6aa8c583210d66a813e0cd33dc9e1690dc Mon Sep 17 00:00:00 2001 From: TheManii Date: Fri, 8 Apr 2016 00:48:34 -0700 Subject: [PATCH] Added relative warps --- FFXIVClassic Map Server/CommandProcessor.cs | 217 +++++++++++------- .../Properties/Resources.Designer.cs | 5 +- .../Properties/Resources.resx | 2 + 3 files changed, 139 insertions(+), 85 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index d815467a..86c095d0 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -95,11 +95,11 @@ namespace FFXIVClassic_Lobby_Server } } - /// - /// Teleports player to a location on a predefined list - /// - /// The current player - /// Predefined list: <ffxiv_database>\server_zones_spawnlocations + /// + /// Teleports player to a location on a predefined list + /// + /// The current player + /// Predefined list: <ffxiv_database>\server_zones_spawnlocations public void doWarp(ConnectedPlayer client, string entranceId) { uint id; @@ -133,39 +133,39 @@ namespace FFXIVClassic_Lobby_Server public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz) { uint zoneId; - float x,y,z; - + float x,y,z; + x = Single.Parse(sx); y = Single.Parse(sy); z = Single.Parse(sz); - if (zone == null) - { - if (client != null) - mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, 0.0f); + if (zone == null) + { + if (client != null) + mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, 0.0f); } - else - { - if (zone.ToLower().StartsWith("0x")) - zoneId = Convert.ToUInt32(zone, 16); - else - zoneId = Convert.ToUInt32(zone); - - if (mWorldManager.GetZone(zoneId) == null) - { - if (client != null) - client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Zone does not exist or setting isn't valid."), true, false)); - Log.error("Zone does not exist or setting isn't valid."); - } - - if (client != null) - mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); - } + else + { + if (zone.ToLower().StartsWith("0x")) + zoneId = Convert.ToUInt32(zone, 16); + else + zoneId = Convert.ToUInt32(zone); + + if (mWorldManager.GetZone(zoneId) == null) + { + if (client != null) + client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Zone does not exist or setting isn't valid."), true, false)); + Log.error("Zone does not exist or setting isn't valid."); + } + + if (client != null) + mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); + } } } } @@ -351,6 +351,64 @@ namespace FFXIVClassic_Lobby_Server } } + private void parseWarp(ConnectedPlayer client, string[] split) + { + //bool relx = false, + // rely = false, + // relz = false; + float x = 0, + y = 0, + z = 0; + + if (split.Length == 2) // Predefined list + doWarp(client, split[1]); + else if (split.Length == 4) // X/Y/Z + { + #region relativewarp + if (split[1].StartsWith("@")) + { + //relx = true; + split[1] = split[1].Replace("@", string.Empty); + + if (String.IsNullOrEmpty(split[1])) + split[1] = "0"; + + x = Single.Parse(split[1]) + client.getActor().positionX; + split[1] = x.ToString(); + } + if (split[2].StartsWith("@")) + { + //rely = true; + split[2] = split[2].Replace("@", string.Empty); + + if (String.IsNullOrEmpty(split[2])) + split[2] = "0"; + + y = Single.Parse(split[2]) + client.getActor().positionY; + split[2] = y.ToString(); + } + if (split[3].StartsWith("@")) + { + //relz = true; + split[3] = split[3].Replace("@", string.Empty); + + if (String.IsNullOrEmpty(split[3])) + split[3] = "0"; + + z = Single.Parse(split[3]) + client.getActor().positionZ; + split[3] = z.ToString(); + } + #endregion + //sendMessage(client, String.Format("relx: {0}, rely: {1}, relz: {2}, x: {3}, y: {4}, z: {5}, fx: {6}, fy: {7}, fz: {8}", relx, rely, relz, split[1], split[2], split[3], x, y ,z)); + sendMessage(client, String.Format("Warping to: X: {0}, Y: {1}, Z: {2}", split[1], split[2], split[3])); + doWarp(client, null, null, split[1], split[2], split[3]); + } + else if (split.Length == 5) // Zone + X/Y/Z + doWarp(client, split[1], null, split[2], split[3], split[4]); + else if (split.Length == 6) // Zone + instance + X/Y/Z + doWarp(client, split[1], split[2], split[3], split[4], split[5]); + } + /// /// We only use the default options for SendMessagePacket. /// May as well make it less unwieldly to view @@ -370,11 +428,11 @@ namespace FFXIVClassic_Lobby_Server input = input.Substring(1); String[] split = input.Split(' '); - split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands - split = split.Where(temp => temp != "").ToArray(); // strips extra whitespace from commands - - // Debug - //sendMessage(client, string.Join(",", split)); + split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands + split = split.Where(temp => temp != "").ToArray(); // strips extra whitespace from commands + + // Debug + //sendMessage(client, string.Join(",", split)); if (split.Length >= 1) { @@ -422,9 +480,9 @@ namespace FFXIVClassic_Lobby_Server } return true; - } + } #endregion - + #region !mypos else if (split[0].Equals("mypos")) { @@ -437,9 +495,9 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not load packet: " + e); } - } + } #endregion - + #region !reloadzones else if (split[0].Equals("reloadzones")) { @@ -453,9 +511,9 @@ namespace FFXIVClassic_Lobby_Server } mWorldManager.reloadZone(client.getActor().zoneId); return true; - } + } #endregion - + #region !reloaditems else if (split[0].Equals("reloaditems")) { @@ -466,9 +524,9 @@ namespace FFXIVClassic_Lobby_Server Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); sendMessage(client, String.Format("Loaded {0} items.", gamedataItems.Count)); return true; - } + } #endregion - + #region !sendpacket else if (split[0].Equals("sendpacket")) { @@ -484,9 +542,9 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not load packet: " + e); } - } + } #endregion - + #region !graphic else if (split[0].Equals("graphic")) { @@ -500,9 +558,9 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not give item."); } - } + } #endregion - + #region !giveitem else if (split[0].Equals("giveitem")) { @@ -520,10 +578,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not give item."); } - } + } #endregion - - #region !removeitem + + #region !removeitem else if (split[0].Equals("removeitem")) { if (split.Length < 2) @@ -543,10 +601,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not remove item."); } - } + } #endregion - - #region !givekeyitem + + #region !givekeyitem else if (split[0].Equals("givekeyitem")) { try @@ -558,10 +616,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not give keyitem."); } - } + } #endregion - - #region !removekeyitem + + #region !removekeyitem else if (split[0].Equals("removekeyitem")) { if (split.Length < 2) @@ -577,10 +635,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not remove keyitem."); } - } + } #endregion - - #region !givecurrency + + #region !givecurrency else if (split[0].Equals("givecurrency")) { try @@ -594,10 +652,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not give currency."); } - } + } #endregion - - #region !removecurrency + + #region !removecurrency else if (split[0].Equals("removecurrency")) { if (split.Length < 2) @@ -615,9 +673,9 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not remove currency."); } - } + } #endregion - + #region !music else if (split[0].Equals("music")) { @@ -633,24 +691,17 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not change music: " + e); } - } + } #endregion - + #region !warp else if (split[0].Equals("warp")) - { - if (split.Length == 2) // Predefined list - doWarp(client, split[1]); - else if (split.Length == 4) // X/Y/Z - doWarp(client, null, null, split[1], split[2], split[3]); - else if (split.Length == 5) // Zone + X/Y/Z - doWarp(client, split[1], null, split[2], split[3], split[4]); - else if (split.Length == 6) // Zone + instance + X/Y/Z - doWarp(client, split[1], split[2], split[3], split[4], split[5]); + { + parseWarp(client, split); return true; - } + } #endregion - + #region !property else if (split[0].Equals("property")) { @@ -659,9 +710,9 @@ namespace FFXIVClassic_Lobby_Server changeProperty(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]); } return true; - } + } #endregion - + #region !property2 else if (split[0].Equals("property2")) { @@ -670,7 +721,7 @@ namespace FFXIVClassic_Lobby_Server changeProperty(Convert.ToUInt32(split[1], 16), Convert.ToUInt32(split[2], 16), split[3]); } return true; - } + } #endregion } return false; diff --git a/FFXIVClassic Map Server/Properties/Resources.Designer.cs b/FFXIVClassic Map Server/Properties/Resources.Designer.cs index cea7c949..3a6f068b 100644 --- a/FFXIVClassic Map Server/Properties/Resources.Designer.cs +++ b/FFXIVClassic Map Server/Properties/Resources.Designer.cs @@ -239,13 +239,14 @@ namespace FFXIVClassic_Map_Server.Properties { /// /// Looks up a localized string similar to Teleports the player to the specified location /// + ///*Note: You teleport relative to your current position by putting a @ in front of a value, cannot be combined with a zone id or instance name + /// ///*Syntax: warp <location list> /// warp <X coordinate> <Y coordinate> <Z coordinate> /// warp <zone id> <X coordinate> <Y coordinate> <Z coordinate> /// warp <zone id> <instance> <X coordinate> <Y coordinate> <Z coordinate> ///<location list> is a pre-defined list of locations from the server database - ///<zone id> is the zone's id as defined in the server database - ///<instance> is an instanced copy of the desired zone that's only visible to the current player. + ///<zone id> is the zon [rest of string was truncated]";. /// public static string CPwarp { get { diff --git a/FFXIVClassic Map Server/Properties/Resources.resx b/FFXIVClassic Map Server/Properties/Resources.resx index 71b54066..a038aae6 100644 --- a/FFXIVClassic Map Server/Properties/Resources.resx +++ b/FFXIVClassic Map Server/Properties/Resources.resx @@ -206,6 +206,8 @@ Server Administration: givecurrency, giveitem, givekeyitem, removecurrency, remo Teleports the player to the specified location +*Note: You teleport relative to your current position by putting a @ in front of a value, cannot be combined with a zone id or instance name + *Syntax: warp <location list> warp <X coordinate> <Y coordinate> <Z coordinate> warp <zone id> <X coordinate> <Y coordinate> <Z coordinate>