HEX打印加空格

移除部分DEBUG
修正config
未修正角色数据读取
This commit is contained in:
Longfeng Qin 2024-09-12 17:49:10 +08:00
parent 30b4cab4af
commit 6297da5c59
8 changed files with 30 additions and 23 deletions

View File

@ -23,37 +23,37 @@ namespace PSO2SERVER
Path.DirectorySeparatorChar + "Server.cfg"; Path.DirectorySeparatorChar + "Server.cfg";
// Settings // Settings
[ConfigComment("The address to bind to")] [ConfigComment("服务器对外绑定的地址(支持域名或者IP,优先获取IPV4)")]
public IPAddress BindAddress = IPAddress.Loopback; public IPAddress BindAddress = IPAddress.Loopback;
[ConfigComment("The prefix to check for to send a command from the client to the server")] [ConfigComment("从客户端向服务器发送命令时要检查的前缀")]
public string CommandPrefix = "|"; public string CommandPrefix = "|";
[ConfigComment("Address of the database server")] [ConfigComment("数据库地址")]
public string DatabaseAddress = "127.0.0.1"; public string DatabaseAddress = "127.0.0.1";
[ConfigComment("Port of the database server")] [ConfigComment("数据库端口")]
public string DatabasePort = "3306"; public string DatabasePort = "3306";
[ConfigComment("Name of the database which contains the Server data")] [ConfigComment("数据库表名称")]
public string DatabaseName = "pso2server"; public string DatabaseName = "pso2server";
[ConfigComment("Username for logging into the database server")] [ConfigComment("数据库用户名")]
public string DatabaseUsername = "root"; public string DatabaseUsername = "root";
[ConfigComment("Password for logging into the database server")] [ConfigComment("数据库密码")]
public string DatabasePassword = "root"; public string DatabasePassword = "root";
[ConfigComment("Message of the day to display to users upon login.")] [ConfigComment("登录时显示给用户的当天消息")]
public string motd = "Wellcom PSO2SERVER"; public string motd = "Wellcom PSO2SERVER";
[ConfigComment("Time in seconds to perform a ping of all connected clients to the server")] [ConfigComment("对所有连接到服务器的客户机执行ping操作的时间(以秒为单位)")]
public double PingTime = 60; public double PingTime = 60;
[ConfigComment("Enable foreground colors for console text (Unstable on linux)")] [ConfigComment("为控制台文本启用前景色(在linux上不稳定)")]
public bool UseConsoleColors = true; public bool UseConsoleColors = true;
[ConfigComment("Log the data sent and recieved from packets")] [ConfigComment("记录从数据包发送和接收的数据")]
public bool VerbosePackets = false; public bool VerbosePackets = false;
public void Load() public void Load()

View File

@ -718,7 +718,7 @@ namespace PSO2SERVER
}; };
client.SendPacket(fakePacket); client.SendPacket(fakePacket);
Logger.WriteCommand(client, "[CMD] Spawned a clone of {0} named {1}", name, playerName); Logger.WriteCommand(client, "[CMD] 克隆 {0} 玩家名称 {1} 生成", name, playerName);
} }
private void SendPacket(string[] args, int length, string full, Client client) private void SendPacket(string[] args, int length, string full, Client client)
@ -738,7 +738,7 @@ namespace PSO2SERVER
// Couldn't find the username // Couldn't find the username
if (!foundPlayer) if (!foundPlayer)
{ {
Logger.WriteCommand(client, "[CMD] Could not find user " + name); Logger.WriteCommand(client, "[CMD] 无法找到 " + name);
return; return;
} }

View File

@ -101,6 +101,10 @@ namespace PSO2SERVER
if (j + (i * 16) >= array.Length) if (j + (i * 16) >= array.Length)
break; break;
// Append the hex byte with an extra space for every 8 bytes
if (j % 8 == 0 && j > 0)
hexString += ' ';
hexString += string.Format("{0:X2} ", array[j + (i * 16)]); hexString += string.Format("{0:X2} ", array[j + (i * 16)]);
} }

View File

@ -19,8 +19,8 @@ namespace PSO2SERVER.Packets.Handlers
return; return;
var reader = new PacketReader(data, position, size); var reader = new PacketReader(data, position, size);
var info = string.Format("[<--] 接收到的数据 (hex): "); //var info = string.Format("[<--] 接收到的数据 (hex): ");
Logger.WriteHex(info, data); //Logger.WriteHex(info, data);
reader.ReadBytes(12); // 12 unknown bytes reader.ReadBytes(12); // 12 unknown bytes
reader.ReadByte(); // VoiceType reader.ReadByte(); // VoiceType
@ -32,7 +32,7 @@ namespace PSO2SERVER.Packets.Handlers
var looks = reader.ReadStruct<Character.LooksParam>(); var looks = reader.ReadStruct<Character.LooksParam>();
var jobs = reader.ReadStruct<Character.JobParam>(); var jobs = reader.ReadStruct<Character.JobParam>();
Logger.WriteInternal("[CHR] {0} 创建了名为 {1} 的新角色.", context.User.Username, name); //Logger.WriteInternal("[CHR] {0} 创建了名为 {1} 的新角色.", context.User.Username, name);
var newCharacter = new Character var newCharacter = new Character
{ {
Name = name, Name = name,
@ -57,7 +57,7 @@ namespace PSO2SERVER.Packets.Handlers
newCharacter.CharacterId = 1; newCharacter.CharacterId = 1;
} }
Logger.Write("newCharacter.CharacterId {0} {1}", newCharacter.CharacterId, context.User.PlayerId); //Logger.Write("newCharacter.CharacterId {0} {1}", newCharacter.CharacterId, context.User.PlayerId);
db.Characters.Add(newCharacter); db.Characters.Add(newCharacter);
db.Entry(newCharacter.Player).State = EntityState.Modified; db.Entry(newCharacter.Player).State = EntityState.Modified;

View File

@ -52,6 +52,12 @@ namespace PSO2SERVER.Packets.Handlers
// --- // ---
// CK note: Extra data is likely current equipment, playtime, etc. // CK note: Extra data is likely current equipment, playtime, etc.
// All of that data is currently unaccounted for at the moment. // All of that data is currently unaccounted for at the moment.
//忍者注意:这个包后面可能有额外的数据,
//在固定长度的字符数据结构数组之后。
//需要更多的调查。
// ---
// CK注:额外的数据可能是当前设备,游戏时间等。
//所有这些数据目前都是未知的。
context.SendPacket(0x11, 0x03, 0, writer.ToArray()); context.SendPacket(0x11, 0x03, 0, writer.ToArray());
} }

View File

@ -12,16 +12,13 @@ namespace PSO2SERVER.Packets.Handlers
{ {
if (context.Character == null) if (context.Character == null)
return; return;
var info = string.Format("[<--] 接收到的数据 (hex): "); var info = string.Format("[<--] 接收到的数据 (hex): ");
Logger.WriteHex(info, data); Logger.WriteHex(info, data);
var reader = new PacketReader(data, position, size); var reader = new PacketReader(data, position, size);
reader.BaseStream.Seek(0xC, SeekOrigin.Begin); reader.BaseStream.Seek(0xC, SeekOrigin.Begin);
var channel = reader.ReadUInt32(); var channel = reader.ReadUInt32();
var message = reader.ReadUtf16(0x9D7B, 0x44); var message = reader.ReadUtf16(0x9D3F, 0x44);
//Logger.Write("频道 {0} 对话 {1}", channel, message);
if (message.StartsWith(ServerApp.Config.CommandPrefix)) if (message.StartsWith(ServerApp.Config.CommandPrefix))
{ {

View File

@ -15,7 +15,7 @@ namespace PSO2SERVER.Packets.Handlers
var reader = new PacketReader(data, position, size); var reader = new PacketReader(data, position, size);
var charId = reader.ReadUInt32(); var charId = reader.ReadUInt32();
Logger.Write("id {0}", charId); //Logger.Write("id {0}", charId);
if (context.User == null) if (context.User == null)
return; return;

View File

@ -165,7 +165,7 @@ namespace PSO2SERVER.Zone
Clients.Add(c); Clients.Add(c);
Logger.Write("[MAP] {0} has spawned in {1}.", c.User.Username, Name); Logger.Write("[MAP] {0} 已生成至 {1}.", c.User.Username, Name);
if (InstanceName != null && ZoneManager.Instance.playerCounter.ContainsKey(InstanceName)) if (InstanceName != null && ZoneManager.Instance.playerCounter.ContainsKey(InstanceName))
{ {