1
Fork 0
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:
TheManii 2016-04-09 12:42:24 -07:00
commit 10d4d7c148
9 changed files with 290 additions and 201 deletions

View file

@ -24,8 +24,8 @@ namespace FFXIVClassic_Lobby_Server
class CommandProcessor class CommandProcessor
{ {
private Dictionary<uint, ConnectedPlayer> mConnectedPlayerList; private Dictionary<uint, ConnectedPlayer> mConnectedPlayerList;
private static WorldManager mWorldManager = Server.getWorldManager(); private static WorldManager mWorldManager = Server.GetWorldManager();
private static Dictionary<uint, Item> gamedataItems = Server.getItemGamedataList(); private static Dictionary<uint, Item> gamedataItems = Server.GetGamedataItems();
// For the moment, this is the only predefined item // 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 // 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> /// <summary>
/// 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, 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; if (mWorldManager.GetZone(zoneId) == null)
float x,y,z; {
if (client != null)
x = Single.Parse(sx); 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));
y = Single.Parse(sy); Log.error("Zone does not exist or setting isn't valid.");
z = Single.Parse(sz);
if (zone == null)
{
if (client != null)
mWorldManager.DoZoneChange(client.getActor(), 0, privateArea, 0x2, x, y, z, 0.0f);
} }
else
{ if (client != null)
if (zone.ToLower().StartsWith("0x")) mWorldManager.DoZoneChange(client.getActor(), zoneId, privateArea, 0x2, x, y, z, r);
zoneId = Convert.ToUInt32(zone, 16); else
else {
zoneId = Convert.ToUInt32(zone); foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{
if (mWorldManager.GetZone(zoneId) == null) mWorldManager.DoZoneChange(entry.Value.getActor(), zoneId, privateArea, 0x2, x, y, z, r);
{
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);
}
} }
} }
} }
@ -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> /// <summary>
/// We only use the default options for SendMessagePacket. /// We only use the default options for SendMessagePacket.
/// May as well make it less unwieldly to view /// May as well make it less unwieldly to view
@ -370,11 +473,11 @@ namespace FFXIVClassic_Lobby_Server
input = input.Substring(1); input = input.Substring(1);
String[] split = input.Split(' '); String[] split = input.Split(' ');
split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands split = split.Select(temp => temp.ToLower()).ToArray(); // Ignore case on commands
split = split.Where(temp => temp != "").ToArray(); // strips extra whitespace from commands split = split.Where(temp => temp != "").ToArray(); // strips extra whitespace from commands
// Debug // Debug
//sendMessage(client, string.Join(",", split)); //sendMessage(client, string.Join(",", split));
if (split.Length >= 1) if (split.Length >= 1)
{ {
@ -422,9 +525,9 @@ namespace FFXIVClassic_Lobby_Server
} }
return true; return true;
} }
#endregion #endregion
#region !mypos #region !mypos
else if (split[0].Equals("mypos")) else if (split[0].Equals("mypos"))
{ {
@ -437,9 +540,9 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not load packet: " + e); Log.error("Could not load packet: " + e);
} }
} }
#endregion #endregion
#region !reloadzones #region !reloadzones
else if (split[0].Equals("reloadzones")) else if (split[0].Equals("reloadzones"))
{ {
@ -453,9 +556,9 @@ namespace FFXIVClassic_Lobby_Server
} }
mWorldManager.reloadZone(client.getActor().zoneId); mWorldManager.reloadZone(client.getActor().zoneId);
return true; return true;
} }
#endregion #endregion
#region !reloaditems #region !reloaditems
else if (split[0].Equals("reloaditems")) else if (split[0].Equals("reloaditems"))
{ {
@ -466,9 +569,9 @@ namespace FFXIVClassic_Lobby_Server
Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); Log.info(String.Format("Loaded {0} items.", gamedataItems.Count));
sendMessage(client, String.Format("Loaded {0} items.", gamedataItems.Count)); sendMessage(client, String.Format("Loaded {0} items.", gamedataItems.Count));
return true; return true;
} }
#endregion #endregion
#region !sendpacket #region !sendpacket
else if (split[0].Equals("sendpacket")) else if (split[0].Equals("sendpacket"))
{ {
@ -484,9 +587,9 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not load packet: " + e); Log.error("Could not load packet: " + e);
} }
} }
#endregion #endregion
#region !graphic #region !graphic
else if (split[0].Equals("graphic")) else if (split[0].Equals("graphic"))
{ {
@ -500,9 +603,9 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give item."); Log.error("Could not give item.");
} }
} }
#endregion #endregion
#region !giveitem #region !giveitem
else if (split[0].Equals("giveitem")) else if (split[0].Equals("giveitem"))
{ {
@ -520,10 +623,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give item."); Log.error("Could not give item.");
} }
} }
#endregion #endregion
#region !removeitem #region !removeitem
else if (split[0].Equals("removeitem")) else if (split[0].Equals("removeitem"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -543,10 +646,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not remove item."); Log.error("Could not remove item.");
} }
} }
#endregion #endregion
#region !givekeyitem #region !givekeyitem
else if (split[0].Equals("givekeyitem")) else if (split[0].Equals("givekeyitem"))
{ {
try try
@ -558,10 +661,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give keyitem."); Log.error("Could not give keyitem.");
} }
} }
#endregion #endregion
#region !removekeyitem #region !removekeyitem
else if (split[0].Equals("removekeyitem")) else if (split[0].Equals("removekeyitem"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -577,10 +680,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not remove keyitem."); Log.error("Could not remove keyitem.");
} }
} }
#endregion #endregion
#region !givecurrency #region !givecurrency
else if (split[0].Equals("givecurrency")) else if (split[0].Equals("givecurrency"))
{ {
try try
@ -594,10 +697,10 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not give currency."); Log.error("Could not give currency.");
} }
} }
#endregion #endregion
#region !removecurrency #region !removecurrency
else if (split[0].Equals("removecurrency")) else if (split[0].Equals("removecurrency"))
{ {
if (split.Length < 2) if (split.Length < 2)
@ -615,9 +718,9 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not remove currency."); Log.error("Could not remove currency.");
} }
} }
#endregion #endregion
#region !music #region !music
else if (split[0].Equals("music")) else if (split[0].Equals("music"))
{ {
@ -633,24 +736,17 @@ namespace FFXIVClassic_Lobby_Server
{ {
Log.error("Could not change music: " + e); Log.error("Could not change music: " + e);
} }
} }
#endregion #endregion
#region !warp #region !warp
else if (split[0].Equals("warp")) else if (split[0].Equals("warp"))
{ {
if (split.Length == 2) // Predefined list parseWarp(client, split);
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]);
return true; return true;
} }
#endregion #endregion
#region !property #region !property
else if (split[0].Equals("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]); changeProperty(Utils.MurmurHash2(split[1], 0), Convert.ToUInt32(split[2], 16), split[3]);
} }
return true; return true;
} }
#endregion #endregion
#region !property2 #region !property2
else if (split[0].Equals("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]); changeProperty(Convert.ToUInt32(split[1], 16), Convert.ToUInt32(split[2], 16), split[3]);
} }
return true; return true;
} }
#endregion #endregion
} }
return false; return false;

View file

@ -188,7 +188,7 @@ namespace FFXIVClassic_Lobby_Server
subpacket.debugPrintSubPacket(); subpacket.debugPrintSubPacket();
client.queuePacket(_0x2Packet.buildPacket(player.actorID), true, false); client.queuePacket(_0x2Packet.buildPacket(player.actorID), true, false);
Server.getWorldManager().DoLogin(player.getActor()); Server.GetWorldManager().DoLogin(player.getActor());
break; break;
@ -267,7 +267,7 @@ namespace FFXIVClassic_Lobby_Server
if (ownerActor == null) if (ownerActor == null)
{ {
//Is it a instance actor? //Is it a instance actor?
ownerActor = Server.getWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner); ownerActor = Server.GetWorldManager().GetActorInWorld(player.getActor().eventCurrentOwner);
if (ownerActor == null) if (ownerActor == null)
{ {
//Is it a Director? //Is it a Director?
@ -298,7 +298,7 @@ namespace FFXIVClassic_Lobby_Server
Actor updateOwnerActor = Server.getStaticActors(player.getActor().eventCurrentOwner); Actor updateOwnerActor = Server.getStaticActors(player.getActor().eventCurrentOwner);
if (updateOwnerActor == null) 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) if (player.getActor().currentDirector != null && player.getActor().eventCurrentOwner == player.getActor().currentDirector.actorId)
updateOwnerActor = player.getActor().currentDirector; updateOwnerActor = player.getActor().currentDirector;

View file

@ -239,13 +239,14 @@ namespace FFXIVClassic_Map_Server.Properties {
/// <summary> /// <summary>
/// Looks up a localized string similar to Teleports the player to the specified location /// 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 &lt;location list&gt; ///*Syntax: warp &lt;location list&gt;
/// warp &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt; /// warp &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
/// warp &lt;zone id&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt; /// warp &lt;zone id&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
/// warp &lt;zone id&gt; &lt;instance&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt; /// warp &lt;zone id&gt; &lt;instance&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
///&lt;location list&gt; is a pre-defined list of locations from the server database ///&lt;location list&gt; is a pre-defined list of locations from the server database
///&lt;zone id&gt; is the zone&apos;s id as defined in the server database ///&lt;zone id&gt; is the [rest of string was truncated]&quot;;.
///&lt;instance&gt; is an instanced copy of the desired zone that&apos;s only visible to the current player.
/// </summary> /// </summary>
public static string CPwarp { public static string CPwarp {
get { get {

View file

@ -206,6 +206,8 @@ Server Administration: givecurrency, giveitem, givekeyitem, removecurrency, remo
<data name="CPwarp" xml:space="preserve"> <data name="CPwarp" xml:space="preserve">
<value>Teleports the player to the specified location <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 &lt;location list&gt; *Syntax: warp &lt;location list&gt;
warp &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt; warp &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;
warp &lt;zone id&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt; warp &lt;zone id&gt; &lt;X coordinate&gt; &lt;Y coordinate&gt; &lt;Z coordinate&gt;

View file

@ -83,8 +83,8 @@ namespace FFXIVClassic_Lobby_Server
mConnectionHealthThread.Name = "MapThread:Health"; mConnectionHealthThread.Name = "MapThread:Health";
//mConnectionHealthThread.Start(); //mConnectionHealthThread.Start();
mStaticActors = new StaticActors(STATIC_ACTORS_PATH); mStaticActors = new StaticActors(STATIC_ACTORS_PATH);
gamedataItems = Database.getItemGamedata(); gamedataItems = Database.getItemGamedata();
Log.info(String.Format("Loaded {0} items.", gamedataItems.Count)); 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); 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) catch (Exception e)
{ {
@ -146,8 +146,8 @@ namespace FFXIVClassic_Lobby_Server
private void acceptCallback(IAsyncResult result) private void acceptCallback(IAsyncResult result)
{ {
ClientConnection conn = null; ClientConnection conn = null;
Socket socket = (System.Net.Sockets.Socket)result.AsyncState; Socket socket = (System.Net.Sockets.Socket)result.AsyncState;
try try
{ {
@ -169,8 +169,8 @@ namespace FFXIVClassic_Lobby_Server
catch (SocketException) catch (SocketException)
{ {
if (conn != null) if (conn != null)
{ {
lock (mConnectionList) lock (mConnectionList)
{ {
mConnectionList.Remove(conn); mConnectionList.Remove(conn);
@ -181,7 +181,7 @@ namespace FFXIVClassic_Lobby_Server
catch (Exception) catch (Exception)
{ {
if (conn != null) if (conn != null)
{ {
lock (mConnectionList) lock (mConnectionList)
{ {
mConnectionList.Remove(conn); mConnectionList.Remove(conn);
@ -225,7 +225,7 @@ namespace FFXIVClassic_Lobby_Server
lock (mConnectionList) lock (mConnectionList)
{ {
mConnectionList.Remove(conn); mConnectionList.Remove(conn);
} }
if (conn.connType == BasePacket.TYPE_ZONE) if (conn.connType == BasePacket.TYPE_ZONE)
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));
return; return;
@ -243,36 +243,36 @@ namespace FFXIVClassic_Lobby_Server
//Build packets until can no longer or out of data //Build packets until can no longer or out of data
while (true) while (true)
{ {
BasePacket basePacket = buildPacket(ref offset, conn.buffer, bytesRead); BasePacket basePacket = buildPacket(ref offset, conn.buffer, bytesRead);
//If can't build packet, break, else process another //If can't build packet, break, else process another
if (basePacket == null) if (basePacket == null)
break; break;
else else
mProcessor.processPacket(conn, basePacket); mProcessor.processPacket(conn, basePacket);
} }
//Not all bytes consumed, transfer leftover to beginning //Not all bytes consumed, transfer leftover to beginning
if (offset < bytesRead) if (offset < bytesRead)
Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset); Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset);
conn.lastPartialSize = bytesRead - offset; conn.lastPartialSize = bytesRead - offset;
//Build any queued subpackets into basepackets and send //Build any queued subpackets into basepackets and send
conn.flushQueuedSendPackets(); conn.flushQueuedSendPackets();
if (offset < bytesRead) if (offset < bytesRead)
//Need offset since not all bytes consumed //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); conn.socket.BeginReceive(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset), SocketFlags.None, new AsyncCallback(receiveCallback), conn);
else else
//All bytes consumed, full buffer available //All bytes consumed, full buffer available
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn); conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn);
} }
else 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) lock (mConnectionList)
{ {
mConnectionList.Remove(conn); mConnectionList.Remove(conn);
@ -280,15 +280,15 @@ namespace FFXIVClassic_Lobby_Server
} }
} }
catch (SocketException) catch (SocketException)
{ {
if (conn.socket != null) 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) lock (mConnectionList)
{ {
mConnectionList.Remove(conn); mConnectionList.Remove(conn);
} }
} }
} }
} }
@ -326,23 +326,23 @@ namespace FFXIVClassic_Lobby_Server
} }
return newPacket; return newPacket;
}
#endregion
public static WorldManager getWorldManager()
{
return mWorldManager;
} }
public Dictionary<uint, ConnectedPlayer> getConnectedPlayerList() #endregion
{
return mConnectedPlayerList; public static WorldManager GetWorldManager()
} {
return mWorldManager;
public static Dictionary<uint, Item> getItemGamedataList() }
{
return gamedataItems; public Dictionary<uint, ConnectedPlayer> getConnectedPlayerList()
} {
return mConnectedPlayerList;
}
public static Dictionary<uint, Item> GetGamedataItems()
{
return gamedataItems;
}
} }
} }

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

View file

@ -49,7 +49,7 @@ namespace FFXIVClassic_Map_Server.Actors
{ {
List<LuaParam> lParams; List<LuaParam> lParams;
Player player = Server.getWorldManager().GetPCInWorld(playerActorId); Player player = Server.GetWorldManager().GetPCInWorld(playerActorId);
lParams = LuaEngine.doActorOnInstantiate(player, this); lParams = LuaEngine.doActorOnInstantiate(player, this);
if (lParams == null) if (lParams == null)

View file

@ -703,34 +703,34 @@ namespace FFXIVClassic_Map_Server.Actors
{ {
if (msgParams.Length == 0) 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 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) public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, params object[] msgParams)
{ {
if (msgParams.Length == 0) 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 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) public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, string customSender, params object[] msgParams)
{ {
if (msgParams.Length == 0) 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 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) public void sendGameMessage(Actor textIdOwner, ushort textId, byte log, uint displayId, params object[] msgParams)
{ {
if (msgParams.Length == 0) 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 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) public void broadcastWorldMessage(ushort worldMasterId, params object[] msgParams)

View file

@ -43,7 +43,7 @@ namespace FFXIVClassic_Map_Server.lua
Script script = new Script(); Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; ((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" };
script.Globals["getStaticActor"] = (Func<string, Actor>)Server.getStaticActors; 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.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
script.DoFile(luaPath); script.DoFile(luaPath);
DynValue result = script.Call(script.Globals["onInstantiate"], target); DynValue result = script.Call(script.Globals["onInstantiate"], target);
@ -82,9 +82,9 @@ namespace FFXIVClassic_Map_Server.lua
{ {
Script script = new Script(); Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; ((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["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.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
script.DoFile(luaPath); script.DoFile(luaPath);
@ -125,9 +125,9 @@ namespace FFXIVClassic_Map_Server.lua
{ {
Script script = new Script(); Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; ((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["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.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
script.DoFile(luaPath); script.DoFile(luaPath);
@ -158,9 +158,9 @@ namespace FFXIVClassic_Map_Server.lua
{ {
Script script = new Script(); Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; ((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["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.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
script.DoFile(luaPath); script.DoFile(luaPath);
@ -175,9 +175,9 @@ namespace FFXIVClassic_Map_Server.lua
{ {
Script script = new Script(); Script script = new Script();
((ScriptLoaderBase)script.Options.ScriptLoader).ModulePaths = new string[] { "./scripts/?", "./scripts/?.lua" }; ((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["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.Globals["getItemGamedata"] = (Func<uint, Item>)Server.getItemGamedata;
script.DoFile(FILEPATH_PLAYER); script.DoFile(FILEPATH_PLAYER);