Zone server now uses the World server's group classes. MotD now shows proper world name. Added party functions to zone server.

This commit is contained in:
Filip Maj 2016-12-21 09:27:51 -05:00
parent ae38ee1bc1
commit e89b7557b3
22 changed files with 310 additions and 284 deletions

View File

@ -10,7 +10,6 @@ namespace FFXIVClassic_Map_Server
public static String OPTIONS_PORT; public static String OPTIONS_PORT;
public static bool OPTIONS_TIMESTAMP = false; public static bool OPTIONS_TIMESTAMP = false;
public static uint DATABASE_WORLDID;
public static String DATABASE_HOST; public static String DATABASE_HOST;
public static String DATABASE_PORT; public static String DATABASE_PORT;
public static String DATABASE_NAME; public static String DATABASE_NAME;
@ -33,7 +32,6 @@ namespace FFXIVClassic_Map_Server
ConfigConstants.OPTIONS_PORT = configIni.GetValue("General", "server_port", "1989"); ConfigConstants.OPTIONS_PORT = configIni.GetValue("General", "server_port", "1989");
ConfigConstants.OPTIONS_TIMESTAMP = configIni.GetValue("General", "showtimestamp", "true").ToLower().Equals("true"); ConfigConstants.OPTIONS_TIMESTAMP = configIni.GetValue("General", "showtimestamp", "true").ToLower().Equals("true");
ConfigConstants.DATABASE_WORLDID = UInt32.Parse(configIni.GetValue("Database", "worldid", "0"));
ConfigConstants.DATABASE_HOST = configIni.GetValue("Database", "host", ""); ConfigConstants.DATABASE_HOST = configIni.GetValue("Database", "host", "");
ConfigConstants.DATABASE_PORT = configIni.GetValue("Database", "port", ""); ConfigConstants.DATABASE_PORT = configIni.GetValue("Database", "port", "");
ConfigConstants.DATABASE_NAME = configIni.GetValue("Database", "database", ""); ConfigConstants.DATABASE_NAME = configIni.GetValue("Database", "database", "");

View File

@ -45,30 +45,7 @@ namespace FFXIVClassic_Map_Server
} }
} }
return id; return id;
} }
public static DBWorld GetServer(uint serverId)
{
using (var conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
DBWorld world = null;
try
{
conn.Open();
world = conn.Query<DBWorld>("SELECT * FROM servers WHERE id=@ServerId", new {ServerId = serverId}).SingleOrDefault();
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
return world;
}
}
public static List<Npc> GetNpcList() public static List<Npc> GetNpcList()
{ {

View File

@ -123,7 +123,6 @@
<Compile Include="actors\chara\CharaWork.cs" /> <Compile Include="actors\chara\CharaWork.cs" />
<Compile Include="actors\chara\ParameterSave.cs" /> <Compile Include="actors\chara\ParameterSave.cs" />
<Compile Include="actors\chara\player\PlayerWork.cs" /> <Compile Include="actors\chara\player\PlayerWork.cs" />
<Compile Include="dataobjects\DBWorld.cs" />
<Compile Include="dataobjects\InventoryItem.cs" /> <Compile Include="dataobjects\InventoryItem.cs" />
<Compile Include="dataobjects\Session.cs" /> <Compile Include="dataobjects\Session.cs" />
<Compile Include="dataobjects\Item.cs" /> <Compile Include="dataobjects\Item.cs" />
@ -283,6 +282,7 @@
<Compile Include="packets\receive\PingPacket.cs" /> <Compile Include="packets\receive\PingPacket.cs" />
<Compile Include="packets\receive\UpdatePlayerPositionPacket.cs" /> <Compile Include="packets\receive\UpdatePlayerPositionPacket.cs" />
<Compile Include="packets\WorldPackets\Receive\ErrorPacket.cs" /> <Compile Include="packets\WorldPackets\Receive\ErrorPacket.cs" />
<Compile Include="packets\WorldPackets\Receive\PartySyncPacket.cs" />
<Compile Include="packets\WorldPackets\Receive\SessionEndPacket.cs" /> <Compile Include="packets\WorldPackets\Receive\SessionEndPacket.cs" />
<Compile Include="packets\WorldPackets\Receive\SessionBeginPacket.cs" /> <Compile Include="packets\WorldPackets\Receive\SessionBeginPacket.cs" />
<Compile Include="packets\WorldPackets\Send\Group\CreateLinkshellPacket.cs" /> <Compile Include="packets\WorldPackets\Send\Group\CreateLinkshellPacket.cs" />

View File

@ -51,14 +51,7 @@ namespace FFXIVClassic_Map_Server
startServer = false; startServer = false;
} }
} }
//Check World ID
DBWorld thisWorld = Database.GetServer(ConfigConstants.DATABASE_WORLDID);
if (thisWorld != null)
Program.Log.Info("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name);
else
Program.Log.Info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed.");
//Start server if A-OK //Start server if A-OK
if (startServer) if (startServer)
{ {

View File

@ -16,13 +16,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
<<<<<<< HEAD
using FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group;
=======
using FFXIVClassic_Map_Server.actors.group; using FFXIVClassic_Map_Server.actors.group;
using FFXIVClassic_Map_Server.packets.send.group; using FFXIVClassic_Map_Server.packets.send.group;
using FFXIVClassic_Map_Server.packets.WorldPackets.Receive; using FFXIVClassic_Map_Server.packets.WorldPackets.Receive;
>>>>>>> 2bdc238bc2ab3e4f397e0a61d8ab9cc2b2d7d590 using FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group;
namespace FFXIVClassic_Map_Server namespace FFXIVClassic_Map_Server
{ {
@ -34,7 +31,7 @@ namespace FFXIVClassic_Map_Server
private Dictionary<uint, List<SeamlessBoundry>> seamlessBoundryList; private Dictionary<uint, List<SeamlessBoundry>> seamlessBoundryList;
private Dictionary<uint, ZoneEntrance> zoneEntranceList; private Dictionary<uint, ZoneEntrance> zoneEntranceList;
private Dictionary<uint, ActorClass> actorClasses = new Dictionary<uint,ActorClass>(); private Dictionary<uint, ActorClass> actorClasses = new Dictionary<uint,ActorClass>();
private Dictionary<ulong, PartyGroup> currentPlayerParties = new Dictionary<ulong, PartyGroup>(); //GroupId, Party object private Dictionary<ulong, Party> currentPlayerParties = new Dictionary<ulong, Party>(); //GroupId, Party object
private Server mServer; private Server mServer;
@ -703,42 +700,34 @@ namespace FFXIVClassic_Map_Server
//World server sent a party member list synch packet to the zone server. Add and update players that may be a part of it. //World server sent a party member list synch packet to the zone server. Add and update players that may be a part of it.
public void PartyMemberListRecieved(PartySyncPacket syncPacket) public void PartyMemberListRecieved(PartySyncPacket syncPacket)
{ {
PartyGroup group; Party group;
List<GroupMember> members = new List<GroupMember>();
//Build member list for players on this server
foreach (uint actorId in syncPacket.memberActorIds)
{
Player p = GetPCInWorld(actorId);
if (p == null)
continue;
GroupMember member = new GroupMember(actorId, -1, 0, false, true, p.customDisplayName);
members.Add(member);
}
//If no members on this server, get out or clean //If no members on this server, get out or clean
if (!currentPlayerParties.ContainsKey(syncPacket.partyGroupId) && members.Count == 0) if (!currentPlayerParties.ContainsKey(syncPacket.partyGroupId) && syncPacket.memberActorIds.Length == 0)
return; return;
else if (!currentPlayerParties.ContainsKey(syncPacket.partyGroupId) && members.Count == 0) else if (!currentPlayerParties.ContainsKey(syncPacket.partyGroupId) && syncPacket.memberActorIds.Length == 0)
NoMembersInParty(currentPlayerParties[syncPacket.partyGroupId]); NoMembersInParty(currentPlayerParties[syncPacket.partyGroupId]);
//Get or create group //Get or create group
if (!currentPlayerParties.ContainsKey(syncPacket.partyGroupId)) if (!currentPlayerParties.ContainsKey(syncPacket.partyGroupId))
{ {
group = new PartyGroup(syncPacket.partyGroupId, syncPacket.owner); group = new Party(syncPacket.partyGroupId, syncPacket.owner);
currentPlayerParties.Add(syncPacket.partyGroupId, group); currentPlayerParties.Add(syncPacket.partyGroupId, group);
} }
else else
group = currentPlayerParties[syncPacket.partyGroupId]; group = currentPlayerParties[syncPacket.partyGroupId];
currentPlayerParties[syncPacket.partyGroupId].members = members; currentPlayerParties[syncPacket.partyGroupId].members = syncPacket.memberActorIds.ToList();
//Add group to everyone //Add group to everyone
foreach (GroupMember member in members) foreach (uint member in currentPlayerParties[syncPacket.partyGroupId].members)
{ {
Player player = GetPCInWorld(member.actorId); Session session = Server.GetServer().GetSession(member);
if (session == null)
continue;
Player player = session.GetActor();
if (player == null) if (player == null)
continue; continue;
player.SetParty(group); player.SetParty(group);
@ -746,10 +735,10 @@ namespace FFXIVClassic_Map_Server
} }
//Player was removed from the party either due to leaving it or leaving the server. Remove if empty. //Player was removed from the party either due to leaving it or leaving the server. Remove if empty.
public void NoMembersInParty(PartyGroup party) public void NoMembersInParty(Party party)
{ {
if (currentPlayerParties.ContainsKey(party.groupId)) if (currentPlayerParties.ContainsKey(party.groupIndex))
currentPlayerParties.Remove(party.groupId); currentPlayerParties.Remove(party.groupIndex);
} }
public Player GetPCInWorld(string name) public Player GetPCInWorld(string name)

View File

@ -1274,10 +1274,42 @@ namespace FFXIVClassic_Map_Server.Actors
playerSession.UpdateInstance(aroundMe); playerSession.UpdateInstance(aroundMe);
} }
//A party member list packet came, set the party public bool IsInParty()
public void SetParty(PartyGroup group)
{ {
if (group is PartyGroup) return currentParty != null;
}
public bool IsPartyLeader()
{
if (IsInParty())
{
Party party = (Party)currentParty;
return party.GetLeader() == actorId;
}
else
return false;
}
public void PartyOustPlayer()
{
}
public void PartyLeave()
{
}
public void PartyDisband()
{
}
public void PartyPromote()
{
}
//A party member list packet came, set the party
public void SetParty(Party group)
{
if (group is Party)
{ {
RemoveFromCurrentPartyAndCleanup(); RemoveFromCurrentPartyAndCleanup();
currentParty = group; currentParty = group;
@ -1290,18 +1322,20 @@ namespace FFXIVClassic_Map_Server.Actors
if (currentParty == null) if (currentParty == null)
return; return;
for (int i = 0; i < currentParty.members.Count; i++) Party partyGroup = (Party) currentParty;
for (int i = 0; i < partyGroup.members.Count; i++)
{ {
if (currentParty.members[i].actorId == actorId) if (partyGroup.members[i] == actorId)
{ {
currentParty.members.RemoveAt(i); partyGroup.members.RemoveAt(i);
break; break;
} }
} }
//currentParty.members.Remove(this); //currentParty.members.Remove(this);
if (currentParty.members.Count == 0) if (partyGroup.members.Count == 0)
Server.GetWorldManager().NoMembersInParty((PartyGroup)currentParty); Server.GetWorldManager().NoMembersInParty((Party)currentParty);
currentParty = null; currentParty = null;
} }

View File

@ -1,91 +1,85 @@
using FFXIVClassic.Common; using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.actors.group.work; using FFXIVClassic_Map_Server.dataobjects;
using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.packets.send.actor;
using FFXIVClassic_Map_Server.packets.send.group; using FFXIVClassic_Map_Server.packets.send.group;
using FFXIVClassic_Map_Server.packets.send.groups;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.actors.group namespace FFXIVClassic_Map_Server.actors.group
{ {
class Group class Group
{ {
public const uint PlayerPartyGroup = 10001; public const uint PlayerPartyGroup = 10001;
public const uint CompanyGroup = 20001; public const uint CompanyGroup = 20002;
public const uint GroupInvitationRelationGroup = 50001; public const uint GroupInvitationRelationGroup = 50001;
public const uint TradeRelationGroup = 50002; public const uint TradeRelationGroup = 50002;
public const uint BazaarBuyItemRelationGroup = 50009; public const uint BazaarBuyItemRelationGroup = 50009;
public const uint RetainerGroup = 80001; public const uint RetainerGroup = 80001;
public ulong groupId; public readonly ulong groupIndex;
public uint groupTypeId;
public int localizedNamed = -1; public Group(ulong groupIndex)
public string groupName = "";
public List<GroupMember> members = new List<GroupMember>();
public Group(ulong id, uint typeId)
{ {
groupId = id; this.groupIndex = groupIndex;
groupTypeId = typeId;
} }
public Group(ulong id, uint typeId, int nameId, object work) public virtual int GetMemberCount()
{ {
groupId = id; return 0;
groupTypeId = typeId;
localizedNamed = nameId;
} }
public Group(ulong id, uint typeId, string name, object work) public virtual uint GetTypeId()
{ {
groupId = id; return 0;
groupTypeId = typeId;
groupName = name;
localizedNamed = -1;
} }
public void add(Actor actor) public virtual string GetGroupName()
{ {
GroupMember member = new GroupMember(actor.actorId, (int)actor.displayNameId, 0, false, true, actor.customDisplayName); return "";
members.Add(member);
} }
public void sendMemberPackets(Player toPlayer) public virtual int GetGroupLocalizedName()
{
return -1;
}
public virtual List<GroupMember> BuildMemberList()
{
return new List<GroupMember>();
}
public void SendGroupPackets(Session session)
{ {
ulong time = Utils.MilisUnixTimeStampUTC(); ulong time = Utils.MilisUnixTimeStampUTC();
List<GroupMember> members = BuildMemberList();
toPlayer.QueuePacket(GroupHeaderPacket.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, this)); Server.GetWorldConnection().QueuePacket(GroupHeaderPacket.buildPacket(session.id, session.GetActor().zoneId, time, this), true, false);
toPlayer.QueuePacket(GroupMembersBeginPacket.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, this)); Server.GetWorldConnection().QueuePacket(GroupMembersBeginPacket.buildPacket(session.id, session.GetActor().zoneId, time, this), true, false);
int currentIndex = 0; int currentIndex = 0;
while (true) while (true)
{ {
if (members.Count - currentIndex >= 64) if (GetMemberCount() - currentIndex >= 64)
toPlayer.QueuePacket(GroupMembersX64Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex)); Server.GetWorldConnection().QueuePacket(GroupMembersX64Packet.buildPacket(session.id, session.GetActor().zoneId, time, members, ref currentIndex), true, false);
else if (members.Count - currentIndex >= 32) else if (GetMemberCount() - currentIndex >= 32)
toPlayer.QueuePacket(GroupMembersX32Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex)); Server.GetWorldConnection().QueuePacket(GroupMembersX32Packet.buildPacket(session.id, session.GetActor().zoneId, time, members, ref currentIndex), true, false);
else if (members.Count - currentIndex >= 16) else if (GetMemberCount() - currentIndex >= 16)
toPlayer.QueuePacket(GroupMembersX16Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex)); Server.GetWorldConnection().QueuePacket(GroupMembersX16Packet.buildPacket(session.id, session.GetActor().zoneId, time, members, ref currentIndex), true, false);
else if (members.Count - currentIndex > 0) else if (GetMemberCount() - currentIndex > 0)
toPlayer.QueuePacket(GroupMembersX08Packet.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, members, ref currentIndex)); Server.GetWorldConnection().QueuePacket(GroupMembersX08Packet.buildPacket(session.id, session.GetActor().zoneId, time, members, ref currentIndex), true, false);
else else
break; break;
} }
Server.GetWorldConnection().QueuePacket(GroupMembersEndPacket.buildPacket(session.id, session.GetActor().zoneId, time, this), true, false);
toPlayer.QueuePacket(GroupMembersEndPacket.buildPacket(toPlayer.actorId, toPlayer.zoneId, time, this));
} }
public virtual void sendWorkValues(Player player){} public virtual void SendInitWorkValues(Session session)
{
}
} }
} }

View File

@ -1,37 +0,0 @@
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.actors.group.work;
using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.packets.send.groups;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.actors.group
{
class GroupInvitationRelationGroup : Group
{
RelationWork work;
public GroupInvitationRelationGroup(uint id, uint hostActorId, uint commandType) : base(id, Group.GroupInvitationRelationGroup)
{
work = new RelationWork();
work._globalTemp.host = hostActorId;
work._globalTemp.variableCommand = commandType;
}
public override void sendWorkValues(Player player)
{
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupId);
groupWork.addProperty(this, "work._globalTemp.host");
groupWork.addProperty(this, "work._globalTemp.variableCommand");
groupWork.setTarget("/_init");
SubPacket test = groupWork.buildPacket(player.actorId, player.actorId);
test.DebugPrintSubPacket();
player.QueuePacket(test);
}
}
}

View File

@ -1,42 +0,0 @@
using FFXIVClassic_Map_Server.actors.group.work;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.actors.group
{
class LinkshellGroup : Group
{
private LinkshellWork linkshellWork;
public LinkshellGroup(ulong id) : base(id, Group.CompanyGroup)
{
linkshellWork = new LinkshellWork();
}
public void setMaster(uint actorId)
{
linkshellWork._globalSave.master = (ulong)((0xB36F92 << 8) | actorId);
}
public void setCrest(ushort crestId)
{
linkshellWork._globalSave.crestIcon[0] = crestId;
}
public void setRank(byte rank = 1)
{
linkshellWork._globalSave.rank = rank;
}
public void setMemberRank(int index, byte rank)
{
if (members.Count >= index)
return;
linkshellWork._memberSave[index].rank = rank;
}
}
}

View File

@ -0,0 +1,53 @@
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.actors.group.work;
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.actors.group
{
class Party : Group
{
public PartyWork partyGroupWork = new PartyWork();
public List<uint> members = new List<uint>();
public Party(ulong groupId, uint leaderCharaId) : base(groupId)
{
partyGroupWork._globalTemp.owner = (ulong)(((ulong)leaderCharaId << 32) | 0xB36F92);
members.Add(leaderCharaId);
}
public void SetLeader(uint actorId)
{
partyGroupWork._globalTemp.owner = (ulong)((actorId << 32) | 0xB36F92);
}
public uint GetLeader()
{
return (uint)((partyGroupWork._globalTemp.owner >> 32) & 0xFFFFFFFF);
}
public bool IsInParty(uint charaId)
{
return members.Contains(charaId);
}
public override void SendInitWorkValues(Session session)
{
}
public override int GetMemberCount()
{
return members.Count;
}
public override uint GetTypeId()
{
return Group.PlayerPartyGroup;
}
}
}

View File

@ -1,37 +0,0 @@
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.actors.group.work;
using FFXIVClassic_Map_Server.packets.send.groups;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.actors.group
{
class PartyGroup : Group
{
private PartyWork partyGroupWork;
public PartyGroup(ulong id, uint owner) : base(id, Group.PlayerPartyGroup)
{
partyGroupWork = new PartyWork();
partyGroupWork._globalTemp.owner = (ulong)((0xB36F92 << 8) | owner);
}
public void setPartyOwner(uint actorId)
{
partyGroupWork._globalTemp.owner = (ulong)((0xB36F92 << 8) | actorId);
}
public override void sendWorkValues(Actors.Player player)
{
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupId);
groupWork.addProperty(this, "partyGroupWork._globalTemp.owner");
groupWork.setTarget("/_init");
SubPacket test = groupWork.buildPacket(player.actorId, player.actorId);
player.QueuePacket(test);
}
}
}

View File

@ -0,0 +1,46 @@
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.actors.group.work;
using FFXIVClassic_Map_Server.dataobjects;
using FFXIVClassic_Map_Server.packets.send.group;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.actors.group
{
class Relation : Group
{
public RelationWork work = new RelationWork();
public uint charaOther;
public Relation(ulong groupIndex, uint host, uint other, uint command) : base (groupIndex)
{
this.charaOther = other;
work._globalTemp.host = ((ulong)host << 32) | (0xc17909);
work._globalTemp.variableCommand = command;
}
public override int GetMemberCount()
{
return 2;
}
public override uint GetTypeId()
{
return Group.GroupInvitationRelationGroup;
}
public override List<GroupMember> BuildMemberList()
{
return null;
}
public override void SendInitWorkValues(Session session)
{
}
}
}

View File

@ -1,44 +0,0 @@
using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.actors.group.work;
using FFXIVClassic_Map_Server.packets.send.groups;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FFXIVClassic_Map_Server.actors.group
{
class RetainerGroup : Group
{
private RetainerWork work;
public RetainerGroup(ulong id) : base(id, Group.RetainerGroup)
{
work = new RetainerWork();
}
public void setRetainerProperties(int index, byte cdIDOffset, ushort placeName, byte condition, byte level)
{
if (members.Count >= index)
return;
work._memberSave[index].cdIDOffset = cdIDOffset;
work._memberSave[index].placeName = placeName;
work._memberSave[index].conditions = condition;
work._memberSave[index].level = level;
}
public override void sendWorkValues(Actors.Player player)
{
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupId);
groupWork.addProperty(this, "work._memberSave[0].cdIDOffset");
groupWork.addProperty(this, "work._memberSave[0].placeName");
groupWork.addProperty(this, "work._memberSave[0].conditions");
groupWork.addProperty(this, "work._memberSave[0].level");
groupWork.setTarget("/_init");
SubPacket test = groupWork.buildPacket(player.actorId, player.actorId);
player.QueuePacket(test);
}
}
}

View File

@ -10,12 +10,15 @@ namespace FFXIVClassic_World_Server
public static String OPTIONS_PORT; public static String OPTIONS_PORT;
public static bool OPTIONS_TIMESTAMP = false; public static bool OPTIONS_TIMESTAMP = false;
public static uint DATABASE_WORLDID;
public static String DATABASE_HOST; public static String DATABASE_HOST;
public static String DATABASE_PORT; public static String DATABASE_PORT;
public static String DATABASE_NAME; public static String DATABASE_NAME;
public static String DATABASE_USERNAME; public static String DATABASE_USERNAME;
public static String DATABASE_PASSWORD; public static String DATABASE_PASSWORD;
public static String PREF_SERVERNAME;
public static bool Load() public static bool Load()
{ {
Program.Log.Info("Loading world_config.ini"); Program.Log.Info("Loading world_config.ini");
@ -32,6 +35,7 @@ namespace FFXIVClassic_World_Server
ConfigConstants.OPTIONS_PORT = configIni.GetValue("General", "server_port", "54992"); ConfigConstants.OPTIONS_PORT = configIni.GetValue("General", "server_port", "54992");
ConfigConstants.OPTIONS_TIMESTAMP = configIni.GetValue("General", "showtimestamp", "true").ToLower().Equals("true"); ConfigConstants.OPTIONS_TIMESTAMP = configIni.GetValue("General", "showtimestamp", "true").ToLower().Equals("true");
ConfigConstants.DATABASE_WORLDID = UInt32.Parse(configIni.GetValue("Database", "worldid", "0"));
ConfigConstants.DATABASE_HOST = configIni.GetValue("Database", "host", ""); ConfigConstants.DATABASE_HOST = configIni.GetValue("Database", "host", "");
ConfigConstants.DATABASE_PORT = configIni.GetValue("Database", "port", ""); ConfigConstants.DATABASE_PORT = configIni.GetValue("Database", "port", "");
ConfigConstants.DATABASE_NAME = configIni.GetValue("Database", "database", ""); ConfigConstants.DATABASE_NAME = configIni.GetValue("Database", "database", "");

View File

@ -1,9 +1,9 @@
namespace FFXIVClassic_Map_Server.dataobjects namespace FFXIVClassic_World_Server.DataObjects
{ {
class DBWorld class DBWorld
{ {
public ushort id; public uint id;
public string Address; public string address;
public ushort port; public ushort port;
public ushort listPosition; public ushort listPosition;
public ushort population; public ushort population;

View File

@ -8,6 +8,41 @@ namespace FFXIVClassic_World_Server
{ {
class Database class Database
{ {
public static DBWorld GetServer(uint serverId)
{
using (var conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
DBWorld world = null;
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT name, address, port FROM servers WHERE id = @serverId", conn);
cmd.Parameters.AddWithValue("@serverId", serverId);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
world = new DBWorld();
world.id = serverId;
world.name = Reader.GetString("name");
world.address = Reader.GetString("address");
world.port = Reader.GetUInt16("port");
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
return world;
}
}
public static bool LoadZoneSessionInfo(Session session) public static bool LoadZoneSessionInfo(Session session)
{ {
string characterName; string characterName;

View File

@ -75,6 +75,7 @@
<Compile Include="ConfigConstants.cs" /> <Compile Include="ConfigConstants.cs" />
<Compile Include="Database.cs" /> <Compile Include="Database.cs" />
<Compile Include="DataObjects\ClientConnection.cs" /> <Compile Include="DataObjects\ClientConnection.cs" />
<Compile Include="DataObjects\DBWorld.cs" />
<Compile Include="DataObjects\Group\Group.cs" /> <Compile Include="DataObjects\Group\Group.cs" />
<Compile Include="DataObjects\Group\Linkshell.cs" /> <Compile Include="DataObjects\Group\Linkshell.cs" />
<Compile Include="DataObjects\Group\LinkshellMember.cs" /> <Compile Include="DataObjects\Group\LinkshellMember.cs" />
@ -115,6 +116,7 @@
<Compile Include="Packets\WorldPackets\Receive\WorldRequestZoneChangePacket.cs" /> <Compile Include="Packets\WorldPackets\Receive\WorldRequestZoneChangePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\SessionEndConfirmPacket.cs" /> <Compile Include="Packets\WorldPackets\Receive\SessionEndConfirmPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\ErrorPacket.cs" /> <Compile Include="Packets\WorldPackets\Send\ErrorPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\Group\PartySyncPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\Group\GroupWorkValuesPacket.cs" /> <Compile Include="Packets\WorldPackets\Send\Group\GroupWorkValuesPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\Group\GroupMemberListPacket.cs" /> <Compile Include="Packets\WorldPackets\Send\Group\GroupMemberListPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\Group\GroupMemberListEndPacket.cs" /> <Compile Include="Packets\WorldPackets\Send\Group\GroupMemberListEndPacket.cs" />

View File

@ -160,7 +160,7 @@ namespace FFXIVClassic_World_Server
public Linkshell GetLinkshell(string name) public Linkshell GetLinkshell(string name)
{ {
if (mNameToIdLookup.ContainsKey(name)) if (mNameToIdLookup.ContainsKey(name))
return mCurrentWorldGroupsReference[mNameToIdLookup[name]]; return (Linkshell)mCurrentWorldGroupsReference[mNameToIdLookup[name]];
else else
return null; return null;
} }

View File

@ -0,0 +1,33 @@
using FFXIVClassic.Common;
using FFXIVClassic_World_Server.DataObjects;
using FFXIVClassic_World_Server.DataObjects.Group;
using System;
using System.IO;
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Send.Group
{
class PartySyncPacket
{
public const ushort OPCODE = 0x1020;
public const uint PACKET_SIZE = 0x60;
public static SubPacket BuildPacket(Session session, Party party)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt64)party.groupIndex);
binWriter.Write((UInt32)party.GetLeader());
binWriter.Write((UInt32)party.members.Count);
for (int i = 0; i < party.members.Count; i++)
binWriter.Write((UInt32)party.members[i]);
}
}
return new SubPacket(true, OPCODE, 0, session.sessionId, data);
}
}
}

View File

@ -1,4 +1,5 @@
using MySql.Data.MySqlClient; using FFXIVClassic_World_Server.DataObjects;
using MySql.Data.MySqlClient;
using NLog; using NLog;
using NLog.Fluent; using NLog.Fluent;
using System; using System;
@ -56,6 +57,19 @@ namespace FFXIVClassic_World_Server
startServer = false; startServer = false;
} }
} }
//Check World ID
DBWorld thisWorld = Database.GetServer(ConfigConstants.DATABASE_WORLDID);
if (thisWorld != null)
{
Program.Log.Info("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name);
ConfigConstants.PREF_SERVERNAME = thisWorld.name;
}
else
{
Program.Log.Info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed.");
ConfigConstants.PREF_SERVERNAME = "Unknown";
}
//Start server if A-OK //Start server if A-OK
if (startServer) if (startServer)

View File

@ -228,7 +228,7 @@ namespace FFXIVClassic_World_Server
//Linkshell set active //Linkshell set active
case 0x1028: case 0x1028:
SetActiveLinkshellPacket setActiveLinkshellPacket = new SetActiveLinkshellPacket(subpacket.data); SetActiveLinkshellPacket setActiveLinkshellPacket = new SetActiveLinkshellPacket(subpacket.data);
Linkshell ls = mWorldManager.GetLinkshellManager().GetLinkshell(); //Linkshell ls = mWorldManager.GetLinkshellManager().GetLinkshell();
break; break;
} }
} }

View File

@ -4,6 +4,7 @@ using FFXIVClassic_World_Server.DataObjects.Group;
using FFXIVClassic_World_Server.Packets.Send.Subpackets; using FFXIVClassic_World_Server.Packets.Send.Subpackets;
using FFXIVClassic_World_Server.Packets.Send.Subpackets.Groups; using FFXIVClassic_World_Server.Packets.Send.Subpackets.Groups;
using FFXIVClassic_World_Server.Packets.WorldPackets.Send; using FFXIVClassic_World_Server.Packets.WorldPackets.Send;
using FFXIVClassic_World_Server.Packets.WorldPackets.Send.Group;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -219,6 +220,7 @@ namespace FFXIVClassic_World_Server
mPartyManager.AddToParty(pt.groupIndex, 161); mPartyManager.AddToParty(pt.groupIndex, 161);
mPartyManager.AddToParty(pt.groupIndex, 162); mPartyManager.AddToParty(pt.groupIndex, 162);
pt.SendGroupPackets(session); pt.SendGroupPackets(session);
SendPartySync(pt);
mRetainerGroupManager.GetRetainerGroup(session.sessionId).SendGroupPackets(session); mRetainerGroupManager.GetRetainerGroup(session.sessionId).SendGroupPackets(session);
List<Linkshell> linkshells = mLinkshellManager.GetPlayerLinkshellMembership(session.sessionId); List<Linkshell> linkshells = mLinkshellManager.GetPlayerLinkshellMembership(session.sessionId);
foreach (Linkshell ls in linkshells) foreach (Linkshell ls in linkshells)
@ -230,11 +232,23 @@ namespace FFXIVClassic_World_Server
private void SendMotD(Session session) private void SendMotD(Session session)
{ {
session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "-------- Login Message --------"), true, false); session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "-------- Login Message --------"), true, false);
session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Welcome to <Server Name>!"), true, false); session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Welcome to {0}!", ConfigConstants.PREF_SERVERNAME)), true, false);
session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Welcome to Eorzea!"), true, false); session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Welcome to Eorzea!"), true, false);
session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Here is a test Message of the Day from the World Server!"), true, false); session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Here is a test Message of the Day from the World Server!"), true, false);
} }
public void SendPartySync(Party party)
{
foreach (uint member in party.members)
{
Session session = Server.GetServer().GetSession(member);
if (session == null)
continue;
SubPacket syncPacket = PartySyncPacket.BuildPacket(session, party);
session.routing1.SendPacket(syncPacket);
}
}
public class ZoneEntrance public class ZoneEntrance
{ {
public uint zoneId; public uint zoneId;