2015-09-25 18:52:25 -04:00
|
|
|
|
using FFXIVClassic_Lobby_Server;
|
|
|
|
|
using FFXIVClassic_Lobby_Server.dataobjects;
|
2015-10-13 19:15:44 -04:00
|
|
|
|
using FFXIVClassic_Lobby_Server.packets;
|
2015-12-04 02:00:05 -05:00
|
|
|
|
using FFXIVClassic_Map_Server.dataobjects.chara;
|
2015-10-13 19:15:44 -04:00
|
|
|
|
using FFXIVClassic_Map_Server.packets.send.actor;
|
2015-09-25 18:52:25 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace FFXIVClassic_Map_Server.dataobjects
|
|
|
|
|
{
|
2015-12-04 02:00:05 -05:00
|
|
|
|
class ConnectedPlayer
|
|
|
|
|
{
|
|
|
|
|
public uint actorID = 0;
|
2016-01-02 14:04:45 -05:00
|
|
|
|
Player playerActor;
|
|
|
|
|
public List<Actor> actorInstanceList = new List<Actor>();
|
|
|
|
|
|
|
|
|
|
public uint eventCurrentOwner = 0;
|
|
|
|
|
public string eventCurrentStarter = "";
|
2015-09-25 18:52:25 -04:00
|
|
|
|
|
|
|
|
|
ClientConnection conn1;
|
|
|
|
|
ClientConnection conn2;
|
|
|
|
|
|
|
|
|
|
bool isDisconnected;
|
|
|
|
|
|
2015-12-04 02:00:05 -05:00
|
|
|
|
public ConnectedPlayer(uint actorId)
|
2015-09-25 18:52:25 -04:00
|
|
|
|
{
|
|
|
|
|
this.actorID = actorId;
|
2015-12-04 02:00:05 -05:00
|
|
|
|
DBCharacter chara = Database.getCharacter(actorId);
|
2015-10-06 00:39:18 -04:00
|
|
|
|
createPlayerActor(actorId, chara);
|
2015-09-25 18:52:25 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addConnection(ClientConnection conn)
|
|
|
|
|
{
|
|
|
|
|
if (conn1 == null && conn2 != null)
|
|
|
|
|
conn1 = conn;
|
|
|
|
|
else if (conn2 == null && conn1 != null)
|
|
|
|
|
conn2 = conn;
|
|
|
|
|
else
|
|
|
|
|
conn1 = conn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool isClientConnectionsReady()
|
|
|
|
|
{
|
|
|
|
|
return (conn1 != null && conn2 != null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void disconnect()
|
|
|
|
|
{
|
|
|
|
|
isDisconnected = true;
|
|
|
|
|
conn1.disconnect();
|
|
|
|
|
conn2.disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setConnection1(ClientConnection conn)
|
|
|
|
|
{
|
|
|
|
|
conn1 = conn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setConnection2(ClientConnection conn)
|
|
|
|
|
{
|
|
|
|
|
conn2 = conn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ClientConnection getConnection1()
|
|
|
|
|
{
|
|
|
|
|
return conn1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ClientConnection getConnection2()
|
|
|
|
|
{
|
2015-11-27 00:42:35 -05:00
|
|
|
|
return conn2;
|
2015-09-25 18:52:25 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-02 14:04:45 -05:00
|
|
|
|
public void queuePacket(BasePacket basePacket)
|
|
|
|
|
{
|
|
|
|
|
conn1.queuePacket(basePacket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void queuePacket(SubPacket subPacket, bool isAuthed, bool isEncrypted)
|
|
|
|
|
{
|
|
|
|
|
conn1.queuePacket(subPacket, isAuthed, isEncrypted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Player getActor()
|
2015-10-06 00:39:18 -04:00
|
|
|
|
{
|
|
|
|
|
return playerActor;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 02:00:05 -05:00
|
|
|
|
public void createPlayerActor(uint actorId, DBCharacter chara)
|
2015-09-25 18:52:25 -04:00
|
|
|
|
{
|
2016-01-02 14:04:45 -05:00
|
|
|
|
playerActor = new Player(actorId);
|
2015-10-06 00:39:18 -04:00
|
|
|
|
|
2016-01-02 14:04:45 -05:00
|
|
|
|
playerActor.displayNameId = 0xFFFFFFFF;
|
2015-10-06 00:39:18 -04:00
|
|
|
|
playerActor.customDisplayName = chara.name;
|
|
|
|
|
playerActor.setPlayerAppearance();
|
2015-09-25 18:52:25 -04:00
|
|
|
|
actorInstanceList.Add(playerActor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updatePlayerActorPosition(float x, float y, float z, float rot, ushort moveState)
|
|
|
|
|
{
|
|
|
|
|
playerActor.positionX = x;
|
|
|
|
|
playerActor.positionY = y;
|
|
|
|
|
playerActor.positionZ = z;
|
|
|
|
|
playerActor.rotation = rot;
|
|
|
|
|
playerActor.moveState = moveState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void sendMotd()
|
|
|
|
|
{
|
2015-12-04 02:00:05 -05:00
|
|
|
|
DBWorld world = Database.getServer(ConfigConstants.DATABASE_WORLDID);
|
2015-09-25 18:52:25 -04:00
|
|
|
|
//sendChat(world.motd);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 02:00:05 -05:00
|
|
|
|
public void sendChat(ConnectedPlayer sender, string message, int mode)
|
2015-09-25 18:52:25 -04:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-13 19:15:44 -04:00
|
|
|
|
public List<BasePacket> updateInstance(List<Actor> list)
|
|
|
|
|
{
|
|
|
|
|
List<BasePacket> basePackets = new List<BasePacket>();
|
|
|
|
|
List<SubPacket> posUpdateSubpackets = new List<SubPacket>();
|
2015-10-12 02:03:47 -04:00
|
|
|
|
|
2015-10-13 19:15:44 -04:00
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
Actor actor = list[i];
|
|
|
|
|
|
2016-01-02 14:04:45 -05:00
|
|
|
|
if (actor.actorId == playerActor.actorId)
|
2015-10-13 19:15:44 -04:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (actorInstanceList.Contains(actor))
|
2015-10-13 22:58:21 -04:00
|
|
|
|
{
|
2016-01-02 14:04:45 -05:00
|
|
|
|
posUpdateSubpackets.Add(actor.createPositionUpdatePacket(playerActor.actorId));
|
2015-10-13 22:58:21 -04:00
|
|
|
|
}
|
2015-10-13 19:15:44 -04:00
|
|
|
|
else
|
2015-10-13 22:58:21 -04:00
|
|
|
|
{
|
2016-01-02 14:04:45 -05:00
|
|
|
|
BasePacket p = actor.createActorSpawnPackets(playerActor.actorId);
|
|
|
|
|
p.replaceActorID(playerActor.actorId);
|
2015-10-13 22:58:21 -04:00
|
|
|
|
basePackets.Add(p);
|
|
|
|
|
actorInstanceList.Add(actor);
|
|
|
|
|
}
|
2015-10-13 19:15:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-27 00:42:35 -05:00
|
|
|
|
if (posUpdateSubpackets.Count > 0)
|
|
|
|
|
basePackets.Add(BasePacket.createPacket(posUpdateSubpackets, true, false));
|
2015-10-13 19:15:44 -04:00
|
|
|
|
|
|
|
|
|
return basePackets;
|
2015-10-12 02:03:47 -04:00
|
|
|
|
}
|
2016-01-02 14:04:45 -05:00
|
|
|
|
|
2015-09-25 18:52:25 -04:00
|
|
|
|
}
|
|
|
|
|
}
|