@@ -3,6 +3,9 @@ use std::sync::Arc;
33
44use async_trait:: async_trait;
55use byteorder:: { BigEndian , LittleEndian , ReadBytesExt } ;
6+ use serde:: Serialize ;
7+ use tentacli_packet:: WorldPacket ;
8+ use tentacli_traits:: types:: chat:: { Language , MessageType } ;
69use tentacli_traits:: types:: movement:: ObjectUpdateFlags ;
710use tentacli_traits:: types:: opcodes:: Opcode ;
811use tokio:: io:: { AsyncReadExt , BufReader } ;
@@ -64,11 +67,7 @@ const WHITELISTED_OPCODES: &[u16] = &[
6467 // FOR TESTING
6568 Opcode :: SMSG_POWER_UPDATE ,
6669 Opcode :: SMSG_SPELLLOGEXECUTE ,
67- Opcode :: SMSG_INITIAL_SPELLS ,
68- Opcode :: SMSG_INITIALIZE_FACTIONS ,
69- Opcode :: SMSG_ACTION_BUTTONS ,
7070 Opcode :: SMSG_INIT_WORLD_STATES ,
71- Opcode :: SMSG_LOAD_EQUIPMENT_SET ,
7271 Opcode :: SMSG_LEARNED_DANCE_MOVES ,
7372 Opcode :: SMSG_CHANNEL_NOTIFY ,
7473 Opcode :: SMSG_ATTACKSTART ,
@@ -112,6 +111,37 @@ impl RelayServer {
112111 }
113112 . to_binary_with_server_opcode ( Opcode :: SMSG_UPDATE_OBJECT ) ?)
114113 }
114+ Opcode :: SMSG_MESSAGECHAT => {
115+ // overriding chat messages to understand each language
116+ #[ derive( WorldPacket , Serialize , Debug ) ]
117+ struct Incoming {
118+ message_type : u8 ,
119+ language : u32 ,
120+ sender_guid : u64 ,
121+ skip : u32 ,
122+ #[ conditional]
123+ channel_name : String ,
124+ target_guid : u64 ,
125+ message_length : u32 ,
126+ #[ depends_on( message_length) ]
127+ message : String ,
128+ unknown : u16 ,
129+ }
130+
131+ impl Incoming {
132+ fn channel_name ( instance : & mut Self ) -> bool {
133+ instance. message_type == MessageType :: CHANNEL
134+ }
135+ }
136+
137+ let ( fields, _) = Incoming :: from_binary ( & packet[ 4 ..] ) ?;
138+
139+ Ok ( Incoming {
140+ language : Language :: UNIVERSAL ,
141+ ..fields
142+ }
143+ . to_binary_with_server_opcode ( Opcode :: SMSG_MESSAGECHAT ) ?)
144+ }
115145 _ => Ok ( packet. to_vec ( ) ) ,
116146 }
117147 }
0 commit comments