File tree Expand file tree Collapse file tree 4 files changed +38
-6
lines changed
Expand file tree Collapse file tree 4 files changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -104,14 +104,27 @@ pub fn create_callback(input: TokenStream) -> TokenStream {
104104 quote ! (
105105 #[ no_mangle]
106106 pub unsafe extern "C" fn #orig_callback_name( #( #orig_callback_params) * ) -> #return_type {
107- crate :: runtime:: Runtime . as_mut( ) . unwrap( ) . #user_func_name( #( #user_func_args) * )
107+ let scripts = crate :: runtime:: Runtime . as_mut( ) . unwrap( ) ;
108+ let mut ret = false ;
109+ for script in scripts. iter_mut( ) {
110+ ret = script. #user_func_name( #( #user_func_args) * ) ;
111+ if crate :: runtime:: __terminate_event_chain {
112+ crate :: runtime:: __terminate_event_chain = false ;
113+ return ret;
114+ }
115+ }
116+ ret
117+
108118 }
109119 )
110120 } else {
111121 quote ! (
112122 #[ no_mangle]
113123 pub unsafe extern "C" fn #orig_callback_name( #( #orig_callback_params) * ) {
114- crate :: runtime:: Runtime . as_mut( ) . unwrap( ) . #user_func_name( #( #user_func_args) * ) ;
124+ let scripts = crate :: runtime:: Runtime . as_mut( ) . unwrap( ) ;
125+ for script in scripts. iter_mut( ) {
126+ script. #user_func_name( #( #user_func_args) * ) ;
127+ }
115128 }
116129 )
117130 } ;
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ mod runtime;
1515
1616pub use events:: Events ;
1717pub use omp_codegen:: main;
18- pub use runtime:: Runtime ;
18+ pub use runtime:: { Runtime , __terminate_event_chain } ;
1919pub use scripting:: actors;
2020pub use scripting:: checkpoints;
2121pub use scripting:: classes;
Original file line number Diff line number Diff line change 11use crate :: events:: Events ;
22
33/// Runtime global object that implements all the callbacks and gamemode data
4- pub static mut Runtime : Option < Box < dyn Events + ' static > > = None ;
4+ pub static mut Runtime : Option < Vec < Box < dyn Events + ' static > > > = None ;
5+
6+ #[ doc( hidden) ]
7+ pub static mut __terminate_event_chain: bool = false ;
Original file line number Diff line number Diff line change 1- pub use omp_gdk:: Runtime ;
1+ pub use omp_gdk:: { Runtime , __terminate_event_chain } ;
22/// Registers the gamemode object and it's events
33#[ macro_export]
44macro_rules! register {
55 ( $name: expr) => {
66 unsafe {
7- omp:: runtime:: Runtime = Some ( Box :: new( $name) ) ;
7+ if omp:: runtime:: Runtime . is_none( ) {
8+ omp:: runtime:: Runtime = Some ( Vec :: new( ) ) ;
9+ }
10+ omp:: runtime:: Runtime
11+ . as_mut( )
12+ . unwrap( )
13+ . push( Box :: new( $name) ) ;
814 }
915 } ;
1016}
17+
18+ #[ macro_export]
19+ macro_rules! terminate_event {
20+ ( $name: expr) => {
21+ unsafe {
22+ omp:: runtime:: __terminate_event_chain = true ;
23+ }
24+ return $name
25+ } ;
26+ }
You can’t perform that action at this time.
0 commit comments