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

Added temp character and retainer packets. Added constants for easy modding.

This commit is contained in:
Filip Maj 2015-09-07 12:12:08 -04:00
parent 6c869353cc
commit c78414f9be
7 changed files with 243 additions and 9 deletions

View file

@ -52,6 +52,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="dataobjects\Retainer.cs" />
<Compile Include="dataobjects\Character.cs" /> <Compile Include="dataobjects\Character.cs" />
<Compile Include="ClientConnection.cs" /> <Compile Include="ClientConnection.cs" />
<Compile Include="common\Blowfish.cs" /> <Compile Include="common\Blowfish.cs" />
@ -62,10 +63,12 @@
<Compile Include="dataobjects\World.cs" /> <Compile Include="dataobjects\World.cs" />
<Compile Include="PacketProcessor.cs" /> <Compile Include="PacketProcessor.cs" />
<Compile Include="packets\BasePacket.cs" /> <Compile Include="packets\BasePacket.cs" />
<Compile Include="packets\RetainerListPacket.cs" />
<Compile Include="packets\ErrorPacket.cs" /> <Compile Include="packets\ErrorPacket.cs" />
<Compile Include="packets\HardCoded_Packets.cs" /> <Compile Include="packets\HardCoded_Packets.cs" />
<Compile Include="packets\PacketStructs.cs" /> <Compile Include="packets\PacketStructs.cs" />
<Compile Include="packets\SubPacket.cs" /> <Compile Include="packets\SubPacket.cs" />
<Compile Include="packets\CharacterListPacket.cs" />
<Compile Include="packets\WorldListPacket.cs" /> <Compile Include="packets\WorldListPacket.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View file

@ -148,6 +148,7 @@ namespace FFXIVClassic_Lobby_Server
Console.WriteLine("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId); Console.WriteLine("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId);
sendWorldList(client, packet); sendWorldList(client, packet);
sendCharacterList(client, packet);
BasePacket outgoingPacket = new BasePacket("./packets/getCharsPacket.bin"); BasePacket outgoingPacket = new BasePacket("./packets/getCharsPacket.bin");
BasePacket.encryptPacket(client.blowfish, outgoingPacket); BasePacket.encryptPacket(client.blowfish, outgoingPacket);
@ -270,7 +271,18 @@ namespace FFXIVClassic_Lobby_Server
private void sendCharacterList(ClientConnection client, SubPacket packet) private void sendCharacterList(ClientConnection client, SubPacket packet)
{ {
//List<Character> serverList = Database.getServers();
List<Character> charaList = new List<Character>();
charaList.Add(new Character());
charaList.Add(new Character());
CharacterListPacket characterlistPacket = new CharacterListPacket(1, charaList);
List<SubPacket> subPackets = characterlistPacket.buildPackets();
BasePacket basePacket = BasePacket.createPacket(subPackets, true, false);
BasePacket.encryptPacket(client.blowfish, basePacket);
client.queuePacket(basePacket);
} }
} }

View file

@ -9,7 +9,8 @@ namespace FFXIVClassic_Lobby_Server
{ {
class Character class Character
{ {
public string name = ""; public string name = "Test Test";
public string world = "Test World";
public uint id = 0; public uint id = 0;

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FFXIVClassic_Lobby_Server.common;
namespace FFXIVClassic_Lobby_Server
{
class Retainer
{
public string name = "";
}
}

View file

@ -0,0 +1,103 @@
using FFXIVClassic_Lobby_Server.dataobjects;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Lobby_Server.packets
{
class CharacterListPacket
{
public const ushort OPCODE = 0x0D;
public const ushort MAXPERPACKET = 3;
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 characterCount = 0;
int totalCount = 0;
MemoryStream memStream = null;
BinaryWriter binWriter = null;
foreach (Character chara in characterList)
{
if (totalCount == 0 || characterCount % MAXPERPACKET == 0)
{
memStream = new MemoryStream(0x3D0);
binWriter = new BinaryWriter(memStream);
//Write List Info
binWriter.Write((UInt64)sequence);
binWriter.Write(characterList.Count - totalCount <= MAXPERPACKET ? (byte)(characterList.Count + 1) : (byte)0);
binWriter.Write(characterList.Count - totalCount <= MAXPERPACKET ? (UInt32)(characterList.Count - totalCount) : (UInt32)MAXPERPACKET);
binWriter.Write((byte)6);
binWriter.Write((UInt16)5);
}
binWriter.Seek(0x10 + (0x1D0 * characterCount), SeekOrigin.Begin);
//Write Entries
binWriter.Write((uint)0);
binWriter.Write((uint)totalCount);
binWriter.Write((uint)0);
binWriter.Write((uint)0);
binWriter.Write(Encoding.ASCII.GetBytes(chara.name.PadRight(0x20, '\0')));
binWriter.Write(Encoding.ASCII.GetBytes(chara.world.PadRight(0x10, '\0')));
binWriter.Write("wAQAAOonIyMNAAAAV3Jlbml4IFdyb25nABwAAAAEAAAAAwAAAAMAAAA_8OADAAHQFAAEAAABAAAAABTQCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGEgAAAAMQAAQCQAAMAsAACKVAAAAPgCAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAkAwAAAAAAAAAAANvb1M05AQAABBoAAAEABqoiIuIKAAAAcHJ2MElubjAxABEAAABkZWZhdWx0VGVycml0b3J5AAwJAhcABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAA=");
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, 0xe0006868, data);
subPackets.Add(subpacket);
characterCount = 0;
}
}
//If there is anything left that was missed or the list is empty
if (characterCount > 0 || characterList.Count == 0)
{
if (characterList.Count == 0)
{
memStream = new MemoryStream(0x3D0);
binWriter = new BinaryWriter(memStream);
//Write Empty List Info
binWriter.Write((UInt64)0);
binWriter.Write((byte)1);
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, 0xe0006868, data);
subPackets.Add(subpacket);
}
return subPackets;
}
}
}

View file

@ -0,0 +1,97 @@
using FFXIVClassic_Lobby_Server.dataobjects;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Lobby_Server.packets
{
class RetainerListPacket
{
public const ushort OPCODE = 0x17;
public const ushort MAXPERPACKET = 3;
private List<Retainer> retainerList;
public RetainerListPacket(List<Retainer> retainerList)
{
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 chara in retainerList)
{
if (totalCount == 0 || retainerCount % MAXPERPACKET == 0)
{
memStream = new MemoryStream(0x210);
binWriter = new BinaryWriter(memStream);
//Write List Info
binWriter.Write((UInt64)0);
binWriter.Write(retainerList.Count - totalCount <= MAXPERPACKET ? (byte)(retainerList.Count + 1) : (byte)0);
binWriter.Write(retainerList.Count - totalCount <= MAXPERPACKET ? (UInt32)(retainerList.Count - totalCount) : (UInt32)MAXPERPACKET);
binWriter.Write((byte)6);
binWriter.Write((UInt16)5);
}
//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')));
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, 0xe0006868, data);
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)0);
binWriter.Write((byte)1);
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, 0xe0006868, data);
subPackets.Add(subpacket);
}
return subPackets;
}
}
}

View file

@ -10,6 +10,9 @@ namespace FFXIVClassic_Lobby_Server.packets
{ {
class WorldListPacket class WorldListPacket
{ {
public const ushort OPCODE = 0x15;
public const ushort MAXPERPACKET = 6;
private List<World> worldList; private List<World> worldList;
public WorldListPacket(List<World> serverList) public WorldListPacket(List<World> serverList)
@ -29,17 +32,17 @@ namespace FFXIVClassic_Lobby_Server.packets
foreach (World world in worldList) foreach (World world in worldList)
{ {
if (totalCount == 0 || serverCount % 6 == 0) if (totalCount == 0 || serverCount % MAXPERPACKET == 0)
{ {
memStream = new MemoryStream(0x210); memStream = new MemoryStream(0x210);
binWriter = new BinaryWriter(memStream); binWriter = new BinaryWriter(memStream);
//Write List Info //Write List Info
binWriter.Write((UInt64)0); binWriter.Write((UInt64)0);
binWriter.Write(worldList.Count - totalCount <= 6 ? (byte)(worldList.Count + 1) : (byte)0); binWriter.Write(worldList.Count - totalCount <= MAXPERPACKET ? (byte)(worldList.Count + 1) : (byte)0);
binWriter.Write(worldList.Count - totalCount <= 6 ? (UInt32)(worldList.Count - totalCount) : (UInt32)6); binWriter.Write(worldList.Count - totalCount <= MAXPERPACKET ? (UInt32)(worldList.Count - totalCount) : (UInt32)MAXPERPACKET);
binWriter.Write((byte)6); binWriter.Write((byte)0);
binWriter.Write((UInt16)5); binWriter.Write((UInt16)0);
} }
//Write Entries //Write Entries
@ -53,12 +56,12 @@ namespace FFXIVClassic_Lobby_Server.packets
totalCount++; totalCount++;
//Send this chunk of world list //Send this chunk of world list
if (serverCount >= 6) if (serverCount >= MAXPERPACKET)
{ {
byte[] data = memStream.GetBuffer(); byte[] data = memStream.GetBuffer();
binWriter.Dispose(); binWriter.Dispose();
memStream.Dispose(); memStream.Dispose();
SubPacket subpacket = new SubPacket(0x15, 0xe0006868, 0xe0006868, data); SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, 0xe0006868, data);
subPackets.Add(subpacket); subPackets.Add(subpacket);
serverCount = 0; serverCount = 0;
} }
@ -84,7 +87,7 @@ namespace FFXIVClassic_Lobby_Server.packets
byte[] data = memStream.GetBuffer(); byte[] data = memStream.GetBuffer();
binWriter.Dispose(); binWriter.Dispose();
memStream.Dispose(); memStream.Dispose();
SubPacket subpacket = new SubPacket(0x15, 0xe0006868, 0xe0006868, data); SubPacket subpacket = new SubPacket(OPCODE, 0xe0006868, 0xe0006868, data);
subPackets.Add(subpacket); subPackets.Add(subpacket);
} }