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

*Revert changes to worldmanager.cs, not needed anymore

*Made !warp silently catch all exceptions so they dont crash server/don't change player state if invalid
*Moved rest of !warp parsing logic into parseWarp(), doWarp() now purely handles actual act of warping
This commit is contained in:
TheManii 2016-04-09 12:27:04 -07:00
parent 2eb40a0d7c
commit 06606c5f01
2 changed files with 119 additions and 139 deletions

View file

@ -99,77 +99,41 @@ namespace FFXIVClassic_Lobby_Server
/// Teleports player to a location on a predefined list /// Teleports player to a location on a predefined list
/// </summary> /// </summary>
/// <param name="client">The current player</param> /// <param name="client">The current player</param>
/// <param name="entranceId">Predefined list: &lt;ffxiv_database&gt;\server_zones_spawnlocations</param> /// <param name="id">Predefined list: &lt;ffxiv_database&gt;\server_zones_spawnlocations</param>
public void doWarp(ConnectedPlayer client, string entranceId) public void doWarp(ConnectedPlayer client, uint id)
{ {
uint id;
try
{
if (entranceId.ToLower().StartsWith("0x"))
id = Convert.ToUInt32(entranceId, 16);
else
id = Convert.ToUInt32(entranceId);
}
catch(FormatException e)
{return;}
FFXIVClassic_Map_Server.WorldManager.ZoneEntrance ze = mWorldManager.getZoneEntrance(id); FFXIVClassic_Map_Server.WorldManager.ZoneEntrance ze = mWorldManager.getZoneEntrance(id);
if (ze == null) if (ze == null)
return; return;
if (client != null) if (client != null)
mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation);
else else
{ {
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList) foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{ {
mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, 0.0f); mWorldManager.DoZoneChange(entry.Value.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation);
} }
} }
} }
public void doWarp(ConnectedPlayer client, string zone, string privateArea, float x, float y, float z, float r) public void doWarp(ConnectedPlayer client, uint zoneId, string privateArea, float x, float y, float z, float r)
{ {
uint zoneId; if (mWorldManager.GetZone(zoneId) == null)
if (zone == null)
{ {
if (client != null) if (client != null)
mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, r); client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Zone does not exist or setting isn't valid."), true, false));
Log.error("Zone does not exist or setting isn't valid.");
} }
if (client != null)
mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, r);
else else
{ {
if (zone.ToLower().StartsWith("0x")) foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{
try {zoneId = Convert.ToUInt32(zone, 16);}
catch (FormatException e)
{return;}
}
else
{
try {zoneId = Convert.ToUInt32(zone);}
catch (FormatException e)
{return;}
}
if (mWorldManager.GetZone(zoneId) == null)
{ {
if (client != null) mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, r);
client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Zone does not exist or setting isn't valid."), true, false));
Log.error("Zone does not exist or setting isn't valid.");
}
if (client != null)
mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, r);
else
{
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{
mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, r);
}
} }
} }
} }
@ -357,111 +321,137 @@ namespace FFXIVClassic_Lobby_Server
private void parseWarp(ConnectedPlayer client, string[] split) private void parseWarp(ConnectedPlayer client, string[] split)
{ {
//bool relx = false, float x = 0, y = 0, z = 0, r = 0.0f;
// rely = false, uint zoneId = 0;
// relz = false; string privatearea = null;
float x = 0, y = 0, z = 0, r = 0.0f;
string zone = null, privatearea = null;
if (split.Length == 2) // Predefined list
if (split.Length == 2) // Predefined list
{ {
// TODO: Handle !warp Playername // TODO: Handle !warp Playername
doWarp(client, split[1]); #region !warp (predefined list)
try
{
if (split[1].ToLower().StartsWith("0x"))
zoneId = Convert.ToUInt32(split[1], 16);
else
zoneId = Convert.ToUInt32(split[1]);
}
catch{return;}
#endregion
doWarp(client, zoneId);
} }
else if (split.Length == 4) else if (split.Length == 4)
{ {
#region !warp X Y Z #region !warp X Y Z
if (split[1].StartsWith("@")) if (split[1].StartsWith("@"))
{ {
//relx = true;
split[1] = split[1].Replace("@", string.Empty); split[1] = split[1].Replace("@", string.Empty);
if (String.IsNullOrEmpty(split[1])) if (String.IsNullOrEmpty(split[1]))
split[1] = "0"; split[1] = "0";
try { x = Single.Parse(split[1]) + client.getActor().positionX; } try { x = Single.Parse(split[1]) + client.getActor().positionX; }
catch (FormatException e) catch{return;}
{ return; }
split[1] = x.ToString(); split[1] = x.ToString();
} }
if (split[2].StartsWith("@")) if (split[2].StartsWith("@"))
{ {
//rely = true;
split[2] = split[2].Replace("@", string.Empty); split[2] = split[2].Replace("@", string.Empty);
if (String.IsNullOrEmpty(split[2])) if (String.IsNullOrEmpty(split[2]))
split[2] = "0"; split[2] = "0";
try { y = Single.Parse(split[2]) + client.getActor().positionY; } try { y = Single.Parse(split[2]) + client.getActor().positionY; }
catch (FormatException e) catch{return;}
{ return; }
split[2] = y.ToString(); split[2] = y.ToString();
} }
if (split[3].StartsWith("@")) if (split[3].StartsWith("@"))
{ {
//relz = true;
split[3] = split[3].Replace("@", string.Empty); split[3] = split[3].Replace("@", string.Empty);
if (String.IsNullOrEmpty(split[3])) if (String.IsNullOrEmpty(split[3]))
split[3] = "0"; split[3] = "0";
try { z = Single.Parse(split[3]) + client.getActor().positionZ; } try { z = Single.Parse(split[3]) + client.getActor().positionZ; }
catch (FormatException e) catch{return;}
{ return; }
split[3] = z.ToString(); split[3] = z.ToString();
} }
try
{
x = Single.Parse(split[1]);
y = Single.Parse(split[2]);
z = Single.Parse(split[3]);
}
catch (FormatException e)
{ return; }
try
{
x = Single.Parse(split[1]);
y = Single.Parse(split[2]);
z = Single.Parse(split[3]);
}
catch{return;}
zoneId = client.getActor().zoneId;
r = client.getActor().rotation; r = client.getActor().rotation;
//sendMessage(client, String.Format("relx: {0}, rely: {1}, relz: {2}, x: {3}, y: {4}, z: {5}, fx: {6}, fy: {7}, fz: {8}", relx, rely, relz, split[1], split[2], split[3], x, y ,z));
sendMessage(client, String.Format("Warping to: X: {0}, Y: {1}, Z: {2}", split[1], split[2], split[3]));
#endregion #endregion
sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y));
doWarp(client, zoneId, privatearea, x, y, z, r);
} }
else if (split.Length == 5) else if (split.Length == 5)
{ {
#region !warp Zone X Y Z #region !warp Zone X Y Z
try try
{ {
x = Single.Parse(split[2]); x = Single.Parse(split[2]);
y = Single.Parse(split[3]); y = Single.Parse(split[3]);
z = Single.Parse(split[4]); z = Single.Parse(split[4]);
} }
catch (FormatException e) catch{return;}
{ return; }
zone = split[1]; if (split[1].ToLower().StartsWith("0x"))
#endregion {
try { zoneId = Convert.ToUInt32(split[1], 16); }
catch{return;}
}
else
{
try { zoneId = Convert.ToUInt32(split[1]); }
catch{return;}
}
#endregion
sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y));
doWarp(client, zoneId, privatearea, x, y, z, r);
} }
else if (split.Length == 6) else if (split.Length == 6)
{ {
#region !warp Zone Instance X Y Z #region !warp Zone Instance X Y Z
try try
{ {
x = Single.Parse(split[3]); x = Single.Parse(split[3]);
y = Single.Parse(split[4]); y = Single.Parse(split[4]);
z = Single.Parse(split[5]); z = Single.Parse(split[5]);
} }
catch (FormatException e) catch{return;}
{ return; }
zone = split[1]; if (split[1].ToLower().StartsWith("0x"))
privatearea = split[2]; {
#endregion try { zoneId = Convert.ToUInt32(split[1], 16); }
catch{return;}
}
else
{
try { zoneId = Convert.ToUInt32(split[1]); }
catch{return;}
}
privatearea = split[2];
#endregion
sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y));
doWarp(client, zoneId, privatearea, x, y, z, r);
} }
else else
return; // catch any invalid warps here return; // catch any invalid warps here
doWarp(client, zone, privatearea, x, y, z, r);
} }
/// <summary> /// <summary>

View file

@ -372,35 +372,25 @@ namespace FFXIVClassic_Map_Server
} }
//Add player to new zone and update //Add player to new zone and update
Area newArea; Area newArea;
if (destinationZoneId != 0) if (destinationPrivateArea == null)
{ 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);