mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-02 19:42:05 -04:00
Fixed packet creators in Actor. Added replace id overload. Fixed Zone class, should work correctly.
This commit is contained in:
parent
b17a86ba2c
commit
7116c96b2f
@ -1,4 +1,5 @@
|
|||||||
using FFXIVClassic_Map_Server.dataobjects;
|
using FFXIVClassic_Lobby_Server.common;
|
||||||
|
using FFXIVClassic_Map_Server.dataobjects;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -12,8 +13,8 @@ namespace FFXIVClassic_Map_Server
|
|||||||
public uint mapId;
|
public uint mapId;
|
||||||
public ushort weatherNormal, weatherCommon, weatherRare;
|
public ushort weatherNormal, weatherCommon, weatherRare;
|
||||||
public ushort bgmDay, bgmNight, bgmBattle;
|
public ushort bgmDay, bgmNight, bgmBattle;
|
||||||
public int boundingGridSize = 200;
|
public int boundingGridSize = 50;
|
||||||
public int minX = -1000, minY = -1000, maxX = 1000, maxY = 1000;
|
public int minX = -100, minY = -100, maxX = 100, maxY = 100;
|
||||||
private int numXBlocks, numYBlocks;
|
private int numXBlocks, numYBlocks;
|
||||||
private int halfWidth, halfHeight;
|
private int halfWidth, halfHeight;
|
||||||
private List<Actor>[,] actorBlock;
|
private List<Actor>[,] actorBlock;
|
||||||
@ -25,6 +26,15 @@ namespace FFXIVClassic_Map_Server
|
|||||||
actorBlock = new List<Actor>[numXBlocks, numYBlocks];
|
actorBlock = new List<Actor>[numXBlocks, numYBlocks];
|
||||||
halfWidth = numXBlocks / 2;
|
halfWidth = numXBlocks / 2;
|
||||||
halfHeight = numYBlocks / 2;
|
halfHeight = numYBlocks / 2;
|
||||||
|
|
||||||
|
for (int y = 0; y < numYBlocks; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < numXBlocks; x++ )
|
||||||
|
{
|
||||||
|
actorBlock[x, y] = new List<Actor>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Actor Management
|
#region Actor Management
|
||||||
@ -32,7 +42,7 @@ namespace FFXIVClassic_Map_Server
|
|||||||
public void addActorToZone(Actor actor)
|
public void addActorToZone(Actor actor)
|
||||||
{
|
{
|
||||||
int gridX = (int)actor.positionX / boundingGridSize;
|
int gridX = (int)actor.positionX / boundingGridSize;
|
||||||
int gridY = (int)actor.positionY / boundingGridSize;
|
int gridY = (int)actor.positionZ / boundingGridSize;
|
||||||
|
|
||||||
gridX += halfWidth;
|
gridX += halfWidth;
|
||||||
gridY += halfHeight;
|
gridY += halfHeight;
|
||||||
@ -54,7 +64,7 @@ namespace FFXIVClassic_Map_Server
|
|||||||
public void removeActorToZone(Actor actor)
|
public void removeActorToZone(Actor actor)
|
||||||
{
|
{
|
||||||
int gridX = (int)actor.positionX / boundingGridSize;
|
int gridX = (int)actor.positionX / boundingGridSize;
|
||||||
int gridY = (int)actor.positionY / boundingGridSize;
|
int gridY = (int)actor.positionZ / boundingGridSize;
|
||||||
|
|
||||||
gridX += halfWidth;
|
gridX += halfWidth;
|
||||||
gridY += halfHeight;
|
gridY += halfHeight;
|
||||||
@ -76,7 +86,7 @@ namespace FFXIVClassic_Map_Server
|
|||||||
public void updateActorPosition(Actor actor)
|
public void updateActorPosition(Actor actor)
|
||||||
{
|
{
|
||||||
int gridX = (int)actor.positionX / boundingGridSize;
|
int gridX = (int)actor.positionX / boundingGridSize;
|
||||||
int gridY = (int)actor.positionY / boundingGridSize;
|
int gridY = (int)actor.positionZ / boundingGridSize;
|
||||||
|
|
||||||
gridX += halfWidth;
|
gridX += halfWidth;
|
||||||
gridY += halfHeight;
|
gridY += halfHeight;
|
||||||
@ -92,7 +102,7 @@ namespace FFXIVClassic_Map_Server
|
|||||||
gridY = numYBlocks - 1;
|
gridY = numYBlocks - 1;
|
||||||
|
|
||||||
int gridOldX = (int)actor.oldPositionX / boundingGridSize;
|
int gridOldX = (int)actor.oldPositionX / boundingGridSize;
|
||||||
int gridOldY = (int)actor.oldPositionY / boundingGridSize;
|
int gridOldY = (int)actor.oldPositionZ / boundingGridSize;
|
||||||
|
|
||||||
gridOldX += halfWidth;
|
gridOldX += halfWidth;
|
||||||
gridOldY += halfHeight;
|
gridOldY += halfHeight;
|
||||||
@ -151,26 +161,18 @@ namespace FFXIVClassic_Map_Server
|
|||||||
public List<Actor> getActorsAroundActor(Actor actor, int checkDistance)
|
public List<Actor> getActorsAroundActor(Actor actor, int checkDistance)
|
||||||
{
|
{
|
||||||
int gridX = (int)actor.positionX / boundingGridSize;
|
int gridX = (int)actor.positionX / boundingGridSize;
|
||||||
int gridY = (int)actor.positionY / boundingGridSize;
|
int gridY = (int)actor.positionZ / boundingGridSize;
|
||||||
|
|
||||||
gridX += halfWidth;
|
gridX += halfWidth;
|
||||||
gridY += halfHeight;
|
gridY += halfHeight;
|
||||||
|
|
||||||
//Boundries
|
|
||||||
if (gridX < 0)
|
|
||||||
gridX = 0;
|
|
||||||
if (gridX >= numXBlocks)
|
|
||||||
gridX = numXBlocks - 1;
|
|
||||||
if (gridY < 0)
|
|
||||||
gridY = 0;
|
|
||||||
if (gridY >= numYBlocks)
|
|
||||||
gridY = numYBlocks - 1;
|
|
||||||
|
|
||||||
List<Actor> result = new List<Actor>();
|
List<Actor> result = new List<Actor>();
|
||||||
|
|
||||||
for (int gx = gridX - checkDistance; gx <= gridX + checkDistance; gx++)
|
for (int gy = ((gridY - checkDistance) < 0 ? 0 : (gridY - checkDistance)); gy <= ((gridY + checkDistance) >= numYBlocks ? numYBlocks - 1 : (gridY + checkDistance)); gy++)
|
||||||
{
|
{
|
||||||
for (int gy = gridY - checkDistance; gy <= gridY + checkDistance; gy++)
|
for (int gx = ((gridX - checkDistance) < 0 ? 0 : (gridX - checkDistance)); gx <= ((gridX + checkDistance) >= numXBlocks ? numXBlocks - 1 : (gridX + checkDistance)); gx++)
|
||||||
{
|
{
|
||||||
result.AddRange(actorBlock[gx, gy]);
|
result.AddRange(actorBlock[gx, gy]);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using FFXIVClassic_Map_Server.packets.send.actor;
|
|||||||
using FFXIVClassic_Map_Server.packets.send.Actor;
|
using FFXIVClassic_Map_Server.packets.send.Actor;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@ -108,33 +109,33 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||||||
|
|
||||||
public SubPacket createNamePacket(uint playerActorID)
|
public SubPacket createNamePacket(uint playerActorID)
|
||||||
{
|
{
|
||||||
return SetActorNamePacket.buildPacket(playerActorID, actorID, displayNameID, displayNameID == 0xFFFFFFFF ? customDisplayName : "");
|
return SetActorNamePacket.buildPacket(actorID, playerActorID, displayNameID, displayNameID == 0xFFFFFFFF ? customDisplayName : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubPacket createAppearancePacket(uint playerActorID)
|
public SubPacket createAppearancePacket(uint playerActorID)
|
||||||
{
|
{
|
||||||
SetActorAppearancePacket setappearance = new SetActorAppearancePacket(modelID, appearanceIDs);
|
SetActorAppearancePacket setappearance = new SetActorAppearancePacket(modelID, appearanceIDs);
|
||||||
return setappearance.buildPacket(playerActorID, actorID);
|
return setappearance.buildPacket(actorID, playerActorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubPacket createStatePacket(uint playerActorID)
|
public SubPacket createStatePacket(uint playerActorID)
|
||||||
{
|
{
|
||||||
return SetActorStatePacket.buildPacket(playerActorID, actorID, currentState);
|
return SetActorStatePacket.buildPacket(actorID, playerActorID, currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubPacket createSpeedPacket(uint playerActorID)
|
public SubPacket createSpeedPacket(uint playerActorID)
|
||||||
{
|
{
|
||||||
return SetActorSpeedPacket.buildPacket(playerActorID, actorID);
|
return SetActorSpeedPacket.buildPacket(actorID, playerActorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubPacket createSpawnPositonPacket(uint playerActorID, uint spawnType)
|
public SubPacket createSpawnPositonPacket(uint playerActorID, uint spawnType)
|
||||||
{
|
{
|
||||||
return SetActorPositionPacket.buildPacket(playerActorID, actorID, positionX, positionY, positionZ, rotation, spawnType);
|
return SetActorPositionPacket.buildPacket(actorID, playerActorID, positionX, positionY, positionZ, rotation, spawnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubPacket createPositionUpdatePacket(uint playerActorID)
|
public SubPacket createPositionUpdatePacket(uint playerActorID)
|
||||||
{
|
{
|
||||||
return MoveActorToPositionPacket.buildPacket(playerActorID, actorID, positionX, positionY, positionZ, rotation, moveState);
|
return MoveActorToPositionPacket.buildPacket(actorID, playerActorID, positionX, positionY, positionZ, rotation, moveState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubPacket createScriptBindPacket(uint playerActorID)
|
public SubPacket createScriptBindPacket(uint playerActorID)
|
||||||
@ -145,15 +146,27 @@ namespace FFXIVClassic_Map_Server.dataobjects
|
|||||||
public BasePacket createActorSpawnPackets(uint playerActorID)
|
public BasePacket createActorSpawnPackets(uint playerActorID)
|
||||||
{
|
{
|
||||||
List<SubPacket> subpackets = new List<SubPacket>();
|
List<SubPacket> subpackets = new List<SubPacket>();
|
||||||
subpackets.Add(AddActorPacket.buildPacket(playerActorID, actorID));
|
subpackets.Add(AddActorPacket.buildPacket(actorID, playerActorID, 8));
|
||||||
subpackets.Add(createSpeedPacket(playerActorID));
|
subpackets.Add(createSpeedPacket(playerActorID));
|
||||||
subpackets.Add(createSpawnPositonPacket(playerActorID, 0));
|
subpackets.Add(createSpawnPositonPacket(playerActorID, 0));
|
||||||
subpackets.Add(createAppearancePacket(playerActorID));
|
subpackets.Add(createAppearancePacket(playerActorID));
|
||||||
subpackets.Add(createNamePacket(playerActorID));
|
subpackets.Add(createNamePacket(playerActorID));
|
||||||
subpackets.Add(createStatePacket(playerActorID));
|
subpackets.Add(createStatePacket(playerActorID));
|
||||||
subpackets.Add(createScriptBindPacket(playerActorID));
|
//subpackets.Add(createScriptBindPacket(playerActorID));
|
||||||
|
subpackets.Add(new SubPacket(0xCC, actorID, playerActorID, File.ReadAllBytes("./packets/playerscript")));
|
||||||
|
subpackets.Add(new SubPacket(0x137, actorID, playerActorID, File.ReadAllBytes("./packets/playerscript2")));
|
||||||
|
subpackets.Add(new SubPacket(0x137, actorID, playerActorID, File.ReadAllBytes("./packets/playerscript3")));
|
||||||
return BasePacket.createPacket(subpackets, true, false);
|
return BasePacket.createPacket(subpackets, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool Equals(Object obj)
|
||||||
|
{
|
||||||
|
Actor actorObj = obj as Actor;
|
||||||
|
if (actorObj == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return actorID == actorObj.actorID;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,29 @@ namespace FFXIVClassic_Lobby_Server.packets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Replaces all instances of the sniffed actorID with the given one
|
||||||
|
public void replaceActorID(uint fromActorID, uint actorID)
|
||||||
|
{
|
||||||
|
using (MemoryStream mem = new MemoryStream(data))
|
||||||
|
{
|
||||||
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||||
|
{
|
||||||
|
using (BinaryReader binreader = new BinaryReader(mem))
|
||||||
|
{
|
||||||
|
while (binreader.BaseStream.Position + 4 < data.Length)
|
||||||
|
{
|
||||||
|
uint read = binreader.ReadUInt32();
|
||||||
|
if (read == fromActorID) //Original ID
|
||||||
|
{
|
||||||
|
binWriter.BaseStream.Seek(binreader.BaseStream.Position - 0x4, SeekOrigin.Begin);
|
||||||
|
binWriter.Write(actorID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Utility Functions
|
#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)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user