mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
Cleaned up namespaces (still have to do Map Project) and removed references to FFXIV Classic from the code. Removed the Launcher Editor project as it is no longer needed (host file editing is cleaner).
This commit is contained in:
121
Lobby Server/Packets/Send/AccountListPacket.cs
Normal file
121
Lobby Server/Packets/Send/AccountListPacket.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Meteor.Common;
|
||||
using Meteor.Lobby.DataObjects;
|
||||
|
||||
namespace Meteor.Lobby.Packets
|
||||
{
|
||||
class AccountListPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x0C;
|
||||
public const ushort MAXPERPACKET = 8;
|
||||
|
||||
private UInt64 sequence;
|
||||
private List<Account> accountList;
|
||||
|
||||
public AccountListPacket(UInt64 sequence, List<Account> accountList)
|
||||
{
|
||||
this.sequence = sequence;
|
||||
this.accountList = accountList;
|
||||
}
|
||||
|
||||
public List<SubPacket> BuildPackets()
|
||||
{
|
||||
List<SubPacket> subPackets = new List<SubPacket>();
|
||||
|
||||
int accountCount = 0;
|
||||
int totalCount = 0;
|
||||
|
||||
MemoryStream memStream = null;
|
||||
BinaryWriter binWriter = null;
|
||||
|
||||
foreach (Account account in accountList)
|
||||
{
|
||||
if (totalCount == 0 || accountCount % MAXPERPACKET == 0)
|
||||
{
|
||||
memStream = new MemoryStream(0x280);
|
||||
binWriter = new BinaryWriter(memStream);
|
||||
|
||||
//Write List Info
|
||||
binWriter.Write((UInt64)sequence);
|
||||
byte listTracker = (byte)((MAXPERPACKET * 2) * subPackets.Count);
|
||||
binWriter.Write(accountList.Count - totalCount <= MAXPERPACKET ? (byte)(listTracker + 1) : (byte)(listTracker));
|
||||
binWriter.Write(accountList.Count - totalCount <= MAXPERPACKET ? (UInt32)(accountList.Count - totalCount) : (UInt32)MAXPERPACKET);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write((UInt16)0);
|
||||
}
|
||||
|
||||
//Write Entries
|
||||
binWriter.Write((UInt32)account.id);
|
||||
binWriter.Write((UInt32)0);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(account.name.PadRight(0x40, '\0')));
|
||||
|
||||
accountCount++;
|
||||
totalCount++;
|
||||
|
||||
//Send this chunk of world list
|
||||
if (accountCount >= MAXPERPACKET)
|
||||
{
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
accountCount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//If there is anything left that was missed or the list is empty
|
||||
if (accountCount > 0 || accountList.Count == 0)
|
||||
{
|
||||
if (accountList.Count == 0)
|
||||
{
|
||||
memStream = new MemoryStream(0x210);
|
||||
binWriter = new BinaryWriter(memStream);
|
||||
|
||||
//Write Empty List Info
|
||||
binWriter.Write((UInt64)sequence);
|
||||
byte listTracker = (byte)((MAXPERPACKET * 2) * subPackets.Count);
|
||||
binWriter.Write(accountList.Count - totalCount <= MAXPERPACKET ? (byte)(listTracker + 1) : (byte)(listTracker));
|
||||
binWriter.Write((UInt32)0);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write((UInt16)0);
|
||||
}
|
||||
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
}
|
||||
|
||||
return subPackets;
|
||||
}
|
||||
}
|
||||
}
|
86
Lobby Server/Packets/Send/CharaCreatorPacket.cs
Normal file
86
Lobby Server/Packets/Send/CharaCreatorPacket.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Meteor.Common;
|
||||
|
||||
namespace Meteor.Lobby.Packets
|
||||
{
|
||||
class CharaCreatorPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x0E;
|
||||
|
||||
public const ushort RESERVE = 0x01;
|
||||
public const ushort MAKE = 0x02;
|
||||
public const ushort RENAME = 0x03;
|
||||
public const ushort DELETE = 0x04;
|
||||
public const ushort RENAME_RETAINER = 0x06;
|
||||
|
||||
private UInt64 sequence;
|
||||
|
||||
private ushort command;
|
||||
private uint pid;
|
||||
private uint cid;
|
||||
private uint type;
|
||||
private uint ticket;
|
||||
private string charaName;
|
||||
private string worldName;
|
||||
|
||||
public CharaCreatorPacket(UInt64 sequence, ushort command, uint pid, uint cid, uint ticket, string charaName, string worldName)
|
||||
{
|
||||
this.sequence = sequence;
|
||||
this.command = command;
|
||||
this.pid = pid;
|
||||
this.cid = cid;
|
||||
this.type = 0x400017;
|
||||
this.ticket = ticket;
|
||||
this.charaName = charaName;
|
||||
this.worldName = worldName;
|
||||
}
|
||||
|
||||
public SubPacket BuildPacket()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream(0x1F0);
|
||||
BinaryWriter binWriter = new BinaryWriter(memStream);
|
||||
|
||||
binWriter.Write((UInt64)sequence);
|
||||
binWriter.Write((byte)1);
|
||||
binWriter.Write((byte)1);
|
||||
binWriter.Write((UInt16)command);
|
||||
binWriter.Write((UInt32)0);
|
||||
|
||||
binWriter.Write((UInt32)pid); //PID
|
||||
binWriter.Write((UInt32)cid); //CID
|
||||
binWriter.Write((UInt32)type); //Type?
|
||||
binWriter.Write((UInt32)ticket); //Ticket
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(charaName.PadRight(0x20, '\0'))); //Name
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(worldName.PadRight(0x20, '\0'))); //World Name
|
||||
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
|
||||
return new SubPacket(OPCODE, 0xe0006868, data);
|
||||
}
|
||||
}
|
||||
}
|
179
Lobby Server/Packets/Send/CharacterListPacket.cs
Normal file
179
Lobby Server/Packets/Send/CharacterListPacket.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Meteor.Common;
|
||||
using Meteor.Lobby.DataObjects;
|
||||
|
||||
namespace Meteor.Lobby.Packets
|
||||
{
|
||||
class CharacterListPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x0D;
|
||||
public const ushort MAXPERPACKET = 2;
|
||||
|
||||
private ulong sequence;
|
||||
private List<Character> characterList;
|
||||
|
||||
public CharacterListPacket(ulong sequence, List<Character> characterList)
|
||||
{
|
||||
this.sequence = sequence;
|
||||
this.characterList = characterList;
|
||||
}
|
||||
|
||||
public List<SubPacket> BuildPackets()
|
||||
{
|
||||
List<SubPacket> subPackets = new List<SubPacket>();
|
||||
|
||||
int numCharacters = characterList.Count >= 8 ? 8 : characterList.Count + 1;
|
||||
|
||||
int characterCount = 0;
|
||||
int totalCount = 0;
|
||||
|
||||
MemoryStream memStream = null;
|
||||
BinaryWriter binWriter = null;
|
||||
|
||||
foreach (Character chara in characterList)
|
||||
{
|
||||
Appearance appearance = Database.GetAppearance(chara.id);
|
||||
|
||||
if (totalCount == 0 || characterCount % MAXPERPACKET == 0)
|
||||
{
|
||||
memStream = new MemoryStream(0x3B0);
|
||||
binWriter = new BinaryWriter(memStream);
|
||||
|
||||
//Write List Info
|
||||
binWriter.Write((UInt64)sequence);
|
||||
byte listTracker = (byte)((MAXPERPACKET * 2) * subPackets.Count);
|
||||
binWriter.Write(numCharacters - totalCount <= MAXPERPACKET ? (byte)(listTracker + 1) : (byte)(listTracker));
|
||||
binWriter.Write(numCharacters - totalCount <= MAXPERPACKET ? (UInt32)(numCharacters - totalCount) : (UInt32)MAXPERPACKET);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write((UInt16)0);
|
||||
}
|
||||
|
||||
binWriter.Seek(0x10 + (0x1D0 * characterCount), SeekOrigin.Begin);
|
||||
|
||||
//Write Entries
|
||||
World world = Database.GetServer(chara.serverId);
|
||||
string worldname = world == null ? "Unknown" : world.name;
|
||||
|
||||
binWriter.Write((uint)0); //???
|
||||
binWriter.Write((uint)chara.id); //Character Id
|
||||
binWriter.Write((byte)(totalCount)); //Slot
|
||||
|
||||
byte options = 0;
|
||||
if (chara.state == 1)
|
||||
options |= 0x01;
|
||||
if (chara.doRename)
|
||||
options |= 0x02;
|
||||
if (chara.isLegacy)
|
||||
options |= 0x08;
|
||||
|
||||
binWriter.Write((byte)options); //Options (0x01: Service Account not active, 0x72: Change Chara Name)
|
||||
binWriter.Write((ushort)0);
|
||||
binWriter.Write((uint)chara.currentZoneId); //Logged out zone
|
||||
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
|
||||
|
||||
characterCount++;
|
||||
totalCount++;
|
||||
|
||||
//Send this chunk of character list
|
||||
if (characterCount >= MAXPERPACKET)
|
||||
{
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
characterCount = 0;
|
||||
}
|
||||
|
||||
//Incase DB came back with more than max
|
||||
if (totalCount >= 8)
|
||||
break;
|
||||
}
|
||||
|
||||
//Add a 'NEW' slot if there is space
|
||||
if (characterList.Count < 8)
|
||||
{
|
||||
if (characterCount % MAXPERPACKET == 0)
|
||||
{
|
||||
memStream = new MemoryStream(0x3B0);
|
||||
binWriter = new BinaryWriter(memStream);
|
||||
|
||||
//Write List Info
|
||||
binWriter.Write((UInt64)sequence);
|
||||
byte listTracker = (byte)((MAXPERPACKET * 2) * subPackets.Count);
|
||||
binWriter.Write(numCharacters - totalCount <= MAXPERPACKET ? (byte)(listTracker + 1) : (byte)(listTracker));
|
||||
binWriter.Write(numCharacters - totalCount <= MAXPERPACKET ? (UInt32)(numCharacters-totalCount) : (UInt32)MAXPERPACKET);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write((UInt16)0);
|
||||
}
|
||||
|
||||
binWriter.Seek(0x10 + (0x1D0 * characterCount), SeekOrigin.Begin);
|
||||
|
||||
//Write Entries
|
||||
binWriter.Write((uint)0); //???
|
||||
binWriter.Write((uint)0); //Character Id
|
||||
binWriter.Write((byte)(totalCount)); //Slot
|
||||
binWriter.Write((byte)0); //Options (0x01: Service Account not active, 0x72: Change Chara Name)
|
||||
binWriter.Write((ushort)0);
|
||||
binWriter.Write((uint)0); //Logged out zone
|
||||
|
||||
characterCount++;
|
||||
totalCount++;
|
||||
|
||||
//Send this chunk of character list
|
||||
if (characterCount >= MAXPERPACKET)
|
||||
{
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
characterCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//If there is anything left that was missed or the list is empty
|
||||
if (characterCount > 0 || numCharacters == 0)
|
||||
{
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
}
|
||||
|
||||
return subPackets;
|
||||
}
|
||||
}
|
||||
}
|
67
Lobby Server/Packets/Send/ErrorPacket.cs
Normal file
67
Lobby Server/Packets/Send/ErrorPacket.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Meteor.Common;
|
||||
|
||||
namespace Meteor.Lobby.Packets
|
||||
{
|
||||
class ErrorPacket
|
||||
{
|
||||
private const ushort OPCODE = 0x02;
|
||||
|
||||
private UInt64 sequence;
|
||||
private uint errorCode;
|
||||
private uint statusCode;
|
||||
private uint textId;
|
||||
private string message;
|
||||
|
||||
public ErrorPacket(UInt64 sequence, uint errorCode, uint statusCode, uint textId, string message)
|
||||
{
|
||||
this.sequence = sequence;
|
||||
this.errorCode = errorCode;
|
||||
this.statusCode = statusCode;
|
||||
this.textId = textId;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public SubPacket BuildPacket()
|
||||
{
|
||||
MemoryStream memStream = new MemoryStream(0x210);
|
||||
BinaryWriter binWriter = new BinaryWriter(memStream);
|
||||
|
||||
binWriter.Write(sequence);
|
||||
binWriter.Write(errorCode);
|
||||
binWriter.Write(statusCode);
|
||||
binWriter.Write(textId);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(message));
|
||||
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
return subpacket;
|
||||
}
|
||||
}
|
||||
}
|
124
Lobby Server/Packets/Send/ImportListPacket.cs
Normal file
124
Lobby Server/Packets/Send/ImportListPacket.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Meteor.Common;
|
||||
|
||||
namespace Meteor.Lobby.Packets
|
||||
{
|
||||
class ImportListPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x16;
|
||||
public const ushort MAXPERPACKET = 12;
|
||||
|
||||
private UInt64 sequence;
|
||||
private List<String> namesList;
|
||||
|
||||
public ImportListPacket(UInt64 sequence, List<String> names)
|
||||
{
|
||||
this.sequence = sequence;
|
||||
this.namesList = names;
|
||||
}
|
||||
|
||||
public List<SubPacket> BuildPackets()
|
||||
{
|
||||
List<SubPacket> subPackets = new List<SubPacket>();
|
||||
|
||||
int namesCount = 0;
|
||||
int totalCount = 0;
|
||||
|
||||
MemoryStream memStream = null;
|
||||
BinaryWriter binWriter = null;
|
||||
|
||||
foreach (String name in namesList)
|
||||
{
|
||||
if (totalCount == 0 || namesCount % MAXPERPACKET == 0)
|
||||
{
|
||||
memStream = new MemoryStream(0x210);
|
||||
binWriter = new BinaryWriter(memStream);
|
||||
|
||||
//Write List Info
|
||||
binWriter.Write((UInt64)sequence);
|
||||
byte listTracker = (byte)((MAXPERPACKET * 2) * subPackets.Count);
|
||||
binWriter.Write(namesList.Count - totalCount <= MAXPERPACKET ? (byte)(listTracker + 1) : (byte)(listTracker));
|
||||
binWriter.Write(namesList.Count - totalCount <= MAXPERPACKET ? (UInt32)(namesList.Count - totalCount) : (UInt32)MAXPERPACKET);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write((UInt16)0);
|
||||
}
|
||||
|
||||
//Write Entries
|
||||
binWriter.Write((uint)0);
|
||||
binWriter.Write((uint)totalCount);
|
||||
|
||||
if (!name.Contains(" "))
|
||||
binWriter.Write(Encoding.ASCII.GetBytes((name+" Last").PadRight(0x20, '\0')));
|
||||
else
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(name.PadRight(0x20, '\0')));
|
||||
|
||||
namesCount++;
|
||||
totalCount++;
|
||||
|
||||
//Send this chunk of world list
|
||||
if (namesCount >= MAXPERPACKET)
|
||||
{
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
namesCount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//If there is anything left that was missed or the list is empty
|
||||
if (namesCount > 0 || namesList.Count == 0)
|
||||
{
|
||||
if (namesList.Count == 0)
|
||||
{
|
||||
memStream = new MemoryStream(0x210);
|
||||
binWriter = new BinaryWriter(memStream);
|
||||
|
||||
//Write Empty List Info
|
||||
binWriter.Write((UInt64)sequence);
|
||||
byte listTracker = (byte)((MAXPERPACKET * 2) * subPackets.Count);
|
||||
binWriter.Write(namesList.Count - totalCount <= MAXPERPACKET ? (byte)(listTracker + 1) : (byte)(listTracker));
|
||||
binWriter.Write((UInt32)0);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write((UInt16)0);
|
||||
}
|
||||
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
}
|
||||
|
||||
return subPackets;
|
||||
}
|
||||
}
|
||||
}
|
126
Lobby Server/Packets/Send/RetainerListPacket.cs
Normal file
126
Lobby Server/Packets/Send/RetainerListPacket.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Meteor.Common;
|
||||
using Meteor.Lobby.DataObjects;
|
||||
|
||||
namespace Meteor.Lobby.Packets
|
||||
{
|
||||
class RetainerListPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x17;
|
||||
public const ushort MAXPERPACKET = 9;
|
||||
|
||||
private UInt64 sequence;
|
||||
private List<Retainer> retainerList;
|
||||
|
||||
public RetainerListPacket(UInt64 sequence, List<Retainer> retainerList)
|
||||
{
|
||||
this.sequence = sequence;
|
||||
this.retainerList = retainerList;
|
||||
}
|
||||
|
||||
public List<SubPacket> BuildPackets()
|
||||
{
|
||||
List<SubPacket> subPackets = new List<SubPacket>();
|
||||
|
||||
int retainerCount = 0;
|
||||
int totalCount = 0;
|
||||
|
||||
MemoryStream memStream = null;
|
||||
BinaryWriter binWriter = null;
|
||||
|
||||
foreach (Retainer retainer in retainerList)
|
||||
{
|
||||
if (totalCount == 0 || retainerCount % MAXPERPACKET == 0)
|
||||
{
|
||||
memStream = new MemoryStream(0x210);
|
||||
binWriter = new BinaryWriter(memStream);
|
||||
|
||||
//Write List Info
|
||||
binWriter.Write((UInt64)sequence);
|
||||
byte listTracker = (byte)((MAXPERPACKET * 2) * subPackets.Count);
|
||||
binWriter.Write(retainerList.Count - totalCount <= MAXPERPACKET ? (byte)(listTracker + 1) : (byte)(listTracker));
|
||||
binWriter.Write(retainerList.Count - totalCount <= MAXPERPACKET ? (UInt32)(retainerList.Count - totalCount) : (UInt32)MAXPERPACKET);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write((UInt16)0);
|
||||
binWriter.Write((UInt64)0);
|
||||
binWriter.Write((UInt32)0);
|
||||
}
|
||||
|
||||
//Write Entries
|
||||
binWriter.Write((uint)retainer.id);
|
||||
binWriter.Write((uint)retainer.characterId);
|
||||
binWriter.Write((ushort)totalCount);
|
||||
binWriter.Write((ushort)(retainer.doRename ? 0x04 : 0x00));
|
||||
binWriter.Write((uint)0);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(retainer.name.PadRight(0x20, '\0')));
|
||||
|
||||
retainerCount++;
|
||||
totalCount++;
|
||||
|
||||
//Send this chunk of character list
|
||||
if (retainerCount >= MAXPERPACKET)
|
||||
{
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
retainerCount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//If there is anything left that was missed or the list is empty
|
||||
if (retainerCount > 0 || retainerList.Count == 0)
|
||||
{
|
||||
if (retainerList.Count == 0)
|
||||
{
|
||||
memStream = new MemoryStream(0x210);
|
||||
binWriter = new BinaryWriter(memStream);
|
||||
|
||||
//Write Empty List Info
|
||||
binWriter.Write((UInt64)sequence);
|
||||
byte listTracker = (byte)((MAXPERPACKET * 2) * subPackets.Count);
|
||||
binWriter.Write(retainerList.Count - totalCount <= MAXPERPACKET ? (byte)(listTracker + 1) : (byte)(listTracker));
|
||||
binWriter.Write((UInt32)0);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write((UInt16)0);
|
||||
}
|
||||
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
}
|
||||
|
||||
return subPackets;
|
||||
}
|
||||
}
|
||||
}
|
80
Lobby Server/Packets/Send/SelectCharacterConfirmPacket.cs
Normal file
80
Lobby Server/Packets/Send/SelectCharacterConfirmPacket.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Meteor.Common;
|
||||
|
||||
namespace Meteor.Lobby.Packets
|
||||
{
|
||||
class SelectCharacterConfirmPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x0F;
|
||||
|
||||
private UInt64 sequence;
|
||||
private UInt32 characterId;
|
||||
private string sessionToken;
|
||||
private string worldIp;
|
||||
private UInt16 worldPort;
|
||||
private UInt64 selectCharTicket;
|
||||
|
||||
public SelectCharacterConfirmPacket(UInt64 sequence, UInt32 characterId, string sessionToken, string worldIp, ushort worldPort, UInt64 selectCharTicket)
|
||||
{
|
||||
this.sequence = sequence;
|
||||
this.characterId = characterId;
|
||||
this.sessionToken = sessionToken;
|
||||
this.worldIp = worldIp;
|
||||
this.worldPort = worldPort;
|
||||
this.selectCharTicket = selectCharTicket;
|
||||
}
|
||||
|
||||
public List<SubPacket> BuildPackets()
|
||||
{
|
||||
List<SubPacket> subPackets = new List<SubPacket>();
|
||||
|
||||
byte[] data;
|
||||
|
||||
using (MemoryStream memStream = new MemoryStream(0x98))
|
||||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(memStream))
|
||||
{
|
||||
binWriter.Write((UInt64)sequence);
|
||||
binWriter.Write((UInt32)characterId); //ActorId
|
||||
binWriter.Write((UInt32)characterId); //CharacterId
|
||||
binWriter.Write((UInt32)0);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(sessionToken.PadRight(0x42, '\0'))); //Session Token
|
||||
binWriter.Write((UInt16)worldPort); //World Port
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(worldIp.PadRight(0x38, '\0'))); //World Hostname/IP
|
||||
binWriter.Write((UInt64)selectCharTicket); //Ticket or Handshake of somekind
|
||||
}
|
||||
data = memStream.GetBuffer();
|
||||
}
|
||||
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
|
||||
return subPackets;
|
||||
}
|
||||
}
|
||||
}
|
123
Lobby Server/Packets/Send/WorldListPacket.cs
Normal file
123
Lobby Server/Packets/Send/WorldListPacket.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015-2019 Project Meteor Dev Team
|
||||
|
||||
This file is part of Project Meteor Server.
|
||||
|
||||
Project Meteor Server is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Project Meteor Server is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Meteor.Common;
|
||||
using Meteor.Lobby.DataObjects;
|
||||
|
||||
namespace Meteor.Lobby.Packets
|
||||
{
|
||||
class WorldListPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x15;
|
||||
public const ushort MAXPERPACKET = 6;
|
||||
|
||||
private UInt64 sequence;
|
||||
private List<World> worldList;
|
||||
|
||||
public WorldListPacket(UInt64 sequence, List<World> serverList)
|
||||
{
|
||||
this.sequence = sequence;
|
||||
this.worldList = serverList;
|
||||
}
|
||||
|
||||
public List<SubPacket> BuildPackets()
|
||||
{
|
||||
List<SubPacket> subPackets = new List<SubPacket>();
|
||||
|
||||
int serverCount = 0;
|
||||
int totalCount = 0;
|
||||
|
||||
MemoryStream memStream = null;
|
||||
BinaryWriter binWriter = null;
|
||||
|
||||
foreach (World world in worldList)
|
||||
{
|
||||
if (totalCount == 0 || serverCount % MAXPERPACKET == 0)
|
||||
{
|
||||
memStream = new MemoryStream(0x210);
|
||||
binWriter = new BinaryWriter(memStream);
|
||||
|
||||
//Write List Info
|
||||
binWriter.Write((UInt64)sequence);
|
||||
byte listTracker = (byte)((MAXPERPACKET * 2) * subPackets.Count);
|
||||
binWriter.Write(worldList.Count - totalCount <= MAXPERPACKET ? (byte)(listTracker + 1) : (byte)(listTracker));
|
||||
binWriter.Write(worldList.Count - totalCount <= MAXPERPACKET ? (UInt32)(worldList.Count - totalCount) : (UInt32)MAXPERPACKET);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write((UInt16)0);
|
||||
}
|
||||
|
||||
//Write Entries
|
||||
binWriter.Write((ushort)world.id);
|
||||
binWriter.Write((ushort)world.listPosition);
|
||||
binWriter.Write((uint)world.population);
|
||||
binWriter.Write((UInt64)0);
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(world.name.PadRight(64, '\0')));
|
||||
|
||||
serverCount++;
|
||||
totalCount++;
|
||||
|
||||
//Send this chunk of world list
|
||||
if (serverCount >= MAXPERPACKET)
|
||||
{
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
serverCount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//If there is anything left that was missed or the list is empty
|
||||
if (serverCount > 0 || worldList.Count == 0)
|
||||
{
|
||||
if (worldList.Count == 0)
|
||||
{
|
||||
memStream = new MemoryStream(0x210);
|
||||
binWriter = new BinaryWriter(memStream);
|
||||
|
||||
//Write Empty List Info
|
||||
binWriter.Write((UInt64)sequence);
|
||||
byte listTracker = (byte)((MAXPERPACKET * 2) * subPackets.Count);
|
||||
binWriter.Write(worldList.Count - totalCount <= MAXPERPACKET ? (byte)(listTracker + 1) : (byte)(listTracker));
|
||||
binWriter.Write((UInt32)0);
|
||||
binWriter.Write((byte)0);
|
||||
binWriter.Write((UInt16)0);
|
||||
}
|
||||
|
||||
byte[] data = memStream.GetBuffer();
|
||||
binWriter.Dispose();
|
||||
memStream.Dispose();
|
||||
SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, data);
|
||||
subpacket.SetTargetId(0xe0006868);
|
||||
subPackets.Add(subpacket);
|
||||
}
|
||||
|
||||
return subPackets;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user