From 7a8e53a8acd4ce9e0ed51b8883632f02fd238e47 Mon Sep 17 00:00:00 2001 From: TheManii Date: Tue, 5 Apr 2016 16:06:38 -0700 Subject: [PATCH 01/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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