mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04: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:
		| @@ -99,77 +99,41 @@ namespace FFXIVClassic_Lobby_Server | ||||
|         /// Teleports player to a location on a predefined list | ||||
|         /// </summary> | ||||
|         /// <param name="client">The current player</param> | ||||
|         /// <param name="entranceId">Predefined list: <ffxiv_database>\server_zones_spawnlocations</param> | ||||
|         public void doWarp(ConnectedPlayer client, string entranceId) | ||||
|         /// <param name="id">Predefined list: <ffxiv_database>\server_zones_spawnlocations</param> | ||||
|         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); | ||||
|  | ||||
|             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); | ||||
|                 mWorldManager.DoZoneChange(client.getActor(), ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation); | ||||
|             else | ||||
|             { | ||||
|                 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 (zone == null) | ||||
|             if (mWorldManager.GetZone(zoneId) == 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 | ||||
|             { | ||||
|                 if (zone.ToLower().StartsWith("0x")) | ||||
|                 { | ||||
|                     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) | ||||
|                 foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList) | ||||
|                 { | ||||
|                     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, r); | ||||
|                 else | ||||
|                 { | ||||
|                     foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList) | ||||
|                     { | ||||
|                         mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, r); | ||||
|                     } | ||||
|                     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) | ||||
|         { | ||||
|             //bool relx = false, | ||||
|             //     rely = false,  | ||||
|             //     relz = false; | ||||
|             float x = 0, y = 0, z = 0, r = 0.0f; | ||||
|             string zone = null, privatearea = null; | ||||
|             float x = 0, y = 0, z = 0, r = 0.0f; | ||||
|             uint zoneId = 0; | ||||
|             string privatearea = null; | ||||
|  | ||||
|  | ||||
|             if (split.Length == 2) // Predefined list | ||||
|             if (split.Length == 2) // Predefined list | ||||
|             { | ||||
|                 // 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 | ||||
|                 if (split[1].StartsWith("@")) | ||||
|                 { | ||||
|                     //relx = true; | ||||
|                     split[1] = split[1].Replace("@", string.Empty); | ||||
|  | ||||
|                     if (String.IsNullOrEmpty(split[1])) | ||||
|                         split[1] = "0"; | ||||
|  | ||||
|                     try { x = Single.Parse(split[1]) + client.getActor().positionX; } | ||||
|                     catch (FormatException e) | ||||
|                     { return; } | ||||
|                     split[1] = x.ToString(); | ||||
|                     catch{return;} | ||||
|  | ||||
|                     split[1] = x.ToString(); | ||||
|                 } | ||||
|                 if (split[2].StartsWith("@")) | ||||
|                 { | ||||
|                     //rely = true; | ||||
|                     split[2] = split[2].Replace("@", string.Empty); | ||||
|  | ||||
|                     if (String.IsNullOrEmpty(split[2])) | ||||
|                         split[2] = "0"; | ||||
|  | ||||
|                     try { y = Single.Parse(split[2]) + client.getActor().positionY; } | ||||
|                     catch (FormatException e) | ||||
|                     { return; } | ||||
|                     split[2] = y.ToString(); | ||||
|                     try { y = Single.Parse(split[2]) + client.getActor().positionY; } | ||||
|                     catch{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"; | ||||
|  | ||||
|                     try { z = Single.Parse(split[3]) + client.getActor().positionZ; } | ||||
|                     catch (FormatException e) | ||||
|                     { return; } | ||||
|                         split[3] = "0"; | ||||
|  | ||||
|                     try { z = Single.Parse(split[3]) + client.getActor().positionZ; } | ||||
|                     catch{return;} | ||||
|  | ||||
|                     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; | ||||
|  | ||||
|                 //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 | ||||
|  | ||||
|                 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) | ||||
|             { | ||||
|                 #region !warp Zone X Y Z | ||||
|                 try | ||||
|                 { | ||||
|                     x = Single.Parse(split[2]); | ||||
|                     y = Single.Parse(split[3]); | ||||
|                     z = Single.Parse(split[4]); | ||||
|                 } | ||||
|                 catch (FormatException e) | ||||
|                 { return; } | ||||
|             else if (split.Length == 5) | ||||
|             { | ||||
|                 #region !warp Zone X Y Z | ||||
|                 try | ||||
|                 { | ||||
|                     x = Single.Parse(split[2]); | ||||
|                     y = Single.Parse(split[3]); | ||||
|                     z = Single.Parse(split[4]); | ||||
|                 } | ||||
|                 catch{return;} | ||||
|  | ||||
|                 zone = split[1]; | ||||
|                 #endregion | ||||
|                 if (split[1].ToLower().StartsWith("0x")) | ||||
|                 { | ||||
|                     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) | ||||
|             { | ||||
|                 #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; } | ||||
|             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{return;} | ||||
|  | ||||
|                 zone = split[1]; | ||||
|                 privatearea = split[2]; | ||||
|                 #endregion | ||||
|                 if (split[1].ToLower().StartsWith("0x")) | ||||
|                 { | ||||
|                     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 | ||||
|                 return; // catch any invalid warps here | ||||
|  | ||||
|             doWarp(client, zone, privatearea, x, y, z, r); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|   | ||||
| @@ -372,35 +372,25 @@ namespace FFXIVClassic_Map_Server | ||||
|             } | ||||
|  | ||||
|             //Add player to new zone and update | ||||
|             Area newArea; | ||||
|  | ||||
|             if (destinationZoneId != 0) | ||||
|             { | ||||
|                 if (destinationPrivateArea == null) | ||||
|                     newArea = GetZone(destinationZoneId); | ||||
|                 else | ||||
|                     newArea = GetZone(destinationZoneId).getPrivateArea(destinationPrivateArea, 0); | ||||
|             } | ||||
|             Area newArea; | ||||
|  | ||||
|             if (destinationPrivateArea == null) | ||||
|                 newArea = GetZone(destinationZoneId); | ||||
|             else | ||||
|             { | ||||
|                 if (destinationPrivateArea == null) | ||||
|                     newArea = GetZone(player.zoneId); | ||||
|                 else | ||||
|                     newArea = GetZone(player.zoneId).getPrivateArea(destinationPrivateArea, 0); | ||||
|             } | ||||
|                 newArea = GetZone(destinationZoneId).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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user