More cleanup (moved groups to WorldMaster class) and fixed the project file.

This commit is contained in:
Filip Maj 2016-12-17 09:37:18 -05:00
parent 2cc63960a7
commit 31446f37fa
10 changed files with 227 additions and 127 deletions

View File

@ -80,6 +80,7 @@ namespace FFXIVClassic_Map_Server.Actors
return AddActorPacket.BuildPacket(actorId, playerActorId, 8);
}
int val = 0x0b00;
// actorClassId, [], [], numBattleCommon, [battleCommon], numEventCommon, [eventCommon], args for either initForBattle/initForEvent
public override SubPacket CreateScriptBindPacket(uint playerActorId)
{
@ -88,6 +89,13 @@ namespace FFXIVClassic_Map_Server.Actors
Player player = Server.GetWorldManager().GetPCInWorld(playerActorId);
lParams = DoActorInit(player);
if (uniqueIdentifier.Equals("1"))
{
lParams[5].value = val;
val++;
player.SendMessage(0x20, "", String.Format("ID is now: 0x{0:X}", val));
}
if (lParams != null && lParams.Count >= 3 && lParams[2].typeID == 0 && (int)lParams[2].value == 0)
isStatic = true;
@ -122,7 +130,58 @@ namespace FFXIVClassic_Map_Server.Actors
subpackets.AddRange(GetEventConditionPackets(playerActorId));
subpackets.Add(CreateSpeedPacket(playerActorId));
subpackets.Add(CreateSpawnPositonPacket(playerActorId, 0x0));
subpackets.Add(CreateAppearancePacket(playerActorId));
if (uniqueIdentifier.Equals("door2"))
{
subpackets.Add(_0xD8Packet.BuildPacket(actorId, playerActorId, 0xB09, 0x1af));
}
else if (uniqueIdentifier.Equals("uldah_mapshipport_1"))
{
subpackets.Add(_0xD8Packet.BuildPacket(actorId, playerActorId, 0xdc5, 0x1af));
subpackets[subpackets.Count - 1].DebugPrintSubPacket();
subpackets.Add(_0xD9Packet.BuildPacket(actorId, playerActorId, "end0"));
subpackets[subpackets.Count - 1].DebugPrintSubPacket();
}
else if (uniqueIdentifier.Equals("uldah_mapshipport_2"))
{
subpackets.Add(_0xD8Packet.BuildPacket(actorId, playerActorId, 0x2, 0x1eb));
subpackets[subpackets.Count - 1].DebugPrintSubPacket();
subpackets.Add(_0xD9Packet.BuildPacket(actorId, playerActorId, "end0"));
subpackets[subpackets.Count - 1].DebugPrintSubPacket();
}
else if (uniqueIdentifier.Equals("gridania_shipport"))
{
subpackets.Add(_0xD8Packet.BuildPacket(actorId,playerActorId, 0xcde, 0x141));
subpackets.Add(_0xD9Packet.BuildPacket(actorId,playerActorId, "end0"));
}
else if (uniqueIdentifier.Equals("gridania_shipport2"))
{
subpackets.Add(_0xD8Packet.BuildPacket(actorId, playerActorId, 0x02, 0x187));
subpackets.Add(_0xD9Packet.BuildPacket(actorId, playerActorId, "end0"));
}
else if (uniqueIdentifier.Equals("limsa_shipport"))
{
subpackets.Add(_0xD8Packet.BuildPacket(actorId, playerActorId, 0x1c8, 0xc4));
subpackets.Add(_0xD9Packet.BuildPacket(actorId, playerActorId, "spin"));
}
else if (actorClassId == 5900013)
{
uint id = 2;
uint id2 = 5144;
string val = "fdot";
subpackets.Add(_0xD8Packet.BuildPacket(actorId, playerActorId, id, id2));
subpackets.Add(_0xD9Packet.BuildPacket(actorId, playerActorId, val));
}
else if (actorClassId == 5900014)
{
uint id = 2;
uint id2 = 5145;
string val = "fdot";
subpackets.Add(_0xD8Packet.BuildPacket(actorId, playerActorId, id, id2));
subpackets.Add(_0xD9Packet.BuildPacket(actorId, playerActorId, val));
}
else
subpackets.Add(CreateAppearancePacket(playerActorId));
subpackets.Add(CreateNamePacket(playerActorId));
subpackets.Add(CreateStatePacket(playerActorId));
subpackets.Add(CreateIdleAnimationPacket(playerActorId));

View File

@ -82,7 +82,7 @@ namespace FFXIVClassic_Map_Server.dataobjects
GetActor().zone.UpdateActorPosition(GetActor());
}
long lastMilis = 0;
public void UpdateInstance(List<Actor> list)
{
if (isUpdatesLocked)
@ -95,11 +95,29 @@ namespace FFXIVClassic_Map_Server.dataobjects
//Remove missing actors
for (int i = 0; i < actorInstanceList.Count; i++)
{
if (list.Contains(actorInstanceList[i]) && actorInstanceList[i] is Npc)
{
Npc npc = (Npc)actorInstanceList[i];
long milliseconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
if (npc.GetUniqueId().Equals("1") && milliseconds - lastMilis > 1000)
{
lastMilis = milliseconds;
GetActor().QueuePacket(RemoveActorPacket.BuildPacket(playerActor.actorId, actorInstanceList[i].actorId));
actorInstanceList.RemoveAt(i);
continue;
}
}
if (!list.Contains(actorInstanceList[i]))
{
GetActor().QueuePacket(RemoveActorPacket.BuildPacket(playerActor.actorId, actorInstanceList[i].actorId));
actorInstanceList.RemoveAt(i);
}
}
//Add new actors or move

View File

@ -29,6 +29,11 @@ namespace FFXIVClassic_World_Server.DataObjects.Group
return (uint)(partyGroupWork._globalTemp.owner & 0xFFFFFF);
}
public bool IsInParty(uint charaId)
{
return members.Contains(charaId);
}
public override void SendInitWorkValues(Session session)
{
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupIndex);

View File

@ -64,12 +64,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Actor\Group\Group.cs" />
<Compile Include="Actor\Group\GroupInvitationRelationGroup.cs" />
<Compile Include="Actor\Group\GroupMember.cs" />
<Compile Include="Actor\Group\LinkshellGroup.cs" />
<Compile Include="Actor\Group\PartyGroup.cs" />
<Compile Include="Actor\Group\RetainerGroup.cs" />
<Compile Include="Actor\Group\Work\ContentWork.cs" />
<Compile Include="Actor\Group\Work\GroupGlobalSave.cs" />
<Compile Include="Actor\Group\Work\GroupGlobalTemp.cs" />
@ -93,6 +87,7 @@
<Compile Include="LinkshellManager.cs" />
<Compile Include="PacketProcessor.cs" />
<Compile Include="Packets\Receive\HelloPacket.cs" />
<Compile Include="Packets\Receive\Subpackets\GroupCreatedPacket.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\CreateNamedGroup.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\CreateNamedGroupMultiple.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\DeleteGroupPacket.cs" />

View File

@ -9,14 +9,14 @@ namespace FFXIVClassic_World_Server
{
class LinkshellManager
{
private Server mServer;
private WorldManager mWorldManager;
private Object mGroupLockReference;
private Dictionary<ulong, Group> mCurrentWorldGroupsReference;
private Dictionary<ulong, Linkshell> mLinkshellList = new Dictionary<ulong, Linkshell>();
public LinkshellManager(Server server, Object groupLock, Dictionary<ulong, Group> worldGroupList)
public LinkshellManager(WorldManager worldManager, Object groupLock, Dictionary<ulong, Group> worldGroupList)
{
mServer = server;
mWorldManager = worldManager;
mGroupLockReference = groupLock;
mCurrentWorldGroupsReference = worldGroupList;
}
@ -29,14 +29,14 @@ namespace FFXIVClassic_World_Server
ulong resultId = Database.CreateLinkshell(name, crest, master);
if (resultId >= 0)
{
Linkshell newLs = new Linkshell(resultId, mServer.GetGroupIndex(), name, crest, master, 0xa);
Linkshell newLs = new Linkshell(resultId, mWorldManager.GetGroupIndex(), name, crest, master, 0xa);
//Add founder to the LS
if (AddMemberToLinkshell(master, newLs.groupIndex))
{
mLinkshellList.Add(mServer.GetGroupIndex(), newLs);
mCurrentWorldGroupsReference.Add(mServer.GetGroupIndex(), newLs);
mServer.IncrementGroupIndex();
mLinkshellList.Add(mWorldManager.GetGroupIndex(), newLs);
mCurrentWorldGroupsReference.Add(mWorldManager.GetGroupIndex(), newLs);
mWorldManager.IncrementGroupIndex();
}
}
return resultId;
@ -126,14 +126,14 @@ namespace FFXIVClassic_World_Server
{
lock (mGroupLockReference)
{
Linkshell ls = Database.GetLinkshell(mServer.GetGroupIndex(), id);
Linkshell ls = Database.GetLinkshell(mWorldManager.GetGroupIndex(), id);
ls.LoadMembers();
if (ls != null)
{
mLinkshellList.Add(id, ls);
mCurrentWorldGroupsReference.Add(mServer.GetGroupIndex(), ls);
mServer.IncrementGroupIndex();
mCurrentWorldGroupsReference.Add(mWorldManager.GetGroupIndex(), ls);
mWorldManager.IncrementGroupIndex();
return ls;
}
}

View File

@ -6,27 +6,30 @@ namespace FFXIVClassic_World_Server
{
class PartyManager
{
private Server mServer;
private WorldManager mWorldManager;
private Object mGroupLockReference;
private Dictionary<ulong, Group> mCurrentWorldGroupsReference;
private Dictionary<ulong, Party> mPartyList = new Dictionary<ulong, Party>();
private Dictionary<uint, Party> mPlayerPartyLookup = new Dictionary<uint, Party>();
public PartyManager(Server server, Object groupLock, Dictionary<ulong, Group> worldGroupList)
public PartyManager(WorldManager worldManager, Object groupLock, Dictionary<ulong, Group> worldGroupList)
{
mServer = server;
mWorldManager = worldManager;
mGroupLockReference = groupLock;
mCurrentWorldGroupsReference = worldGroupList;
}
public void CreateParty(uint leaderCharaId)
public Party CreateParty(uint leaderCharaId)
{
lock (mGroupLockReference)
{
ulong groupId = mServer.GetGroupIndex();
ulong groupId = mWorldManager.GetGroupIndex();
Party party = new Party(groupId, leaderCharaId);
mPartyList.Add(groupId, party);
mPlayerPartyLookup.Add(leaderCharaId, party);
mCurrentWorldGroupsReference.Add(groupId, party);
mServer.IncrementGroupIndex();
mWorldManager.IncrementGroupIndex();
return party;
}
}
@ -44,7 +47,11 @@ namespace FFXIVClassic_World_Server
{
Party party = mPartyList[groupId];
if (!party.members.Contains(charaId))
{
party.members.Add(charaId);
mPlayerPartyLookup.Remove(charaId);
mPlayerPartyLookup.Add(charaId, party);
}
return true;
}
return false;
@ -58,6 +65,7 @@ namespace FFXIVClassic_World_Server
if (party.members.Contains(charaId))
{
party.members.Remove(charaId);
mPlayerPartyLookup.Remove(charaId);
//If current ldr, make a new ldr if not empty pt
if (party.GetLeader() == charaId && party.members.Count != 0)
@ -81,5 +89,13 @@ namespace FFXIVClassic_World_Server
}
return false;
}
public Party GetParty(uint charaId)
{
if (mPlayerPartyLookup.ContainsKey(charaId))
return mPlayerPartyLookup[charaId];
else
return CreateParty(charaId);
}
}
}

View File

@ -6,14 +6,14 @@ namespace FFXIVClassic_World_Server
{
class RelationGroupManager
{
private Server mServer;
private WorldManager mWorldManager;
private Object mGroupLockReference;
private Dictionary<ulong, Group> mCurrentWorldGroupsReference;
private Dictionary<ulong, Relation> mRelationList = new Dictionary<ulong, Relation>();
public RelationGroupManager(Server server, Object groupLock, Dictionary<ulong, Group> worldGroupList)
public RelationGroupManager(WorldManager worldManager, Object groupLock, Dictionary<ulong, Group> worldGroupList)
{
mServer = server;
mWorldManager = worldManager;
mGroupLockReference = groupLock;
mCurrentWorldGroupsReference = worldGroupList;
}
@ -22,11 +22,11 @@ namespace FFXIVClassic_World_Server
{
lock (mGroupLockReference)
{
ulong groupIndex = mServer.GetGroupIndex();
ulong groupIndex = mWorldManager.GetGroupIndex();
Relation relation = new Relation(groupIndex, hostCharaId, otherCharaId, command);
mRelationList.Add(groupIndex, relation);
mCurrentWorldGroupsReference.Add(groupIndex, relation);
mServer.IncrementGroupIndex();
mWorldManager.IncrementGroupIndex();
}
}

View File

@ -9,14 +9,14 @@ namespace FFXIVClassic_World_Server
{
class RetainerGroupManager
{
private Server mServer;
private WorldManager mWorldManager;
private Object mGroupLockReference;
private Dictionary<ulong, Group> mCurrentWorldGroupsReference;
private Dictionary<uint, RetainerGroup> mRetainerGroupList = new Dictionary<uint, RetainerGroup>();
public RetainerGroupManager(Server server, Object groupLock, Dictionary<ulong, Group> worldGroupList)
public RetainerGroupManager(WorldManager worldManager, Object groupLock, Dictionary<ulong, Group> worldGroupList)
{
mServer = server;
mWorldManager = worldManager;
mGroupLockReference = groupLock;
mCurrentWorldGroupsReference = worldGroupList;
}
@ -33,7 +33,7 @@ namespace FFXIVClassic_World_Server
{
lock(mGroupLockReference)
{
ulong groupId = mServer.GetGroupIndex();
ulong groupId = mWorldManager.GetGroupIndex();
RetainerGroup retainerGroup = new RetainerGroup(groupId, charaId);
Dictionary<uint, RetainerGroupMember> members = Database.GetRetainers(charaId);
@ -44,7 +44,7 @@ namespace FFXIVClassic_World_Server
mRetainerGroupList.Add(charaId, retainerGroup);
mCurrentWorldGroupsReference.Add(groupId, retainerGroup);
mServer.IncrementGroupIndex();
mWorldManager.IncrementGroupIndex();
return retainerGroup;
}

View File

@ -2,6 +2,7 @@
using FFXIVClassic_World_Server.DataObjects;
using FFXIVClassic_World_Server.DataObjects.Group;
using FFXIVClassic_World_Server.Packets.Receive.Subpackets;
using FFXIVClassic_World_Server.Packets.Send.Subpackets.Groups;
using FFXIVClassic_World_Server.Packets.WorldPackets.Receive;
using FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group;
using System;
@ -31,23 +32,9 @@ namespace FFXIVClassic_World_Server
private Dictionary<uint, Session> mZoneSessionList = new Dictionary<uint, Session>();
private Dictionary<uint, Session> mChatSessionList = new Dictionary<uint, Session>();
//World Scope Group Management
private Object mGroupLock = new object();
private ulong mRunningGroupIndex = 1;
private Dictionary<ulong, Group> mCurrentWorldGroups = new Dictionary<ulong, Group>();
private PartyManager mPartyManager;
private RetainerGroupManager mRetainerGroupManager;
private LinkshellManager mLinkshellManager;
private RelationGroupManager mRelationGroupManager;
public Server()
{
mSelf = this;
mPartyManager = new PartyManager(this, mGroupLock, mCurrentWorldGroups);
mLinkshellManager = new LinkshellManager(this, mGroupLock, mCurrentWorldGroups);
mRetainerGroupManager = new RetainerGroupManager(this, mGroupLock, mCurrentWorldGroups);
mRelationGroupManager = new RelationGroupManager(this, mGroupLock, mCurrentWorldGroups);
}
public static Server GetServer()
@ -58,6 +45,9 @@ namespace FFXIVClassic_World_Server
public bool StartServer()
{
mPacketProcessor = new PacketProcessor(this);
LoadCharaNames();
mWorldManager = new WorldManager(this);
mWorldManager.LoadZoneServerList();
mWorldManager.LoadZoneEntranceList();
@ -213,22 +203,22 @@ namespace FFXIVClassic_World_Server
//Group get data request
case 0x1020:
GetGroupPacket getGroupPacket = new GetGroupPacket(subpacket.data);
SendGroupData(session, getGroupPacket.groupId);
mWorldManager.SendGroupData(session, getGroupPacket.groupId);
break;
//Group delete request
case 0x1021:
DeleteGroupPacket deleteGroupPacket = new DeleteGroupPacket(subpacket.data);
DeleteGroup(deleteGroupPacket.groupId);
FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group.DeleteGroupPacket deleteGroupPacket = new FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group.DeleteGroupPacket(subpacket.data);
mWorldManager.DeleteGroup(deleteGroupPacket.groupId);
break;
//Linkshell create request
case 0x1023:
CreateLinkshellPacket createLinkshellpacket = new CreateLinkshellPacket(subpacket.data);
mLinkshellManager.CreateLinkshell(createLinkshellpacket.name, createLinkshellpacket.crestid, createLinkshellpacket.master);
mWorldManager.GetLinkshellManager().CreateLinkshell(createLinkshellpacket.name, createLinkshellpacket.crestid, createLinkshellpacket.master);
break;
//Linkshell modify request
case 0x1024:
ModifyLinkshellPacket modifyLinkshellpacket = new ModifyLinkshellPacket(subpacket.data);
mLinkshellManager.ModifyLinkshell();
mWorldManager.GetLinkshellManager().ModifyLinkshell();
break;
//Group Add/Remove Member
case 0x1022:
@ -240,11 +230,7 @@ namespace FFXIVClassic_World_Server
else if (subpacket.gameMessage.opcode == 0x133)
{
GroupCreatedPacket groupCreatedPacket = new GroupCreatedPacket(subpacket.data);
if (mCurrentWorldGroups.ContainsKey(groupCreatedPacket.groupId))
{
mCurrentWorldGroups[groupCreatedPacket.groupId].SendInitWorkValues(session);
}
else //Not a world group, send to zone server
if (!mWorldManager.SendGroupInit(session, groupCreatedPacket.groupId))
{
ClientConnection conn = mZoneSessionList[sessionId].clientConnection;
conn.QueuePacket(subpacket, true, false);
@ -414,66 +400,5 @@ namespace FFXIVClassic_World_Server
return null;
}
private void SendGroupData(Session session, ulong groupId)
{
if (mCurrentWorldGroups.ContainsKey(groupId))
{
Group group = mCurrentWorldGroups[groupId];
}
}
private void SendGroupDataToAllMembers(ulong groupId)
{
if (mCurrentWorldGroups.ContainsKey(groupId))
{
Group group = mCurrentWorldGroups[groupId];
}
}
public void GetGroup(Group group)
{
if (group is Party)
{
}
else if (group is RetainerGroup)
{
}
else if (group is Linkshell)
{
}
else if (group is Relation)
{
}
}
public void DeleteGroup(ulong id)
{
if (!mCurrentWorldGroups.ContainsKey(id))
return;
Group group = mCurrentWorldGroups[id];
if (group is Party)
mPartyManager.DeleteParty(group.groupIndex);
else if (group is Linkshell)
mLinkshellManager.DeleteLinkshell(group.groupIndex);
else if (group is Relation)
mRelationGroupManager.DeleteRelationGroup(group.groupIndex);
}
public void IncrementGroupIndex()
{
mRunningGroupIndex++;
}
public ulong GetGroupIndex()
{
return mRunningGroupIndex;
}
}
}

View File

@ -1,5 +1,7 @@
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
using FFXIVClassic_World_Server.DataObjects.Group;
using FFXIVClassic_World_Server.Packets.Send.Subpackets.Groups;
using FFXIVClassic_World_Server.Packets.WorldPackets.Send;
using MySql.Data.MySqlClient;
using System;
@ -18,9 +20,23 @@ namespace FFXIVClassic_World_Server
public Dictionary<string, ZoneServer> mZoneServerList;
private Dictionary<uint, ZoneEntrance> zoneEntranceList;
//World Scope Group Management
private Object mGroupLock = new object();
private ulong mRunningGroupIndex = 1;
private Dictionary<ulong, Group> mCurrentWorldGroups = new Dictionary<ulong, Group>();
private PartyManager mPartyManager;
private RetainerGroupManager mRetainerGroupManager;
private LinkshellManager mLinkshellManager;
private RelationGroupManager mRelationGroupManager;
public WorldManager(Server server)
{
mServer = server;
mPartyManager = new PartyManager(this, mGroupLock, mCurrentWorldGroups);
mLinkshellManager = new LinkshellManager(this, mGroupLock, mCurrentWorldGroups);
mRetainerGroupManager = new RetainerGroupManager(this, mGroupLock, mCurrentWorldGroups);
mRelationGroupManager = new RelationGroupManager(this, mGroupLock, mCurrentWorldGroups);
}
public void LoadZoneServerList()
@ -216,6 +232,72 @@ namespace FFXIVClassic_World_Server
}
}
public void SendGroupData(Session session, ulong groupId)
{
if (mCurrentWorldGroups.ContainsKey(groupId))
{
Group group = mCurrentWorldGroups[groupId];
group.SendGroupPackets(session);
}
}
public void SendGroupDataToAllMembers(ulong groupId)
{
if (mCurrentWorldGroups.ContainsKey(groupId))
{
Group group = mCurrentWorldGroups[groupId];
foreach (GroupMember member in group.BuildMemberList())
group.SendGroupPackets(mServer.GetSession(member.actorId));
}
}
public void DeleteGroup(ulong id)
{
if (!mCurrentWorldGroups.ContainsKey(id))
return;
Group group = mCurrentWorldGroups[id];
if (group is Party)
mPartyManager.DeleteParty(group.groupIndex);
else if (group is Linkshell)
mLinkshellManager.DeleteLinkshell(group.groupIndex);
else if (group is Relation)
mRelationGroupManager.DeleteRelationGroup(group.groupIndex);
}
public void IncrementGroupIndex()
{
mRunningGroupIndex++;
}
public ulong GetGroupIndex()
{
return mRunningGroupIndex;
}
public bool SendGroupInit(Session session, ulong groupId)
{
if (mCurrentWorldGroups.ContainsKey(groupId))
{
mCurrentWorldGroups[groupId].SendInitWorkValues(session);
return true;
}
return false;
}
public PartyManager GetPartyManager()
{
return mPartyManager;
}
public RetainerGroupManager GetRetainerManager()
{
return mRetainerGroupManager;
}
public LinkshellManager GetLinkshellManager()
{
return mLinkshellManager;
}
}
}