mass replaced all methods to pascal case

This commit is contained in:
Tahir Akhlaq 2016-06-14 21:29:10 +01:00
parent ed0a0a58f7
commit 24f55139dd
179 changed files with 1585 additions and 1585 deletions

View file

@ -15,7 +15,7 @@ namespace FFXIVClassic_Lobby_Server
public Socket socket;
public byte[] buffer = new byte[0xffff];
public CircularBuffer<byte> incomingStream = new CircularBuffer<byte>(1024);
public BlockingCollection<BasePacket> sendPacketQueue = new BlockingCollection<BasePacket>(100);
public BlockingCollection<BasePacket> SendPacketQueue = new BlockingCollection<BasePacket>(100);
public int lastPartialSize = 0;
//Instance Stuff
@ -31,7 +31,7 @@ namespace FFXIVClassic_Lobby_Server
public ushort newCharaWorldId;
public void processIncoming(int bytesIn)
public void ProcessIncoming(int bytesIn)
{
if (bytesIn == 0)
return;
@ -39,20 +39,20 @@ namespace FFXIVClassic_Lobby_Server
incomingStream.Put(buffer, 0, bytesIn);
}
public void queuePacket(BasePacket packet)
public void QueuePacket(BasePacket packet)
{
sendPacketQueue.Add(packet);
SendPacketQueue.Add(packet);
}
public void flushQueuedSendPackets()
public void FlushQueuedSendPackets()
{
if (!socket.Connected)
return;
while (sendPacketQueue.Count > 0)
while (SendPacketQueue.Count > 0)
{
BasePacket packet = sendPacketQueue.Take();
byte[] packetBytes = packet.getPacketBytes();
BasePacket packet = SendPacketQueue.Take();
byte[] packetBytes = packet.GetPacketBytes();
byte[] buffer = new byte[0xffff];
Array.Copy(packetBytes, buffer, packetBytes.Length);
try {
@ -63,12 +63,12 @@ namespace FFXIVClassic_Lobby_Server
}
}
public String getAddress()
public String GetAddress()
{
return String.Format("{0}:{1}", (socket.RemoteEndPoint as IPEndPoint).Address, (socket.RemoteEndPoint as IPEndPoint).Port);
}
public void disconnect()
public void Disconnect()
{
socket.Shutdown(SocketShutdown.Both);
socket.Disconnect(false);

View file

@ -16,7 +16,7 @@ namespace FFXIVClassic_Lobby_Server
public static String DATABASE_USERNAME;
public static String DATABASE_PASSWORD;
public static bool load()
public static bool Load()
{
Console.Write("Loading lobby_config.ini file... ");

View file

@ -13,7 +13,7 @@ namespace FFXIVClassic_Lobby_Server
class Database
{
public static uint getUserIdFromSession(String sessionId)
public static uint GetUserIdFromSession(String sessionId)
{
uint id = 0;
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)))
@ -44,7 +44,7 @@ namespace FFXIVClassic_Lobby_Server
return id;
}
public static bool reserveCharacter(uint userId, uint slot, uint serverId, String name, out uint pid, out uint cid)
public static bool ReserveCharacter(uint userId, uint slot, uint serverId, String name, out uint pid, out uint cid)
{
bool alreadyExists = false;
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)))
@ -100,13 +100,13 @@ namespace FFXIVClassic_Lobby_Server
conn.Dispose();
}
Program.Log.Debug("[SQL] CID={0} created on 'characters' table.", cid);
Program.Log.Debug("[SQL] CID={0} Created on 'characters' table.", cid);
}
return alreadyExists;
}
public static void makeCharacter(uint accountId, uint cid, CharaInfo charaInfo)
public static void MakeCharacter(uint accountId, uint cid, CharaInfo charaInfo)
{
//Update character entry
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)))
@ -245,7 +245,7 @@ namespace FFXIVClassic_Lobby_Server
Program.Log.Debug("[SQL] CID={0} state updated to active(2).", cid);
}
public static bool renameCharacter(uint userId, uint characterId, uint serverId, String newName)
public static bool RenameCharacter(uint userId, uint characterId, uint serverId, String newName)
{
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)))
{
@ -267,7 +267,7 @@ namespace FFXIVClassic_Lobby_Server
cmd = new MySqlCommand();
cmd.Connection = conn;
cmd.CommandText = "UPDATE characters SET name=@name, doRename=0 WHERE id=@cid AND userId=@uid";
cmd.CommandText = "UPDATE characters SET name=@name, DoRename=0 WHERE id=@cid AND userId=@uid";
cmd.Prepare();
cmd.Parameters.AddWithValue("@uid", userId);
cmd.Parameters.AddWithValue("@cid", characterId);
@ -292,7 +292,7 @@ namespace FFXIVClassic_Lobby_Server
}
}
public static void deleteCharacter(uint characterId, String name)
public static void DeleteCharacter(uint characterId, String name)
{
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)))
{
@ -323,7 +323,7 @@ namespace FFXIVClassic_Lobby_Server
Program.Log.Debug("[SQL] CID={0} deleted.", characterId);
}
public static List<World> getServers()
public static List<World> GetServers()
{
using (var 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)))
{
@ -345,7 +345,7 @@ namespace FFXIVClassic_Lobby_Server
}
}
public static World getServer(uint serverId)
public static World GetServer(uint serverId)
{
using (var 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)))
{
@ -369,7 +369,7 @@ namespace FFXIVClassic_Lobby_Server
}
}
public static List<Character> getCharacters(uint userId)
public static List<Character> GetCharacters(uint userId)
{
List<Character> characters = new List<Character>();
using (var 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)))
@ -384,7 +384,7 @@ namespace FFXIVClassic_Lobby_Server
serverId,
name,
isLegacy,
doRename,
DoRename,
currentZoneId,
guardian,
birthMonth,
@ -427,7 +427,7 @@ namespace FFXIVClassic_Lobby_Server
return characters;
}
public static Character getCharacter(uint userId, uint charId)
public static Character GetCharacter(uint userId, uint charId)
{
Character chara = null;
using (var 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)))
@ -441,7 +441,7 @@ namespace FFXIVClassic_Lobby_Server
serverId,
name,
isLegacy,
doRename,
DoRename,
currentZoneId,
guardian,
birthMonth,
@ -482,7 +482,7 @@ namespace FFXIVClassic_Lobby_Server
return chara;
}
public static Appearance getAppearance(uint charaId)
public static Appearance GetAppearance(uint charaId)
{
using (var 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)))
{
@ -506,7 +506,7 @@ namespace FFXIVClassic_Lobby_Server
}
}
public static List<String> getReservedNames(uint userId)
public static List<String> GetReservedNames(uint userId)
{
using (var 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)))
{
@ -528,7 +528,7 @@ namespace FFXIVClassic_Lobby_Server
}
}
public static List<Retainer> getRetainers(uint userId)
public static List<Retainer> GetRetainers(uint userId)
{
using (var 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)))
{

View file

@ -14,25 +14,25 @@ namespace FFXIVClassic_Lobby_Server
class PacketProcessor
{
public void processPacket(ClientConnection client, BasePacket packet)
public void ProcessPacket(ClientConnection client, BasePacket packet)
{
if ((packet.header.packetSize == 0x288) && (packet.data[0x34] == 'T')) //Test Ticket Data
{
packet.debugPrintPacket();
packet.DebugPrintPacket();
//Crypto handshake
ProcessStartSession(client, packet);
return;
}
BasePacket.decryptPacket(client.blowfish, ref packet);
BasePacket.DecryptPacket(client.blowfish, ref packet);
packet.debugPrintPacket();
packet.DebugPrintPacket();
List<SubPacket> subPackets = packet.getSubpackets();
List<SubPacket> subPackets = packet.GetSubpackets();
foreach (SubPacket subpacket in subPackets)
{
subpacket.debugPrintSubPacket();
subpacket.DebugPrintSubPacket();
if (subpacket.header.type == 3)
{
@ -71,30 +71,30 @@ namespace FFXIVClassic_Lobby_Server
//Respond with acknowledgment
BasePacket outgoingPacket = new BasePacket(HardCoded_Packets.g_secureConnectionAcknowledgment);
BasePacket.encryptPacket(client.blowfish, outgoingPacket);
client.queuePacket(outgoingPacket);
BasePacket.EncryptPacket(client.blowfish, outgoingPacket);
client.QueuePacket(outgoingPacket);
}
private void ProcessSessionAcknowledgement(ClientConnection client, SubPacket packet)
{
packet.debugPrintSubPacket();
packet.DebugPrintSubPacket();
SessionPacket sessionPacket = new SessionPacket(packet.data);
String clientVersion = sessionPacket.version;
Program.Log.Info("Got acknowledgment for secure session.");
Program.Log.Info("CLIENT VERSION: {0}", clientVersion);
uint userId = Database.getUserIdFromSession(sessionPacket.session);
uint userId = Database.GetUserIdFromSession(sessionPacket.session);
client.currentUserId = userId;
client.currentSessionToken = sessionPacket.session; ;
if (userId == 0)
{
ErrorPacket errorPacket = new ErrorPacket(sessionPacket.sequence, 0, 0, 13001, "Your session has expired, please login again.");
SubPacket subpacket = errorPacket.buildPacket();
BasePacket errorBasePacket = BasePacket.createPacket(subpacket, true, false);
BasePacket.encryptPacket(client.blowfish, errorBasePacket);
client.queuePacket(errorBasePacket);
SubPacket subpacket = errorPacket.BuildPacket();
BasePacket errorBasePacket = BasePacket.CreatePacket(subpacket, true, false);
BasePacket.EncryptPacket(client.blowfish, errorBasePacket);
client.QueuePacket(errorBasePacket);
Program.Log.Info("Invalid session, kicking...");
return;
@ -108,19 +108,19 @@ namespace FFXIVClassic_Lobby_Server
defaultAccount.name = "FINAL FANTASY XIV";
accountList.Add(defaultAccount);
AccountListPacket listPacket = new AccountListPacket(1, accountList);
BasePacket basePacket = BasePacket.createPacket(listPacket.buildPackets(), true, false);
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
BasePacket basePacket = BasePacket.CreatePacket(listPacket.BuildPackets(), true, false);
BasePacket.EncryptPacket(client.blowfish, basePacket);
client.QueuePacket(basePacket);
}
private void ProcessGetCharacters(ClientConnection client, SubPacket packet)
{
Program.Log.Info("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId);
Program.Log.Info("{0} => Get characters", client.currentUserId == 0 ? client.GetAddress() : "User " + client.currentUserId);
sendWorldList(client, packet);
sendImportList(client, packet);
sendRetainerList(client, packet);
sendCharacterList(client, packet);
SendWorldList(client, packet);
SendImportList(client, packet);
SendRetainerList(client, packet);
SendCharacterList(client, packet);
}
@ -128,29 +128,29 @@ namespace FFXIVClassic_Lobby_Server
{
SelectCharacterPacket selectCharRequest = new SelectCharacterPacket(packet.data);
Program.Log.Info("{0} => Select character id {1}", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId, selectCharRequest.characterId);
Program.Log.Info("{0} => Select character id {1}", client.currentUserId == 0 ? client.GetAddress() : "User " + client.currentUserId, selectCharRequest.characterId);
Character chara = Database.getCharacter(client.currentUserId, selectCharRequest.characterId);
Character chara = Database.GetCharacter(client.currentUserId, selectCharRequest.characterId);
World world = null;
if (chara != null)
world = Database.getServer(chara.serverId);
world = Database.GetServer(chara.serverId);
if (world == null)
{
ErrorPacket errorPacket = new ErrorPacket(selectCharRequest.sequence, 0, 0, 13001, "World does not exist or is inactive.");
SubPacket subpacket = errorPacket.buildPacket();
BasePacket basePacket = BasePacket.createPacket(subpacket, true, false);
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
ErrorPacket errorPacket = new ErrorPacket(selectCharRequest.sequence, 0, 0, 13001, "World Does not exist or is inactive.");
SubPacket subpacket = errorPacket.BuildPacket();
BasePacket basePacket = BasePacket.CreatePacket(subpacket, true, false);
BasePacket.EncryptPacket(client.blowfish, basePacket);
client.QueuePacket(basePacket);
return;
}
SelectCharacterConfirmPacket connectCharacter = new SelectCharacterConfirmPacket(selectCharRequest.sequence, selectCharRequest.characterId, client.currentSessionToken, world.address, world.port, selectCharRequest.ticket);
BasePacket outgoingPacket = BasePacket.createPacket(connectCharacter.buildPackets(), true, false);
BasePacket.encryptPacket(client.blowfish, outgoingPacket);
client.queuePacket(outgoingPacket);
BasePacket outgoingPacket = BasePacket.CreatePacket(connectCharacter.BuildPackets(), true, false);
BasePacket.EncryptPacket(client.blowfish, outgoingPacket);
client.QueuePacket(outgoingPacket);
}
private void ProcessModifyCharacter(ClientConnection client, SubPacket packet)
@ -169,23 +169,23 @@ namespace FFXIVClassic_Lobby_Server
//Check if this character exists, get world from there
if (worldId == 0 && charaReq.characterId != 0)
{
Character chara = Database.getCharacter(client.currentUserId, charaReq.characterId);
Character chara = Database.GetCharacter(client.currentUserId, charaReq.characterId);
if (chara != null)
worldId = chara.serverId;
}
string worldName = null;
World world = Database.getServer(worldId);
World world = Database.GetServer(worldId);
if (world != null)
worldName = world.name;
if (worldName == null)
{
ErrorPacket errorPacket = new ErrorPacket(charaReq.sequence, 0, 0, 13001, "World does not exist or is inactive.");
SubPacket subpacket = errorPacket.buildPacket();
BasePacket basePacket = BasePacket.createPacket(subpacket, true, false);
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
ErrorPacket errorPacket = new ErrorPacket(charaReq.sequence, 0, 0, 13001, "World Does not exist or is inactive.");
SubPacket subpacket = errorPacket.BuildPacket();
BasePacket basePacket = BasePacket.CreatePacket(subpacket, true, false);
BasePacket.EncryptPacket(client.blowfish, basePacket);
client.QueuePacket(basePacket);
Program.Log.Info("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId);
return;
@ -197,15 +197,15 @@ namespace FFXIVClassic_Lobby_Server
{
case 0x01://Reserve
alreadyTaken = Database.reserveCharacter(client.currentUserId, slot, worldId, name, out pid, out cid);
alreadyTaken = Database.ReserveCharacter(client.currentUserId, slot, worldId, name, out pid, out cid);
if (alreadyTaken)
{
ErrorPacket errorPacket = new ErrorPacket(charaReq.sequence, 1003, 0, 13005, ""); //BDB - Chara Name Used, //1003 - Bad Word
SubPacket subpacket = errorPacket.buildPacket();
BasePacket basePacket = BasePacket.createPacket(subpacket, true, false);
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
SubPacket subpacket = errorPacket.BuildPacket();
BasePacket basePacket = BasePacket.CreatePacket(subpacket, true, false);
BasePacket.EncryptPacket(client.blowfish, basePacket);
client.QueuePacket(basePacket);
Program.Log.Info("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName);
return;
@ -222,7 +222,7 @@ namespace FFXIVClassic_Lobby_Server
Program.Log.Info("User {0} => Character reserved \"{1}\"", client.currentUserId, name);
break;
case 0x02://Make
CharaInfo info = CharaInfo.getFromNewCharRequest(charaReq.characterInfoEncoded);
CharaInfo info = CharaInfo.GetFromNewCharRequest(charaReq.characterInfoEncoded);
//Set Initial Appearance (items will be loaded in by map server)
uint[] classAppearance = CharacterCreatorUtils.GetEquipmentForClass(info.currentClass);
@ -266,25 +266,25 @@ namespace FFXIVClassic_Lobby_Server
break;
}
Database.makeCharacter(client.currentUserId, client.newCharaCid, info);
Database.MakeCharacter(client.currentUserId, client.newCharaCid, info);
pid = 1;
cid = client.newCharaCid;
name = client.newCharaName;
Program.Log.Info("User {0} => Character created \"{1}\"", client.currentUserId, name);
Program.Log.Info("User {0} => Character Created \"{1}\"", client.currentUserId, name);
break;
case 0x03://Rename
alreadyTaken = Database.renameCharacter(client.currentUserId, charaReq.characterId, worldId, charaReq.characterName);
alreadyTaken = Database.RenameCharacter(client.currentUserId, charaReq.characterId, worldId, charaReq.characterName);
if (alreadyTaken)
{
ErrorPacket errorPacket = new ErrorPacket(charaReq.sequence, 1003, 0, 13005, ""); //BDB - Chara Name Used, //1003 - Bad Word
SubPacket subpacket = errorPacket.buildPacket();
BasePacket basePacket = BasePacket.createPacket(subpacket, true, false);
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
SubPacket subpacket = errorPacket.BuildPacket();
BasePacket basePacket = BasePacket.CreatePacket(subpacket, true, false);
BasePacket.EncryptPacket(client.blowfish, basePacket);
client.QueuePacket(basePacket);
Program.Log.Info("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName);
return;
@ -293,7 +293,7 @@ namespace FFXIVClassic_Lobby_Server
Program.Log.Info("User {0} => Character renamed \"{1}\"", client.currentUserId, name);
break;
case 0x04://Delete
Database.deleteCharacter(charaReq.characterId, charaReq.characterName);
Database.DeleteCharacter(charaReq.characterId, charaReq.characterName);
Program.Log.Info("User {0} => Character deleted \"{1}\"", client.currentUserId, name);
break;
@ -304,58 +304,58 @@ namespace FFXIVClassic_Lobby_Server
}
CharaCreatorPacket charaCreator = new CharaCreatorPacket(charaReq.sequence, charaReq.command, pid, cid, 1, name, worldName);
BasePacket charaCreatorPacket = BasePacket.createPacket(charaCreator.buildPacket(), true, false);
BasePacket.encryptPacket(client.blowfish, charaCreatorPacket);
client.queuePacket(charaCreatorPacket);
BasePacket charaCreatorPacket = BasePacket.CreatePacket(charaCreator.BuildPacket(), true, false);
BasePacket.EncryptPacket(client.blowfish, charaCreatorPacket);
client.QueuePacket(charaCreatorPacket);
}
private void sendWorldList(ClientConnection client, SubPacket packet)
private void SendWorldList(ClientConnection client, SubPacket packet)
{
List<World> serverList = Database.getServers();
List<World> serverList = Database.GetServers();
WorldListPacket worldlistPacket = new WorldListPacket(0, serverList);
List<SubPacket> subPackets = worldlistPacket.buildPackets();
List<SubPacket> subPackets = worldlistPacket.BuildPackets();
BasePacket basePacket = BasePacket.createPacket(subPackets, true, false);
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
BasePacket basePacket = BasePacket.CreatePacket(subPackets, true, false);
BasePacket.EncryptPacket(client.blowfish, basePacket);
client.QueuePacket(basePacket);
}
private void sendImportList(ClientConnection client, SubPacket packet)
private void SendImportList(ClientConnection client, SubPacket packet)
{
List<String> names = Database.getReservedNames(client.currentUserId);
List<String> names = Database.GetReservedNames(client.currentUserId);
ImportListPacket importListPacket = new ImportListPacket(0, names);
List<SubPacket> subPackets = importListPacket.buildPackets();
BasePacket basePacket = BasePacket.createPacket(subPackets, true, false);
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
List<SubPacket> subPackets = importListPacket.BuildPackets();
BasePacket basePacket = BasePacket.CreatePacket(subPackets, true, false);
BasePacket.EncryptPacket(client.blowfish, basePacket);
client.QueuePacket(basePacket);
}
private void sendRetainerList(ClientConnection client, SubPacket packet)
private void SendRetainerList(ClientConnection client, SubPacket packet)
{
List<Retainer> retainers = Database.getRetainers(client.currentUserId);
List<Retainer> retainers = Database.GetRetainers(client.currentUserId);
RetainerListPacket retainerListPacket = new RetainerListPacket(0, retainers);
List<SubPacket> subPackets = retainerListPacket.buildPackets();
BasePacket basePacket = BasePacket.createPacket(subPackets, true, false);
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
List<SubPacket> subPackets = retainerListPacket.BuildPackets();
BasePacket basePacket = BasePacket.CreatePacket(subPackets, true, false);
BasePacket.EncryptPacket(client.blowfish, basePacket);
client.QueuePacket(basePacket);
}
private void sendCharacterList(ClientConnection client, SubPacket packet)
private void SendCharacterList(ClientConnection client, SubPacket packet)
{
List<Character> characterList = Database.getCharacters(client.currentUserId);
List<Character> characterList = Database.GetCharacters(client.currentUserId);
if (characterList.Count > 8)
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();
BasePacket basePacket = BasePacket.createPacket(subPackets, true, false);
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
List<SubPacket> subPackets = characterlistPacket.BuildPackets();
BasePacket basePacket = BasePacket.CreatePacket(subPackets, true, false);
BasePacket.EncryptPacket(client.blowfish, basePacket);
client.QueuePacket(basePacket);
}
private byte[] GenerateKey(string ticketPhrase, uint clientNumber)

View file

@ -21,7 +21,7 @@ namespace FFXIVClassic_Lobby_Server
bool startServer = true;
//Load Config
if (!ConfigConstants.load())
if (!ConfigConstants.Load())
startServer = false;
Log = LogManager.GetCurrentClassLogger();
@ -57,7 +57,7 @@ namespace FFXIVClassic_Lobby_Server
if (startServer)
{
Server server = new Server();
server.startServer();
server.StartServer();
}
Program.Log.Info("Press any key to continue...");

View file

@ -24,7 +24,7 @@ namespace FFXIVClassic_Lobby_Server
private Thread cleanupThread;
private bool killCleanupThread = false;
private void socketCleanup()
private void SocketCleanup()
{
Program.Log.Info("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME);
while (!killCleanupThread)
@ -47,7 +47,7 @@ namespace FFXIVClassic_Lobby_Server
}
#region Socket Handling
public bool startServer()
public bool StartServer()
{
//cleanupThread = new Thread(new ThreadStart(socketCleanup));
//cleanupThread.Name = "LobbyThread:Cleanup";
@ -60,7 +60,7 @@ namespace FFXIVClassic_Lobby_Server
}
catch (Exception e)
{
throw new ApplicationException("Could not create socket, check to make sure not duplicating port", e);
throw new ApplicationException("Could not Create socket, check to make sure not duplicating port", e);
}
try
{
@ -73,7 +73,7 @@ namespace FFXIVClassic_Lobby_Server
}
try
{
mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket);
mServerSocket.BeginAccept(new AsyncCallback(AcceptCallback), mServerSocket);
}
catch (Exception e)
{
@ -89,7 +89,7 @@ namespace FFXIVClassic_Lobby_Server
return true;
}
private void acceptCallback(IAsyncResult result)
private void AcceptCallback(IAsyncResult result)
{
ClientConnection conn = null;
try
@ -103,9 +103,9 @@ namespace FFXIVClassic_Lobby_Server
mConnectionList.Add(conn);
}
//Queue recieving of data from the connection
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn);
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), conn);
//Queue the accept of the next incomming connection
mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket);
mServerSocket.BeginAccept(new AsyncCallback(AcceptCallback), mServerSocket);
Program.Log.Info("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port);
}
catch (SocketException)
@ -118,7 +118,7 @@ namespace FFXIVClassic_Lobby_Server
mConnectionList.Remove(conn);
}
}
mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket);
mServerSocket.BeginAccept(new AsyncCallback(AcceptCallback), mServerSocket);
}
catch (Exception)
{
@ -130,11 +130,11 @@ namespace FFXIVClassic_Lobby_Server
mConnectionList.Remove(conn);
}
}
mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket);
mServerSocket.BeginAccept(new AsyncCallback(AcceptCallback), mServerSocket);
}
}
private void receiveCallback(IAsyncResult result)
private void ReceiveCallback(IAsyncResult result)
{
ClientConnection conn = (ClientConnection)result.AsyncState;
@ -151,13 +151,13 @@ namespace FFXIVClassic_Lobby_Server
//Build packets until can no longer or out of data
while (true)
{
BasePacket basePacket = buildPacket(ref offset, conn.buffer, bytesRead);
BasePacket basePacket = BuildPacket(ref offset, conn.buffer, bytesRead);
//If can't build packet, break, else process another
if (basePacket == null)
break;
else
mProcessor.processPacket(conn, basePacket);
mProcessor.ProcessPacket(conn, basePacket);
}
//Not all bytes consumed, transfer leftover to beginning
@ -169,22 +169,22 @@ namespace FFXIVClassic_Lobby_Server
conn.lastPartialSize = bytesRead - offset;
//Build any queued subpackets into basepackets and send
conn.flushQueuedSendPackets();
conn.FlushQueuedSendPackets();
if (offset < bytesRead)
//Need offset since not all bytes consumed
conn.socket.BeginReceive(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset), SocketFlags.None, new AsyncCallback(receiveCallback), conn);
conn.socket.BeginReceive(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset), SocketFlags.None, new AsyncCallback(ReceiveCallback), conn);
else
//All bytes consumed, full buffer available
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn);
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), conn);
}
else
{
Program.Log.Info("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId);
Program.Log.Info("{0} has disconnected.", conn.currentUserId == 0 ? conn.GetAddress() : "User " + conn.currentUserId);
lock (mConnectionList)
{
conn.disconnect();
conn.Disconnect();
mConnectionList.Remove(conn);
}
}
@ -193,7 +193,7 @@ namespace FFXIVClassic_Lobby_Server
{
if (conn.socket != null)
{
Program.Log.Info("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId);
Program.Log.Info("{0} has disconnected.", conn.currentUserId == 0 ? conn.GetAddress() : "User " + conn.currentUserId);
lock (mConnectionList)
{
@ -209,7 +209,7 @@ namespace FFXIVClassic_Lobby_Server
/// <param name="offset">Current offset in buffer.</param>
/// <param name="buffer">Incoming buffer.</param>
/// <returns>Returns either a BasePacket or null if not enough data.</returns>
public BasePacket buildPacket(ref int offset, byte[] buffer, int bytesRead)
public BasePacket BuildPacket(ref int offset, byte[] buffer, int bytesRead)
{
BasePacket newPacket = null;

View file

@ -56,7 +56,7 @@ namespace FFXIVClassic_Lobby_Server.dataobjects
public uint feet;
public uint belt;
public static CharaInfo getFromNewCharRequest(String encoded)
public static CharaInfo GetFromNewCharRequest(String encoded)
{
byte[] data = Convert.FromBase64String(encoded.Replace('-', '+').Replace('_', '/'));
@ -116,7 +116,7 @@ namespace FFXIVClassic_Lobby_Server.dataobjects
return info;
}
public static String buildForCharaList(Character chara, Appearance appearance)
public static String BuildForCharaList(Character chara, Appearance appearance)
{
byte[] data;
@ -146,7 +146,7 @@ namespace FFXIVClassic_Lobby_Server.dataobjects
writer.Write(System.Text.Encoding.UTF8.GetBytes(chara.name + '\0'));
writer.Write((UInt32)0x1c);
writer.Write((UInt32)0x04);
writer.Write((UInt32)getTribeModel(chara.tribe));
writer.Write((UInt32)GetTribeModel(chara.tribe));
writer.Write((UInt32)appearance.size);
uint colorVal = appearance.skinColor | (uint)(appearance.hairColor << 10) | (uint)(appearance.eyeColor << 20);
writer.Write((UInt32)colorVal);
@ -223,7 +223,7 @@ namespace FFXIVClassic_Lobby_Server.dataobjects
return Convert.ToBase64String(data).Replace('+', '-').Replace('/', '_');
}
public static String debug()
public static String Debug()
{
byte[] bytes = File.ReadAllBytes("./packets/charaappearance.bin");
@ -232,7 +232,7 @@ namespace FFXIVClassic_Lobby_Server.dataobjects
return Convert.ToBase64String(bytes).Replace('+', '-').Replace('/', '_');
}
public static UInt32 getTribeModel(byte tribe)
public static UInt32 GetTribeModel(byte tribe)
{
switch (tribe)
{

View file

@ -103,7 +103,7 @@ namespace FFXIVClassic_Lobby_Server.packets
this.data = data;
}
public List<SubPacket> getSubpackets()
public List<SubPacket> GetSubpackets()
{
List<SubPacket> subpackets = new List<SubPacket>(header.numSubpackets);
@ -115,7 +115,7 @@ namespace FFXIVClassic_Lobby_Server.packets
return subpackets;
}
public unsafe static BasePacketHeader getHeader(byte[] bytes)
public unsafe static BasePacketHeader GetHeader(byte[] bytes)
{
BasePacketHeader header;
if (bytes.Length < BASEPACKET_SIZE)
@ -129,7 +129,7 @@ namespace FFXIVClassic_Lobby_Server.packets
return header;
}
public byte[] getHeaderBytes()
public byte[] GetHeaderBytes()
{
int size = Marshal.SizeOf(header);
byte[] arr = new byte[size];
@ -141,16 +141,16 @@ namespace FFXIVClassic_Lobby_Server.packets
return arr;
}
public byte[] getPacketBytes()
public byte[] GetPacketBytes()
{
byte[] outBytes = new byte[header.packetSize];
Array.Copy(getHeaderBytes(), 0, outBytes, 0, BASEPACKET_SIZE);
Array.Copy(GetHeaderBytes(), 0, outBytes, 0, BASEPACKET_SIZE);
Array.Copy(data, 0, outBytes, BASEPACKET_SIZE, data.Length);
return outBytes;
}
//Replaces all instances of the sniffed actorID with the given one
public void replaceActorID(uint actorID)
public void ReplaceActorID(uint actorID)
{
using (MemoryStream mem = new MemoryStream(data))
{
@ -173,7 +173,7 @@ namespace FFXIVClassic_Lobby_Server.packets
}
//Replaces all instances of the sniffed actorID with the given one
public void replaceActorID(uint fromActorID, uint actorID)
public void ReplaceActorID(uint fromActorID, uint actorID)
{
using (MemoryStream mem = new MemoryStream(data))
{
@ -196,7 +196,7 @@ namespace FFXIVClassic_Lobby_Server.packets
}
#region Utility Functions
public static BasePacket createPacket(List<SubPacket> subpackets, bool isAuthed, bool isEncrypted)
public static BasePacket CreatePacket(List<SubPacket> subpackets, bool isAuthed, bool isEncrypted)
{
//Create Header
BasePacketHeader header = new BasePacketHeader();
@ -218,7 +218,7 @@ namespace FFXIVClassic_Lobby_Server.packets
int offset = 0;
foreach (SubPacket subpacket in subpackets)
{
byte[] subpacketData = subpacket.getBytes();
byte[] subpacketData = subpacket.GetBytes();
Array.Copy(subpacketData, 0, data, offset, subpacketData.Length);
offset += (ushort)subpacketData.Length;
}
@ -229,7 +229,7 @@ namespace FFXIVClassic_Lobby_Server.packets
return packet;
}
public static BasePacket createPacket(SubPacket subpacket, bool isAuthed, bool isEncrypted)
public static BasePacket CreatePacket(SubPacket subpacket, bool isAuthed, bool isEncrypted)
{
//Create Header
BasePacketHeader header = new BasePacketHeader();
@ -247,7 +247,7 @@ namespace FFXIVClassic_Lobby_Server.packets
data = new byte[header.packetSize - 0x10];
//Add Subpackets
byte[] subpacketData = subpacket.getBytes();
byte[] subpacketData = subpacket.GetBytes();
Array.Copy(subpacketData, 0, data, 0, subpacketData.Length);
Debug.Assert(data != null);
@ -256,7 +256,7 @@ namespace FFXIVClassic_Lobby_Server.packets
return packet;
}
public static BasePacket createPacket(byte[] data, bool isAuthed, bool isEncrypted)
public static BasePacket CreatePacket(byte[] data, bool isAuthed, bool isEncrypted)
{
Debug.Assert(data != null);
@ -277,7 +277,7 @@ namespace FFXIVClassic_Lobby_Server.packets
return packet;
}
public static unsafe void encryptPacket(Blowfish blowfish, BasePacket packet)
public static unsafe void EncryptPacket(Blowfish blowfish, BasePacket packet)
{
byte[] data = packet.data;
int size = packet.header.packetSize;
@ -304,7 +304,7 @@ namespace FFXIVClassic_Lobby_Server.packets
}
public static unsafe void decryptPacket(Blowfish blowfish, ref BasePacket packet)
public static unsafe void DecryptPacket(Blowfish blowfish, ref BasePacket packet)
{
byte[] data = packet.data;
int size = packet.header.packetSize;
@ -331,16 +331,16 @@ namespace FFXIVClassic_Lobby_Server.packets
}
#endregion
public void debugPrintPacket()
public void DebugPrintPacket()
{
#if DEBUG
Console.BackgroundColor = ConsoleColor.DarkYellow;
Program.Log.Debug("IsAuth: {0} Size: 0x{1:X}, NumSubpackets: {2}{3}{4}", header.isAuthenticated, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()));
Program.Log.Debug("IsAuth: {0} Size: 0x{1:X}, NumSubpackets: {2}{3}{4}", header.isAuthenticated, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(GetHeaderBytes()));
foreach (SubPacket sub in getSubpackets())
foreach (SubPacket sub in GetSubpackets())
{
sub.debugPrintSubPacket();
sub.DebugPrintSubPacket();
}
Console.BackgroundColor = ConsoleColor.Black;

View file

@ -101,7 +101,7 @@ namespace FFXIVClassic_Lobby_Server.packets
data = original.data;
}
public byte[] getHeaderBytes()
public byte[] GetHeaderBytes()
{
int size = Marshal.SizeOf(header);
byte[] arr = new byte[size];
@ -113,7 +113,7 @@ namespace FFXIVClassic_Lobby_Server.packets
return arr;
}
public byte[] getGameMessageBytes()
public byte[] GetGameMessageBytes()
{
int size = Marshal.SizeOf(gameMessage);
byte[] arr = new byte[size];
@ -125,26 +125,26 @@ namespace FFXIVClassic_Lobby_Server.packets
return arr;
}
public byte[] getBytes()
public byte[] GetBytes()
{
byte[] outBytes = new byte[header.subpacketSize];
Array.Copy(getHeaderBytes(), 0, outBytes, 0, SUBPACKET_SIZE);
Array.Copy(GetHeaderBytes(), 0, outBytes, 0, SUBPACKET_SIZE);
if (header.type == 0x3)
Array.Copy(getGameMessageBytes(), 0, outBytes, SUBPACKET_SIZE, GAMEMESSAGE_SIZE);
Array.Copy(GetGameMessageBytes(), 0, outBytes, SUBPACKET_SIZE, GAMEMESSAGE_SIZE);
Array.Copy(data, 0, outBytes, SUBPACKET_SIZE + (header.type == 0x3 ? GAMEMESSAGE_SIZE : 0), data.Length);
return outBytes;
}
public void debugPrintSubPacket()
public void DebugPrintSubPacket()
{
#if DEBUG
Program.Log.Debug("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()));
Program.Log.Debug("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(GetHeaderBytes()));
if (header.type == 0x03)
{
Program.Log.Debug("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE));
Program.Log.Debug("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(GetGameMessageBytes(), SUBPACKET_SIZE));
}
Program.Log.Debug("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE));

View file

@ -20,7 +20,7 @@ namespace FFXIVClassic_Lobby_Server.packets
this.accountList = accountList;
}
public List<SubPacket> buildPackets()
public List<SubPacket> BuildPackets()
{
List<SubPacket> subPackets = new List<SubPacket>();

View file

@ -36,7 +36,7 @@ namespace FFXIVClassic_Lobby_Server.packets
this.worldName = worldName;
}
public SubPacket buildPacket()
public SubPacket BuildPacket()
{
MemoryStream memStream = new MemoryStream(0x1F0);
BinaryWriter binWriter = new BinaryWriter(memStream);

View file

@ -20,7 +20,7 @@ namespace FFXIVClassic_Lobby_Server.packets
this.characterList = characterList;
}
public List<SubPacket> buildPackets()
public List<SubPacket> BuildPackets()
{
List<SubPacket> subPackets = new List<SubPacket>();
@ -34,7 +34,7 @@ namespace FFXIVClassic_Lobby_Server.packets
foreach (Character chara in characterList)
{
Appearance appearance = Database.getAppearance(chara.id);
Appearance appearance = Database.GetAppearance(chara.id);
if (totalCount == 0 || characterCount % MAXPERPACKET == 0)
{
@ -53,7 +53,7 @@ namespace FFXIVClassic_Lobby_Server.packets
binWriter.Seek(0x10 + (0x1D0 * characterCount), SeekOrigin.Begin);
//Write Entries
World world = Database.getServer(chara.serverId);
World world = Database.GetServer(chara.serverId);
string worldname = world == null ? "Unknown" : world.name;
binWriter.Write((uint)0); //???
@ -74,8 +74,8 @@ namespace FFXIVClassic_Lobby_Server.packets
binWriter.Write(Encoding.ASCII.GetBytes(chara.name.PadRight(0x20, '\0'))); //Name
binWriter.Write(Encoding.ASCII.GetBytes(worldname.PadRight(0xE, '\0'))); //World Name
binWriter.Write(CharaInfo.buildForCharaList(chara, appearance)); //Appearance Data
//binWriter.Write(CharaInfo.debug()); //Appearance Data
binWriter.Write(CharaInfo.BuildForCharaList(chara, appearance)); //Appearance Data
//binWriter.Write(CharaInfo.Debug()); //Appearance Data
characterCount++;
totalCount++;

View file

@ -23,7 +23,7 @@ namespace FFXIVClassic_Lobby_Server.packets
this.message = message;
}
public SubPacket buildPacket()
public SubPacket BuildPacket()
{
MemoryStream memStream = new MemoryStream(0x210);
BinaryWriter binWriter = new BinaryWriter(memStream);

View file

@ -19,7 +19,7 @@ namespace FFXIVClassic_Lobby_Server.packets
this.namesList = names;
}
public List<SubPacket> buildPackets()
public List<SubPacket> BuildPackets()
{
List<SubPacket> subPackets = new List<SubPacket>();

View file

@ -19,7 +19,7 @@ namespace FFXIVClassic_Lobby_Server.packets
this.retainerList = retainerList;
}
public List<SubPacket> buildPackets()
public List<SubPacket> BuildPackets()
{
List<SubPacket> subPackets = new List<SubPacket>();

View file

@ -26,7 +26,7 @@ namespace FFXIVClassic_Lobby_Server.packets
this.selectCharTicket = selectCharTicket;
}
public List<SubPacket> buildPackets()
public List<SubPacket> BuildPackets()
{
List<SubPacket> subPackets = new List<SubPacket>();

View file

@ -20,7 +20,7 @@ namespace FFXIVClassic_Lobby_Server.packets
this.worldList = serverList;
}
public List<SubPacket> buildPackets()
public List<SubPacket> BuildPackets()
{
List<SubPacket> subPackets = new List<SubPacket>();