修正对话
This commit is contained in:
parent
edd0feda14
commit
666110163e
@ -1,10 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using PSO2SERVER.Models;
|
||||
using PSO2SERVER.Packets.PSOPackets;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace PSO2SERVER.Packets.Handlers
|
||||
{
|
||||
|
||||
[PacketHandlerAttr(0x07, 0x00)]
|
||||
public class ChatHandler : PacketHandler
|
||||
{
|
||||
@ -18,8 +19,11 @@ namespace PSO2SERVER.Packets.Handlers
|
||||
Logger.WriteHex(info, data);
|
||||
|
||||
var reader = new PacketReader(data, position, size);
|
||||
reader.BaseStream.Seek(0xC, SeekOrigin.Begin);
|
||||
var channel = reader.ReadUInt32();
|
||||
var obj = reader.ReadStruct<ObjectHeader>();
|
||||
var channel = reader.ReadByte();
|
||||
var unk3 = reader.ReadByte();
|
||||
var unk4 = reader.ReadInt16();
|
||||
reader.BaseStream.Seek(0x4, SeekOrigin.Current);
|
||||
var message = reader.ReadUtf16(0x9D3F, 0x44);
|
||||
|
||||
if (message.StartsWith(ServerApp.Config.CommandPrefix))
|
||||
@ -50,44 +54,16 @@ namespace PSO2SERVER.Packets.Handlers
|
||||
{
|
||||
Logger.Write("[CHT] <{0}> 频道{1}说 {2}", context.Character.Name, channel, message);
|
||||
|
||||
var writer = new PacketWriter();
|
||||
writer.WriteAccountHeader((uint) context._account.AccountId);
|
||||
writer.Write(channel);
|
||||
writer.WriteUtf16(message, 0x9D3F, 0x44);
|
||||
|
||||
data = writer.ToArray();
|
||||
|
||||
foreach (var c in Server.Instance.Clients)
|
||||
{
|
||||
if (c.Character == null || c.CurrentZone != context.CurrentZone)
|
||||
continue;
|
||||
|
||||
c.SendPacket(0x07, 0x00, 0x44, data);
|
||||
c.SendPacket(new ChatPacket((uint)context._account.AccountId, channel, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
public enum MessageChannel : byte
|
||||
{
|
||||
// Map channel.
|
||||
Map = 0,
|
||||
|
||||
// Party channel.
|
||||
Party = 1,
|
||||
|
||||
// Alliance channel.
|
||||
Alliance = 2,
|
||||
|
||||
// Whisper channel.
|
||||
Whisper = 3,
|
||||
|
||||
// Group channel.
|
||||
Group = 4,
|
||||
|
||||
// Undefined channel.
|
||||
Undefined = 0xFF
|
||||
}
|
||||
|
||||
}
|
98
Server/Packets/PSOPackets/07-ChatPacket/07-00-ChatPacket.cs
Normal file
98
Server/Packets/PSOPackets/07-ChatPacket/07-00-ChatPacket.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using PSO2SERVER.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Remoting.Channels;
|
||||
using System.Runtime.Remoting.Contexts;
|
||||
using System.Text;
|
||||
using static PSO2SERVER.Packets.Handlers.ChatHandler;
|
||||
|
||||
namespace PSO2SERVER.Packets.PSOPackets
|
||||
{
|
||||
public class ChatPacket : Packet
|
||||
{
|
||||
public enum MessageChannel : byte
|
||||
{
|
||||
// Map channel.
|
||||
Map = 0,
|
||||
|
||||
// Party channel.
|
||||
Party = 1,
|
||||
|
||||
// Alliance channel.
|
||||
Alliance = 2,
|
||||
|
||||
// Whisper channel.
|
||||
Whisper = 3,
|
||||
|
||||
// Group channel.
|
||||
Group = 4,
|
||||
|
||||
// Undefined channel.
|
||||
Undefined = 0xFF
|
||||
}
|
||||
|
||||
/// Sender of the message.
|
||||
public ObjectHeader Object;
|
||||
|
||||
/// Message channel.
|
||||
public byte Channel;
|
||||
|
||||
public byte Unk3;
|
||||
public ushort Unk4;
|
||||
|
||||
// Only included if feature is enabled
|
||||
#if NGS_PACKETS
|
||||
public ushort Unk5;
|
||||
public ushort Unk6;
|
||||
#endif
|
||||
|
||||
public string Unk7;
|
||||
|
||||
/// Message.
|
||||
public string Message;
|
||||
|
||||
public ChatPacket(uint id, byte channel, string message)
|
||||
{
|
||||
Object = new ObjectHeader()
|
||||
{
|
||||
ID = id,
|
||||
padding = 0,
|
||||
ObjectType = ObjectType.Player,
|
||||
MapID = 0
|
||||
};
|
||||
|
||||
Unk3 = 0xFF;
|
||||
|
||||
Channel = channel;
|
||||
|
||||
Message = message;
|
||||
}
|
||||
|
||||
#region implemented abstract members of Packet
|
||||
|
||||
public override byte[] Build()
|
||||
{
|
||||
var pkt = new PacketWriter();
|
||||
pkt.WriteStruct(Object);
|
||||
pkt.Write(Channel);
|
||||
pkt.Write(Unk3);
|
||||
pkt.Write(Unk4);
|
||||
|
||||
pkt.Write((byte)0x7B);
|
||||
pkt.Write((byte)0x9D);
|
||||
pkt.Write((byte)0);
|
||||
pkt.Write((byte)0);
|
||||
|
||||
pkt.WriteUtf16(Message, 0x9D3F, 0x44);
|
||||
return pkt.ToArray();
|
||||
}
|
||||
|
||||
public override PacketHeader GetHeader()
|
||||
{
|
||||
return new PacketHeader(0x07, 0x00, PacketFlags.PACKED | PacketFlags.OBJECT_RELATED);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -122,7 +122,7 @@ namespace PSO2SERVER.Packets
|
||||
{
|
||||
Write(id);
|
||||
Write((uint) 0);
|
||||
Write((ushort) 4);
|
||||
Write((ushort)ObjectType.Player);
|
||||
Write((ushort) 0);
|
||||
}
|
||||
|
||||
|
@ -209,6 +209,7 @@
|
||||
<Compile Include="Packets\Handlers\2B-SettingHandler\2B-01-SavePlayerSettings.cs" />
|
||||
<Compile Include="Packets\Handlers\2B-SettingHandler\2B-00-SettingsRequest.cs" />
|
||||
<Compile Include="Packets\Handlers\2F-SymbolHandler\2F-06-SymbolArtHandler.cs" />
|
||||
<Compile Include="Packets\PSOPackets\07-ChatPacket\07-00-ChatPacket.cs" />
|
||||
<Compile Include="Packets\PSOPackets\0E-PartyPacket\0E-65-Unk0E65Packet.cs" />
|
||||
<Compile Include="Packets\PSOPackets\49-UNK49\49-01-Unk4901Packet.cs" />
|
||||
<Compile Include="Packets\PSOPackets\03-ServerPacket\03-0B-ServerPingPacket.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user