more work on commands

- moved script object to wrapper class to catch and log exceptions
- added loggers for basepacket/subpacket (todo: colour and use them in NLog.config)
- finished up most commands (todo: !property and !property2)
- todo: create and use mysql wrapper class to log exceptions
This commit is contained in:
Tahir Akhlaq 2016-06-17 05:05:31 +01:00
parent 57b9d5ab99
commit 1ad2b5d7d0
35 changed files with 780 additions and 958 deletions

View file

@ -12,13 +12,13 @@ namespace FFXIVClassic_Lobby_Server
public static Logger Log;
static void Main(string[] args)
{
// set up logging
{
// set up logging
Log = LogManager.GetCurrentClassLogger();
#if DEBUG
TextWriterTraceListener myWriter = new TextWriterTraceListener(System.Console.Out);
Debug.Listeners.Add(myWriter);
Debug.Listeners.Add(myWriter);
#endif
Program.Log.Info("--------FFXIV 1.0 Lobby Server--------");
@ -55,6 +55,9 @@ namespace FFXIVClassic_Lobby_Server
{
Server server = new Server();
server.StartServer();
while (true)
Thread.Sleep(1000);
}
Program.Log.Info("Press any key to continue...");

View file

@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
using System.Diagnostics;
using FFXIVClassic.Common;
using System.IO;
using NLog;
namespace FFXIVClassic_Lobby_Server.packets
{
@ -21,7 +22,7 @@ namespace FFXIVClassic_Lobby_Server.packets
public class BasePacket
{
public static Logger Log = LogManager.GetCurrentClassLogger();
public const int TYPE_ZONE = 1;
public const int TYPE_CHAT = 2;
public const int BASEPACKET_SIZE = 0x10;
@ -332,12 +333,12 @@ namespace FFXIVClassic_Lobby_Server.packets
#endregion
public void DebugPrintPacket()
{
{
#if DEBUG
// todo: create new target for colourful packet logging
//Console.BackgroundColor = ConsoleColor.DarkYellow;
Program.Log.Debug("IsAuth: {0} Size: 0x{1:X}, NumSubpackets: {2}{3}{4}", header.isAuthenticated, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(GetHeaderBytes()));
// todo: create new target for colourful packet logging
//Console.BackgroundColor = ConsoleColor.DarkYellow;
Log.Debug("IsAuth: {0} Size: 0x{1:X}, NumSubpackets: {2}{3}{4}", header.isAuthenticated, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(GetHeaderBytes()));
foreach (SubPacket sub in GetSubpackets())
{

View file

@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;
using FFXIVClassic.Common;
using NLog;
namespace FFXIVClassic_Lobby_Server.packets
{
@ -26,6 +27,7 @@ namespace FFXIVClassic_Lobby_Server.packets
public class SubPacket
{
public static Logger Log = LogManager.GetCurrentClassLogger();
public const int SUBPACKET_SIZE = 0x10;
public const int GAMEMESSAGE_SIZE = 0x10;
@ -141,14 +143,14 @@ namespace FFXIVClassic_Lobby_Server.packets
{
#if DEBUG
// todo: create new target for colourful packet logging
Program.Log.Debug("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(GetHeaderBytes()));
Log.Debug("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(GetHeaderBytes()));
if (header.type == 0x03)
{
Program.Log.Debug("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(GetGameMessageBytes(), SUBPACKET_SIZE));
Log.Debug("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(GetGameMessageBytes(), SUBPACKET_SIZE));
}
Program.Log.Debug("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE));
Log.Debug("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE));
#endif
}