mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-23 13:17:45 +00:00
Implemented more packets. Implemented zone grid map.
This commit is contained in:
parent
8f7e7d4c0d
commit
b0ab527550
7 changed files with 174 additions and 1 deletions
|
@ -24,6 +24,7 @@ namespace FFXIVClassic_Lobby_Server
|
|||
private List<ClientConnection> mConnectionList = new List<ClientConnection>();
|
||||
private PacketProcessor mProcessor;
|
||||
private Thread mProcessorThread;
|
||||
private Thread mGameThread;
|
||||
|
||||
#region Socket Handling
|
||||
public bool startServer()
|
||||
|
@ -63,6 +64,8 @@ namespace FFXIVClassic_Lobby_Server
|
|||
mProcessor = new PacketProcessor(mConnectedPlayerList, mConnectionList);
|
||||
mProcessorThread = new Thread(new ThreadStart(mProcessor.update));
|
||||
mProcessorThread.Start();
|
||||
//mGameThread = new Thread(new ThreadStart(mProcessor.update));
|
||||
//mGameThread.Start();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
72
FFXIVClassic Map Server/Zone.cs
Normal file
72
FFXIVClassic Map Server/Zone.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
using FFXIVClassic_Map_Server.dataobjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server
|
||||
{
|
||||
class Zone
|
||||
{
|
||||
public uint mapId;
|
||||
public int boundingGridSize = 200;
|
||||
|
||||
private Dictionary<Tuple<int, int>, List<Actor>> actorBlock = new Dictionary<Tuple<int, int>, List<Actor>>();
|
||||
|
||||
public void addActorToZone(Actor actor)
|
||||
{
|
||||
int gridX = (int)actor.positionX / boundingGridSize;
|
||||
int gridY = (int)actor.positionY / boundingGridSize;
|
||||
|
||||
lock (actorBlock)
|
||||
actorBlock[Tuple.Create(gridX, gridY)].Add(actor);
|
||||
}
|
||||
|
||||
public void removeActorToZone(Actor actor)
|
||||
{
|
||||
int gridX = (int)actor.positionX / boundingGridSize;
|
||||
int gridY = (int)actor.positionY / boundingGridSize;
|
||||
|
||||
lock (actorBlock)
|
||||
actorBlock[Tuple.Create(gridX, gridY)].Remove(actor);
|
||||
}
|
||||
|
||||
public void updateActorPosition(Actor actor)
|
||||
{
|
||||
int gridX = (int)actor.positionX / boundingGridSize;
|
||||
int gridY = (int)actor.positionY / boundingGridSize;
|
||||
|
||||
int gridOldX = (int)actor.oldPositionX / boundingGridSize;
|
||||
int gridOldY = (int)actor.oldPositionY / boundingGridSize;
|
||||
|
||||
//Still in same block
|
||||
if (gridX == gridOldX && gridY == gridOldY)
|
||||
return;
|
||||
|
||||
lock (actorBlock)
|
||||
actorBlock[Tuple.Create(gridOldX, gridOldY)].Remove(actor);
|
||||
lock (actorBlock)
|
||||
actorBlock[Tuple.Create(gridX, gridY)].Add(actor);
|
||||
}
|
||||
|
||||
public List<Actor> getActorsAroundPoint(float x, float y, int checkDistance)
|
||||
{
|
||||
int gridX = (int)x/boundingGridSize;
|
||||
int gridY = (int)y/boundingGridSize;
|
||||
|
||||
List<Actor> result = new List<Actor>();
|
||||
|
||||
for (int gx = gridX - checkDistance; gx <= gridX + checkDistance; gx++)
|
||||
{
|
||||
for (int gy = gridY - checkDistance; gy <= gridY + checkDistance; gy++)
|
||||
{
|
||||
result.AddRange(actorBlock[Tuple.Create(gx, gy)]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
|
@ -40,6 +40,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||
public uint[] appearanceIDs;
|
||||
|
||||
public float positionX, positionY, positionZ;
|
||||
public float oldPositionX, oldPositionY, oldPositionZ;
|
||||
public float rotation;
|
||||
public ushort moveState;
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
using FFXIVClassic_Lobby_Server.packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.send.Actor
|
||||
{
|
||||
class SetActorNamePacket
|
||||
{
|
||||
public const ushort OPCODE = 0x013D;
|
||||
public const uint PACKET_SIZE = 0x48;
|
||||
|
||||
public static SubPacket buildPacket(uint playerActorID, uint targetActorID, uint displayNameID, string customName)
|
||||
{
|
||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
binWriter.Write((UInt32)displayNameID);
|
||||
|
||||
if (displayNameID == 0xFFFFFFFF)
|
||||
{
|
||||
if (customName.Length <= 0x20)
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(customName));
|
||||
else
|
||||
binWriter.Write(Encoding.ASCII.GetBytes("ERROR: NAME TO BIG"));
|
||||
}
|
||||
|
||||
}
|
||||
data = mem.GetBuffer();
|
||||
}
|
||||
|
||||
SubPacket packet = new SubPacket(OPCODE, playerActorID, targetActorID, data);
|
||||
return packet;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
using FFXIVClassic_Lobby_Server.packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.send.Actor.inventory
|
||||
{
|
||||
class ChangeEquipmentPacket
|
||||
{
|
||||
public const ushort OPCODE = 0x014D;
|
||||
public const uint PACKET_SIZE = 0x28;
|
||||
|
||||
public const UInt16 SLOT_MAINHAND = 0x00;
|
||||
public const UInt16 SLOT_OFFHAND = 0x01;
|
||||
public const UInt16 SLOT_THROWINGWEAPON = 0x04;
|
||||
public const UInt16 SLOT_PACK = 0x05;
|
||||
public const UInt16 SLOT_POUCH = 0x06;
|
||||
public const UInt16 SLOT_HEAD = 0x08;
|
||||
public const UInt16 SLOT_UNDERSHIRT = 0x09;
|
||||
public const UInt16 SLOT_BODY = 0x0A;
|
||||
public const UInt16 SLOT_UNDERGARMENT = 0x0B;
|
||||
public const UInt16 SLOT_LEGS = 0x0C;
|
||||
public const UInt16 SLOT_HANDS = 0x0D;
|
||||
public const UInt16 SLOT_BOOTS = 0x0E;
|
||||
public const UInt16 SLOT_WAIST = 0x0F;
|
||||
public const UInt16 SLOT_NECK = 0x10;
|
||||
public const UInt16 SLOT_EARS = 0x11;
|
||||
public const UInt16 SLOT_WRISTS = 0x13;
|
||||
public const UInt16 SLOT_RIGHTFINGER = 0x15;
|
||||
public const UInt16 SLOT_LEFTFINGER = 0x16;
|
||||
|
||||
|
||||
public static SubPacket buildPacket(uint playerActorID, ushort equipSlot, uint inventorySlot)
|
||||
{
|
||||
ulong combined = equipSlot | (inventorySlot << 32);
|
||||
return new SubPacket(OPCODE, 0, playerActorID, BitConverter.GetBytes(combined));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -15,7 +15,8 @@ namespace FFXIVClassic_Map_Server.packets.send.Actor.inventory
|
|||
|
||||
public const ushort CODE_ITEMS = 0x0000;
|
||||
public const ushort CODE_CURRANCYITEMS = 0x0063;
|
||||
public const ushort CODE_KEYITEMS = 0x0064;
|
||||
public const ushort CODE_KEYITEMS = 0x0064;
|
||||
public const ushort CODE_EQUIPMENT = 0x00FE;
|
||||
|
||||
public static SubPacket buildPacket(uint playerActorID, ushort size, ushort code)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue