1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-20 11:47:48 +00:00

PROJECT: added common library to make common files actually common

- renamed sln to FFXIVClassic.sln
- threaded logging
- todo: print packets using Log.Packet
This commit is contained in:
Tahir Akhlaq 2016-06-12 20:12:59 +01:00
parent 16d4779970
commit c23f9c7ca9
53 changed files with 547 additions and 1817 deletions

View file

@ -1,9 +1,9 @@
using System;
namespace FFXIVClassic_Lobby_Server.common
namespace FFXIVClassic.Common
{
[global::System.AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
sealed class BitfieldLengthAttribute : Attribute
public sealed class BitfieldLengthAttribute : Attribute
{
uint length;
@ -15,7 +15,7 @@ namespace FFXIVClassic_Lobby_Server.common
public uint Length { get { return length; } }
}
static class PrimitiveConversion
public static class PrimitiveConversion
{
public static UInt32 ToUInt32<T>(T t) where T : struct
{

View file

@ -1,6 +1,6 @@
using System;
namespace FFXIVClassic_Map_Server.common
namespace FFXIVClassic.Common
{
public class Blowfish
{

View file

@ -1,6 +1,6 @@
using System;
namespace FFXIVClassic_Map_Server.common
namespace FFXIVClassic.Common
{
namespace EfficientHashTables
{

View file

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3A3D6626-C820-4C18-8C81-64811424F20E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FFXIVClassic.Common</RootNamespace>
<AssemblyName>FFXIVClassic.Common</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<RegisterForComInterop>false</RegisterForComInterop>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Bitfield.cs" />
<Compile Include="Blowfish.cs" />
<Compile Include="EfficientHashTables.cs" />
<Compile Include="Log.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="STA_INIFile.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,137 @@
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Threading;
namespace FFXIVClassic.Common
{
public class Log
{
public string LogDirectory;
public string LogFileName;
public int EnabledLogTypes;
public Queue<Tuple<String, LogColour>> LogQueue;
public Log(string path, string file, int enabledtypes)
{
LogQueue = new Queue<Tuple<String, LogColour>>();
EnabledLogTypes = enabledtypes;
LogDirectory = path;
LogFileName = file;
}
public enum LogType
{
None = 0x000,
Console = 0x001,
File = 0x002,
Status = 0x004,
Sql = 0x008,
Info = 0x010,
Debug = 0x020,
Error = 0x040,
}
public enum LogColour
{
Status = ConsoleColor.Green,
Sql = ConsoleColor.Magenta,
Info = ConsoleColor.White,
Debug = ConsoleColor.Cyan,
Error = ConsoleColor.Red
}
public void Status(String message, params object[] formatargs)
{
if (formatargs.Length > 0)
message = String.Format(message, formatargs);
QueueMessage(message, LogColour.Status);
}
public void Sql(String message, params object[] formatargs)
{
if (formatargs.Length > 0)
message = String.Format(message, formatargs);
QueueMessage(message, LogColour.Sql);
}
public void Info(String message, params object[] formatargs)
{
if (formatargs.Length > 0)
message = String.Format(message, formatargs);
QueueMessage(message, LogColour.Info);
}
public void Debug(String message, params object[] formatargs)
{
if (formatargs.Length > 0)
message = String.Format(message, formatargs);
QueueMessage(message, LogColour.Debug);
}
public void Error(String message, params object[] formatargs)
{
if (formatargs.Length > 0)
message = String.Format(message, formatargs);
QueueMessage(message, LogColour.Error);
}
public void Packet(String message, params object[] formatargs)
{
}
private void QueueMessage(String message, LogColour type)
{
LogQueue.Enqueue(Tuple.Create(message, type));
}
public void WriteMessage(String message, LogColour type)
{
var canLog = false;
try
{
canLog = ((EnabledLogTypes & (int)(Enum.Parse(typeof(LogType), type.ToString()))) != 0);
}
catch (Exception e) { }
string timestamp = String.Format("[{0}]", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));
string messageType = String.Format("[{0}] ", type.ToString().ToUpper());
if ((EnabledLogTypes & (int)LogType.Console) != 0)
{
Console.Write(timestamp);
Console.ForegroundColor = (ConsoleColor)type;
Console.Write(messageType);
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(message);
}
StringBuilder sb = new StringBuilder();
sb.AppendLine(String.Format("{0}{1}{2}", timestamp, messageType, message));
if ((EnabledLogTypes & (int)LogType.File) != 0)
{
// todo: add param to see if path has been changed during runtime and then check directory/file
if (!Directory.Exists(LogDirectory))
{
Directory.CreateDirectory(LogDirectory);
}
using (FileStream fs = new FileStream(Path.Combine(LogDirectory, LogFileName), FileMode.Append, FileAccess.Write))
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine(sb.ToString());
}
}
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("FFXIVClassic.Common")]
[assembly: AssemblyDescription("Common class library for FFXIVClassic project")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ffxivclassic.fragmenterworks.com")]
[assembly: AssemblyProduct("FFXIVClassic.Common")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3a3d6626-c820-4c18-8c81-64811424f20e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -9,10 +9,9 @@ using System.Globalization;
using System.IO;
using System.Text;
namespace STA.Settings
namespace FFXIVClassic.Common
{
internal class INIFile
public class INIFile
{
#region "Declarations"
@ -337,7 +336,7 @@ namespace STA.Settings
}
// *** Read a value from local cache ***
internal string GetValue(string SectionName, string Key, string DefaultValue)
public string GetValue(string SectionName, string Key, string DefaultValue)
{
// *** Lazy loading ***
if (m_Lazy)

View file

@ -1,9 +1,9 @@
using System;
using System.Text;
namespace FFXIVClassic_Lobby_Server.common
namespace FFXIVClassic.Common
{
static class Utils
public static class Utils
{
private static readonly uint[] _lookup32 = CreateLookup32();

View file

@ -1,7 +1,7 @@
using System;
using System.Net.Sockets;
using FFXIVClassic_Lobby_Server.packets;
using FFXIVClassic_Lobby_Server.common;
using FFXIVClassic.Common;
using System.Collections.Concurrent;
using Cyotek.Collections.Generic;
using System.Net;
@ -59,7 +59,7 @@ namespace FFXIVClassic_Lobby_Server
socket.Send(packetBytes);
}
catch(Exception e)
{ Log.Error(String.Format("Weird case, socket was d/ced: {0}", e)); }
{ Program.Log.Error(String.Format("Weird case, socket was d/ced: {0}", e)); }
}
}

View file

@ -1,4 +1,4 @@
using STA.Settings;
using FFXIVClassic.Common;
using System;
using System.IO;
@ -11,6 +11,7 @@ namespace FFXIVClassic_Lobby_Server
public static bool OPTIONS_TIMESTAMP = false;
public static String OPTIONS_LOGPATH;
public static String OPTIONS_LOGFILE;
public static String OPTIONS_LOGLEVEL;
public static String DATABASE_HOST;
public static String DATABASE_PORT;
@ -37,6 +38,7 @@ namespace FFXIVClassic_Lobby_Server
ConfigConstants.OPTIONS_TIMESTAMP = configIni.GetValue("General", "showtimestamp", "true").ToLower().Equals("true");
ConfigConstants.OPTIONS_LOGPATH = configIni.GetValue("General", "log_path", "./logs/");
ConfigConstants.OPTIONS_LOGFILE = configIni.GetValue("General", "log_file_name", String.Format("lobby_{0}_{1}.log", OPTIONS_BINDIP, OPTIONS_PORT));
ConfigConstants.OPTIONS_LOGLEVEL = configIni.GetValue("General", "log_level", "127");
ConfigConstants.DATABASE_HOST = configIni.GetValue("Database", "host", "");
ConfigConstants.DATABASE_PORT = configIni.GetValue("Database", "port", "");

View file

@ -5,7 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using FFXIVClassic_Lobby_Server.utils;
using FFXIVClassic_Lobby_Server.common;
using FFXIVClassic.Common;
namespace FFXIVClassic_Lobby_Server
{
@ -33,7 +33,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
@ -88,9 +88,9 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
pid = 0;
cid = 0;
@ -100,7 +100,7 @@ namespace FFXIVClassic_Lobby_Server
conn.Dispose();
}
Log.Sql(String.Format("CID={0} created on 'characters' table.", cid));
Program.Log.Sql(String.Format("CID={0} created on 'characters' table.", cid));
}
return alreadyExists;
@ -183,7 +183,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
conn.Dispose();
return;
@ -208,7 +208,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
conn.Dispose();
return;
@ -230,7 +230,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
@ -242,7 +242,7 @@ namespace FFXIVClassic_Lobby_Server
}
Log.Sql(String.Format("CID={0} state updated to active(2).", cid));
Program.Log.Sql(String.Format("CID={0} state updated to active(2).", cid));
}
public static bool renameCharacter(uint userId, uint characterId, uint serverId, String newName)
@ -277,7 +277,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
@ -286,7 +286,7 @@ namespace FFXIVClassic_Lobby_Server
conn.Dispose();
}
Log.Sql(String.Format("CID={0} name updated to \"{1}\".", characterId, newName));
Program.Log.Sql(String.Format("CID={0} name updated to \"{1}\".", characterId, newName));
return false;
}
@ -310,7 +310,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
@ -320,7 +320,7 @@ namespace FFXIVClassic_Lobby_Server
}
}
Log.Sql(String.Format("CID={0} deleted.", characterId));
Program.Log.Sql(String.Format("CID={0} deleted.", characterId));
}
public static List<World> getServers()
@ -335,7 +335,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
worldList = new List<World>(); }
finally
{
@ -357,7 +357,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
@ -494,7 +494,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
@ -518,7 +518,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
nameList = new List<String>(); }
finally
{
@ -540,7 +540,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
retainerList = new List<Retainer>(); }
finally
{

View file

@ -11,6 +11,7 @@
<AssemblyName>FFXIVClassic_Lobby_Server</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@ -23,7 +24,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
@ -55,6 +55,9 @@
<Reference Include="Dapper">
<HintPath>..\packages\Dapper.1.42\lib\net45\Dapper.dll</HintPath>
</Reference>
<Reference Include="FFXIVClassic.Common">
<HintPath>..\FFXIVClassic Common Class Lib\bin\Debug\FFXIVClassic.Common.dll</HintPath>
</Reference>
<Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.6.9.7\lib\net45\MySql.Data.dll</HintPath>
</Reference>
@ -71,17 +74,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="common\Bitfield.cs" />
<Compile Include="common\Blowfish.cs" />
<Compile Include="common\Log.cs" />
<Compile Include="common\STA_INIFile.cs" />
<Compile Include="dataobjects\Account.cs" />
<Compile Include="dataobjects\Appearance.cs" />
<Compile Include="dataobjects\CharaInfo.cs" />
<Compile Include="dataobjects\Retainer.cs" />
<Compile Include="dataobjects\Character.cs" />
<Compile Include="ClientConnection.cs" />
<Compile Include="common\Utils.cs" />
<Compile Include="ConfigConstants.cs" />
<Compile Include="Database.cs" />
<Compile Include="dataobjects\World.cs" />

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Lobby_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Lobby_Server.dataobjects;
using FFXIVClassic_Lobby_Server.packets;
using FFXIVClassic_Lobby_Server.packets.receive;
@ -53,7 +53,7 @@ namespace FFXIVClassic_Lobby_Server
case 0x0F:
//Mod Retainers
default:
Log.Debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode));
Program.Log.Debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode));
break;
}
}
@ -67,7 +67,7 @@ namespace FFXIVClassic_Lobby_Server
byte[] blowfishKey = GenerateKey(securityHandshake.ticketPhrase, securityHandshake.clientNumber);
client.blowfish = new Blowfish(blowfishKey);
Log.Info(String.Format("SecCNum: 0x{0:X}", securityHandshake.clientNumber));
Program.Log.Info(String.Format("SecCNum: 0x{0:X}", securityHandshake.clientNumber));
//Respond with acknowledgment
BasePacket outgoingPacket = new BasePacket(HardCoded_Packets.g_secureConnectionAcknowledgment);
@ -81,8 +81,8 @@ namespace FFXIVClassic_Lobby_Server
SessionPacket sessionPacket = new SessionPacket(packet.data);
String clientVersion = sessionPacket.version;
Log.Info(String.Format("Got acknowledgment for secure session."));
Log.Info(String.Format("CLIENT VERSION: {0}", clientVersion));
Program.Log.Info(String.Format("Got acknowledgment for secure session."));
Program.Log.Info(String.Format("CLIENT VERSION: {0}", clientVersion));
uint userId = Database.getUserIdFromSession(sessionPacket.session);
client.currentUserId = userId;
@ -96,11 +96,11 @@ namespace FFXIVClassic_Lobby_Server
BasePacket.encryptPacket(client.blowfish, errorBasePacket);
client.queuePacket(errorBasePacket);
Log.Info(String.Format("Invalid session, kicking..."));
Program.Log.Info(String.Format("Invalid session, kicking..."));
return;
}
Log.Info(String.Format("USER ID: {0}", userId));
Program.Log.Info(String.Format("USER ID: {0}", userId));
List<Account> accountList = new List<Account>();
Account defaultAccount = new Account();
@ -115,7 +115,7 @@ namespace FFXIVClassic_Lobby_Server
private void ProcessGetCharacters(ClientConnection client, SubPacket packet)
{
Log.Info(String.Format("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId));
Program.Log.Info(String.Format("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId));
sendWorldList(client, packet);
sendImportList(client, packet);
@ -128,7 +128,7 @@ namespace FFXIVClassic_Lobby_Server
{
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));
Program.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);
World world = null;
@ -187,7 +187,7 @@ namespace FFXIVClassic_Lobby_Server
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
Log.Info(String.Format("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId));
Program.Log.Info(String.Format("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId));
return;
}
@ -207,7 +207,7 @@ namespace FFXIVClassic_Lobby_Server
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
Log.Info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
Program.Log.Info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
return;
}
else
@ -219,7 +219,7 @@ namespace FFXIVClassic_Lobby_Server
client.newCharaName = name;
}
Log.Info(String.Format("User {0} => Character reserved \"{1}\"", client.currentUserId, name));
Program.Log.Info(String.Format("User {0} => Character reserved \"{1}\"", client.currentUserId, name));
break;
case 0x02://Make
CharaInfo info = CharaInfo.getFromNewCharRequest(charaReq.characterInfoEncoded);
@ -272,7 +272,7 @@ namespace FFXIVClassic_Lobby_Server
cid = client.newCharaCid;
name = client.newCharaName;
Log.Info(String.Format("User {0} => Character created \"{1}\"", client.currentUserId, name));
Program.Log.Info(String.Format("User {0} => Character created \"{1}\"", client.currentUserId, name));
break;
case 0x03://Rename
@ -286,20 +286,20 @@ namespace FFXIVClassic_Lobby_Server
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
Log.Info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
Program.Log.Info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName));
return;
}
Log.Info(String.Format("User {0} => Character renamed \"{1}\"", client.currentUserId, name));
Program.Log.Info(String.Format("User {0} => Character renamed \"{1}\"", client.currentUserId, name));
break;
case 0x04://Delete
Database.deleteCharacter(charaReq.characterId, charaReq.characterName);
Log.Info(String.Format("User {0} => Character deleted \"{1}\"", client.currentUserId, name));
Program.Log.Info(String.Format("User {0} => Character deleted \"{1}\"", client.currentUserId, name));
break;
case 0x06://Rename Retainer
Log.Info(String.Format("User {0} => Retainer renamed \"{1}\"", client.currentUserId, name));
Program.Log.Info(String.Format("User {0} => Retainer renamed \"{1}\"", client.currentUserId, name));
break;
}
@ -349,7 +349,7 @@ namespace FFXIVClassic_Lobby_Server
List<Character> characterList = Database.getCharacters(client.currentUserId);
if (characterList.Count > 8)
Log.Error("Warning, got more than 8 characters. List truncated, check DB for issues.");
Program.Log.Error("Warning, got more than 8 characters. List truncated, check DB for issues.");
CharacterListPacket characterlistPacket = new CharacterListPacket(0, characterList);
List<SubPacket> subPackets = characterlistPacket.buildPackets();

View file

@ -3,12 +3,14 @@ using System.Diagnostics;
using System.Threading;
using MySql.Data.MySqlClient;
using System.Reflection;
using FFXIVClassic_Lobby_Server.common;
using FFXIVClassic.Common;
namespace FFXIVClassic_Lobby_Server
{
class Program
{
public static Log Log;
static void Main(string[] args)
{
#if DEBUG
@ -22,15 +24,30 @@ namespace FFXIVClassic_Lobby_Server
if (!ConfigConstants.load())
startServer = false;
Log.Info("--------FFXIV 1.0 Lobby Server--------");
Log = new Log(ConfigConstants.OPTIONS_LOGPATH, ConfigConstants.OPTIONS_LOGFILE, Int32.Parse(ConfigConstants.OPTIONS_LOGLEVEL));
Thread thread = new Thread(() =>
{
while (true)
{
if (Log.LogQueue.Count > 0)
{
var message = Program.Log.LogQueue.Dequeue();
Program.Log.WriteMessage(message.Item1, message.Item2);
}
}
});
thread.Start();
Program.Log.Info("--------FFXIV 1.0 Lobby Server--------");
Assembly assem = Assembly.GetExecutingAssembly();
Version vers = assem.GetName().Version;
Log.Info("Version: " + vers.ToString());
Program.Log.Info("Version: " + vers.ToString());
//Test DB Connection
Log.Info(String.Format("Testing DB connection to \"{0}\"... ", ConfigConstants.DATABASE_HOST));
Program.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)))
{
try
@ -38,12 +55,12 @@ namespace FFXIVClassic_Lobby_Server
conn.Open();
conn.Close();
Log.Status("[OK]");
Program.Log.Status("[OK]");
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Log.Error("[FAILED]");
Program.Log.Error(e.ToString());
Program.Log.Error("[FAILED]");
startServer = false;
}
@ -58,7 +75,7 @@ namespace FFXIVClassic_Lobby_Server
while (true) Thread.Sleep(10000);
}
Log.Info("Press any key to continue...");
Program.Log.Info("Press any key to continue...");
Console.ReadKey();
}

View file

@ -4,7 +4,7 @@ using System.Net;
using System.Net.Sockets;
using System.Threading;
using FFXIVClassic_Lobby_Server.packets;
using FFXIVClassic_Lobby_Server.common;
using FFXIVClassic.Common;
namespace FFXIVClassic_Lobby_Server
{
@ -25,7 +25,7 @@ namespace FFXIVClassic_Lobby_Server
private void socketCleanup()
{
Log.Debug(String.Format("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME));
Program.Log.Debug(String.Format("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME));
while (!killCleanupThread)
{
int count = 0;
@ -40,7 +40,7 @@ namespace FFXIVClassic_Lobby_Server
}
}
if (count != 0)
Log.Status(String.Format("{0} connections were cleaned up.", count));
Program.Log.Status(String.Format("{0} connections were cleaned up.", count));
Thread.Sleep(CLEANUP_THREAD_SLEEP_TIME*1000);
}
}
@ -80,7 +80,7 @@ namespace FFXIVClassic_Lobby_Server
}
Console.ForegroundColor = ConsoleColor.White;
Log.Debug(String.Format("Lobby Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
Program.Log.Debug(String.Format("Lobby Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
Console.ForegroundColor = ConsoleColor.Gray;
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);
//Queue the accept of the next incomming connection
mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket);
Log.Status(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
Program.Log.Status(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
}
catch (SocketException)
{
@ -179,7 +179,7 @@ namespace FFXIVClassic_Lobby_Server
}
else
{
Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
Program.Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
lock (mConnectionList)
{
@ -192,7 +192,7 @@ namespace FFXIVClassic_Lobby_Server
{
if (conn.socket != null)
{
Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
Program.Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId));
lock (mConnectionList)
{

View file

@ -1,456 +0,0 @@
using System;
namespace FFXIVClassic_Lobby_Server.common
{
public class Blowfish
{
const int N = 16;
UInt32 [] P = new uint[16 + 2];
UInt32 [,] S = new UInt32[4,256];
#region P and S Values
byte [] P_values =
{
0x88, 0x6A, 0x3F, 0x24, 0xD3, 0x08, 0xA3, 0x85, 0x2E, 0x8A, 0x19, 0x13, 0x44, 0x73, 0x70, 0x03,
0x22, 0x38, 0x09, 0xA4, 0xD0, 0x31, 0x9F, 0x29, 0x98, 0xFA, 0x2E, 0x08, 0x89, 0x6C, 0x4E, 0xEC,
0xE6, 0x21, 0x28, 0x45, 0x77, 0x13, 0xD0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0x35,
0x05, 0x69, 0x12, 0x71, 0x22, 0x02, 0x04, 0xB2, 0x7C, 0xCF, 0xCB, 0xB6, 0x2B, 0x9C, 0x76, 0xCD,
0xC0, 0x3E, 0x11, 0x53, 0xD3, 0xE3, 0x40, 0x16, 0x60, 0xBD, 0xAB, 0x38, 0xF0, 0xAD, 0x47, 0x25,
0x9C, 0x20, 0x38, 0xBA, 0x76, 0xCE, 0x46, 0xF7, 0xC5, 0xA1, 0xAF, 0x77, 0x60, 0x60, 0x75, 0x20,
0x4E, 0xFE, 0xCB, 0x85, 0xD8, 0x8D, 0xE8, 0x8A, 0xB0, 0xF9, 0xAA, 0x7A, 0x7E, 0xAA, 0xF9, 0x4C,
0x5C, 0xC2, 0x48, 0x19, 0x8C, 0x8A, 0xFB, 0x02, 0xE4, 0x6A, 0xC3, 0x01, 0xF9, 0xE1, 0xEB, 0xD6,
0x69, 0xF8, 0xD4, 0x90, 0xA0, 0xDE, 0x5C, 0xA6, 0x2D, 0x25, 0x09, 0x3F, 0x9F, 0xE6, 0x08, 0xC2,
0x32, 0x61, 0x4E, 0xB7, 0x5B, 0xE2, 0x77, 0xCE, 0xE3, 0xDF, 0x8F, 0x57, 0xE6, 0x72, 0xC3, 0x3A
};
#endregion
public Blowfish(byte[] key)
{
initializeBlowfish(key);
}
public void Encipher(byte[] data, int offset, int length)
{
if ((length - offset) % 8 != 0)
throw new ArgumentException("Needs to be a multiple of 8");
for (int i = offset; i < offset + length; i += 8)
{
uint xl = (uint)((data[i + 0]) | (data[i + 1] << 8) | (data[i + 2] << 16) | (data[i + 3] << 24));
uint xr = (uint)((data[i + 4]) | (data[i + 5] << 8) | (data[i + 6] << 16) | (data[i + 7] << 24));
blowfish_encipher(ref xl, ref xr);
data[i + 0] = (byte)(xl >> 0);
data[i + 1] = (byte)(xl >> 8);
data[i + 2] = (byte)(xl >> 16);
data[i + 3] = (byte)(xl >> 24);
data[i + 4] = (byte)(xr >> 0);
data[i + 5] = (byte)(xr >> 8);
data[i + 6] = (byte)(xr >> 16);
data[i + 7] = (byte)(xr >> 24);
}
}
public void Decipher(byte[] data, int offset, int length)
{
if ((length - offset) % 8 != 0)
throw new ArgumentException("Needs to be a multiple of 8");
for (int i = offset; i < offset + length; i += 8)
{
uint xl = (uint)((data[i + 0]) | (data[i + 1] << 8) | (data[i + 2] << 16) | (data[i + 3] << 24));
uint xr = (uint)((data[i + 4]) | (data[i + 5] << 8) | (data[i + 6] << 16) | (data[i + 7] << 24));
blowfish_decipher(ref xl, ref xr);
data[i + 0] = (byte)(xl >> 0);
data[i + 1] = (byte)(xl >> 8);
data[i + 2] = (byte)(xl >> 16);
data[i + 3] = (byte)(xl >> 24);
data[i + 4] = (byte)(xr >> 0);
data[i + 5] = (byte)(xr >> 8);
data[i + 6] = (byte)(xr >> 16);
data[i + 7] = (byte)(xr >> 24);
}
}
private UInt32 F(UInt32 x)
{
UInt16 a;
UInt16 b;
UInt16 c;
UInt16 d;
UInt32 y;
d = (UInt16)(x & 0x00FF);
x >>= 8;
c = (UInt16)(x & 0x00FF);
x >>= 8;
b = (UInt16)(x & 0x00FF);
x >>= 8;
a = (UInt16)(x & 0x00FF);
//y = ((S[0][a] + S[1][b]) ^ S[2][c]) + S[3][d];
y = S[0,a] + S[1,b];
y = y ^ S[2,c];
y = y + S[3,d];
return y;
}
private void blowfish_encipher(ref UInt32 xl, ref UInt32 xr)
{
UInt32 temp;
Int32 i;
for (i = 0; i < N; ++i) {
xl = xl ^ P[i];
xr = F(xl) ^ xr;
temp = xl;
xl = xr;
xr = temp;
}
temp = xl;
xl = xr;
xr = temp;
xr = xr ^ P[N];
xl = xl ^ P[N + 1];
}
private void blowfish_decipher(ref UInt32 xl, ref UInt32 xr)
{
UInt32 temp;
Int32 i;
for (i = N + 1; i > 1; --i) {
xl = xl ^ P[i];
xr = F(xl) ^ xr;
/* Exchange xl and xr */
temp = xl;
xl = xr;
xr = temp;
}
/* Exchange xl and xr */
temp = xl;
xl = xr;
xr = temp;
xr = xr ^ P[1];
xl = xl ^ P[0];
}
private int initializeBlowfish(byte [] key)
{
Int16 i;
Int16 j;
Int16 k;
int data;
uint datal;
uint datar;
Buffer.BlockCopy(P_values, 0, P, 0, P_values.Length);
Buffer.BlockCopy(S_values, 0, S, 0, S_values.Length);
j = 0;
for (i = 0; i < N + 2; ++i)
{
data = 0x00000000;
for (k = 0; k < 4; ++k)
{
data = (data << 8) | (SByte)key[j];
j = (short)(j + 1);
if (j >= key.Length)
{
j = 0;
}
}
P[i] = P[i] ^ (uint)data;
}
datal = 0x00000000;
datar = 0x00000000;
for (i = 0; i < N + 2; i += 2)
{
blowfish_encipher(ref datal, ref datar);
P[i] = datal;
P[i + 1] = datar;
}
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 256; j += 2)
{
blowfish_encipher(ref datal, ref datar);
S[i,j] = datal;
S[i,j + 1] = datar;
}
}
return 0;
}
}
}

View file

@ -1,72 +0,0 @@
using System;
using System.IO;
using System.Text;
namespace FFXIVClassic_Lobby_Server.common
{
class Log
{
public enum LogType
{
Status = ConsoleColor.Green,
Sql = ConsoleColor.Magenta,
Info = ConsoleColor.White,
Debug = ConsoleColor.Cyan,
Error = ConsoleColor.Red
}
public static void Status(String message)
{
LogFile(message, LogType.Status);
}
public static void Sql(String message)
{
LogFile(message, LogType.Sql);
}
public static void Info(String message)
{
LogFile(message, LogType.Info);
}
public static void Debug(String message)
{
#if DEBUG
LogFile(message, LogType.Debug);
#endif
}
public static void Error(String message)
{
LogFile(message, LogType.Error);
}
private static void LogFile(String message, LogType type)
{
string timestamp = String.Format("[{0}]", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));
string messageType = String.Format("[{0}] ", type.ToString().ToUpper());
Console.Write(timestamp);
Console.ForegroundColor = (ConsoleColor)type;
Console.Write(messageType);
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(message);
StringBuilder sb = new StringBuilder();
sb.AppendLine(String.Format("{0}{1}{2}", timestamp, messageType, message));
if (!Directory.Exists(ConfigConstants.OPTIONS_LOGPATH))
{
Directory.CreateDirectory(ConfigConstants.OPTIONS_LOGPATH);
}
using (FileStream fs = new FileStream(Path.Combine(ConfigConstants.OPTIONS_LOGPATH, ConfigConstants.OPTIONS_LOGFILE), FileMode.Append, FileAccess.Write))
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine(sb.ToString());
}
}
}
}

View file

@ -1,533 +0,0 @@
// *******************************
// *** INIFile class V2.1 ***
// *******************************
// *** (C)2009-2013 S.T.A. snc ***
// *******************************
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
namespace STA.Settings
{
internal class INIFile
{
#region "Declarations"
// *** Lock for thread-safe access to file and local cache ***
private object m_Lock = new object();
// *** File name ***
private string m_FileName = null;
internal string FileName
{
get
{
return m_FileName;
}
}
// *** Lazy loading flag ***
private bool m_Lazy = false;
// *** Automatic flushing flag ***
private bool m_AutoFlush = false;
// *** Local cache ***
private Dictionary<string, Dictionary<string, string>> m_Sections = new Dictionary<string, Dictionary<string, string>>();
private Dictionary<string, Dictionary<string, string>> m_Modified = new Dictionary<string, Dictionary<string, string>>();
// *** Local cache modified flag ***
private bool m_CacheModified = false;
#endregion
#region "Methods"
// *** Constructor ***
public INIFile(string FileName)
{
Initialize(FileName, false, false);
}
public INIFile(string FileName, bool Lazy, bool AutoFlush)
{
Initialize(FileName, Lazy, AutoFlush);
}
// *** Initialization ***
private void Initialize(string FileName, bool Lazy, bool AutoFlush)
{
m_FileName = FileName;
m_Lazy = Lazy;
m_AutoFlush = AutoFlush;
if (!m_Lazy) Refresh();
}
// *** Parse section name ***
private string ParseSectionName(string Line)
{
if (!Line.StartsWith("[")) return null;
if (!Line.EndsWith("]")) return null;
if (Line.Length < 3) return null;
return Line.Substring(1, Line.Length - 2);
}
// *** Parse key+value pair ***
private bool ParseKeyValuePair(string Line, ref string Key, ref string Value)
{
// *** Check for key+value pair ***
int i;
if ((i = Line.IndexOf('=')) <= 0) return false;
int j = Line.Length - i - 1;
Key = Line.Substring(0, i).Trim();
if (Key.Length <= 0) return false;
Value = (j > 0) ? (Line.Substring(i + 1, j).Trim()) : ("");
return true;
}
// *** Read file contents into local cache ***
internal void Refresh()
{
lock (m_Lock)
{
StreamReader sr = null;
try
{
// *** Clear local cache ***
m_Sections.Clear();
m_Modified.Clear();
// *** Open the INI file ***
try
{
sr = new StreamReader(m_FileName);
}
catch (FileNotFoundException)
{
return;
}
// *** Read up the file content ***
Dictionary<string, string> CurrentSection = null;
string s;
string SectionName;
string Key = null;
string Value = null;
while ((s = sr.ReadLine()) != null)
{
s = s.Trim();
// *** Check for section names ***
SectionName = ParseSectionName(s);
if (SectionName != null)
{
// *** Only first occurrence of a section is loaded ***
if (m_Sections.ContainsKey(SectionName))
{
CurrentSection = null;
}
else
{
CurrentSection = new Dictionary<string, string>();
m_Sections.Add(SectionName, CurrentSection);
}
}
else if (CurrentSection != null)
{
// *** Check for key+value pair ***
if (ParseKeyValuePair(s, ref Key, ref Value))
{
// *** Only first occurrence of a key is loaded ***
if (!CurrentSection.ContainsKey(Key))
{
CurrentSection.Add(Key, Value);
}
}
}
}
}
finally
{
// *** Cleanup: close file ***
if (sr != null) sr.Close();
sr = null;
}
}
}
// *** Flush local cache content ***
internal void Flush()
{
lock (m_Lock)
{
PerformFlush();
}
}
private void PerformFlush()
{
// *** If local cache was not modified, exit ***
if (!m_CacheModified) return;
m_CacheModified = false;
// *** Check if original file exists ***
bool OriginalFileExists = File.Exists(m_FileName);
// *** Get temporary file name ***
string TmpFileName = Path.ChangeExtension(m_FileName, "$n$");
// *** Copy content of original file to temporary file, replace modified values ***
StreamWriter sw = null;
// *** Create the temporary file ***
sw = new StreamWriter(TmpFileName);
try
{
Dictionary<string, string> CurrentSection = null;
if (OriginalFileExists)
{
StreamReader sr = null;
try
{
// *** Open the original file ***
sr = new StreamReader(m_FileName);
// *** Read the file original content, replace changes with local cache values ***
string s;
string SectionName;
string Key = null;
string Value = null;
bool Unmodified;
bool Reading = true;
while (Reading)
{
s = sr.ReadLine();
Reading = (s != null);
// *** Check for end of file ***
if (Reading)
{
Unmodified = true;
s = s.Trim();
SectionName = ParseSectionName(s);
}
else
{
Unmodified = false;
SectionName = null;
}
// *** Check for section names ***
if ((SectionName != null) || (!Reading))
{
if (CurrentSection != null)
{
// *** Write all remaining modified values before leaving a section ****
if (CurrentSection.Count > 0)
{
foreach (string fkey in CurrentSection.Keys)
{
if (CurrentSection.TryGetValue(fkey, out Value))
{
sw.Write(fkey);
sw.Write('=');
sw.WriteLine(Value);
}
}
sw.WriteLine();
CurrentSection.Clear();
}
}
if (Reading)
{
// *** Check if current section is in local modified cache ***
if (!m_Modified.TryGetValue(SectionName, out CurrentSection))
{
CurrentSection = null;
}
}
}
else if (CurrentSection != null)
{
// *** Check for key+value pair ***
if (ParseKeyValuePair(s, ref Key, ref Value))
{
if (CurrentSection.TryGetValue(Key, out Value))
{
// *** Write modified value to temporary file ***
Unmodified = false;
CurrentSection.Remove(Key);
sw.Write(Key);
sw.Write('=');
sw.WriteLine(Value);
}
}
}
// *** Write unmodified lines from the original file ***
if (Unmodified)
{
sw.WriteLine(s);
}
}
// *** Close the original file ***
sr.Close();
sr = null;
}
finally
{
// *** Cleanup: close files ***
if (sr != null) sr.Close();
sr = null;
}
}
// *** Cycle on all remaining modified values ***
foreach (KeyValuePair<string, Dictionary<string, string>> SectionPair in m_Modified)
{
CurrentSection = SectionPair.Value;
if (CurrentSection.Count > 0)
{
sw.WriteLine();
// *** Write the section name ***
sw.Write('[');
sw.Write(SectionPair.Key);
sw.WriteLine(']');
// *** Cycle on all key+value pairs in the section ***
foreach (KeyValuePair<string, string> ValuePair in CurrentSection)
{
// *** Write the key+value pair ***
sw.Write(ValuePair.Key);
sw.Write('=');
sw.WriteLine(ValuePair.Value);
}
CurrentSection.Clear();
}
}
m_Modified.Clear();
// *** Close the temporary file ***
sw.Close();
sw = null;
// *** Rename the temporary file ***
File.Copy(TmpFileName, m_FileName, true);
// *** Delete the temporary file ***
File.Delete(TmpFileName);
}
finally
{
// *** Cleanup: close files ***
if (sw != null) sw.Close();
sw = null;
}
}
// *** Read a value from local cache ***
internal string GetValue(string SectionName, string Key, string DefaultValue)
{
// *** Lazy loading ***
if (m_Lazy)
{
m_Lazy = false;
Refresh();
}
lock (m_Lock)
{
// *** Check if the section exists ***
Dictionary<string, string> Section;
if (!m_Sections.TryGetValue(SectionName, out Section)) return DefaultValue;
// *** Check if the key exists ***
string Value;
if (!Section.TryGetValue(Key, out Value)) return DefaultValue;
// *** Return the found value ***
return Value;
}
}
// *** Insert or modify a value in local cache ***
internal void SetValue(string SectionName, string Key, string Value)
{
// *** Lazy loading ***
if (m_Lazy)
{
m_Lazy = false;
Refresh();
}
lock (m_Lock)
{
// *** Flag local cache modification ***
m_CacheModified = true;
// *** Check if the section exists ***
Dictionary<string, string> Section;
if (!m_Sections.TryGetValue(SectionName, out Section))
{
// *** If it doesn't, add it ***
Section = new Dictionary<string, string>();
m_Sections.Add(SectionName,Section);
}
// *** Modify the value ***
if (Section.ContainsKey(Key)) Section.Remove(Key);
Section.Add(Key, Value);
// *** Add the modified value to local modified values cache ***
if (!m_Modified.TryGetValue(SectionName, out Section))
{
Section = new Dictionary<string, string>();
m_Modified.Add(SectionName, Section);
}
if (Section.ContainsKey(Key)) Section.Remove(Key);
Section.Add(Key, Value);
// *** Automatic flushing : immediately write any modification to the file ***
if (m_AutoFlush) PerformFlush();
}
}
// *** Encode byte array ***
private string EncodeByteArray(byte[] Value)
{
if (Value == null) return null;
StringBuilder sb = new StringBuilder();
foreach (byte b in Value)
{
string hex = Convert.ToString(b, 16);
int l = hex.Length;
if (l > 2)
{
sb.Append(hex.Substring(l - 2, 2));
}
else
{
if (l < 2) sb.Append("0");
sb.Append(hex);
}
}
return sb.ToString();
}
// *** Decode byte array ***
private byte[] DecodeByteArray(string Value)
{
if (Value == null) return null;
int l = Value.Length;
if (l < 2) return new byte[] { };
l /= 2;
byte[] Result = new byte[l];
for (int i = 0; i < l; i++) Result[i] = Convert.ToByte(Value.Substring(i * 2, 2), 16);
return Result;
}
// *** Getters for various types ***
internal bool GetValue(string SectionName, string Key, bool DefaultValue)
{
string StringValue = GetValue(SectionName, Key, DefaultValue.ToString(System.Globalization.CultureInfo.InvariantCulture));
int Value;
if (int.TryParse(StringValue, out Value)) return (Value != 0);
return DefaultValue;
}
internal int GetValue(string SectionName, string Key, int DefaultValue)
{
string StringValue = GetValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
int Value;
if (int.TryParse(StringValue, NumberStyles.Any, CultureInfo.InvariantCulture, out Value)) return Value;
return DefaultValue;
}
internal long GetValue(string SectionName, string Key, long DefaultValue)
{
string StringValue = GetValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
long Value;
if (long.TryParse(StringValue, NumberStyles.Any, CultureInfo.InvariantCulture, out Value)) return Value;
return DefaultValue;
}
internal double GetValue(string SectionName, string Key, double DefaultValue)
{
string StringValue = GetValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
double Value;
if (double.TryParse(StringValue, NumberStyles.Any, CultureInfo.InvariantCulture, out Value)) return Value;
return DefaultValue;
}
internal byte[] GetValue(string SectionName, string Key, byte[] DefaultValue)
{
string StringValue = GetValue(SectionName, Key, EncodeByteArray(DefaultValue));
try
{
return DecodeByteArray(StringValue);
}
catch (FormatException)
{
return DefaultValue;
}
}
internal DateTime GetValue(string SectionName, string Key, DateTime DefaultValue)
{
string StringValue = GetValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
DateTime Value;
if (DateTime.TryParse(StringValue, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces | DateTimeStyles.NoCurrentDateDefault | DateTimeStyles.AssumeLocal, out Value)) return Value;
return DefaultValue;
}
// *** Setters for various types ***
internal void SetValue(string SectionName, string Key, bool Value)
{
SetValue(SectionName, Key, (Value) ? ("1") : ("0"));
}
internal void SetValue(string SectionName, string Key, int Value)
{
SetValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
internal void SetValue(string SectionName, string Key, long Value)
{
SetValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
internal void SetValue(string SectionName, string Key, double Value)
{
SetValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
internal void SetValue(string SectionName, string Key, byte[] Value)
{
SetValue(SectionName, Key, EncodeByteArray(Value));
}
internal void SetValue(string SectionName, string Key, DateTime Value)
{
SetValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
#endregion
}
}

View file

@ -1,5 +1,5 @@
using System;
using FFXIVClassic_Lobby_Server.common;
using FFXIVClassic.Common;
using System.IO;
namespace FFXIVClassic_Lobby_Server.dataobjects
@ -227,7 +227,7 @@ namespace FFXIVClassic_Lobby_Server.dataobjects
{
byte[] bytes = File.ReadAllBytes("./packets/charaappearance.bin");
Log.Debug(Utils.ByteArrayToHex(bytes));
Program.Log.Debug(Utils.ByteArrayToHex(bytes));
return Convert.ToBase64String(bytes).Replace('+', '-').Replace('/', '_');
}

View file

@ -1,5 +1,5 @@
using System;
using FFXIVClassic_Lobby_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Lobby_Server.dataobjects;
namespace FFXIVClassic_Lobby_Server
@ -33,9 +33,9 @@ namespace FFXIVClassic_Lobby_Server
charaInfo.Replace("/", "_");
byte[] data = System.Convert.FromBase64String(charaInfo);
Log.Debug("------------Base64 printout------------------");
Log.Debug(Utils.ByteArrayToHex(data));
Log.Debug("------------Base64 printout------------------");
Program.Log.Debug("------------Base64 printout------------------");
Program.Log.Debug(Utils.ByteArrayToHex(data));
Program.Log.Debug("------------Base64 printout------------------");
CharaInfo chara = new CharaInfo();

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Diagnostics;
using FFXIVClassic_Lobby_Server.common;
using FFXIVClassic.Common;
using System.IO;
namespace FFXIVClassic_Lobby_Server.packets
@ -336,7 +336,7 @@ namespace FFXIVClassic_Lobby_Server.packets
#if DEBUG
Console.BackgroundColor = ConsoleColor.DarkYellow;
Log.Debug(String.Format("IsAuth: {0} Size: 0x{1:X}, NumSubpackets: {2}{3}{4}", header.isAuthenticated, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())));
Program.Log.Debug(String.Format("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,6 @@
using System;
using System.Runtime.InteropServices;
using FFXIVClassic_Lobby_Server.common;
using FFXIVClassic.Common;
namespace FFXIVClassic_Lobby_Server.packets
{
@ -142,16 +142,16 @@ namespace FFXIVClassic_Lobby_Server.packets
#if DEBUG
Console.BackgroundColor = ConsoleColor.DarkRed;
Log.Debug(String.Format("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())));
Program.Log.Debug(String.Format("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())));
if (header.type == 0x03)
{
Log.Debug(String.Format("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE)));
Program.Log.Debug(String.Format("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE)));
}
Console.BackgroundColor = ConsoleColor.DarkMagenta;
Log.Debug(String.Format("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE)));
Program.Log.Debug(String.Format("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE)));
Console.BackgroundColor = ConsoleColor.Black;
#endif

View file

@ -1,7 +1,7 @@
using System;
using System.Net.Sockets;
using FFXIVClassic_Map_Server.packets;
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using System.Collections.Concurrent;
using System.Net;
@ -46,7 +46,7 @@ namespace FFXIVClassic_Map_Server
socket.Send(packetBytes);
}
catch (Exception e)
{ Log.Error(String.Format("Weird case, socket was d/ced: {0}", e)); }
{ Program.Log.Error(String.Format("Weird case, socket was d/ced: {0}", e)); }
}
}

View file

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.dataobjects;
using FFXIVClassic_Map_Server.packets;
using FFXIVClassic_Map_Server.packets.send.actor;
@ -116,7 +116,7 @@ namespace FFXIVClassic_Map_Server
{
if (client != null)
client.queuePacket(BasePacket.createPacket(SendMessagePacket.buildPacket(client.actorID, client.actorID, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Zone does not exist or setting isn't valid."), true, false));
Log.Error("Zone does not exist or setting isn't valid.");
Program.Log.Error("Zone does not exist or setting isn't valid.");
}
if (client != null)
@ -142,7 +142,7 @@ namespace FFXIVClassic_Map_Server
foreach (KeyValuePair<uint, ConnectedPlayer> entry in mConnectedPlayerList)
{
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));
Program.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)
{
Log.Error("Could not change weather: " + e);
Program.Log.Error("Could not change weather: " + e);
}
}
#endregion
@ -597,7 +597,7 @@ namespace FFXIVClassic_Map_Server
}
catch (Exception e)
{
Log.Error("Could not load packet: " + e);
Program.Log.Error("Could not load packet: " + e);
}
}
#endregion
@ -607,7 +607,7 @@ namespace FFXIVClassic_Map_Server
{
if (client != null)
{
Log.Info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId));
Program.Log.Info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId));
client.getActor().zone.clear();
client.getActor().zone.addActorToZone(client.getActor());
client.getActor().sendInstanceUpdate();
@ -621,11 +621,11 @@ namespace FFXIVClassic_Map_Server
#region !reloaditems
else if (split[0].Equals("reloaditems"))
{
Log.Info(String.Format("Got request to reload item gamedata"));
Program.Log.Info(String.Format("Got request to reload item gamedata"));
sendMessage(client, "Reloading Item Gamedata...");
gamedataItems.Clear();
gamedataItems = Database.getItemGamedata();
Log.Info(String.Format("Loaded {0} items.", gamedataItems.Count));
Program.Log.Info(String.Format("Loaded {0} items.", gamedataItems.Count));
sendMessage(client, String.Format("Loaded {0} items.", gamedataItems.Count));
return true;
}
@ -644,7 +644,7 @@ namespace FFXIVClassic_Map_Server
}
catch (Exception e)
{
Log.Error("Could not load packet: " + e);
Program.Log.Error("Could not load packet: " + e);
}
}
#endregion
@ -660,7 +660,7 @@ namespace FFXIVClassic_Map_Server
}
catch (Exception e)
{
Log.Error("Could not give item.");
Program.Log.Error("Could not give item.");
}
}
#endregion
@ -680,7 +680,7 @@ namespace FFXIVClassic_Map_Server
}
catch (Exception e)
{
Log.Error("Could not give item.");
Program.Log.Error("Could not give item.");
}
}
#endregion
@ -703,7 +703,7 @@ namespace FFXIVClassic_Map_Server
}
catch (Exception e)
{
Log.Error("Could not remove item.");
Program.Log.Error("Could not remove item.");
}
}
#endregion
@ -718,7 +718,7 @@ namespace FFXIVClassic_Map_Server
}
catch (Exception e)
{
Log.Error("Could not give keyitem.");
Program.Log.Error("Could not give keyitem.");
}
}
#endregion
@ -737,7 +737,7 @@ namespace FFXIVClassic_Map_Server
}
catch (Exception e)
{
Log.Error("Could not remove keyitem.");
Program.Log.Error("Could not remove keyitem.");
}
}
#endregion
@ -754,7 +754,7 @@ namespace FFXIVClassic_Map_Server
}
catch (Exception e)
{
Log.Error("Could not give currency.");
Program.Log.Error("Could not give currency.");
}
}
#endregion
@ -775,7 +775,7 @@ namespace FFXIVClassic_Map_Server
}
catch (Exception e)
{
Log.Error("Could not remove currency.");
Program.Log.Error("Could not remove currency.");
}
}
#endregion
@ -793,7 +793,7 @@ namespace FFXIVClassic_Map_Server
}
catch (Exception e)
{
Log.Error("Could not change music: " + e);
Program.Log.Error("Could not change music: " + e);
}
}
#endregion

View file

@ -1,4 +1,4 @@
using STA.Settings;
using FFXIVClassic.Common;
using System;
using System.IO;
@ -11,6 +11,7 @@ namespace FFXIVClassic_Map_Server
public static bool OPTIONS_TIMESTAMP = false;
public static String OPTIONS_LOGPATH;
public static String OPTIONS_LOGFILE;
public static String OPTIONS_LOGLEVEL;
public static uint DATABASE_WORLDID;
public static String DATABASE_HOST;
@ -38,8 +39,9 @@ namespace FFXIVClassic_Map_Server
ConfigConstants.OPTIONS_TIMESTAMP = configIni.GetValue("General", "showtimestamp", "true").ToLower().Equals("true");
ConfigConstants.OPTIONS_LOGPATH = configIni.GetValue("General", "log_path", "./logs/");
ConfigConstants.OPTIONS_LOGFILE = configIni.GetValue("General", "log_file_name", String.Format("map_{0}_{1}.log", OPTIONS_BINDIP, OPTIONS_PORT));
ConfigConstants.OPTIONS_LOGLEVEL = configIni.GetValue("General", "log_level", "127");
ConfigConstants.DATABASE_WORLDID = configIni.GetValue("Database", "worldid", (uint)0);
ConfigConstants.DATABASE_WORLDID = UInt32.Parse(configIni.GetValue("Database", "worldid", "0"));
ConfigConstants.DATABASE_HOST = configIni.GetValue("Database", "host", "");
ConfigConstants.DATABASE_PORT = configIni.GetValue("Database", "port", "");
ConfigConstants.DATABASE_NAME = configIni.GetValue("Database", "database", "");

View file

@ -3,7 +3,7 @@ using Dapper;
using System;
using System.Collections.Generic;
using System.Linq;
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.utils;
using FFXIVClassic_Map_Server.packets;
using FFXIVClassic_Map_Server.packets.send.player;
@ -37,7 +37,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -59,7 +59,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -82,7 +82,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -138,7 +138,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -196,7 +196,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -232,7 +232,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -274,7 +274,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -308,7 +308,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -322,7 +322,7 @@ namespace FFXIVClassic_Map_Server
int slot = player.getQuestSlot(quest.actorId);
if (slot == -1)
{
Log.Error(String.Format("Tried saving quest player didn't have: Player: {0:x}, QuestId: {0:x}", player.actorId, quest.actorId));
Program.Log.Error(String.Format("Tried saving quest player didn't have: Player: {0:x}, QuestId: {0:x}", player.actorId, quest.actorId));
return;
}
else
@ -360,7 +360,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -790,7 +790,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -834,7 +834,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -872,7 +872,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -905,7 +905,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -976,7 +976,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -1032,7 +1032,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -1067,7 +1067,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -1107,7 +1107,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -1148,7 +1148,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -1188,7 +1188,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -1225,7 +1225,7 @@ namespace FFXIVClassic_Map_Server
if (offset < 0 || offset >= cheevosPacket.achievementFlags.Length)
{
Log.Error("SQL Error; achievement flag offset id out of range: " + offset);
Program.Log.Error("SQL Error; achievement flag offset id out of range: " + offset);
continue;
}
cheevosPacket.achievementFlags[offset] = true;
@ -1234,7 +1234,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{

View file

@ -42,6 +42,10 @@
<HintPath>..\packages\Dapper.1.42\lib\net45\Dapper.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FFXIVClassic.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\FFXIVClassic Common Class Lib\bin\Debug\FFXIVClassic.Common.dll</HintPath>
</Reference>
<Reference Include="MoonSharp.Interpreter">
<HintPath>..\packages\MoonSharp.1.2.1.0\lib\net40-client\MoonSharp.Interpreter.dll</HintPath>
</Reference>
@ -83,12 +87,6 @@
<Compile Include="actors\world\WorldMaster.cs" />
<Compile Include="ClientConnection.cs" />
<Compile Include="CommandProcessor.cs" />
<Compile Include="common\Bitfield.cs" />
<Compile Include="common\Blowfish.cs" />
<Compile Include="common\EfficientHashTables.cs" />
<Compile Include="common\Log.cs" />
<Compile Include="common\STA_INIFile.cs" />
<Compile Include="common\Utils.cs" />
<Compile Include="ConfigConstants.cs" />
<Compile Include="Database.cs" />
<Compile Include="actors\Actor.cs" />

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.packets;
using System;
using System.Collections.Generic;
@ -127,9 +127,9 @@ namespace FFXIVClassic_Map_Server
player.setConnection(packet.header.connectionType, client);
if (packet.header.connectionType == BasePacket.TYPE_ZONE)
Log.Debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.getAddress()));
Program.Log.Debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.getAddress()));
else if (packet.header.connectionType == BasePacket.TYPE_CHAT)
Log.Debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.getAddress()));
Program.Log.Debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.getAddress()));
//Create player actor
reply1.debugPrintPacket();
@ -180,7 +180,7 @@ namespace FFXIVClassic_Map_Server
//Chat Received
case 0x0003:
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));
Program.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();
if (chatMessage.message.StartsWith("!"))
@ -238,7 +238,7 @@ namespace FFXIVClassic_Map_Server
player.errorMessage += eventStart.error;
if (eventStart.errorIndex == eventStart.errorNum - 1)
Log.Error("\n"+player.errorMessage);
Program.Log.Error("\n"+player.errorMessage);
break;
@ -268,7 +268,7 @@ namespace FFXIVClassic_Map_Server
ownerActor = player.getActor().currentDirector;
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)));
Program.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;
}
}
@ -276,7 +276,7 @@ namespace FFXIVClassic_Map_Server
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)));
Program.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;
//Unknown, happens at npc spawn and cutscene play????
case 0x00CE:
@ -285,7 +285,7 @@ namespace FFXIVClassic_Map_Server
case 0x012E:
subpacket.debugPrintSubPacket();
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)));
Program.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
Actor updateOwnerActor = Server.getStaticActors(player.getActor().currentEventOwner);
@ -398,7 +398,7 @@ namespace FFXIVClassic_Map_Server
//GM Ticket Sent
case 0x01D5:
GMSupportTicketPacket gmTicket = new GMSupportTicketPacket(subpacket.data);
Log.Info("Got GM Ticket: \n" + gmTicket.ticketTitle + "\n" + gmTicket.ticketBody);
Program.Log.Info("Got GM Ticket: \n" + gmTicket.ticketTitle + "\n" + gmTicket.ticketBody);
client.queuePacket(BasePacket.createPacket(GMTicketSentResponsePacket.buildPacket(player.actorID, true), true, false));
break;
//Request to end ticket
@ -406,7 +406,7 @@ namespace FFXIVClassic_Map_Server
client.queuePacket(BasePacket.createPacket(EndGMTicketPacket.buildPacket(player.actorID), true, false));
break;
default:
Log.Debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode));
Program.Log.Debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode));
subpacket.debugPrintSubPacket();
break;
}

View file

@ -1,14 +1,17 @@
using System;
using System.Diagnostics;
using System.Threading;
using MySql.Data.MySqlClient;
using System.Reflection;
using FFXIVClassic_Map_Server.dataobjects;
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
namespace FFXIVClassic_Map_Server
{
class Program
{
public static Log Log;
static void Main(string[] args)
{
#if DEBUG
@ -21,14 +24,29 @@ namespace FFXIVClassic_Map_Server
if (!ConfigConstants.load())
startServer = false;
Log.Info("---------FFXIV 1.0 Map Server---------");
Log = new Log(ConfigConstants.OPTIONS_LOGPATH, ConfigConstants.OPTIONS_LOGFILE, Int32.Parse(ConfigConstants.OPTIONS_LOGLEVEL));
Thread thread = new Thread(() =>
{
while (true)
{
if (Log.LogQueue.Count > 0)
{
var message = Program.Log.LogQueue.Dequeue();
Program.Log.WriteMessage(message.Item1, message.Item2);
}
}
});
thread.Start();
Program.Log.Info("---------FFXIV 1.0 Map Server---------");
Assembly assem = Assembly.GetExecutingAssembly();
Version vers = assem.GetName().Version;
Log.Info("Version: " + vers.ToString());
Program.Log.Info("Version: " + vers.ToString());
//Test DB Connection
Log.Info("Testing DB connection... ");
Program.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)))
{
try
@ -36,11 +54,11 @@ namespace FFXIVClassic_Map_Server
conn.Open();
conn.Close();
Log.Status("[OK]");
Program.Log.Status("[OK]");
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
startServer = false;
}
}
@ -48,9 +66,9 @@ namespace FFXIVClassic_Map_Server
//Check World ID
DBWorld thisWorld = Database.getServer(ConfigConstants.DATABASE_WORLDID);
if (thisWorld != null)
Log.Info(String.Format("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name));
Program.Log.Info(String.Format("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name));
else
Log.Info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed.");
Program.Log.Info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed.");
//Start server if A-OK
if (startServer)
@ -66,7 +84,7 @@ namespace FFXIVClassic_Map_Server
}
}
Log.Info("Press any key to continue...");
Program.Log.Info("Press any key to continue...");
Console.ReadKey();
}

View file

@ -5,7 +5,7 @@ using System.Net.Sockets;
using System.Threading;
using FFXIVClassic_Map_Server.dataobjects;
using FFXIVClassic_Map_Server.packets;
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.lua;
@ -39,7 +39,7 @@ namespace FFXIVClassic_Map_Server
private void connectionHealth()
{
Log.Info(String.Format("Connection Health thread started; it will run every {0} seconds.", HEALTH_THREAD_SLEEP_TIME));
Program.Log.Info(String.Format("Connection Health thread started; it will run every {0} seconds.", HEALTH_THREAD_SLEEP_TIME));
while (!killHealthThread)
{
lock (mConnectedPlayerList)
@ -77,7 +77,7 @@ namespace FFXIVClassic_Map_Server
mStaticActors = new StaticActors(STATIC_ACTORS_PATH);
gamedataItems = Database.getItemGamedata();
Log.Info(String.Format("Loaded {0} items.", gamedataItems.Count));
Program.Log.Info(String.Format("Loaded {0} items.", gamedataItems.Count));
mWorldManager = new WorldManager(this);
mWorldManager.LoadZoneList();
@ -113,7 +113,7 @@ namespace FFXIVClassic_Map_Server
}
Console.ForegroundColor = ConsoleColor.White;
Log.Debug(String.Format("Map Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
Program.Log.Debug(String.Format("Map Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port));
Console.ForegroundColor = ConsoleColor.Gray;
mProcessor = new PacketProcessor(this, mConnectedPlayerList, mConnectionList);
@ -150,7 +150,7 @@ namespace FFXIVClassic_Map_Server
mConnectionList.Add(conn);
}
Log.Status(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port));
Program.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
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn);
//Queue the accept of the next incomming connection
@ -217,7 +217,7 @@ namespace FFXIVClassic_Map_Server
mConnectionList.Remove(conn);
}
if (conn.connType == BasePacket.TYPE_ZONE)
Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
Program.Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
return;
}
@ -261,7 +261,7 @@ namespace FFXIVClassic_Map_Server
}
else
{
Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
Program.Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
lock (mConnectionList)
{
@ -273,7 +273,7 @@ namespace FFXIVClassic_Map_Server
{
if (conn.socket != null)
{
Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
Program.Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner));
lock (mConnectionList)
{

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.actors.area;
using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.lua;
@ -67,7 +67,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
@ -117,7 +117,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -125,7 +125,7 @@ namespace FFXIVClassic_Map_Server
}
}
Log.Info(String.Format("Loaded {0} zones and {1} private areas.", count1, count2));
Program.Log.Info(String.Format("Loaded {0} zones and {1} private areas.", count1, count2));
}
public void LoadZoneEntranceList()
@ -170,7 +170,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -178,7 +178,7 @@ namespace FFXIVClassic_Map_Server
}
}
Log.Info(String.Format("Loaded {0} zone spawn locations.", count));
Program.Log.Info(String.Format("Loaded {0} zone spawn locations.", count));
}
public void LoadNPCs()
@ -242,7 +242,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -250,7 +250,7 @@ namespace FFXIVClassic_Map_Server
}
}
Log.Info(String.Format("Loaded {0} npc(s).", count));
Program.Log.Info(String.Format("Loaded {0} npc(s).", count));
}
public void LoadNPCs(uint zoneId)
@ -315,7 +315,7 @@ namespace FFXIVClassic_Map_Server
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -323,7 +323,7 @@ namespace FFXIVClassic_Map_Server
}
}
Log.Info(String.Format("Loaded {0} npc(s).", count));
Program.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.
@ -354,7 +354,7 @@ namespace FFXIVClassic_Map_Server
{
if (!zoneEntranceList.ContainsKey(zoneEntrance))
{
Log.Error("Given zone entrance was not found: " + zoneEntrance);
Program.Log.Error("Given zone entrance was not found: " + zoneEntrance);
return;
}
@ -410,7 +410,7 @@ namespace FFXIVClassic_Map_Server
{
if (!zoneEntranceList.ContainsKey(zoneEntrance))
{
Log.Error("Given zone entrance was not found: " + zoneEntrance);
Program.Log.Error("Given zone entrance was not found: " + zoneEntrance);
return;
}

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using System;
using System.Collections.Generic;
using System.IO;
@ -89,9 +89,9 @@ namespace FFXIVClassic_Map_Server.Actors
}
}
catch(FileNotFoundException e)
{ Log.Error("Could not find staticactors file."); return false; }
{ Program.Log.Error("Could not find staticactors file."); return false; }
Log.Info(String.Format("Loaded {0} static actors.", mStaticActors.Count()));
Program.Log.Info(String.Format("Loaded {0} static actors.", mStaticActors.Count()));
return true;
}

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.packets;
using FFXIVClassic_Map_Server.actors;
using FFXIVClassic_Map_Server.Actors.Chara;
@ -238,7 +238,7 @@ namespace FFXIVClassic_Map_Server.Actors
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.packets;
using FFXIVClassic_Map_Server.actors.chara.player;
using FFXIVClassic_Map_Server.actors.director;
@ -642,7 +642,7 @@ namespace FFXIVClassic_Map_Server.Actors
Database.savePlayerPlayTime(this);
Database.savePlayerPosition(this);
Log.Info(String.Format("{0} has been logged out and saved.", this.customDisplayName));
Program.Log.Info(String.Format("{0} has been logged out and saved.", this.customDisplayName));
}
public Area getZone()

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@ -68,7 +68,7 @@ namespace FFXIVClassic_Map_Server.Actors
{
if (bitIndex >= 32)
{
Log.Error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId));
Program.Log.Error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId));
return;
}
@ -86,7 +86,7 @@ namespace FFXIVClassic_Map_Server.Actors
{
if (bitIndex >= 32)
{
Log.Error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId));
Program.Log.Error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId));
return false;
}
else

View file

@ -1,74 +0,0 @@
using System;
namespace FFXIVClassic_Map_Server.common
{
[global::System.AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
sealed class BitfieldLengthAttribute : Attribute
{
uint length;
public BitfieldLengthAttribute(uint length)
{
this.length = length;
}
public uint Length { get { return length; } }
}
static class PrimitiveConversion
{
public static UInt32 ToUInt32<T>(T t) where T : struct
{
UInt32 r = 0;
int offset = 0;
// For every field suitably attributed with a BitfieldLength
foreach (System.Reflection.FieldInfo f in t.GetType().GetFields())
{
object[] attrs = f.GetCustomAttributes(typeof(BitfieldLengthAttribute), false);
if (attrs.Length == 1)
{
uint fieldLength = ((BitfieldLengthAttribute)attrs[0]).Length;
// Calculate a bitmask of the desired length
uint mask = 0;
for (int i = 0; i < fieldLength; i++)
mask |= (UInt32)1 << i;
r |= ((UInt32)f.GetValue(t) & mask) << offset;
offset += (int)fieldLength;
}
}
return r;
}
public static long ToLong<T>(T t) where T : struct
{
long r = 0;
int offset = 0;
// For every field suitably attributed with a BitfieldLength
foreach (System.Reflection.FieldInfo f in t.GetType().GetFields())
{
object[] attrs = f.GetCustomAttributes(typeof(BitfieldLengthAttribute), false);
if (attrs.Length == 1)
{
uint fieldLength = ((BitfieldLengthAttribute)attrs[0]).Length;
// Calculate a bitmask of the desired length
long mask = 0;
for (int i = 0; i < fieldLength; i++)
mask |= 1 << i;
r |= ((UInt32)f.GetValue(t) & mask) << offset;
offset += (int)fieldLength;
}
}
return r;
}
}
}

View file

@ -1,72 +0,0 @@
using System;
using System.IO;
using System.Text;
namespace FFXIVClassic_Map_Server.common
{
class Log
{
public enum LogType
{
Status = ConsoleColor.Green,
Sql = ConsoleColor.Magenta,
Info = ConsoleColor.White,
Debug = ConsoleColor.Cyan,
Error = ConsoleColor.Red
}
public static void Status(String message)
{
LogFile(message, LogType.Status);
}
public static void Sql(String message)
{
LogFile(message, LogType.Sql);
}
public static void Info(String message)
{
LogFile(message, LogType.Info);
}
public static void Debug(String message)
{
#if DEBUG
LogFile(message, LogType.Debug);
#endif
}
public static void Error(String message)
{
LogFile(message, LogType.Error);
}
private static void LogFile(String message, LogType type)
{
string timestamp = String.Format("[{0}]", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));
string messageType = String.Format("[{0}] ", type.ToString().ToUpper());
Console.Write(timestamp);
Console.ForegroundColor = (ConsoleColor)type;
Console.Write(messageType);
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(message);
StringBuilder sb = new StringBuilder();
sb.AppendLine(String.Format("{0}{1}{2}", timestamp, messageType, message));
if (!Directory.Exists(ConfigConstants.OPTIONS_LOGPATH))
{
Directory.CreateDirectory(ConfigConstants.OPTIONS_LOGPATH);
}
using (FileStream fs = new FileStream(Path.Combine(ConfigConstants.OPTIONS_LOGPATH, ConfigConstants.OPTIONS_LOGFILE), FileMode.Append, FileAccess.Write))
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine(sb.ToString());
}
}
}
}

View file

@ -1,346 +0,0 @@
using System;
using System.IO;
using System.Text;
namespace FFXIVClassic_Map_Server.common
{
static class Utils
{
private static readonly uint[] _lookup32 = CreateLookup32();
private static uint[] CreateLookup32()
{
var result = new uint[256];
for (int i = 0; i < 256; i++)
{
string s = i.ToString("X2");
result[i] = ((uint)s[0]) + ((uint)s[1] << 16);
}
return result;
}
public static string ByteArrayToHex(byte[] bytes, int offset = 0, int bytesPerLine = 16)
{
if (bytes == null)
{
return String.Empty;
}
char[] hexChars = "0123456789ABCDEF".ToCharArray();
// 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
// 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
int offsetBlock = 8 + 3;
int byteBlock = offsetBlock + (bytesPerLine * 3) + ((bytesPerLine - 1) / 8) + 2;
int lineLength = byteBlock + bytesPerLine + Environment.NewLine.Length;
char[] line = (new String(' ', lineLength - Environment.NewLine.Length) + Environment.NewLine).ToCharArray();
int numLines = (bytes.Length + bytesPerLine - 1) / bytesPerLine;
StringBuilder sb = new StringBuilder(numLines * lineLength);
for (int i = 0; i < bytes.Length; i += bytesPerLine)
{
int h = i + offset;
line[0] = hexChars[(h >> 28) & 0xF];
line[1] = hexChars[(h >> 24) & 0xF];
line[2] = hexChars[(h >> 20) & 0xF];
line[3] = hexChars[(h >> 16) & 0xF];
line[4] = hexChars[(h >> 12) & 0xF];
line[5] = hexChars[(h >> 8) & 0xF];
line[6] = hexChars[(h >> 4) & 0xF];
line[7] = hexChars[(h >> 0) & 0xF];
int hexColumn = offsetBlock;
int charColumn = byteBlock;
for (int j = 0; j < bytesPerLine; j++)
{
if (j > 0 && (j & 7) == 0)
{
hexColumn++;
}
if (i + j >= bytes.Length)
{
line[hexColumn] = ' ';
line[hexColumn + 1] = ' ';
line[charColumn] = ' ';
}
else
{
byte by = bytes[i + j];
line[hexColumn] = hexChars[(by >> 4) & 0xF];
line[hexColumn + 1] = hexChars[by & 0xF];
line[charColumn] = (by < 32 ? '.' : (char)by);
}
hexColumn += 3;
charColumn++;
}
sb.Append(line);
}
return sb.ToString();
}
public static UInt32 UnixTimeStampUTC()
{
UInt32 unixTimeStamp;
DateTime currentTime = DateTime.Now;
DateTime zuluTime = currentTime.ToUniversalTime();
DateTime unixEpoch = new DateTime(1970, 1, 1);
unixTimeStamp = (UInt32)(zuluTime.Subtract(unixEpoch)).TotalSeconds;
return unixTimeStamp;
}
public static UInt64 MilisUnixTimeStampUTC()
{
UInt64 unixTimeStamp;
DateTime currentTime = DateTime.Now;
DateTime zuluTime = currentTime.ToUniversalTime();
DateTime unixEpoch = new DateTime(1970, 1, 1);
unixTimeStamp = (UInt64)(zuluTime.Subtract(unixEpoch)).TotalMilliseconds;
return unixTimeStamp;
}
public static ulong swapEndian(ulong input)
{
return ((0x00000000000000FF) & (input >> 56) |
(0x000000000000FF00) & (input >> 40) |
(0x0000000000FF0000) & (input >> 24) |
(0x00000000FF000000) & (input >> 8) |
(0x000000FF00000000) & (input << 8) |
(0x0000FF0000000000) & (input << 24) |
(0x00FF000000000000) & (input << 40) |
(0xFF00000000000000) & (input << 56));
}
public static uint swapEndian(uint input)
{
return ((input >> 24) & 0xff) |
((input << 8) & 0xff0000) |
((input >> 8) & 0xff00) |
((input << 24) & 0xff000000);
}
public static int swapEndian(int input)
{
uint inputAsUint = (uint)input;
input = (int)
(((inputAsUint >> 24) & 0xff) |
((inputAsUint << 8) & 0xff0000) |
((inputAsUint >> 8) & 0xff00) |
((inputAsUint << 24) & 0xff000000));
return input;
}
public static uint MurmurHash2(string key, uint seed)
{
// 'm' and 'r' are mixing constants generated offline.
// They're not really 'magic', they just happen to work well.
byte[] data = Encoding.ASCII.GetBytes(key);
const uint m = 0x5bd1e995;
const int r = 24;
int len = key.Length;
int dataIndex = len - 4;
// Initialize the hash to a 'random' value
uint h = seed ^ (uint)len;
// Mix 4 bytes at a time into the hash
while (len >= 4)
{
h *= m;
uint k = (uint)BitConverter.ToInt32(data, dataIndex);
k = ((k >> 24) & 0xff) | // move byte 3 to byte 0
((k << 8) & 0xff0000) | // move byte 1 to byte 2
((k >> 8) & 0xff00) | // move byte 2 to byte 1
((k << 24) & 0xff000000); // byte 0 to byte 3
k *= m;
k ^= k >> r;
k *= m;
h ^= k;
dataIndex -= 4;
len -= 4;
}
// Handle the last few bytes of the input array
switch (len)
{
case 3:
h ^= (uint)data[0] << 16; goto case 2;
case 2:
h ^= (uint)data[len - 2] << 8; goto case 1;
case 1:
h ^= data[len - 1];
h *= m;
break;
};
// Do a few final mixes of the hash to ensure the last few
// bytes are well-incorporated.
h ^= h >> 13;
h *= m;
h ^= h >> 15;
return h;
}
public static byte[] ConvertBoolArrayToBinaryStream(bool[] array)
{
byte[] data = new byte[(array.Length / 8) + (array.Length % 8 != 0 ? 1 : 0)];
int dataCounter = 0;
for (int i = 0; i < array.Length; i += 8)
{
for (int bitCount = 0; bitCount < 8; bitCount++)
{
if (i + bitCount >= array.Length)
break;
data[dataCounter] = (byte)(((array[i + bitCount] ? 1 : 0) << 7 - bitCount) | data[dataCounter]);
}
dataCounter++;
}
return data;
}
public static string FFXIVLoginStringDecodeBinary(string path)
{
Console.OutputEncoding = System.Text.Encoding.UTF8;
byte[] data = File.ReadAllBytes(path);
int offset = 0x5405a;
//int offset = 0x5425d;
//int offset = 0x53ea0;
while (true)
{
string result = "";
uint key = (uint)data[offset + 0] << 8 | data[offset + 1];
uint key2 = data[offset + 2];
key = RotateRight(key, 1) & 0xFFFF;
key -= 0x22AF;
key &= 0xFFFF;
key2 = key2 ^ key;
key = RotateRight(key, 1) & 0xFFFF;
key -= 0x22AF;
key &= 0xFFFF;
uint finalKey = key;
key = data[offset + 3];
uint count = (key2 & 0xFF) << 8;
key = key ^ finalKey;
key &= 0xFF;
count |= key;
int count2 = 0;
while (count != 0)
{
uint encrypted = data[offset + 4 + count2];
finalKey = RotateRight(finalKey, 1) & 0xFFFF;
finalKey -= 0x22AF;
finalKey &= 0xFFFF;
encrypted = encrypted ^ (finalKey & 0xFF);
result += (char)encrypted;
count--;
count2++;
}
offset += 4 + count2;
Log.Debug(result);
}
}
public static string FFXIVLoginStringDecode(byte[] data)
{
string result = "";
uint key = (uint)data[0] << 8 | data[1];
uint key2 = data[2];
key = RotateRight(key, 1) & 0xFFFF;
key -= 0x22AF;
key2 = key2 ^ key;
key = RotateRight(key, 1) & 0xFFFF;
key -= 0x22AF;
uint finalKey = key;
key = data[3];
uint count = (key2 & 0xFF) << 8;
key = key ^ finalKey;
key &= 0xFF;
count |= key;
int count2 = 0;
while (count != 0)
{
uint encrypted = data[4 + count2];
finalKey = RotateRight(finalKey, 1) & 0xFFFF;
finalKey -= 0x22AF;
encrypted = encrypted ^ (finalKey & 0xFF);
result += (char)encrypted;
count--;
count2++;
}
return result;
}
public static byte[] FFXIVLoginStringEncode(uint key, string text)
{
key = key & 0xFFFF;
uint count = 0;
byte[] asciiBytes = Encoding.ASCII.GetBytes(text);
byte[] result = new byte[4 + text.Length];
for (count = 0; count < text.Length; count++)
{
result[result.Length - count - 1] = (byte)(asciiBytes[asciiBytes.Length - count - 1] ^ (key & 0xFF));
key += 0x22AF;
key &= 0xFFFF;
key = RotateLeft(key, 1) & 0xFFFF;
}
count = count ^ key;
result[3] = (byte)(count & 0xFF);
key += 0x22AF & 0xFFFF;
key = RotateLeft(key, 1) & 0xFFFF;
result[2] = (byte)(key & 0xFF);
key += 0x22AF & 0xFFFF;
key = RotateLeft(key, 1) & 0xFFFF;
result[1] = (byte)(key & 0xFF);
result[0] = (byte)((key >> 8) & 0xFF);
return result;
}
public static uint RotateLeft(uint value, int bits)
{
return (value << bits) | (value >> (16 - bits));
}
public static uint RotateRight(uint value, int bits)
{
return (value >> bits) | (value << (16 - bits));
}
}
}

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.packets;
using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.lua;

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.packets;
using FFXIVClassic_Map_Server.actors.director;
using FFXIVClassic_Map_Server.Actors;
@ -217,7 +217,7 @@ namespace FFXIVClassic_Map_Server.lua
}
catch(SyntaxErrorException e)
{
Log.Error(String.Format("LUAERROR: {0}.", e.DecoratedMessage));
Program.Log.Error(String.Format("LUAERROR: {0}.", e.DecoratedMessage));
return null;
}
return script;

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.lua;
using MoonSharp.Interpreter;

View file

@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Diagnostics;
using FFXIVClassic_Map_Server.common;
using System.IO;
using FFXIVClassic.Common;
namespace FFXIVClassic_Map_Server.packets
{
@ -334,7 +334,7 @@ namespace FFXIVClassic_Map_Server.packets
#if DEBUG
Console.BackgroundColor = ConsoleColor.DarkYellow;
Log.Debug(String.Format("IsAuth: {0} IsEncrypted: {1}, Size: 0x{2:X}, NumSubpackets: {3}{4}{5}", header.isAuthenticated, header.isCompressed, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())));
Program.Log.Debug(String.Format("IsAuth: {0} IsEncrypted: {1}, Size: 0x{2:X}, NumSubpackets: {3}{4}{5}", header.isAuthenticated, header.isCompressed, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())));
foreach (SubPacket sub in getSubpackets())
{

View file

@ -1,6 +1,6 @@
using System;
using System.Runtime.InteropServices;
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
namespace FFXIVClassic_Map_Server.packets
{
@ -142,15 +142,15 @@ namespace FFXIVClassic_Map_Server.packets
#if DEBUG
Console.BackgroundColor = ConsoleColor.DarkRed;
Log.Debug(String.Format("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())));
Program.Log.Debug(String.Format("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())));
if (header.type == 0x03)
{
Log.Debug(String.Format("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE)));
Program.Log.Debug(String.Format("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE)));
Console.BackgroundColor = ConsoleColor.DarkMagenta;
Log.Debug(String.Format("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE)));
Program.Log.Debug(String.Format("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE)));
}
Console.BackgroundColor = ConsoleColor.Black;

View file

@ -48,7 +48,7 @@ namespace FFXIVClassic_Map_Server.packets.receive.events
error = ASCIIEncoding.ASCII.GetString(binReader.ReadBytes(0x80)).Replace("\0", "");
if (errorIndex == 0)
Log.Error("LUA ERROR:");
Program.Log.Error("LUA ERROR:");
return;
}

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using System;
using System.IO;
using System.Linq;

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using System;
using System.IO;
using System.Linq;

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using System.IO;
namespace FFXIVClassic_Map_Server.packets.send.player
@ -36,7 +36,7 @@ namespace FFXIVClassic_Map_Server.packets.send.player
if (binStream.Length <= PACKET_SIZE - 0x20)
binWriter.Write(binStream);
else
Log.Error("Failed making SetCompletedAchievements packet. Bin Stream was too big!");
Program.Log.Error("Failed making SetCompletedAchievements packet. Bin Stream was too big!");
}
}

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using System;
using System.IO;
using System.Text;
@ -81,7 +81,7 @@ namespace FFXIVClassic_Map_Server.packets.send.player
if (binStream.Length <= PACKET_SIZE - 0x20)
binWriter.Write(binStream);
else
Log.Error("Failed making SetCutsceneBook packet. Bin Stream was too big!");
Program.Log.Error("Failed making SetCutsceneBook packet. Bin Stream was too big!");
binWriter.Seek(0x109, SeekOrigin.Begin);
binWriter.Write(Encoding.ASCII.GetBytes(sNpcName), 0, Encoding.ASCII.GetByteCount(sNpcName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sNpcName));

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using System;
namespace FFXIVClassic_Map_Server.utils

View file

@ -1,4 +1,4 @@
using FFXIVClassic_Map_Server.common;
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.packets.send.player;
using MySql.Data.MySqlClient;
using System;
@ -79,14 +79,14 @@ namespace FFXIVClassic_Map_Server.utils
cmd.Parameters["@placename"].Value = placenames[pId];
Log.Debug(String.Format("Wrote: {0}", id));
Program.Log.Debug(String.Format("Wrote: {0}", id));
cmd.ExecuteNonQuery();
}
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -137,14 +137,14 @@ namespace FFXIVClassic_Map_Server.utils
cmd.Parameters["@id"].Value = id;
cmd.Parameters["@displayNameId"].Value = nameId;
Log.Debug(String.Format("Wrote: {0} : {1}", id, nameId));
Program.Log.Debug(String.Format("Wrote: {0} : {1}", id, nameId));
cmd.ExecuteNonQuery();
}
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -203,14 +203,14 @@ namespace FFXIVClassic_Map_Server.utils
cmd.Parameters["@id"].Value = id;
Log.Debug(String.Format("Wrote: {0}", id));
Program.Log.Debug(String.Format("Wrote: {0}", id));
cmd.ExecuteNonQuery();
}
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
finally
{
@ -288,7 +288,7 @@ namespace FFXIVClassic_Map_Server.utils
else if (id == 1500)
otherId = SetCompletedAchievementsPacket.CATEGORY_GRAND_COMPANY;
Log.Debug(String.Format("Wrote: {0} : {1} : {2} : {3}", id, name, otherId, points));
Program.Log.Debug(String.Format("Wrote: {0} : {1} : {2} : {3}", id, name, otherId, points));
cmd.Parameters["@id"].Value = id;
cmd.Parameters["@name"].Value = name;
cmd.Parameters["@otherId"].Value = otherId;
@ -300,7 +300,7 @@ namespace FFXIVClassic_Map_Server.utils
}
catch (MySqlException e)
{
Log.Error(e.ToString());
Program.Log.Error(e.ToString());
}
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]);
Log.Debug(output2);
Program.Log.Debug(output2);
w.WriteLine(output2);
}

View file

@ -1,11 +1,19 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FFXIVClassic Map Server", "FFXIVClassic Map Server\FFXIVClassic Map Server.csproj", "{E8FA2784-D4B9-4711-8CC6-712A4B1CD54F}"
ProjectSection(ProjectDependencies) = postProject
{3A3D6626-C820-4C18-8C81-64811424F20E} = {3A3D6626-C820-4C18-8C81-64811424F20E}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FFXIVClassic Lobby Server", "FFXIVClassic Lobby Server\FFXIVClassic Lobby Server.csproj", "{703091E0-F69C-4177-8FAE-C258AC6A65AA}"
ProjectSection(ProjectDependencies) = postProject
{3A3D6626-C820-4C18-8C81-64811424F20E} = {3A3D6626-C820-4C18-8C81-64811424F20E}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FFXIVClassic Common Class Lib", "FFXIVClassic Common Class Lib\FFXIVClassic Common Class Lib.csproj", "{3A3D6626-C820-4C18-8C81-64811424F20E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -21,6 +29,10 @@ Global
{703091E0-F69C-4177-8FAE-C258AC6A65AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{703091E0-F69C-4177-8FAE-C258AC6A65AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{703091E0-F69C-4177-8FAE-C258AC6A65AA}.Release|Any CPU.Build.0 = Release|Any CPU
{3A3D6626-C820-4C18-8C81-64811424F20E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A3D6626-C820-4C18-8C81-64811424F20E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A3D6626-C820-4C18-8C81-64811424F20E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A3D6626-C820-4C18-8C81-64811424F20E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -1,7 +1,7 @@
[General]
server_ip=127.0.0.1
showtimestamp = true
log_level = 127
[Database]
worldid=1
host=127.0.0.1

View file

@ -1,7 +1,7 @@
[General]
server_ip=127.0.0.1
showtimestamp = true
log_level = 127
[Database]
worldid=1
host=127.0.0.1