*Revert ea1e16a, should be done globally and not simply here

This commit is contained in:
TheManii 2016-04-09 12:35:29 -07:00
parent 06606c5f01
commit c38fbc0c09
6 changed files with 108 additions and 108 deletions

View file

@ -24,7 +24,7 @@ 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.getItemGamedataList();
// For the moment, this is the only predefined item // For the moment, this is the only predefined item
@ -322,23 +322,23 @@ namespace FFXIVClassic_Lobby_Server
private void parseWarp(ConnectedPlayer client, string[] split) private void parseWarp(ConnectedPlayer client, string[] split)
{ {
float x = 0, y = 0, z = 0, r = 0.0f; float x = 0, y = 0, z = 0, r = 0.0f;
uint zoneId = 0; uint zoneId = 0;
string privatearea = null; string privatearea = null;
if (split.Length == 2) // Predefined list if (split.Length == 2) // Predefined list
{ {
// TODO: Handle !warp Playername // TODO: Handle !warp Playername
#region !warp (predefined list) #region !warp (predefined list)
try try
{ {
if (split[1].ToLower().StartsWith("0x")) if (split[1].ToLower().StartsWith("0x"))
zoneId = Convert.ToUInt32(split[1], 16); zoneId = Convert.ToUInt32(split[1], 16);
else else
zoneId = Convert.ToUInt32(split[1]); zoneId = Convert.ToUInt32(split[1]);
} }
catch{return;} catch{return;}
#endregion #endregion
doWarp(client, zoneId); doWarp(client, zoneId);
} }
else if (split.Length == 4) else if (split.Length == 4)
@ -393,7 +393,7 @@ namespace FFXIVClassic_Lobby_Server
r = client.getActor().rotation; r = client.getActor().rotation;
#endregion #endregion
sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); 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); doWarp(client, zoneId, privatearea, x, y, z, r);
} }
else if (split.Length == 5) else if (split.Length == 5)
@ -406,20 +406,20 @@ namespace FFXIVClassic_Lobby_Server
z = Single.Parse(split[4]); z = Single.Parse(split[4]);
} }
catch{return;} catch{return;}
if (split[1].ToLower().StartsWith("0x")) if (split[1].ToLower().StartsWith("0x"))
{ {
try { zoneId = Convert.ToUInt32(split[1], 16); } try { zoneId = Convert.ToUInt32(split[1], 16); }
catch{return;} catch{return;}
} }
else else
{ {
try { zoneId = Convert.ToUInt32(split[1]); } try { zoneId = Convert.ToUInt32(split[1]); }
catch{return;} catch{return;}
} }
#endregion #endregion
sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); 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); doWarp(client, zoneId, privatearea, x, y, z, r);
} }
else if (split.Length == 6) else if (split.Length == 6)
@ -431,23 +431,23 @@ namespace FFXIVClassic_Lobby_Server
y = Single.Parse(split[4]); y = Single.Parse(split[4]);
z = Single.Parse(split[5]); z = Single.Parse(split[5]);
} }
catch{return;} catch{return;}
if (split[1].ToLower().StartsWith("0x")) if (split[1].ToLower().StartsWith("0x"))
{ {
try { zoneId = Convert.ToUInt32(split[1], 16); } try { zoneId = Convert.ToUInt32(split[1], 16); }
catch{return;} catch{return;}
} }
else else
{ {
try { zoneId = Convert.ToUInt32(split[1]); } try { zoneId = Convert.ToUInt32(split[1]); }
catch{return;} catch{return;}
} }
privatearea = split[2]; privatearea = split[2];
#endregion #endregion
sendMessage(client, String.Format("Warping to: ZoneID: {0} X: {1}, Y: {2}, Z: {3}", zoneId, x, x, y)); 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); doWarp(client, zoneId, privatearea, x, y, z, r);
} }
else else

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

@ -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> getItemGamedataList()
{
return gamedataItems;
}
} }
} }

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