Cleaned up namespaces (still have to do Map Project) and removed references to FFXIV Classic from the code. Removed the Launcher Editor project as it is no longer needed (host file editing is cleaner).

This commit is contained in:
Filip Maj 2019-06-19 00:05:18 -04:00
parent 7587a6e142
commit 0f61c4c0e1
544 changed files with 54548 additions and 55498 deletions

View file

@ -0,0 +1,28 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.Actor.Group.Work
{
class ContentWork
{
public GroupGlobalTemp _globalTemp = new GroupGlobalTemp();
}
}

View file

@ -0,0 +1,30 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.Actor.Group.Work
{
class GroupGlobalSave
{
public ulong master;
public ushort[] crestIcon = new ushort[4];
public byte rank = 1;
}
}

View file

@ -0,0 +1,35 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.Actor.Group.Work
{
class GroupGlobalTemp
{
public ulong owner;
//For content group
public ulong director;
//For relation group
public ulong host;
public uint variableCommand;
}
}

View file

@ -0,0 +1,35 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.Actor.Group.Work
{
class GroupMemberSave
{
//For LS
public byte rank;
//For Retainers
public byte cdIDOffset;
public ushort placeName;
public byte conditions;
public byte level;
}
}

View file

@ -0,0 +1,35 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.Actor.Group.Work
{
class LinkshellWork
{
public GroupGlobalSave _globalSave = new GroupGlobalSave();
public GroupMemberSave[] _memberSave = new GroupMemberSave[128];
public LinkshellWork()
{
for (int i = 0; i < _memberSave.Length; i++)
_memberSave[i] = new GroupMemberSave();
}
}
}

View file

@ -0,0 +1,28 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.Actor.Group.Work
{
class PartyWork
{
public GroupGlobalTemp _globalTemp = new GroupGlobalTemp();
}
}

View file

@ -0,0 +1,28 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.Actor.Group.Work
{
class RelationWork
{
public GroupGlobalTemp _globalTemp = new GroupGlobalTemp();
}
}

View file

@ -0,0 +1,34 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.Actor.Group.Work
{
class RetainerWork
{
public GroupMemberSave[] _memberSave = new GroupMemberSave[128];
public RetainerWork()
{
for (int i = 0; i < _memberSave.Length; i++)
_memberSave[i] = new GroupMemberSave();
}
}
}

11
World Server/App.config Normal file
View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/>
</startup>
<system.data>
<DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient"/>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</DbProviderFactories>
</system.data></configuration>

View file

@ -0,0 +1,117 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Linq;
using System.Net;
using Meteor.Common;
namespace Meteor.World
{
class ConfigConstants
{
public static String OPTIONS_BINDIP;
public static String OPTIONS_PORT;
public static bool OPTIONS_TIMESTAMP = false;
public static uint DATABASE_WORLDID;
public static String DATABASE_HOST;
public static String DATABASE_PORT;
public static String DATABASE_NAME;
public static String DATABASE_USERNAME;
public static String DATABASE_PASSWORD;
public static String PREF_SERVERNAME;
public static bool Load()
{
Program.Log.Info("Loading world_config.ini");
if (!File.Exists("./world_config.ini"))
{
Program.Log.Error("FILE NOT FOUND!");
Program.Log.Error("Loading defaults...");
}
INIFile configIni = new INIFile("./world_config.ini");
ConfigConstants.OPTIONS_BINDIP = configIni.GetValue("General", "server_ip", "127.0.0.1");
ConfigConstants.OPTIONS_PORT = configIni.GetValue("General", "server_port", "54992");
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_PORT = configIni.GetValue("Database", "port", "");
ConfigConstants.DATABASE_NAME = configIni.GetValue("Database", "database", "");
ConfigConstants.DATABASE_USERNAME = configIni.GetValue("Database", "username", "");
ConfigConstants.DATABASE_PASSWORD = configIni.GetValue("Database", "password", "");
return true;
}
public static void ApplyLaunchArgs(string[] launchArgs)
{
var args = (from arg in launchArgs select arg.ToLower().Trim().TrimStart('-')).ToList();
for (var i = 0; i + 1 < args.Count; i += 2)
{
var arg = args[i];
var val = args[i + 1];
var legit = false;
if (arg == "ip")
{
IPAddress ip;
if (IPAddress.TryParse(val, out ip) && (legit = true))
OPTIONS_BINDIP = val;
}
else if (arg == "port")
{
UInt16 port;
if (UInt16.TryParse(val, out port) && (legit = true))
OPTIONS_PORT = val;
}
else if (arg == "user" && (legit = true))
{
DATABASE_USERNAME = val;
}
else if (arg == "p" && (legit = true))
{
DATABASE_PASSWORD = val;
}
else if (arg == "db" && (legit = true))
{
DATABASE_NAME = val;
}
else if (arg == "host" && (legit = true))
{
DATABASE_HOST = val;
}
if (!legit)
{
Program.Log.Error("Invalid parameter <{0}> for argument: <--{1}> or argument doesnt exist!", val, arg);
}
}
}
}
}

View file

@ -0,0 +1,92 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Net.Sockets;
using System.Collections.Concurrent;
using System.Net;
using Meteor.Common;
using Meteor.World.DataObjects;
namespace Meteor.World
{
class ClientConnection
{
//Connection stuff
public Socket socket;
public byte[] buffer;
private BlockingCollection<BasePacket> SendPacketQueue = new BlockingCollection<BasePacket>(1000);
public int lastPartialSize = 0;
//Instance Stuff
public Session owner;
public void QueuePacket(BasePacket packet)
{
SendPacketQueue.Add(packet);
}
public void QueuePacket(SubPacket subpacket)
{
bool isAuthed = true;
bool isEncrypted = false;
subpacket.SetTargetId(owner.sessionId);
SendPacketQueue.Add(BasePacket.CreatePacket(subpacket, isAuthed, isEncrypted));
}
public void FlushQueuedSendPackets()
{
if (!socket.Connected)
return;
while (SendPacketQueue.Count > 0)
{
BasePacket packet = SendPacketQueue.Take();
byte[] packetBytes = packet.GetPacketBytes();
try
{
socket.Send(packetBytes);
}
catch (Exception e)
{ Program.Log.Error(e, "Weird case, socket was d/ced: {0}"); }
}
}
public String GetAddress()
{
return String.Format("{0}:{1}", (socket.RemoteEndPoint as IPEndPoint).Address, (socket.RemoteEndPoint as IPEndPoint).Port);
}
public bool IsConnected()
{
return (socket.Poll(1, SelectMode.SelectRead) && socket.Available == 0);
}
public void Disconnect()
{
if (socket.Connected)
socket.Disconnect(false);
}
}
}

View file

@ -0,0 +1,35 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.DataObjects
{
class DBWorld
{
public uint id;
public string address;
public ushort port;
public ushort listPosition;
public ushort population;
public string name;
public bool isActive;
public string motd;
}
}

View file

@ -0,0 +1,158 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using Meteor.Common;
using Meteor.World.Packets.Send.Subpackets.Groups;
namespace Meteor.World.DataObjects.Group
{
class Group
{
public const uint PlayerPartyGroup = 10001;
public const uint CompanyGroup = 20002;
public const uint GroupInvitationRelationGroup = 50001;
public const uint TradeRelationGroup = 50002;
public const uint RetainerMeetingRelationGroup = 50003;
public const uint BazaarBuyItemRelationGroup = 50009;
public const uint RetainerGroup = 80001;
public readonly ulong groupIndex;
public Group(ulong groupIndex)
{
this.groupIndex = groupIndex;
}
public virtual int GetMemberCount()
{
return 0;
}
public virtual uint GetTypeId()
{
return 0;
}
public virtual string GetGroupName()
{
return "";
}
public virtual int GetGroupLocalizedName()
{
return -1;
}
public virtual List<GroupMember> BuildMemberList(uint id)
{
return new List<GroupMember>();
}
public void SendGroupPacketsAll(params uint[] sessionIds)
{
for (int i = 0; i < sessionIds.Length; i++)
{
Session session = Server.GetServer().GetSession(sessionIds[i]);
if (session != null)
SendGroupPackets(session);
}
}
public void SendGroupPacketsAll(List<uint> sessionIds)
{
for (int i = 0; i < sessionIds.Count; i++)
{
Session session = Server.GetServer().GetSession(sessionIds[i]);
if (session != null)
SendGroupPackets(session);
}
}
public void SendDeletePackets(params uint[] sessionIds)
{
for (int i = 0; i < sessionIds.Length; i++)
{
Session session = Server.GetServer().GetSession(sessionIds[i]);
if (session != null)
SendDeletePacket(session);
}
}
public void SendDeletePackets(List<uint> sessionIds)
{
for (int i = 0; i < sessionIds.Count; i++)
{
Session session = Server.GetServer().GetSession(sessionIds[i]);
if (session != null)
SendDeletePacket(session);
}
}
public void SendGroupPackets(Session session)
{
ulong time = Utils.MilisUnixTimeStampUTC();
List<GroupMember> members = BuildMemberList(session.sessionId);
session.clientConnection.QueuePacket(GroupHeaderPacket.buildPacket(session.sessionId, session.currentZoneId, time, this));
session.clientConnection.QueuePacket(GroupMembersBeginPacket.buildPacket(session.sessionId, session.currentZoneId, time, this));
int currentIndex = 0;
while (true)
{
int memberCount = Math.Min(GetMemberCount(), members.Count);
if (memberCount - currentIndex >= 64)
session.clientConnection.QueuePacket(GroupMembersX64Packet.buildPacket(session.sessionId, session.currentZoneId, time, members, ref currentIndex));
else if (memberCount - currentIndex >= 32)
session.clientConnection.QueuePacket(GroupMembersX32Packet.buildPacket(session.sessionId, session.currentZoneId, time, members, ref currentIndex));
else if (memberCount - currentIndex >= 16)
session.clientConnection.QueuePacket(GroupMembersX16Packet.buildPacket(session.sessionId, session.currentZoneId, time, members, ref currentIndex));
else if (memberCount - currentIndex > 0)
session.clientConnection.QueuePacket(GroupMembersX08Packet.buildPacket(session.sessionId, session.currentZoneId, time, members, ref currentIndex));
else
break;
}
session.clientConnection.QueuePacket(GroupMembersEndPacket.buildPacket(session.sessionId, session.currentZoneId, time, this));
}
public void SendDeletePacket(Session session)
{
if (session != null)
session.clientConnection.QueuePacket(DeleteGroupPacket.buildPacket(session.sessionId, this));
}
public virtual void SendInitWorkValues(Session session)
{
}
}
}

View file

@ -0,0 +1,329 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using Meteor.Common;
using Meteor.World.Actor.Group.Work;
using Meteor.World.Packets.Send.Subpackets.Groups;
namespace Meteor.World.DataObjects.Group
{
class Linkshell : Group
{
public ulong dbId;
public string name;
public LinkshellWork work = new LinkshellWork();
private List<LinkshellMember> members = new List<LinkshellMember>();
public Linkshell(ulong dbId, ulong groupIndex, string name, ushort crestId, uint master, byte rank) : base(groupIndex)
{
this.dbId = dbId;
this.name = name;
work._globalSave.crestIcon[0] = crestId;
work._globalSave.master = master;
work._globalSave.rank = rank;
}
public void setMaster(uint actorId)
{
work._globalSave.master = (ulong)((0xB36F92 << 8) | actorId);
}
public void setCrest(ushort crestId)
{
work._globalSave.crestIcon[0] = crestId;
}
public void setRank(byte rank = 1)
{
work._globalSave.rank = rank;
}
public void setMemberRank(int index, byte rank)
{
if (members.Count >= index)
return;
work._memberSave[index].rank = rank;
}
public void AddMember(uint charaId, byte rank = LinkshellManager.RANK_MEMBER)
{
members.Add(new LinkshellMember(charaId, dbId, rank));
members.Sort();
}
public void RemoveMember(uint charaId)
{
for (int i = 0; i < members.Count; i++)
{
if (members[i].charaId == charaId)
{
members.Remove(members[i]);
members.Sort();
break;
}
}
}
public override int GetMemberCount()
{
return members.Count;
}
public override string GetGroupName()
{
return name;
}
public override uint GetTypeId()
{
return Group.CompanyGroup;
}
public override List<GroupMember> BuildMemberList(uint id)
{
lock (members)
{
List<GroupMember> groupMembers = new List<GroupMember>();
foreach (LinkshellMember member in members)
groupMembers.Add(new GroupMember(member.charaId, -1, 0, false, true, Server.GetServer().GetNameForId(member.charaId)));
return groupMembers;
}
}
public uint[] GetMemberIds()
{
lock (members)
{
uint[] memberIds = new uint[members.Count];
for (int i = 0; i < memberIds.Length; i++)
memberIds[i] = members[i].charaId;
return memberIds;
}
}
public override void SendInitWorkValues(Session session)
{
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupIndex);
groupWork.addProperty(this, "work._globalSave.master");
groupWork.addProperty(this, "work._globalSave.crestIcon[0]");
groupWork.addProperty(this, "work._globalSave.rank");
for (int i = 0; i < members.Count; i++)
{
work._memberSave[i].rank = members[i].rank;
groupWork.addProperty(this, String.Format("work._memberSave[{0}].rank", i));
}
groupWork.setTarget("/_init");
SubPacket test = groupWork.buildPacket(session.sessionId);
test.DebugPrintSubPacket();
session.clientConnection.QueuePacket(test);
}
public void ResendWorkValues()
{
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupIndex);
groupWork.addProperty(this, "work._globalSave.master");
groupWork.addProperty(this, "work._globalSave.crestIcon[0]");
groupWork.addProperty(this, "work._globalSave.rank");
for (int i = 0; i < members.Count; i++)
{
work._memberSave[i].rank = members[i].rank;
groupWork.addProperty(this, String.Format("work._memberSave[{0}].rank", i));
}
groupWork.setTarget("memberRank");
lock (members)
{
for (int i = 0; i < members.Count; i++)
{
Session session = Server.GetServer().GetSession(members[i].charaId);
if (session != null)
{
SubPacket test = groupWork.buildPacket(session.sessionId);
session.clientConnection.QueuePacket(test);
}
}
}
}
public void LoadMembers()
{
members = Database.GetLSMembers(this);
}
public void OnPlayerJoin(Session inviteeSession)
{
for (int i = 0; i < members.Count; i++)
{
Session session = Server.GetServer().GetSession(members[i].charaId);
if (session == null)
continue;
if (inviteeSession.Equals(session))
session.SendGameMessage(25157, 0x20, (object) 0, (object)inviteeSession, name);
else
session.SendGameMessage(25284, 0x20, (object) 0, (object)Server.GetServer().GetNameForId(inviteeSession.sessionId), name);
}
}
public LinkshellMember GetMember(string name)
{
lock (members)
{
for (int i = 0; i < members.Count; i++)
{
if (Server.GetServer().GetNameForId((members[i].charaId)).Equals(name))
return members[i];
}
return null;
}
}
public bool HasMember(uint id)
{
lock (members)
{
for (int i = 0; i < members.Count; i++)
{
if (members[i].charaId == id)
return true;
}
return false;
}
}
public void DisbandRequest(Session session)
{
throw new NotImplementedException();
}
public void LeaveRequest(Session requestSession)
{
uint leaver = requestSession.sessionId;
//Check if ls contains this person
if (!HasMember(leaver))
{
return;
}
//Send you are leaving message
requestSession.SendGameMessage(25162, 0x20, (Object)1, name);
//All good, remove
Server.GetServer().GetWorldManager().GetLinkshellManager().RemoveMemberFromLinkshell(requestSession.sessionId, name);
SendGroupPacketsAll(GetMemberIds());
ResendWorkValues();
//If active, remove it
if (requestSession.activeLinkshellName.Equals(name))
{
SubPacket activeLsPacket = SetActiveLinkshellPacket.BuildPacket(requestSession.sessionId, 0);
requestSession.clientConnection.QueuePacket(activeLsPacket);
requestSession.SetActiveLS("");
}
//Delete group for kicked guy
SendDeletePacket(requestSession);
}
public void KickRequest(Session requestSession, string kickedName)
{
LinkshellMember kicked = GetMember(kickedName);
Session kickedSession = Server.GetServer().GetSession(kicked.charaId);
//Check if ls contains this person
if (!HasMember(kicked.charaId))
{
requestSession.SendGameMessage(25281, 0x20, (Object)1, (Object)kickedName, (Object)name);
return;
}
//Send you are exiled message
lock (members)
{
for (int i = 0; i < members.Count; i++)
{
Session session = Server.GetServer().GetSession(members[i].charaId);
if (session == null)
continue;
if (session.sessionId == kicked.charaId)
session.SendGameMessage(25184, 0x20, (Object)1, (Object)name);
else
session.SendGameMessage(25280, 0x20, (Object)1, (Object)kickedName, (Object)name);
}
}
//All good, remove
Server.GetServer().GetWorldManager().GetLinkshellManager().RemoveMemberFromLinkshell(kicked.charaId, name);
SendGroupPacketsAll(GetMemberIds());
ResendWorkValues();
//If active, remove it
if (requestSession.activeLinkshellName.Equals(name))
{
SubPacket activeLsPacket = SetActiveLinkshellPacket.BuildPacket(requestSession.sessionId, 0);
requestSession.clientConnection.QueuePacket(activeLsPacket);
requestSession.SetActiveLS("");
}
//Delete group for kicked guy
SendDeletePacket(kickedSession);
}
public void RankChangeRequest(Session requestSession, string name, byte rank)
{
lock (members)
{
for (int i = 0; i < members.Count; i++)
{
if (Server.GetServer().GetNameForId(members[i].charaId).Equals(name))
{
if (Database.LinkshellChangeRank(members[i].charaId, rank))
{
members[i].rank = rank;
ResendWorkValues();
requestSession.SendGameMessage(25277, 0x20, (object)(100000 + rank), (object)name);
}
return;
}
}
}
}
}
}

View file

@ -0,0 +1,44 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
namespace Meteor.World.DataObjects.Group
{
class LinkshellMember : IComparable<LinkshellMember>
{
public readonly uint charaId;
public readonly ulong lsId;
public byte rank;
public LinkshellMember(uint charaId, ulong lsId, byte rank)
{
this.charaId = charaId;
this.lsId = lsId;
this.rank = rank;
}
public int CompareTo(LinkshellMember other)
{
return Server.GetServer().GetNameForId(charaId).CompareTo(Server.GetServer().GetNameForId(other.charaId));
}
}
}

View file

@ -0,0 +1,288 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using Meteor.Common;
using Meteor.World.Actor.Group.Work;
using Meteor.World.Packets.Send.Subpackets.Groups;
namespace Meteor.World.DataObjects.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 SetLeaderPlayerRequest(Session requestSession, string name)
{
SetLeaderPlayerRequest(requestSession, GetIdForName(name));
}
public void SetLeaderPlayerRequest(Session requestSession, uint actorId)
{
if (GetLeader() != requestSession.sessionId)
{
requestSession.SendGameMessage(30428, 0x20, Server.GetServer().GetNameForId(requestSession.sessionId));
return;
}
uint newLeader = actorId;
if (!members.Contains(actorId))
{
requestSession.SendGameMessage(30567, 0x20);
return;
}
else if (newLeader == GetLeader())
{
requestSession.SendGameMessage(30559, 0x20, (Object)Server.GetServer().GetNameForId(actorId));
return;
}
SetLeader(newLeader);
SendLeaderWorkToAllMembers();
for (int i = 0; i < members.Count; i++)
{
Session session = Server.GetServer().GetSession(members[i]);
if (session == null)
continue;
session.SendGameMessage(30429, 0x20, (Object)Server.GetServer().GetNameForId(actorId));
}
Server.GetServer().GetWorldManager().SendPartySync(this);
}
public void KickPlayerRequest(Session requestSession, string name)
{
KickPlayerRequest(requestSession, GetIdForName(name));
}
public void KickPlayerRequest(Session requestSession, uint actorId)
{
if (GetLeader() != requestSession.sessionId)
{
requestSession.SendGameMessage(30428, 0x20, Server.GetServer().GetNameForId(requestSession.sessionId));
return;
}
uint kickedMemberId = actorId;
if (!members.Contains(actorId))
{
requestSession.SendGameMessage(30575, 0x20);
return;
}
for (int i = 0; i < members.Count; i++)
{
Session session = Server.GetServer().GetSession(members[i]);
if (session == null)
continue;
if (members[i] == kickedMemberId)
session.SendGameMessage(30410, 0x20);
else
session.SendGameMessage(30428, 0x20, (Object)Server.GetServer().GetNameForId(actorId));
}
//All good, remove
Server.GetServer().GetWorldManager().GetPartyManager().RemoveFromParty(groupIndex, kickedMemberId);
SendGroupPacketsAll(members);
Server.GetServer().GetWorldManager().SendPartySync(this);
//Set the kicked guy to a new party
Session kickedSession = Server.GetServer().GetSession(kickedMemberId);
if (kickedSession != null)
{
Party kickedPlayersNewParty = Server.GetServer().GetWorldManager().GetPartyManager().CreateParty(kickedMemberId);
kickedPlayersNewParty.SendGroupPackets(kickedSession);
Server.GetServer().GetWorldManager().SendPartySync(kickedPlayersNewParty);
kickedPlayersNewParty.SendInitWorkValues(kickedSession);
}
}
public void LeavePlayerRequest(Session requestSession)
{
uint leaver = requestSession.sessionId;
//Check if party contains this person
if (!members.Contains(leaver))
{
return;
}
//Send you are leaving messages
for (int i = 0; i < members.Count; i++)
{
Session session = Server.GetServer().GetSession(members[i]);
if (session == null)
continue;
session.SendGameMessage(30431, 0x20, (Object)Server.GetServer().GetNameForId(leaver));
}
//All good, remove
Server.GetServer().GetWorldManager().GetPartyManager().RemoveFromParty(groupIndex, leaver);
SendGroupPacketsAll(members);
Server.GetServer().GetWorldManager().SendPartySync(this);
//Set the left guy to a new party
if (requestSession != null)
{
Party kickedPlayersNewParty = Server.GetServer().GetWorldManager().GetPartyManager().CreateParty(leaver);
kickedPlayersNewParty.SendGroupPackets(requestSession);
Server.GetServer().GetWorldManager().SendPartySync(kickedPlayersNewParty);
kickedPlayersNewParty.SendInitWorkValues(requestSession);
}
}
public void DisbandPlayerRequest(Session requestSession)
{
uint disbander = requestSession.sessionId;
//Check if leader
if (GetLeader() != disbander)
{
requestSession.SendGameMessage(30428, 0x20, Server.GetServer().GetNameForId(requestSession.sessionId));
return;
}
Server.GetServer().GetWorldManager().GetPartyManager().DeleteParty(groupIndex);
//Send game messages and set new parties
for (int i = 0; i < members.Count; i++)
{
Session session = Server.GetServer().GetSession(members[i]);
if (session == null)
continue;
session.SendGameMessage(30401, 0x20);
//Set char to new party
Party newParty = Server.GetServer().GetWorldManager().GetPartyManager().CreateParty(members[i]);
newParty.SendGroupPackets(session);
Server.GetServer().GetWorldManager().SendPartySync(newParty);
newParty.SendInitWorkValues(session);
}
Server.GetServer().GetWorldManager().SendPartySync(this);
}
public void SendLeaderWorkToAllMembers()
{
for (int i = 0; i < members.Count; i++)
{
SynchGroupWorkValuesPacket leaderUpdate = new SynchGroupWorkValuesPacket(groupIndex);
leaderUpdate.addProperty(this, "partyGroupWork._globalTemp.owner");
leaderUpdate.setTarget("partyGroupWork/leader");
Session session = Server.GetServer().GetSession(members[i]);
if (session == null)
continue;
else
session.clientConnection.QueuePacket(leaderUpdate.buildPacket(session.sessionId));
}
}
public void SetLeader(uint actorId)
{
partyGroupWork._globalTemp.owner = (ulong)(((ulong)actorId << 32) | 0xB36F92);
}
public uint GetLeader()
{
return (uint)(((ulong)partyGroupWork._globalTemp.owner >> 32) & 0xFFFFFFFF);
}
public uint GetIdForName(string name)
{
for (int i = 0; i < members.Count; i++)
{
if (Server.GetServer().GetNameForId(members[i]).Equals(name))
{
return members[i];
}
}
return 0;
}
public bool IsInParty(uint charaId)
{
return members.Contains(charaId);
}
public override void SendInitWorkValues(Session session)
{
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupIndex);
groupWork.addProperty(this, "partyGroupWork._globalTemp.owner");
groupWork.setTarget("/_init");
SubPacket test = groupWork.buildPacket(session.sessionId);
session.clientConnection.QueuePacket(test);
test.DebugPrintSubPacket();
}
public override int GetMemberCount()
{
return members.Count;
}
public override uint GetTypeId()
{
return Group.PlayerPartyGroup;
}
public override List<GroupMember> BuildMemberList(uint id)
{
List<GroupMember> groupMembers = new List<GroupMember>();
groupMembers.Add(new GroupMember(id, -1, 0, false, true, Server.GetServer().GetNameForId(id)));
foreach (uint charaId in members)
{
if (charaId != id)
groupMembers.Add(new GroupMember(charaId, -1, 0, false, true, Server.GetServer().GetNameForId(charaId)));
}
return groupMembers;
}
public void OnPlayerJoin(Session inviteeSession)
{
for (int i = 0; i < members.Count; i++)
{
Session session = Server.GetServer().GetSession(members[i]);
if (session == null)
continue;
session.SendGameMessage(30427, 0x20, (Object)Server.GetServer().GetNameForId(inviteeSession.sessionId));
}
}
}
}

View file

@ -0,0 +1,93 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System.Collections.Generic;
using Meteor.Common;
using Meteor.World.Actor.Group.Work;
using Meteor.World.Packets.Send.Subpackets.Groups;
namespace Meteor.World.DataObjects.Group
{
class Relation : Group
{
public RelationWork work = new RelationWork();
private uint charaOther;
private ulong topicGroup;
public Relation(ulong groupIndex, uint host, uint other, uint command, ulong topicGroup) : base (groupIndex)
{
this.charaOther = other;
work._globalTemp.host = ((ulong)host << 32) | (0xc17909);
work._globalTemp.variableCommand = command;
this.topicGroup = topicGroup;
}
public uint GetHost()
{
return (uint)(((ulong)work._globalTemp.host >> 32) & 0xFFFFFFFF);
}
public uint GetOther()
{
return charaOther;
}
public override int GetMemberCount()
{
return 2;
}
public override uint GetTypeId()
{
return Group.GroupInvitationRelationGroup;
}
public ulong GetTopicGroupIndex()
{
return topicGroup;
}
public override List<GroupMember> BuildMemberList(uint id)
{
List<GroupMember> groupMembers = new List<GroupMember>();
uint hostId = (uint)((work._globalTemp.host >> 32) & 0xFFFFFFFF);
groupMembers.Add(new GroupMember(hostId, -1, 0, false, Server.GetServer().GetSession(hostId) != null, Server.GetServer().GetNameForId(hostId)));
groupMembers.Add(new GroupMember(charaOther, -1, 0, false, Server.GetServer().GetSession(charaOther) != null, Server.GetServer().GetNameForId(charaOther)));
return groupMembers;
}
public override void SendInitWorkValues(Session session)
{
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupIndex);
groupWork.addProperty(this, "work._globalTemp.host");
groupWork.addProperty(this, "work._globalTemp.variableCommand");
groupWork.setTarget("/_init");
SubPacket test = groupWork.buildPacket(session.sessionId);
test.DebugPrintSubPacket();
session.clientConnection.QueuePacket(test);
}
}
}

View file

@ -0,0 +1,99 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using Meteor.Common;
using Meteor.World.Actor.Group.Work;
using Meteor.World.Packets.Send.Subpackets.Groups;
namespace Meteor.World.DataObjects.Group
{
class RetainerGroup : Group
{
public RetainerWork work = new RetainerWork();
public uint owner;
public List<RetainerGroupMember> members = new List<RetainerGroupMember>();
public RetainerGroup(ulong groupId, uint owner) : base(groupId)
{
this.owner = owner;
}
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 SendInitWorkValues(Session session)
{
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupIndex);
for (int i = 0; i < members.Count; i++)
{
work._memberSave[i].cdIDOffset = members[i].cdIDOffset;
work._memberSave[i].placeName = members[i].placeName;
work._memberSave[i].conditions = members[i].conditions;
work._memberSave[i].level = members[i].level;
groupWork.addProperty(this, String.Format("work._memberSave[{0}].cdIDOffset", i));
groupWork.addProperty(this, String.Format("work._memberSave[{0}].placeName", i));
groupWork.addProperty(this, String.Format("work._memberSave[{0}].conditions", i));
groupWork.addProperty(this, String.Format("work._memberSave[{0}].level", i));
}
groupWork.setTarget("/_init");
SubPacket test = groupWork.buildPacket(session.sessionId);
session.clientConnection.QueuePacket(test);
}
public override int GetMemberCount()
{
return members.Count + 1;
}
public override uint GetTypeId()
{
return Group.RetainerGroup;
}
public override List<GroupMember> BuildMemberList(uint id)
{
List<GroupMember> groupMembers = new List<GroupMember>();
//Add retainers
foreach (RetainerGroupMember member in members)
groupMembers.Add(new GroupMember(member.id, -1, 0, false, true, member.name));
//Add player
groupMembers.Add(new GroupMember(owner, -1, 0, false, true, Server.GetServer().GetNameForId(owner)));
return groupMembers;
}
}
}

View file

@ -0,0 +1,45 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.DataObjects.Group
{
class RetainerGroupMember
{
public uint id;
public string name;
public uint classActorId;
public byte cdIDOffset;
public ushort placeName;
public byte conditions;
public byte level;
public RetainerGroupMember(uint id, string name, uint classActorId, byte cdIDOffset, ushort placeName, byte conditions, byte level)
{
this.id = id;
this.name = name;
this.classActorId = classActorId;
this.cdIDOffset = cdIDOffset;
this.placeName = placeName;
this.conditions = conditions;
this.level = level;
}
}
}

View file

@ -0,0 +1,51 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using Meteor.Common;
using Meteor.World.Packets.Send.Subpackets.Groups;
namespace Meteor.World.DataObjects.Group
{
class RetainerMeetingRelationGroup : Relation
{
public RetainerMeetingRelationGroup(ulong groupIndex, uint host, uint other, uint command, ulong topicGroup)
: base(groupIndex, host, other, command, topicGroup)
{
}
public override uint GetTypeId()
{
return Group.RetainerMeetingRelationGroup;
}
public override void SendInitWorkValues(Session session)
{
SynchGroupWorkValuesPacket groupWork = new SynchGroupWorkValuesPacket(groupIndex);
groupWork.setTarget("/_init");
SubPacket test = groupWork.buildPacket(session.sessionId);
test.DebugPrintSubPacket();
session.clientConnection.QueuePacket(test);
}
}
}

View file

@ -0,0 +1,37 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
namespace Meteor.World.DataObjects
{
class LuaParam
{
public int typeID;
public Object value;
public LuaParam(int type, Object value)
{
this.typeID = type;
this.value = value;
}
}
}

View file

@ -0,0 +1,406 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Meteor.Common;
namespace Meteor.World.DataObjects
{
class LuaUtils
{
public class Type7Param
{
public uint actorId;
public byte unknown;
public byte slot;
public byte inventoryType;
public Type7Param(uint actorId, byte unknown, byte slot, byte inventoryType)
{
this.actorId = actorId;
this.unknown = unknown;
this.slot = slot;
this.inventoryType = inventoryType;
}
}
public class Type9Param
{
public ulong item1;
public ulong item2;
public Type9Param(ulong item1, ulong item2)
{
this.item1 = item1;
this.item2 = item2;
}
}
public static List<LuaParam> ReadLuaParams(BinaryReader reader)
{
List<LuaParam> luaParams = new List<LuaParam>();
bool isDone = false;
while (true)
{
byte code = reader.ReadByte();
object value = null;
bool wasNil = false;
switch (code)
{
case 0x0: //Int32
value = Utils.SwapEndian(reader.ReadInt32());
break;
case 0x1: //Int32
value = Utils.SwapEndian(reader.ReadUInt32());
break;
case 0x2: //Null Termed String
List<byte> list = new List<byte>();
while(true){
byte readByte = reader.ReadByte();
if (readByte == 0)
break;
list.Add(readByte);
}
value = Encoding.ASCII.GetString(list.ToArray());
break;
case 0x3: //Boolean True
value = true;
break;
case 0x4: //Boolean False
value = false;
break;
case 0x5: //Nil
wasNil = true;
break;
case 0x6: //Actor (By Id)
value = Utils.SwapEndian(reader.ReadUInt32());
break;
case 0x7: //Weird one used for inventory
uint type7ActorId = Utils.SwapEndian(reader.ReadUInt32());
byte type7Unknown = reader.ReadByte();
byte type7Slot = reader.ReadByte();
byte type7InventoryType = reader.ReadByte();
value = new Type7Param(type7ActorId, type7Unknown, type7Slot, type7InventoryType);
break;
case 0x9: //Two Longs (only storing first one)
value = new Type9Param(Utils.SwapEndian(reader.ReadUInt64()), Utils.SwapEndian(reader.ReadUInt64()));
break;
case 0xC: //Byte
value = reader.ReadByte();
break;
case 0x1B: //Short?
value = reader.ReadUInt16();
break;
case 0xF: //End
isDone = true;
continue;
}
if (isDone)
break;
if (value != null)
luaParams.Add(new LuaParam(code, value));
else if (wasNil)
luaParams.Add(new LuaParam(code, value));
}
return luaParams;
}
public static void WriteLuaParams(BinaryWriter writer, List<LuaParam> luaParams)
{
foreach (LuaParam l in luaParams)
{
if (l.typeID == 0x1)
writer.Write((Byte)0);
else
writer.Write((Byte)l.typeID);
switch (l.typeID)
{
case 0x0: //Int32
writer.Write((Int32)Utils.SwapEndian((Int32)l.value));
break;
case 0x1: //Int32
writer.Write((UInt32)Utils.SwapEndian((UInt32)l.value));
break;
case 0x2: //Null Termed String
string sv = (string)l.value;
writer.Write(Encoding.ASCII.GetBytes(sv), 0, Encoding.ASCII.GetByteCount(sv));
writer.Write((Byte)0);
break;
case 0x3: //Boolean True
break;
case 0x4: //Boolean False
break;
case 0x5: //Nil
break;
case 0x6: //Actor (By Id)
writer.Write((UInt32)Utils.SwapEndian((UInt32)l.value));
break;
case 0x7: //Weird one used for inventory
Type7Param type7 = (Type7Param)l.value;
writer.Write((UInt32)Utils.SwapEndian((UInt32)type7.actorId));
writer.Write((Byte)type7.unknown);
writer.Write((Byte)type7.slot);
writer.Write((Byte)type7.inventoryType);
break;
case 0x9: //Two Longs (only storing first one)
writer.Write((UInt64)Utils.SwapEndian(((Type9Param)l.value).item1));
writer.Write((UInt64)Utils.SwapEndian(((Type9Param)l.value).item2));
break;
case 0xC: //Byte
writer.Write((Byte)l.value);
break;
case 0x1B: //Short?
break;
case 0xF: //End
continue;
}
}
writer.Write((Byte)0xF);
}
public static List<LuaParam> ReadLuaParams(byte[] bytesIn)
{
List<LuaParam> luaParams = new List<LuaParam>();
using (MemoryStream memStream = new MemoryStream(bytesIn))
{
using (BinaryReader reader = new BinaryReader(memStream))
{
bool isDone = false;
while (true)
{
byte code = reader.ReadByte();
object value = null;
bool wasNil = false;
switch (code)
{
case 0x0: //Int32
value = Utils.SwapEndian(reader.ReadInt32());
break;
case 0x1: //Int32
value = Utils.SwapEndian(reader.ReadUInt32());
break;
case 0x2: //Null Termed String
List<byte> list = new List<byte>();
while (true)
{
byte readByte = reader.ReadByte();
if (readByte == 0)
break;
list.Add(readByte);
}
value = Encoding.ASCII.GetString(list.ToArray());
break;
case 0x3: //Boolean True
value = true;
break;
case 0x4: //Boolean False
value = false;
break;
case 0x5: //Nil
wasNil = true;
break;
case 0x6: //Actor (By Id)
value = Utils.SwapEndian(reader.ReadUInt32());
break;
case 0x7: //Weird one used for inventory
uint type7ActorId = Utils.SwapEndian(reader.ReadUInt32());
byte type7Unknown = reader.ReadByte();
byte type7Slot = reader.ReadByte();
byte type7InventoryType = reader.ReadByte();
value = new Type7Param(type7ActorId, type7Unknown, type7Slot, type7InventoryType);
break;
case 0x9: //Two Longs (only storing first one)
value = new Type9Param(Utils.SwapEndian(reader.ReadUInt64()), Utils.SwapEndian(reader.ReadUInt64()));
break;
case 0xC: //Byte
value = reader.ReadByte();
break;
case 0x1B: //Short?
value = reader.ReadUInt16();
break;
case 0xF: //End
isDone = true;
continue;
}
if (isDone)
break;
if (value != null)
luaParams.Add(new LuaParam(code, value));
else if (wasNil)
luaParams.Add(new LuaParam(code, value));
}
}
}
return luaParams;
}
public static List<LuaParam> CreateLuaParamList(params object[] list)
{
List<LuaParam> luaParams = new List<LuaParam>();
foreach (object o in list)
{
if (o != null && o.GetType().IsArray)
{
Array arrayO = (Array)o;
foreach (object o2 in arrayO)
AddToList(o2, luaParams);
}
else
AddToList(o, luaParams);
}
return luaParams;
}
private static void AddToList(object o, List<LuaParam> luaParams)
{
if (o is int)
{
luaParams.Add(new LuaParam(0x0, (int)o));
}
else if (o is uint)
{
luaParams.Add(new LuaParam(0x1, (uint)o));
}
else if (o is Double)
{
if (((double)o) % 1 == 0)
luaParams.Add(new LuaParam(0x0, (int)(double)o));
}
else if (o is string)
{
luaParams.Add(new LuaParam(0x2, (string)o));
}
else if (o is bool)
{
if (((bool)o))
luaParams.Add(new LuaParam(0x3, null));
else
luaParams.Add(new LuaParam(0x4, null));
}
else if (o == null)
{
luaParams.Add(new LuaParam(0x5, null));
}
else if (o is Session)
{
luaParams.Add(new LuaParam(0x6, (uint)((Session)o).sessionId));
}
else if (o is Type7Param)
{
luaParams.Add(new LuaParam(0x7, (Type7Param)o));
}
else if (o is Type9Param)
{
luaParams.Add(new LuaParam(0x9, (Type9Param)o));
}
else if (o is byte)
{
luaParams.Add(new LuaParam(0xC, (byte)o));
}
}
public static object[] CreateLuaParamObjectList(List <LuaParam> luaParams)
{
object[] list = new object[luaParams.Count];
for (int i = 0; i < list.Length; i++)
list[i] = luaParams[i].value;
return list;
}
public static string DumpParams(List<LuaParam> lParams)
{
if (lParams == null)
return "Param list was null?";
string dumpString = "";
for (int i = 0; i < lParams.Count; i++)
{
switch (lParams[i].typeID)
{
case 0x0: //Int32
dumpString += String.Format("0x{0:X}", (int)lParams[i].value);
break;
case 0x1: //Int32
dumpString += String.Format("0x{0:X}", (uint)lParams[i].value);
break;
case 0x2: //Null Termed String
dumpString += String.Format("\"{0}\"", (string)lParams[i].value);
break;
case 0x3: //Boolean True
dumpString += "true";
break;
case 0x4: //Boolean False
dumpString += "false";
break;
case 0x5: //NULL???
dumpString += "nil";
break;
case 0x6: //Actor (By Id)
dumpString += String.Format("0x{0:X}", (uint)lParams[i].value);
break;
case 0x7: //Weird one used for inventory
Type7Param type7Param = ((Type7Param)lParams[i].value);
dumpString += String.Format("Type7 Param: (0x{0:X}, 0x{1:X}, 0x{2:X}, 0x{3:X})", type7Param.actorId, type7Param.unknown, type7Param.slot, type7Param.inventoryType);
break;
case 0xC: //Byte
dumpString += String.Format("0x{0:X}", (byte)lParams[i].value);
break;
case 0x9: //Long (+ 8 bytes ignored)
Type9Param type9Param = ((Type9Param)lParams[i].value);
dumpString += String.Format("Type9 Param: (0x{0:X}, 0x{1:X})", type9Param.item1, type9Param.item2);
break;
case 0x1B: //Short?
dumpString += String.Format("0x{0:X}", (ushort)lParams[i].value);
break;
case 0xF: //End
break;
}
if (i != lParams.Count - 1)
dumpString += ", ";
}
return dumpString;
}
}
}

View file

@ -0,0 +1,94 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using Meteor.World.Packets.Send.Subpackets;
namespace Meteor.World.DataObjects
{
class Session
{
public enum Channel {ZONE, CHAT};
public readonly uint sessionId;
public string characterName;
public uint currentZoneId;
public string activeLinkshellName = "";
public readonly ClientConnection clientConnection;
public readonly Channel type;
public ZoneServer routing1, routing2;
public Session(uint sessionId, ClientConnection connection, Channel type)
{
this.sessionId = sessionId;
this.clientConnection = connection;
this.type = type;
connection.owner = this;
Database.LoadZoneSessionInfo(this);
}
public void SendGameMessage(uint actorId, ushort textId, byte log, params object[] msgParams)
{
if (msgParams == null || msgParams.Length == 0)
{
clientConnection.QueuePacket(GameMessagePacket.BuildPacket(0x5FF80001, actorId, 0x5FF80001, textId, log));
}
else
clientConnection.QueuePacket(GameMessagePacket.BuildPacket(0x5FF80001, actorId, 0x5FF80001, textId, log, LuaUtils.CreateLuaParamList(msgParams)));
}
public void SendGameMessage( ushort textId, byte log, params object[] msgParams)
{
if (msgParams == null || msgParams.Length == 0)
clientConnection.QueuePacket(GameMessagePacket.BuildPacket(0x5FF80001, 0x5FF80001, textId, log));
else
clientConnection.QueuePacket(GameMessagePacket.BuildPacket(0x5FF80001, 0x5FF80001, textId, log, LuaUtils.CreateLuaParamList(msgParams)));
}
public void SendGameMessage( ushort textId, byte log, string customSender, params object[] msgParams)
{
if (msgParams == null || msgParams.Length == 0)
clientConnection.QueuePacket(GameMessagePacket.BuildPacket(0x5FF80001, 0x5FF80001, textId, customSender, log));
else
clientConnection.QueuePacket(GameMessagePacket.BuildPacket(0x5FF80001, 0x5FF80001, textId, customSender, log, LuaUtils.CreateLuaParamList(msgParams)));
}
public void SendGameMessage(ushort textId, byte log, uint displayId, params object[] msgParams)
{
if (msgParams == null || msgParams.Length == 0)
clientConnection.QueuePacket(GameMessagePacket.BuildPacket(0x5FF80001, 0x5FF80001, textId, displayId, log));
else
clientConnection.QueuePacket(GameMessagePacket.BuildPacket(0x5FF80001, 0x5FF80001, textId, displayId, log, LuaUtils.CreateLuaParamList(msgParams)));
}
public bool SetActiveLS(string name)
{
if (Database.SetActiveLS(this, name))
{
activeLinkshellName = name;
return true;
}
return false;
}
}
}

View file

@ -0,0 +1,188 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using Meteor.Common;
using Meteor.World.Packets.WorldPackets.Send;
namespace Meteor.World.DataObjects
{
class ZoneServer
{
public readonly string zoneServerIp;
public readonly int zoneServerPort;
public readonly List<uint> ownedZoneIds;
public bool isConnected = false;
public Socket zoneServerConnection;
private ClientConnection conn;
private byte[] buffer = new byte[0xFFFF];
public ZoneServer(string ip, int port, uint firstId)
{
zoneServerIp = ip;
zoneServerPort = port;
ownedZoneIds = new List<uint>();
ownedZoneIds.Add(firstId);
}
public void AddLoadedZone(uint id)
{
ownedZoneIds.Add(id);
}
public bool Connect()
{
Program.Log.Info("Connecting to zone server @ {0}:{1}", zoneServerIp, zoneServerPort);
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse(zoneServerIp), zoneServerPort);
zoneServerConnection = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
try
{
zoneServerConnection.Connect(remoteEP);
isConnected = true;
conn = new ClientConnection();
conn.socket = zoneServerConnection;
conn.buffer = new byte[0xFFFF];
try
{
zoneServerConnection.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), conn);
}
catch (Exception e)
{
throw new ApplicationException("Error occured starting listeners, check inner exception", e);
}
}
catch (Exception)
{ Program.Log.Error("Failed to connect"); return false; }
return true;
}
public void SendPacket(SubPacket subpacket)
{
if (isConnected)
{
byte[] packetBytes = subpacket.GetBytes();
try
{
zoneServerConnection.Send(packetBytes);
}
catch (Exception e)
{ Program.Log.Error(e, "Weird case, socket was d/ced: {0}"); }
}
else
{
if (Connect())
SendPacket(subpacket);
}
}
private void ReceiveCallback(IAsyncResult result)
{
ClientConnection conn = (ClientConnection)result.AsyncState;
//Check if disconnected
if ((conn.socket.Poll(1, SelectMode.SelectRead) && conn.socket.Available == 0))
{
conn = null;
isConnected = false;
Program.Log.Info("Zone server @ {0}:{1} disconnected!", zoneServerIp, zoneServerPort);
return;
}
try
{
int bytesRead = conn.socket.EndReceive(result);
bytesRead += conn.lastPartialSize;
if (bytesRead >= 0)
{
int offset = 0;
//Build packets until can no longer or out of data
while (true)
{
SubPacket subpacket = SubPacket.CreatePacket(ref offset, conn.buffer, bytesRead);
//If can't build packet, break, else process another
if (subpacket == null)
break;
else
Server.GetServer().OnReceiveSubPacketFromZone(this, subpacket);
}
//Not all bytes consumed, transfer leftover to beginning
if (offset < bytesRead)
Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset);
conn.lastPartialSize = bytesRead - offset;
//Build any queued subpackets into basepackets and send
conn.FlushQueuedSendPackets();
if (offset < bytesRead)
//Need offset since not all bytes consumed
conn.socket.BeginReceive(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset), SocketFlags.None, new AsyncCallback(ReceiveCallback), conn);
else
//All bytes consumed, full buffer available
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), conn);
}
else
{
conn = null;
isConnected = false;
Program.Log.Info("Zone server @ {0}:{1} disconnected!", zoneServerIp, zoneServerPort);
}
}
catch (SocketException)
{
conn = null;
isConnected = false;
Program.Log.Info("Zone server @ {0}:{1} disconnected!", zoneServerIp, zoneServerPort);
}
}
public void SendSessionStart(Session session, bool isLogin = false)
{
SendPacket(SessionBeginPacket.BuildPacket(session, isLogin));
}
public void SendSessionEnd(Session session)
{
SendPacket(SessionEndPacket.BuildPacket(session));
}
public void SendSessionEnd(Session session, uint destinationZoneId, string destinationPrivateArea, byte spawnType, float spawnX, float spawnY, float spawnZ, float spawnRotation)
{
SendPacket(SessionEndPacket.BuildPacket(session, destinationZoneId, destinationPrivateArea, spawnType, spawnX, spawnY, spawnZ, spawnRotation));
}
}
}

586
World Server/Database.cs Normal file
View file

@ -0,0 +1,586 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using Meteor.World.DataObjects;
using Meteor.World.DataObjects.Group;
using MySql.Data.MySqlClient;
namespace Meteor.World
{
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)
{
string characterName, currentLinkshell;
uint currentZone = 0;
uint destinationZone = 0;
bool readIn = false;
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT name, currentZoneId, destinationZoneId, currentActiveLinkshell FROM characters WHERE id = @charaId", conn);
cmd.Parameters.AddWithValue("@charaId", session.sessionId);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
characterName = Reader.GetString("name");
currentZone = Reader.GetUInt32("currentZoneId");
destinationZone = Reader.GetUInt32("destinationZoneId");
currentLinkshell = Reader.GetString("currentActiveLinkshell");
session.characterName = characterName;
session.currentZoneId = currentZone;
session.activeLinkshellName = currentLinkshell;
readIn = true;
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return readIn;
}
public static void GetAllCharaNames(Dictionary<uint, string> mIdToNameMap)
{
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT id, name FROM characters", conn);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
uint id = Reader.GetUInt32("id");
string name = Reader.GetString("name");
mIdToNameMap.Add(id, name);
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
}
public static uint GetCurrentZoneForSession(uint charId)
{
uint currentZone = 0;
uint destinationZone = 0;
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT currentZoneId, destinationZoneId FROM characters WHERE id = @charaId", conn);
cmd.Parameters.AddWithValue("@charaId", charId);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
currentZone = Reader.GetUInt32("currentZoneId");
destinationZone = Reader.GetUInt32("destinationZoneId");
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
if (currentZone == 0 && destinationZone != 0)
return destinationZone;
if (currentZone != 0 && destinationZone == 0)
return currentZone;
else
{
return 0;
}
}
public static List<RetainerGroupMember> GetRetainers(uint charaId)
{
List<RetainerGroupMember> members = new List<RetainerGroupMember>();
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT id, name, actorClassId, cdIDOffset, placeName, conditions, level FROM server_retainers INNER JOIN characters_retainers ON retainerId = server_retainers.id WHERE characterId = @charaId", conn);
cmd.Parameters.AddWithValue("@charaId", charaId);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
uint id = Reader.GetUInt32("id") | 0xE0000000;
string name = Reader.GetString("name");
uint actorClassId = Reader.GetUInt32("actorClassId");
byte cdIDOffset = Reader.GetByte("cdIDOffset");
ushort placeName = Reader.GetUInt16("placeName");
byte conditions = Reader.GetByte("conditions");
byte level = Reader.GetByte("level");
members.Add(new RetainerGroupMember(id, name, actorClassId, cdIDOffset, placeName, conditions, level));
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return members;
}
public static Linkshell GetLinkshell(ulong groupIndex, string lsName)
{
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT id, name, crestIcon, master FROM server_linkshells WHERE name = @lsName", conn);
cmd.Parameters.AddWithValue("@lsName", lsName);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
ulong lsId = Reader.GetUInt64("id");
string name = Reader.GetString("name");
ushort crest = Reader.GetUInt16("crestIcon");
uint master = Reader.GetUInt32("master");
Linkshell linkshell = new Linkshell(lsId, groupIndex, name, crest, master, 0xa);
return linkshell;
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return null;
}
public static Linkshell GetLinkshell(ulong groupIndex, ulong lsId)
{
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT name, crestIcon, master FROM server_linkshells WHERE id = @lsId", conn);
cmd.Parameters.AddWithValue("@lsId", lsId);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
string name = Reader.GetString("name");
ushort crest = Reader.GetUInt16("crestIcon");
uint master = Reader.GetUInt32("master");
Linkshell linkshell = new Linkshell(lsId, groupIndex, name, crest, master, 0xa);
return linkshell;
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return null;
}
public static List<LinkshellMember> GetLSMembers(Linkshell ls)
{
List<LinkshellMember> memberList = new List<LinkshellMember>();
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT characterId, linkshellId, rank FROM characters_linkshells WHERE linkshellId = @lsId", conn);
cmd.Parameters.AddWithValue("@lsId", ls.dbId);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
uint characterId = Reader.GetUInt32("characterId");
ulong linkshellId = Reader.GetUInt64("linkshellId");
byte rank = Reader.GetByte("rank");
LinkshellMember member = new LinkshellMember(characterId, linkshellId, rank);
memberList.Add(member);
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
memberList.Sort();
return memberList;
}
public static List<LinkshellMember> GetPlayerLSMembership(uint charaId)
{
List<LinkshellMember> memberList = new List<LinkshellMember>();
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT characterId, linkshellId, rank FROM characters_linkshells WHERE characterId = @charaId", conn);
cmd.Parameters.AddWithValue("@charaId", charaId);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
while (Reader.Read())
{
uint characterId = Reader.GetUInt32("characterId");
ulong linkshellId = Reader.GetUInt64("linkshellId");
byte rank = Reader.GetByte("rank");
LinkshellMember member = new LinkshellMember(characterId, linkshellId, rank);
memberList.Add(member);
}
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return memberList;
}
public static ulong CreateLinkshell(string name, ushort crest, uint master)
{
string query;
MySqlCommand cmd;
ulong lastId = 0;
using (MySqlConnection 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)))
{
try
{
conn.Open();
query = @"
INSERT INTO server_linkshells
(name, crestIcon, master, rank)
VALUES
(@name, @crestIcon, @master, @rank)
";
cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@crestIcon", crest);
cmd.Parameters.AddWithValue("@master", master);
cmd.Parameters.AddWithValue("@rank", 0xa);
if (cmd.ExecuteNonQuery() == 1)
lastId = (ulong)cmd.LastInsertedId;
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return lastId;
}
public static bool DeleteLinkshell(ulong lsId)
{
throw new NotImplementedException();
}
public static bool LinkshellAddPlayer(ulong lsId, uint charaId, byte rank = LinkshellManager.RANK_MEMBER)
{
string query;
MySqlCommand cmd;
using (MySqlConnection 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)))
{
try
{
conn.Open();
query = @"
INSERT INTO characters_linkshells
(characterId, linkshellId, rank)
VALUES
(@charaId, @lsId, @rank)
";
cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@charaId", charaId);
cmd.Parameters.AddWithValue("@lsId", lsId);
cmd.Parameters.AddWithValue("@rank", rank);
cmd.ExecuteNonQuery();
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
conn.Dispose();
return false;
}
finally
{
conn.Dispose();
}
}
return true;
}
public static bool LinkshellRemovePlayer(ulong lsId, uint charaId)
{
bool success = false;
using (MySqlConnection 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)))
{
try
{
conn.Open();
string query = @"
DELETE FROM characters_linkshells
WHERE characterId = @charaId AND linkshellId = @lsId;
";
MySqlCommand cmd = new MySqlCommand(query, conn);
cmd.Parameters.AddWithValue("@charaId", charaId);
cmd.Parameters.AddWithValue("@lsId", lsId);
cmd.ExecuteNonQuery();
success = true;
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return success;
}
public static bool ChangeLinkshellCrest(ulong lsId, ushort newCrestId)
{
bool success = false;
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("UPDATE server_linkshells SET crestIcon = @crestIcon WHERE id = @lsId", conn);
cmd.Parameters.AddWithValue("@lsId", lsId);
cmd.Parameters.AddWithValue("@crestIcon", newCrestId);
cmd.ExecuteNonQuery();
success = true;
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return success;
}
public static bool LinkshellChangeRank(uint charaId, byte rank)
{
bool success = false;
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("UPDATE characters_linkshells SET rank = @rank WHERE characterId = @charaId", conn);
cmd.Parameters.AddWithValue("@charaId", charaId);
cmd.Parameters.AddWithValue("@rank", rank);
cmd.ExecuteNonQuery();
success = true;
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return success;
}
public static bool SetActiveLS(Session session, string name)
{
bool success = false;
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("UPDATE characters SET currentActiveLinkshell = @lsName WHERE id = @charaId", conn);
cmd.Parameters.AddWithValue("@charaId", session.sessionId);
cmd.Parameters.AddWithValue("@lsName", name);
cmd.ExecuteNonQuery();
success = true;
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return success;
}
public static bool LinkshellIsBannedName(string name)
{
return false;
}
public static bool LinkshellExists(string name)
{
bool hasLS = false;
using (MySqlConnection 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)))
{
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand("SELECT * FROM server_linkshells WHERE name = @lsName", conn);
cmd.Parameters.AddWithValue("@lsName", name);
object result = cmd.ExecuteScalar();
hasLS = result != null && ((uint)result > 0);
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
}
finally
{
conn.Dispose();
}
}
return hasLS;
}
}
}

View file

@ -0,0 +1,271 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using Meteor.World.DataObjects.Group;
namespace Meteor.World
{
class LinkshellManager
{
public const int LS_MAX_ALLOWED = 8;
public const int LS_MAX_MEMBERS = 128;
public const byte RANK_GUEST = 0x1;
public const byte RANK_MEMBER = 0x4;
public const byte RANK_LEADER = 0x7;
public const byte RANK_MASTER = 0xA;
private WorldManager mWorldManager;
private Object mGroupLockReference;
private Dictionary<ulong, Group> mCurrentWorldGroupsReference; //GroupId, LS
private Dictionary<ulong, Linkshell> mLinkshellList = new Dictionary<ulong, Linkshell>(); //GroupId, LS
private Dictionary<ulong, Linkshell> mLSIdToIdLookup = new Dictionary<ulong, Linkshell>(); //Name, GroupId
private Dictionary<string, ulong> mNameToIdLookup = new Dictionary<string, ulong>(); //Name, GroupId
public LinkshellManager(WorldManager worldManager, Object groupLock, Dictionary<ulong, Group> worldGroupList)
{
mWorldManager = worldManager;
mGroupLockReference = groupLock;
mCurrentWorldGroupsReference = worldGroupList;
}
//Checks if the LS name is in use or banned
public int CanCreateLinkshell(string name)
{
bool nameBanned = Database.LinkshellIsBannedName(name);
bool alreadyExists = Database.LinkshellExists(name);
if (nameBanned)
return 2;
if (alreadyExists)
return 1;
else
return 0;
}
//Creates a new linkshell and adds it to the list
public Linkshell CreateLinkshell(string name, ushort crest, uint master)
{
lock (mGroupLockReference)
{
ulong resultId = Database.CreateLinkshell(name, crest, master);
if (resultId >= 0)
{
Linkshell newLs = new Linkshell(resultId, mWorldManager.GetGroupIndex(), name, crest, master, RANK_MASTER);
mLinkshellList.Add(mWorldManager.GetGroupIndex(), newLs);
mNameToIdLookup.Add(newLs.name, newLs.groupIndex);
mLSIdToIdLookup.Add(newLs.dbId, newLs);
mCurrentWorldGroupsReference.Add(mWorldManager.GetGroupIndex(), newLs);
mWorldManager.IncrementGroupIndex();
//Add founder to the LS
AddMemberToLinkshell(master, newLs.name, RANK_MASTER);
return newLs;
}
return null;
}
}
//Modifies the LS master
public bool ChangeLinkshellMaster(string name, uint newMaster)
{
ulong groupInstanceId;
if (mNameToIdLookup.ContainsKey(name))
groupInstanceId = mNameToIdLookup[name];
else
return false;
if (mCurrentWorldGroupsReference.ContainsKey(groupInstanceId))
{
Linkshell ls = (Linkshell)mCurrentWorldGroupsReference[groupInstanceId];
return false;
}
return false;
}
//Modifies the LS crest
public bool ChangeLinkshellCrest(string name, ushort newCrestId)
{
ulong groupInstanceId;
if (mNameToIdLookup.ContainsKey(name))
groupInstanceId = mNameToIdLookup[name];
else
return false;
if (mCurrentWorldGroupsReference.ContainsKey(groupInstanceId))
{
Linkshell ls = (Linkshell)mCurrentWorldGroupsReference[groupInstanceId];
return Database.ChangeLinkshellCrest(ls.dbId, newCrestId);
}
return false;
}
//Deletes a LS
public bool DeleteLinkshell(string name)
{
lock (mGroupLockReference)
{
ulong groupInstanceId;
if (mNameToIdLookup.ContainsKey(name))
groupInstanceId = mNameToIdLookup[name];
else
return false;
if (mCurrentWorldGroupsReference.ContainsKey(groupInstanceId))
{
Linkshell ls = (Linkshell)mCurrentWorldGroupsReference[groupInstanceId];
bool result = Database.DeleteLinkshell(ls.dbId);
if (result)
{
mCurrentWorldGroupsReference.Remove(groupInstanceId);
mLinkshellList.Remove(groupInstanceId);
mNameToIdLookup.Remove(name);
return true;
}
}
}
return false;
}
//Adds a player to the linkshell
public bool AddMemberToLinkshell(uint charaId, string LSName, byte rank = RANK_MEMBER)
{
//Get the LS
Linkshell ls = GetLinkshell(LSName);
if (ls == null)
return false;
//Add player to ls in db
lock (mGroupLockReference)
{
bool result = Database.LinkshellAddPlayer(ls.dbId, charaId, rank);
if (result)
{
ls.AddMember(charaId, rank);
return true;
}
else
return false;
}
}
//Removes a player from the linkshell
public bool RemoveMemberFromLinkshell(uint charaId, string LSName)
{
//Get the LS
Linkshell ls = GetLinkshell(LSName);
if (ls == null)
return false;
//Delete the player in the db
lock (mGroupLockReference)
{
bool result = Database.LinkshellRemovePlayer(ls.dbId, charaId);
if (!result)
return false;
//Remove from group instance
ls.RemoveMember(charaId);
return true;
}
}
//Get a single linkshell group either already instantiated or make one from the db by Name
public Linkshell GetLinkshell(string name)
{
if (mNameToIdLookup.ContainsKey(name))
return (Linkshell)mCurrentWorldGroupsReference[mNameToIdLookup[name]];
else
{
lock (mGroupLockReference)
{
Linkshell ls = Database.GetLinkshell(mWorldManager.GetGroupIndex(), name);
if (ls == null)
return null;
ls.LoadMembers();
if (ls != null)
{
mLinkshellList.Add(ls.groupIndex, ls);
mNameToIdLookup.Add(ls.name, ls.groupIndex);
mLSIdToIdLookup.Add(ls.dbId, ls);
mCurrentWorldGroupsReference.Add(ls.groupIndex, ls);
mWorldManager.IncrementGroupIndex();
return ls;
}
else
return null;
}
}
}
//Get a single linkshell group either already instantiated or make one from the db by ID
public Linkshell GetLinkshell(ulong lsId)
{
if (mLSIdToIdLookup.ContainsKey(lsId))
return (Linkshell)mCurrentWorldGroupsReference[mLSIdToIdLookup[lsId].groupIndex];
else
{
lock (mGroupLockReference)
{
Linkshell ls = Database.GetLinkshell(mWorldManager.GetGroupIndex(), lsId);
ls.LoadMembers();
if (ls != null)
{
mLinkshellList.Add(ls.groupIndex, ls);
mNameToIdLookup.Add(ls.name, ls.groupIndex);
mLSIdToIdLookup.Add(ls.dbId, ls);
mCurrentWorldGroupsReference.Add(ls.groupIndex, ls);
mWorldManager.IncrementGroupIndex();
return ls;
}
else
return null;
}
}
}
//Get the linkshells player is part of
public List<Linkshell> GetPlayerLinkshellMembership(uint charaId)
{
List<LinkshellMember> memberships = Database.GetPlayerLSMembership(charaId);
List<Linkshell> linkshells = new List<Linkshell>();
foreach (LinkshellMember membership in memberships)
linkshells.Add(GetLinkshell(membership.lsId));
return linkshells;
}
}
}

62
World Server/NLog.config Normal file
View file

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variabeles
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue" />
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets async="true">
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<!--
Write events to a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
<!--<target xsi:type="ColoredConsole" name="console" layout="[${longdate}] [${uppercase:${level}}] ${message}" />-->
<target xsi:type="File" name="file" fileName="${basedir}/logs/${shortdate}/map.log"
layout="[${date:format=dd MMM yyyy HH\:mm\:ss.fff}] [${uppercase:${level}}] ${message}" />
<target xsi:type="ColoredConsole" name="console"
layout="[${date:format=dd MMM yyyy HH\:mm\:ss.fff}] [${uppercase:${level}}] ${message}" />
<target xsi:type="ColoredConsole" name="packets"
layout="${message}">
<highlight-row
condition="equals('${logger}', 'FFXIVClassic.Common.BasePacket') and equals('${event-context:item=color}', '6')"
backgroundColor="DarkYellow" foregroundColor="NoChange" />
<highlight-row
condition="equals('${logger}', 'FFXIVClassic.Common.SubPacket') and equals('${event-context:item=color}', '4')"
backgroundColor="DarkRed" foregroundColor="NoChange" />
<highlight-row
condition="equals('${logger}', 'FFXIVClassic.Common.SubPacket') and equals('${event-context:item=color}', '5')"
backgroundColor="DarkMagenta" foregroundColor="NoChange" />
</target>
</targets>
<rules>
<!-- add your logging rules here -->
<logger name='*' minlevel='Trace' writeTo='file' />
<logger name='FFXIVClassic_World_Server.Program' minlevel='Trace' writeTo='console' />
<logger name='FFXIVClassic.Common.*' minlevel='Debug' writeTo='packets' />
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
</rules>
</nlog>

2601
World Server/NLog.xsd Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,200 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System.Collections.Generic;
using Meteor.Common;
using Meteor.World.DataObjects;
using Meteor.World.DataObjects.Group;
using Meteor.World.Packets.Receive;
using Meteor.World.Packets.Receive.Subpackets;
using Meteor.World.Packets.Send;
using Meteor.World.Packets.Send.Login;
using Meteor.World.Packets.Send.Subpackets;
using Meteor.World.Packets.WorldPackets.Receive;
namespace Meteor.World
{
class PacketProcessor
{
/*
Session Creation:
Get 0x1 from server
Send 0x7
Send 0x2
Zone Change:
Send 0x7
Get 0x8 - Wait??
Send 0x2
*/
Server mServer;
public PacketProcessor(Server server)
{
mServer = server;
}
public void ProcessPacket(ClientConnection client, BasePacket packet)
{
if (packet.header.isCompressed == 0x01)
BasePacket.DecompressPacket(ref packet);
List<SubPacket> subPackets = packet.GetSubpackets();
foreach (SubPacket subpacket in subPackets)
{
//Initial Connect Packet, Create session
if (subpacket.header.type == 0x01)
{
HelloPacket hello = new HelloPacket(packet.data);
if (packet.header.connectionType == BasePacket.TYPE_ZONE)
{
mServer.AddSession(client, Session.Channel.ZONE, hello.sessionId);
Session session = mServer.GetSession(hello.sessionId);
session.routing1 = mServer.GetWorldManager().GetZoneServer(session.currentZoneId);
session.routing1.SendSessionStart(session, true);
}
else if (packet.header.connectionType == BasePacket.TYPE_CHAT)
mServer.AddSession(client, Session.Channel.CHAT, hello.sessionId);
client.QueuePacket(_0x7Packet.BuildPacket(0x0E016EE5));
client.QueuePacket(_0x2Packet.BuildPacket(hello.sessionId));
}
//Ping from World Server
else if (subpacket.header.type == 0x07)
{
SubPacket init = _0x8PingPacket.BuildPacket(client.owner.sessionId);
client.QueuePacket(BasePacket.CreatePacket(init, true, false));
}
//Zoning Related
else if (subpacket.header.type == 0x08)
{
//Response, client's current [actorID][time]
//BasePacket init = Login0x7ResponsePacket.BuildPacket(BitConverter.ToUInt32(packet.data, 0x10), Utils.UnixTimeStampUTC(), 0x07);
//client.QueuePacket(init);
packet.DebugPrintPacket();
}
//Game Message
else if (subpacket.header.type == 0x03)
{
//Send to the correct zone server
uint targetSession = subpacket.header.targetId;
InterceptProcess(mServer.GetSession(targetSession), subpacket);
if (mServer.GetSession(targetSession).routing1 != null)
mServer.GetSession(targetSession).routing1.SendPacket(subpacket);
if (mServer.GetSession(targetSession).routing2 != null)
mServer.GetSession(targetSession).routing2.SendPacket(subpacket);
}
//World Server Type
else if (subpacket.header.type >= 0x1000)
{
uint targetSession = subpacket.header.targetId;
Session session = mServer.GetSession(targetSession);
switch (subpacket.header.type)
{
//Session Begin Confirm
case 0x1000:
SessionBeginConfirmPacket beginConfirmPacket = new SessionBeginConfirmPacket(packet.data);
if (beginConfirmPacket.invalidPacket || beginConfirmPacket.errorCode == 0)
Program.Log.Error("Session {0} had a error beginning session.", beginConfirmPacket.sessionId);
break;
//Session End Confirm
case 0x1001:
SessionEndConfirmPacket endConfirmPacket = new SessionEndConfirmPacket(packet.data);
if (!endConfirmPacket.invalidPacket && endConfirmPacket.errorCode != 0)
{
//Check destination, if != 0, update route and start new session
if (endConfirmPacket.destinationZone != 0)
{
session.currentZoneId = endConfirmPacket.destinationZone;
session.routing1 = Server.GetServer().GetWorldManager().GetZoneServer(endConfirmPacket.destinationZone);
session.routing1.SendSessionStart(session);
}
else
{
mServer.RemoveSession(Session.Channel.ZONE, endConfirmPacket.sessionId);
mServer.RemoveSession(Session.Channel.CHAT, endConfirmPacket.sessionId);
}
}
else
Program.Log.Error("Session {0} had an error ending session.", endConfirmPacket.sessionId);
break;
//Zone Change Request
case 0x1002:
WorldRequestZoneChangePacket zoneChangePacket = new WorldRequestZoneChangePacket(packet.data);
if (!zoneChangePacket.invalidPacket)
{
mServer.GetWorldManager().DoZoneServerChange(session, zoneChangePacket.destinationZoneId, "", zoneChangePacket.destinationSpawnType, zoneChangePacket.destinationX, zoneChangePacket.destinationY, zoneChangePacket.destinationZ, zoneChangePacket.destinationRot);
}
break;
}
}
else
packet.DebugPrintPacket();
}
}
public void InterceptProcess(Session session, SubPacket subpacket)
{
switch (subpacket.gameMessage.opcode)
{
case 0x00C9:
subpacket.DebugPrintSubPacket();
PartyChatMessagePacket partyChatMessagePacket = new PartyChatMessagePacket(subpacket.data);
Party playerParty = mServer.GetWorldManager().GetPartyManager().GetParty(session.sessionId);
for (int i = 0; i < playerParty.members.Count; i++)
{
Session thatSession = mServer.GetSession(playerParty.members[i]);
if (thatSession != null && !session.Equals(thatSession))
{
thatSession.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, thatSession.sessionId, SendMessagePacket.MESSAGE_TYPE_PARTY, mServer.GetNameForId(session.sessionId), partyChatMessagePacket.message));
}
}
break;
case 0x6:
mServer.GetWorldManager().DoLogin(session);
break;
//Special case for groups. If it's a world group, send values, else send to zone server
case 0x133:
GroupCreatedPacket groupCreatedPacket = new GroupCreatedPacket(subpacket.data);
if (!mServer.GetWorldManager().SendGroupInit(session, groupCreatedPacket.groupId))
session.clientConnection.QueuePacket(subpacket);
break;
}
}
}
}

View file

@ -0,0 +1,54 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.Receive
{
class HelloPacket
{
public bool invalidPacket = false;
public uint sessionId;
public HelloPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
byte[] readIn = new byte[12];
binReader.BaseStream.Seek(0x14, SeekOrigin.Begin);
binReader.Read(readIn, 0, 12);
sessionId = UInt32.Parse(Encoding.ASCII.GetString(readIn));
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,63 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.Receive.Subpackets
{
class ChatMessagePacket
{
public float posX;
public float posY;
public float posZ;
public float posRot;
public uint logType;
public string message;
public bool invalidPacket = false;
public ChatMessagePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try{
binReader.ReadUInt64();
posX = binReader.ReadSingle();
posY = binReader.ReadSingle();
posZ = binReader.ReadSingle();
posRot = binReader.ReadSingle();
logType = binReader.ReadUInt32();
message = Encoding.ASCII.GetString(binReader.ReadBytes(0x200)).Trim(new [] { '\0' });
}
catch (Exception){
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,53 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.Receive.Subpackets
{
class GroupCreatedPacket
{
public ulong groupId;
public string workString;
public bool invalidPacket = false;
public GroupCreatedPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try{
groupId = binReader.ReadUInt64();
workString = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
}
catch (Exception){
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,52 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.Receive.Subpackets
{
class PartyChatMessagePacket
{
public uint actorId;
public string message;
public bool invalidPacket = false;
public PartyChatMessagePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try{
actorId = binReader.ReadUInt32();
message = Encoding.ASCII.GetString(binReader.ReadBytes(0x200)).Trim(new [] { '\0' });
}
catch (Exception){
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,371 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Meteor.Common;
using Meteor.World.DataObjects;
namespace Meteor.World.Packets.Send.Subpackets
{
class GameMessagePacket
{
private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR1 = 0x157;
private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR2 = 0x158;
private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR3 = 0x159;
private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR4 = 0x15a;
private const ushort OPCODE_GAMEMESSAGE_WITH_ACTOR5 = 0x15b;
private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER1 = 0x15c;
private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 = 0x15d;
private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 = 0x15e;
private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 = 0x15f;
private const ushort OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 = 0x160;
private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER1 = 0x161;
private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER2 = 0x162;
private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER3 = 0x163;
private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER4 = 0x164;
private const ushort OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER5 = 0x165;
private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR1 = 0x166;
private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR2 = 0x167;
private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR3 = 0x168;
private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR4 = 0x169;
private const ushort OPCODE_GAMEMESSAGE_WITHOUT_ACTOR5 = 0x16a;
private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR1 = 0x30;
private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR2 = 0x38;
private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR3 = 0x40;
private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR4 = 0x50;
private const ushort SIZE_GAMEMESSAGE_WITH_ACTOR5 = 0x70;
private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER1 = 0x48;
private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 = 0x58;
private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 = 0x68;
private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 = 0x78;
private const ushort SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 = 0x98;
private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER1 = 0x30;
private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER2 = 0x38;
private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER3 = 0x40;
private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER4 = 0x50;
private const ushort SIZE_GAMEMESSAGE_WITH_DISPID_SENDER5 = 0x60;
private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR1 = 0x28;
private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR2 = 0x38;
private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR3 = 0x38;
private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR4 = 0x48;
private const ushort SIZE_GAMEMESSAGE_WITHOUT_ACTOR5 = 0x68;
public static SubPacket BuildPacket(uint sourceId, uint actorId, uint textOwnerActorId, ushort textId, byte log)
{
byte[] data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR1 - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)actorId);
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
}
}
return new SubPacket(OPCODE_GAMEMESSAGE_WITH_ACTOR1, sourceId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint actorId, uint textOwnerActorId, ushort textId, byte log, List<LuaParam> lParams)
{
int lParamsSize = findSizeOfParams(lParams);
byte[] data;
ushort opcode;
if (lParamsSize <= 0x8)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR2 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR2;
}
else if (lParamsSize <= 0x10)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR3 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR3;
}
else if (lParamsSize <= 0x20)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR4 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR4;
}
else
{
data = new byte[SIZE_GAMEMESSAGE_WITH_ACTOR5 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_ACTOR5;
}
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)actorId);
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
LuaUtils.WriteLuaParams(binWriter, lParams);
if (lParamsSize <= 0x14-12)
{
binWriter.Seek(0x14, SeekOrigin.Begin);
binWriter.Write((UInt32)8);
}
}
}
return new SubPacket(opcode, sourceId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint textOwnerActorId, ushort textId, string sender, byte log)
{
byte[] data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER1 - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
binWriter.Write(Encoding.ASCII.GetBytes(sender), 0, Encoding.ASCII.GetByteCount(sender) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sender));
}
}
return new SubPacket(OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER1, sourceId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint textOwnerActorId, ushort textId, string sender, byte log, List<LuaParam> lParams)
{
int lParamsSize = findSizeOfParams(lParams);
byte[] data;
ushort opcode;
if (lParamsSize <= 0x8)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER2 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER2;
}
else if (lParamsSize <= 0x10)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER3 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER3;
}
else if (lParamsSize <= 0x20)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER4 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER4;
}
else
{
data = new byte[SIZE_GAMEMESSAGE_WITH_CUSTOM_SENDER5 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_CUSTOM_SENDER5;
}
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
binWriter.Write(Encoding.ASCII.GetBytes(sender), 0, Encoding.ASCII.GetByteCount(sender) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sender));
LuaUtils.WriteLuaParams(binWriter, lParams);
if (lParamsSize <= 0x14 - 12)
{
binWriter.Seek(0x30, SeekOrigin.Begin);
binWriter.Write((UInt32)8);
}
}
}
return new SubPacket(opcode, sourceId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint textOwnerActorId, ushort textId, uint senderDisplayNameId, byte log)
{
byte[] data = new byte[SIZE_GAMEMESSAGE_WITH_DISPID_SENDER1 - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)senderDisplayNameId);
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
}
}
return new SubPacket(OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER1, sourceId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint textOwnerActorId, ushort textId, uint senderDisplayNameId, byte log, List<LuaParam> lParams)
{
int lParamsSize = findSizeOfParams(lParams);
byte[] data;
ushort opcode;
if (lParamsSize <= 0x8)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_DISPID_SENDER2 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER2;
}
else if (lParamsSize <= 0x10)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_DISPID_SENDER3 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER3;
}
else if (lParamsSize <= 0x20)
{
data = new byte[SIZE_GAMEMESSAGE_WITH_DISPID_SENDER4 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER4;
}
else
{
data = new byte[SIZE_GAMEMESSAGE_WITH_DISPID_SENDER5 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITH_DISPID_SENDER5;
}
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)senderDisplayNameId);
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
LuaUtils.WriteLuaParams(binWriter, lParams);
if (lParamsSize <= 0x14 - 12)
{
binWriter.Seek(0x14, SeekOrigin.Begin);
binWriter.Write((UInt32)8);
}
}
}
return new SubPacket(opcode, sourceId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint textOwnerActorId, ushort textId, byte log)
{
byte[] data = new byte[SIZE_GAMEMESSAGE_WITHOUT_ACTOR1 - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
}
}
return new SubPacket(OPCODE_GAMEMESSAGE_WITHOUT_ACTOR1, sourceId, data);
}
public static SubPacket BuildPacket(uint sourceId, uint textOwnerActorId, ushort textId, byte log, List<LuaParam> lParams)
{
int lParamsSize = findSizeOfParams(lParams);
byte[] data;
ushort opcode;
if (lParamsSize <= 0x8)
{
data = new byte[SIZE_GAMEMESSAGE_WITHOUT_ACTOR2 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITHOUT_ACTOR2;
}
else if (lParamsSize <= 0x10)
{
data = new byte[SIZE_GAMEMESSAGE_WITHOUT_ACTOR3 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITHOUT_ACTOR3;
}
else if (lParamsSize <= 0x20)
{
data = new byte[SIZE_GAMEMESSAGE_WITHOUT_ACTOR4 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITHOUT_ACTOR4;
}
else
{
data = new byte[SIZE_GAMEMESSAGE_WITHOUT_ACTOR5 - 0x20];
opcode = OPCODE_GAMEMESSAGE_WITHOUT_ACTOR5;
}
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt32)textOwnerActorId);
binWriter.Write((UInt16)textId);
binWriter.Write((UInt16)log);
LuaUtils.WriteLuaParams(binWriter, lParams);
if (lParamsSize <= 0x8)
{
binWriter.Seek(0x10, SeekOrigin.Begin);
binWriter.Write((UInt32)8);
}
}
}
return new SubPacket(opcode, sourceId, data);
}
private static int findSizeOfParams(List<LuaParam> lParams)
{
int total = 0;
foreach (LuaParam l in lParams)
{
switch (l.typeID)
{
case 0:
case 1:
total += 5;
break;
case 2:
total += 1 + 0x20;
break;
case 6:
total += 5;
break;
case 3:
case 4:
case 5:
total += 1;
break;
}
}
return total + 1;
}
}
}

View file

@ -0,0 +1,59 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
using Meteor.Common;
using Meteor.World.DataObjects.Group;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class CreateNamedGroup
{
public const ushort OPCODE = 0x0188;
public const uint PACKET_SIZE = 0x60;
public static SubPacket buildPacket(uint sessionId, Group group)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt64)group.groupIndex);
binWriter.Write((UInt32)group.GetTypeId());
binWriter.Write((Int32)group.GetGroupLocalizedName());
binWriter.Write((UInt16)0x121C);
binWriter.Seek(0x20, SeekOrigin.Begin);
binWriter.Write(Encoding.ASCII.GetBytes(group.GetGroupName()), 0, Encoding.ASCII.GetByteCount(group.GetGroupName()) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(group.GetGroupName()));
}
}
return new SubPacket(OPCODE, sessionId, data);
}
}
}

View file

@ -0,0 +1,73 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
using Meteor.Common;
using Meteor.World.DataObjects.Group;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class CreateNamedGroupMultiple
{
public const ushort OPCODE = 0x0189;
public const uint PACKET_SIZE = 0x228;
public static SubPacket buildPacket(uint playerActorID, Group[] groups, ref int offset)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
int max = 8;
if (groups.Length - offset <= 8)
max = groups.Length - offset;
for (int i = 0; i < max; i++)
{
binWriter.Seek(i * 0x40, SeekOrigin.Begin);
Group group = groups[offset+i];
binWriter.Write((UInt64)group.groupIndex);
binWriter.Write((UInt32)group.GetTypeId());
binWriter.Write((Int32)group.GetGroupLocalizedName());
binWriter.Write((UInt16)0x121C);
binWriter.Seek(0x20, SeekOrigin.Begin);
binWriter.Write(Encoding.ASCII.GetBytes(group.GetGroupName()), 0, Encoding.ASCII.GetByteCount(group.GetGroupName()) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(group.GetGroupName()));
}
binWriter.Seek(0x200, SeekOrigin.Begin);
binWriter.Write((Byte)max);
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
}
}

View file

@ -0,0 +1,61 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
using Meteor.World.DataObjects.Group;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class DeleteGroupPacket
{
public const ushort OPCODE = 0x0143;
public const uint PACKET_SIZE = 0x40;
public static SubPacket buildPacket(uint sessionId, Group group)
{
return buildPacket(sessionId, group.groupIndex);
}
public static SubPacket buildPacket(uint sessionId, ulong groupId)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
//Write control num ????
binWriter.Write((UInt64)3);
//Write Ids
binWriter.Write((UInt64)groupId);
binWriter.Write((UInt64)0);
binWriter.Write((UInt64)groupId);
}
}
return new SubPacket(OPCODE, sessionId, data);
}
}
}

View file

@ -0,0 +1,81 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
using Meteor.Common;
using Meteor.World.DataObjects.Group;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class GroupHeaderPacket
{
public const uint TYPEID_RETAINER = 0x13881;
public const uint TYPEID_PARTY = 0x2711;
public const uint TYPEID_LINKSHELL = 0x4E22;
public const ushort OPCODE = 0x017C;
public const uint PACKET_SIZE = 0x98;
public static SubPacket buildPacket(uint playerActorID, uint locationCode, ulong sequenceId, Group group)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
//Write list header
binWriter.Write((UInt64)locationCode);
binWriter.Write((UInt64)sequenceId);
//Write list id
binWriter.Write((UInt64)3);
binWriter.Write((UInt64)group.groupIndex);
binWriter.Write((UInt64)0);
binWriter.Write((UInt64)group.groupIndex);
//This seems to change depending on what the list is for
binWriter.Write((UInt32)group.GetTypeId());
binWriter.Seek(0x40, SeekOrigin.Begin);
//This is for Linkshell
binWriter.Write((UInt32)group.GetGroupLocalizedName());
binWriter.Write(Encoding.ASCII.GetBytes(group.GetGroupName()), 0, Encoding.ASCII.GetByteCount(group.GetGroupName()) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(group.GetGroupName()));
binWriter.Seek(0x64, SeekOrigin.Begin);
//Does this change chat????
binWriter.Write((UInt32)0x6D);
binWriter.Write((UInt32)0x6D);
binWriter.Write((UInt32)0x6D);
binWriter.Write((UInt32)0x6D);
binWriter.Write((UInt32)group.GetMemberCount());
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
}
}

View file

@ -0,0 +1,43 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class GroupMember
{
public uint actorId;
public int localizedName;
public uint unknown2;
public bool flag1;
public bool isOnline;
public string name;
public GroupMember(uint actorId, int localizedName, uint unknown2, bool flag1, bool isOnline, string name)
{
this.actorId = actorId;
this.localizedName = localizedName;
this.unknown2 = unknown2;
this.flag1 = flag1;
this.isOnline = isOnline;
this.name = name;
}
}
}

View file

@ -0,0 +1,55 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
using Meteor.World.DataObjects.Group;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class GroupMembersBeginPacket
{
public const ushort OPCODE = 0x017D;
public const uint PACKET_SIZE = 0x40;
public static SubPacket buildPacket(uint playerActorID, uint locationCode, ulong sequenceId, Group group)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
//Write List Header
binWriter.Write((UInt64)locationCode);
binWriter.Write((UInt64)sequenceId);
//Write List Info
binWriter.Write((UInt64)group.groupIndex);
binWriter.Write((UInt32)group.GetMemberCount());
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
}
}

View file

@ -0,0 +1,55 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
using Meteor.World.DataObjects.Group;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class GroupMembersEndPacket
{
public const ushort OPCODE = 0x017E;
public const uint PACKET_SIZE = 0x38;
public static SubPacket buildPacket(uint sessionId, uint locationCode, ulong sequenceId, Group group)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
//Write List Header
binWriter.Write((UInt64)locationCode);
binWriter.Write((UInt64)sequenceId);
//Write List Info
binWriter.Write((UInt64)group.groupIndex);
}
}
return new SubPacket(OPCODE, sessionId, data);
}
}
}

View file

@ -0,0 +1,74 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Meteor.Common;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class GroupMembersX08Packet
{
public const ushort OPCODE = 0x017F;
public const uint PACKET_SIZE = 0x1B8;
public static SubPacket buildPacket(uint playerActorID, uint locationCode, ulong sequenceId, List<GroupMember> entries, ref int offset)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
//Write List Header
binWriter.Write((UInt64)locationCode);
binWriter.Write((UInt64)sequenceId);
//Write Entries
int max = 8;
if (entries.Count-offset < 8)
max = entries.Count - offset;
for (int i = 0; i < max; i++)
{
binWriter.Seek(0x10 + (0x30 * i), SeekOrigin.Begin);
GroupMember entry = entries[i];
binWriter.Write((UInt32)entry.actorId);
binWriter.Write((Int32)entry.localizedName);
binWriter.Write((UInt32)entry.unknown2);
binWriter.Write((Byte)(entry.flag1? 1 : 0));
binWriter.Write((Byte)(entry.isOnline? 1 : 0));
binWriter.Write(Encoding.ASCII.GetBytes(entry.name), 0, Encoding.ASCII.GetByteCount(entry.name) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(entry.name));
offset++;
}
//Write Count
binWriter.Seek(0x10 + (0x30 * 8), SeekOrigin.Begin);
binWriter.Write(max);
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
}
}

View file

@ -0,0 +1,71 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Meteor.Common;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class GroupMembersX16Packet
{
public const ushort OPCODE = 0x0180;
public const uint PACKET_SIZE = 0x330;
public static SubPacket buildPacket(uint playerActorID, uint locationCode, ulong sequenceId, List<GroupMember> entries, ref int offset)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
//Write List Header
binWriter.Write((UInt64)locationCode);
binWriter.Write((UInt64)sequenceId);
//Write Entries
int max = 16;
if (entries.Count-offset < 16)
max = entries.Count - offset;
for (int i = 0; i < max; i++)
{
binWriter.Seek(0x10 + (0x30 * i), SeekOrigin.Begin);
GroupMember entry = entries[i];
binWriter.Write((UInt32)entry.actorId);
binWriter.Write((Int32)entry.localizedName);
binWriter.Write((UInt32)entry.unknown2);
binWriter.Write((Byte)(entry.flag1? 1 : 0));
binWriter.Write((Byte)(entry.isOnline? 1 : 0));
binWriter.Write(Encoding.ASCII.GetBytes(entry.name), 0, Encoding.ASCII.GetByteCount(entry.name) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(entry.name));
offset++;
}
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
}
}

View file

@ -0,0 +1,71 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Meteor.Common;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class GroupMembersX32Packet
{
public const ushort OPCODE = 0x0181;
public const uint PACKET_SIZE = 0x630;
public static SubPacket buildPacket(uint playerActorID, uint locationCode, ulong sequenceId, List<GroupMember> entries, ref int offset)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
//Write List Header
binWriter.Write((UInt64)locationCode);
binWriter.Write((UInt64)sequenceId);
//Write Entries
int max = 32;
if (entries.Count-offset < 32)
max = entries.Count - offset;
for (int i = 0; i < max; i++)
{
binWriter.Seek(0x10 + (0x30 * i), SeekOrigin.Begin);
GroupMember entry = entries[i];
binWriter.Write((UInt32)entry.actorId);
binWriter.Write((Int32)entry.localizedName);
binWriter.Write((UInt32)entry.unknown2);
binWriter.Write((Byte)(entry.flag1? 1 : 0));
binWriter.Write((Byte)(entry.isOnline? 1 : 0));
binWriter.Write(Encoding.ASCII.GetBytes(entry.name), 0, Encoding.ASCII.GetByteCount(entry.name) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(entry.name));
offset++;
}
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
}
}

View file

@ -0,0 +1,71 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Meteor.Common;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class GroupMembersX64Packet
{
public const ushort OPCODE = 0x0182;
public const uint PACKET_SIZE = 0xC30;
public static SubPacket buildPacket(uint playerActorID, uint locationCode, ulong sequenceId, List<GroupMember> entries, ref int offset)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
//Write List Header
binWriter.Write((UInt64)locationCode);
binWriter.Write((UInt64)sequenceId);
//Write Entries
int max = 64;
if (entries.Count - offset < 64)
max = entries.Count - offset;
for (int i = 0; i < max; i++)
{
binWriter.Seek(0x10 + (0x30 * i), SeekOrigin.Begin);
GroupMember entry = entries[i];
binWriter.Write((UInt32)entry.actorId);
binWriter.Write((Int32)entry.localizedName);
binWriter.Write((UInt32)entry.unknown2);
binWriter.Write((Byte)(entry.flag1? 1 : 0));
binWriter.Write((Byte)(entry.isOnline? 1 : 0));
binWriter.Write(Encoding.ASCII.GetBytes(entry.name), 0, Encoding.ASCII.GetByteCount(entry.name) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(entry.name));
offset++;
}
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
}
}

View file

@ -0,0 +1,60 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
using Meteor.World.DataObjects.Group;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class SetActiveLinkshellPacket
{
public const ushort OPCODE = 0x018A;
public const uint PACKET_SIZE = 0x98;
public static SubPacket BuildPacket(uint sessionId, ulong groupId)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
//Write the LS groupId
binWriter.Write((UInt64)groupId);
//Write the LS group type
binWriter.Seek(0x40, SeekOrigin.Begin);
binWriter.Write((UInt32)Group.CompanyGroup);
//Seems to be a index but can only set one active so /shrug
binWriter.Seek(0x60, SeekOrigin.Begin);
binWriter.Write((UInt32)(groupId == 0 ? 0 : 1));
}
}
return new SubPacket(OPCODE, sessionId, data);
}
}
}

View file

@ -0,0 +1,230 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Meteor.Common;
using Meteor.World.DataObjects.Group;
namespace Meteor.World.Packets.Send.Subpackets.Groups
{
class SynchGroupWorkValuesPacket
{
public const ushort OPCODE = 0x017A;
public const uint PACKET_SIZE = 0xB0;
private const ushort MAXBYTES = 0x98;
private ushort runningByteTotal = 0;
private byte[] data = new byte[PACKET_SIZE - 0x20];
private bool isMore = false;
private MemoryStream mem;
private BinaryWriter binWriter;
public SynchGroupWorkValuesPacket(ulong listId)
{
mem = new MemoryStream(data);
binWriter = new BinaryWriter(mem);
binWriter.Write((UInt64)listId);
binWriter.Seek(1, SeekOrigin.Current);
}
public void closeStreams()
{
binWriter.Dispose();
mem.Dispose();
}
public bool addByte(uint id, byte value)
{
if (runningByteTotal + 6 > MAXBYTES)
return false;
binWriter.Write((byte)1);
binWriter.Write((UInt32)id);
binWriter.Write((byte)value);
runningByteTotal += 6;
return true;
}
public bool addShort(uint id, ushort value)
{
if (runningByteTotal + 7 > MAXBYTES)
return false;
binWriter.Write((byte)2);
binWriter.Write((UInt32)id);
binWriter.Write((UInt16)value);
runningByteTotal += 7;
return true;
}
public bool addInt(uint id, uint value)
{
if (runningByteTotal + 9 > MAXBYTES)
return false;
binWriter.Write((byte)4);
binWriter.Write((UInt32)id);
binWriter.Write((UInt32)value);
runningByteTotal += 9;
return true;
}
public bool addLong(uint id, ulong value)
{
if (runningByteTotal + 13 > MAXBYTES)
return false;
binWriter.Write((byte)8);
binWriter.Write((UInt32)id);
binWriter.Write((UInt64)value);
runningByteTotal += 13;
return true;
}
public bool addBuffer(uint id, byte[] buffer)
{
if (runningByteTotal + 5 + buffer.Length > MAXBYTES)
return false;
binWriter.Write((byte)buffer.Length);
binWriter.Write((UInt32)id);
binWriter.Write(buffer);
runningByteTotal += (ushort)(5 + buffer.Length);
return true;
}
public void addProperty(Group group, string name)
{
string[] split = name.Split('.');
int arrayIndex = 0;
if (!(split[0].Equals("work") || split[0].Equals("partyGroupWork")))
return;
Object curObj = group;
for (int i = 0; i < split.Length; i++)
{
//For arrays
if (split[i].Contains('['))
{
if (split[i].LastIndexOf(']') - split[i].IndexOf('[') <= 0)
return;
arrayIndex = Convert.ToInt32(split[i].Substring(split[i].IndexOf('[') + 1, split[i].Length - split[i].LastIndexOf(']')));
split[i] = split[i].Substring(0, split[i].IndexOf('['));
if (i != split.Length - 1)
{
curObj = curObj.GetType().GetField(split[i]).GetValue(curObj);
curObj = ((Array)curObj).GetValue(arrayIndex);
i++;
}
}
FieldInfo field = curObj.GetType().GetField(split[i]);
if (field == null)
return;
curObj = field.GetValue(curObj);
if (curObj == null)
return;
}
if (curObj == null)
return;
else
{
//Array, we actually care whats inside
if (curObj.GetType().IsArray)
{
if (((Array)curObj).Length <= arrayIndex)
return;
curObj = ((Array)curObj).GetValue(arrayIndex);
}
if (curObj == null)
return;
//Cast to the proper object and add to packet
uint id = Utils.MurmurHash2(name, 0);
if (curObj is bool)
addByte(id, (byte)(((bool)curObj) ? 1 : 0));
else if (curObj is byte)
addByte(id, (byte)curObj);
else if (curObj is ushort)
addShort(id, (ushort)curObj);
else if (curObj is short)
addShort(id, (ushort)(short)curObj);
else if (curObj is uint)
addInt(id, (uint)curObj);
else if (curObj is int)
addInt(id, (uint)(int)curObj);
else if (curObj is long)
addLong(id, (ulong)(long)curObj);
else if (curObj is ulong)
addLong(id, (ulong)curObj);
else if (curObj is float)
addBuffer(id, BitConverter.GetBytes((float)curObj));
else
return;
}
}
public void setIsMore(bool flag)
{
isMore = flag;
}
public void setTarget(string target)
{
binWriter.Write((byte)(isMore ? 0x62 + target.Length : 0x82 + target.Length));
binWriter.Write(Encoding.ASCII.GetBytes(target));
runningByteTotal += (ushort)(1 + Encoding.ASCII.GetByteCount(target));
}
public SubPacket buildPacket(uint playerActorID)
{
binWriter.Seek(0x8, SeekOrigin.Begin);
binWriter.Write((byte)runningByteTotal);
closeStreams();
SubPacket packet = new SubPacket(OPCODE, playerActorID, data);
return packet;
}
}
}

View file

@ -0,0 +1,79 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
using Meteor.Common;
namespace Meteor.World.Packets.Send.Subpackets
{
class SendMessagePacket
{
public const int MESSAGE_TYPE_NONE = 0;
public const int MESSAGE_TYPE_SAY = 1;
public const int MESSAGE_TYPE_SHOUT = 2;
public const int MESSAGE_TYPE_TELL = 3;
public const int MESSAGE_TYPE_PARTY = 4;
public const int MESSAGE_TYPE_LINKSHELL1 = 5;
public const int MESSAGE_TYPE_LINKSHELL2 = 6;
public const int MESSAGE_TYPE_LINKSHELL3 = 7;
public const int MESSAGE_TYPE_LINKSHELL4 = 8;
public const int MESSAGE_TYPE_LINKSHELL5 = 9;
public const int MESSAGE_TYPE_LINKSHELL6 = 10;
public const int MESSAGE_TYPE_LINKSHELL7 = 11;
public const int MESSAGE_TYPE_LINKSHELL8 = 12;
public const int MESSAGE_TYPE_SAY_SPAM = 22;
public const int MESSAGE_TYPE_SHOUT_SPAM = 23;
public const int MESSAGE_TYPE_TELL_SPAM = 24;
public const int MESSAGE_TYPE_CUSTOM_EMOTE = 25;
public const int MESSAGE_TYPE_EMOTE_SPAM = 26;
public const int MESSAGE_TYPE_STANDARD_EMOTE = 27;
public const int MESSAGE_TYPE_URGENT_MESSAGE = 28;
public const int MESSAGE_TYPE_GENERAL_INFO = 29;
public const int MESSAGE_TYPE_SYSTEM = 32;
public const int MESSAGE_TYPE_SYSTEM_ERROR = 33;
public const ushort OPCODE = 0x0003;
public const uint PACKET_SIZE = 0x248;
public static SubPacket BuildPacket(uint playerActorID, uint targetID, uint messageType, string sender, string message)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write(Encoding.ASCII.GetBytes(sender), 0, Encoding.ASCII.GetByteCount(sender) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(sender));
binWriter.BaseStream.Seek(0x20, SeekOrigin.Begin);
binWriter.Write((UInt32)messageType);
binWriter.Write(Encoding.ASCII.GetBytes(message), 0, Encoding.ASCII.GetByteCount(message) >= 0x200 ? 0x200 : Encoding.ASCII.GetByteCount(message));
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
}
}

View file

@ -0,0 +1,65 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
namespace Meteor.World.Packets.Send
{
class _0x2Packet
{
public const ushort OPCODE = 0x0002;
public const uint PACKET_SIZE = 0x38;
public static SubPacket BuildPacket(uint actorID)
{
byte[] data = {
0x6c, 0x00, 0x00, 0x00, 0xC8, 0xD6, 0xAF, 0x2B, 0x38, 0x2B, 0x5F, 0x26, 0xB8, 0x8D, 0xF0, 0x2B,
0xC8, 0xFD, 0x85, 0xFE, 0xA8, 0x7C, 0x5B, 0x09, 0x38, 0x2B, 0x5F, 0x26, 0xC8, 0xD6, 0xAF, 0x2B,
0xB8, 0x8D, 0xF0, 0x2B, 0x88, 0xAF, 0x5E, 0x26
};
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
try
{
binWriter.Seek(0, SeekOrigin.Begin);
binWriter.Write((UInt32)actorID);
}
catch (Exception)
{ }
}
}
/*
0x6c, 0x00, 0x00, 0x00, 0xC8, 0xD6, 0xAF, 0x2B, 0x38, 0x2B, 0x5F, 0x26, 0xB8, 0x8D, 0xF0, 0x2B,
0xC8, 0xFD, 0x85, 0xFE, 0xA8, 0x7C, 0x5B, 0x09, 0x38, 0x2B, 0x5F, 0x26, 0xC8, 0xD6, 0xAF, 0x2B,
0xB8, 0x8D, 0xF0, 0x2B, 0x88, 0xAF, 0x5E, 0x26
*/
return new SubPacket(false, OPCODE, 0, data);
}
}
}

View file

@ -0,0 +1,55 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
namespace Meteor.World.Packets.Send
{
class _0x7Packet
{
public const ushort OPCODE = 0x0007;
public const uint PACKET_SIZE = 0x18;
public static SubPacket BuildPacket(uint actorID)
{
byte[] data = new byte[PACKET_SIZE];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
try
{
binWriter.Write((UInt32)actorID);
binWriter.Write((UInt32)Utils.UnixTimeStampUTC());
}
catch (Exception)
{ }
}
}
return new SubPacket(false, OPCODE, 0, data);
}
}
}

View file

@ -0,0 +1,55 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
namespace Meteor.World.Packets.Send.Login
{
class _0x8PingPacket
{
public const ushort OPCODE = 0x0008;
public const uint PACKET_SIZE = 0x18;
public static SubPacket BuildPacket(uint actorID)
{
byte[] data = new byte[PACKET_SIZE];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
try
{
binWriter.Write((UInt32)actorID);
binWriter.Write((UInt32)Utils.UnixTimeStampUTC());
}
catch (Exception)
{}
}
}
return new SubPacket(false, OPCODE, 0, data);
}
}
}

View file

@ -0,0 +1,56 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class CreateLinkshellPacket
{
public bool invalidPacket = false;
public string name;
public ushort crestid;
public uint master;
public CreateLinkshellPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
crestid = binReader.ReadUInt16();
master = binReader.ReadUInt32();
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,55 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class CreateRelationPacket
{
public bool invalidPacket = false;
public uint host;
public uint guest;
public uint command;
public CreateRelationPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
host = binReader.ReadUInt32();
guest = binReader.ReadUInt32();
command = binReader.ReadUInt32();
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,51 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class DeleteLinkshellPacket
{
public bool invalidPacket = false;
public string name;
public DeleteLinkshellPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,50 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class GetGroupPacket
{
public bool invalidPacket = false;
public ulong groupId;
public GetGroupPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
groupId = binReader.ReadUInt64();
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,53 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class GroupInviteResultPacket
{
public bool invalidPacket = false;
public uint groupType;
public uint result;
public GroupInviteResultPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
groupType = binReader.ReadUInt32();
result = binReader.ReadUInt32();
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,52 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class LinkshellChangePacket
{
public bool invalidPacket = false;
public string lsName;
public LinkshellChangePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
lsName = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,51 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class LinkshellInviteCancelPacket
{
public bool invalidPacket = false;
public string lsName;
public uint actorId;
public LinkshellInviteCancelPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,54 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class LinkshellInvitePacket
{
public bool invalidPacket = false;
public string lsName;
public uint actorId;
public LinkshellInvitePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
actorId = binReader.ReadUInt32();
lsName = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,56 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class LinkshellLeavePacket
{
public bool invalidPacket = false;
public bool isKicked;
public string lsName;
public string kickedName;
public LinkshellLeavePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
isKicked = binReader.ReadUInt16() == 1;
kickedName = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
lsName = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,56 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class LinkshellRankChangePacket
{
public bool invalidPacket = false;
public string name;
public string lsName;
public byte rank;
public LinkshellRankChangePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
lsName = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
rank = binReader.ReadByte();
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,70 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class ModifyLinkshellPacket
{
public bool invalidPacket = false;
public string currentName;
public ushort argCode;
public string name;
public ushort crestid;
public uint master;
public ModifyLinkshellPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
currentName = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
argCode = binReader.ReadUInt16();
switch (argCode)
{
case 0:
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
break;
case 1:
crestid = binReader.ReadUInt16();
break;
case 2:
master = binReader.ReadUInt32();
break;
}
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,59 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class PartyInvitePacket
{
public bool invalidPacket = false;
public ushort command;
public string name;
public uint actorId;
public PartyInvitePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
command = binReader.ReadUInt16();
if (command == 1)
actorId = binReader.ReadUInt32();
else
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,51 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class PartyLeavePacket
{
public bool invalidPacket = false;
public bool isDisband;
public PartyLeavePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
isDisband = binReader.ReadByte() == 1;
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,62 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using System.Text;
namespace Meteor.World.Packets.WorldPackets.Receive.Group
{
class PartyModifyPacket
{
public bool invalidPacket = false;
public const ushort MODIFY_LEADER = 0;
public const ushort MODIFY_KICKPLAYER = 1;
public ushort command;
public string name;
public uint actorId;
public PartyModifyPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
command = binReader.ReadUInt16();
if (command >= 2)
actorId = binReader.ReadUInt32();
else
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,53 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
namespace Meteor.World.Packets.WorldPackets.Receive
{
class SessionBeginConfirmPacket
{
public bool invalidPacket = false;
public uint sessionId;
public ushort errorCode;
public SessionBeginConfirmPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
sessionId = binReader.ReadUInt32();
errorCode = binReader.ReadUInt16();
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,54 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
namespace Meteor.World.Packets.WorldPackets.Receive
{
class SessionEndConfirmPacket
{
public bool invalidPacket = false;
public uint sessionId;
public ushort errorCode;
public uint destinationZone;
public SessionEndConfirmPacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
sessionId = binReader.ReadUInt32();
errorCode = binReader.ReadUInt16();
destinationZone = binReader.ReadUInt32();
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,64 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
namespace Meteor.World.Packets.WorldPackets.Receive
{
class WorldRequestZoneChangePacket
{
public uint sessionId;
public uint destinationZoneId;
public byte destinationSpawnType;
public float destinationX;
public float destinationY;
public float destinationZ;
public float destinationRot;
public bool invalidPacket = false;
public WorldRequestZoneChangePacket(byte[] data)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryReader binReader = new BinaryReader(mem))
{
try
{
sessionId = binReader.ReadUInt32();
destinationZoneId = binReader.ReadUInt32();
destinationSpawnType = (byte)binReader.ReadUInt16();
destinationX = binReader.ReadSingle();
destinationY = binReader.ReadSingle();
destinationZ = binReader.ReadSingle();
destinationRot = binReader.ReadSingle();
}
catch (Exception)
{
invalidPacket = true;
}
}
}
}
}
}

View file

@ -0,0 +1,55 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
using Meteor.World.DataObjects;
namespace Meteor.World.Packets.WorldPackets.Send
{
class ErrorPacket
{
public const ushort OPCODE = 0x100A;
public const uint PACKET_SIZE = 0x24;
public static SubPacket BuildPacket(Session session, uint errorCode)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
try
{
binWriter.Write((UInt32)errorCode);
}
catch (Exception)
{ }
}
}
return new SubPacket(true, OPCODE, session.sessionId, data);
}
}
}

View file

@ -0,0 +1,55 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
using Meteor.World.DataObjects;
using Meteor.World.DataObjects.Group;
namespace Meteor.World.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, session.sessionId, data);
}
}
}

View file

@ -0,0 +1,50 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
using Meteor.World.DataObjects;
namespace Meteor.World.Packets.WorldPackets.Send
{
class LinkshellResultPacket
{
public const ushort OPCODE = 0x1025;
public const uint PACKET_SIZE = 0x24;
public static SubPacket BuildPacket(Session session, int result)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((Int32)result);
}
}
return new SubPacket(true, OPCODE, session.sessionId, data);
}
}
}

View file

@ -0,0 +1,53 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
using Meteor.World.DataObjects;
namespace Meteor.World.Packets.WorldPackets.Send
{
class SessionBeginPacket
{
public const ushort OPCODE = 0x1000;
public const uint PACKET_SIZE = 0x24;
public static SubPacket BuildPacket(Session session, bool isLogin)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
if (isLogin)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((Byte)1);
}
}
}
return new SubPacket(true, OPCODE, session.sessionId, data);
}
}
}

View file

@ -0,0 +1,81 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.IO;
using Meteor.Common;
using Meteor.World.DataObjects;
namespace Meteor.World.Packets.WorldPackets.Send
{
class SessionEndPacket
{
public const ushort OPCODE = 0x1001;
public const uint PACKET_SIZE = 0x38;
public static SubPacket BuildPacket(Session session)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
try
{
binWriter.Write((UInt32)0);
}
catch (Exception)
{ }
}
}
return new SubPacket(true, OPCODE, session.sessionId, data);
}
public static SubPacket BuildPacket(Session session, uint destinationZoneId, string destinationPrivateArea, byte spawnType, float spawnX, float spawnY, float spawnZ, float spawnRotation)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
try
{
binWriter.Write((UInt32)destinationZoneId);
binWriter.Write((UInt16)spawnType);
binWriter.Write((Single)spawnX);
binWriter.Write((Single)spawnY);
binWriter.Write((Single)spawnZ);
binWriter.Write((Single)spawnRotation);
}
catch (Exception)
{ }
}
}
return new SubPacket(true, OPCODE, session.sessionId, data);
}
}
}

View file

@ -0,0 +1,130 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using Meteor.World.DataObjects.Group;
namespace Meteor.World
{
class PartyManager
{
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(WorldManager worldManager, Object groupLock, Dictionary<ulong, Group> worldGroupList)
{
mWorldManager = worldManager;
mGroupLockReference = groupLock;
mCurrentWorldGroupsReference = worldGroupList;
}
public Party CreateParty(uint leaderCharaId)
{
lock (mGroupLockReference)
{
ulong groupId = mWorldManager.GetGroupIndex();
Party party = new Party(groupId, leaderCharaId);
mPartyList.Add(groupId, party);
mPlayerPartyLookup.Add(leaderCharaId, party);
mCurrentWorldGroupsReference.Add(groupId, party);
mWorldManager.IncrementGroupIndex();
return party;
}
}
public void DeleteParty(ulong groupId)
{
if (mCurrentWorldGroupsReference.ContainsKey(groupId))
mCurrentWorldGroupsReference.Remove(groupId);
if (mPartyList.ContainsKey(groupId))
{
foreach (uint id in mPartyList[groupId].members)
{
if (mPlayerPartyLookup.ContainsKey(id))
mPlayerPartyLookup.Remove(id);
}
mPartyList.Remove(groupId);
}
}
public bool AddToParty(ulong groupId, uint charaId)
{
if (mPartyList.ContainsKey(groupId))
{
Party party = mPartyList[groupId];
if (!party.members.Contains(charaId))
{
party.members.Add(charaId);
mPlayerPartyLookup.Remove(charaId);
mPlayerPartyLookup.Add(charaId, party);
}
return true;
}
return false;
}
public int RemoveFromParty(ulong groupId, uint charaId)
{
if (mPartyList.ContainsKey(groupId))
{
Party party = mPartyList[groupId];
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)
party.SetLeader(party.members[0]);
}
return party.members.Count;
}
return -1;
}
public bool ChangeLeader(ulong groupId, uint charaId)
{
if (mPartyList.ContainsKey(groupId))
{
Party party = mPartyList[groupId];
if (party.members.Contains(charaId))
{
party.SetLeader(charaId);
return true;
}
}
return false;
}
public Party GetParty(uint charaId)
{
if (mPlayerPartyLookup.ContainsKey(charaId))
return mPlayerPartyLookup[charaId];
else
return CreateParty(charaId);
}
}
}

112
World Server/Program.cs Normal file
View file

@ -0,0 +1,112 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Diagnostics;
using NLog;
using Meteor.World.DataObjects;
using MySql.Data.MySqlClient;
namespace Meteor.World
{
class Program
{
public static Logger Log;
static void Main(string[] args)
{
// set up logging
Log = LogManager.GetCurrentClassLogger();
bool startServer = true;
Log.Info("==================================");
Log.Info("FFXIV Classic World Server");
Log.Info("Version: 0.1");
Log.Info("==================================");
#if DEBUG
TextWriterTraceListener myWriter = new TextWriterTraceListener(System.Console.Out);
Debug.Listeners.Add(myWriter);
if (System.Diagnostics.Debugger.IsAttached)
{
System.Threading.Thread.Sleep(5000);
}
#endif
//Load Config
ConfigConstants.Load();
ConfigConstants.ApplyLaunchArgs(args);
//Test DB Connection
Log.Info("Testing DB connection... ");
using (MySqlConnection 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)))
{
try
{
conn.Open();
conn.Close();
Log.Info("Connection ok.");
}
catch (MySqlException e)
{
Log.Error(e.ToString());
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
if (startServer)
{
Server server = new Server();
server.StartServer();
while (startServer)
{
String input = Console.ReadLine();
Log.Info("[Console Input] " + input);
//cp.DoCommand(input, null);
}
}
Program.Log.Info("Press any key to continue...");
Console.ReadKey();
}
}
}

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("FFXIVClassic Proxy Server")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FFXIVClassic Proxy Server")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3067889d-8a50-40d6-9cd5-23aa8ea96f26")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,106 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using Meteor.World.DataObjects.Group;
namespace Meteor.World
{
class RelationGroupManager
{
private WorldManager mWorldManager;
private Object mGroupLockReference;
private Dictionary<ulong, Group> mCurrentWorldGroupsReference;
private Dictionary<ulong, Relation> mPartyRelationList = new Dictionary<ulong, Relation>();
private Dictionary<ulong, Relation> mLinkshellRelationList = new Dictionary<ulong, Relation>();
public RelationGroupManager(WorldManager worldManager, Object groupLock, Dictionary<ulong, Group> worldGroupList)
{
mWorldManager = worldManager;
mGroupLockReference = groupLock;
mCurrentWorldGroupsReference = worldGroupList;
}
public Relation CreatePartyRelationGroup(ulong topicGroupId, uint hostCharaId, uint otherCharaId)
{
lock (mGroupLockReference)
{
ulong groupIndex = mWorldManager.GetGroupIndex();
Relation relation = new Relation(groupIndex, hostCharaId, otherCharaId, 10001, topicGroupId);
mPartyRelationList.Add(groupIndex, relation);
mCurrentWorldGroupsReference.Add(groupIndex, relation);
mWorldManager.IncrementGroupIndex();
return relation;
}
}
public Relation CreateLinkshellRelationGroup(ulong topicGroupId, uint hostCharaId, uint otherCharaId)
{
lock (mGroupLockReference)
{
ulong groupIndex = mWorldManager.GetGroupIndex();
Relation relation = new Relation(groupIndex, hostCharaId, otherCharaId, 10002, topicGroupId);
mLinkshellRelationList.Add(groupIndex, relation);
mCurrentWorldGroupsReference.Add(groupIndex, relation);
mWorldManager.IncrementGroupIndex();
return relation;
}
}
public Relation GetPartyRelationGroup(uint charaId)
{
lock (mGroupLockReference)
{
foreach (Relation relation in mPartyRelationList.Values)
{
if (relation.GetHost() == charaId || relation.GetOther() == charaId)
return relation;
}
return null;
}
}
public Relation GetLinkshellRelationGroup(uint charaId)
{
lock (mGroupLockReference)
{
foreach (Relation relation in mLinkshellRelationList.Values)
{
if (relation.GetHost() == charaId || relation.GetOther() == charaId)
return relation;
}
return null;
}
}
public void DeleteRelationGroup(ulong groupId)
{
if (mPartyRelationList.ContainsKey(groupId))
mPartyRelationList.Remove(groupId);
if (mLinkshellRelationList.ContainsKey(groupId))
mLinkshellRelationList.Remove(groupId);
if (mCurrentWorldGroupsReference.ContainsKey(groupId))
mCurrentWorldGroupsReference.Remove(groupId);
}
}
}

View file

@ -0,0 +1,80 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using Meteor.World.DataObjects.Group;
namespace Meteor.World
{
class RetainerGroupManager
{
private WorldManager mWorldManager;
private Object mGroupLockReference;
private Dictionary<ulong, Group> mCurrentWorldGroupsReference;
private Dictionary<uint, RetainerGroup> mRetainerGroupList = new Dictionary<uint, RetainerGroup>();
public RetainerGroupManager(WorldManager worldManager, Object groupLock, Dictionary<ulong, Group> worldGroupList)
{
mWorldManager = worldManager;
mGroupLockReference = groupLock;
mCurrentWorldGroupsReference = worldGroupList;
}
public RetainerGroup GetRetainerGroup(uint charaId)
{
if (!mRetainerGroupList.ContainsKey(charaId))
return LoadRetainerGroup(charaId);
else
return mRetainerGroupList[charaId];
}
private RetainerGroup LoadRetainerGroup(uint charaId)
{
lock(mGroupLockReference)
{
ulong groupId = mWorldManager.GetGroupIndex();
RetainerGroup retainerGroup = new RetainerGroup(groupId, charaId);
List<RetainerGroupMember> members = Database.GetRetainers(charaId);
retainerGroup.members = members;
mRetainerGroupList.Add(charaId, retainerGroup);
mCurrentWorldGroupsReference.Add(groupId, retainerGroup);
mWorldManager.IncrementGroupIndex();
return retainerGroup;
}
}
public void AddRetainerToGroup(ulong charaId, uint retainerId)
{
}
public void RemoveRetainerFromGroup(ulong charaId, uint retainerId)
{
}
}
}

541
World Server/Server.cs Normal file
View file

@ -0,0 +1,541 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using Meteor.Common;
using Meteor.World.DataObjects;
using Meteor.World.DataObjects.Group;
using Meteor.World.Packets.WorldPackets.Receive;
using Meteor.World.Packets.WorldPackets.Receive.Group;
using Meteor.World.Packets.WorldPackets.Send;
namespace Meteor.World
{
class Server
{
public const int FFXIV_MAP_PORT = 54992;
public const int BUFFER_SIZE = 0xFFFF; //Max basepacket size is 0xFFFF
public const int BACKLOG = 100;
private static Server mSelf;
//Connections
private Socket mServerSocket;
WorldManager mWorldManager;
PacketProcessor mPacketProcessor;
//Preloaded Maps
private Dictionary<uint, string> mIdToNameMap = new Dictionary<uint, string>();
//Session Management
private List<ClientConnection> mConnectionList = new List<ClientConnection>();
private Dictionary<uint, Session> mZoneSessionList = new Dictionary<uint, Session>();
private Dictionary<uint, Session> mChatSessionList = new Dictionary<uint, Session>();
public Server()
{
mSelf = this;
}
public static Server GetServer()
{
return mSelf;
}
public bool StartServer()
{
mPacketProcessor = new PacketProcessor(this);
LoadCharaNames();
mWorldManager = new WorldManager(this);
mWorldManager.LoadZoneServerList();
mWorldManager.LoadZoneEntranceList();
mWorldManager.ConnectToZoneServers();
IPEndPoint serverEndPoint = new System.Net.IPEndPoint(IPAddress.Parse(ConfigConstants.OPTIONS_BINDIP), int.Parse(ConfigConstants.OPTIONS_PORT));
try
{
mServerSocket = new System.Net.Sockets.Socket(serverEndPoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
}
catch (Exception e)
{
throw new ApplicationException("Could not Create socket, check to make sure not duplicating port", e);
}
try
{
mServerSocket.Bind(serverEndPoint);
mServerSocket.Listen(BACKLOG);
}
catch (Exception e)
{
throw new ApplicationException("Error occured while binding socket, check inner exception", e);
}
try
{
mServerSocket.BeginAccept(new AsyncCallback(AcceptCallback), mServerSocket);
}
catch (Exception e)
{
throw new ApplicationException("Error occured starting listeners, check inner exception", e);
}
Console.ForegroundColor = ConsoleColor.White;
Program.Log.Info("World Server accepting connections @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port);
Console.ForegroundColor = ConsoleColor.Gray;
return true;
}
public void AddSession(ClientConnection connection, Session.Channel type, uint id)
{
Session session = new Session(id, connection, type);
switch (type)
{
case Session.Channel.ZONE:
//New character since world server loaded
if (!mIdToNameMap.ContainsKey(id))
AddNameToMap(id, session.characterName);
//TODO: this is technically wrong!!! Should kick out player and wait till auto-removed.
if (mZoneSessionList.ContainsKey(id))
mZoneSessionList.Remove(id);
mZoneSessionList.Add(id, session);
break;
case Session.Channel.CHAT:
if (!mChatSessionList.ContainsKey(id))
mChatSessionList.Add(id, session);
break;
}
}
public void RemoveSession(Session.Channel type, uint id)
{
switch (type)
{
case Session.Channel.ZONE:
if (mZoneSessionList.ContainsKey(id))
{
mZoneSessionList[id].clientConnection.Disconnect();
mConnectionList.Remove(mZoneSessionList[id].clientConnection);
mZoneSessionList.Remove(id);
}
break;
case Session.Channel.CHAT:
if (mChatSessionList.ContainsKey(id))
{
mChatSessionList[id].clientConnection.Disconnect();
mConnectionList.Remove(mChatSessionList[id].clientConnection);
mChatSessionList.Remove(id);
}
break;
}
}
public Session GetSession(uint targetSession, Session.Channel type = Session.Channel.ZONE)
{
switch (type)
{
case Session.Channel.ZONE:
if (mZoneSessionList.ContainsKey(targetSession))
return mZoneSessionList[targetSession];
break;
case Session.Channel.CHAT:
if (mChatSessionList.ContainsKey(targetSession))
return mChatSessionList[targetSession];
break;
}
return null;
}
public Session GetSession(string targetSessionName)
{
lock (mZoneSessionList)
{
foreach (Session s in mZoneSessionList.Values)
{
if (s.characterName != null && s.characterName.Equals(targetSessionName))
return s;
}
}
return null;
}
public void OnReceiveSubPacketFromZone(ZoneServer zoneServer, SubPacket subpacket)
{
uint sessionId = subpacket.header.targetId;
Session session = GetSession(sessionId);
if (subpacket.gameMessage.opcode != 0x1 && subpacket.gameMessage.opcode != 0xca)
subpacket.DebugPrintSubPacket();
if (subpacket.gameMessage.opcode >= 0x1000)
{
//subpacket.DebugPrintSubPacket();
switch (subpacket.gameMessage.opcode)
{
//Session Begin Confirm
case 0x1000:
SessionBeginConfirmPacket beginConfirmPacket = new SessionBeginConfirmPacket(subpacket.data);
if (beginConfirmPacket.invalidPacket || beginConfirmPacket.errorCode == 0)
Program.Log.Error("Session {0} had a error beginning session.", beginConfirmPacket.sessionId);
break;
//Session End Confirm
case 0x1001:
SessionEndConfirmPacket endConfirmPacket = new SessionEndConfirmPacket(subpacket.data);
if (!endConfirmPacket.invalidPacket && endConfirmPacket.errorCode == 0)
{
//Check destination, if != 0, update route and start new session
if (endConfirmPacket.destinationZone != 0)
{
session.routing1 = Server.GetServer().GetWorldManager().GetZoneServer(endConfirmPacket.destinationZone);
session.routing1.SendSessionStart(session);
}
else
{
RemoveSession(Session.Channel.ZONE, endConfirmPacket.sessionId);
RemoveSession(Session.Channel.CHAT, endConfirmPacket.sessionId);
}
}
else
Program.Log.Error("Session {0} had an error ending session.", endConfirmPacket.sessionId);
break;
//Zone Change Request
case 0x1002:
WorldRequestZoneChangePacket zoneChangePacket = new WorldRequestZoneChangePacket(subpacket.data);
if (!zoneChangePacket.invalidPacket)
{
GetWorldManager().DoZoneServerChange(session, zoneChangePacket.destinationZoneId, "", zoneChangePacket.destinationSpawnType, zoneChangePacket.destinationX, zoneChangePacket.destinationY, zoneChangePacket.destinationZ, zoneChangePacket.destinationRot);
}
break;
//Change leader or kick
case 0x1020:
PartyModifyPacket partyModifyPacket = new PartyModifyPacket(subpacket.data);
Party pt = mWorldManager.GetPartyManager().GetParty(subpacket.header.targetId);
if (pt.GetMemberCount() <= 1)
return;
if (partyModifyPacket.command == PartyModifyPacket.MODIFY_LEADER)
pt.SetLeaderPlayerRequest(GetSession(subpacket.header.sourceId), partyModifyPacket.name);
else if (partyModifyPacket.command == PartyModifyPacket.MODIFY_KICKPLAYER)
pt.KickPlayerRequest(GetSession(subpacket.header.sourceId), partyModifyPacket.name);
else if (partyModifyPacket.command == PartyModifyPacket.MODIFY_LEADER + 2)
pt.SetLeaderPlayerRequest(GetSession(subpacket.header.sourceId), partyModifyPacket.actorId);
else if (partyModifyPacket.command == PartyModifyPacket.MODIFY_KICKPLAYER + 2)
pt.KickPlayerRequest(GetSession(subpacket.header.sourceId), partyModifyPacket.actorId);
break;
//Party Resign or Disband
case 0x1021:
PartyLeavePacket partyLeavePacket = new PartyLeavePacket(subpacket.data);
Party leavePt = mWorldManager.GetPartyManager().GetParty(subpacket.header.sourceId);
if (!partyLeavePacket.isDisband)
leavePt.LeavePlayerRequest(GetSession(subpacket.header.sourceId));
else
leavePt.DisbandPlayerRequest(GetSession(subpacket.header.sourceId));
break;
//Party Invite Request
case 0x1022:
PartyInvitePacket partyInvitePacket = new PartyInvitePacket(subpacket.data);
if (partyInvitePacket.command == 1)
mWorldManager.ProcessPartyInvite(GetSession(subpacket.header.sourceId), partyInvitePacket.actorId);
else if (partyInvitePacket.command == 0)
{
Session inviteeByNamesSession = GetSession(partyInvitePacket.name);
if (inviteeByNamesSession != null)
mWorldManager.ProcessPartyInvite(GetSession(subpacket.header.sourceId), inviteeByNamesSession.sessionId);
else
{
//Show not found msg
}
}
break;
//Group Invite Result
case 0x1023:
GroupInviteResultPacket groupInviteResultPacket = new GroupInviteResultPacket(subpacket.data);
switch (groupInviteResultPacket.groupType)
{
case 0x2711:
mWorldManager.ProcessPartyInviteResult(GetSession(subpacket.header.sourceId), groupInviteResultPacket.result);
break;
case 0x2712:
mWorldManager.ProcessLinkshellInviteResult(GetSession(subpacket.header.sourceId), groupInviteResultPacket.result);
break;
}
break;
//Linkshell create request
case 0x1025:
CreateLinkshellPacket createLinkshellPacket = new CreateLinkshellPacket(subpacket.data);
Linkshell newLs = null;
int lsError = mWorldManager.GetLinkshellManager().CanCreateLinkshell(createLinkshellPacket.name);
if (lsError == 0)
{
newLs = mWorldManager.GetLinkshellManager().CreateLinkshell(createLinkshellPacket.name, createLinkshellPacket.crestid, createLinkshellPacket.master);
if (newLs != null)
newLs.SendGroupPackets(session);
else
lsError = 3;
}
SubPacket resultPacket = LinkshellResultPacket.BuildPacket(session, lsError);
zoneServer.SendPacket(resultPacket);
break;
//Linkshell modify request
case 0x1026:
ModifyLinkshellPacket modifyLinkshellPacket = new ModifyLinkshellPacket(subpacket.data);
switch (modifyLinkshellPacket.argCode)
{
case 0:
break;
case 1:
mWorldManager.GetLinkshellManager().ChangeLinkshellCrest(modifyLinkshellPacket.currentName, modifyLinkshellPacket.crestid);
break;
case 2:
mWorldManager.GetLinkshellManager().ChangeLinkshellMaster(modifyLinkshellPacket.currentName, modifyLinkshellPacket.master);
break;
}
break;
//Linkshell delete request
case 0x1027:
DeleteLinkshellPacket deleteLinkshellPacket = new DeleteLinkshellPacket(subpacket.data);
mWorldManager.GetLinkshellManager().DeleteLinkshell(deleteLinkshellPacket.name);
break;
//Linkshell set active
case 0x1028:
LinkshellChangePacket linkshellChangePacket = new LinkshellChangePacket(subpacket.data);
mWorldManager.ProcessLinkshellSetActive(GetSession(subpacket.header.sourceId), linkshellChangePacket.lsName);
break;
//Linkshell invite member
case 0x1029:
LinkshellInvitePacket linkshellInvitePacket = new LinkshellInvitePacket(subpacket.data);
mWorldManager.ProcessLinkshellInvite(GetSession(subpacket.header.sourceId), linkshellInvitePacket.lsName, linkshellInvitePacket.actorId);
break;
//Linkshell cancel invite
case 0x1030:
LinkshellInviteCancelPacket linkshellInviteCancelPacket = new LinkshellInviteCancelPacket(subpacket.data);
mWorldManager.ProcessLinkshellInviteCancel(GetSession(subpacket.header.sourceId));
break;
//Linkshell resign/kicked
case 0x1031:
LinkshellLeavePacket linkshellLeavePacket = new LinkshellLeavePacket(subpacket.data);
Linkshell lsLeave = mWorldManager.GetLinkshellManager().GetLinkshell(linkshellLeavePacket.lsName);
if (linkshellLeavePacket.isKicked)
lsLeave.KickRequest(GetSession(subpacket.header.sourceId), linkshellLeavePacket.kickedName);
else
lsLeave.LeaveRequest(GetSession(subpacket.header.sourceId));
break;
//Linkshell rank change
case 0x1032:
LinkshellRankChangePacket linkshellRankChangePacket = new LinkshellRankChangePacket(subpacket.data);
Linkshell lsRankChange = mWorldManager.GetLinkshellManager().GetLinkshell(linkshellRankChangePacket.lsName);
lsRankChange.RankChangeRequest(GetSession(subpacket.header.sourceId), linkshellRankChangePacket.name, linkshellRankChangePacket.rank);
break;
}
}
else if (mZoneSessionList.ContainsKey(sessionId))
{
ClientConnection conn = mZoneSessionList[sessionId].clientConnection;
conn.QueuePacket(subpacket);
conn.FlushQueuedSendPackets();
}
}
public WorldManager GetWorldManager()
{
return mWorldManager;
}
#region Socket Handling
private void AcceptCallback(IAsyncResult result)
{
ClientConnection conn = null;
Socket socket = (System.Net.Sockets.Socket)result.AsyncState;
try
{
conn = new ClientConnection();
conn.socket = socket.EndAccept(result);
conn.buffer = new byte[BUFFER_SIZE];
lock (mConnectionList)
{
mConnectionList.Add(conn);
}
Program.Log.Info("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port);
//Queue recieving of data from the connection
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), conn);
//Queue the accept of the next incomming connection
mServerSocket.BeginAccept(new AsyncCallback(AcceptCallback), mServerSocket);
}
catch (SocketException)
{
if (conn != null)
{
lock (mConnectionList)
{
mConnectionList.Remove(conn);
}
}
mServerSocket.BeginAccept(new AsyncCallback(AcceptCallback), mServerSocket);
}
catch (Exception)
{
if (conn != null)
{
lock (mConnectionList)
{
mConnectionList.Remove(conn);
}
}
mServerSocket.BeginAccept(new AsyncCallback(AcceptCallback), mServerSocket);
}
}
/// <summary>
/// Receive Callback. Reads in incoming data, converting them to base packets. Base packets are sent to be parsed. If not enough data at the end to build a basepacket, move to the beginning and prepend.
/// </summary>
/// <param name="result"></param>
private void ReceiveCallback(IAsyncResult result)
{
ClientConnection conn = (ClientConnection)result.AsyncState;
//Check if disconnected
if ((conn.socket.Poll(1, SelectMode.SelectRead) && conn.socket.Available == 0))
{
lock (mConnectionList)
{
mConnectionList.Remove(conn);
}
return;
}
try
{
int bytesRead = conn.socket.EndReceive(result);
bytesRead += conn.lastPartialSize;
if (bytesRead >= 0)
{
int offset = 0;
//Build packets until can no longer or out of data
while (true)
{
BasePacket basePacket = BasePacket.CreatePacket(ref offset, conn.buffer, bytesRead);
//If can't build packet, break, else process another
if (basePacket == null)
break;
else
{
mPacketProcessor.ProcessPacket(conn, basePacket);
}
}
//Not all bytes consumed, transfer leftover to beginning
if (offset < bytesRead)
Array.Copy(conn.buffer, offset, conn.buffer, 0, bytesRead - offset);
conn.lastPartialSize = bytesRead - offset;
//Build any queued subpackets into basepackets and send
conn.FlushQueuedSendPackets();
if (offset < bytesRead)
//Need offset since not all bytes consumed
conn.socket.BeginReceive(conn.buffer, bytesRead - offset, conn.buffer.Length - (bytesRead - offset), SocketFlags.None, new AsyncCallback(ReceiveCallback), conn);
else
//All bytes consumed, full buffer available
conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), conn);
}
else
{
lock (mConnectionList)
{
mConnectionList.Remove(conn);
}
}
}
catch (SocketException)
{
if (conn.socket != null)
{
lock (mConnectionList)
{
mConnectionList.Remove(conn);
}
}
}
}
#endregion
public void LoadCharaNames()
{
Database.GetAllCharaNames(mIdToNameMap);
}
public void AddNameToMap(uint charaId, string name)
{
mIdToNameMap.Add(charaId, name);
}
public string GetNameForId(uint charaId)
{
if (mIdToNameMap.ContainsKey(charaId))
return mIdToNameMap[charaId];
return null;
}
}
}

View file

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3067889D-8A50-40D6-9CD5-23AA8EA96F26}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Meteor.World</RootNamespace>
<AssemblyName>World Server</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Cyotek.Collections.Generic.CircularBuffer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=58daa28b0b2de221, processorArchitecture=MSIL">
<HintPath>..\packages\Cyotek.CircularBuffer.1.0.0.0\lib\net20\Cyotek.Collections.Generic.CircularBuffer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MySql.Data, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.6.9.8\lib\net45\MySql.Data.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.3.5\lib\net45\NLog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Actor\Group\Work\ContentWork.cs" />
<Compile Include="Actor\Group\Work\GroupGlobalSave.cs" />
<Compile Include="Actor\Group\Work\GroupGlobalTemp.cs" />
<Compile Include="Actor\Group\Work\GroupMemberSave.cs" />
<Compile Include="Actor\Group\Work\LinkshellWork.cs" />
<Compile Include="Actor\Group\Work\PartyWork.cs" />
<Compile Include="Actor\Group\Work\RelationWork.cs" />
<Compile Include="Actor\Group\Work\RetainerWork.cs" />
<Compile Include="ConfigConstants.cs" />
<Compile Include="Database.cs" />
<Compile Include="DataObjects\ClientConnection.cs" />
<Compile Include="DataObjects\DBWorld.cs" />
<Compile Include="DataObjects\Group\Group.cs" />
<Compile Include="DataObjects\Group\Linkshell.cs" />
<Compile Include="DataObjects\Group\LinkshellMember.cs" />
<Compile Include="DataObjects\Group\Party.cs" />
<Compile Include="DataObjects\Group\RetainerMeetingRelationGroup.cs" />
<Compile Include="DataObjects\Group\Relation.cs" />
<Compile Include="DataObjects\Group\RetainerGroup.cs" />
<Compile Include="DataObjects\Group\RetainerGroupMember.cs" />
<Compile Include="DataObjects\LuaParam.cs" />
<Compile Include="DataObjects\LuaUtils.cs" />
<Compile Include="DataObjects\ZoneServer.cs" />
<Compile Include="DataObjects\Session.cs" />
<Compile Include="LinkshellManager.cs" />
<Compile Include="PacketProcessor.cs" />
<Compile Include="Packets\Receive\HelloPacket.cs" />
<Compile Include="Packets\Receive\Subpackets\PartyChatMessagePacket.cs" />
<Compile Include="Packets\Receive\Subpackets\ChatMessagePacket.cs" />
<Compile Include="Packets\Receive\Subpackets\GroupCreatedPacket.cs" />
<Compile Include="Packets\Send\Subpackets\GameMessagePacket.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" />
<Compile Include="Packets\Send\Subpackets\Groups\SetActiveLinkshellPacket.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\GroupHeaderPacket.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\GroupMember.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\GroupMembersBeginPacket.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\GroupMembersEndPacket.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\GroupMembersX08Packet.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\GroupMembersX16Packet.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\GroupMembersX32Packet.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\GroupMembersX64Packet.cs" />
<Compile Include="Packets\Send\Subpackets\Groups\SynchGroupWorkValuesPacket.cs" />
<Compile Include="Packets\Send\Subpackets\SendMessagePacket.cs" />
<Compile Include="Packets\Send\_0x2Packet.cs" />
<Compile Include="Packets\Send\_0x7Packet.cs" />
<Compile Include="Packets\Send\_0x8PingPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\GroupInviteResultPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\LinkshellInviteCancelPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\LinkshellInvitePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\LinkshellChangePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\LinkshellRankChangePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\LinkshellLeavePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\PartyLeavePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\PartyInvitePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\PartyModifyPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\ModifyLinkshellPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\CreateRelationPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\CreateLinkshellPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\GetGroupPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\Group\DeleteLinkshellPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\SessionBeginConfirmPacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\WorldRequestZoneChangePacket.cs" />
<Compile Include="Packets\WorldPackets\Receive\SessionEndConfirmPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\ErrorPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\Group\PartySyncPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\LinkshellResultPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\SessionBeginPacket.cs" />
<Compile Include="Packets\WorldPackets\Send\SessionEndPacket.cs" />
<Compile Include="PartyManager.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RelationGroupManager.cs" />
<Compile Include="RetainerGroupManager.cs" />
<Compile Include="Server.cs" />
<Compile Include="WorldMaster.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<Content Include="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FFXIVClassic Common Class Lib\Common Class Lib.csproj">
<Project>{3a3d6626-c820-4c18-8c81-64811424f20e}</Project>
<Name>Common Class Lib</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

535
World Server/WorldMaster.cs Normal file
View file

@ -0,0 +1,535 @@
/*
===========================================================================
Copyright (C) 2015-2019 Project Meteor Dev Team
This file is part of Project Meteor Server.
Project Meteor Server is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Project Meteor Server is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Project Meteor Server. If not, see <https:www.gnu.org/licenses/>.
===========================================================================
*/
using System;
using System.Collections.Generic;
using Meteor.Common;
using Meteor.World.DataObjects;
using Meteor.World.DataObjects.Group;
using Meteor.World.Packets.Send.Subpackets;
using Meteor.World.Packets.Send.Subpackets.Groups;
using Meteor.World.Packets.WorldPackets.Send;
using Meteor.World.Packets.WorldPackets.Send.Group;
using MySql.Data.MySqlClient;
namespace Meteor.World
{
class WorldManager
{
private Server mServer;
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()
{
mZoneServerList = new Dictionary<string, ZoneServer>();
using (MySqlConnection 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)))
{
try
{
conn.Open();
string query = @"
SELECT
id,
serverIp,
serverPort
FROM server_zones
WHERE serverIp IS NOT NULL";
MySqlCommand cmd = new MySqlCommand(query, conn);
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
uint id = reader.GetUInt32(0);
string ip = reader.GetString(1);
int port = reader.GetInt32(2);
string address = ip + ":" + port;
if (!mZoneServerList.ContainsKey(address))
{
ZoneServer zone = new ZoneServer(ip, port, id);
mZoneServerList.Add(address, zone);
}
else
mZoneServerList[address].AddLoadedZone(id);
}
}
}
catch (MySqlException e)
{ Console.WriteLine(e); }
finally
{
conn.Dispose();
}
}
}
public void LoadZoneEntranceList()
{
zoneEntranceList = new Dictionary<uint, ZoneEntrance>();
int count = 0;
using (MySqlConnection 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)))
{
try
{
conn.Open();
string query = @"
SELECT
id,
zoneId,
spawnType,
spawnX,
spawnY,
spawnZ,
spawnRotation,
privateAreaName
FROM server_zones_spawnlocations";
MySqlCommand cmd = new MySqlCommand(query, conn);
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
uint id = reader.GetUInt32(0);
string privArea = null;
if (!reader.IsDBNull(7))
privArea = reader.GetString(7);
ZoneEntrance entance = new ZoneEntrance(reader.GetUInt32(1), privArea, reader.GetByte(2), reader.GetFloat(3), reader.GetFloat(4), reader.GetFloat(5), reader.GetFloat(6));
zoneEntranceList[id] = entance;
count++;
}
}
}
catch (MySqlException e)
{ Console.WriteLine(e); }
finally
{
conn.Dispose();
}
}
Program.Log.Info(String.Format("Loaded {0} zone spawn locations.", count));
}
public void ConnectToZoneServers()
{
Program.Log.Info("--------------------------");
Program.Log.Info("Connecting to zone servers");
Program.Log.Info("--------------------------");
foreach (ZoneServer zs in mZoneServerList.Values)
{
zs.Connect();
}
}
public ZoneServer GetZoneServer(uint zoneId)
{
foreach (ZoneServer zs in mZoneServerList.Values)
{
if (zs.ownedZoneIds.Contains(zoneId))
return zs;
}
return null;
}
//Moves the actor to the new zone if exists. No packets are sent nor position changed.
public void DoSeamlessZoneServerChange(Session session, uint destinationZoneId)
{
}
//Moves actor to new zone, and sends packets to spawn at the given zone entrance
public void DoZoneServerChange(Session session, uint zoneEntrance)
{
if (!zoneEntranceList.ContainsKey(zoneEntrance))
{
Program.Log.Error("Given zone entrance was not found: " + zoneEntrance);
return;
}
ZoneEntrance ze = zoneEntranceList[zoneEntrance];
DoZoneServerChange(session, ze.zoneId, ze.privateAreaName, ze.spawnType, ze.spawnX, ze.spawnY, ze.spawnZ, ze.spawnRotation);
}
//Moves actor to new zone, and sends packets to spawn at the given coords.
public void DoZoneServerChange(Session session, uint destinationZoneId, string destinationPrivateArea, byte spawnType, float spawnX, float spawnY, float spawnZ, float spawnRotation)
{
ZoneServer zs = GetZoneServer(destinationZoneId);
if (zs == null)
return;
session.currentZoneId = destinationZoneId;
//Intrazone change, just update the id
if (zs.Equals(session.routing1))
return;
if (zs.isConnected)
session.routing1.SendSessionEnd(session, destinationZoneId, destinationPrivateArea, spawnType, spawnX, spawnY, spawnZ, spawnRotation);
else if (zs.Connect())
session.routing1.SendSessionEnd(session, destinationZoneId, destinationPrivateArea, spawnType, spawnX, spawnY, spawnZ, spawnRotation);
else
session.routing1.SendPacket(ErrorPacket.BuildPacket(session, 1));
}
//Login Zone In
public void DoLogin(Session session)
{
SendMotD(session);
//Send party, retainer, ls groups
Party pt = mPartyManager.GetParty(session.sessionId);
pt.SendGroupPackets(session);
SendPartySync(pt);
mRetainerGroupManager.GetRetainerGroup(session.sessionId).SendGroupPackets(session);
List<Linkshell> linkshells = mLinkshellManager.GetPlayerLinkshellMembership(session.sessionId);
foreach (Linkshell ls in linkshells)
ls.SendGroupPackets(session);
//Reset to blank if in unknown state
ulong activeGroupIndex = 0;
if (!session.activeLinkshellName.Equals(""))
{
Linkshell activeLs = mLinkshellManager.GetLinkshell(session.activeLinkshellName);
if (activeLs != null && activeLs.HasMember(session.sessionId))
{
activeGroupIndex = activeLs.groupIndex;
}
else
{
session.activeLinkshellName = "";
Database.SetActiveLS(session, "");
}
}
SubPacket activeLsPacket = SetActiveLinkshellPacket.BuildPacket(session.sessionId, activeGroupIndex);
session.clientConnection.QueuePacket(activeLsPacket);
}
private void SendMotD(Session session)
{
session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "-------- Login Message --------"));
session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", String.Format("Welcome to {0}!", ConfigConstants.PREF_SERVERNAME)));
session.clientConnection.QueuePacket(SendMessagePacket.BuildPacket(session.sessionId, session.sessionId, SendMessagePacket.MESSAGE_TYPE_GENERAL_INFO, "", "Welcome to Eorzea!"));
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!"));
}
public void SendPartySync(Party party)
{
List<ZoneServer> alreadySent = new List<ZoneServer>();
foreach (uint member in party.members)
{
Session session = Server.GetServer().GetSession(member);
if (session == null)
continue;
if (alreadySent.Contains(session.routing1))
continue;
alreadySent.Add(session.routing1);
SubPacket syncPacket = PartySyncPacket.BuildPacket(session, party);
session.routing1.SendPacket(syncPacket);
}
}
public class ZoneEntrance
{
public uint zoneId;
public string privateAreaName;
public byte spawnType;
public float spawnX;
public float spawnY;
public float spawnZ;
public float spawnRotation;
public ZoneEntrance(uint zoneId, string privateAreaName, byte spawnType, float x, float y, float z, float rot)
{
this.zoneId = zoneId;
this.privateAreaName = privateAreaName;
this.spawnType = spawnType;
this.spawnX = x;
this.spawnY = y;
this.spawnZ = z;
this.spawnRotation = rot;
}
}
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(0))
group.SendGroupPackets(mServer.GetSession(member.actorId));
}
}
public void ProcessPartyInvite(Session requestSession, uint invitee)
{
if (mServer.GetSession(invitee) == null)
{
requestSession.SendGameMessage(30544, 0x20);
}
else
{
Session inviteeSession = mServer.GetSession(invitee);
Relation inviteRelation = mRelationGroupManager.CreatePartyRelationGroup(mPartyManager.GetParty(requestSession.sessionId).groupIndex, requestSession.sessionId, invitee);
inviteRelation.SendGroupPacketsAll(requestSession.sessionId, invitee);
inviteeSession.SendGameMessage(30430, 0x20, (object)mServer.GetNameForId(requestSession.sessionId)); //X Invited you
requestSession.SendGameMessage(30433, 0x20, (object)mServer.GetNameForId(inviteeSession.sessionId)); //You invite X
}
}
public void ProcessPartyInviteResult(Session inviteeSession, uint resultCode)
{
Relation relation = mRelationGroupManager.GetPartyRelationGroup(inviteeSession.sessionId);
Session inviterSession = mServer.GetSession(relation.GetHost());
//Accept
if (resultCode == 1)
{
Party oldParty = mPartyManager.GetParty(inviteeSession.sessionId);
if (oldParty.members.Count == 1)
{
mPartyManager.DeleteParty(oldParty.groupIndex);
Party newParty = mPartyManager.GetParty(inviterSession.sessionId);
mPartyManager.AddToParty(newParty.groupIndex, inviteeSession.sessionId);
newParty.SendGroupPacketsAll(newParty.members);
SendPartySync(newParty);
newParty.OnPlayerJoin(inviteeSession);
}
}
else //Refuse
{
inviterSession.SendGameMessage(30573, 0x20, (object)mServer.GetNameForId(inviteeSession.sessionId)); //X rejects your invite
}
//Delete the relation
mRelationGroupManager.DeleteRelationGroup(relation.groupIndex);
relation.SendDeletePackets(inviterSession.sessionId, inviteeSession.sessionId);
}
public void ProcessLinkshellInvite(Session inviterSession, string lsName, uint invitee)
{
Session inviteeSession = mServer.GetSession(invitee);
Linkshell ls = mLinkshellManager.GetLinkshell(lsName);
//Something really fucked up
if (mServer.GetSession(invitee) == null)
{
inviterSession.SendGameMessage(30544, 0x20);
}
//Check if they are already in your LS
else if (ls.HasMember(invitee))
{
inviterSession.SendGameMessage(25282, 0x20, (object)inviteeSession.characterName, 1); //X already belongs to
}
//Check if you can invite more members
else if (ls.GetMemberCount() >= LinkshellManager.LS_MAX_MEMBERS)
{
inviterSession.SendGameMessage(25158, 0x20, (object)inviteeSession); //This linkshell cannot take on any more members.
}
//Check if they currently have an invite
else if (mRelationGroupManager.GetLinkshellRelationGroup(invitee) != null)
{
inviterSession.SendGameMessage(25196, 0x20, (object)inviteeSession); //Unable to invite X another pending
}
else
{
Relation inviteRelation = mRelationGroupManager.CreateLinkshellRelationGroup(mLinkshellManager.GetLinkshell(lsName).groupIndex, inviterSession.sessionId, invitee);
inviteRelation.SendGroupPacketsAll(inviterSession.sessionId, invitee);
inviteeSession.SendGameMessage(25150, 0x20, (object)1, (object)lsName, (object)inviterSession); //X Offers you
inviterSession.SendGameMessage(25151, 0x20, (object)1, null, (object)inviteeSession); //You offer X
}
}
public void ProcessLinkshellInviteResult(Session inviteeSession, uint resultCode)
{
Relation relation = mRelationGroupManager.GetLinkshellRelationGroup(inviteeSession.sessionId);
Session inviterSession = mServer.GetSession(relation.GetHost());
Linkshell newLS = null;
if (mCurrentWorldGroups.ContainsKey(relation.groupIndex))
newLS = (Linkshell)mCurrentWorldGroups[relation.GetTopicGroupIndex()];
else
{
//??? errored
}
if (newLS != null)
{
//Accept
if (resultCode == 1)
{
//Check if the invitee has room for more linkshells
if (mLinkshellManager.GetPlayerLinkshellMembership(inviteeSession.sessionId).Count >= LinkshellManager.LS_MAX_ALLOWED)
{
inviteeSession.SendGameMessage(25153, 0x20, (object)inviteeSession); //You are unable to join any more linkshells.
}
//Did someone invite in the meantime?
else if (newLS.GetMemberCount() >= LinkshellManager.LS_MAX_MEMBERS)
{
inviterSession.SendGameMessage(25158, 0x20, (object)inviteeSession); //This linkshell cannot take on any more members.
}
//All good, add new member
else
{
mLinkshellManager.AddMemberToLinkshell(inviteeSession.sessionId, newLS.name);
newLS.SendGroupPacketsAll(newLS.GetMemberIds());
newLS.OnPlayerJoin(inviteeSession);
}
}
else //Refuse
{
inviteeSession.SendGameMessage(25189, 0x20); //You decline the linkpearl offer.
inviterSession.SendGameMessage(25190, 0x20); //Your linkpearl offer is declined.
}
}
//Delete the relation
//mRelationGroupManager.DeleteRelationGroup(relation.groupIndex);
relation.SendDeletePackets(inviterSession.sessionId, inviteeSession.sessionId);
}
public void ProcessLinkshellInviteCancel(Session inviterSession)
{
Relation relation = mRelationGroupManager.GetLinkshellRelationGroup(inviterSession.sessionId);
Session inviteeSession = mServer.GetSession(relation.GetOther());
inviterSession.SendGameMessage(25191, 0x20); //You cancel the linkpearl offer.
inviteeSession.SendGameMessage(25192, 0x20); //The linkpearl offer has been canceled.
//Delete the relation
mRelationGroupManager.DeleteRelationGroup(relation.groupIndex);
relation.SendDeletePackets(inviterSession.sessionId, inviteeSession.sessionId);
}
public void ProcessLinkshellSetActive(Session requestSession, string lsName)
{
//Deactivate all
if (lsName.Equals(""))
{
requestSession.SetActiveLS(lsName);
SubPacket activeLsPacket = SetActiveLinkshellPacket.BuildPacket(requestSession.sessionId, 0);
requestSession.clientConnection.QueuePacket(activeLsPacket);
requestSession.SendGameMessage(25132, 0x20, (object)1);
}
else
{
Linkshell ls = mLinkshellManager.GetLinkshell(lsName);
if (ls == null || !ls.HasMember(requestSession.sessionId))
{
requestSession.SendGameMessage(25167, 0x20, (object)1, (object)lsName);
}
else
{
requestSession.SetActiveLS(lsName);
SubPacket activeLsPacket = SetActiveLinkshellPacket.BuildPacket(requestSession.sessionId, ls.groupIndex);
requestSession.clientConnection.QueuePacket(activeLsPacket);
requestSession.SendGameMessage(25131, 0x20, (object)1, (object)lsName);
}
}
}
public void IncrementGroupIndex()
{
mRunningGroupIndex++;
}
public ulong GetGroupIndex()
{
return mRunningGroupIndex | 0x8000000000000000;
}
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;
}
}
}

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cyotek.CircularBuffer" version="1.0.0.0" targetFramework="net452" />
<package id="MySql.Data" version="6.9.8" targetFramework="net452" />
<package id="NLog" version="4.3.5" targetFramework="net452" />
<package id="NLog.Config" version="4.3.5" targetFramework="net452" />
<package id="NLog.Schema" version="4.3.4" targetFramework="net452" />
</packages>