1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-21 20:27:47 +00:00

Save player rotation for relative warps

Make !warp more robust with error handling
This commit is contained in:
TheManii 2016-04-09 11:28:21 -07:00
parent b1a9ced93e
commit 2eb40a0d7c

View file

@ -130,26 +130,30 @@ namespace FFXIVClassic_Lobby_Server
} }
} }
public void doWarp(ConnectedPlayer client, string zone, string privateArea, string sx, string sy, string sz) public void doWarp(ConnectedPlayer client, string zone, string privateArea, float x, float y, float z, float r)
{ {
uint zoneId; uint zoneId;
float x,y,z;
x = Single.Parse(sx);
y = Single.Parse(sy);
z = Single.Parse(sz);
if (zone == null) if (zone == null)
{ {
if (client != null) if (client != null)
mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, 0.0f); mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, r);
} }
else else
{ {
if (zone.ToLower().StartsWith("0x")) if (zone.ToLower().StartsWith("0x"))
zoneId = Convert.ToUInt32(zone, 16); {
else try {zoneId = Convert.ToUInt32(zone, 16);}
zoneId = Convert.ToUInt32(zone); catch (FormatException e)
{return;}
}
else
{
try {zoneId = Convert.ToUInt32(zone);}
catch (FormatException e)
{return;}
}
if (mWorldManager.GetZone(zoneId) == null) if (mWorldManager.GetZone(zoneId) == null)
{ {
@ -159,12 +163,12 @@ namespace FFXIVClassic_Lobby_Server
} }
if (client != null) if (client != null)
mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, r);
else else
{ {
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList) foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{ {
mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, 0.0f); mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, r);
} }
} }
} }
@ -351,62 +355,113 @@ namespace FFXIVClassic_Lobby_Server
} }
} }
private void parseWarp(ConnectedPlayer client, string[] split) private void parseWarp(ConnectedPlayer client, string[] split)
{ {
//bool relx = false, //bool relx = false,
// rely = false, // rely = false,
// relz = false; // relz = false;
float x = 0, float x = 0, y = 0, z = 0, r = 0.0f;
y = 0, string zone = null, privatearea = null;
z = 0;
if (split.Length == 2) // Predefined list if (split.Length == 2) // Predefined list
doWarp(client, split[1]);
else if (split.Length == 4) // X/Y/Z
{ {
#region relativewarp // TODO: Handle !warp Playername
if (split[1].StartsWith("@")) doWarp(client, split[1]);
{ }
//relx = true; else if (split.Length == 4)
split[1] = split[1].Replace("@", string.Empty); {
#region !warp X Y Z
if (String.IsNullOrEmpty(split[1])) if (split[1].StartsWith("@"))
split[1] = "0"; {
//relx = true;
x = Single.Parse(split[1]) + client.getActor().positionX; split[1] = split[1].Replace("@", string.Empty);
split[1] = x.ToString();
} if (String.IsNullOrEmpty(split[1]))
if (split[2].StartsWith("@")) split[1] = "0";
{
//rely = true; try { x = Single.Parse(split[1]) + client.getActor().positionX; }
split[2] = split[2].Replace("@", string.Empty); catch (FormatException e)
{ return; }
if (String.IsNullOrEmpty(split[2])) split[1] = x.ToString();
split[2] = "0"; }
if (split[2].StartsWith("@"))
y = Single.Parse(split[2]) + client.getActor().positionY; {
split[2] = y.ToString(); //rely = true;
} split[2] = split[2].Replace("@", string.Empty);
if (split[3].StartsWith("@"))
{ if (String.IsNullOrEmpty(split[2]))
//relz = true; split[2] = "0";
split[3] = split[3].Replace("@", string.Empty);
try { y = Single.Parse(split[2]) + client.getActor().positionY; }
if (String.IsNullOrEmpty(split[3])) catch (FormatException e)
{ return; }
split[2] = y.ToString();
}
if (split[3].StartsWith("@"))
{
//relz = true;
split[3] = split[3].Replace("@", string.Empty);
if (String.IsNullOrEmpty(split[3]))
split[3] = "0"; split[3] = "0";
z = Single.Parse(split[3]) + client.getActor().positionZ; try { z = Single.Parse(split[3]) + client.getActor().positionZ; }
split[3] = z.ToString(); catch (FormatException e)
{ return; }
split[3] = z.ToString();
} }
#endregion
//sendMessage(client, String.Format("relx: {0}, rely: {1}, relz: {2}, x: {3}, y: {4}, z: {5}, fx: {6}, fy: {7}, fz: {8}", relx, rely, relz, split[1], split[2], split[3], x, y ,z)); try
{
x = Single.Parse(split[1]);
y = Single.Parse(split[2]);
z = Single.Parse(split[3]);
}
catch (FormatException e)
{ return; }
r = client.getActor().rotation;
//sendMessage(client, String.Format("relx: {0}, rely: {1}, relz: {2}, x: {3}, y: {4}, z: {5}, fx: {6}, fy: {7}, fz: {8}", relx, rely, relz, split[1], split[2], split[3], x, y ,z));
sendMessage(client, String.Format("Warping to: X: {0}, Y: {1}, Z: {2}", split[1], split[2], split[3])); sendMessage(client, String.Format("Warping to: X: {0}, Y: {1}, Z: {2}", split[1], split[2], split[3]));
doWarp(client, null, null, split[1], split[2], split[3]); #endregion
} }
else if (split.Length == 5) // Zone + X/Y/Z else if (split.Length == 5)
doWarp(client, split[1], null, split[2], split[3], split[4]); {
else if (split.Length == 6) // Zone + instance + X/Y/Z #region !warp Zone X Y Z
doWarp(client, split[1], split[2], split[3], split[4], split[5]); try
{
x = Single.Parse(split[2]);
y = Single.Parse(split[3]);
z = Single.Parse(split[4]);
}
catch (FormatException e)
{ return; }
zone = split[1];
#endregion
}
else if (split.Length == 6)
{
#region !warp Zone Instance X Y Z
try
{
x = Single.Parse(split[3]);
y = Single.Parse(split[4]);
z = Single.Parse(split[5]);
}
catch (FormatException e)
{ return; }
zone = split[1];
privatearea = split[2];
#endregion
}
else
return; // catch any invalid warps here
doWarp(client, zone, privatearea, x, y, z, r);
} }
/// <summary> /// <summary>
@ -696,7 +751,7 @@ namespace FFXIVClassic_Lobby_Server
#region !warp #region !warp
else if (split[0].Equals("warp")) else if (split[0].Equals("warp"))
{ {
parseWarp(client, split); parseWarp(client, split);
return true; return true;
} }