mirror of
https://github.com/redstrate/Kawari.git
synced 2025-06-30 03:37:45 +00:00
Document the EventScene struct more: We'll support only two params for now.
We'll have a generic version soon™️, though.
This commit is contained in:
parent
2075da0c5e
commit
53748c33f0
2 changed files with 34 additions and 14 deletions
|
@ -12,11 +12,10 @@ pub struct EventScene {
|
|||
#[brw(pad_before = 2)] // FIXME: um, i don't think this is empty!!
|
||||
pub scene_flags: u32,
|
||||
pub unk1: u32,
|
||||
pub unk2: u8,
|
||||
#[brw(pad_before = 3)]
|
||||
pub unk3: u32,
|
||||
pub unk4: u32,
|
||||
pub unk5: u32,
|
||||
pub params_count: u8,
|
||||
// Extra padding seems needed after or the client will seemingly softlock even with 2 params, possibly used for alignment?
|
||||
#[brw(pad_before = 3, pad_after = 4)]
|
||||
pub params: [u32; 2],
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -49,9 +48,8 @@ mod tests {
|
|||
assert_eq!(event_play.scene, 0);
|
||||
assert_eq!(event_play.scene_flags, 4959237);
|
||||
assert_eq!(event_play.unk1, 0);
|
||||
assert_eq!(event_play.unk2, 1);
|
||||
assert_eq!(event_play.unk3, 0);
|
||||
assert_eq!(event_play.unk4, 0);
|
||||
assert_eq!(event_play.unk5, 0);
|
||||
assert_eq!(event_play.params_count, 1);
|
||||
assert_eq!(event_play.params[0], 0);
|
||||
assert_eq!(event_play.params[1], 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,8 @@ impl LuaPlayer {
|
|||
event_id: u32,
|
||||
scene: u16,
|
||||
scene_flags: u32,
|
||||
param: u8,
|
||||
params_count: u8,
|
||||
params: [u32; 2],
|
||||
) {
|
||||
let op_code = ServerZoneIpcType::EventScene;
|
||||
let data = ServerZoneIpcData::EventScene(EventScene {
|
||||
|
@ -101,7 +102,8 @@ impl LuaPlayer {
|
|||
event_id,
|
||||
scene,
|
||||
scene_flags,
|
||||
unk2: param,
|
||||
params_count,
|
||||
params,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
@ -242,9 +244,29 @@ impl UserData for LuaPlayer {
|
|||
);
|
||||
methods.add_method_mut(
|
||||
"play_scene",
|
||||
|_, this, (target, event_id, scene, scene_flags, param): (ObjectTypeId, u32, u16, u32, u8)| {
|
||||
this.play_scene(target, event_id, scene, scene_flags, param);
|
||||
Ok(())
|
||||
|_,
|
||||
this,
|
||||
(target, event_id, scene, scene_flags, params): (
|
||||
ObjectTypeId,
|
||||
u32,
|
||||
u16,
|
||||
u32,
|
||||
Vec<u32>,
|
||||
)| {
|
||||
let params_arr: [u32; 2];
|
||||
if params.len() == 2 {
|
||||
params_arr = [params[0], params[1]];
|
||||
} else if params.len() == 1 {
|
||||
params_arr = [params[0], 0];
|
||||
} else {
|
||||
this.finish_event(event_id);
|
||||
let message = "Script params are invalid, it contains either more than 2 parameters or no parameters at all!";
|
||||
tracing::error!(message);
|
||||
this.send_message(message, 0);
|
||||
return Ok(());
|
||||
}
|
||||
this.play_scene(target, event_id, scene, scene_flags, params.len() as u8, params_arr);
|
||||
return Ok(());
|
||||
},
|
||||
);
|
||||
methods.add_method_mut(
|
||||
|
|
Loading…
Add table
Reference in a new issue