From 7a8e53a8acd4ce9e0ed51b8883632f02fd238e47 Mon Sep 17 00:00:00 2001 From: TheManii Date: Tue, 5 Apr 2016 16:06:38 -0700 Subject: [PATCH 01/22] Add in ingame help system --- FFXIVClassic Map Server/Server.cs | 145 ++++++++++++++++++++++++++++-- 1 file changed, 137 insertions(+), 8 deletions(-) diff --git a/FFXIVClassic Map Server/Server.cs b/FFXIVClassic Map Server/Server.cs index c87f47a1..29b2d02c 100644 --- a/FFXIVClassic Map Server/Server.cs +++ b/FFXIVClassic Map Server/Server.cs @@ -460,14 +460,14 @@ namespace FFXIVClassic_Lobby_Server if (client != null) { Player p = client.getActor(); - client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Position: {1}, {2}, {3}, {4}", p.customDisplayName, p.positionX, p.positionY, p.positionZ, p.rotation)), true, false)); + client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)), true, false)); } else { foreach (KeyValuePair entry in mConnectedPlayerList) { Player p = entry.Value.getActor(); - Log.info(String.Format("{0} position: {1}, {2}, {3}, {4}", p.customDisplayName, p.positionX, p.positionY, p.positionZ, p.rotation)); + Log.info(String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)); } } } @@ -642,10 +642,139 @@ namespace FFXIVClassic_Lobby_Server input = input.Substring(1); String[] split = input.Split(' '); + split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands + + + // Debug +// if (client != null) +// client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", +// string.Join(",", split) +// )); if (split.Length >= 1) { - if (split[0].Equals("mypos")) + + if (split[0].Equals("help")) + { + if (split.Length == 1) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Use !help (command) for details\n\nAvailable commands:\nStandard: mypos, music, warp\nServer Administration: givecurrency, giveitem, givekeyitem, removecurrency, removekeyitem, reloaditems, resetzone\nDebug: property, property2, sendpacket, setgraphic" + )); + } + if (split.Length == 2) + { + if (split[1].Equals("mypos")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Prints out your current location\n\n*Note: The X/Y/Z coordinates do not correspond to the coordinates listed in the in-game map, they are based on the underlying game data" + )); + } + else if (split[1].Equals("music")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Changes the currently playing background music\n\n*Syntax: music \n is the key item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("warp")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Teleports the player to the specified location\n\n*Syntax:\twarp \n\twarp \n\twarp \n is a pre-defined list of locations from the server database\n is an instanced copy of the desired zone that's only visible to the current player" + )); + } + else if (split[1].Equals("givecurrency")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Adds the specified currency to the current player's inventory\n\n*Syntax:\tgivecurrency \n\tgivecurrency \n is the specific type of currency desired, defaults to gil if no type specified" + )); + } + else if (split[1].Equals("giveitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Adds the specified items to the current player's inventory\n\n*Syntax:\tgiveitem \n\tgiveitem \n\tgiveitem \n is the item's specific id as defined in the server database\n is the type as defined in the server database (defaults to gil if not specified)" + )); + } + else if (split[1].Equals("givekeyitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Adds the specified key item to the current player's inventory\n\n*Syntax: givekeyitem \n is the key item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("removecurrency")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Removes the specified currency from the current player's inventory\n\n*Syntax:\tremovecurrency \n\tremovecurrency \n is the specific type of currency desired, defaults to gil if no type specified" + )); + } + else if (split[1].Equals("removeitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Removes the specified items to the current player's inventory\n\n*Syntax:\tremoveitem \n\tremoveitem \n is the item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("removekeyitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Removes the specified key item to the current player's inventory\n\n*Syntax: removekeyitem \n is the key item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("reloaditems")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Reloads the current item data from the database" + )); + } + else if (split[1].Equals("resetzone")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Reloads the current zone data from the server files" + )); + } + else if (split[1].Equals("property")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "\n*Syntax: property " + )); + } + else if (split[1].Equals("property2")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "\n*Syntax: property2 " + )); + } + else if (split[1].Equals("sendpacket")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Server sends a special packet to the client\n\n*Syntax: sendpacket \n is the path to the packet, starting in \\packet" + )); + } + else if (split[1].Equals("setgraphic")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Overrides the currently displayed character equipment in a specific slot\n\n*Note: Similar to Glamours in FFXIV:ARR, the overridden graphics are purely cosmetic, they do not affect the underlying stats of whatever is equipped on that slot\n\n*Syntax: sendpacket \n are as defined in the client game data" + )); + } + } + + return true; + } + else if (split[0].Equals("mypos")) { try { @@ -665,7 +794,7 @@ namespace FFXIVClassic_Lobby_Server client.getActor().zone.clear(); client.getActor().zone.addActorToZone(client.getActor()); client.getActor().sendInstanceUpdate(); - client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Resting zone {0}...", client.getActor().zoneId)), true, false)); + client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Reseting zone {0}...", client.getActor().zoneId)), true, false)); } mWorldManager.reloadZone(client.getActor().zoneId); return true; @@ -775,7 +904,7 @@ namespace FFXIVClassic_Lobby_Server Log.error("Could not remove keyitem."); } } - else if (split[0].Equals("givecurrancy")) + else if (split[0].Equals("givecurrency")) { try { @@ -786,10 +915,10 @@ namespace FFXIVClassic_Lobby_Server } catch (Exception e) { - Log.error("Could not give currancy."); + Log.error("Could not give currency."); } } - else if (split[0].Equals("removecurrancy")) + else if (split[0].Equals("removecurrency")) { if (split.Length < 2) return false; @@ -804,7 +933,7 @@ namespace FFXIVClassic_Lobby_Server } catch (Exception e) { - Log.error("Could not remove currancy."); + Log.error("Could not remove currency."); } } else if (split[0].Equals("music")) From 1ef3e350c05b83a0882758c7ee34bbbbf9e5bca2 Mon Sep 17 00:00:00 2001 From: TheManii Date: Tue, 5 Apr 2016 16:13:16 -0700 Subject: [PATCH 02/22] Fix line endings --- FFXIVClassic Map Server/Server.cs | 34 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/FFXIVClassic Map Server/Server.cs b/FFXIVClassic Map Server/Server.cs index 29b2d02c..19b31f1d 100644 --- a/FFXIVClassic Map Server/Server.cs +++ b/FFXIVClassic Map Server/Server.cs @@ -664,113 +664,113 @@ namespace FFXIVClassic_Lobby_Server )); } if (split.Length == 2) - { + { if (split[1].Equals("mypos")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Prints out your current location\n\n*Note: The X/Y/Z coordinates do not correspond to the coordinates listed in the in-game map, they are based on the underlying game data" )); - } + } else if (split[1].Equals("music")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Changes the currently playing background music\n\n*Syntax: music \n is the key item's specific id as defined in the server database" )); - } + } else if (split[1].Equals("warp")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Teleports the player to the specified location\n\n*Syntax:\twarp \n\twarp \n\twarp \n is a pre-defined list of locations from the server database\n is an instanced copy of the desired zone that's only visible to the current player" )); - } + } else if (split[1].Equals("givecurrency")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Adds the specified currency to the current player's inventory\n\n*Syntax:\tgivecurrency \n\tgivecurrency \n is the specific type of currency desired, defaults to gil if no type specified" )); - } + } else if (split[1].Equals("giveitem")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Adds the specified items to the current player's inventory\n\n*Syntax:\tgiveitem \n\tgiveitem \n\tgiveitem \n is the item's specific id as defined in the server database\n is the type as defined in the server database (defaults to gil if not specified)" )); - } + } else if (split[1].Equals("givekeyitem")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Adds the specified key item to the current player's inventory\n\n*Syntax: givekeyitem \n is the key item's specific id as defined in the server database" )); - } + } else if (split[1].Equals("removecurrency")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Removes the specified currency from the current player's inventory\n\n*Syntax:\tremovecurrency \n\tremovecurrency \n is the specific type of currency desired, defaults to gil if no type specified" )); - } + } else if (split[1].Equals("removeitem")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Removes the specified items to the current player's inventory\n\n*Syntax:\tremoveitem \n\tremoveitem \n is the item's specific id as defined in the server database" )); - } + } else if (split[1].Equals("removekeyitem")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Removes the specified key item to the current player's inventory\n\n*Syntax: removekeyitem \n is the key item's specific id as defined in the server database" )); - } + } else if (split[1].Equals("reloaditems")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Reloads the current item data from the database" )); - } + } else if (split[1].Equals("resetzone")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Reloads the current zone data from the server files" )); - } + } else if (split[1].Equals("property")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "\n*Syntax: property " )); - } + } else if (split[1].Equals("property2")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "\n*Syntax: property2 " )); - } + } else if (split[1].Equals("sendpacket")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Server sends a special packet to the client\n\n*Syntax: sendpacket \n is the path to the packet, starting in \\packet" )); - } + } else if (split[1].Equals("setgraphic")) { if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Overrides the currently displayed character equipment in a specific slot\n\n*Note: Similar to Glamours in FFXIV:ARR, the overridden graphics are purely cosmetic, they do not affect the underlying stats of whatever is equipped on that slot\n\n*Syntax: sendpacket \n are as defined in the client game data" )); - } - } + } + } return true; } From cdcdd6a584e5ca6faa863bfef8db60283c6dcea0 Mon Sep 17 00:00:00 2001 From: TheManii Date: Wed, 6 Apr 2016 15:22:26 -0700 Subject: [PATCH 03/22] Split off ingame commands from server --- FFXIVClassic Map Server/CommandProcessor.cs | 682 ++++++++++++++++ .../FFXIVClassic Map Server.csproj | 1 + FFXIVClassic Map Server/PacketProcessor.cs | 4 +- FFXIVClassic Map Server/Program.cs | 3 +- FFXIVClassic Map Server/Server.cs | 749 ++---------------- 5 files changed, 744 insertions(+), 695 deletions(-) create mode 100644 FFXIVClassic Map Server/CommandProcessor.cs diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs new file mode 100644 index 00000000..f295eaf1 --- /dev/null +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -0,0 +1,682 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Net; +using System.Net.Sockets; +using System.Threading.Tasks; +using System.Threading; +using FFXIVClassic_Lobby_Server.common; +using FFXIVClassic_Map_Server.dataobjects; +using FFXIVClassic_Lobby_Server.packets; +using System.IO; +using FFXIVClassic_Map_Server.packets.send.actor; +using FFXIVClassic_Map_Server; +using FFXIVClassic_Map_Server.packets.send; +using FFXIVClassic_Map_Server.dataobjects.chara; +using FFXIVClassic_Map_Server.Actors; +using FFXIVClassic_Map_Server.lua; +using FFXIVClassic_Map_Server.actors.chara.player; + +namespace FFXIVClassic_Lobby_Server +{ + class CommandProcessor + { + private Dictionary mConnectedPlayerList; + private static WorldManager mWorldManager = Server.GetWorldManager(); + private static Dictionary gamedataItems = Server.GetGamedataItems(); + + public CommandProcessor(Dictionary playerList) + { + mConnectedPlayerList = playerList; + } + + public void sendPacket(ConnectedPlayer client, string path) + { + BasePacket packet = new BasePacket(path); + + if (client != null) + { + packet.replaceActorID(client.actorID); + client.queuePacket(packet); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + packet.replaceActorID(entry.Value.actorID); + entry.Value.queuePacket(packet); + } + } + } + + public void changeProperty(uint id, uint value, string target) + { + SetActorPropetyPacket changeProperty = new SetActorPropetyPacket(target); + + changeProperty.setTarget(target); + changeProperty.addInt(id, value); + changeProperty.addTarget(); + + foreach (KeyValuePair entry in mConnectedPlayerList) + { + SubPacket changePropertyPacket = changeProperty.buildPacket((entry.Value.actorID), (entry.Value.actorID)); + + BasePacket packet = BasePacket.createPacket(changePropertyPacket, true, false); + packet.debugPrintPacket(); + + entry.Value.queuePacket(packet); + } + } + + public void doMusic(ConnectedPlayer client, string music) + { + ushort musicId; + + if (music.ToLower().StartsWith("0x")) + musicId = Convert.ToUInt16(music, 16); + else + musicId = Convert.ToUInt16(music); + + if (client != null) + client.queuePacket(BasePacket.createPacket(SetMusicPacket.buildPacket(client.actorID, musicId, 1), true, false)); + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + BasePacket musicPacket = BasePacket.createPacket(SetMusicPacket.buildPacket(entry.Value.actorID, musicId, 1), true, false); + entry.Value.queuePacket(musicPacket); + } + } + } + + public void doWarp(ConnectedPlayer client, string entranceId) + { + uint id; + + try + { + if (entranceId.ToLower().StartsWith("0x")) + id = Convert.ToUInt32(entranceId, 16); + else + id = Convert.ToUInt32(entranceId); + } + catch(FormatException e) + {return;} + + FFXIVClassic_Map_Server.WorldManager.ZoneEntrance ze = mWorldManager.getZoneEntrance(id); + + if (ze == null) + return; + + if (client != null) + mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); + } + } + } + + public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz) + { + uint zoneId; + float x,y,z; + + 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."); + } + + x = Single.Parse(sx); + y = Single.Parse(sy); + z = Single.Parse(sz); + + 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); + } + } + } + + public void printPos(ConnectedPlayer client) + { + if (client != null) + { + Player p = client.getActor(); + client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)), true, false)); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + Log.info(String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)); + } + } + } + + private void setGraphic(ConnectedPlayer client, uint slot, uint wId, uint eId, uint vId, uint cId) + { + if (client != null) + { + Player p = client.getActor(); + p.graphicChange(slot, wId, eId, vId, cId); + p.sendAppearance(); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.graphicChange(slot, wId, eId, vId, cId); + p.sendAppearance(); + } + } + } + + private void giveItem(ConnectedPlayer client, uint itemId, int quantity) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.NORMAL).addItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.NORMAL).addItem(itemId, quantity); + } + } + } + + private void giveItem(ConnectedPlayer client, uint itemId, int quantity, ushort type) + { + if (client != null) + { + Player p = client.getActor(); + + if (p.getInventory(type) != null) + p.getInventory(type).addItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + + if (p.getInventory(type) != null) + p.getInventory(type).addItem(itemId, quantity); + } + } + } + + private void removeItem(ConnectedPlayer client, uint itemId, int quantity) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.NORMAL).removeItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.NORMAL).removeItem(itemId, quantity); + } + } + } + + private void removeItem(ConnectedPlayer client, uint itemId, int quantity, ushort type) + { + if (client != null) + { + Player p = client.getActor(); + + if (p.getInventory(type) != null) + p.getInventory(type).removeItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + + if (p.getInventory(type) != null) + p.getInventory(type).removeItem(itemId, quantity); + } + } + } + + private void giveCurrancy(ConnectedPlayer client, uint itemId, int quantity) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.CURRANCY).addItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.CURRANCY).addItem(itemId, quantity); + } + } + } + + private void removeCurrancy(ConnectedPlayer client, uint itemId, int quantity) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.CURRANCY).removeItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.CURRANCY).removeItem(itemId, quantity); + } + } + } + + private void giveKeyItem(ConnectedPlayer client, uint itemId) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.KEYITEMS).addItem(itemId, 1); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.KEYITEMS).addItem(itemId, 1); + } + } + } + + private void removeKeyItem(ConnectedPlayer client, uint itemId) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.KEYITEMS).removeItem(itemId, 1); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.KEYITEMS).removeItem(itemId, 1); + } + } + } + + internal bool doCommand(string input, ConnectedPlayer client) + { + input.Trim(); + if (input.StartsWith("!")) + input = input.Substring(1); + + String[] split = input.Split(' '); + split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands + + + // Debug + // if (client != null) + // client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + // string.Join(",", split) + // )); + + if (split.Length >= 1) + { + + if (split[0].Equals("help")) + { + if (split.Length == 1) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Use !help (command) for details\n\nAvailable commands:\nStandard: mypos, music, warp\nServer Administration: givecurrency, giveitem, givekeyitem, removecurrency, removekeyitem, reloaditems, resetzone\nDebug: property, property2, sendpacket, setgraphic" + )); + } + if (split.Length == 2) + { + if (split[1].Equals("mypos")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Prints out your current location\n\n*Note: The X/Y/Z coordinates do not correspond to the coordinates listed in the in-game map, they are based on the underlying game data" + )); + } + else if (split[1].Equals("music")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Changes the currently playing background music\n\n*Syntax: music \n is the key item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("warp")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Teleports the player to the specified location\n\n*Syntax:\twarp \n\twarp \n\twarp \n is a pre-defined list of locations from the server database\n is an instanced copy of the desired zone that's only visible to the current player" + )); + } + else if (split[1].Equals("givecurrency")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Adds the specified currency to the current player's inventory\n\n*Syntax:\tgivecurrency \n\tgivecurrency \n is the specific type of currency desired, defaults to gil if no type specified" + )); + } + else if (split[1].Equals("giveitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Adds the specified items to the current player's inventory\n\n*Syntax:\tgiveitem \n\tgiveitem \n\tgiveitem \n is the item's specific id as defined in the server database\n is the type as defined in the server database (defaults to gil if not specified)" + )); + } + else if (split[1].Equals("givekeyitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Adds the specified key item to the current player's inventory\n\n*Syntax: givekeyitem \n is the key item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("removecurrency")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Removes the specified currency from the current player's inventory\n\n*Syntax:\tremovecurrency \n\tremovecurrency \n is the specific type of currency desired, defaults to gil if no type specified" + )); + } + else if (split[1].Equals("removeitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Removes the specified items to the current player's inventory\n\n*Syntax:\tremoveitem \n\tremoveitem \n is the item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("removekeyitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Removes the specified key item to the current player's inventory\n\n*Syntax: removekeyitem \n is the key item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("reloaditems")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Reloads the current item data from the database" + )); + } + else if (split[1].Equals("resetzone")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Reloads the current zone data from the server files" + )); + } + else if (split[1].Equals("property")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "\n*Syntax: property " + )); + } + else if (split[1].Equals("property2")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "\n*Syntax: property2 " + )); + } + else if (split[1].Equals("sendpacket")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Server sends a special packet to the client\n\n*Syntax: sendpacket \n is the path to the packet, starting in \\packet" + )); + } + else if (split[1].Equals("setgraphic")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Overrides the currently displayed character equipment in a specific slot\n\n*Note: Similar to Glamours in FFXIV:ARR, the overridden graphics are purely cosmetic, they do not affect the underlying stats of whatever is equipped on that slot\n\n*Syntax: sendpacket \n are as defined in the client game data" + )); + } + } + + return true; + } + else if (split[0].Equals("mypos")) + { + try + { + printPos(client); + return true; + } + catch (Exception e) + { + Log.error("Could not load packet: " + e); + } + } + else if (split[0].Equals("resetzone")) + { + if (client != null) + { + Log.info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId)); + client.getActor().zone.clear(); + client.getActor().zone.addActorToZone(client.getActor()); + client.getActor().sendInstanceUpdate(); + client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Reseting zone {0}...", client.getActor().zoneId)), true, false)); + } + mWorldManager.reloadZone(client.getActor().zoneId); + return true; + } + else if (split[0].Equals("reloaditems")) + { + Log.info(String.Format("Got request to reload item gamedata")); + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Reloading Item Gamedata...")); + gamedataItems.Clear(); + gamedataItems = Database.getItemGamedata(); + Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Loaded {0} items.", gamedataItems.Count))); + return true; + } + else if (split[0].Equals("sendpacket")) + { + if (split.Length < 2) + return false; + + try + { + sendPacket(client, "./packets/" + split[1]); + return true; + } + catch (Exception e) + { + Log.error("Could not load packet: " + e); + } + } + else if (split[0].Equals("graphic")) + { + try + { + if (split.Length == 6) + setGraphic(client, UInt32.Parse(split[1]), UInt32.Parse(split[2]), UInt32.Parse(split[3]), UInt32.Parse(split[4]), UInt32.Parse(split[5])); + return true; + } + catch (Exception e) + { + Log.error("Could not give item."); + } + } + else if (split[0].Equals("giveitem")) + { + try + { + if (split.Length == 2) + giveItem(client, UInt32.Parse(split[1]), 1); + else if (split.Length == 3) + giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); + else if (split.Length == 4) + giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3])); + return true; + } + catch (Exception e) + { + Log.error("Could not give item."); + } + } + else if (split[0].Equals("removeitem")) + { + if (split.Length < 2) + return false; + + try + { + if (split.Length == 2) + removeItem(client, UInt32.Parse(split[1]), 1); + else if (split.Length == 3) + removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); + else if (split.Length == 4) + removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3])); + return true; + } + catch (Exception e) + { + Log.error("Could not remove item."); + } + } + else if (split[0].Equals("givekeyitem")) + { + try + { + if (split.Length == 2) + giveKeyItem(client, UInt32.Parse(split[1])); + } + catch (Exception e) + { + Log.error("Could not give keyitem."); + } + } + else if (split[0].Equals("removekeyitem")) + { + if (split.Length < 2) + return false; + + try + { + if (split.Length == 2) + removeKeyItem(client, UInt32.Parse(split[1])); + return true; + } + catch (Exception e) + { + Log.error("Could not remove keyitem."); + } + } + else if (split[0].Equals("givecurrency")) + { + try + { + if (split.Length == 2) + giveCurrancy(client, UInt32.Parse(split[1]), 1); + else if (split.Length == 3) + giveCurrancy(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); + } + catch (Exception e) + { + Log.error("Could not give currency."); + } + } + else if (split[0].Equals("removecurrency")) + { + if (split.Length < 2) + return false; + + try + { + if (split.Length == 2) + removeCurrancy(client, UInt32.Parse(split[1]), 1); + else if (split.Length == 3) + removeCurrancy(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); + return true; + } + catch (Exception e) + { + Log.error("Could not remove currency."); + } + } + else if (split[0].Equals("music")) + { + if (split.Length < 2) + return false; + + try + { + doMusic(client, split[1]); + return true; + } + catch (Exception e) + { + Log.error("Could not change music: " + e); + } + } + else if (split[0].Equals("warp")) + { + if (split.Length == 2) + doWarp(client, split[1]); + else if (split.Length == 5) + doWarp(client, split[1], null, split[2], split[3], split[4]); + else if (split.Length == 6) + doWarp(client, split[1], split[2], split[3], split[4], split[5]); + return true; + } + else if (split[0].Equals("property")) + { + if (split.Length == 4) + { + changeProperty(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]); + } + return true; + } + else if (split[0].Equals("property2")) + { + if (split.Length == 4) + { + changeProperty(Convert.ToUInt32(split[1], 16), Convert.ToUInt32(split[2], 16), split[3]); + } + return true; + } + } + return false; + } + } + +} diff --git a/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj b/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj index 80affaef..c5ac86aa 100644 --- a/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj +++ b/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj @@ -79,6 +79,7 @@ + diff --git a/FFXIVClassic Map Server/PacketProcessor.cs b/FFXIVClassic Map Server/PacketProcessor.cs index 8d1cd62b..5d04595e 100644 --- a/FFXIVClassic Map Server/PacketProcessor.cs +++ b/FFXIVClassic Map Server/PacketProcessor.cs @@ -39,6 +39,7 @@ namespace FFXIVClassic_Lobby_Server class PacketProcessor { Server mServer; + CommandProcessor cp; Dictionary mPlayers; List mConnections; @@ -47,6 +48,7 @@ namespace FFXIVClassic_Lobby_Server mPlayers = playerList; mConnections = connectionList; mServer = server; + cp = new CommandProcessor(playerList); } public void processPacket(ClientConnection client, BasePacket packet) @@ -198,7 +200,7 @@ namespace FFXIVClassic_Lobby_Server if (chatMessage.message.StartsWith("!")) { - if (mServer.doCommand(chatMessage.message, player)) + if (cp.doCommand(chatMessage.message, player)) continue; } diff --git a/FFXIVClassic Map Server/Program.cs b/FFXIVClassic Map Server/Program.cs index 5c9cc061..cf73ad7d 100644 --- a/FFXIVClassic Map Server/Program.cs +++ b/FFXIVClassic Map Server/Program.cs @@ -68,12 +68,13 @@ namespace FFXIVClassic_Lobby_Server if (startServer) { Server server = new Server(); + CommandProcessor cp = new CommandProcessor(server.GetConnectedPlayerList()); server.startServer(); while (true) { String input = Console.ReadLine(); - server.doCommand(input, null); + cp.doCommand(input, null); } } diff --git a/FFXIVClassic Map Server/Server.cs b/FFXIVClassic Map Server/Server.cs index 19b31f1d..d90eb8ff 100644 --- a/FFXIVClassic Map Server/Server.cs +++ b/FFXIVClassic Map Server/Server.cs @@ -22,9 +22,9 @@ namespace FFXIVClassic_Lobby_Server { class Server { - public const int FFXIV_MAP_PORT = 54992; - public const int BUFFER_SIZE = 0xFFFF; //Max basepacket size is 0xFFFF - public const int BACKLOG = 100; + public const int FFXIV_MAP_PORT = 54992; + public const int BUFFER_SIZE = 0xFFFF; //Max basepacket size is 0xFFFF + public const int BACKLOG = 100; public const int HEALTH_THREAD_SLEEP_TIME = 5; public const string STATIC_ACTORS_PATH = "./staticactors.bin"; @@ -33,7 +33,7 @@ namespace FFXIVClassic_Lobby_Server private Socket mServerSocket; - private Dictionary mConnectedPlayerList = new Dictionary(); + private Dictionary mConnectedPlayerList = new Dictionary(); private List mConnectionList = new List(); private LuaEngine mLuaEngine = new LuaEngine(); @@ -83,10 +83,10 @@ namespace FFXIVClassic_Lobby_Server mConnectionHealthThread.Name = "MapThread:Health"; //mConnectionHealthThread.Start(); - mStaticActors = new StaticActors(STATIC_ACTORS_PATH); - + mStaticActors = new StaticActors(STATIC_ACTORS_PATH); + gamedataItems = Database.getItemGamedata(); - Log.info(String.Format("Loaded {0} items.",gamedataItems.Count)); + Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); mWorldManager = new WorldManager(this); mWorldManager.LoadZoneList(); @@ -95,8 +95,9 @@ namespace FFXIVClassic_Lobby_Server IPEndPoint serverEndPoint = new System.Net.IPEndPoint(IPAddress.Parse(ConfigConstants.OPTIONS_BINDIP), FFXIV_MAP_PORT); - try{ - mServerSocket = new System.Net.Sockets.Socket(serverEndPoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + try + { + mServerSocket = new System.Net.Sockets.Socket(serverEndPoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); } catch (Exception e) { @@ -145,8 +146,8 @@ namespace FFXIVClassic_Lobby_Server private void acceptCallback(IAsyncResult result) { ClientConnection conn = null; - Socket socket = (System.Net.Sockets.Socket)result.AsyncState; - + Socket socket = (System.Net.Sockets.Socket)result.AsyncState; + try { @@ -168,8 +169,8 @@ namespace FFXIVClassic_Lobby_Server catch (SocketException) { if (conn != null) - { - + { + lock (mConnectionList) { mConnectionList.Remove(conn); @@ -180,7 +181,7 @@ namespace FFXIVClassic_Lobby_Server catch (Exception) { if (conn != null) - { + { lock (mConnectionList) { mConnectionList.Remove(conn); @@ -224,7 +225,7 @@ namespace FFXIVClassic_Lobby_Server lock (mConnectionList) { mConnectionList.Remove(conn); - } + } if (conn.connType == BasePacket.TYPE_ZONE) Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); return; @@ -241,37 +242,37 @@ namespace FFXIVClassic_Lobby_Server int offset = 0; //Build packets until can no longer or out of data - while(true) - { - BasePacket basePacket = buildPacket(ref offset, conn.buffer, bytesRead); - - //If can't build packet, break, else process another - if (basePacket == null) - break; - else - mProcessor.processPacket(conn, basePacket); - } - - //Not all bytes consumed, transfer leftover to beginning + while (true) + { + BasePacket basePacket = buildPacket(ref offset, conn.buffer, bytesRead); + + //If can't build packet, break, else process another + if (basePacket == null) + break; + else + mProcessor.processPacket(conn, basePacket); + } + + //Not all bytes consumed, transfer leftover to beginning if (offset < bytesRead) Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset); conn.lastPartialSize = bytesRead - offset; //Build any queued subpackets into basepackets and send - conn.flushQueuedSendPackets(); - - if (offset < bytesRead) - //Need offset since not all bytes consumed + conn.flushQueuedSendPackets(); + + if (offset < bytesRead) + //Need offset since not all bytes consumed conn.socket.BeginReceive(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset), SocketFlags.None, new AsyncCallback(receiveCallback), conn); - else - //All bytes consumed, full buffer available + else + //All bytes consumed, full buffer available conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn); } else { - Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); - + Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); + lock (mConnectionList) { mConnectionList.Remove(conn); @@ -279,15 +280,15 @@ namespace FFXIVClassic_Lobby_Server } } catch (SocketException) - { + { if (conn.socket != null) { - Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); - + Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); + lock (mConnectionList) { mConnectionList.Remove(conn); - } + } } } } @@ -325,661 +326,23 @@ namespace FFXIVClassic_Lobby_Server } return newPacket; - } - + } + #endregion - - public void sendPacket(ConnectedPlayer client, string path) - { - BasePacket packet = new BasePacket(path); - - if (client != null) - { - packet.replaceActorID(client.actorID); - client.queuePacket(packet); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - packet.replaceActorID(entry.Value.actorID); - entry.Value.queuePacket(packet); - } - } + + public static WorldManager GetWorldManager() + { + return mWorldManager; } - public void changeProperty(uint id, uint value, string target) - { - SetActorPropetyPacket changeProperty = new SetActorPropetyPacket(target); - - changeProperty.setTarget(target); - changeProperty.addInt(id, value); - changeProperty.addTarget(); - - foreach (KeyValuePair entry in mConnectedPlayerList) - { - SubPacket changePropertyPacket = changeProperty.buildPacket((entry.Value.actorID), (entry.Value.actorID)); - - BasePacket packet = BasePacket.createPacket(changePropertyPacket, true, false); - packet.debugPrintPacket(); - - entry.Value.queuePacket(packet); - } - } - - public void doMusic(ConnectedPlayer client, string music) - { - ushort musicId; - - if (music.ToLower().StartsWith("0x")) - musicId = Convert.ToUInt16(music, 16); - else - musicId = Convert.ToUInt16(music); - - if (client != null) - client.queuePacket(BasePacket.createPacket(SetMusicPacket.buildPacket(client.actorID, musicId, 1), true, false)); - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - BasePacket musicPacket = BasePacket.createPacket(SetMusicPacket.buildPacket(entry.Value.actorID, musicId, 1), true, false); - entry.Value.queuePacket(musicPacket); - } - } - } - - public void doWarp(ConnectedPlayer client, string entranceId) - { - uint id; - - try - { - if (entranceId.ToLower().StartsWith("0x")) - id = Convert.ToUInt32(entranceId, 16); - else - id = Convert.ToUInt32(entranceId); - } - catch(FormatException e) - {return;} - - FFXIVClassic_Map_Server.WorldManager.ZoneEntrance ze = mWorldManager.getZoneEntrance(id); - - if (ze == null) - return; - - if (client != null) - mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); - } - } - } - - public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz) - { - uint zoneId; - float x,y,z; - - 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."); - } - - x = Single.Parse(sx); - y = Single.Parse(sy); - z = Single.Parse(sz); - - 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); - } - } - } - - public static WorldManager GetWorldManager() - { - return mWorldManager; - } - - public void printPos(ConnectedPlayer client) - { - if (client != null) - { - Player p = client.getActor(); - client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)), true, false)); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - Log.info(String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)); - } - } - } - - private void setGraphic(ConnectedPlayer client, uint slot, uint wId, uint eId, uint vId, uint cId) - { - if (client != null) - { - Player p = client.getActor(); - p.graphicChange(slot, wId, eId, vId, cId); - p.sendAppearance(); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.graphicChange(slot, wId, eId, vId, cId); - p.sendAppearance(); - } - } - } - - private void giveItem(ConnectedPlayer client, uint itemId, int quantity) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.NORMAL).addItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.NORMAL).addItem(itemId, quantity); - } - } - } - - private void giveItem(ConnectedPlayer client, uint itemId, int quantity, ushort type) - { - if (client != null) - { - Player p = client.getActor(); - - if (p.getInventory(type) != null) - p.getInventory(type).addItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - - if (p.getInventory(type) != null) - p.getInventory(type).addItem(itemId, quantity); - } - } - } - - private void removeItem(ConnectedPlayer client, uint itemId, int quantity) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.NORMAL).removeItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.NORMAL).removeItem(itemId, quantity); - } - } - } - - private void removeItem(ConnectedPlayer client, uint itemId, int quantity, ushort type) - { - if (client != null) - { - Player p = client.getActor(); - - if (p.getInventory(type) != null) - p.getInventory(type).removeItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - - if (p.getInventory(type) != null) - p.getInventory(type).removeItem(itemId, quantity); - } - } - } - - private void giveCurrancy(ConnectedPlayer client, uint itemId, int quantity) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.CURRANCY).addItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.CURRANCY).addItem(itemId, quantity); - } - } - } - - private void removeCurrancy(ConnectedPlayer client, uint itemId, int quantity) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.CURRANCY).removeItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.CURRANCY).removeItem(itemId, quantity); - } - } - } - - private void giveKeyItem(ConnectedPlayer client, uint itemId) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.KEYITEMS).addItem(itemId, 1); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.KEYITEMS).addItem(itemId, 1); - } - } - } - - private void removeKeyItem(ConnectedPlayer client, uint itemId) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.KEYITEMS).removeItem(itemId, 1); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.KEYITEMS).removeItem(itemId, 1); - } - } - } - - internal bool doCommand(string input, ConnectedPlayer client) - { - input.Trim(); - if (input.StartsWith("!")) - input = input.Substring(1); - - String[] split = input.Split(' '); - split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands - - - // Debug -// if (client != null) -// client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", -// string.Join(",", split) -// )); - - if (split.Length >= 1) - { - - if (split[0].Equals("help")) - { - if (split.Length == 1) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Use !help (command) for details\n\nAvailable commands:\nStandard: mypos, music, warp\nServer Administration: givecurrency, giveitem, givekeyitem, removecurrency, removekeyitem, reloaditems, resetzone\nDebug: property, property2, sendpacket, setgraphic" - )); - } - if (split.Length == 2) - { - if (split[1].Equals("mypos")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Prints out your current location\n\n*Note: The X/Y/Z coordinates do not correspond to the coordinates listed in the in-game map, they are based on the underlying game data" - )); - } - else if (split[1].Equals("music")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Changes the currently playing background music\n\n*Syntax: music \n is the key item's specific id as defined in the server database" - )); - } - else if (split[1].Equals("warp")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Teleports the player to the specified location\n\n*Syntax:\twarp \n\twarp \n\twarp \n is a pre-defined list of locations from the server database\n is an instanced copy of the desired zone that's only visible to the current player" - )); - } - else if (split[1].Equals("givecurrency")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Adds the specified currency to the current player's inventory\n\n*Syntax:\tgivecurrency \n\tgivecurrency \n is the specific type of currency desired, defaults to gil if no type specified" - )); - } - else if (split[1].Equals("giveitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Adds the specified items to the current player's inventory\n\n*Syntax:\tgiveitem \n\tgiveitem \n\tgiveitem \n is the item's specific id as defined in the server database\n is the type as defined in the server database (defaults to gil if not specified)" - )); - } - else if (split[1].Equals("givekeyitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Adds the specified key item to the current player's inventory\n\n*Syntax: givekeyitem \n is the key item's specific id as defined in the server database" - )); - } - else if (split[1].Equals("removecurrency")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Removes the specified currency from the current player's inventory\n\n*Syntax:\tremovecurrency \n\tremovecurrency \n is the specific type of currency desired, defaults to gil if no type specified" - )); - } - else if (split[1].Equals("removeitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Removes the specified items to the current player's inventory\n\n*Syntax:\tremoveitem \n\tremoveitem \n is the item's specific id as defined in the server database" - )); - } - else if (split[1].Equals("removekeyitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Removes the specified key item to the current player's inventory\n\n*Syntax: removekeyitem \n is the key item's specific id as defined in the server database" - )); - } - else if (split[1].Equals("reloaditems")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Reloads the current item data from the database" - )); - } - else if (split[1].Equals("resetzone")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Reloads the current zone data from the server files" - )); - } - else if (split[1].Equals("property")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "\n*Syntax: property " - )); - } - else if (split[1].Equals("property2")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "\n*Syntax: property2 " - )); - } - else if (split[1].Equals("sendpacket")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Server sends a special packet to the client\n\n*Syntax: sendpacket \n is the path to the packet, starting in \\packet" - )); - } - else if (split[1].Equals("setgraphic")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Overrides the currently displayed character equipment in a specific slot\n\n*Note: Similar to Glamours in FFXIV:ARR, the overridden graphics are purely cosmetic, they do not affect the underlying stats of whatever is equipped on that slot\n\n*Syntax: sendpacket \n are as defined in the client game data" - )); - } - } - - return true; - } - else if (split[0].Equals("mypos")) - { - try - { - printPos(client); - return true; - } - catch (Exception e) - { - Log.error("Could not load packet: " + e); - } - } - else if (split[0].Equals("resetzone")) - { - if (client != null) - { - Log.info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId)); - client.getActor().zone.clear(); - client.getActor().zone.addActorToZone(client.getActor()); - client.getActor().sendInstanceUpdate(); - client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Reseting zone {0}...", client.getActor().zoneId)), true, false)); - } - mWorldManager.reloadZone(client.getActor().zoneId); - return true; - } - else if (split[0].Equals("reloaditems")) - { - Log.info(String.Format("Got request to reload item gamedata")); - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Reloading Item Gamedata...")); - gamedataItems.Clear(); - gamedataItems = Database.getItemGamedata(); - Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Loaded {0} items.", gamedataItems.Count))); - return true; - } - else if (split[0].Equals("sendpacket")) - { - if (split.Length < 2) - return false; - - try - { - sendPacket(client, "./packets/" + split[1]); - return true; - } - catch (Exception e) - { - Log.error("Could not load packet: " + e); - } - } - else if (split[0].Equals("graphic")) - { - try - { - if (split.Length == 6) - setGraphic(client, UInt32.Parse(split[1]), UInt32.Parse(split[2]), UInt32.Parse(split[3]), UInt32.Parse(split[4]), UInt32.Parse(split[5])); - return true; - } - catch (Exception e) - { - Log.error("Could not give item."); - } - } - else if (split[0].Equals("giveitem")) - { - try - { - if (split.Length == 2) - giveItem(client, UInt32.Parse(split[1]), 1); - else if (split.Length == 3) - giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); - else if (split.Length == 4) - giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3])); - return true; - } - catch (Exception e) - { - Log.error("Could not give item."); - } - } - else if (split[0].Equals("removeitem")) - { - if (split.Length < 2) - return false; - - try - { - if (split.Length == 2) - removeItem(client, UInt32.Parse(split[1]), 1); - else if (split.Length == 3) - removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); - else if (split.Length == 4) - removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3])); - return true; - } - catch (Exception e) - { - Log.error("Could not remove item."); - } - } - else if (split[0].Equals("givekeyitem")) - { - try - { - if (split.Length == 2) - giveKeyItem(client, UInt32.Parse(split[1])); - } - catch (Exception e) - { - Log.error("Could not give keyitem."); - } - } - else if (split[0].Equals("removekeyitem")) - { - if (split.Length < 2) - return false; - - try - { - if (split.Length == 2) - removeKeyItem(client, UInt32.Parse(split[1])); - return true; - } - catch (Exception e) - { - Log.error("Could not remove keyitem."); - } - } - else if (split[0].Equals("givecurrency")) - { - try - { - if (split.Length == 2) - giveCurrancy(client, UInt32.Parse(split[1]), 1); - else if (split.Length == 3) - giveCurrancy(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); - } - catch (Exception e) - { - Log.error("Could not give currency."); - } - } - else if (split[0].Equals("removecurrency")) - { - if (split.Length < 2) - return false; - - try - { - if (split.Length == 2) - removeCurrancy(client, UInt32.Parse(split[1]), 1); - else if (split.Length == 3) - removeCurrancy(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); - return true; - } - catch (Exception e) - { - Log.error("Could not remove currency."); - } - } - else if (split[0].Equals("music")) - { - if (split.Length < 2) - return false; - - try - { - doMusic(client, split[1]); - return true; - } - catch (Exception e) - { - Log.error("Could not change music: " + e); - } - } - else if (split[0].Equals("warp")) - { - if (split.Length == 2) - doWarp(client, split[1]); - else if (split.Length == 5) - doWarp(client, split[1], null, split[2], split[3], split[4]); - else if (split.Length == 6) - doWarp(client, split[1], split[2], split[3], split[4], split[5]); - return true; - } - else if (split[0].Equals("property")) - { - if (split.Length == 4) - { - changeProperty(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]); - } - return true; - } - else if (split[0].Equals("property2")) - { - if (split.Length == 4) - { - changeProperty(Convert.ToUInt32(split[1], 16), Convert.ToUInt32(split[2], 16), split[3]); - } - return true; - } - } - return false; - } + public Dictionary GetConnectedPlayerList() + { + return mConnectedPlayerList; + } + + public static Dictionary GetGamedataItems() + { + return gamedataItems; + } } - -} +} \ No newline at end of file From ea1e16aea7b345fda0d31c46cc436fa52298c8e0 Mon Sep 17 00:00:00 2001 From: TheManii Date: Wed, 6 Apr 2016 15:29:24 -0700 Subject: [PATCH 04/22] Make Getters more case consistant --- FFXIVClassic Map Server/CommandProcessor.cs | 4 ++-- FFXIVClassic Map Server/PacketProcessor.cs | 6 +++--- FFXIVClassic Map Server/Program.cs | 2 +- FFXIVClassic Map Server/Server.cs | 6 +++--- .../actors/chara/npc/Npc.cs | 2 +- .../actors/chara/player/Player.cs | 16 ++++++++-------- FFXIVClassic Map Server/lua/LuaEngine.cs | 18 +++++++++--------- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index f295eaf1..6ed3edae 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -23,8 +23,8 @@ namespace FFXIVClassic_Lobby_Server class CommandProcessor { private Dictionary mConnectedPlayerList; - private static WorldManager mWorldManager = Server.GetWorldManager(); - private static Dictionary gamedataItems = Server.GetGamedataItems(); + private static WorldManager mWorldManager = Server.getWorldManager(); + private static Dictionary gamedataItems = Server.getItemGamedataList(); public CommandProcessor(Dictionary playerList) { diff --git a/FFXIVClassic Map Server/PacketProcessor.cs b/FFXIVClassic Map Server/PacketProcessor.cs index 5d04595e..9f922c55 100644 --- a/FFXIVClassic Map Server/PacketProcessor.cs +++ b/FFXIVClassic Map Server/PacketProcessor.cs @@ -188,7 +188,7 @@ namespace FFXIVClassic_Lobby_Server subpacket.debugPrintSubPacket(); client.queuePacket(_0x2Packet.buildPacket(player.actorID), true, false); - Server.GetWorldManager().DoLogin(player.getActor()); + Server.getWorldManager().DoLogin(player.getActor()); break; @@ -267,7 +267,7 @@ namespace FFXIVClassic_Lobby_Server if (ownerActor == null) { //Is it a instance actor? - ownerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); + ownerActor = Server.getWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); if (ownerActor == null) { //Is it a Director? @@ -298,7 +298,7 @@ namespace FFXIVClassic_Lobby_Server Actor updateOwnerActor = Server.getStaticActors(player.getActor().eventCurrentOwner); if (updateOwnerActor == null) { - updateOwnerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); + updateOwnerActor = Server.getWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); if (player.getActor().currentDirector != null && player.getActor().eventCurrentOwner == player.getActor().currentDirector.actorId) updateOwnerActor = player.getActor().currentDirector; diff --git a/FFXIVClassic Map Server/Program.cs b/FFXIVClassic Map Server/Program.cs index cf73ad7d..4790bc0f 100644 --- a/FFXIVClassic Map Server/Program.cs +++ b/FFXIVClassic Map Server/Program.cs @@ -68,7 +68,7 @@ namespace FFXIVClassic_Lobby_Server if (startServer) { Server server = new Server(); - CommandProcessor cp = new CommandProcessor(server.GetConnectedPlayerList()); + CommandProcessor cp = new CommandProcessor(server.getConnectedPlayerList()); server.startServer(); while (true) diff --git a/FFXIVClassic Map Server/Server.cs b/FFXIVClassic Map Server/Server.cs index d90eb8ff..206de92f 100644 --- a/FFXIVClassic Map Server/Server.cs +++ b/FFXIVClassic Map Server/Server.cs @@ -330,17 +330,17 @@ namespace FFXIVClassic_Lobby_Server #endregion - public static WorldManager GetWorldManager() + public static WorldManager getWorldManager() { return mWorldManager; } - public Dictionary GetConnectedPlayerList() + public Dictionary getConnectedPlayerList() { return mConnectedPlayerList; } - public static Dictionary GetGamedataItems() + public static Dictionary getItemGamedataList() { return gamedataItems; } diff --git a/FFXIVClassic Map Server/actors/chara/npc/Npc.cs b/FFXIVClassic Map Server/actors/chara/npc/Npc.cs index 9e43c677..e78444cf 100644 --- a/FFXIVClassic Map Server/actors/chara/npc/Npc.cs +++ b/FFXIVClassic Map Server/actors/chara/npc/Npc.cs @@ -49,7 +49,7 @@ namespace FFXIVClassic_Map_Server.Actors { List lParams; - Player player = Server.GetWorldManager().GetPCInWorld(playerActorId); + Player player = Server.getWorldManager().GetPCInWorld(playerActorId); lParams = LuaEngine.doActorOnInstantiate(player, this); if (lParams == null) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index 9ef1b188..7cb10eed 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -702,34 +702,34 @@ namespace FFXIVClassic_Map_Server.Actors { if (msgParams.Length == 0) { - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); } else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, string customSender, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, uint displayId, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); } public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams) diff --git a/FFXIVClassic Map Server/lua/LuaEngine.cs b/FFXIVClassic Map Server/lua/LuaEngine.cs index a9d18ee5..27631503 100644 --- a/FFXIVClassic Map Server/lua/LuaEngine.cs +++ b/FFXIVClassic Map Server/lua/LuaEngine.cs @@ -43,7 +43,7 @@ namespace FFXIVClassic_Map_Server.lua Script script = new Script(); ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; script.Globals["getStaticActor"] = (Func)Server.getStaticActors; - script.Globals["getWorldMaster"] = (Func)Server.GetWorldManager().GetActor; + script.Globals["getWorldMaster"] = (Func)Server.getWorldManager().GetActor; script.Globals["getItemGamedata"] = (Func)Server.getItemGamedata; script.DoFile(luaPath); DynValue result = script.Call(script.Globals["onInstantiate"], target); @@ -82,9 +82,9 @@ namespace FFXIVClassic_Map_Server.lua { Script script = new Script(); ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; - script.Globals["getWorldManager"] = (Func)Server.GetWorldManager; + script.Globals["getWorldManager"] = (Func)Server.getWorldManager; script.Globals["getStaticActor"] = (Func)Server.getStaticActors; - script.Globals["getWorldMaster"] = (Func)Server.GetWorldManager().GetActor; + script.Globals["getWorldMaster"] = (Func)Server.getWorldManager().GetActor; script.Globals["getItemGamedata"] = (Func)Server.getItemGamedata; script.DoFile(luaPath); @@ -125,9 +125,9 @@ namespace FFXIVClassic_Map_Server.lua { Script script = new Script(); ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; - script.Globals["getWorldManager"] = (Func)Server.GetWorldManager; + script.Globals["getWorldManager"] = (Func)Server.getWorldManager; script.Globals["getStaticActor"] = (Func)Server.getStaticActors; - script.Globals["getWorldMaster"] = (Func)Server.GetWorldManager().GetActor; + script.Globals["getWorldMaster"] = (Func)Server.getWorldManager().GetActor; script.Globals["getItemGamedata"] = (Func)Server.getItemGamedata; script.DoFile(luaPath); @@ -158,9 +158,9 @@ namespace FFXIVClassic_Map_Server.lua { Script script = new Script(); ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; - script.Globals["getWorldManager"] = (Func)Server.GetWorldManager; + script.Globals["getWorldManager"] = (Func)Server.getWorldManager; script.Globals["getStaticActor"] = (Func)Server.getStaticActors; - script.Globals["getWorldMaster"] = (Func)Server.GetWorldManager().GetActor; + script.Globals["getWorldMaster"] = (Func)Server.getWorldManager().GetActor; script.Globals["getItemGamedata"] = (Func)Server.getItemGamedata; script.DoFile(luaPath); @@ -175,9 +175,9 @@ namespace FFXIVClassic_Map_Server.lua { Script script = new Script(); ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; - script.Globals["getWorldManager"] = (Func)Server.GetWorldManager; + script.Globals["getWorldManager"] = (Func)Server.getWorldManager; script.Globals["getStaticActor"] = (Func)Server.getStaticActors; - script.Globals["getWorldMaster"] = (Func)Server.GetWorldManager().GetActor; + script.Globals["getWorldMaster"] = (Func)Server.getWorldManager().GetActor; script.Globals["getItemGamedata"] = (Func)Server.getItemGamedata; script.DoFile(FILEPATH_PLAYER); From 26f5e1be28d61f2763828f523ad464a4ab7bac1a Mon Sep 17 00:00:00 2001 From: TheManii Date: Wed, 6 Apr 2016 15:34:04 -0700 Subject: [PATCH 05/22] Fix spelling --- FFXIVClassic Map Server/CommandProcessor.cs | 1326 ++++++++--------- FFXIVClassic Map Server/Database.cs | 2 +- .../actors/chara/player/Inventory.cs | 8 +- .../actors/chara/player/Player.cs | 6 +- 4 files changed, 671 insertions(+), 671 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index 6ed3edae..c48e57c5 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -16,667 +16,667 @@ using FFXIVClassic_Map_Server.packets.send; using FFXIVClassic_Map_Server.dataobjects.chara; using FFXIVClassic_Map_Server.Actors; using FFXIVClassic_Map_Server.lua; -using FFXIVClassic_Map_Server.actors.chara.player; - -namespace FFXIVClassic_Lobby_Server -{ - class CommandProcessor - { - private Dictionary mConnectedPlayerList; - private static WorldManager mWorldManager = Server.getWorldManager(); - private static Dictionary gamedataItems = Server.getItemGamedataList(); - - public CommandProcessor(Dictionary playerList) - { - mConnectedPlayerList = playerList; - } - - public void sendPacket(ConnectedPlayer client, string path) - { - BasePacket packet = new BasePacket(path); - - if (client != null) - { - packet.replaceActorID(client.actorID); - client.queuePacket(packet); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - packet.replaceActorID(entry.Value.actorID); - entry.Value.queuePacket(packet); - } - } - } - - public void changeProperty(uint id, uint value, string target) - { - SetActorPropetyPacket changeProperty = new SetActorPropetyPacket(target); - - changeProperty.setTarget(target); - changeProperty.addInt(id, value); - changeProperty.addTarget(); - - foreach (KeyValuePair entry in mConnectedPlayerList) - { - SubPacket changePropertyPacket = changeProperty.buildPacket((entry.Value.actorID), (entry.Value.actorID)); - - BasePacket packet = BasePacket.createPacket(changePropertyPacket, true, false); - packet.debugPrintPacket(); - - entry.Value.queuePacket(packet); - } - } - - public void doMusic(ConnectedPlayer client, string music) - { - ushort musicId; - - if (music.ToLower().StartsWith("0x")) - musicId = Convert.ToUInt16(music, 16); - else - musicId = Convert.ToUInt16(music); - - if (client != null) - client.queuePacket(BasePacket.createPacket(SetMusicPacket.buildPacket(client.actorID, musicId, 1), true, false)); - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - BasePacket musicPacket = BasePacket.createPacket(SetMusicPacket.buildPacket(entry.Value.actorID, musicId, 1), true, false); - entry.Value.queuePacket(musicPacket); - } - } - } - - public void doWarp(ConnectedPlayer client, string entranceId) - { - uint id; - - try - { - if (entranceId.ToLower().StartsWith("0x")) - id = Convert.ToUInt32(entranceId, 16); - else - id = Convert.ToUInt32(entranceId); - } +using FFXIVClassic_Map_Server.actors.chara.player; + +namespace FFXIVClassic_Lobby_Server +{ + class CommandProcessor + { + private Dictionary mConnectedPlayerList; + private static WorldManager mWorldManager = Server.getWorldManager(); + private static Dictionary gamedataItems = Server.getItemGamedataList(); + + public CommandProcessor(Dictionary playerList) + { + mConnectedPlayerList = playerList; + } + + public void sendPacket(ConnectedPlayer client, string path) + { + BasePacket packet = new BasePacket(path); + + if (client != null) + { + packet.replaceActorID(client.actorID); + client.queuePacket(packet); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + packet.replaceActorID(entry.Value.actorID); + entry.Value.queuePacket(packet); + } + } + } + + public void changeProperty(uint id, uint value, string target) + { + SetActorPropetyPacket changeProperty = new SetActorPropetyPacket(target); + + changeProperty.setTarget(target); + changeProperty.addInt(id, value); + changeProperty.addTarget(); + + foreach (KeyValuePair entry in mConnectedPlayerList) + { + SubPacket changePropertyPacket = changeProperty.buildPacket((entry.Value.actorID), (entry.Value.actorID)); + + BasePacket packet = BasePacket.createPacket(changePropertyPacket, true, false); + packet.debugPrintPacket(); + + entry.Value.queuePacket(packet); + } + } + + public void doMusic(ConnectedPlayer client, string music) + { + ushort musicId; + + if (music.ToLower().StartsWith("0x")) + musicId = Convert.ToUInt16(music, 16); + else + musicId = Convert.ToUInt16(music); + + if (client != null) + client.queuePacket(BasePacket.createPacket(SetMusicPacket.buildPacket(client.actorID, musicId, 1), true, false)); + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + BasePacket musicPacket = BasePacket.createPacket(SetMusicPacket.buildPacket(entry.Value.actorID, musicId, 1), true, false); + entry.Value.queuePacket(musicPacket); + } + } + } + + public void doWarp(ConnectedPlayer client, string entranceId) + { + uint id; + + try + { + if (entranceId.ToLower().StartsWith("0x")) + id = Convert.ToUInt32(entranceId, 16); + else + id = Convert.ToUInt32(entranceId); + } catch(FormatException e) - {return;} - - FFXIVClassic_Map_Server.WorldManager.ZoneEntrance ze = mWorldManager.getZoneEntrance(id); - - if (ze == null) - return; - - if (client != null) - mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); - } - } - } - - public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz) - { - uint zoneId; - float x,y,z; - - 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."); - } - - x = Single.Parse(sx); - y = Single.Parse(sy); - z = Single.Parse(sz); - - 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); - } - } - } - - public void printPos(ConnectedPlayer client) - { - if (client != null) - { - Player p = client.getActor(); - client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)), true, false)); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - Log.info(String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)); - } - } - } - - private void setGraphic(ConnectedPlayer client, uint slot, uint wId, uint eId, uint vId, uint cId) - { - if (client != null) - { - Player p = client.getActor(); - p.graphicChange(slot, wId, eId, vId, cId); - p.sendAppearance(); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.graphicChange(slot, wId, eId, vId, cId); - p.sendAppearance(); - } - } - } - - private void giveItem(ConnectedPlayer client, uint itemId, int quantity) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.NORMAL).addItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.NORMAL).addItem(itemId, quantity); - } - } - } - - private void giveItem(ConnectedPlayer client, uint itemId, int quantity, ushort type) - { - if (client != null) - { - Player p = client.getActor(); - - if (p.getInventory(type) != null) - p.getInventory(type).addItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - - if (p.getInventory(type) != null) - p.getInventory(type).addItem(itemId, quantity); - } - } - } - - private void removeItem(ConnectedPlayer client, uint itemId, int quantity) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.NORMAL).removeItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.NORMAL).removeItem(itemId, quantity); - } - } - } - - private void removeItem(ConnectedPlayer client, uint itemId, int quantity, ushort type) - { - if (client != null) - { - Player p = client.getActor(); - - if (p.getInventory(type) != null) - p.getInventory(type).removeItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - - if (p.getInventory(type) != null) - p.getInventory(type).removeItem(itemId, quantity); - } - } - } - - private void giveCurrancy(ConnectedPlayer client, uint itemId, int quantity) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.CURRANCY).addItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.CURRANCY).addItem(itemId, quantity); - } - } - } - - private void removeCurrancy(ConnectedPlayer client, uint itemId, int quantity) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.CURRANCY).removeItem(itemId, quantity); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.CURRANCY).removeItem(itemId, quantity); - } - } - } - - private void giveKeyItem(ConnectedPlayer client, uint itemId) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.KEYITEMS).addItem(itemId, 1); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.KEYITEMS).addItem(itemId, 1); - } - } - } - - private void removeKeyItem(ConnectedPlayer client, uint itemId) - { - if (client != null) - { - Player p = client.getActor(); - p.getInventory(Inventory.KEYITEMS).removeItem(itemId, 1); - } - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - Player p = entry.Value.getActor(); - p.getInventory(Inventory.KEYITEMS).removeItem(itemId, 1); - } - } - } - - internal bool doCommand(string input, ConnectedPlayer client) - { - input.Trim(); - if (input.StartsWith("!")) - input = input.Substring(1); - - String[] split = input.Split(' '); - split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands - - - // Debug - // if (client != null) - // client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - // string.Join(",", split) - // )); - - if (split.Length >= 1) - { - - if (split[0].Equals("help")) - { - if (split.Length == 1) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Use !help (command) for details\n\nAvailable commands:\nStandard: mypos, music, warp\nServer Administration: givecurrency, giveitem, givekeyitem, removecurrency, removekeyitem, reloaditems, resetzone\nDebug: property, property2, sendpacket, setgraphic" - )); - } - if (split.Length == 2) - { - if (split[1].Equals("mypos")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Prints out your current location\n\n*Note: The X/Y/Z coordinates do not correspond to the coordinates listed in the in-game map, they are based on the underlying game data" - )); - } - else if (split[1].Equals("music")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Changes the currently playing background music\n\n*Syntax: music \n is the key item's specific id as defined in the server database" - )); - } - else if (split[1].Equals("warp")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Teleports the player to the specified location\n\n*Syntax:\twarp \n\twarp \n\twarp \n is a pre-defined list of locations from the server database\n is an instanced copy of the desired zone that's only visible to the current player" - )); - } - else if (split[1].Equals("givecurrency")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Adds the specified currency to the current player's inventory\n\n*Syntax:\tgivecurrency \n\tgivecurrency \n is the specific type of currency desired, defaults to gil if no type specified" - )); - } - else if (split[1].Equals("giveitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Adds the specified items to the current player's inventory\n\n*Syntax:\tgiveitem \n\tgiveitem \n\tgiveitem \n is the item's specific id as defined in the server database\n is the type as defined in the server database (defaults to gil if not specified)" - )); - } - else if (split[1].Equals("givekeyitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Adds the specified key item to the current player's inventory\n\n*Syntax: givekeyitem \n is the key item's specific id as defined in the server database" - )); - } - else if (split[1].Equals("removecurrency")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Removes the specified currency from the current player's inventory\n\n*Syntax:\tremovecurrency \n\tremovecurrency \n is the specific type of currency desired, defaults to gil if no type specified" - )); - } - else if (split[1].Equals("removeitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Removes the specified items to the current player's inventory\n\n*Syntax:\tremoveitem \n\tremoveitem \n is the item's specific id as defined in the server database" - )); - } - else if (split[1].Equals("removekeyitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Removes the specified key item to the current player's inventory\n\n*Syntax: removekeyitem \n is the key item's specific id as defined in the server database" - )); - } - else if (split[1].Equals("reloaditems")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Reloads the current item data from the database" - )); - } - else if (split[1].Equals("resetzone")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Reloads the current zone data from the server files" - )); - } - else if (split[1].Equals("property")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "\n*Syntax: property " - )); - } - else if (split[1].Equals("property2")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "\n*Syntax: property2 " - )); - } - else if (split[1].Equals("sendpacket")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Server sends a special packet to the client\n\n*Syntax: sendpacket \n is the path to the packet, starting in \\packet" - )); - } - else if (split[1].Equals("setgraphic")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Overrides the currently displayed character equipment in a specific slot\n\n*Note: Similar to Glamours in FFXIV:ARR, the overridden graphics are purely cosmetic, they do not affect the underlying stats of whatever is equipped on that slot\n\n*Syntax: sendpacket \n are as defined in the client game data" - )); - } - } - - return true; - } - else if (split[0].Equals("mypos")) - { - try - { - printPos(client); - return true; - } - catch (Exception e) - { - Log.error("Could not load packet: " + e); - } - } - else if (split[0].Equals("resetzone")) - { - if (client != null) - { - Log.info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId)); - client.getActor().zone.clear(); - client.getActor().zone.addActorToZone(client.getActor()); - client.getActor().sendInstanceUpdate(); - client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Reseting zone {0}...", client.getActor().zoneId)), true, false)); - } - mWorldManager.reloadZone(client.getActor().zoneId); - return true; - } - else if (split[0].Equals("reloaditems")) - { - Log.info(String.Format("Got request to reload item gamedata")); - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Reloading Item Gamedata...")); - gamedataItems.Clear(); - gamedataItems = Database.getItemGamedata(); - Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Loaded {0} items.", gamedataItems.Count))); - return true; - } - else if (split[0].Equals("sendpacket")) - { - if (split.Length < 2) - return false; - - try - { - sendPacket(client, "./packets/" + split[1]); - return true; - } - catch (Exception e) - { - Log.error("Could not load packet: " + e); - } - } - else if (split[0].Equals("graphic")) - { - try - { - if (split.Length == 6) - setGraphic(client, UInt32.Parse(split[1]), UInt32.Parse(split[2]), UInt32.Parse(split[3]), UInt32.Parse(split[4]), UInt32.Parse(split[5])); - return true; - } - catch (Exception e) - { - Log.error("Could not give item."); - } - } - else if (split[0].Equals("giveitem")) - { - try - { - if (split.Length == 2) - giveItem(client, UInt32.Parse(split[1]), 1); - else if (split.Length == 3) - giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); - else if (split.Length == 4) - giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3])); - return true; - } - catch (Exception e) - { - Log.error("Could not give item."); - } - } - else if (split[0].Equals("removeitem")) - { - if (split.Length < 2) - return false; - - try - { - if (split.Length == 2) - removeItem(client, UInt32.Parse(split[1]), 1); - else if (split.Length == 3) - removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); - else if (split.Length == 4) - removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3])); - return true; - } - catch (Exception e) - { - Log.error("Could not remove item."); - } - } - else if (split[0].Equals("givekeyitem")) - { - try - { - if (split.Length == 2) - giveKeyItem(client, UInt32.Parse(split[1])); - } - catch (Exception e) - { - Log.error("Could not give keyitem."); - } - } - else if (split[0].Equals("removekeyitem")) - { - if (split.Length < 2) - return false; - - try - { - if (split.Length == 2) - removeKeyItem(client, UInt32.Parse(split[1])); - return true; - } - catch (Exception e) - { - Log.error("Could not remove keyitem."); - } - } - else if (split[0].Equals("givecurrency")) - { - try - { - if (split.Length == 2) - giveCurrancy(client, UInt32.Parse(split[1]), 1); - else if (split.Length == 3) - giveCurrancy(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); - } - catch (Exception e) - { - Log.error("Could not give currency."); - } - } - else if (split[0].Equals("removecurrency")) - { - if (split.Length < 2) - return false; - - try - { - if (split.Length == 2) - removeCurrancy(client, UInt32.Parse(split[1]), 1); - else if (split.Length == 3) - removeCurrancy(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); - return true; - } - catch (Exception e) - { - Log.error("Could not remove currency."); - } - } - else if (split[0].Equals("music")) - { - if (split.Length < 2) - return false; - - try - { - doMusic(client, split[1]); - return true; - } - catch (Exception e) - { - Log.error("Could not change music: " + e); - } - } - else if (split[0].Equals("warp")) - { - if (split.Length == 2) - doWarp(client, split[1]); - else if (split.Length == 5) - doWarp(client, split[1], null, split[2], split[3], split[4]); - else if (split.Length == 6) - doWarp(client, split[1], split[2], split[3], split[4], split[5]); - return true; - } - else if (split[0].Equals("property")) - { - if (split.Length == 4) - { - changeProperty(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]); - } - return true; - } - else if (split[0].Equals("property2")) - { - if (split.Length == 4) - { - changeProperty(Convert.ToUInt32(split[1], 16), Convert.ToUInt32(split[2], 16), split[3]); - } - return true; - } - } - return false; - } - } - -} + {return;} + + FFXIVClassic_Map_Server.WorldManager.ZoneEntrance ze = mWorldManager.getZoneEntrance(id); + + if (ze == null) + return; + + if (client != null) + mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); + } + } + } + + public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz) + { + uint zoneId; + float x,y,z; + + 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."); + } + + x = Single.Parse(sx); + y = Single.Parse(sy); + z = Single.Parse(sz); + + 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); + } + } + } + + public void printPos(ConnectedPlayer client) + { + if (client != null) + { + Player p = client.getActor(); + client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)), true, false)); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + Log.info(String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)); + } + } + } + + private void setGraphic(ConnectedPlayer client, uint slot, uint wId, uint eId, uint vId, uint cId) + { + if (client != null) + { + Player p = client.getActor(); + p.graphicChange(slot, wId, eId, vId, cId); + p.sendAppearance(); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.graphicChange(slot, wId, eId, vId, cId); + p.sendAppearance(); + } + } + } + + private void giveItem(ConnectedPlayer client, uint itemId, int quantity) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.NORMAL).addItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.NORMAL).addItem(itemId, quantity); + } + } + } + + private void giveItem(ConnectedPlayer client, uint itemId, int quantity, ushort type) + { + if (client != null) + { + Player p = client.getActor(); + + if (p.getInventory(type) != null) + p.getInventory(type).addItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + + if (p.getInventory(type) != null) + p.getInventory(type).addItem(itemId, quantity); + } + } + } + + private void removeItem(ConnectedPlayer client, uint itemId, int quantity) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.NORMAL).removeItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.NORMAL).removeItem(itemId, quantity); + } + } + } + + private void removeItem(ConnectedPlayer client, uint itemId, int quantity, ushort type) + { + if (client != null) + { + Player p = client.getActor(); + + if (p.getInventory(type) != null) + p.getInventory(type).removeItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + + if (p.getInventory(type) != null) + p.getInventory(type).removeItem(itemId, quantity); + } + } + } + + private void giveCurrency(ConnectedPlayer client, uint itemId, int quantity) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.CURRENCY).addItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.CURRENCY).addItem(itemId, quantity); + } + } + } + + private void removeCurrency(ConnectedPlayer client, uint itemId, int quantity) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.CURRENCY).removeItem(itemId, quantity); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.CURRENCY).removeItem(itemId, quantity); + } + } + } + + private void giveKeyItem(ConnectedPlayer client, uint itemId) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.KEYITEMS).addItem(itemId, 1); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.KEYITEMS).addItem(itemId, 1); + } + } + } + + private void removeKeyItem(ConnectedPlayer client, uint itemId) + { + if (client != null) + { + Player p = client.getActor(); + p.getInventory(Inventory.KEYITEMS).removeItem(itemId, 1); + } + else + { + foreach (KeyValuePair entry in mConnectedPlayerList) + { + Player p = entry.Value.getActor(); + p.getInventory(Inventory.KEYITEMS).removeItem(itemId, 1); + } + } + } + + internal bool doCommand(string input, ConnectedPlayer client) + { + input.Trim(); + if (input.StartsWith("!")) + input = input.Substring(1); + + String[] split = input.Split(' '); + split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands + + + // Debug + // if (client != null) + // client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + // string.Join(",", split) + // )); + + if (split.Length >= 1) + { + + if (split[0].Equals("help")) + { + if (split.Length == 1) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Use !help (command) for details\n\nAvailable commands:\nStandard: mypos, music, warp\nServer Administration: givecurrency, giveitem, givekeyitem, removecurrency, removekeyitem, reloaditems, resetzone\nDebug: property, property2, sendpacket, setgraphic" + )); + } + if (split.Length == 2) + { + if (split[1].Equals("mypos")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Prints out your current location\n\n*Note: The X/Y/Z coordinates do not correspond to the coordinates listed in the in-game map, they are based on the underlying game data" + )); + } + else if (split[1].Equals("music")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Changes the currently playing background music\n\n*Syntax: music \n is the key item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("warp")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Teleports the player to the specified location\n\n*Syntax:\twarp \n\twarp \n\twarp \n is a pre-defined list of locations from the server database\n is an instanced copy of the desired zone that's only visible to the current player" + )); + } + else if (split[1].Equals("givecurrency")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Adds the specified currency to the current player's inventory\n\n*Syntax:\tgivecurrency \n\tgivecurrency \n is the specific type of currency desired, defaults to gil if no type specified" + )); + } + else if (split[1].Equals("giveitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Adds the specified items to the current player's inventory\n\n*Syntax:\tgiveitem \n\tgiveitem \n\tgiveitem \n is the item's specific id as defined in the server database\n is the type as defined in the server database (defaults to gil if not specified)" + )); + } + else if (split[1].Equals("givekeyitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Adds the specified key item to the current player's inventory\n\n*Syntax: givekeyitem \n is the key item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("removecurrency")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Removes the specified currency from the current player's inventory\n\n*Syntax:\tremovecurrency \n\tremovecurrency \n is the specific type of currency desired, defaults to gil if no type specified" + )); + } + else if (split[1].Equals("removeitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Removes the specified items to the current player's inventory\n\n*Syntax:\tremoveitem \n\tremoveitem \n is the item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("removekeyitem")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Removes the specified key item to the current player's inventory\n\n*Syntax: removekeyitem \n is the key item's specific id as defined in the server database" + )); + } + else if (split[1].Equals("reloaditems")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Reloads the current item data from the database" + )); + } + else if (split[1].Equals("resetzone")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Reloads the current zone data from the server files" + )); + } + else if (split[1].Equals("property")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "\n*Syntax: property " + )); + } + else if (split[1].Equals("property2")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "\n*Syntax: property2 " + )); + } + else if (split[1].Equals("sendpacket")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Server sends a special packet to the client\n\n*Syntax: sendpacket \n is the path to the packet, starting in \\packet" + )); + } + else if (split[1].Equals("setgraphic")) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", + "Overrides the currently displayed character equipment in a specific slot\n\n*Note: Similar to Glamours in FFXIV:ARR, the overridden graphics are purely cosmetic, they do not affect the underlying stats of whatever is equipped on that slot\n\n*Syntax: sendpacket \n are as defined in the client game data" + )); + } + } + + return true; + } + else if (split[0].Equals("mypos")) + { + try + { + printPos(client); + return true; + } + catch (Exception e) + { + Log.error("Could not load packet: " + e); + } + } + else if (split[0].Equals("resetzone")) + { + if (client != null) + { + Log.info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId)); + client.getActor().zone.clear(); + client.getActor().zone.addActorToZone(client.getActor()); + client.getActor().sendInstanceUpdate(); + client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Reseting zone {0}...", client.getActor().zoneId)), true, false)); + } + mWorldManager.reloadZone(client.getActor().zoneId); + return true; + } + else if (split[0].Equals("reloaditems")) + { + Log.info(String.Format("Got request to reload item gamedata")); + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Reloading Item Gamedata...")); + gamedataItems.Clear(); + gamedataItems = Database.getItemGamedata(); + Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Loaded {0} items.", gamedataItems.Count))); + return true; + } + else if (split[0].Equals("sendpacket")) + { + if (split.Length < 2) + return false; + + try + { + sendPacket(client, "./packets/" + split[1]); + return true; + } + catch (Exception e) + { + Log.error("Could not load packet: " + e); + } + } + else if (split[0].Equals("graphic")) + { + try + { + if (split.Length == 6) + setGraphic(client, UInt32.Parse(split[1]), UInt32.Parse(split[2]), UInt32.Parse(split[3]), UInt32.Parse(split[4]), UInt32.Parse(split[5])); + return true; + } + catch (Exception e) + { + Log.error("Could not give item."); + } + } + else if (split[0].Equals("giveitem")) + { + try + { + if (split.Length == 2) + giveItem(client, UInt32.Parse(split[1]), 1); + else if (split.Length == 3) + giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); + else if (split.Length == 4) + giveItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3])); + return true; + } + catch (Exception e) + { + Log.error("Could not give item."); + } + } + else if (split[0].Equals("removeitem")) + { + if (split.Length < 2) + return false; + + try + { + if (split.Length == 2) + removeItem(client, UInt32.Parse(split[1]), 1); + else if (split.Length == 3) + removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); + else if (split.Length == 4) + removeItem(client, UInt32.Parse(split[1]), Int32.Parse(split[2]), UInt16.Parse(split[3])); + return true; + } + catch (Exception e) + { + Log.error("Could not remove item."); + } + } + else if (split[0].Equals("givekeyitem")) + { + try + { + if (split.Length == 2) + giveKeyItem(client, UInt32.Parse(split[1])); + } + catch (Exception e) + { + Log.error("Could not give keyitem."); + } + } + else if (split[0].Equals("removekeyitem")) + { + if (split.Length < 2) + return false; + + try + { + if (split.Length == 2) + removeKeyItem(client, UInt32.Parse(split[1])); + return true; + } + catch (Exception e) + { + Log.error("Could not remove keyitem."); + } + } + else if (split[0].Equals("givecurrency")) + { + try + { + if (split.Length == 2) + giveCurrency(client, UInt32.Parse(split[1]), 1); + else if (split.Length == 3) + giveCurrency(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); + } + catch (Exception e) + { + Log.error("Could not give currency."); + } + } + else if (split[0].Equals("removecurrency")) + { + if (split.Length < 2) + return false; + + try + { + if (split.Length == 2) + removeCurrency(client, UInt32.Parse(split[1]), 1); + else if (split.Length == 3) + removeCurrency(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); + return true; + } + catch (Exception e) + { + Log.error("Could not remove currency."); + } + } + else if (split[0].Equals("music")) + { + if (split.Length < 2) + return false; + + try + { + doMusic(client, split[1]); + return true; + } + catch (Exception e) + { + Log.error("Could not change music: " + e); + } + } + else if (split[0].Equals("warp")) + { + if (split.Length == 2) + doWarp(client, split[1]); + else if (split.Length == 5) + doWarp(client, split[1], null, split[2], split[3], split[4]); + else if (split.Length == 6) + doWarp(client, split[1], split[2], split[3], split[4], split[5]); + return true; + } + else if (split[0].Equals("property")) + { + if (split.Length == 4) + { + changeProperty(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]); + } + return true; + } + else if (split[0].Equals("property2")) + { + if (split.Length == 4) + { + changeProperty(Convert.ToUInt32(split[1], 16), Convert.ToUInt32(split[2], 16), split[3]); + } + return true; + } + } + return false; + } + } + +} diff --git a/FFXIVClassic Map Server/Database.cs b/FFXIVClassic Map Server/Database.cs index 06a03b1e..3f114e1c 100644 --- a/FFXIVClassic Map Server/Database.cs +++ b/FFXIVClassic Map Server/Database.cs @@ -708,7 +708,7 @@ namespace FFXIVClassic_Lobby_Server player.getInventory(Inventory.NORMAL).initList(getInventory(player, 0, Inventory.NORMAL)); player.getInventory(Inventory.KEYITEMS).initList(getInventory(player, 0, Inventory.KEYITEMS)); - player.getInventory(Inventory.CURRANCY).initList(getInventory(player, 0, Inventory.CURRANCY)); + player.getInventory(Inventory.CURRENCY).initList(getInventory(player, 0, Inventory.CURRENCY)); player.getInventory(Inventory.BAZAAR).initList(getInventory(player, 0, Inventory.BAZAAR)); player.getInventory(Inventory.MELDREQUEST).initList(getInventory(player, 0, Inventory.MELDREQUEST)); player.getInventory(Inventory.LOOT).initList(getInventory(player, 0, Inventory.LOOT)); diff --git a/FFXIVClassic Map Server/actors/chara/player/Inventory.cs b/FFXIVClassic Map Server/actors/chara/player/Inventory.cs index 07f1e336..52c90ef2 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Inventory.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Inventory.cs @@ -18,7 +18,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player public const ushort LOOT = 0x0004; //Max 0xA public const ushort MELDREQUEST = 0x0005; //Max 0x04 public const ushort BAZAAR = 0x0007; //Max 0x0A - public const ushort CURRANCY = 0x0063; //Max 0x140 + public const ushort CURRENCY = 0x0063; //Max 0x140 public const ushort KEYITEMS = 0x0064; //Max 0x500 public const ushort EQUIPMENT = 0x00FE; //Max 0x23 public const ushort EQUIPMENT_OTHERPLAYER = 0x00F9; //Max 0x23 @@ -132,7 +132,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.player { Database.setQuantity(owner, slot, inventoryCode, list[slot].quantity); - if (inventoryCode != CURRANCY && inventoryCode != KEYITEMS) + if (inventoryCode != CURRENCY && inventoryCode != KEYITEMS) sendInventoryPackets(list[slot]); } @@ -144,13 +144,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.player list.Add(addedItem); - if (inventoryCode != CURRANCY && inventoryCode != KEYITEMS) + if (inventoryCode != CURRENCY && inventoryCode != KEYITEMS) sendInventoryPackets(addedItem); quantityCount -= gItem.maxStack; } - if (inventoryCode == CURRANCY || inventoryCode == KEYITEMS) + if (inventoryCode == CURRENCY || inventoryCode == KEYITEMS) sendFullInventory(); owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId)); diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index 7cb10eed..5b341c10 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -140,7 +140,7 @@ namespace FFXIVClassic_Map_Server.Actors inventories[Inventory.NORMAL] = new Inventory(this, MAXSIZE_INVENTORY_NORMAL, Inventory.NORMAL); inventories[Inventory.KEYITEMS] = new Inventory(this, MAXSIZE_INVENTORY_KEYITEMS, Inventory.KEYITEMS); - inventories[Inventory.CURRANCY] = new Inventory(this, MAXSIZE_INVENTORY_CURRANCY, Inventory.CURRANCY); + inventories[Inventory.CURRENCY] = new Inventory(this, MAXSIZE_INVENTORY_CURRANCY, Inventory.CURRENCY); inventories[Inventory.MELDREQUEST] = new Inventory(this, MAXSIZE_INVENTORY_MELDREQUEST, Inventory.MELDREQUEST); inventories[Inventory.BAZAAR] = new Inventory(this, MAXSIZE_INVENTORY_BAZAAR, Inventory.BAZAAR); inventories[Inventory.LOOT] = new Inventory(this, MAXSIZE_INVENTORY_LOOT, Inventory.LOOT); @@ -500,7 +500,7 @@ namespace FFXIVClassic_Map_Server.Actors #region Inventory & Equipment queuePacket(InventoryBeginChangePacket.buildPacket(actorId)); inventories[Inventory.NORMAL].sendFullInventory(); - inventories[Inventory.CURRANCY].sendFullInventory(); + inventories[Inventory.CURRENCY].sendFullInventory(); inventories[Inventory.KEYITEMS].sendFullInventory(); inventories[Inventory.BAZAAR].sendFullInventory(); inventories[Inventory.MELDREQUEST].sendFullInventory(); @@ -550,7 +550,7 @@ namespace FFXIVClassic_Map_Server.Actors reply11.replaceActorID(actorId); //playerSession.queuePacket(reply10); // playerSession.queuePacket(reply11); - #endregion + #endregion } private void sendRemoveInventoryPackets(List slots) From cd8cb1acb3953f7b2e8899a234119a47357b3a78 Mon Sep 17 00:00:00 2001 From: TheManii Date: Wed, 6 Apr 2016 16:28:24 -0700 Subject: [PATCH 06/22] Made give/removecurrency consistant with help description --- FFXIVClassic Map Server/CommandProcessor.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index c48e57c5..2bc8453c 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -26,6 +26,10 @@ namespace FFXIVClassic_Lobby_Server private static WorldManager mWorldManager = Server.getWorldManager(); private static Dictionary gamedataItems = Server.getItemGamedataList(); + // For the moment, this is the only predefined item + // TODO: make a list/enum in the future so that items can be given by name, instead of by id + const UInt32 ITEM_GIL = 1000001; + public CommandProcessor(Dictionary playerList) { mConnectedPlayerList = playerList; @@ -606,7 +610,7 @@ namespace FFXIVClassic_Lobby_Server try { if (split.Length == 2) - giveCurrency(client, UInt32.Parse(split[1]), 1); + giveCurrency(client, ITEM_GIL, Int32.Parse(split[1])); else if (split.Length == 3) giveCurrency(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); } @@ -623,7 +627,7 @@ namespace FFXIVClassic_Lobby_Server try { if (split.Length == 2) - removeCurrency(client, UInt32.Parse(split[1]), 1); + removeCurrency(client, ITEM_GIL, Int32.Parse(split[1])); else if (split.Length == 3) removeCurrency(client, UInt32.Parse(split[1]), Int32.Parse(split[2])); return true; From 4cf005467a908415d3906ab7ab2b06c12c072f37 Mon Sep 17 00:00:00 2001 From: TheManii Date: Wed, 6 Apr 2016 19:55:12 -0700 Subject: [PATCH 07/22] Moved most of the strings to external resource file --- FFXIVClassic Map Server/CommandProcessor.cs | 157 ++++------- .../FFXIVClassic Map Server.csproj | 12 +- .../Properties/Resources.Designer.cs | 254 ++++++++++++++++++ .../Properties/Resources.resx | 215 +++++++++++++++ 4 files changed, 525 insertions(+), 113 deletions(-) create mode 100644 FFXIVClassic Map Server/Properties/Resources.Designer.cs create mode 100644 FFXIVClassic Map Server/Properties/Resources.resx diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index 2bc8453c..36e58202 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -16,17 +16,18 @@ using FFXIVClassic_Map_Server.packets.send; using FFXIVClassic_Map_Server.dataobjects.chara; using FFXIVClassic_Map_Server.Actors; using FFXIVClassic_Map_Server.lua; -using FFXIVClassic_Map_Server.actors.chara.player; - +using FFXIVClassic_Map_Server.actors.chara.player; +using FFXIVClassic_Map_Server.Properties; + namespace FFXIVClassic_Lobby_Server { class CommandProcessor { private Dictionary mConnectedPlayerList; private static WorldManager mWorldManager = Server.getWorldManager(); - private static Dictionary gamedataItems = Server.getItemGamedataList(); - - // For the moment, this is the only predefined item + private static Dictionary gamedataItems = Server.getItemGamedataList(); + + // For the moment, this is the only predefined item // TODO: make a list/enum in the future so that items can be given by name, instead of by id const UInt32 ITEM_GIL = 1000001; @@ -336,6 +337,18 @@ namespace FFXIVClassic_Lobby_Server } } + /// + /// We only use the default options for SendMessagePacket. + /// May as well make it less unwieldly to view + /// + /// + /// + private void sendMessage(ConnectedPlayer client, String message) + { + if (client != null) + client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", message)); + } + internal bool doCommand(string input, ConnectedPlayer client) { input.Trim(); @@ -347,130 +360,50 @@ namespace FFXIVClassic_Lobby_Server // Debug - // if (client != null) - // client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - // string.Join(",", split) - // )); + //sendMessage(client, string.Join(",", split)); if (split.Length >= 1) { - if (split[0].Equals("help")) { if (split.Length == 1) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Use !help (command) for details\n\nAvailable commands:\nStandard: mypos, music, warp\nServer Administration: givecurrency, giveitem, givekeyitem, removecurrency, removekeyitem, reloaditems, resetzone\nDebug: property, property2, sendpacket, setgraphic" - )); + { + sendMessage(client, Resources.CPhelp); } if (split.Length == 2) { if (split[1].Equals("mypos")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Prints out your current location\n\n*Note: The X/Y/Z coordinates do not correspond to the coordinates listed in the in-game map, they are based on the underlying game data" - )); - } + sendMessage(client, Resources.CPmypos); else if (split[1].Equals("music")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Changes the currently playing background music\n\n*Syntax: music \n is the key item's specific id as defined in the server database" - )); - } + sendMessage(client, Resources.CPmusic); else if (split[1].Equals("warp")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Teleports the player to the specified location\n\n*Syntax:\twarp \n\twarp \n\twarp \n is a pre-defined list of locations from the server database\n is an instanced copy of the desired zone that's only visible to the current player" - )); - } - else if (split[1].Equals("givecurrency")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Adds the specified currency to the current player's inventory\n\n*Syntax:\tgivecurrency \n\tgivecurrency \n is the specific type of currency desired, defaults to gil if no type specified" - )); - } + sendMessage(client, Resources.CPwarp); + else if (split[1].Equals("givecurrency")) + sendMessage(client, Resources.CPgivecurrency); else if (split[1].Equals("giveitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Adds the specified items to the current player's inventory\n\n*Syntax:\tgiveitem \n\tgiveitem \n\tgiveitem \n is the item's specific id as defined in the server database\n is the type as defined in the server database (defaults to gil if not specified)" - )); - } + sendMessage(client, Resources.CPgiveitem); else if (split[1].Equals("givekeyitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Adds the specified key item to the current player's inventory\n\n*Syntax: givekeyitem \n is the key item's specific id as defined in the server database" - )); - } + sendMessage(client, Resources.CPgivekeyitem); else if (split[1].Equals("removecurrency")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Removes the specified currency from the current player's inventory\n\n*Syntax:\tremovecurrency \n\tremovecurrency \n is the specific type of currency desired, defaults to gil if no type specified" - )); - } + sendMessage(client, Resources.CPremovecurrency); else if (split[1].Equals("removeitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Removes the specified items to the current player's inventory\n\n*Syntax:\tremoveitem \n\tremoveitem \n is the item's specific id as defined in the server database" - )); - } + sendMessage(client, Resources.CPremoveitem); else if (split[1].Equals("removekeyitem")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Removes the specified key item to the current player's inventory\n\n*Syntax: removekeyitem \n is the key item's specific id as defined in the server database" - )); - } + sendMessage(client, Resources.CPremovekeyitem); else if (split[1].Equals("reloaditems")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Reloads the current item data from the database" - )); - } - else if (split[1].Equals("resetzone")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Reloads the current zone data from the server files" - )); - } - else if (split[1].Equals("property")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "\n*Syntax: property " - )); - } - else if (split[1].Equals("property2")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "\n*Syntax: property2 " - )); - } - else if (split[1].Equals("sendpacket")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Server sends a special packet to the client\n\n*Syntax: sendpacket \n is the path to the packet, starting in \\packet" - )); - } - else if (split[1].Equals("setgraphic")) - { - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", - "Overrides the currently displayed character equipment in a specific slot\n\n*Note: Similar to Glamours in FFXIV:ARR, the overridden graphics are purely cosmetic, they do not affect the underlying stats of whatever is equipped on that slot\n\n*Syntax: sendpacket \n are as defined in the client game data" - )); - } + sendMessage(client, Resources.CPreloaditems); + else if (split[1].Equals("reloadzones")) + sendMessage(client, Resources.CPreloadzones); + /* + else if (split[1].Equals("property")) + sendMessage(client, Resources.CPproperty); + else if (split[1].Equals("property2")) + sendMessage(client, Resources.CPproperty2); + else if (split[1].Equals("sendpacket")) + sendMessage(client, Resources.CPsendpacket); + else if (split[1].Equals("setgraphic")) + sendMessage(client, Resources.CPsetgraphic); + */ } return true; @@ -487,7 +420,7 @@ namespace FFXIVClassic_Lobby_Server Log.error("Could not load packet: " + e); } } - else if (split[0].Equals("resetzone")) + else if (split[0].Equals("reloadzones")) { if (client != null) { diff --git a/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj b/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj index c5ac86aa..d11205d9 100644 --- a/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj +++ b/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj @@ -251,6 +251,11 @@ + + True + True + Resources.resx + @@ -262,7 +267,12 @@ - + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + xcopy "$(SolutionDir)data" "$(SolutionDir)$(ProjectName)\$(OutDir)" /E /C /D diff --git a/FFXIVClassic Map Server/Properties/Resources.Designer.cs b/FFXIVClassic Map Server/Properties/Resources.Designer.cs new file mode 100644 index 00000000..27563937 --- /dev/null +++ b/FFXIVClassic Map Server/Properties/Resources.Designer.cs @@ -0,0 +1,254 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace FFXIVClassic_Map_Server.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FFXIVClassic_Map_Server.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Adds the specified currency to the current player's inventory + /// + ///*Syntax: givecurrency <quantity> + /// givecurrency <quantity> <type> + ///<type> is the specific type of currency desired, defaults to gil if no type specified. + /// + public static string CPgivecurrency { + get { + return ResourceManager.GetString("CPgivecurrency", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Adds the specified items to the current player's inventory + /// + ///*Syntax: giveitem <item id> + /// giveitem <item id> <quantity> + /// giveitem <item id> <quantity> <type> + ///<item id> is the item's specific id as defined in the server database + ///<type> is the type as defined in the server database (defaults to standard item if not specified). + /// + public static string CPgiveitem { + get { + return ResourceManager.GetString("CPgiveitem", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Adds the specified key item to the current player's inventory + /// + ///*Syntax: givekeyitem <item id> + ///<item id> is the key item's specific id as defined in the server database. + /// + public static string CPgivekeyitem { + get { + return ResourceManager.GetString("CPgivekeyitem", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Use !help(command) for details + /// + ///Available commands: + ///Standard: mypos, music, warp + ///Server Administration: givecurrency, giveitem, givekeyitem, removecurrency, removekeyitem, reloaditems, reloadzones. + /// + public static string CPhelp { + get { + return ResourceManager.GetString("CPhelp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Changes the currently playing background music + /// + ///*Syntax: music <music id> + ///<music id> is the key item's specific id as defined in the server database. + /// + public static string CPmusic { + get { + return ResourceManager.GetString("CPmusic", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Prints out your current location + /// + ///*Note: The X/Y/Z coordinates do not correspond to the coordinates listed in the in-game map, they are based on the underlying game data. + /// + public static string CPmypos { + get { + return ResourceManager.GetString("CPmypos", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to *Syntax: property <value 1> <value 2> <value 3>. + /// + public static string CPproperty { + get { + return ResourceManager.GetString("CPproperty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to *Syntax: property2 <value 1> <value 2> <value 3>. + /// + public static string CPproperty2 { + get { + return ResourceManager.GetString("CPproperty2", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reloads the current item data from the database. + /// + public static string CPreloaditems { + get { + return ResourceManager.GetString("CPreloaditems", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reloads the current zone data from the database. + /// + public static string CPreloadzones { + get { + return ResourceManager.GetString("CPreloadzones", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Removes the specified currency from the current player's inventory + /// + ///*Syntax: removecurrency <quantity> + /// removecurrency <quantity> <type> + ///<type> is the specific type of currency desired, defaults to gil if no type specified. + /// + public static string CPremovecurrency { + get { + return ResourceManager.GetString("CPremovecurrency", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Removes the specified items to the current player's inventory + /// + ///*Syntax: removeitem <itemid> + /// removeitem <itemid> <quantity> + ///<item id> is the item's specific id as defined in the server database. + /// + public static string CPremoveitem { + get { + return ResourceManager.GetString("CPremoveitem", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Removes the specified key item to the current player's inventory + /// + ///*Syntax: removekeyitem <itemid> + ///<item id> is the key item's specific id as defined in the server database. + /// + public static string CPremovekeyitem { + get { + return ResourceManager.GetString("CPremovekeyitem", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Server sends a special packet to the client + /// + ///*Syntax: sendpacket <path to packet> + ///<Path to packet> is the path to the packet, starting in <map server install location>\packet. + /// + public static string CPsendpacket { + get { + return ResourceManager.GetString("CPsendpacket", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Overrides the currently displayed character equipment in a specific slot + /// + ///*Note: Similar to Glamours in FFXIV:ARR, the overridden graphics are purely cosmetic, they do not affect the underlying stats of whatever is equipped on that slot + /// + ///*Syntax: sendpacket <slot> <wid> <eid> <vid> <cid> + ///<w/e/v/c id> are as defined in the client game data. + /// + public static string CPsetgraphic { + get { + return ResourceManager.GetString("CPsetgraphic", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Teleports the player to the specified location + /// + ///*Syntax: warp <location list> + /// 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 + ///<instance> is an instanced copy of the desired zone that's only visible to the current player. + /// + public static string CPwarp { + get { + return ResourceManager.GetString("CPwarp", resourceCulture); + } + } + } +} diff --git a/FFXIVClassic Map Server/Properties/Resources.resx b/FFXIVClassic Map Server/Properties/Resources.resx new file mode 100644 index 00000000..1ce0528a --- /dev/null +++ b/FFXIVClassic Map Server/Properties/Resources.resx @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Adds the specified currency to the current player's inventory + +*Syntax: givecurrency <quantity> + givecurrency <quantity> <type> +<type> is the specific type of currency desired, defaults to gil if no type specified + + + Adds the specified items to the current player's inventory + +*Syntax: giveitem <item id> + giveitem <item id> <quantity> + giveitem <item id> <quantity> <type> +<item id> is the item's specific id as defined in the server database +<type> is the type as defined in the server database (defaults to standard item if not specified) + + + Adds the specified key item to the current player's inventory + +*Syntax: givekeyitem <item id> +<item id> is the key item's specific id as defined in the server database + + + Use !help(command) for details + +Available commands: +Standard: mypos, music, warp +Server Administration: givecurrency, giveitem, givekeyitem, removecurrency, removekeyitem, reloaditems, reloadzones + + + Changes the currently playing background music + +*Syntax: music <music id> +<music id> is the key item's specific id as defined in the server database + + + Prints out your current location + +*Note: The X/Y/Z coordinates do not correspond to the coordinates listed in the in-game map, they are based on the underlying game data + + + *Syntax: property <value 1> <value 2> <value 3> + + + *Syntax: property2 <value 1> <value 2> <value 3> + + + Reloads the current item data from the database + + + Reloads the current zone data from the database + + + Removes the specified currency from the current player's inventory + +*Syntax: removecurrency <quantity> + removecurrency <quantity> <type> +<type> is the specific type of currency desired, defaults to gil if no type specified + + + Removes the specified items to the current player's inventory + +*Syntax: removeitem <itemid> + removeitem <itemid> <quantity> +<item id> is the item's specific id as defined in the server database + + + Removes the specified key item to the current player's inventory + +*Syntax: removekeyitem <itemid> +<item id> is the key item's specific id as defined in the server database + + + Server sends a special packet to the client + +*Syntax: sendpacket <path to packet> +<Path to packet> is the path to the packet, starting in <map server install location>\packet + + + Overrides the currently displayed character equipment in a specific slot + +*Note: Similar to Glamours in FFXIV:ARR, the overridden graphics are purely cosmetic, they do not affect the underlying stats of whatever is equipped on that slot + +*Syntax: sendpacket <slot> <wid> <eid> <vid> <cid> +<w/e/v/c id> are as defined in the client game data + + + Teleports the player to the specified location + +*Syntax: warp <location list> + 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 +<instance> is an instanced copy of the desired zone that's only visible to the current player + + \ No newline at end of file From 7c0594b749ace9921a5929fb56589683d7a66014 Mon Sep 17 00:00:00 2001 From: TheManii Date: Thu, 7 Apr 2016 10:37:14 -0700 Subject: [PATCH 08/22] Cherrypick *b16ea7b Disable login10/11 --- FFXIVClassic Map Server/actors/chara/player/Player.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index 5b341c10..22cf7cda 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -542,7 +542,7 @@ namespace FFXIVClassic_Map_Server.Actors packet.debugPrintSubPacket(); queuePacket(packet); } - +/* #region hardcode BasePacket reply10 = new BasePacket("./packets/login/login10.bin"); //Item Storage, Inn Door created BasePacket reply11 = new BasePacket("./packets/login/login11.bin"); //NPC Create ??? Final init @@ -552,7 +552,7 @@ namespace FFXIVClassic_Map_Server.Actors // playerSession.queuePacket(reply11); #endregion } - +*/ private void sendRemoveInventoryPackets(List slots) { int currentIndex = 0; From b17d193a595e45b325cdd87b9de7b1b3890910d4 Mon Sep 17 00:00:00 2001 From: TheManii Date: Thu, 7 Apr 2016 11:41:56 -0700 Subject: [PATCH 09/22] Fix previous commit --- FFXIVClassic Map Server/actors/chara/player/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index 22cf7cda..44ad01fd 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -551,8 +551,8 @@ namespace FFXIVClassic_Map_Server.Actors //playerSession.queuePacket(reply10); // playerSession.queuePacket(reply11); #endregion - } */ + } private void sendRemoveInventoryPackets(List slots) { int currentIndex = 0; From ecc61ea5f9700b636816edea73741faedafb6db3 Mon Sep 17 00:00:00 2001 From: TheManii Date: Thu, 7 Apr 2016 12:25:28 -0700 Subject: [PATCH 10/22] Surrounded command chain with region boxes Changed doWarp() to handle in implicit, in-zone only warps Might have issues with instanced zones, untested --- FFXIVClassic Map Server/CommandProcessor.cs | 198 +++++++++++++------- FFXIVClassic Map Server/WorldManager.cs | 39 ++-- 2 files changed, 154 insertions(+), 83 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index 36e58202..02c450a5 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -16,19 +16,19 @@ using FFXIVClassic_Map_Server.packets.send; using FFXIVClassic_Map_Server.dataobjects.chara; using FFXIVClassic_Map_Server.Actors; using FFXIVClassic_Map_Server.lua; -using FFXIVClassic_Map_Server.actors.chara.player; -using FFXIVClassic_Map_Server.Properties; - +using FFXIVClassic_Map_Server.actors.chara.player; +using FFXIVClassic_Map_Server.Properties; + namespace FFXIVClassic_Lobby_Server { class CommandProcessor { private Dictionary mConnectedPlayerList; private static WorldManager mWorldManager = Server.getWorldManager(); - private static Dictionary gamedataItems = Server.getItemGamedataList(); - - // For the moment, this is the only predefined item - // TODO: make a list/enum in the future so that items can be given by name, instead of by id + private static Dictionary gamedataItems = Server.getItemGamedataList(); + + // For the moment, this is the only predefined item + // TODO: make a list/enum in the future so that items can be given by name, instead of by id const UInt32 ITEM_GIL = 1000001; public CommandProcessor(Dictionary playerList) @@ -95,6 +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 public void doWarp(ConnectedPlayer client, string entranceId) { uint id; @@ -128,31 +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; - - 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."); - } - + float x,y,z; + x = Single.Parse(sx); y = Single.Parse(sy); z = Single.Parse(sz); - 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); + 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); + } } } } @@ -356,18 +369,19 @@ namespace FFXIVClassic_Lobby_Server input = input.Substring(1); String[] split = input.Split(' '); - split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands - - - // Debug - //sendMessage(client, string.Join(",", split)); - + split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands + + + // Debug + //sendMessage(client, string.Join(",", split)); + if (split.Length >= 1) { + #region !help if (split[0].Equals("help")) { if (split.Length == 1) - { + { sendMessage(client, Resources.CPhelp); } if (split.Length == 2) @@ -378,7 +392,7 @@ namespace FFXIVClassic_Lobby_Server sendMessage(client, Resources.CPmusic); else if (split[1].Equals("warp")) sendMessage(client, Resources.CPwarp); - else if (split[1].Equals("givecurrency")) + else if (split[1].Equals("givecurrency")) sendMessage(client, Resources.CPgivecurrency); else if (split[1].Equals("giveitem")) sendMessage(client, Resources.CPgiveitem); @@ -392,22 +406,25 @@ namespace FFXIVClassic_Lobby_Server sendMessage(client, Resources.CPremovekeyitem); else if (split[1].Equals("reloaditems")) sendMessage(client, Resources.CPreloaditems); - else if (split[1].Equals("reloadzones")) - sendMessage(client, Resources.CPreloadzones); - /* - else if (split[1].Equals("property")) - sendMessage(client, Resources.CPproperty); - else if (split[1].Equals("property2")) - sendMessage(client, Resources.CPproperty2); - else if (split[1].Equals("sendpacket")) - sendMessage(client, Resources.CPsendpacket); - else if (split[1].Equals("setgraphic")) - sendMessage(client, Resources.CPsetgraphic); - */ + else if (split[1].Equals("reloadzones")) + sendMessage(client, Resources.CPreloadzones); + /* + else if (split[1].Equals("property")) + sendMessage(client, Resources.CPproperty); + else if (split[1].Equals("property2")) + sendMessage(client, Resources.CPproperty2); + else if (split[1].Equals("sendpacket")) + sendMessage(client, Resources.CPsendpacket); + else if (split[1].Equals("setgraphic")) + sendMessage(client, Resources.CPsetgraphic); + */ } return true; - } + } + #endregion + + #region !mypos else if (split[0].Equals("mypos")) { try @@ -419,7 +436,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not load packet: " + e); } - } + } + #endregion + + #region !reloadzones else if (split[0].Equals("reloadzones")) { if (client != null) @@ -432,7 +452,10 @@ namespace FFXIVClassic_Lobby_Server } mWorldManager.reloadZone(client.getActor().zoneId); return true; - } + } + #endregion + + #region !reloaditems else if (split[0].Equals("reloaditems")) { Log.info(String.Format("Got request to reload item gamedata")); @@ -444,7 +467,10 @@ namespace FFXIVClassic_Lobby_Server if (client != null) client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Loaded {0} items.", gamedataItems.Count))); return true; - } + } + #endregion + + #region !sendpacket else if (split[0].Equals("sendpacket")) { if (split.Length < 2) @@ -459,7 +485,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not load packet: " + e); } - } + } + #endregion + + #region !graphic else if (split[0].Equals("graphic")) { try @@ -472,7 +501,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not give item."); } - } + } + #endregion + + #region !giveitem else if (split[0].Equals("giveitem")) { try @@ -489,7 +521,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not give item."); } - } + } + #endregion + + #region !removeitem else if (split[0].Equals("removeitem")) { if (split.Length < 2) @@ -509,7 +544,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not remove item."); } - } + } + #endregion + + #region !givekeyitem else if (split[0].Equals("givekeyitem")) { try @@ -521,7 +559,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not give keyitem."); } - } + } + #endregion + + #region !removekeyitem else if (split[0].Equals("removekeyitem")) { if (split.Length < 2) @@ -537,7 +578,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not remove keyitem."); } - } + } + #endregion + + #region !givecurrency else if (split[0].Equals("givecurrency")) { try @@ -551,7 +595,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not give currency."); } - } + } + #endregion + + #region !removecurrency else if (split[0].Equals("removecurrency")) { if (split.Length < 2) @@ -569,7 +616,10 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not remove currency."); } - } + } + #endregion + + #region !music else if (split[0].Equals("music")) { if (split.Length < 2) @@ -584,17 +634,25 @@ namespace FFXIVClassic_Lobby_Server { Log.error("Could not change music: " + e); } - } + } + #endregion + + #region !warp else if (split[0].Equals("warp")) { - if (split.Length == 2) - doWarp(client, split[1]); - else if (split.Length == 5) + 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) + else if (split.Length == 6) // Zone + instance + X/Y/Z doWarp(client, split[1], split[2], split[3], split[4], split[5]); return true; - } + } + #endregion + + #region !property else if (split[0].Equals("property")) { if (split.Length == 4) @@ -602,7 +660,10 @@ 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")) { if (split.Length == 4) @@ -610,7 +671,8 @@ 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/WorldManager.cs b/FFXIVClassic Map Server/WorldManager.cs index cbac035a..32e19250 100644 --- a/FFXIVClassic Map Server/WorldManager.cs +++ b/FFXIVClassic Map Server/WorldManager.cs @@ -372,26 +372,35 @@ namespace FFXIVClassic_Map_Server } //Add player to new zone and update - Area newArea; - - if (destinationPrivateArea == null) - newArea = GetZone(destinationZoneId); + Area newArea; + + if (destinationZoneId != 0) + { + if (destinationPrivateArea == null) + newArea = GetZone(destinationZoneId); + else + newArea = GetZone(destinationZoneId).getPrivateArea(destinationPrivateArea, 0); + } else - newArea = GetZone(destinationZoneId).getPrivateArea(destinationPrivateArea, 0); - + { + if (destinationPrivateArea == null) + newArea = GetZone(player.zoneId); + else + newArea = GetZone(player.zoneId).getPrivateArea(destinationPrivateArea, 0); + } //This server does not contain that zoneId if (newArea == null) return; - newArea.addActorToZone(player); - - //Update player actor's properties - player.zoneId = newArea.actorId; - player.zone = newArea; - player.positionX = spawnX; - player.positionY = spawnY; - player.positionZ = spawnZ; - player.rotation = spawnRotation; + newArea.addActorToZone(player); + + //Update player actor's properties + player.zoneId = newArea.actorId; + player.zone = newArea; + player.positionX = spawnX; + player.positionY = spawnY; + player.positionZ = spawnZ; + player.rotation = spawnRotation; //Send packets player.playerSession.queuePacket(DeleteAllActorsPacket.buildPacket(player.actorId), true, false); From cc5d0b139aad6e57f07653261303ce5f0e699d81 Mon Sep 17 00:00:00 2001 From: TheManii Date: Thu, 7 Apr 2016 12:29:17 -0700 Subject: [PATCH 11/22] Added new !warp to help --- FFXIVClassic Map Server/Properties/Resources.Designer.cs | 2 ++ FFXIVClassic Map Server/Properties/Resources.resx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/FFXIVClassic Map Server/Properties/Resources.Designer.cs b/FFXIVClassic Map Server/Properties/Resources.Designer.cs index 27563937..cea7c949 100644 --- a/FFXIVClassic Map Server/Properties/Resources.Designer.cs +++ b/FFXIVClassic Map Server/Properties/Resources.Designer.cs @@ -240,9 +240,11 @@ namespace FFXIVClassic_Map_Server.Properties { /// Looks up a localized string similar to Teleports the player to the specified location /// ///*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. /// public static string CPwarp { diff --git a/FFXIVClassic Map Server/Properties/Resources.resx b/FFXIVClassic Map Server/Properties/Resources.resx index 1ce0528a..71b54066 100644 --- a/FFXIVClassic Map Server/Properties/Resources.resx +++ b/FFXIVClassic Map Server/Properties/Resources.resx @@ -207,9 +207,11 @@ Server Administration: givecurrency, giveitem, givekeyitem, removecurrency, remo Teleports the player to the specified location *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 \ No newline at end of file From 33be97ea9d52da26d0c06ef8d82a85e45ac9a1f6 Mon Sep 17 00:00:00 2001 From: TheManii Date: Thu, 7 Apr 2016 22:22:31 -0700 Subject: [PATCH 12/22] Make CommandProcessor more robust --- FFXIVClassic Map Server/CommandProcessor.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index 02c450a5..d815467a 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -299,6 +299,7 @@ namespace FFXIVClassic_Lobby_Server } } + // TODO: make removeCurrency() remove all quantity of a currency if quantity_to_remove > quantity_in_inventory instead of silently failing private void removeCurrency(ConnectedPlayer client, uint itemId, int quantity) { if (client != null) @@ -370,7 +371,7 @@ namespace FFXIVClassic_Lobby_Server 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)); @@ -459,13 +460,11 @@ namespace FFXIVClassic_Lobby_Server else if (split[0].Equals("reloaditems")) { Log.info(String.Format("Got request to reload item gamedata")); - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Reloading Item Gamedata...")); + sendMessage(client, "Reloading Item Gamedata..."); gamedataItems.Clear(); gamedataItems = Database.getItemGamedata(); Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); - if (client != null) - client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Loaded {0} items.", gamedataItems.Count))); + sendMessage(client, String.Format("Loaded {0} items.", gamedataItems.Count)); return true; } #endregion From 21745a6aa8c583210d66a813e0cd33dc9e1690dc Mon Sep 17 00:00:00 2001 From: TheManii Date: Fri, 8 Apr 2016 00:48:34 -0700 Subject: [PATCH 13/22] 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> From 3790920db3351c39f57835b7b023f8a29e1e1683 Mon Sep 17 00:00:00 2001 From: TheManii Date: Fri, 8 Apr 2016 00:51:34 -0700 Subject: [PATCH 14/22] Typo --- FFXIVClassic Map Server/Properties/Resources.Designer.cs | 4 ++-- FFXIVClassic Map Server/Properties/Resources.resx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/FFXIVClassic Map Server/Properties/Resources.Designer.cs b/FFXIVClassic Map Server/Properties/Resources.Designer.cs index 3a6f068b..d0cae89c 100644 --- a/FFXIVClassic Map Server/Properties/Resources.Designer.cs +++ b/FFXIVClassic Map Server/Properties/Resources.Designer.cs @@ -239,14 +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 + ///*Note: You can 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 zon [rest of string was truncated]";. + ///<zone id> is the [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 a038aae6..f121876e 100644 --- a/FFXIVClassic Map Server/Properties/Resources.resx +++ b/FFXIVClassic Map Server/Properties/Resources.resx @@ -206,7 +206,7 @@ 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 +*Note: You can 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> From 29228a0c115454a74786f05badf6fa16195f5f85 Mon Sep 17 00:00:00 2001 From: TheManii Date: Fri, 8 Apr 2016 09:57:40 -0700 Subject: [PATCH 15/22] Fix merge --- .../actors/chara/player/Player.cs | 20 +++++++++---------- data/config.ini | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index ce523cf9..e535cbf0 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -140,7 +140,7 @@ namespace FFXIVClassic_Map_Server.Actors inventories[Inventory.NORMAL] = new Inventory(this, MAXSIZE_INVENTORY_NORMAL, Inventory.NORMAL); inventories[Inventory.KEYITEMS] = new Inventory(this, MAXSIZE_INVENTORY_KEYITEMS, Inventory.KEYITEMS); - inventories[Inventory.CURRANCY] = new Inventory(this, MAXSIZE_INVENTORY_CURRANCY, Inventory.CURRANCY); + inventories[Inventory.CURRENCY] = new Inventory(this, MAXSIZE_INVENTORY_CURRANCY, Inventory.CURRENCY); inventories[Inventory.MELDREQUEST] = new Inventory(this, MAXSIZE_INVENTORY_MELDREQUEST, Inventory.MELDREQUEST); inventories[Inventory.BAZAAR] = new Inventory(this, MAXSIZE_INVENTORY_BAZAAR, Inventory.BAZAAR); inventories[Inventory.LOOT] = new Inventory(this, MAXSIZE_INVENTORY_LOOT, Inventory.LOOT); @@ -500,7 +500,7 @@ namespace FFXIVClassic_Map_Server.Actors #region Inventory & Equipment queuePacket(InventoryBeginChangePacket.buildPacket(actorId)); inventories[Inventory.NORMAL].sendFullInventory(); - inventories[Inventory.CURRANCY].sendFullInventory(); + inventories[Inventory.CURRENCY].sendFullInventory(); inventories[Inventory.KEYITEMS].sendFullInventory(); inventories[Inventory.BAZAAR].sendFullInventory(); inventories[Inventory.MELDREQUEST].sendFullInventory(); @@ -703,34 +703,34 @@ namespace FFXIVClassic_Map_Server.Actors { if (msgParams.Length == 0) { - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); } else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, string customSender, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, uint displayId, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); } public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams) diff --git a/data/config.ini b/data/config.ini index 7caf0001..238c6145 100644 --- a/data/config.ini +++ b/data/config.ini @@ -1,5 +1,5 @@ [General] -server_ip=127.0.0.1 +server_ip=192.168.1.124 showtimestamp = true [Database] From de2ec984e44e680e8a4c5cb76a8225eefe7eaea2 Mon Sep 17 00:00:00 2001 From: TheManii Date: Fri, 8 Apr 2016 09:59:56 -0700 Subject: [PATCH 16/22] Revert "Fix merge" This reverts commit 29228a0c115454a74786f05badf6fa16195f5f85. --- .../actors/chara/player/Player.cs | 20 +++++++++---------- data/config.ini | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index e535cbf0..ce523cf9 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -140,7 +140,7 @@ namespace FFXIVClassic_Map_Server.Actors inventories[Inventory.NORMAL] = new Inventory(this, MAXSIZE_INVENTORY_NORMAL, Inventory.NORMAL); inventories[Inventory.KEYITEMS] = new Inventory(this, MAXSIZE_INVENTORY_KEYITEMS, Inventory.KEYITEMS); - inventories[Inventory.CURRENCY] = new Inventory(this, MAXSIZE_INVENTORY_CURRANCY, Inventory.CURRENCY); + inventories[Inventory.CURRANCY] = new Inventory(this, MAXSIZE_INVENTORY_CURRANCY, Inventory.CURRANCY); inventories[Inventory.MELDREQUEST] = new Inventory(this, MAXSIZE_INVENTORY_MELDREQUEST, Inventory.MELDREQUEST); inventories[Inventory.BAZAAR] = new Inventory(this, MAXSIZE_INVENTORY_BAZAAR, Inventory.BAZAAR); inventories[Inventory.LOOT] = new Inventory(this, MAXSIZE_INVENTORY_LOOT, Inventory.LOOT); @@ -500,7 +500,7 @@ namespace FFXIVClassic_Map_Server.Actors #region Inventory & Equipment queuePacket(InventoryBeginChangePacket.buildPacket(actorId)); inventories[Inventory.NORMAL].sendFullInventory(); - inventories[Inventory.CURRENCY].sendFullInventory(); + inventories[Inventory.CURRANCY].sendFullInventory(); inventories[Inventory.KEYITEMS].sendFullInventory(); inventories[Inventory.BAZAAR].sendFullInventory(); inventories[Inventory.MELDREQUEST].sendFullInventory(); @@ -703,34 +703,34 @@ namespace FFXIVClassic_Map_Server.Actors { if (msgParams.Length == 0) { - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); } else - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, string customSender, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, uint displayId, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); } public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams) diff --git a/data/config.ini b/data/config.ini index 238c6145..7caf0001 100644 --- a/data/config.ini +++ b/data/config.ini @@ -1,5 +1,5 @@ [General] -server_ip=192.168.1.124 +server_ip=127.0.0.1 showtimestamp = true [Database] From dbbd1fa0d81a78e7dac152198ad2a525b47ae05b Mon Sep 17 00:00:00 2001 From: TheManii Date: Fri, 8 Apr 2016 10:03:35 -0700 Subject: [PATCH 17/22] Fix merge --- .../actors/chara/player/Player.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index ce523cf9..e535cbf0 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -140,7 +140,7 @@ namespace FFXIVClassic_Map_Server.Actors inventories[Inventory.NORMAL] = new Inventory(this, MAXSIZE_INVENTORY_NORMAL, Inventory.NORMAL); inventories[Inventory.KEYITEMS] = new Inventory(this, MAXSIZE_INVENTORY_KEYITEMS, Inventory.KEYITEMS); - inventories[Inventory.CURRANCY] = new Inventory(this, MAXSIZE_INVENTORY_CURRANCY, Inventory.CURRANCY); + inventories[Inventory.CURRENCY] = new Inventory(this, MAXSIZE_INVENTORY_CURRANCY, Inventory.CURRENCY); inventories[Inventory.MELDREQUEST] = new Inventory(this, MAXSIZE_INVENTORY_MELDREQUEST, Inventory.MELDREQUEST); inventories[Inventory.BAZAAR] = new Inventory(this, MAXSIZE_INVENTORY_BAZAAR, Inventory.BAZAAR); inventories[Inventory.LOOT] = new Inventory(this, MAXSIZE_INVENTORY_LOOT, Inventory.LOOT); @@ -500,7 +500,7 @@ namespace FFXIVClassic_Map_Server.Actors #region Inventory & Equipment queuePacket(InventoryBeginChangePacket.buildPacket(actorId)); inventories[Inventory.NORMAL].sendFullInventory(); - inventories[Inventory.CURRANCY].sendFullInventory(); + inventories[Inventory.CURRENCY].sendFullInventory(); inventories[Inventory.KEYITEMS].sendFullInventory(); inventories[Inventory.BAZAAR].sendFullInventory(); inventories[Inventory.MELDREQUEST].sendFullInventory(); @@ -703,34 +703,34 @@ namespace FFXIVClassic_Map_Server.Actors { if (msgParams.Length == 0) { - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); } else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, string customSender, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, uint displayId, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); } public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams) From 2eb40a0d7c9b12909c7f91f8b153fb8f81fe5881 Mon Sep 17 00:00:00 2001 From: TheManii Date: Sat, 9 Apr 2016 11:28:21 -0700 Subject: [PATCH 18/22] Save player rotation for relative warps Make !warp more robust with error handling --- FFXIVClassic Map Server/CommandProcessor.cs | 183 +++++++++++++------- 1 file changed, 119 insertions(+), 64 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index 86c095d0..ee468f19 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -130,26 +130,30 @@ namespace FFXIVClassic_Lobby_Server } } - public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz) + public void doWarp(ConnectedPlayer client, string zone, string privateArea, float x, float y, float z, float r) { uint zoneId; - 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); + mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, r); } else { - if (zone.ToLower().StartsWith("0x")) - zoneId = Convert.ToUInt32(zone, 16); - else - zoneId = Convert.ToUInt32(zone); + if (zone.ToLower().StartsWith("0x")) + { + try {zoneId = Convert.ToUInt32(zone, 16);} + catch (FormatException e) + {return;} + } + else + { + try {zoneId = Convert.ToUInt32(zone);} + catch (FormatException e) + {return;} + } + if (mWorldManager.GetZone(zoneId) == null) { @@ -159,12 +163,12 @@ namespace FFXIVClassic_Lobby_Server } if (client != null) - mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); + mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, r); else { foreach (KeyValuePair entry in mConnectedPlayerList) { - mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); + mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, r); } } } @@ -351,62 +355,113 @@ 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; - + private void parseWarp(ConnectedPlayer client, string[] split) + { + //bool relx = false, + // rely = false, + // relz = false; + float x = 0, y = 0, z = 0, r = 0.0f; + string zone = null, privatearea = null; + + 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])) + // TODO: Handle !warp Playername + doWarp(client, split[1]); + } + else if (split.Length == 4) + { + #region !warp X Y Z + if (split[1].StartsWith("@")) + { + //relx = true; + split[1] = split[1].Replace("@", string.Empty); + + if (String.IsNullOrEmpty(split[1])) + split[1] = "0"; + + try { x = Single.Parse(split[1]) + client.getActor().positionX; } + catch (FormatException e) + { return; } + 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"; + + try { y = Single.Parse(split[2]) + client.getActor().positionY; } + catch (FormatException e) + { return; } + 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(); + try { z = Single.Parse(split[3]) + client.getActor().positionZ; } + catch (FormatException e) + { return; } + 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)); + + try + { + x = Single.Parse(split[1]); + y = Single.Parse(split[2]); + z = Single.Parse(split[3]); + } + catch (FormatException e) + { return; } + + r = client.getActor().rotation; + + //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]); + #endregion + } + else if (split.Length == 5) + { + #region !warp Zone X Y Z + try + { + x = Single.Parse(split[2]); + y = Single.Parse(split[3]); + z = Single.Parse(split[4]); + } + catch (FormatException e) + { return; } + + zone = split[1]; + #endregion + } + else if (split.Length == 6) + { + #region !warp Zone Instance X Y Z + try + { + x = Single.Parse(split[3]); + y = Single.Parse(split[4]); + z = Single.Parse(split[5]); + } + catch (FormatException e) + { return; } + + zone = split[1]; + privatearea = split[2]; + #endregion + } + else + return; // catch any invalid warps here + + doWarp(client, zone, privatearea, x, y, z, r); } /// @@ -696,7 +751,7 @@ namespace FFXIVClassic_Lobby_Server #region !warp else if (split[0].Equals("warp")) - { + { parseWarp(client, split); return true; } From 06606c5f01497917f62f350cf072827d5725369d Mon Sep 17 00:00:00 2001 From: TheManii Date: Sat, 9 Apr 2016 12:27:04 -0700 Subject: [PATCH 19/22] *Revert changes to worldmanager.cs, not needed anymore *Made !warp silently catch all exceptions so they dont crash server/don't change player state if invalid *Moved rest of !warp parsing logic into parseWarp(), doWarp() now purely handles actual act of warping --- FFXIVClassic Map Server/CommandProcessor.cs | 220 ++++++++++---------- FFXIVClassic Map Server/WorldManager.cs | 38 ++-- 2 files changed, 119 insertions(+), 139 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index ee468f19..650d9289 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -99,77 +99,41 @@ namespace FFXIVClassic_Lobby_Server /// 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) + /// Predefined list: <ffxiv_database>\server_zones_spawnlocations + public void doWarp(ConnectedPlayer client, uint id) { - uint id; - - try - { - if (entranceId.ToLower().StartsWith("0x")) - id = Convert.ToUInt32(entranceId, 16); - else - id = Convert.ToUInt32(entranceId); - } - catch(FormatException e) - {return;} - FFXIVClassic_Map_Server.WorldManager.ZoneEntrance ze = mWorldManager.getZoneEntrance(id); if (ze == null) return; if (client != null) - mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); + mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation); else { foreach (KeyValuePair entry in mConnectedPlayerList) { - mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); + mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation); } } } - public void doWarp(ConnectedPlayer client, string zone, string privateArea, float x, float y, float z, float r) + public void doWarp(ConnectedPlayer client, uint zoneId, string privateArea, float x, float y, float z, float r) { - uint zoneId; - - if (zone == null) + if (mWorldManager.GetZone(zoneId) == null) { if (client != null) - mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, r); + 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, r); else { - if (zone.ToLower().StartsWith("0x")) - { - try {zoneId = Convert.ToUInt32(zone, 16);} - catch (FormatException e) - {return;} - } - else - { - try {zoneId = Convert.ToUInt32(zone);} - catch (FormatException e) - {return;} - } - - - if (mWorldManager.GetZone(zoneId) == null) + foreach (KeyValuePair entry in mConnectedPlayerList) { - 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, r); - else - { - foreach (KeyValuePair entry in mConnectedPlayerList) - { - mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, r); - } + mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, r); } } } @@ -357,111 +321,137 @@ 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, r = 0.0f; - string zone = null, privatearea = null; + float x = 0, y = 0, z = 0, r = 0.0f; + uint zoneId = 0; + string privatearea = null; - - if (split.Length == 2) // Predefined list + if (split.Length == 2) // Predefined list { // TODO: Handle !warp Playername - doWarp(client, split[1]); + #region !warp (predefined list) + try + { + if (split[1].ToLower().StartsWith("0x")) + zoneId = Convert.ToUInt32(split[1], 16); + else + zoneId = Convert.ToUInt32(split[1]); + } + catch{return;} + #endregion + + doWarp(client, zoneId); } - else if (split.Length == 4) + else if (split.Length == 4) { #region !warp X Y Z if (split[1].StartsWith("@")) { - //relx = true; split[1] = split[1].Replace("@", string.Empty); if (String.IsNullOrEmpty(split[1])) split[1] = "0"; try { x = Single.Parse(split[1]) + client.getActor().positionX; } - catch (FormatException e) - { return; } - split[1] = x.ToString(); + catch{return;} + + 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"; - try { y = Single.Parse(split[2]) + client.getActor().positionY; } - catch (FormatException e) - { return; } - split[2] = y.ToString(); + try { y = Single.Parse(split[2]) + client.getActor().positionY; } + catch{return;} + + 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"; - - try { z = Single.Parse(split[3]) + client.getActor().positionZ; } - catch (FormatException e) - { return; } + split[3] = "0"; + + try { z = Single.Parse(split[3]) + client.getActor().positionZ; } + catch{return;} + split[3] = z.ToString(); - } - - try - { - x = Single.Parse(split[1]); - y = Single.Parse(split[2]); - z = Single.Parse(split[3]); - } - catch (FormatException e) - { return; } + } + try + { + x = Single.Parse(split[1]); + y = Single.Parse(split[2]); + z = Single.Parse(split[3]); + } + catch{return;} + + zoneId = client.getActor().zoneId; r = client.getActor().rotation; - - //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])); #endregion + + sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); + doWarp(client, zoneId, privatearea, x, y, z, r); } - else if (split.Length == 5) - { - #region !warp Zone X Y Z - try - { - x = Single.Parse(split[2]); - y = Single.Parse(split[3]); - z = Single.Parse(split[4]); - } - catch (FormatException e) - { return; } + else if (split.Length == 5) + { + #region !warp Zone X Y Z + try + { + x = Single.Parse(split[2]); + y = Single.Parse(split[3]); + z = Single.Parse(split[4]); + } + catch{return;} - zone = split[1]; - #endregion + if (split[1].ToLower().StartsWith("0x")) + { + try { zoneId = Convert.ToUInt32(split[1], 16); } + catch{return;} + } + else + { + try { zoneId = Convert.ToUInt32(split[1]); } + catch{return;} + } + #endregion + + sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); + doWarp(client, zoneId, privatearea, x, y, z, r); } - else if (split.Length == 6) - { - #region !warp Zone Instance X Y Z - try - { - x = Single.Parse(split[3]); - y = Single.Parse(split[4]); - z = Single.Parse(split[5]); - } - catch (FormatException e) - { return; } + else if (split.Length == 6) + { + #region !warp Zone Instance X Y Z + try + { + x = Single.Parse(split[3]); + y = Single.Parse(split[4]); + z = Single.Parse(split[5]); + } + catch{return;} - zone = split[1]; - privatearea = split[2]; - #endregion + if (split[1].ToLower().StartsWith("0x")) + { + try { zoneId = Convert.ToUInt32(split[1], 16); } + catch{return;} + } + else + { + try { zoneId = Convert.ToUInt32(split[1]); } + catch{return;} + } + + privatearea = split[2]; + #endregion + + sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); + doWarp(client, zoneId, privatearea, x, y, z, r); } else return; // catch any invalid warps here - - doWarp(client, zone, privatearea, x, y, z, r); } /// diff --git a/FFXIVClassic Map Server/WorldManager.cs b/FFXIVClassic Map Server/WorldManager.cs index 32e19250..3d5d33c5 100644 --- a/FFXIVClassic Map Server/WorldManager.cs +++ b/FFXIVClassic Map Server/WorldManager.cs @@ -372,35 +372,25 @@ namespace FFXIVClassic_Map_Server } //Add player to new zone and update - Area newArea; - - if (destinationZoneId != 0) - { - if (destinationPrivateArea == null) - newArea = GetZone(destinationZoneId); - else - newArea = GetZone(destinationZoneId).getPrivateArea(destinationPrivateArea, 0); - } + Area newArea; + + if (destinationPrivateArea == null) + newArea = GetZone(destinationZoneId); else - { - if (destinationPrivateArea == null) - newArea = GetZone(player.zoneId); - else - newArea = GetZone(player.zoneId).getPrivateArea(destinationPrivateArea, 0); - } + newArea = GetZone(destinationZoneId).getPrivateArea(destinationPrivateArea, 0); //This server does not contain that zoneId if (newArea == null) return; - newArea.addActorToZone(player); - - //Update player actor's properties - player.zoneId = newArea.actorId; - player.zone = newArea; - player.positionX = spawnX; - player.positionY = spawnY; - player.positionZ = spawnZ; - player.rotation = spawnRotation; + newArea.addActorToZone(player); + + //Update player actor's properties + player.zoneId = newArea.actorId; + player.zone = newArea; + player.positionX = spawnX; + player.positionY = spawnY; + player.positionZ = spawnZ; + player.rotation = spawnRotation; //Send packets player.playerSession.queuePacket(DeleteAllActorsPacket.buildPacket(player.actorId), true, false); From c38fbc0c0912d0f2995b1974bc5881ea0a30d342 Mon Sep 17 00:00:00 2001 From: TheManii Date: Sat, 9 Apr 2016 12:35:29 -0700 Subject: [PATCH 20/22] *Revert ea1e16a, should be done globally and not simply here --- FFXIVClassic Map Server/CommandProcessor.cs | 76 +++++++------- FFXIVClassic Map Server/PacketProcessor.cs | 6 +- FFXIVClassic Map Server/Server.cs | 98 +++++++++---------- .../actors/chara/npc/Npc.cs | 2 +- .../actors/chara/player/Player.cs | 16 +-- FFXIVClassic Map Server/lua/LuaEngine.cs | 18 ++-- 6 files changed, 108 insertions(+), 108 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index 650d9289..2170338e 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -24,7 +24,7 @@ namespace FFXIVClassic_Lobby_Server class CommandProcessor { private Dictionary mConnectedPlayerList; - private static WorldManager mWorldManager = Server.getWorldManager(); + private static WorldManager mWorldManager = Server.GetWorldManager(); private static Dictionary gamedataItems = Server.getItemGamedataList(); // For the moment, this is the only predefined item @@ -322,23 +322,23 @@ namespace FFXIVClassic_Lobby_Server private void parseWarp(ConnectedPlayer client, string[] split) { float x = 0, y = 0, z = 0, r = 0.0f; - uint zoneId = 0; + uint zoneId = 0; string privatearea = null; if (split.Length == 2) // Predefined list - { - // TODO: Handle !warp Playername - #region !warp (predefined list) - try - { - if (split[1].ToLower().StartsWith("0x")) - zoneId = Convert.ToUInt32(split[1], 16); - else - zoneId = Convert.ToUInt32(split[1]); - } - catch{return;} + { + // TODO: Handle !warp Playername + #region !warp (predefined list) + try + { + if (split[1].ToLower().StartsWith("0x")) + zoneId = Convert.ToUInt32(split[1], 16); + else + zoneId = Convert.ToUInt32(split[1]); + } + catch{return;} #endregion - + doWarp(client, zoneId); } else if (split.Length == 4) @@ -393,7 +393,7 @@ namespace FFXIVClassic_Lobby_Server r = client.getActor().rotation; #endregion - sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); + sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); doWarp(client, zoneId, privatearea, x, y, z, r); } else if (split.Length == 5) @@ -406,20 +406,20 @@ namespace FFXIVClassic_Lobby_Server z = Single.Parse(split[4]); } catch{return;} - - if (split[1].ToLower().StartsWith("0x")) - { - try { zoneId = Convert.ToUInt32(split[1], 16); } - catch{return;} - } - else - { - try { zoneId = Convert.ToUInt32(split[1]); } - catch{return;} + + if (split[1].ToLower().StartsWith("0x")) + { + try { zoneId = Convert.ToUInt32(split[1], 16); } + catch{return;} + } + else + { + try { zoneId = Convert.ToUInt32(split[1]); } + catch{return;} } #endregion - sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); + sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); doWarp(client, zoneId, privatearea, x, y, z, r); } else if (split.Length == 6) @@ -431,23 +431,23 @@ namespace FFXIVClassic_Lobby_Server y = Single.Parse(split[4]); z = Single.Parse(split[5]); } - catch{return;} - - if (split[1].ToLower().StartsWith("0x")) - { - try { zoneId = Convert.ToUInt32(split[1], 16); } - catch{return;} - } - else - { - try { zoneId = Convert.ToUInt32(split[1]); } - catch{return;} + catch{return;} + + if (split[1].ToLower().StartsWith("0x")) + { + try { zoneId = Convert.ToUInt32(split[1], 16); } + catch{return;} + } + else + { + try { zoneId = Convert.ToUInt32(split[1]); } + catch{return;} } privatearea = split[2]; #endregion - sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); + sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); doWarp(client, zoneId, privatearea, x, y, z, r); } else diff --git a/FFXIVClassic Map Server/PacketProcessor.cs b/FFXIVClassic Map Server/PacketProcessor.cs index 9f922c55..5d04595e 100644 --- a/FFXIVClassic Map Server/PacketProcessor.cs +++ b/FFXIVClassic Map Server/PacketProcessor.cs @@ -188,7 +188,7 @@ namespace FFXIVClassic_Lobby_Server subpacket.debugPrintSubPacket(); client.queuePacket(_0x2Packet.buildPacket(player.actorID), true, false); - Server.getWorldManager().DoLogin(player.getActor()); + Server.GetWorldManager().DoLogin(player.getActor()); break; @@ -267,7 +267,7 @@ namespace FFXIVClassic_Lobby_Server if (ownerActor == null) { //Is it a instance actor? - ownerActor = Server.getWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); + ownerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); if (ownerActor == null) { //Is it a Director? @@ -298,7 +298,7 @@ namespace FFXIVClassic_Lobby_Server Actor updateOwnerActor = Server.getStaticActors(player.getActor().eventCurrentOwner); if (updateOwnerActor == null) { - updateOwnerActor = Server.getWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); + updateOwnerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); if (player.getActor().currentDirector != null && player.getActor().eventCurrentOwner == player.getActor().currentDirector.actorId) updateOwnerActor = player.getActor().currentDirector; diff --git a/FFXIVClassic Map Server/Server.cs b/FFXIVClassic Map Server/Server.cs index 206de92f..4a9e7e44 100644 --- a/FFXIVClassic Map Server/Server.cs +++ b/FFXIVClassic Map Server/Server.cs @@ -83,8 +83,8 @@ namespace FFXIVClassic_Lobby_Server mConnectionHealthThread.Name = "MapThread:Health"; //mConnectionHealthThread.Start(); - mStaticActors = new StaticActors(STATIC_ACTORS_PATH); - + mStaticActors = new StaticActors(STATIC_ACTORS_PATH); + gamedataItems = Database.getItemGamedata(); Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); @@ -95,9 +95,9 @@ namespace FFXIVClassic_Lobby_Server IPEndPoint serverEndPoint = new System.Net.IPEndPoint(IPAddress.Parse(ConfigConstants.OPTIONS_BINDIP), FFXIV_MAP_PORT); - try + try { - mServerSocket = new System.Net.Sockets.Socket(serverEndPoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + mServerSocket = new System.Net.Sockets.Socket(serverEndPoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); } catch (Exception e) { @@ -146,8 +146,8 @@ namespace FFXIVClassic_Lobby_Server private void acceptCallback(IAsyncResult result) { ClientConnection conn = null; - Socket socket = (System.Net.Sockets.Socket)result.AsyncState; - + Socket socket = (System.Net.Sockets.Socket)result.AsyncState; + try { @@ -169,8 +169,8 @@ namespace FFXIVClassic_Lobby_Server catch (SocketException) { if (conn != null) - { - + { + lock (mConnectionList) { mConnectionList.Remove(conn); @@ -181,7 +181,7 @@ namespace FFXIVClassic_Lobby_Server catch (Exception) { if (conn != null) - { + { lock (mConnectionList) { mConnectionList.Remove(conn); @@ -225,7 +225,7 @@ namespace FFXIVClassic_Lobby_Server lock (mConnectionList) { mConnectionList.Remove(conn); - } + } if (conn.connType == BasePacket.TYPE_ZONE) Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); return; @@ -243,36 +243,36 @@ namespace FFXIVClassic_Lobby_Server //Build packets until can no longer or out of data while (true) - { - BasePacket basePacket = buildPacket(ref offset, conn.buffer, bytesRead); - - //If can't build packet, break, else process another - if (basePacket == null) - break; - else - mProcessor.processPacket(conn, basePacket); - } - - //Not all bytes consumed, transfer leftover to beginning + { + BasePacket basePacket = buildPacket(ref offset, conn.buffer, bytesRead); + + //If can't build packet, break, else process another + if (basePacket == null) + break; + else + mProcessor.processPacket(conn, basePacket); + } + + //Not all bytes consumed, transfer leftover to beginning if (offset < bytesRead) Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset); conn.lastPartialSize = bytesRead - offset; //Build any queued subpackets into basepackets and send - conn.flushQueuedSendPackets(); - - if (offset < bytesRead) - //Need offset since not all bytes consumed + conn.flushQueuedSendPackets(); + + if (offset < bytesRead) + //Need offset since not all bytes consumed conn.socket.BeginReceive(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset), SocketFlags.None, new AsyncCallback(receiveCallback), conn); - else - //All bytes consumed, full buffer available + else + //All bytes consumed, full buffer available conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn); } else { - Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); - + Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); + lock (mConnectionList) { mConnectionList.Remove(conn); @@ -280,15 +280,15 @@ namespace FFXIVClassic_Lobby_Server } } catch (SocketException) - { + { if (conn.socket != null) { - Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); - + Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); + lock (mConnectionList) { mConnectionList.Remove(conn); - } + } } } } @@ -326,23 +326,23 @@ namespace FFXIVClassic_Lobby_Server } return newPacket; - } - - #endregion - - public static WorldManager getWorldManager() - { - return mWorldManager; } - public Dictionary getConnectedPlayerList() - { - return mConnectedPlayerList; - } - - public static Dictionary getItemGamedataList() - { - return gamedataItems; - } + #endregion + + public static WorldManager GetWorldManager() + { + return mWorldManager; + } + + public Dictionary getConnectedPlayerList() + { + return mConnectedPlayerList; + } + + public static Dictionary getItemGamedataList() + { + return gamedataItems; + } } } \ No newline at end of file diff --git a/FFXIVClassic Map Server/actors/chara/npc/Npc.cs b/FFXIVClassic Map Server/actors/chara/npc/Npc.cs index e78444cf..9e43c677 100644 --- a/FFXIVClassic Map Server/actors/chara/npc/Npc.cs +++ b/FFXIVClassic Map Server/actors/chara/npc/Npc.cs @@ -49,7 +49,7 @@ namespace FFXIVClassic_Map_Server.Actors { List lParams; - Player player = Server.getWorldManager().GetPCInWorld(playerActorId); + Player player = Server.GetWorldManager().GetPCInWorld(playerActorId); lParams = LuaEngine.doActorOnInstantiate(player, this); if (lParams == null) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index e535cbf0..76d1de0a 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -703,34 +703,34 @@ namespace FFXIVClassic_Map_Server.Actors { if (msgParams.Length == 0) { - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log)); } else - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, string customSender, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams))); } public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, uint displayId, params object[] msgParams) { if (msgParams.Length == 0) - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log)); else - queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); + queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams))); } public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams) diff --git a/FFXIVClassic Map Server/lua/LuaEngine.cs b/FFXIVClassic Map Server/lua/LuaEngine.cs index 27631503..a9d18ee5 100644 --- a/FFXIVClassic Map Server/lua/LuaEngine.cs +++ b/FFXIVClassic Map Server/lua/LuaEngine.cs @@ -43,7 +43,7 @@ namespace FFXIVClassic_Map_Server.lua Script script = new Script(); ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; script.Globals["getStaticActor"] = (Func)Server.getStaticActors; - script.Globals["getWorldMaster"] = (Func)Server.getWorldManager().GetActor; + script.Globals["getWorldMaster"] = (Func)Server.GetWorldManager().GetActor; script.Globals["getItemGamedata"] = (Func)Server.getItemGamedata; script.DoFile(luaPath); DynValue result = script.Call(script.Globals["onInstantiate"], target); @@ -82,9 +82,9 @@ namespace FFXIVClassic_Map_Server.lua { Script script = new Script(); ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; - script.Globals["getWorldManager"] = (Func)Server.getWorldManager; + script.Globals["getWorldManager"] = (Func)Server.GetWorldManager; script.Globals["getStaticActor"] = (Func)Server.getStaticActors; - script.Globals["getWorldMaster"] = (Func)Server.getWorldManager().GetActor; + script.Globals["getWorldMaster"] = (Func)Server.GetWorldManager().GetActor; script.Globals["getItemGamedata"] = (Func)Server.getItemGamedata; script.DoFile(luaPath); @@ -125,9 +125,9 @@ namespace FFXIVClassic_Map_Server.lua { Script script = new Script(); ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; - script.Globals["getWorldManager"] = (Func)Server.getWorldManager; + script.Globals["getWorldManager"] = (Func)Server.GetWorldManager; script.Globals["getStaticActor"] = (Func)Server.getStaticActors; - script.Globals["getWorldMaster"] = (Func)Server.getWorldManager().GetActor; + script.Globals["getWorldMaster"] = (Func)Server.GetWorldManager().GetActor; script.Globals["getItemGamedata"] = (Func)Server.getItemGamedata; script.DoFile(luaPath); @@ -158,9 +158,9 @@ namespace FFXIVClassic_Map_Server.lua { Script script = new Script(); ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; - script.Globals["getWorldManager"] = (Func)Server.getWorldManager; + script.Globals["getWorldManager"] = (Func)Server.GetWorldManager; script.Globals["getStaticActor"] = (Func)Server.getStaticActors; - script.Globals["getWorldMaster"] = (Func)Server.getWorldManager().GetActor; + script.Globals["getWorldMaster"] = (Func)Server.GetWorldManager().GetActor; script.Globals["getItemGamedata"] = (Func)Server.getItemGamedata; script.DoFile(luaPath); @@ -175,9 +175,9 @@ namespace FFXIVClassic_Map_Server.lua { Script script = new Script(); ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; - script.Globals["getWorldManager"] = (Func)Server.getWorldManager; + script.Globals["getWorldManager"] = (Func)Server.GetWorldManager; script.Globals["getStaticActor"] = (Func)Server.getStaticActors; - script.Globals["getWorldMaster"] = (Func)Server.getWorldManager().GetActor; + script.Globals["getWorldMaster"] = (Func)Server.GetWorldManager().GetActor; script.Globals["getItemGamedata"] = (Func)Server.getItemGamedata; script.DoFile(FILEPATH_PLAYER); From 5c7ca212aa2626da1732912eb98136be4f7c89b1 Mon Sep 17 00:00:00 2001 From: TheManii Date: Sat, 9 Apr 2016 12:38:15 -0700 Subject: [PATCH 21/22] 2nd half of previous commit --- FFXIVClassic Map Server/CommandProcessor.cs | 2 +- FFXIVClassic Map Server/Server.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index 2170338e..be11e8ea 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -25,7 +25,7 @@ namespace FFXIVClassic_Lobby_Server { private Dictionary mConnectedPlayerList; private static WorldManager mWorldManager = Server.GetWorldManager(); - private static Dictionary gamedataItems = Server.getItemGamedataList(); + private static Dictionary gamedataItems = Server.GetGamedataItems(); // For the moment, this is the only predefined item // TODO: make a list/enum in the future so that items can be given by name, instead of by id diff --git a/FFXIVClassic Map Server/Server.cs b/FFXIVClassic Map Server/Server.cs index 4a9e7e44..52e6480b 100644 --- a/FFXIVClassic Map Server/Server.cs +++ b/FFXIVClassic Map Server/Server.cs @@ -340,7 +340,7 @@ namespace FFXIVClassic_Lobby_Server return mConnectedPlayerList; } - public static Dictionary getItemGamedataList() + public static Dictionary GetGamedataItems() { return gamedataItems; } From 02e9b52a026b2602c6d9a7ef66be93bc5b543516 Mon Sep 17 00:00:00 2001 From: TheManii Date: Sat, 9 Apr 2016 13:26:46 -0700 Subject: [PATCH 22/22] Fix typo --- FFXIVClassic Map Server/CommandProcessor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index be11e8ea..1e4de7a0 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -393,7 +393,7 @@ namespace FFXIVClassic_Lobby_Server r = client.getActor().rotation; #endregion - sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); + sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, y, z)); doWarp(client, zoneId, privatearea, x, y, z, r); } else if (split.Length == 5) @@ -419,7 +419,7 @@ namespace FFXIVClassic_Lobby_Server } #endregion - sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); + sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, y, z)); doWarp(client, zoneId, privatearea, x, y, z, r); } else if (split.Length == 6) @@ -447,7 +447,7 @@ namespace FFXIVClassic_Lobby_Server privatearea = split[2]; #endregion - sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); + sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, y, z)); doWarp(client, zoneId, privatearea, x, y, z, r); } else