1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-22 20:57: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.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<uint, ConnectedPlayer> mConnectedPlayerList;
private static WorldManager mWorldManager = Server.getWorldManager();
private static Dictionary<uint, Item> 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<uint, Item> 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<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)
{
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<uint, ConnectedPlayer> 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<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);
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;
}

View file

@ -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);