mirror of
https://github.com/redstrate/Kawari.git
synced 2025-06-30 11:47:45 +00:00
Document the previously unknown parameter for the ServerChatMessage opcode (#62)
Document the previously unknown parameter for the ServerChatMessage opcode Credit goes to Sapphire as usual (see comments)
This commit is contained in:
parent
c926ceb17b
commit
d73ab383e8
5 changed files with 32 additions and 7 deletions
|
@ -314,3 +314,4 @@ registerCommand("wireframe", "commands/debug/ToggleWireframe.lua")
|
||||||
registerCommand("invis", "commands/debug/ToggleInvisibility.lua")
|
registerCommand("invis", "commands/debug/ToggleInvisibility.lua")
|
||||||
registerCommand("unlockaetheryte", "commands/debug/UnlockAetheryte.lua")
|
registerCommand("unlockaetheryte", "commands/debug/UnlockAetheryte.lua")
|
||||||
registerCommand("teri", "commands/debug/ChangeTerritory.lua")
|
registerCommand("teri", "commands/debug/ChangeTerritory.lua")
|
||||||
|
registerCommand("ost", "commands/debug/OnScreenTest.lua")
|
||||||
|
|
10
resources/scripts/commands/debug/OnScreenTest.lua
Normal file
10
resources/scripts/commands/debug/OnScreenTest.lua
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
required_rank = GM_RANK_DEBUG
|
||||||
|
|
||||||
|
CHAT_LOG = 1
|
||||||
|
ON_SCREEN = 4
|
||||||
|
|
||||||
|
function onCommand(args, player)
|
||||||
|
player:send_message("this is a test of on-screen only", ON_SCREEN)
|
||||||
|
--player:send_message("this is an on-screen + chat log test", ON_SCREEN + CHAT_LOG)
|
||||||
|
player:send_message("this is a test of the chat log only, which omits a param")
|
||||||
|
end
|
|
@ -186,7 +186,20 @@ pub enum ServerZoneIpcData {
|
||||||
Warp(Warp),
|
Warp(Warp),
|
||||||
/// Sent by the server when they send a chat message
|
/// Sent by the server when they send a chat message
|
||||||
ServerChatMessage {
|
ServerChatMessage {
|
||||||
unk: u8, // channel?
|
/*
|
||||||
|
* bits (properties will apply when set, but a final base 10 value of zero defaults to chat log only):
|
||||||
|
* 76543210
|
||||||
|
* xxxxxSxC
|
||||||
|
* x = don't care/unused
|
||||||
|
* S = on-screen
|
||||||
|
* C = chat log
|
||||||
|
* all other bits are unused, therefore some possible examples are (base 10 values follow):
|
||||||
|
* 1 = chat log only
|
||||||
|
* 4 = on-screen only
|
||||||
|
* 5 = both
|
||||||
|
* ref: https://github.com/SapphireServer/Sapphire/blob/bf3368224a00c180cbb7ba413b52395eba58ec0b/src/common/Network/PacketDef/Zone/ServerZoneDef.h#L250
|
||||||
|
*/
|
||||||
|
param: u8,
|
||||||
#[brw(pad_after = 774)]
|
#[brw(pad_after = 774)]
|
||||||
#[br(count = 774)]
|
#[br(count = 774)]
|
||||||
#[br(map = read_string)]
|
#[br(map = read_string)]
|
||||||
|
@ -447,7 +460,7 @@ mod tests {
|
||||||
(
|
(
|
||||||
ServerZoneIpcType::ServerChatMessage,
|
ServerZoneIpcType::ServerChatMessage,
|
||||||
ServerZoneIpcData::ServerChatMessage {
|
ServerZoneIpcData::ServerChatMessage {
|
||||||
unk: 0,
|
param: 0,
|
||||||
message: String::new(),
|
message: String::new(),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -610,7 +610,7 @@ impl ZoneConnection {
|
||||||
timestamp: timestamp_secs(),
|
timestamp: timestamp_secs(),
|
||||||
data: ServerZoneIpcData::ServerChatMessage {
|
data: ServerZoneIpcData::ServerChatMessage {
|
||||||
message: message.to_string(),
|
message: message.to_string(),
|
||||||
unk: 0,
|
param: 0,
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
|
@ -73,11 +73,11 @@ impl LuaPlayer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_message(&mut self, message: &str) {
|
fn send_message(&mut self, message: &str, param: u8) {
|
||||||
let op_code = ServerZoneIpcType::ServerChatMessage;
|
let op_code = ServerZoneIpcType::ServerChatMessage;
|
||||||
let data = ServerZoneIpcData::ServerChatMessage {
|
let data = ServerZoneIpcData::ServerChatMessage {
|
||||||
message: message.to_string(),
|
message: message.to_string(),
|
||||||
unk: 0,
|
param,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.create_segment_self(op_code, data);
|
self.create_segment_self(op_code, data);
|
||||||
|
@ -225,8 +225,9 @@ impl LuaPlayer {
|
||||||
|
|
||||||
impl UserData for LuaPlayer {
|
impl UserData for LuaPlayer {
|
||||||
fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {
|
fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {
|
||||||
methods.add_method_mut("send_message", |_, this, message: String| {
|
methods.add_method_mut("send_message", |lua, this, (message, param): (String, Value)| {
|
||||||
this.send_message(&message);
|
let param: u8 = lua.from_value(param).unwrap_or(0);
|
||||||
|
this.send_message(&message, param);
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
methods.add_method_mut(
|
methods.add_method_mut(
|
||||||
|
|
Loading…
Add table
Reference in a new issue