mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-21 20:27:47 +00:00
Setting the active linkshell now works.
This commit is contained in:
parent
fe1a652cd1
commit
9bc3fc8dd7
11 changed files with 196 additions and 14 deletions
|
@ -289,6 +289,7 @@
|
|||
<Compile Include="packets\WorldPackets\Send\Group\CreateLinkshellPacket.cs" />
|
||||
<Compile Include="packets\WorldPackets\Send\Group\DeleteLinkshellPacket.cs" />
|
||||
<Compile Include="packets\WorldPackets\Send\Group\LinkshellInviteCancelPacket.cs" />
|
||||
<Compile Include="packets\WorldPackets\Send\Group\LinkshellChangePacket.cs" />
|
||||
<Compile Include="packets\WorldPackets\Send\Group\LinkshellRankChangePacket.cs" />
|
||||
<Compile Include="packets\WorldPackets\Send\Group\ModifyLinkshellPacket.cs" />
|
||||
<Compile Include="packets\WorldPackets\Send\Group\GroupInviteResultPacket.cs" />
|
||||
|
|
|
@ -708,6 +708,12 @@ namespace FFXIVClassic_Map_Server
|
|||
Server.GetWorldConnection().QueuePacket(packet, true, false);
|
||||
}
|
||||
|
||||
public void RequestWorldLinkshellChangeActive(Player player, string lsname)
|
||||
{
|
||||
SubPacket packet = LinkshellChangePacket.BuildPacket(player.playerSession, lsname);
|
||||
Server.GetWorldConnection().QueuePacket(packet, true, false);
|
||||
}
|
||||
|
||||
private void RequestWorldServerZoneChange(Player player, uint destinationZoneId, byte spawnType, float spawnX, float spawnY, float spawnZ, float spawnRotation)
|
||||
{
|
||||
ZoneConnection zc = Server.GetWorldConnection();
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic_Map_Server.dataobjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace FFXIVClassic_Map_Server.packets.WorldPackets.Send.Group
|
||||
{
|
||||
class LinkshellChangePacket
|
||||
{
|
||||
public const ushort OPCODE = 0x1028;
|
||||
public const uint PACKET_SIZE = 0x48;
|
||||
|
||||
public static SubPacket BuildPacket(Session session, string lsName)
|
||||
{
|
||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||
{
|
||||
binWriter.Write(Encoding.ASCII.GetBytes(lsName), 0, Encoding.ASCII.GetByteCount(lsName) >= 0x20 ? 0x20 : Encoding.ASCII.GetByteCount(lsName));
|
||||
}
|
||||
}
|
||||
return new SubPacket(true, OPCODE, session.id, session.id, data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
using FFXIVClassic_World_Server.Packets.Send.Subpackets;
|
||||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_World_Server.DataObjects.Group;
|
||||
using FFXIVClassic_World_Server.Packets.Send.Subpackets;
|
||||
using FFXIVClassic_World_Server.Packets.Send.Subpackets.Groups;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -16,7 +19,7 @@ namespace FFXIVClassic_World_Server.DataObjects
|
|||
|
||||
public string characterName;
|
||||
public uint currentZoneId;
|
||||
public uint activeLinkshellIndex = 0;
|
||||
public string activeLinkshellName = "";
|
||||
|
||||
public readonly ClientConnection clientConnection;
|
||||
public readonly Channel type;
|
||||
|
@ -65,5 +68,15 @@ namespace FFXIVClassic_World_Server.DataObjects
|
|||
clientConnection.QueuePacket(GameMessagePacket.BuildPacket(0x5FF80001, sessionId, 0x5FF80001, textId, displayId, log, LuaUtils.CreateLuaParamList(msgParams)), true, false);
|
||||
}
|
||||
|
||||
|
||||
public bool SetActiveLS(string name)
|
||||
{
|
||||
if (Database.SetActiveLS(this, name))
|
||||
{
|
||||
activeLinkshellName = name;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace FFXIVClassic_World_Server
|
|||
|
||||
public static bool LoadZoneSessionInfo(Session session)
|
||||
{
|
||||
string characterName;
|
||||
string characterName, currentLinkshell;
|
||||
uint currentZone = 0;
|
||||
uint destinationZone = 0;
|
||||
bool readIn = false;
|
||||
|
@ -55,7 +55,7 @@ namespace FFXIVClassic_World_Server
|
|||
try
|
||||
{
|
||||
conn.Open();
|
||||
MySqlCommand cmd = new MySqlCommand("SELECT name, currentZoneId, destinationZoneId FROM characters WHERE id = @charaId", conn);
|
||||
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())
|
||||
{
|
||||
|
@ -64,9 +64,11 @@ namespace FFXIVClassic_World_Server
|
|||
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;
|
||||
}
|
||||
|
@ -501,5 +503,31 @@ namespace FFXIVClassic_World_Server
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,7 @@
|
|||
<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" />
|
||||
|
@ -128,12 +129,12 @@
|
|||
<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\SetActiveLinkshellPacket.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" />
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_World_Server.DataObjects.Group;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFXIVClassic_World_Server.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, sessionId, data);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,13 +5,13 @@ using System.Text;
|
|||
|
||||
namespace FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group
|
||||
{
|
||||
class SetActiveLinkshellPacket
|
||||
class LinkshellChangePacket
|
||||
{
|
||||
public bool invalidPacket = false;
|
||||
|
||||
public string name;
|
||||
public string lsName;
|
||||
|
||||
public SetActiveLinkshellPacket(byte[] data)
|
||||
public LinkshellChangePacket(byte[] data)
|
||||
{
|
||||
using (MemoryStream mem = new MemoryStream(data))
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace FFXIVClassic_World_Server.Packets.WorldPackets.Receive.Group
|
|||
{
|
||||
try
|
||||
{
|
||||
name = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
|
||||
lsName = Encoding.ASCII.GetString(binReader.ReadBytes(0x20)).Trim(new[] { '\0' });
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
|
@ -302,8 +302,8 @@ namespace FFXIVClassic_World_Server
|
|||
break;
|
||||
//Linkshell set active
|
||||
case 0x1028:
|
||||
SetActiveLinkshellPacket setActiveLinkshellPacket = new SetActiveLinkshellPacket(subpacket.data);
|
||||
//Linkshell ls = mWorldManager.GetLinkshellManager().GetLinkshell();
|
||||
LinkshellChangePacket linkshellChangePacket = new LinkshellChangePacket(subpacket.data);
|
||||
mWorldManager.ProcessLinkshellSetActive(GetSession(subpacket.header.sourceId), linkshellChangePacket.lsName);
|
||||
break;
|
||||
//Linkshell invite member
|
||||
case 0x1029:
|
||||
|
|
|
@ -220,6 +220,24 @@ namespace FFXIVClassic_World_Server
|
|||
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, true, false);
|
||||
}
|
||||
|
||||
private void SendMotD(Session session)
|
||||
|
@ -408,6 +426,34 @@ namespace FFXIVClassic_World_Server
|
|||
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, true, false);
|
||||
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, true, false);
|
||||
requestSession.SendGameMessage(25131, 0x20, (object)1, (object)lsName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void IncrementGroupIndex()
|
||||
{
|
||||
mRunningGroupIndex++;
|
||||
|
|
15
data/scripts/commands/LinkshellChangeCommand.lua
Normal file
15
data/scripts/commands/LinkshellChangeCommand.lua
Normal file
|
@ -0,0 +1,15 @@
|
|||
--[[
|
||||
|
||||
LinkshellChangeCommand Script
|
||||
|
||||
--]]
|
||||
|
||||
function onEventStarted(player, actor, triggerName, linkshellName, arg1, arg2)
|
||||
|
||||
if (linkshellName == nil) then
|
||||
linkshellName = "";
|
||||
end
|
||||
GetWorldManager():RequestWorldLinkshellChangeActive(player, linkshellName);
|
||||
player:EndEvent();
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue