1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-09-27 12:38:57 +00:00

Allow TSC to keep running when no proper end is reached

This commit is contained in:
dawnDus 2022-03-17 18:26:48 -04:00
parent 1e7da276ab
commit 9dba30d360
No known key found for this signature in database
GPG key ID: 972AABDE81848F21
2 changed files with 16 additions and 3 deletions

View file

@ -123,6 +123,11 @@ impl TextScript {
}
}
// Some nicalis challenges are very broken
if !strict {
put_varint(TSCOpCode::_END as i32, &mut bytecode);
}
Ok(bytecode)
}

View file

@ -267,7 +267,7 @@ impl TextScriptVM {
pub fn run(state: &mut SharedGameState, game_scene: &mut GameScene, ctx: &mut Context) -> GameResult {
let scripts_ref = state.textscript_vm.scripts.clone();
let scripts = scripts_ref.borrow_mut();
let scripts = scripts_ref.borrow();
let mut cached_event: Option<(u16, &Vec<u8>)> = None;
loop {
@ -638,9 +638,17 @@ impl TextScriptVM {
}
}
TSCOpCode::_END => {
// Vanilla keeps execution going into the next event if no proper end condition is met
let scripts_ref = state.textscript_vm.scripts.clone();
let scripts = scripts_ref.borrow();
let script_list = scripts.scene_script.get_event_ids();
if let Some(next_event) = script_list.iter().find(|&&next_event| next_event > event) {
exec_state = TextScriptExecutionState::Running(*next_event, 0 as u32);
} else {
state.textscript_vm.flags.set_cutscene_skip(false);
exec_state = TextScriptExecutionState::Ended;
}
}
TSCOpCode::END => {
state.textscript_vm.flags.set_cutscene_skip(false);
state.control_flags.set_tick_world(true);