mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-23 13:17:45 +00:00
Merge in Relative warps
This commit is contained in:
commit
10d4d7c148
9 changed files with 290 additions and 201 deletions
|
@ -24,8 +24,8 @@ 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();
|
||||
private static WorldManager mWorldManager = Server.GetWorldManager();
|
||||
private static Dictionary<uint, Item> gamedataItems = Server.GetGamedataItems();
|
||||
|
||||
// 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
|
||||
|
@ -95,77 +95,45 @@ 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: <ffxiv_database>\server_zones_spawnlocations</param>
|
||||
public void doWarp(ConnectedPlayer client, string entranceId)
|
||||
/// <summary>
|
||||
/// Teleports player to a location on a predefined list
|
||||
/// </summary>
|
||||
/// <param name="client">The current player</param>
|
||||
/// <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, string sx, string sy, string sz)
|
||||
public void doWarp(ConnectedPlayer client, uint zoneId, string privateArea, float x, float y, float z, float r)
|
||||
{
|
||||
uint zoneId;
|
||||
float x,y,z;
|
||||
|
||||
x = Single.Parse(sx);
|
||||
y = Single.Parse(sy);
|
||||
z = Single.Parse(sz);
|
||||
|
||||
if (zone == null)
|
||||
{
|
||||
if (client != null)
|
||||
mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, 0.0f);
|
||||
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.");
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,6 +319,141 @@ namespace FFXIVClassic_Lobby_Server
|
|||
}
|
||||
}
|
||||
|
||||
private void parseWarp(ConnectedPlayer client, string[] split)
|
||||
{
|
||||
float x = 0, y = 0, z = 0, r = 0.0f;
|
||||
uint zoneId = 0;
|
||||
string privatearea = null;
|
||||
|
||||
if (split.Length == 2) // Predefined list
|
||||
{
|
||||
// TODO: Handle !warp Playername
|
||||
#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)
|
||||
{
|
||||
#region !warp X Y Z
|
||||
if (split[1].StartsWith("@"))
|
||||
{
|
||||
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{return;}
|
||||
|
||||
split[1] = x.ToString();
|
||||
}
|
||||
if (split[2].StartsWith("@"))
|
||||
{
|
||||
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{return;}
|
||||
|
||||
split[2] = y.ToString();
|
||||
}
|
||||
if (split[3].StartsWith("@"))
|
||||
{
|
||||
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{return;}
|
||||
|
||||
split[3] = z.ToString();
|
||||
}
|
||||
|
||||
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;
|
||||
#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{return;}
|
||||
|
||||
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{return;}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We only use the default options for SendMessagePacket.
|
||||
/// May as well make it less unwieldly to view
|
||||
|
@ -370,11 +473,11 @@ namespace FFXIVClassic_Lobby_Server
|
|||
input = input.Substring(1);
|
||||
|
||||
String[] split = input.Split(' ');
|
||||
split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands
|
||||
split = split.Where(temp => temp != "").ToArray(); // strips extra whitespace from commands
|
||||
|
||||
// Debug
|
||||
//sendMessage(client, string.Join(",", split));
|
||||
split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands
|
||||
split = split.Where(temp => temp != "").ToArray(); // strips extra whitespace from commands
|
||||
|
||||
// Debug
|
||||
//sendMessage(client, string.Join(",", split));
|
||||
|
||||
if (split.Length >= 1)
|
||||
{
|
||||
|
@ -422,9 +525,9 @@ namespace FFXIVClassic_Lobby_Server
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region !mypos
|
||||
else if (split[0].Equals("mypos"))
|
||||
{
|
||||
|
@ -437,9 +540,9 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Log.error("Could not load packet: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region !reloadzones
|
||||
else if (split[0].Equals("reloadzones"))
|
||||
{
|
||||
|
@ -453,9 +556,9 @@ namespace FFXIVClassic_Lobby_Server
|
|||
}
|
||||
mWorldManager.reloadZone(client.getActor().zoneId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region !reloaditems
|
||||
else if (split[0].Equals("reloaditems"))
|
||||
{
|
||||
|
@ -466,9 +569,9 @@ namespace FFXIVClassic_Lobby_Server
|
|||
Log.info(String.Format("Loaded {0} items.", gamedataItems.Count));
|
||||
sendMessage(client, String.Format("Loaded {0} items.", gamedataItems.Count));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region !sendpacket
|
||||
else if (split[0].Equals("sendpacket"))
|
||||
{
|
||||
|
@ -484,9 +587,9 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Log.error("Could not load packet: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region !graphic
|
||||
else if (split[0].Equals("graphic"))
|
||||
{
|
||||
|
@ -500,9 +603,9 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Log.error("Could not give item.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region !giveitem
|
||||
else if (split[0].Equals("giveitem"))
|
||||
{
|
||||
|
@ -520,10 +623,10 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Log.error("Could not give item.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region !removeitem
|
||||
|
||||
#region !removeitem
|
||||
else if (split[0].Equals("removeitem"))
|
||||
{
|
||||
if (split.Length < 2)
|
||||
|
@ -543,10 +646,10 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Log.error("Could not remove item.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region !givekeyitem
|
||||
|
||||
#region !givekeyitem
|
||||
else if (split[0].Equals("givekeyitem"))
|
||||
{
|
||||
try
|
||||
|
@ -558,10 +661,10 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Log.error("Could not give keyitem.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region !removekeyitem
|
||||
|
||||
#region !removekeyitem
|
||||
else if (split[0].Equals("removekeyitem"))
|
||||
{
|
||||
if (split.Length < 2)
|
||||
|
@ -577,10 +680,10 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Log.error("Could not remove keyitem.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region !givecurrency
|
||||
|
||||
#region !givecurrency
|
||||
else if (split[0].Equals("givecurrency"))
|
||||
{
|
||||
try
|
||||
|
@ -594,10 +697,10 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Log.error("Could not give currency.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region !removecurrency
|
||||
|
||||
#region !removecurrency
|
||||
else if (split[0].Equals("removecurrency"))
|
||||
{
|
||||
if (split.Length < 2)
|
||||
|
@ -615,9 +718,9 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Log.error("Could not remove currency.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region !music
|
||||
else if (split[0].Equals("music"))
|
||||
{
|
||||
|
@ -633,24 +736,17 @@ namespace FFXIVClassic_Lobby_Server
|
|||
{
|
||||
Log.error("Could not change music: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region !warp
|
||||
else if (split[0].Equals("warp"))
|
||||
{
|
||||
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) // Zone + instance + X/Y/Z
|
||||
doWarp(client, split[1], split[2], split[3], split[4], split[5]);
|
||||
parseWarp(client, split);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region !property
|
||||
else if (split[0].Equals("property"))
|
||||
{
|
||||
|
@ -659,9 +755,9 @@ 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"))
|
||||
{
|
||||
|
@ -670,7 +766,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
changeProperty(Convert.ToUInt32(split[1], 16), Convert.ToUInt32(split[2], 16), split[3]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
subpacket.debugPrintSubPacket();
|
||||
client.queuePacket(_0x2Packet.buildPacket(player.actorID), true, false);
|
||||
|
||||
Server.getWorldManager().DoLogin(player.getActor());
|
||||
Server.GetWorldManager().DoLogin(player.getActor());
|
||||
|
||||
|
||||
break;
|
||||
|
@ -267,7 +267,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
if (ownerActor == null)
|
||||
{
|
||||
//Is it a instance actor?
|
||||
ownerActor = Server.getWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
|
||||
ownerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
|
||||
if (ownerActor == null)
|
||||
{
|
||||
//Is it a Director?
|
||||
|
@ -298,7 +298,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
Actor updateOwnerActor = Server.getStaticActors(player.getActor().eventCurrentOwner);
|
||||
if (updateOwnerActor == null)
|
||||
{
|
||||
updateOwnerActor = Server.getWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
|
||||
updateOwnerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
|
||||
|
||||
if (player.getActor().currentDirector != null && player.getActor().eventCurrentOwner == player.getActor().currentDirector.actorId)
|
||||
updateOwnerActor = player.getActor().currentDirector;
|
||||
|
|
|
@ -239,13 +239,14 @@ namespace FFXIVClassic_Map_Server.Properties {
|
|||
/// <summary>
|
||||
/// Looks up a localized string similar to Teleports the player to the specified location
|
||||
///
|
||||
///*Note: You can teleport relative to your current position by putting a @ in front of a value, cannot be combined with a zone id or instance name
|
||||
///
|
||||
///*Syntax: warp <location list>
|
||||
/// warp <X coordinate> <Y coordinate> <Z coordinate>
|
||||
/// warp <zone id> <X coordinate> <Y coordinate> <Z coordinate>
|
||||
/// warp <zone id> <instance> <X coordinate> <Y coordinate> <Z coordinate>
|
||||
///<location list> is a pre-defined list of locations from the server database
|
||||
///<zone id> is the zone's id as defined in the server database
|
||||
///<instance> is an instanced copy of the desired zone that's only visible to the current player.
|
||||
///<zone id> is the [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
public static string CPwarp {
|
||||
get {
|
||||
|
|
|
@ -206,6 +206,8 @@ Server Administration: givecurrency, giveitem, givekeyitem, removecurrency, remo
|
|||
<data name="CPwarp" xml:space="preserve">
|
||||
<value>Teleports the player to the specified location
|
||||
|
||||
*Note: You can teleport relative to your current position by putting a @ in front of a value, cannot be combined with a zone id or instance name
|
||||
|
||||
*Syntax: warp <location list>
|
||||
warp <X coordinate> <Y coordinate> <Z coordinate>
|
||||
warp <zone id> <X coordinate> <Y coordinate> <Z coordinate>
|
||||
|
|
|
@ -83,8 +83,8 @@ namespace FFXIVClassic_Lobby_Server
|
|||
mConnectionHealthThread.Name = "MapThread:Health";
|
||||
//mConnectionHealthThread.Start();
|
||||
|
||||
mStaticActors = new StaticActors(STATIC_ACTORS_PATH);
|
||||
|
||||
mStaticActors = new StaticActors(STATIC_ACTORS_PATH);
|
||||
|
||||
gamedataItems = Database.getItemGamedata();
|
||||
Log.info(String.Format("Loaded {0} items.", gamedataItems.Count));
|
||||
|
||||
|
@ -95,9 +95,9 @@ namespace FFXIVClassic_Lobby_Server
|
|||
|
||||
IPEndPoint serverEndPoint = new System.Net.IPEndPoint(IPAddress.Parse(ConfigConstants.OPTIONS_BINDIP), FFXIV_MAP_PORT);
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
mServerSocket = new System.Net.Sockets.Socket(serverEndPoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
mServerSocket = new System.Net.Sockets.Socket(serverEndPoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -146,8 +146,8 @@ namespace FFXIVClassic_Lobby_Server
|
|||
private void acceptCallback(IAsyncResult result)
|
||||
{
|
||||
ClientConnection conn = null;
|
||||
Socket socket = (System.Net.Sockets.Socket)result.AsyncState;
|
||||
|
||||
Socket socket = (System.Net.Sockets.Socket)result.AsyncState;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
@ -169,8 +169,8 @@ namespace FFXIVClassic_Lobby_Server
|
|||
catch (SocketException)
|
||||
{
|
||||
if (conn != null)
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
lock (mConnectionList)
|
||||
{
|
||||
mConnectionList.Remove(conn);
|
||||
|
@ -181,7 +181,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
catch (Exception)
|
||||
{
|
||||
if (conn != null)
|
||||
{
|
||||
{
|
||||
lock (mConnectionList)
|
||||
{
|
||||
mConnectionList.Remove(conn);
|
||||
|
@ -225,7 +225,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
lock (mConnectionList)
|
||||
{
|
||||
mConnectionList.Remove(conn);
|
||||
}
|
||||
}
|
||||
if (conn.connType == BasePacket.TYPE_ZONE)
|
||||
Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
|
||||
return;
|
||||
|
@ -243,36 +243,36 @@ namespace FFXIVClassic_Lobby_Server
|
|||
|
||||
//Build packets until can no longer or out of data
|
||||
while (true)
|
||||
{
|
||||
BasePacket basePacket = buildPacket(ref offset, conn.buffer, bytesRead);
|
||||
|
||||
//If can't build packet, break, else process another
|
||||
if (basePacket == null)
|
||||
break;
|
||||
else
|
||||
mProcessor.processPacket(conn, basePacket);
|
||||
}
|
||||
|
||||
//Not all bytes consumed, transfer leftover to beginning
|
||||
{
|
||||
BasePacket basePacket = buildPacket(ref offset, conn.buffer, bytesRead);
|
||||
|
||||
//If can't build packet, break, else process another
|
||||
if (basePacket == null)
|
||||
break;
|
||||
else
|
||||
mProcessor.processPacket(conn, basePacket);
|
||||
}
|
||||
|
||||
//Not all bytes consumed, transfer leftover to beginning
|
||||
if (offset < bytesRead)
|
||||
Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset);
|
||||
|
||||
conn.lastPartialSize = bytesRead - offset;
|
||||
|
||||
//Build any queued subpackets into basepackets and send
|
||||
conn.flushQueuedSendPackets();
|
||||
|
||||
if (offset < bytesRead)
|
||||
//Need offset since not all bytes consumed
|
||||
conn.flushQueuedSendPackets();
|
||||
|
||||
if (offset < bytesRead)
|
||||
//Need offset since not all bytes consumed
|
||||
conn.socket.BeginReceive(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset), SocketFlags.None, new AsyncCallback(receiveCallback), conn);
|
||||
else
|
||||
//All bytes consumed, full buffer available
|
||||
else
|
||||
//All bytes consumed, full buffer available
|
||||
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
|
||||
|
||||
Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
|
||||
|
||||
lock (mConnectionList)
|
||||
{
|
||||
mConnectionList.Remove(conn);
|
||||
|
@ -280,15 +280,15 @@ namespace FFXIVClassic_Lobby_Server
|
|||
}
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
{
|
||||
if (conn.socket != null)
|
||||
{
|
||||
Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
|
||||
|
||||
Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
|
||||
|
||||
lock (mConnectionList)
|
||||
{
|
||||
mConnectionList.Remove(conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -326,23 +326,23 @@ namespace FFXIVClassic_Lobby_Server
|
|||
}
|
||||
|
||||
return newPacket;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static WorldManager getWorldManager()
|
||||
{
|
||||
return mWorldManager;
|
||||
}
|
||||
|
||||
public Dictionary<uint, ConnectedPlayer> getConnectedPlayerList()
|
||||
{
|
||||
return mConnectedPlayerList;
|
||||
}
|
||||
|
||||
public static Dictionary<uint, Item> getItemGamedataList()
|
||||
{
|
||||
return gamedataItems;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static WorldManager GetWorldManager()
|
||||
{
|
||||
return mWorldManager;
|
||||
}
|
||||
|
||||
public Dictionary<uint, ConnectedPlayer> getConnectedPlayerList()
|
||||
{
|
||||
return mConnectedPlayerList;
|
||||
}
|
||||
|
||||
public static Dictionary<uint, Item> GetGamedataItems()
|
||||
{
|
||||
return gamedataItems;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
{
|
||||
List<LuaParam> lParams;
|
||||
|
||||
Player player = Server.getWorldManager().GetPCInWorld(playerActorId);
|
||||
Player player = Server.GetWorldManager().GetPCInWorld(playerActorId);
|
||||
lParams = LuaEngine.doActorOnInstantiate(player, this);
|
||||
|
||||
if (lParams == null)
|
||||
|
|
|
@ -703,34 +703,34 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
{
|
||||
if (msgParams.Length == 0)
|
||||
{
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log));
|
||||
}
|
||||
else
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams)));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, sourceActor.actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams)));
|
||||
}
|
||||
|
||||
public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, params object[] msgParams)
|
||||
{
|
||||
if (msgParams.Length == 0)
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log));
|
||||
else
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams)));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, log, LuaUtils.createLuaParamList(msgParams)));
|
||||
}
|
||||
|
||||
public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, string customSender, params object[] msgParams)
|
||||
{
|
||||
if (msgParams.Length == 0)
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log));
|
||||
else
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams)));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, customSender, log, LuaUtils.createLuaParamList(msgParams)));
|
||||
}
|
||||
|
||||
public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, uint displayId, params object[] msgParams)
|
||||
{
|
||||
if (msgParams.Length == 0)
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log));
|
||||
else
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.getWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams)));
|
||||
queuePacket(GameMessagePacket.buildPacket(Server.GetWorldManager().GetActor().actorId, actorId, textIdOwner.actorId, textId, displayId, log, LuaUtils.createLuaParamList(msgParams)));
|
||||
}
|
||||
|
||||
public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams)
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
Script script = new Script();
|
||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getWorldManager().GetActor;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||
script.DoFile(luaPath);
|
||||
DynValue result = script.Call(script.Globals["onInstantiate"], target);
|
||||
|
@ -82,9 +82,9 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
{
|
||||
Script script = new Script();
|
||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.getWorldManager;
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getWorldManager().GetActor;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||
script.DoFile(luaPath);
|
||||
|
||||
|
@ -125,9 +125,9 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
{
|
||||
Script script = new Script();
|
||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.getWorldManager;
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getWorldManager().GetActor;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||
script.DoFile(luaPath);
|
||||
|
||||
|
@ -158,9 +158,9 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
{
|
||||
Script script = new Script();
|
||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.getWorldManager;
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getWorldManager().GetActor;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||
script.DoFile(luaPath);
|
||||
|
||||
|
@ -175,9 +175,9 @@ namespace FFXIVClassic_Map_Server.lua
|
|||
{
|
||||
Script script = new Script();
|
||||
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.getWorldManager;
|
||||
script.Globals["getWorldManager"] = (Func<WorldManager>)Server.GetWorldManager;
|
||||
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.getWorldManager().GetActor;
|
||||
script.Globals["getWorldMaster"] = (Func<Actor>)Server.GetWorldManager().GetActor;
|
||||
script.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
|
||||
script.DoFile(FILEPATH_PLAYER);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue