mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-23 21:27:46 +00:00
Got linkshell creation working.
This commit is contained in:
parent
c3c19c3592
commit
1d3dd99414
10 changed files with 149 additions and 13 deletions
|
@ -294,6 +294,7 @@
|
||||||
<Compile Include="packets\receive\UpdatePlayerPositionPacket.cs" />
|
<Compile Include="packets\receive\UpdatePlayerPositionPacket.cs" />
|
||||||
<Compile Include="packets\WorldPackets\Receive\ErrorPacket.cs" />
|
<Compile Include="packets\WorldPackets\Receive\ErrorPacket.cs" />
|
||||||
<Compile Include="packets\WorldPackets\Receive\PartySyncPacket.cs" />
|
<Compile Include="packets\WorldPackets\Receive\PartySyncPacket.cs" />
|
||||||
|
<Compile Include="packets\WorldPackets\Receive\LinkshellResultPacket.cs" />
|
||||||
<Compile Include="packets\WorldPackets\Receive\SessionEndPacket.cs" />
|
<Compile Include="packets\WorldPackets\Receive\SessionEndPacket.cs" />
|
||||||
<Compile Include="packets\WorldPackets\Receive\SessionBeginPacket.cs" />
|
<Compile Include="packets\WorldPackets\Receive\SessionBeginPacket.cs" />
|
||||||
<Compile Include="packets\WorldPackets\Send\Group\CreateLinkshellPacket.cs" />
|
<Compile Include="packets\WorldPackets\Send\Group\CreateLinkshellPacket.cs" />
|
||||||
|
|
|
@ -88,6 +88,11 @@ namespace FFXIVClassic_Map_Server
|
||||||
PartySyncPacket partySyncPacket = new PartySyncPacket(subpacket.data);
|
PartySyncPacket partySyncPacket = new PartySyncPacket(subpacket.data);
|
||||||
Server.GetWorldManager().PartyMemberListRecieved(partySyncPacket);
|
Server.GetWorldManager().PartyMemberListRecieved(partySyncPacket);
|
||||||
break;
|
break;
|
||||||
|
//World Server - Linkshell Creation Result
|
||||||
|
case 0x1025:
|
||||||
|
LinkshellResultPacket lsResult = new LinkshellResultPacket(subpacket.data);
|
||||||
|
LuaEngine.GetInstance().OnSignal("ls_result", lsResult.resultCode);
|
||||||
|
break;
|
||||||
//Ping
|
//Ping
|
||||||
case 0x0001:
|
case 0x0001:
|
||||||
//subpacket.DebugPrintSubPacket();
|
//subpacket.DebugPrintSubPacket();
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnSignal(string signal)
|
public void OnSignal(string signal, params object[] args)
|
||||||
{
|
{
|
||||||
List<Coroutine> mToAwake = new List<Coroutine>();
|
List<Coroutine> mToAwake = new List<Coroutine>();
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ namespace FFXIVClassic_Map_Server.lua
|
||||||
|
|
||||||
foreach (Coroutine key in mToAwake)
|
foreach (Coroutine key in mToAwake)
|
||||||
{
|
{
|
||||||
DynValue value = key.Resume();
|
DynValue value = key.Resume(args);
|
||||||
ResolveResume(null, key, value);
|
ResolveResume(null, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FFXIVClassic_Map_Server.packets.WorldPackets.Receive
|
||||||
|
{
|
||||||
|
class LinkshellResultPacket
|
||||||
|
{
|
||||||
|
public int resultCode;
|
||||||
|
|
||||||
|
public bool invalidPacket = false;
|
||||||
|
|
||||||
|
public LinkshellResultPacket(byte[] data)
|
||||||
|
{
|
||||||
|
using (MemoryStream mem = new MemoryStream(data))
|
||||||
|
{
|
||||||
|
using (BinaryReader binReader = new BinaryReader(mem))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
resultCode = binReader.ReadInt32();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
invalidPacket = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ namespace FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group
|
||||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||||
{
|
{
|
||||||
binWriter.Write(Encoding.ASCII.GetBytes(name), 0, Encoding.ASCII.GetByteCount(name) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(name));
|
binWriter.Write(Encoding.ASCII.GetBytes(name), 0, Encoding.ASCII.GetByteCount(name) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(name));
|
||||||
|
binWriter.BaseStream.Seek(0x20, SeekOrigin.Begin);
|
||||||
binWriter.Write((UInt16)crest);
|
binWriter.Write((UInt16)crest);
|
||||||
binWriter.Write((UInt32)master);
|
binWriter.Write((UInt32)master);
|
||||||
}
|
}
|
||||||
|
|
|
@ -529,5 +529,35 @@ namespace FFXIVClassic_World_Server
|
||||||
}
|
}
|
||||||
return success;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,7 @@
|
||||||
<Compile Include="Packets\WorldPackets\Receive\SessionEndConfirmPacket.cs" />
|
<Compile Include="Packets\WorldPackets\Receive\SessionEndConfirmPacket.cs" />
|
||||||
<Compile Include="Packets\WorldPackets\Send\ErrorPacket.cs" />
|
<Compile Include="Packets\WorldPackets\Send\ErrorPacket.cs" />
|
||||||
<Compile Include="Packets\WorldPackets\Send\Group\PartySyncPacket.cs" />
|
<Compile Include="Packets\WorldPackets\Send\Group\PartySyncPacket.cs" />
|
||||||
|
<Compile Include="Packets\WorldPackets\Send\LinkshellResultPacket.cs" />
|
||||||
<Compile Include="Packets\WorldPackets\Send\SessionBeginPacket.cs" />
|
<Compile Include="Packets\WorldPackets\Send\SessionBeginPacket.cs" />
|
||||||
<Compile Include="Packets\WorldPackets\Send\SessionEndPacket.cs" />
|
<Compile Include="Packets\WorldPackets\Send\SessionEndPacket.cs" />
|
||||||
<Compile Include="PartyManager.cs" />
|
<Compile Include="PartyManager.cs" />
|
||||||
|
|
|
@ -23,8 +23,22 @@ namespace FFXIVClassic_World_Server
|
||||||
mCurrentWorldGroupsReference = worldGroupList;
|
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
|
//Creates a new linkshell and adds it to the list
|
||||||
public ulong CreateLinkshell(string name, ushort crest, uint master)
|
public Linkshell CreateLinkshell(string name, ushort crest, uint master)
|
||||||
{
|
{
|
||||||
lock (mGroupLockReference)
|
lock (mGroupLockReference)
|
||||||
{
|
{
|
||||||
|
@ -33,17 +47,18 @@ namespace FFXIVClassic_World_Server
|
||||||
{
|
{
|
||||||
Linkshell newLs = new Linkshell(resultId, mWorldManager.GetGroupIndex(), name, crest, master, 0xa);
|
Linkshell newLs = new Linkshell(resultId, mWorldManager.GetGroupIndex(), name, crest, master, 0xa);
|
||||||
|
|
||||||
//Add founder to the LS
|
|
||||||
if (AddMemberToLinkshell(master, newLs.name))
|
|
||||||
{
|
|
||||||
mLinkshellList.Add(mWorldManager.GetGroupIndex(), newLs);
|
mLinkshellList.Add(mWorldManager.GetGroupIndex(), newLs);
|
||||||
mNameToIdLookup.Add(newLs.name, newLs.groupIndex);
|
mNameToIdLookup.Add(newLs.name, newLs.groupIndex);
|
||||||
mLSIdToIdLookup.Add(newLs.dbId, newLs);
|
mLSIdToIdLookup.Add(newLs.dbId, newLs);
|
||||||
mCurrentWorldGroupsReference.Add(mWorldManager.GetGroupIndex(), newLs);
|
mCurrentWorldGroupsReference.Add(mWorldManager.GetGroupIndex(), newLs);
|
||||||
mWorldManager.IncrementGroupIndex();
|
mWorldManager.IncrementGroupIndex();
|
||||||
|
|
||||||
|
//Add founder to the LS
|
||||||
|
AddMemberToLinkshell(master, newLs.name);
|
||||||
|
|
||||||
|
return newLs;
|
||||||
}
|
}
|
||||||
}
|
return null;
|
||||||
return resultId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
using FFXIVClassic.Common;
|
||||||
|
using FFXIVClassic_World_Server.DataObjects;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FFXIVClassic_World_Server.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ using FFXIVClassic_World_Server.Packets.Receive.Subpackets;
|
||||||
using FFXIVClassic_World_Server.Packets.Send.Subpackets.Groups;
|
using FFXIVClassic_World_Server.Packets.Send.Subpackets.Groups;
|
||||||
using FFXIVClassic_World_Server.Packets.WorldPackets.Receive;
|
using FFXIVClassic_World_Server.Packets.WorldPackets.Receive;
|
||||||
using FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group;
|
using FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group;
|
||||||
|
using FFXIVClassic_World_Server.Packets.WorldPackets.Send;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
@ -282,7 +283,22 @@ namespace FFXIVClassic_World_Server
|
||||||
//Linkshell create request
|
//Linkshell create request
|
||||||
case 0x1025:
|
case 0x1025:
|
||||||
CreateLinkshellPacket createLinkshellPacket = new CreateLinkshellPacket(subpacket.data);
|
CreateLinkshellPacket createLinkshellPacket = new CreateLinkshellPacket(subpacket.data);
|
||||||
mWorldManager.GetLinkshellManager().CreateLinkshell(createLinkshellPacket.name, createLinkshellPacket.crestid, createLinkshellPacket.master);
|
|
||||||
|
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;
|
break;
|
||||||
//Linkshell modify request
|
//Linkshell modify request
|
||||||
case 0x1026:
|
case 0x1026:
|
||||||
|
|
Loading…
Add table
Reference in a new issue