1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-23 05:07:47 +00:00

Surrounded command chain with region boxes

Changed doWarp() to handle in implicit, in-zone only warps

Might have issues with instanced zones, untested
This commit is contained in:
TheManii 2016-04-07 12:25:28 -07:00
parent b17d193a59
commit ecc61ea5f9
2 changed files with 154 additions and 83 deletions

View file

@ -16,19 +16,19 @@ using FFXIVClassic_Map_Server.packets.send;
using FFXIVClassic_Map_Server.dataobjects.chara; using FFXIVClassic_Map_Server.dataobjects.chara;
using FFXIVClassic_Map_Server.Actors; using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.lua; using FFXIVClassic_Map_Server.lua;
using FFXIVClassic_Map_Server.actors.chara.player; using FFXIVClassic_Map_Server.actors.chara.player;
using FFXIVClassic_Map_Server.Properties; using FFXIVClassic_Map_Server.Properties;
namespace FFXIVClassic_Lobby_Server namespace FFXIVClassic_Lobby_Server
{ {
class CommandProcessor class CommandProcessor
{ {
private Dictionary<uint, ConnectedPlayer> mConnectedPlayerList; private Dictionary<uint, ConnectedPlayer> mConnectedPlayerList;
private static WorldManager mWorldManager = Server.getWorldManager(); private static WorldManager mWorldManager = Server.getWorldManager();
private static Dictionary<uint, Item> gamedataItems = Server.getItemGamedataList(); private static Dictionary<uint, Item> gamedataItems = Server.getItemGamedataList();
// For the moment, this is the only predefined item // 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 // 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; const UInt32 ITEM_GIL = 1000001;
public CommandProcessor(Dictionary<uint, ConnectedPlayer> playerList) public CommandProcessor(Dictionary<uint, ConnectedPlayer> playerList)
@ -95,6 +95,11 @@ namespace FFXIVClassic_Lobby_Server
} }
} }
/// <summary>
/// Teleports player to a location on a predefined list
/// </summary>
/// <param name="client">The current player</param>
/// <param name="entranceId">Predefined list: &lt;ffxiv_database&gt;\server_zones_spawnlocations</param>
public void doWarp(ConnectedPlayer client, string entranceId) public void doWarp(ConnectedPlayer client, string entranceId)
{ {
uint id; 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) public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz)
{ {
uint zoneId; uint zoneId;
float x,y,z; 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); x = Single.Parse(sx);
y = Single.Parse(sy); y = Single.Parse(sy);
z = Single.Parse(sz); z = Single.Parse(sz);
if (client != null) if (zone == null)
mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); {
else if (client != null)
{ mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, 0.0f);
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList) }
{ else
mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); {
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<uint, ConnectedPlayer> 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); input = input.Substring(1);
String[] split = input.Split(' '); String[] split = input.Split(' ');
split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands
// Debug // Debug
//sendMessage(client, string.Join(",", split)); //sendMessage(client, string.Join(",", split));
if (split.Length >= 1) if (split.Length >= 1)
{ {
#region !help
if (split[0].Equals("help")) if (split[0].Equals("help"))
{ {
if (split.Length == 1) if (split.Length == 1)
{ {
sendMessage(client, Resources.CPhelp); sendMessage(client, Resources.CPhelp);
} }
if (split.Length == 2) if (split.Length == 2)
@ -378,7 +392,7 @@ namespace FFXIVClassic_Lobby_Server
sendMessage(client, Resources.CPmusic); sendMessage(client, Resources.CPmusic);
else if (split[1].Equals("warp")) else if (split[1].Equals("warp"))
sendMessage(client, Resources.CPwarp); sendMessage(client, Resources.CPwarp);
else if (split[1].Equals("givecurrency")) else if (split[1].Equals("givecurrency"))
sendMessage(client, Resources.CPgivecurrency); sendMessage(client, Resources.CPgivecurrency);
else if (split[1].Equals("giveitem")) else if (split[1].Equals("giveitem"))
sendMessage(client, Resources.CPgiveitem); sendMessage(client, Resources.CPgiveitem);
@ -392,22 +406,25 @@ namespace FFXIVClassic_Lobby_Server
sendMessage(client, Resources.CPremovekeyitem); sendMessage(client, Resources.CPremovekeyitem);
else if (split[1].Equals("reloaditems")) else if (split[1].Equals("reloaditems"))
sendMessage(client, Resources.CPreloaditems); sendMessage(client, Resources.CPreloaditems);
else if (split[1].Equals("reloadzones")) else if (split[1].Equals("reloadzones"))
sendMessage(client, Resources.CPreloadzones); sendMessage(client, Resources.CPreloadzones);
/* /*
else if (split[1].Equals("property")) else if (split[1].Equals("property"))
sendMessage(client, Resources.CPproperty); sendMessage(client, Resources.CPproperty);
else if (split[1].Equals("property2")) else if (split[1].Equals("property2"))
sendMessage(client, Resources.CPproperty2); sendMessage(client, Resources.CPproperty2);
else if (split[1].Equals("sendpacket")) else if (split[1].Equals("sendpacket"))
sendMessage(client, Resources.CPsendpacket); sendMessage(client, Resources.CPsendpacket);
else if (split[1].Equals("setgraphic")) else if (split[1].Equals("setgraphic"))
sendMessage(client, Resources.CPsetgraphic); sendMessage(client, Resources.CPsetgraphic);
*/ */
} }
return true; return true;
} }
#endregion
#region !mypos
else if (split[0].Equals("mypos")) else if (split[0].Equals("mypos"))
{ {
try try
@ -419,7 +436,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not load packet: " + e); Log.error("Could not load packet: " + e);
} }
} }
#endregion
#region !reloadzones
else if (split[0].Equals("reloadzones")) else if (split[0].Equals("reloadzones"))
{ {
if (client != null) if (client != null)
@ -432,7 +452,10 @@ namespace FFXIVClassic_Lobby_Server
} }
mWorldManager.reloadZone(client.getActor().zoneId); mWorldManager.reloadZone(client.getActor().zoneId);
return true; return true;
} }
#endregion
#region !reloaditems
else if (split[0].Equals("reloaditems")) else if (split[0].Equals("reloaditems"))
{ {
Log.info(String.Format("Got request to reload item gamedata")); Log.info(String.Format("Got request to reload item gamedata"));
@ -444,7 +467,10 @@ namespace FFXIVClassic_Lobby_Server
if (client != null) if (client != null)
client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Loaded {0} items.", gamedataItems.Count))); client.getActor().queuePacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Loaded {0} items.", gamedataItems.Count)));
return true; return true;
} }
#endregion
#region !sendpacket
else if (split[0].Equals("sendpacket")) else if (split[0].Equals("sendpacket"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -459,7 +485,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not load packet: " + e); Log.error("Could not load packet: " + e);
} }
} }
#endregion
#region !graphic
else if (split[0].Equals("graphic")) else if (split[0].Equals("graphic"))
{ {
try try
@ -472,7 +501,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give item."); Log.error("Could not give item.");
} }
} }
#endregion
#region !giveitem
else if (split[0].Equals("giveitem")) else if (split[0].Equals("giveitem"))
{ {
try try
@ -489,7 +521,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give item."); Log.error("Could not give item.");
} }
} }
#endregion
#region !removeitem
else if (split[0].Equals("removeitem")) else if (split[0].Equals("removeitem"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -509,7 +544,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not remove item."); Log.error("Could not remove item.");
} }
} }
#endregion
#region !givekeyitem
else if (split[0].Equals("givekeyitem")) else if (split[0].Equals("givekeyitem"))
{ {
try try
@ -521,7 +559,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give keyitem."); Log.error("Could not give keyitem.");
} }
} }
#endregion
#region !removekeyitem
else if (split[0].Equals("removekeyitem")) else if (split[0].Equals("removekeyitem"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -537,7 +578,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not remove keyitem."); Log.error("Could not remove keyitem.");
} }
} }
#endregion
#region !givecurrency
else if (split[0].Equals("givecurrency")) else if (split[0].Equals("givecurrency"))
{ {
try try
@ -551,7 +595,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give currency."); Log.error("Could not give currency.");
} }
} }
#endregion
#region !removecurrency
else if (split[0].Equals("removecurrency")) else if (split[0].Equals("removecurrency"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -569,7 +616,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not remove currency."); Log.error("Could not remove currency.");
} }
} }
#endregion
#region !music
else if (split[0].Equals("music")) else if (split[0].Equals("music"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -584,17 +634,25 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not change music: " + e); Log.error("Could not change music: " + e);
} }
} }
#endregion
#region !warp
else if (split[0].Equals("warp")) else if (split[0].Equals("warp"))
{ {
if (split.Length == 2) if (split.Length == 2) // Predefined list
doWarp(client, split[1]); doWarp(client, split[1]);
else if (split.Length == 5) 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]); 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]); doWarp(client, split[1], split[2], split[3], split[4], split[5]);
return true; return true;
} }
#endregion
#region !property
else if (split[0].Equals("property")) else if (split[0].Equals("property"))
{ {
if (split.Length == 4) 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]); changeProperty(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]);
} }
return true; return true;
} }
#endregion
#region !property2
else if (split[0].Equals("property2")) else if (split[0].Equals("property2"))
{ {
if (split.Length == 4) 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]); changeProperty(Convert.ToUInt32(split[1], 16), Convert.ToUInt32(split[2], 16), split[3]);
} }
return true; return true;
} }
#endregion
} }
return false; return false;
} }

View file

@ -372,26 +372,35 @@ namespace FFXIVClassic_Map_Server
} }
//Add player to new zone and update //Add player to new zone and update
Area newArea; Area newArea;
if (destinationPrivateArea == null) if (destinationZoneId != 0)
newArea = GetZone(destinationZoneId); {
if (destinationPrivateArea == null)
newArea = GetZone(destinationZoneId);
else
newArea = GetZone(destinationZoneId).getPrivateArea(destinationPrivateArea, 0);
}
else 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 //This server does not contain that zoneId
if (newArea == null) if (newArea == null)
return; return;
newArea.addActorToZone(player); newArea.addActorToZone(player);
//Update player actor's properties //Update player actor's properties
player.zoneId = newArea.actorId; player.zoneId = newArea.actorId;
player.zone = newArea; player.zone = newArea;
player.positionX = spawnX; player.positionX = spawnX;
player.positionY = spawnY; player.positionY = spawnY;
player.positionZ = spawnZ; player.positionZ = spawnZ;
player.rotation = spawnRotation; player.rotation = spawnRotation;
//Send packets //Send packets
player.playerSession.queuePacket(DeleteAllActorsPacket.buildPacket(player.actorId), true, false); player.playerSession.queuePacket(DeleteAllActorsPacket.buildPacket(player.actorId), true, false);