mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-24 05:37:46 +00:00
Cleaned up LogFile and ByteArrayToHex utils.
This commit is contained in:
parent
8b93abe86e
commit
1c712c7533
31 changed files with 409 additions and 405 deletions
|
@ -59,7 +59,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
socket.Send(packetBytes);
|
socket.Send(packetBytes);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{ Log.error(String.Format("Weird case, socket was d/ced: {0}", e)); }
|
{ Log.Error(String.Format("Weird case, socket was d/ced: {0}", e)); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -88,9 +88,9 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
pid = 0;
|
pid = 0;
|
||||||
cid = 0;
|
cid = 0;
|
||||||
|
@ -100,7 +100,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
conn.Dispose();
|
conn.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.database(String.Format("CID={0} created on 'characters' table.", cid));
|
Log.Sql(String.Format("CID={0} created on 'characters' table.", cid));
|
||||||
}
|
}
|
||||||
|
|
||||||
return alreadyExists;
|
return alreadyExists;
|
||||||
|
@ -183,7 +183,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
conn.Dispose();
|
conn.Dispose();
|
||||||
return;
|
return;
|
||||||
|
@ -208,7 +208,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
conn.Dispose();
|
conn.Dispose();
|
||||||
return;
|
return;
|
||||||
|
@ -230,7 +230,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.database(String.Format("CID={0} state updated to active(2).", cid));
|
Log.Sql(String.Format("CID={0} state updated to active(2).", cid));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool renameCharacter(uint userId, uint characterId, uint serverId, String newName)
|
public static bool renameCharacter(uint userId, uint characterId, uint serverId, String newName)
|
||||||
|
@ -277,7 +277,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
conn.Dispose();
|
conn.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.database(String.Format("CID={0} name updated to \"{1}\".", characterId, newName));
|
Log.Sql(String.Format("CID={0} name updated to \"{1}\".", characterId, newName));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.database(String.Format("CID={0} deleted.", characterId));
|
Log.Sql(String.Format("CID={0} deleted.", characterId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<World> getServers()
|
public static List<World> getServers()
|
||||||
|
@ -335,7 +335,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
worldList = new List<World>(); }
|
worldList = new List<World>(); }
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -357,7 +357,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -494,7 +494,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -518,7 +518,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
nameList = new List<String>(); }
|
nameList = new List<String>(); }
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -540,7 +540,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
retainerList = new List<Retainer>(); }
|
retainerList = new List<Retainer>(); }
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
case 0x0F:
|
case 0x0F:
|
||||||
//Mod Retainers
|
//Mod Retainers
|
||||||
default:
|
default:
|
||||||
Log.debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode));
|
Log.Debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
byte[] blowfishKey = GenerateKey(securityHandshake.ticketPhrase, securityHandshake.clientNumber);
|
byte[] blowfishKey = GenerateKey(securityHandshake.ticketPhrase, securityHandshake.clientNumber);
|
||||||
client.blowfish = new Blowfish(blowfishKey);
|
client.blowfish = new Blowfish(blowfishKey);
|
||||||
|
|
||||||
Log.info(String.Format("SecCNum: 0x{0:X}", securityHandshake.clientNumber));
|
Log.Info(String.Format("SecCNum: 0x{0:X}", securityHandshake.clientNumber));
|
||||||
|
|
||||||
//Respond with acknowledgment
|
//Respond with acknowledgment
|
||||||
BasePacket outgoingPacket = new BasePacket(HardCoded_Packets.g_secureConnectionAcknowledgment);
|
BasePacket outgoingPacket = new BasePacket(HardCoded_Packets.g_secureConnectionAcknowledgment);
|
||||||
|
@ -81,8 +81,8 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
SessionPacket sessionPacket = new SessionPacket(packet.data);
|
SessionPacket sessionPacket = new SessionPacket(packet.data);
|
||||||
String clientVersion = sessionPacket.version;
|
String clientVersion = sessionPacket.version;
|
||||||
|
|
||||||
Log.info(String.Format("Got acknowledgment for secure session."));
|
Log.Info(String.Format("Got acknowledgment for secure session."));
|
||||||
Log.info(String.Format("CLIENT VERSION: {0}", clientVersion));
|
Log.Info(String.Format("CLIENT VERSION: {0}", clientVersion));
|
||||||
|
|
||||||
uint userId = Database.getUserIdFromSession(sessionPacket.session);
|
uint userId = Database.getUserIdFromSession(sessionPacket.session);
|
||||||
client.currentUserId = userId;
|
client.currentUserId = userId;
|
||||||
|
@ -96,11 +96,11 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
BasePacket.encryptPacket(client.blowfish, errorBasePacket);
|
BasePacket.encryptPacket(client.blowfish, errorBasePacket);
|
||||||
client.queuePacket(errorBasePacket);
|
client.queuePacket(errorBasePacket);
|
||||||
|
|
||||||
Log.info(String.Format("Invalid session, kicking..."));
|
Log.Info(String.Format("Invalid session, kicking..."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info(String.Format("USER ID: {0}", userId));
|
Log.Info(String.Format("USER ID: {0}", userId));
|
||||||
|
|
||||||
List<Account> accountList = new List<Account>();
|
List<Account> accountList = new List<Account>();
|
||||||
Account defaultAccount = new Account();
|
Account defaultAccount = new Account();
|
||||||
|
@ -115,7 +115,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
|
|
||||||
private void ProcessGetCharacters(ClientConnection client, SubPacket packet)
|
private void ProcessGetCharacters(ClientConnection client, SubPacket packet)
|
||||||
{
|
{
|
||||||
Log.info(String.Format("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId));
|
Log.Info(String.Format("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId));
|
||||||
|
|
||||||
sendWorldList(client, packet);
|
sendWorldList(client, packet);
|
||||||
sendImportList(client, packet);
|
sendImportList(client, packet);
|
||||||
|
@ -128,7 +128,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
{
|
{
|
||||||
SelectCharacterPacket selectCharRequest = new SelectCharacterPacket(packet.data);
|
SelectCharacterPacket selectCharRequest = new SelectCharacterPacket(packet.data);
|
||||||
|
|
||||||
Log.info(String.Format("{0} => Select character id {1}", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId, selectCharRequest.characterId));
|
Log.Info(String.Format("{0} => Select character id {1}", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId, selectCharRequest.characterId));
|
||||||
|
|
||||||
Character chara = Database.getCharacter(client.currentUserId, selectCharRequest.characterId);
|
Character chara = Database.getCharacter(client.currentUserId, selectCharRequest.characterId);
|
||||||
World world = null;
|
World world = null;
|
||||||
|
@ -187,7 +187,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
BasePacket.encryptPacket(client.blowfish, basePacket);
|
BasePacket.encryptPacket(client.blowfish, basePacket);
|
||||||
client.queuePacket(basePacket);
|
client.queuePacket(basePacket);
|
||||||
|
|
||||||
Log.info(String.Format("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId));
|
Log.Info(String.Format("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
BasePacket.encryptPacket(client.blowfish, basePacket);
|
BasePacket.encryptPacket(client.blowfish, basePacket);
|
||||||
client.queuePacket(basePacket);
|
client.queuePacket(basePacket);
|
||||||
|
|
||||||
Log.info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
|
Log.Info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -219,7 +219,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
client.newCharaName = name;
|
client.newCharaName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info(String.Format("User {0} => Character reserved \"{1}\"", client.currentUserId, name));
|
Log.Info(String.Format("User {0} => Character reserved \"{1}\"", client.currentUserId, name));
|
||||||
break;
|
break;
|
||||||
case 0x02://Make
|
case 0x02://Make
|
||||||
CharaInfo info = CharaInfo.getFromNewCharRequest(charaReq.characterInfoEncoded);
|
CharaInfo info = CharaInfo.getFromNewCharRequest(charaReq.characterInfoEncoded);
|
||||||
|
@ -272,7 +272,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
cid = client.newCharaCid;
|
cid = client.newCharaCid;
|
||||||
name = client.newCharaName;
|
name = client.newCharaName;
|
||||||
|
|
||||||
Log.info(String.Format("User {0} => Character created \"{1}\"", client.currentUserId, name));
|
Log.Info(String.Format("User {0} => Character created \"{1}\"", client.currentUserId, name));
|
||||||
break;
|
break;
|
||||||
case 0x03://Rename
|
case 0x03://Rename
|
||||||
|
|
||||||
|
@ -286,20 +286,20 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
BasePacket.encryptPacket(client.blowfish, basePacket);
|
BasePacket.encryptPacket(client.blowfish, basePacket);
|
||||||
client.queuePacket(basePacket);
|
client.queuePacket(basePacket);
|
||||||
|
|
||||||
Log.info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
|
Log.Info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info(String.Format("User {0} => Character renamed \"{1}\"", client.currentUserId, name));
|
Log.Info(String.Format("User {0} => Character renamed \"{1}\"", client.currentUserId, name));
|
||||||
break;
|
break;
|
||||||
case 0x04://Delete
|
case 0x04://Delete
|
||||||
Database.deleteCharacter(charaReq.characterId, charaReq.characterName);
|
Database.deleteCharacter(charaReq.characterId, charaReq.characterName);
|
||||||
|
|
||||||
Log.info(String.Format("User {0} => Character deleted \"{1}\"", client.currentUserId, name));
|
Log.Info(String.Format("User {0} => Character deleted \"{1}\"", client.currentUserId, name));
|
||||||
break;
|
break;
|
||||||
case 0x06://Rename Retainer
|
case 0x06://Rename Retainer
|
||||||
|
|
||||||
Log.info(String.Format("User {0} => Retainer renamed \"{1}\"", client.currentUserId, name));
|
Log.Info(String.Format("User {0} => Retainer renamed \"{1}\"", client.currentUserId, name));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
List<Character> characterList = Database.getCharacters(client.currentUserId);
|
List<Character> characterList = Database.getCharacters(client.currentUserId);
|
||||||
|
|
||||||
if (characterList.Count > 8)
|
if (characterList.Count > 8)
|
||||||
Log.error("Warning, got more than 8 characters. List truncated, check DB for issues.");
|
Log.Error("Warning, got more than 8 characters. List truncated, check DB for issues.");
|
||||||
|
|
||||||
CharacterListPacket characterlistPacket = new CharacterListPacket(0, characterList);
|
CharacterListPacket characterlistPacket = new CharacterListPacket(0, characterList);
|
||||||
List<SubPacket> subPackets = characterlistPacket.buildPackets();
|
List<SubPacket> subPackets = characterlistPacket.buildPackets();
|
||||||
|
|
|
@ -22,15 +22,15 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
if (!ConfigConstants.load())
|
if (!ConfigConstants.load())
|
||||||
startServer = false;
|
startServer = false;
|
||||||
|
|
||||||
Log.log("--------FFXIV 1.0 Lobby Server--------", Log.LogType.Debug);
|
Log.Info("--------FFXIV 1.0 Lobby Server--------");
|
||||||
|
|
||||||
|
|
||||||
Assembly assem = Assembly.GetExecutingAssembly();
|
Assembly assem = Assembly.GetExecutingAssembly();
|
||||||
Version vers = assem.GetName().Version;
|
Version vers = assem.GetName().Version;
|
||||||
Log.info("Version: " + vers.ToString());
|
Log.Info("Version: " + vers.ToString());
|
||||||
|
|
||||||
//Test DB Connection
|
//Test DB Connection
|
||||||
Log.info(String.Format("Testing DB connection to \"{0}\"... ", ConfigConstants.DATABASE_HOST));
|
Log.Info(String.Format("Testing DB connection to \"{0}\"... ", ConfigConstants.DATABASE_HOST));
|
||||||
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
|
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -38,12 +38,12 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
conn.Open();
|
conn.Open();
|
||||||
conn.Close();
|
conn.Close();
|
||||||
|
|
||||||
Log.conn("[OK]");
|
Log.Status("[OK]");
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
Log.error("[FAILED]");
|
Log.Error("[FAILED]");
|
||||||
|
|
||||||
startServer = false;
|
startServer = false;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
while (true) Thread.Sleep(10000);
|
while (true) Thread.Sleep(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info("Press any key to continue...");
|
Log.Info("Press any key to continue...");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
|
|
||||||
private void socketCleanup()
|
private void socketCleanup()
|
||||||
{
|
{
|
||||||
Log.debug(String.Format("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME));
|
Log.Debug(String.Format("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME));
|
||||||
while (!killCleanupThread)
|
while (!killCleanupThread)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -40,7 +40,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count != 0)
|
if (count != 0)
|
||||||
Log.conn(String.Format("{0} connections were cleaned up.", count));
|
Log.Status(String.Format("{0} connections were cleaned up.", count));
|
||||||
Thread.Sleep(CLEANUP_THREAD_SLEEP_TIME*1000);
|
Thread.Sleep(CLEANUP_THREAD_SLEEP_TIME*1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
Log.debug(String.Format("Lobby Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
|
Log.Debug(String.Format("Lobby Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
Console.ForegroundColor = ConsoleColor.Gray;
|
||||||
|
|
||||||
mProcessor = new PacketProcessor();
|
mProcessor = new PacketProcessor();
|
||||||
|
@ -105,7 +105,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
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);
|
||||||
//Queue the accept of the next incomming connection
|
//Queue the accept of the next incomming connection
|
||||||
mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket);
|
mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket);
|
||||||
Log.conn(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
|
Log.Status(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
|
||||||
}
|
}
|
||||||
catch (SocketException)
|
catch (SocketException)
|
||||||
{
|
{
|
||||||
|
@ -179,7 +179,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.conn(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
|
Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
|
||||||
|
|
||||||
lock (mConnectionList)
|
lock (mConnectionList)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,7 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
{
|
{
|
||||||
if (conn.socket != null)
|
if (conn.socket != null)
|
||||||
{
|
{
|
||||||
Log.conn(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
|
Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
|
||||||
|
|
||||||
lock (mConnectionList)
|
lock (mConnectionList)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace FFXIVClassic_Lobby_Server.common
|
namespace FFXIVClassic_Lobby_Server.common
|
||||||
{
|
{
|
||||||
|
@ -7,66 +8,64 @@ namespace FFXIVClassic_Lobby_Server.common
|
||||||
{
|
{
|
||||||
public enum LogType
|
public enum LogType
|
||||||
{
|
{
|
||||||
Error = ConsoleColor.Red,
|
Status = ConsoleColor.Green,
|
||||||
Debug = ConsoleColor.Yellow,
|
|
||||||
Info = ConsoleColor.Cyan,
|
|
||||||
Sql = ConsoleColor.Magenta,
|
Sql = ConsoleColor.Magenta,
|
||||||
Conn = ConsoleColor.Green,
|
Info = ConsoleColor.White,
|
||||||
Default = ConsoleColor.Gray
|
Debug = ConsoleColor.Cyan,
|
||||||
|
Error = ConsoleColor.Red
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(String message)
|
public static void Status(String message)
|
||||||
{
|
{
|
||||||
log(message, LogType.Error);
|
LogFile(message, LogType.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(String message)
|
public static void Sql(String message)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
LogFile(message, LogType.Sql);
|
||||||
log(message, LogType.Debug);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(String message)
|
public static void Info(String message)
|
||||||
{
|
{
|
||||||
log(message, LogType.Info);
|
LogFile(message, LogType.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void database(String message)
|
public static void Debug(String message)
|
||||||
{
|
{
|
||||||
log(message, LogType.Sql);
|
#if DEBUG
|
||||||
|
LogFile(message, LogType.Debug);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void conn(String message)
|
public static void Error(String message)
|
||||||
{
|
{
|
||||||
log(message, LogType.Conn);
|
LogFile(message, LogType.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String message, LogType type)
|
private static void LogFile(String message, LogType type)
|
||||||
{
|
{
|
||||||
var timestamp = String.Format("[{0}] ", DateTime.Now.ToString("dd/MMM HH:mm:ss"));
|
string timestamp = String.Format("[{0}]", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));
|
||||||
var typestr = String.Format("[{0}] ", type.ToString().ToUpper());
|
string messageType = String.Format("[{0}] ", type.ToString().ToUpper());
|
||||||
|
|
||||||
Console.Write(timestamp);
|
Console.WriteLine(timestamp);
|
||||||
Console.ForegroundColor = (ConsoleColor)type;
|
Console.ForegroundColor = (ConsoleColor)type;
|
||||||
Console.Write(typestr);
|
Console.Write(messageType);
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
Console.ResetColor();
|
||||||
Console.WriteLine(message);
|
Console.Write(message);
|
||||||
|
|
||||||
message = message.Insert(0, typestr);
|
StringBuilder sb = new StringBuilder();
|
||||||
message = message.Insert(0, timestamp);
|
|
||||||
|
|
||||||
Directory.CreateDirectory(ConfigConstants.OPTIONS_LOGPATH);
|
sb.AppendLine(String.Format("{0}{1}{2}", timestamp, messageType, message));
|
||||||
|
|
||||||
try
|
if (!Directory.Exists(ConfigConstants.OPTIONS_LOGPATH))
|
||||||
{
|
{
|
||||||
File.AppendAllText(ConfigConstants.OPTIONS_LOGPATH + ConfigConstants.OPTIONS_LOGFILE, message + Environment.NewLine);
|
Directory.CreateDirectory(ConfigConstants.OPTIONS_LOGPATH);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
|
using (FileStream fs = new FileStream(Path.Combine(ConfigConstants.OPTIONS_LOGPATH, ConfigConstants.OPTIONS_LOGFILE), FileMode.Append, FileAccess.Write))
|
||||||
|
using (StreamWriter sw = new StreamWriter(fs))
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
sw.WriteLine(sb.ToString());
|
||||||
Console.Write(e.Message);
|
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,48 +18,48 @@ namespace FFXIVClassic_Lobby_Server.common
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ByteArrayToHex(byte[] bytes)
|
public static string ByteArrayToHex(byte[] bytes, int offset = 0, int bytesPerLine = 16)
|
||||||
{
|
{
|
||||||
if (bytes == null) return "<null>";
|
if (bytes == null)
|
||||||
int bytesLength = bytes.Length;
|
{
|
||||||
var bytesPerLine = 16;
|
return String.Empty;
|
||||||
char[] HexChars = "0123456789ABCDEF".ToCharArray();
|
}
|
||||||
|
|
||||||
int firstHexColumn =
|
char[] hexChars = "0123456789ABCDEF".ToCharArray();
|
||||||
8 // 8 characters for the address
|
|
||||||
+ 3; // 3 spaces
|
|
||||||
|
|
||||||
int firstCharColumn = firstHexColumn
|
// 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
|
||||||
+ bytesPerLine * 3 // - 2 digit for the hexadecimal value and 1 space
|
// 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
|
||||||
+ (bytesPerLine - 1) / 8 // - 1 extra space every 8 characters from the 9th
|
int offsetBlock = 8 + 3;
|
||||||
+ 2; // 2 spaces
|
int byteBlock = offsetBlock + (bytesPerLine * 3) + ((bytesPerLine - 1) / 8) + 2;
|
||||||
|
int lineLength = byteBlock + bytesPerLine + Environment.NewLine.Length;
|
||||||
int lineLength = firstCharColumn
|
|
||||||
+ bytesPerLine // - characters to show the ascii value
|
|
||||||
+ Environment.NewLine.Length; // Carriage return and line feed (should normally be 2)
|
|
||||||
|
|
||||||
char[] line = (new String(' ', lineLength - Environment.NewLine.Length) + Environment.NewLine).ToCharArray();
|
char[] line = (new String(' ', lineLength - Environment.NewLine.Length) + Environment.NewLine).ToCharArray();
|
||||||
int expectedLines = (bytesLength + bytesPerLine - 1) / bytesPerLine;
|
int numLines = (bytes.Length + bytesPerLine - 1) / bytesPerLine;
|
||||||
StringBuilder result = new StringBuilder(expectedLines * lineLength);
|
|
||||||
|
|
||||||
for (int i = 0; i < bytesLength; i += bytesPerLine)
|
StringBuilder sb = new StringBuilder(numLines * lineLength);
|
||||||
|
|
||||||
|
for (int i = offset; i < bytes.Length; i += bytesPerLine)
|
||||||
{
|
{
|
||||||
line[0] = HexChars[(i >> 28) & 0xF];
|
line[0] = hexChars[(i >> 28) & 0xF];
|
||||||
line[1] = HexChars[(i >> 24) & 0xF];
|
line[1] = hexChars[(i >> 24) & 0xF];
|
||||||
line[2] = HexChars[(i >> 20) & 0xF];
|
line[2] = hexChars[(i >> 20) & 0xF];
|
||||||
line[3] = HexChars[(i >> 16) & 0xF];
|
line[3] = hexChars[(i >> 16) & 0xF];
|
||||||
line[4] = HexChars[(i >> 12) & 0xF];
|
line[4] = hexChars[(i >> 12) & 0xF];
|
||||||
line[5] = HexChars[(i >> 8) & 0xF];
|
line[5] = hexChars[(i >> 8) & 0xF];
|
||||||
line[6] = HexChars[(i >> 4) & 0xF];
|
line[6] = hexChars[(i >> 4) & 0xF];
|
||||||
line[7] = HexChars[(i >> 0) & 0xF];
|
line[7] = hexChars[(i >> 0) & 0xF];
|
||||||
|
|
||||||
int hexColumn = firstHexColumn;
|
int hexColumn = offsetBlock;
|
||||||
int charColumn = firstCharColumn;
|
int charColumn = byteBlock;
|
||||||
|
|
||||||
for (int j = 0; j < bytesPerLine; j++)
|
for (int j = 0; j < bytesPerLine; j++)
|
||||||
{
|
{
|
||||||
if (j > 0 && (j & 7) == 0) hexColumn++;
|
if (j > 0 && (j & 7) == 0)
|
||||||
if (i + j >= bytesLength)
|
{
|
||||||
|
hexColumn++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i + j >= bytes.Length)
|
||||||
{
|
{
|
||||||
line[hexColumn] = ' ';
|
line[hexColumn] = ' ';
|
||||||
line[hexColumn + 1] = ' ';
|
line[hexColumn + 1] = ' ';
|
||||||
|
@ -67,17 +67,20 @@ namespace FFXIVClassic_Lobby_Server.common
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte b = bytes[i + j];
|
byte by = bytes[i + j];
|
||||||
line[hexColumn] = HexChars[(b >> 4) & 0xF];
|
line[hexColumn] = hexChars[(by >> 4) & 0xF];
|
||||||
line[hexColumn + 1] = HexChars[b & 0xF];
|
line[hexColumn + 1] = hexChars[by & 0xF];
|
||||||
line[charColumn] = (b < 32 ? '.' : (char)b);
|
line[charColumn] = (by < 32 ? '.' : (char)by);
|
||||||
}
|
}
|
||||||
|
|
||||||
hexColumn += 3;
|
hexColumn += 3;
|
||||||
charColumn++;
|
charColumn++;
|
||||||
}
|
}
|
||||||
result.Append(line);
|
|
||||||
|
sb.Append(line);
|
||||||
}
|
}
|
||||||
return Environment.NewLine + result.ToString();
|
|
||||||
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UInt32 UnixTimeStampUTC()
|
public static UInt32 UnixTimeStampUTC()
|
||||||
|
|
|
@ -227,7 +227,7 @@ namespace FFXIVClassic_Lobby_Server.dataobjects
|
||||||
{
|
{
|
||||||
byte[] bytes = File.ReadAllBytes("./packets/charaappearance.bin");
|
byte[] bytes = File.ReadAllBytes("./packets/charaappearance.bin");
|
||||||
|
|
||||||
Log.debug(Utils.ByteArrayToHex(bytes));
|
Log.Debug(Utils.ByteArrayToHex(bytes));
|
||||||
|
|
||||||
return Convert.ToBase64String(bytes).Replace('+', '-').Replace('/', '_');
|
return Convert.ToBase64String(bytes).Replace('+', '-').Replace('/', '_');
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@ namespace FFXIVClassic_Lobby_Server
|
||||||
charaInfo.Replace("/", "_");
|
charaInfo.Replace("/", "_");
|
||||||
byte[] data = System.Convert.FromBase64String(charaInfo);
|
byte[] data = System.Convert.FromBase64String(charaInfo);
|
||||||
|
|
||||||
Log.debug("------------Base64 printout------------------");
|
Log.Debug("------------Base64 printout------------------");
|
||||||
Log.debug(Utils.ByteArrayToHex(data));
|
Log.Debug(Utils.ByteArrayToHex(data));
|
||||||
Log.debug("------------Base64 printout------------------");
|
Log.Debug("------------Base64 printout------------------");
|
||||||
|
|
||||||
CharaInfo chara = new CharaInfo();
|
CharaInfo chara = new CharaInfo();
|
||||||
|
|
||||||
|
|
|
@ -335,8 +335,8 @@ namespace FFXIVClassic_Lobby_Server.packets
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Console.BackgroundColor = ConsoleColor.DarkYellow;
|
Console.BackgroundColor = ConsoleColor.DarkYellow;
|
||||||
Log.debug(String.Format("IsAuthed: {0}, IsEncrypted: {1}, Size: 0x{2:X}, Num Subpackets: {3}", header.isAuthenticated, header.isEncrypted, header.packetSize, header.numSubpackets));
|
Log.Debug(String.Format("IsAuthed: {0}, IsEncrypted: {1}, Size: 0x{2:X}, Num Subpackets: {3}", header.isAuthenticated, header.isEncrypted, header.packetSize, header.numSubpackets));
|
||||||
Log.debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes())));
|
Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes())));
|
||||||
foreach (SubPacket sub in getSubpackets())
|
foreach (SubPacket sub in getSubpackets())
|
||||||
sub.debugPrintSubPacket();
|
sub.debugPrintSubPacket();
|
||||||
Console.BackgroundColor = ConsoleColor.Black;
|
Console.BackgroundColor = ConsoleColor.Black;
|
||||||
|
|
|
@ -141,14 +141,14 @@ namespace FFXIVClassic_Lobby_Server.packets
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Console.BackgroundColor = ConsoleColor.DarkRed;
|
Console.BackgroundColor = ConsoleColor.DarkRed;
|
||||||
Log.debug(String.Format("Size: 0x{0:X}", header.subpacketSize));
|
Log.Debug(String.Format("Size: 0x{0:X}", header.subpacketSize));
|
||||||
if (header.type == 0x03)
|
if (header.type == 0x03)
|
||||||
Log.debug(String.Format("Opcode: 0x{0:X}", gameMessage.opcode));
|
Log.Debug(String.Format("Opcode: 0x{0:X}", gameMessage.opcode));
|
||||||
Log.debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes())));
|
Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes())));
|
||||||
if (header.type == 0x03)
|
if (header.type == 0x03)
|
||||||
Log.debug(String.Format("{0}", Utils.ByteArrayToHex(getGameMessageBytes())));
|
Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getGameMessageBytes())));
|
||||||
Console.BackgroundColor = ConsoleColor.DarkMagenta;
|
Console.BackgroundColor = ConsoleColor.DarkMagenta;
|
||||||
Log.debug(String.Format("{0}", Utils.ByteArrayToHex(data)));
|
Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(data)));
|
||||||
Console.BackgroundColor = ConsoleColor.Black;
|
Console.BackgroundColor = ConsoleColor.Black;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
socket.Send(packetBytes);
|
socket.Send(packetBytes);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{ Log.error(String.Format("Weird case, socket was d/ced: {0}", e)); }
|
{ Log.Error(String.Format("Weird case, socket was d/ced: {0}", e)); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
{
|
{
|
||||||
if (client != 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));
|
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.");
|
Log.Error("Zone does not exist or setting isn't valid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (client != null)
|
if (client != null)
|
||||||
|
@ -142,7 +142,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
|
||||||
{
|
{
|
||||||
Player p = entry.Value.getActor();
|
Player p = entry.Value.getActor();
|
||||||
Log.info(String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation));
|
Log.Info(String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,7 +578,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not change weather: " + e);
|
Log.Error("Could not change weather: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -597,7 +597,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not load packet: " + e);
|
Log.Error("Could not load packet: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -607,7 +607,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
{
|
{
|
||||||
if (client != null)
|
if (client != null)
|
||||||
{
|
{
|
||||||
Log.info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId));
|
Log.Info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId));
|
||||||
client.getActor().zone.clear();
|
client.getActor().zone.clear();
|
||||||
client.getActor().zone.addActorToZone(client.getActor());
|
client.getActor().zone.addActorToZone(client.getActor());
|
||||||
client.getActor().sendInstanceUpdate();
|
client.getActor().sendInstanceUpdate();
|
||||||
|
@ -621,11 +621,11 @@ namespace FFXIVClassic_Map_Server
|
||||||
#region !reloaditems
|
#region !reloaditems
|
||||||
else if (split[0].Equals("reloaditems"))
|
else if (split[0].Equals("reloaditems"))
|
||||||
{
|
{
|
||||||
Log.info(String.Format("Got request to reload item gamedata"));
|
Log.Info(String.Format("Got request to reload item gamedata"));
|
||||||
sendMessage(client, "Reloading Item Gamedata...");
|
sendMessage(client, "Reloading Item Gamedata...");
|
||||||
gamedataItems.Clear();
|
gamedataItems.Clear();
|
||||||
gamedataItems = Database.getItemGamedata();
|
gamedataItems = Database.getItemGamedata();
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -644,7 +644,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not load packet: " + e);
|
Log.Error("Could not load packet: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -660,7 +660,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not give item.");
|
Log.Error("Could not give item.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -680,7 +680,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not give item.");
|
Log.Error("Could not give item.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -703,7 +703,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not remove item.");
|
Log.Error("Could not remove item.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -718,7 +718,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not give keyitem.");
|
Log.Error("Could not give keyitem.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -737,7 +737,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not remove keyitem.");
|
Log.Error("Could not remove keyitem.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -754,7 +754,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not give currency.");
|
Log.Error("Could not give currency.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -775,7 +775,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not remove currency.");
|
Log.Error("Could not remove currency.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -793,7 +793,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.error("Could not change music: " + e);
|
Log.Error("Could not change music: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -138,7 +138,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -196,7 +196,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -232,7 +232,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -274,7 +274,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -308,7 +308,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -322,7 +322,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
int slot = player.getQuestSlot(quest.actorId);
|
int slot = player.getQuestSlot(quest.actorId);
|
||||||
if (slot == -1)
|
if (slot == -1)
|
||||||
{
|
{
|
||||||
Log.error(String.Format("Tried saving quest player didn't have: Player: {0:x}, QuestId: {0:x}", player.actorId, quest.actorId));
|
Log.Error(String.Format("Tried saving quest player didn't have: Player: {0:x}, QuestId: {0:x}", player.actorId, quest.actorId));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -360,7 +360,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -790,7 +790,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -834,7 +834,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -872,7 +872,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -905,7 +905,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -976,7 +976,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1032,7 +1032,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1067,7 +1067,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1107,7 +1107,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1148,7 +1148,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1188,7 +1188,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1225,7 +1225,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
|
|
||||||
if (offset < 0 || offset >= cheevosPacket.achievementFlags.Length)
|
if (offset < 0 || offset >= cheevosPacket.achievementFlags.Length)
|
||||||
{
|
{
|
||||||
Log.error("SQL Error; achievement flag offset id out of range: " + offset);
|
Log.Error("SQL Error; achievement flag offset id out of range: " + offset);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cheevosPacket.achievementFlags[offset] = true;
|
cheevosPacket.achievementFlags[offset] = true;
|
||||||
|
@ -1234,7 +1234,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,9 +127,9 @@ namespace FFXIVClassic_Map_Server
|
||||||
player.setConnection(packet.header.connectionType, client);
|
player.setConnection(packet.header.connectionType, client);
|
||||||
|
|
||||||
if (packet.header.connectionType == BasePacket.TYPE_ZONE)
|
if (packet.header.connectionType == BasePacket.TYPE_ZONE)
|
||||||
Log.debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.getAddress()));
|
Log.Debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.getAddress()));
|
||||||
else if (packet.header.connectionType == BasePacket.TYPE_CHAT)
|
else if (packet.header.connectionType == BasePacket.TYPE_CHAT)
|
||||||
Log.debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.getAddress()));
|
Log.Debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.getAddress()));
|
||||||
|
|
||||||
//Create player actor
|
//Create player actor
|
||||||
reply1.debugPrintPacket();
|
reply1.debugPrintPacket();
|
||||||
|
@ -180,7 +180,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
//Chat Received
|
//Chat Received
|
||||||
case 0x0003:
|
case 0x0003:
|
||||||
ChatMessagePacket chatMessage = new ChatMessagePacket(subpacket.data);
|
ChatMessagePacket chatMessage = new ChatMessagePacket(subpacket.data);
|
||||||
Log.info(String.Format("Got type-{5} message: {0} @ {1}, {2}, {3}, Rot: {4}", chatMessage.message, chatMessage.posX, chatMessage.posY, chatMessage.posZ, chatMessage.posRot, chatMessage.logType));
|
Log.Info(String.Format("Got type-{5} message: {0} @ {1}, {2}, {3}, Rot: {4}", chatMessage.message, chatMessage.posX, chatMessage.posY, chatMessage.posZ, chatMessage.posRot, chatMessage.logType));
|
||||||
subpacket.debugPrintSubPacket();
|
subpacket.debugPrintSubPacket();
|
||||||
|
|
||||||
if (chatMessage.message.StartsWith("!"))
|
if (chatMessage.message.StartsWith("!"))
|
||||||
|
@ -238,7 +238,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
player.errorMessage += eventStart.error;
|
player.errorMessage += eventStart.error;
|
||||||
|
|
||||||
if (eventStart.errorIndex == eventStart.errorNum - 1)
|
if (eventStart.errorIndex == eventStart.errorNum - 1)
|
||||||
Log.error("\n"+player.errorMessage);
|
Log.Error("\n"+player.errorMessage);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -268,7 +268,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
ownerActor = player.getActor().currentDirector;
|
ownerActor = player.getActor().currentDirector;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.debug(String.Format("\n===Event START===\nCould not find actor 0x{0:X} for event started by caller: 0x{1:X}\nEvent Starter: {2}\nParams: {3}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams)));
|
Log.Debug(String.Format("\n===Event START===\nCould not find actor 0x{0:X} for event started by caller: 0x{1:X}\nEvent Starter: {2}\nParams: {3}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
|
|
||||||
LuaEngine.doActorOnEventStarted(player.getActor(), ownerActor, eventStart);
|
LuaEngine.doActorOnEventStarted(player.getActor(), ownerActor, eventStart);
|
||||||
|
|
||||||
Log.debug(String.Format("\n===Event START===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nEvent Starter: {4}\nParams: {5}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.val1, eventStart.val2, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams)));
|
Log.Debug(String.Format("\n===Event START===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nEvent Starter: {4}\nParams: {5}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.val1, eventStart.val2, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams)));
|
||||||
break;
|
break;
|
||||||
//Unknown, happens at npc spawn and cutscene play????
|
//Unknown, happens at npc spawn and cutscene play????
|
||||||
case 0x00CE:
|
case 0x00CE:
|
||||||
|
@ -285,7 +285,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
case 0x012E:
|
case 0x012E:
|
||||||
subpacket.debugPrintSubPacket();
|
subpacket.debugPrintSubPacket();
|
||||||
EventUpdatePacket eventUpdate = new EventUpdatePacket(subpacket.data);
|
EventUpdatePacket eventUpdate = new EventUpdatePacket(subpacket.data);
|
||||||
Log.debug(String.Format("\n===Event UPDATE===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nStep: 0x{4:X}\nParams: {5}", eventUpdate.actorID, eventUpdate.scriptOwnerActorID, eventUpdate.val1, eventUpdate.val2, eventUpdate.step, LuaUtils.dumpParams(eventUpdate.luaParams)));
|
Log.Debug(String.Format("\n===Event UPDATE===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nStep: 0x{4:X}\nParams: {5}", eventUpdate.actorID, eventUpdate.scriptOwnerActorID, eventUpdate.val1, eventUpdate.val2, eventUpdate.step, LuaUtils.dumpParams(eventUpdate.luaParams)));
|
||||||
|
|
||||||
//Is it a static actor? If not look in the player's instance
|
//Is it a static actor? If not look in the player's instance
|
||||||
Actor updateOwnerActor = Server.getStaticActors(player.getActor().currentEventOwner);
|
Actor updateOwnerActor = Server.getStaticActors(player.getActor().currentEventOwner);
|
||||||
|
@ -398,7 +398,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
//GM Ticket Sent
|
//GM Ticket Sent
|
||||||
case 0x01D5:
|
case 0x01D5:
|
||||||
GMSupportTicketPacket gmTicket = new GMSupportTicketPacket(subpacket.data);
|
GMSupportTicketPacket gmTicket = new GMSupportTicketPacket(subpacket.data);
|
||||||
Log.info("Got GM Ticket: \n" + gmTicket.ticketTitle + "\n" + gmTicket.ticketBody);
|
Log.Info("Got GM Ticket: \n" + gmTicket.ticketTitle + "\n" + gmTicket.ticketBody);
|
||||||
client.queuePacket(BasePacket.createPacket(GMTicketSentResponsePacket.buildPacket(player.actorID, true), true, false));
|
client.queuePacket(BasePacket.createPacket(GMTicketSentResponsePacket.buildPacket(player.actorID, true), true, false));
|
||||||
break;
|
break;
|
||||||
//Request to end ticket
|
//Request to end ticket
|
||||||
|
@ -406,7 +406,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
client.queuePacket(BasePacket.createPacket(EndGMTicketPacket.buildPacket(player.actorID), true, false));
|
client.queuePacket(BasePacket.createPacket(EndGMTicketPacket.buildPacket(player.actorID), true, false));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode));
|
Log.Debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode));
|
||||||
subpacket.debugPrintSubPacket();
|
subpacket.debugPrintSubPacket();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,14 @@ namespace FFXIVClassic_Map_Server
|
||||||
if (!ConfigConstants.load())
|
if (!ConfigConstants.load())
|
||||||
startServer = false;
|
startServer = false;
|
||||||
|
|
||||||
Log.info("---------FFXIV 1.0 Map Server---------");
|
Log.Info("---------FFXIV 1.0 Map Server---------");
|
||||||
|
|
||||||
Assembly assem = Assembly.GetExecutingAssembly();
|
Assembly assem = Assembly.GetExecutingAssembly();
|
||||||
Version vers = assem.GetName().Version;
|
Version vers = assem.GetName().Version;
|
||||||
Log.info("Version: " + vers.ToString());
|
Log.Info("Version: " + vers.ToString());
|
||||||
|
|
||||||
//Test DB Connection
|
//Test DB Connection
|
||||||
Log.info("Testing DB connection... ");
|
Log.Info("Testing DB connection... ");
|
||||||
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
|
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -36,11 +36,11 @@ namespace FFXIVClassic_Map_Server
|
||||||
conn.Open();
|
conn.Open();
|
||||||
conn.Close();
|
conn.Close();
|
||||||
|
|
||||||
Log.conn("[OK]");
|
Log.Status("[OK]");
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
startServer = false;
|
startServer = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ namespace FFXIVClassic_Map_Server
|
||||||
//Check World ID
|
//Check World ID
|
||||||
DBWorld thisWorld = Database.getServer(ConfigConstants.DATABASE_WORLDID);
|
DBWorld thisWorld = Database.getServer(ConfigConstants.DATABASE_WORLDID);
|
||||||
if (thisWorld != null)
|
if (thisWorld != null)
|
||||||
Log.info(String.Format("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name));
|
Log.Info(String.Format("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name));
|
||||||
else
|
else
|
||||||
Log.info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed.");
|
Log.Info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed.");
|
||||||
|
|
||||||
//Start server if A-OK
|
//Start server if A-OK
|
||||||
if (startServer)
|
if (startServer)
|
||||||
|
@ -66,7 +66,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info("Press any key to continue...");
|
Log.Info("Press any key to continue...");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
|
|
||||||
private void connectionHealth()
|
private void connectionHealth()
|
||||||
{
|
{
|
||||||
Log.info(String.Format("Connection Health thread started; it will run every {0} seconds.", HEALTH_THREAD_SLEEP_TIME));
|
Log.Info(String.Format("Connection Health thread started; it will run every {0} seconds.", HEALTH_THREAD_SLEEP_TIME));
|
||||||
while (!killHealthThread)
|
while (!killHealthThread)
|
||||||
{
|
{
|
||||||
lock (mConnectedPlayerList)
|
lock (mConnectedPlayerList)
|
||||||
|
@ -77,7 +77,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
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));
|
||||||
|
|
||||||
mWorldManager = new WorldManager(this);
|
mWorldManager = new WorldManager(this);
|
||||||
mWorldManager.LoadZoneList();
|
mWorldManager.LoadZoneList();
|
||||||
|
@ -113,7 +113,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.White;
|
Console.ForegroundColor = ConsoleColor.White;
|
||||||
Log.debug(String.Format("Map Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
|
Log.Debug(String.Format("Map Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
Console.ForegroundColor = ConsoleColor.Gray;
|
||||||
|
|
||||||
mProcessor = new PacketProcessor(this, mConnectedPlayerList, mConnectionList);
|
mProcessor = new PacketProcessor(this, mConnectedPlayerList, mConnectionList);
|
||||||
|
@ -150,7 +150,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
mConnectionList.Add(conn);
|
mConnectionList.Add(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.conn(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
|
Log.Status(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
|
||||||
//Queue recieving of data from the connection
|
//Queue recieving of data from the connection
|
||||||
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);
|
||||||
//Queue the accept of the next incomming connection
|
//Queue the accept of the next incomming connection
|
||||||
|
@ -217,7 +217,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
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.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
|
Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
|
||||||
|
|
||||||
lock (mConnectionList)
|
lock (mConnectionList)
|
||||||
{
|
{
|
||||||
|
@ -273,7 +273,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
{
|
{
|
||||||
if (conn.socket != null)
|
if (conn.socket != null)
|
||||||
{
|
{
|
||||||
Log.conn(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
|
Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
|
||||||
|
|
||||||
lock (mConnectionList)
|
lock (mConnectionList)
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -117,7 +117,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -125,7 +125,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info(String.Format("Loaded {0} zones and {1} private areas.", count1, count2));
|
Log.Info(String.Format("Loaded {0} zones and {1} private areas.", count1, count2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadZoneEntranceList()
|
public void LoadZoneEntranceList()
|
||||||
|
@ -170,7 +170,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -178,7 +178,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info(String.Format("Loaded {0} zone spawn locations.", count));
|
Log.Info(String.Format("Loaded {0} zone spawn locations.", count));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadNPCs()
|
public void LoadNPCs()
|
||||||
|
@ -242,7 +242,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -250,7 +250,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info(String.Format("Loaded {0} npc(s).", count));
|
Log.Info(String.Format("Loaded {0} npc(s).", count));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadNPCs(uint zoneId)
|
public void LoadNPCs(uint zoneId)
|
||||||
|
@ -315,7 +315,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -323,7 +323,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.info(String.Format("Loaded {0} npc(s).", count));
|
Log.Info(String.Format("Loaded {0} npc(s).", count));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Moves the actor to the new zone if exists. No packets are sent nor position changed.
|
//Moves the actor to the new zone if exists. No packets are sent nor position changed.
|
||||||
|
@ -354,7 +354,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
{
|
{
|
||||||
if (!zoneEntranceList.ContainsKey(zoneEntrance))
|
if (!zoneEntranceList.ContainsKey(zoneEntrance))
|
||||||
{
|
{
|
||||||
Log.error("Given zone entrance was not found: " + zoneEntrance);
|
Log.Error("Given zone entrance was not found: " + zoneEntrance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ namespace FFXIVClassic_Map_Server
|
||||||
{
|
{
|
||||||
if (!zoneEntranceList.ContainsKey(zoneEntrance))
|
if (!zoneEntranceList.ContainsKey(zoneEntrance))
|
||||||
{
|
{
|
||||||
Log.error("Given zone entrance was not found: " + zoneEntrance);
|
Log.Error("Given zone entrance was not found: " + zoneEntrance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,9 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(FileNotFoundException e)
|
catch(FileNotFoundException e)
|
||||||
{ Log.error("Could not find staticactors file."); return false; }
|
{ Log.Error("Could not find staticactors file."); return false; }
|
||||||
|
|
||||||
Log.info(String.Format("Loaded {0} static actors.", mStaticActors.Count()));
|
Log.Info(String.Format("Loaded {0} static actors.", mStaticActors.Count()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,7 +238,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
|
@ -642,7 +642,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
Database.savePlayerPlayTime(this);
|
Database.savePlayerPlayTime(this);
|
||||||
Database.savePlayerPosition(this);
|
Database.savePlayerPosition(this);
|
||||||
|
|
||||||
Log.info(String.Format("{0} has been logged out and saved.", this.customDisplayName));
|
Log.Info(String.Format("{0} has been logged out and saved.", this.customDisplayName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Area getZone()
|
public Area getZone()
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
{
|
{
|
||||||
if (bitIndex >= 32)
|
if (bitIndex >= 32)
|
||||||
{
|
{
|
||||||
Log.error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId));
|
Log.Error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
{
|
{
|
||||||
if (bitIndex >= 32)
|
if (bitIndex >= 32)
|
||||||
{
|
{
|
||||||
Log.error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId));
|
Log.Error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace FFXIVClassic_Map_Server.common
|
namespace FFXIVClassic_Map_Server.common
|
||||||
{
|
{
|
||||||
|
@ -7,66 +8,64 @@ namespace FFXIVClassic_Map_Server.common
|
||||||
{
|
{
|
||||||
public enum LogType
|
public enum LogType
|
||||||
{
|
{
|
||||||
Error = ConsoleColor.Red,
|
Status = ConsoleColor.Green,
|
||||||
Debug = ConsoleColor.Yellow,
|
|
||||||
Info = ConsoleColor.Cyan,
|
|
||||||
Sql = ConsoleColor.Magenta,
|
Sql = ConsoleColor.Magenta,
|
||||||
Conn = ConsoleColor.Green,
|
Info = ConsoleColor.White,
|
||||||
Default = ConsoleColor.Gray
|
Debug = ConsoleColor.Cyan,
|
||||||
|
Error = ConsoleColor.Red
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(String message)
|
public static void Status(String message)
|
||||||
{
|
{
|
||||||
log(message, LogType.Error);
|
LogFile(message, LogType.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(String message)
|
public static void Sql(String message)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
LogFile(message, LogType.Sql);
|
||||||
log(message, LogType.Debug);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(String message)
|
public static void Info(String message)
|
||||||
{
|
{
|
||||||
log(message, LogType.Info);
|
LogFile(message, LogType.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void database(String message)
|
public static void Debug(String message)
|
||||||
{
|
{
|
||||||
log(message, LogType.Sql);
|
#if DEBUG
|
||||||
|
LogFile(message, LogType.Debug);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void conn(String message)
|
public static void Error(String message)
|
||||||
{
|
{
|
||||||
log(message, LogType.Conn);
|
LogFile(message, LogType.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void log(String message, LogType type)
|
private static void LogFile(String message, LogType type)
|
||||||
{
|
{
|
||||||
var timestamp = String.Format("[{0}] ", DateTime.Now.ToString("dd/MMM HH:mm:ss"));
|
string timestamp = String.Format("[{0}]", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));
|
||||||
var typestr = String.Format("[{0}] ", type.ToString().ToUpper());
|
string messageType = String.Format("[{0}] ", type.ToString().ToUpper());
|
||||||
|
|
||||||
Console.Write(timestamp);
|
Console.WriteLine(timestamp);
|
||||||
Console.ForegroundColor = (ConsoleColor)type;
|
Console.ForegroundColor = (ConsoleColor)type;
|
||||||
Console.Write(typestr);
|
Console.Write(messageType);
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
Console.ResetColor();
|
||||||
Console.WriteLine(message);
|
Console.Write(message);
|
||||||
|
|
||||||
message = message.Insert(0, typestr);
|
StringBuilder sb = new StringBuilder();
|
||||||
message = message.Insert(0, timestamp);
|
|
||||||
|
|
||||||
Directory.CreateDirectory(ConfigConstants.OPTIONS_LOGPATH);
|
sb.AppendLine(String.Format("{0}{1}{2}", timestamp, messageType, message));
|
||||||
|
|
||||||
try
|
if (!Directory.Exists(ConfigConstants.OPTIONS_LOGPATH))
|
||||||
{
|
{
|
||||||
File.AppendAllText(ConfigConstants.OPTIONS_LOGPATH + ConfigConstants.OPTIONS_LOGFILE, message + Environment.NewLine);
|
Directory.CreateDirectory(ConfigConstants.OPTIONS_LOGPATH);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
|
using (FileStream fs = new FileStream(Path.Combine(ConfigConstants.OPTIONS_LOGPATH, ConfigConstants.OPTIONS_LOGFILE), FileMode.Append, FileAccess.Write))
|
||||||
|
using (StreamWriter sw = new StreamWriter(fs))
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
sw.WriteLine(sb.ToString());
|
||||||
Console.Write(e.Message);
|
|
||||||
Console.ForegroundColor = ConsoleColor.Gray;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,48 +19,48 @@ namespace FFXIVClassic_Map_Server.common
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ByteArrayToHex(byte[] bytes)
|
public static string ByteArrayToHex(byte[] bytes, int offset = 0, int bytesPerLine = 16)
|
||||||
{
|
{
|
||||||
if (bytes == null) return "<null>";
|
if (bytes == null)
|
||||||
int bytesLength = bytes.Length;
|
{
|
||||||
var bytesPerLine = 16;
|
return String.Empty;
|
||||||
char[] HexChars = "0123456789ABCDEF".ToCharArray();
|
}
|
||||||
|
|
||||||
int firstHexColumn =
|
char[] hexChars = "0123456789ABCDEF".ToCharArray();
|
||||||
8 // 8 characters for the address
|
|
||||||
+ 3; // 3 spaces
|
|
||||||
|
|
||||||
int firstCharColumn = firstHexColumn
|
// 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
|
||||||
+ bytesPerLine * 3 // - 2 digit for the hexadecimal value and 1 space
|
// 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
|
||||||
+ (bytesPerLine - 1) / 8 // - 1 extra space every 8 characters from the 9th
|
int offsetBlock = 8 + 3;
|
||||||
+ 2; // 2 spaces
|
int byteBlock = offsetBlock + (bytesPerLine * 3) + ((bytesPerLine - 1) / 8) + 2;
|
||||||
|
int lineLength = byteBlock + bytesPerLine + Environment.NewLine.Length;
|
||||||
int lineLength = firstCharColumn
|
|
||||||
+ bytesPerLine // - characters to show the ascii value
|
|
||||||
+ Environment.NewLine.Length; // Carriage return and line feed (should normally be 2)
|
|
||||||
|
|
||||||
char[] line = (new String(' ', lineLength - Environment.NewLine.Length) + Environment.NewLine).ToCharArray();
|
char[] line = (new String(' ', lineLength - Environment.NewLine.Length) + Environment.NewLine).ToCharArray();
|
||||||
int expectedLines = (bytesLength + bytesPerLine - 1) / bytesPerLine;
|
int numLines = (bytes.Length + bytesPerLine - 1) / bytesPerLine;
|
||||||
StringBuilder result = new StringBuilder(expectedLines * lineLength);
|
|
||||||
|
|
||||||
for (int i = 0; i < bytesLength; i += bytesPerLine)
|
StringBuilder sb = new StringBuilder(numLines * lineLength);
|
||||||
|
|
||||||
|
for (int i = offset; i < bytes.Length; i += bytesPerLine)
|
||||||
{
|
{
|
||||||
line[0] = HexChars[(i >> 28) & 0xF];
|
line[0] = hexChars[(i >> 28) & 0xF];
|
||||||
line[1] = HexChars[(i >> 24) & 0xF];
|
line[1] = hexChars[(i >> 24) & 0xF];
|
||||||
line[2] = HexChars[(i >> 20) & 0xF];
|
line[2] = hexChars[(i >> 20) & 0xF];
|
||||||
line[3] = HexChars[(i >> 16) & 0xF];
|
line[3] = hexChars[(i >> 16) & 0xF];
|
||||||
line[4] = HexChars[(i >> 12) & 0xF];
|
line[4] = hexChars[(i >> 12) & 0xF];
|
||||||
line[5] = HexChars[(i >> 8) & 0xF];
|
line[5] = hexChars[(i >> 8) & 0xF];
|
||||||
line[6] = HexChars[(i >> 4) & 0xF];
|
line[6] = hexChars[(i >> 4) & 0xF];
|
||||||
line[7] = HexChars[(i >> 0) & 0xF];
|
line[7] = hexChars[(i >> 0) & 0xF];
|
||||||
|
|
||||||
int hexColumn = firstHexColumn;
|
int hexColumn = offsetBlock;
|
||||||
int charColumn = firstCharColumn;
|
int charColumn = byteBlock;
|
||||||
|
|
||||||
for (int j = 0; j < bytesPerLine; j++)
|
for (int j = 0; j < bytesPerLine; j++)
|
||||||
{
|
{
|
||||||
if (j > 0 && (j & 7) == 0) hexColumn++;
|
if (j > 0 && (j & 7) == 0)
|
||||||
if (i + j >= bytesLength)
|
{
|
||||||
|
hexColumn++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i + j >= bytes.Length)
|
||||||
{
|
{
|
||||||
line[hexColumn] = ' ';
|
line[hexColumn] = ' ';
|
||||||
line[hexColumn + 1] = ' ';
|
line[hexColumn + 1] = ' ';
|
||||||
|
@ -68,17 +68,20 @@ namespace FFXIVClassic_Map_Server.common
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte b = bytes[i + j];
|
byte by = bytes[i + j];
|
||||||
line[hexColumn] = HexChars[(b >> 4) & 0xF];
|
line[hexColumn] = hexChars[(by >> 4) & 0xF];
|
||||||
line[hexColumn + 1] = HexChars[b & 0xF];
|
line[hexColumn + 1] = hexChars[by & 0xF];
|
||||||
line[charColumn] = (b < 32 ? '.' : (char)b);
|
line[charColumn] = (by < 32 ? '.' : (char)by);
|
||||||
}
|
}
|
||||||
|
|
||||||
hexColumn += 3;
|
hexColumn += 3;
|
||||||
charColumn++;
|
charColumn++;
|
||||||
}
|
}
|
||||||
result.Append(line);
|
|
||||||
|
sb.Append(line);
|
||||||
}
|
}
|
||||||
return Environment.NewLine + result.ToString();
|
|
||||||
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UInt32 UnixTimeStampUTC()
|
public static UInt32 UnixTimeStampUTC()
|
||||||
|
@ -138,77 +141,77 @@ namespace FFXIVClassic_Map_Server.common
|
||||||
|
|
||||||
public static uint MurmurHash2(string key, uint seed)
|
public static uint MurmurHash2(string key, uint seed)
|
||||||
{
|
{
|
||||||
// 'm' and 'r' are mixing constants generated offline.
|
// 'm' and 'r' are mixing constants generated offline.
|
||||||
// They're not really 'magic', they just happen to work well.
|
// They're not really 'magic', they just happen to work well.
|
||||||
|
|
||||||
byte[] data = Encoding.ASCII.GetBytes(key);
|
byte[] data = Encoding.ASCII.GetBytes(key);
|
||||||
const uint m = 0x5bd1e995;
|
const uint m = 0x5bd1e995;
|
||||||
const int r = 24;
|
const int r = 24;
|
||||||
int len = key.Length;
|
int len = key.Length;
|
||||||
int dataIndex = len - 4;
|
int dataIndex = len - 4;
|
||||||
|
|
||||||
// Initialize the hash to a 'random' value
|
// Initialize the hash to a 'random' value
|
||||||
|
|
||||||
uint h = seed ^ (uint)len;
|
uint h = seed ^ (uint)len;
|
||||||
|
|
||||||
// Mix 4 bytes at a time into the hash
|
// Mix 4 bytes at a time into the hash
|
||||||
|
|
||||||
|
|
||||||
while (len >= 4)
|
while (len >= 4)
|
||||||
{
|
{
|
||||||
h *= m;
|
h *= m;
|
||||||
|
|
||||||
uint k = (uint)BitConverter.ToInt32(data, dataIndex);
|
uint k = (uint)BitConverter.ToInt32(data, dataIndex);
|
||||||
k = ((k >> 24) & 0xff) | // move byte 3 to byte 0
|
k = ((k >> 24) & 0xff) | // move byte 3 to byte 0
|
||||||
((k << 8) & 0xff0000) | // move byte 1 to byte 2
|
((k << 8) & 0xff0000) | // move byte 1 to byte 2
|
||||||
((k >> 8) & 0xff00) | // move byte 2 to byte 1
|
((k >> 8) & 0xff00) | // move byte 2 to byte 1
|
||||||
((k << 24) & 0xff000000); // byte 0 to byte 3
|
((k << 24) & 0xff000000); // byte 0 to byte 3
|
||||||
|
|
||||||
k *= m;
|
k *= m;
|
||||||
k ^= k >> r;
|
k ^= k >> r;
|
||||||
k *= m;
|
k *= m;
|
||||||
|
|
||||||
h ^= k;
|
h ^= k;
|
||||||
|
|
||||||
dataIndex -= 4;
|
dataIndex -= 4;
|
||||||
len -= 4;
|
len -= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the last few bytes of the input array
|
// Handle the last few bytes of the input array
|
||||||
switch (len)
|
switch (len)
|
||||||
{
|
{
|
||||||
case 3:
|
case 3:
|
||||||
h ^= (uint)data[0] << 16; goto case 2;
|
h ^= (uint)data[0] << 16; goto case 2;
|
||||||
case 2:
|
case 2:
|
||||||
h ^= (uint)data[len-2] << 8; goto case 1;
|
h ^= (uint)data[len - 2] << 8; goto case 1;
|
||||||
case 1:
|
case 1:
|
||||||
h ^= data[len-1];
|
h ^= data[len - 1];
|
||||||
h *= m;
|
h *= m;
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Do a few final mixes of the hash to ensure the last few
|
// Do a few final mixes of the hash to ensure the last few
|
||||||
// bytes are well-incorporated.
|
// bytes are well-incorporated.
|
||||||
|
|
||||||
h ^= h >> 13;
|
h ^= h >> 13;
|
||||||
h *= m;
|
h *= m;
|
||||||
h ^= h >> 15;
|
h ^= h >> 15;
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] ConvertBoolArrayToBinaryStream(bool[] array)
|
public static byte[] ConvertBoolArrayToBinaryStream(bool[] array)
|
||||||
{
|
{
|
||||||
byte[] data = new byte[(array.Length/8)+(array.Length%8 != 0 ? 1 : 0)];
|
byte[] data = new byte[(array.Length / 8) + (array.Length % 8 != 0 ? 1 : 0)];
|
||||||
|
|
||||||
int dataCounter = 0;
|
int dataCounter = 0;
|
||||||
for (int i = 0; i < array.Length; i+=8)
|
for (int i = 0; i < array.Length; i += 8)
|
||||||
{
|
{
|
||||||
for (int bitCount = 0; bitCount < 8; bitCount++)
|
for (int bitCount = 0; bitCount < 8; bitCount++)
|
||||||
{
|
{
|
||||||
if (i + bitCount >= array.Length)
|
if (i + bitCount >= array.Length)
|
||||||
break;
|
break;
|
||||||
data[dataCounter] = (byte)(((array[i + bitCount] ? 1 : 0) << 7-bitCount) | data[dataCounter]);
|
data[dataCounter] = (byte)(((array[i + bitCount] ? 1 : 0) << 7 - bitCount) | data[dataCounter]);
|
||||||
}
|
}
|
||||||
dataCounter++;
|
dataCounter++;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +229,7 @@ namespace FFXIVClassic_Map_Server.common
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
uint key = (uint)data[offset + 0] << 8 | data[offset+1];
|
uint key = (uint)data[offset + 0] << 8 | data[offset + 1];
|
||||||
uint key2 = data[offset + 2];
|
uint key2 = data[offset + 2];
|
||||||
key = RotateRight(key, 1) & 0xFFFF;
|
key = RotateRight(key, 1) & 0xFFFF;
|
||||||
key -= 0x22AF;
|
key -= 0x22AF;
|
||||||
|
@ -258,7 +261,7 @@ namespace FFXIVClassic_Map_Server.common
|
||||||
|
|
||||||
offset += 4 + count2;
|
offset += 4 + count2;
|
||||||
|
|
||||||
Log.debug(result);
|
Log.Debug(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +313,7 @@ namespace FFXIVClassic_Map_Server.common
|
||||||
}
|
}
|
||||||
|
|
||||||
count = count ^ key;
|
count = count ^ key;
|
||||||
result[3] = (byte) (count & 0xFF);
|
result[3] = (byte)(count & 0xFF);
|
||||||
|
|
||||||
key += 0x22AF & 0xFFFF;
|
key += 0x22AF & 0xFFFF;
|
||||||
key = RotateLeft(key, 1) & 0xFFFF;
|
key = RotateLeft(key, 1) & 0xFFFF;
|
||||||
|
|
|
@ -217,7 +217,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
}
|
}
|
||||||
catch(SyntaxErrorException e)
|
catch(SyntaxErrorException e)
|
||||||
{
|
{
|
||||||
Log.error(String.Format("LUAERROR: {0}.", e.DecoratedMessage));
|
Log.Error(String.Format("LUAERROR: {0}.", e.DecoratedMessage));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return script;
|
return script;
|
||||||
|
|
|
@ -333,8 +333,8 @@ namespace FFXIVClassic_Map_Server.packets
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Console.BackgroundColor = ConsoleColor.DarkYellow;
|
Console.BackgroundColor = ConsoleColor.DarkYellow;
|
||||||
Log.debug(String.Format("IsAuthed: {0}, IsEncrypted: {1}, Size: 0x{2:X}, Num Subpackets: {3}", header.isAuthenticated, header.isCompressed, header.packetSize, header.numSubpackets));
|
Log.Debug(String.Format("IsAuthed: {0}, IsEncrypted: {1}, Size: 0x{2:X}, Num Subpackets: {3}", header.isAuthenticated, header.isCompressed, header.packetSize, header.numSubpackets));
|
||||||
Log.debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes())));
|
Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes())));
|
||||||
foreach (SubPacket sub in getSubpackets())
|
foreach (SubPacket sub in getSubpackets())
|
||||||
sub.debugPrintSubPacket();
|
sub.debugPrintSubPacket();
|
||||||
Console.BackgroundColor = ConsoleColor.Black;
|
Console.BackgroundColor = ConsoleColor.Black;
|
||||||
|
|
|
@ -141,14 +141,14 @@ namespace FFXIVClassic_Map_Server.packets
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Console.BackgroundColor = ConsoleColor.DarkRed;
|
Console.BackgroundColor = ConsoleColor.DarkRed;
|
||||||
Log.debug(String.Format("Size: 0x{0:X}", header.subpacketSize));
|
Log.Debug(String.Format("Size: 0x{0:X}", header.subpacketSize));
|
||||||
if (header.type == 0x03)
|
if (header.type == 0x03)
|
||||||
Log.debug(String.Format("Opcode: 0x{0:X}", gameMessage.opcode));
|
Log.Debug(String.Format("Opcode: 0x{0:X}", gameMessage.opcode));
|
||||||
Log.debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes())));
|
Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getHeaderBytes())));
|
||||||
if (header.type == 0x03)
|
if (header.type == 0x03)
|
||||||
Log.debug(String.Format("{0}", Utils.ByteArrayToHex(getGameMessageBytes())));
|
Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(getGameMessageBytes())));
|
||||||
Console.BackgroundColor = ConsoleColor.DarkMagenta;
|
Console.BackgroundColor = ConsoleColor.DarkMagenta;
|
||||||
Log.debug(String.Format("{0}", Utils.ByteArrayToHex(data)));
|
Log.Debug(String.Format("{0}", Utils.ByteArrayToHex(data)));
|
||||||
Console.BackgroundColor = ConsoleColor.Black;
|
Console.BackgroundColor = ConsoleColor.Black;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace FFXIVClassic_Map_Server.packets.receive.events
|
||||||
error = ASCIIEncoding.ASCII.GetString(binReader.ReadBytes(0x80)).Replace("\0", "");
|
error = ASCIIEncoding.ASCII.GetString(binReader.ReadBytes(0x80)).Replace("\0", "");
|
||||||
|
|
||||||
if (errorIndex == 0)
|
if (errorIndex == 0)
|
||||||
Log.error("LUA ERROR:");
|
Log.Error("LUA ERROR:");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace FFXIVClassic_Map_Server.packets.send.player
|
||||||
if (binStream.Length <= PACKET_SIZE - 0x20)
|
if (binStream.Length <= PACKET_SIZE - 0x20)
|
||||||
binWriter.Write(binStream);
|
binWriter.Write(binStream);
|
||||||
else
|
else
|
||||||
Log.error("Failed making SetCompletedAchievements packet. Bin Stream was too big!");
|
Log.Error("Failed making SetCompletedAchievements packet. Bin Stream was too big!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace FFXIVClassic_Map_Server.packets.send.player
|
||||||
if (binStream.Length <= PACKET_SIZE - 0x20)
|
if (binStream.Length <= PACKET_SIZE - 0x20)
|
||||||
binWriter.Write(binStream);
|
binWriter.Write(binStream);
|
||||||
else
|
else
|
||||||
Log.error("Failed making SetCutsceneBook packet. Bin Stream was too big!");
|
Log.Error("Failed making SetCutsceneBook packet. Bin Stream was too big!");
|
||||||
|
|
||||||
binWriter.Seek(0x109, SeekOrigin.Begin);
|
binWriter.Seek(0x109, SeekOrigin.Begin);
|
||||||
binWriter.Write(Encoding.ASCII.GetBytes(sNpcName), 0, Encoding.ASCII.GetByteCount(sNpcName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sNpcName));
|
binWriter.Write(Encoding.ASCII.GetBytes(sNpcName), 0, Encoding.ASCII.GetByteCount(sNpcName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sNpcName));
|
||||||
|
|
|
@ -79,14 +79,14 @@ namespace FFXIVClassic_Map_Server.utils
|
||||||
|
|
||||||
cmd.Parameters["@placename"].Value = placenames[pId];
|
cmd.Parameters["@placename"].Value = placenames[pId];
|
||||||
|
|
||||||
Log.debug(String.Format("Wrote: {0}", id));
|
Log.Debug(String.Format("Wrote: {0}", id));
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -137,14 +137,14 @@ namespace FFXIVClassic_Map_Server.utils
|
||||||
cmd.Parameters["@id"].Value = id;
|
cmd.Parameters["@id"].Value = id;
|
||||||
cmd.Parameters["@displayNameId"].Value = nameId;
|
cmd.Parameters["@displayNameId"].Value = nameId;
|
||||||
|
|
||||||
Log.debug(String.Format("Wrote: {0} : {1}", id, nameId));
|
Log.Debug(String.Format("Wrote: {0} : {1}", id, nameId));
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -203,14 +203,14 @@ namespace FFXIVClassic_Map_Server.utils
|
||||||
|
|
||||||
cmd.Parameters["@id"].Value = id;
|
cmd.Parameters["@id"].Value = id;
|
||||||
|
|
||||||
Log.debug(String.Format("Wrote: {0}", id));
|
Log.Debug(String.Format("Wrote: {0}", id));
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -288,7 +288,7 @@ namespace FFXIVClassic_Map_Server.utils
|
||||||
else if (id == 1500)
|
else if (id == 1500)
|
||||||
otherId = SetCompletedAchievementsPacket.CATEGORY_GRAND_COMPANY;
|
otherId = SetCompletedAchievementsPacket.CATEGORY_GRAND_COMPANY;
|
||||||
|
|
||||||
Log.debug(String.Format("Wrote: {0} : {1} : {2} : {3}", id, name, otherId, points));
|
Log.Debug(String.Format("Wrote: {0} : {1} : {2} : {3}", id, name, otherId, points));
|
||||||
cmd.Parameters["@id"].Value = id;
|
cmd.Parameters["@id"].Value = id;
|
||||||
cmd.Parameters["@name"].Value = name;
|
cmd.Parameters["@name"].Value = name;
|
||||||
cmd.Parameters["@otherId"].Value = otherId;
|
cmd.Parameters["@otherId"].Value = otherId;
|
||||||
|
@ -300,7 +300,7 @@ namespace FFXIVClassic_Map_Server.utils
|
||||||
}
|
}
|
||||||
catch (MySqlException e)
|
catch (MySqlException e)
|
||||||
{
|
{
|
||||||
Log.error(e.ToString());
|
Log.Error(e.ToString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -338,7 +338,7 @@ namespace FFXIVClassic_Map_Server.utils
|
||||||
|
|
||||||
string output2 = String.Format("mStaticActors.Add(0x{0:x}, new {2}(0x{0:x}, \"{1}\"));", id, output.Substring(1 + output.LastIndexOf("/")), output.Split('/')[1]);
|
string output2 = String.Format("mStaticActors.Add(0x{0:x}, new {2}(0x{0:x}, \"{1}\"));", id, output.Substring(1 + output.LastIndexOf("/")), output.Split('/')[1]);
|
||||||
|
|
||||||
Log.debug(output2);
|
Log.Debug(output2);
|
||||||
w.WriteLine(output2);
|
w.WriteLine(output2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue