Remove lifetime mess, replace a lot of code with Arc instead of borrows.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This cleans up the codebase massively, and allows me to maintain some semblance of sanity.
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
use std::intrinsics::transmute;
|
||||
|
||||
use crate::dynamic_data::{LearnedMove, MoveLearnMethod, Pokemon, TurnChoice};
|
||||
use crate::dynamic_data::LearnedMove;
|
||||
use crate::script_implementations::wasm::export_registry::register;
|
||||
use crate::script_implementations::wasm::extern_ref::ExternRef;
|
||||
use crate::script_implementations::wasm::script_resolver::WebAssemblyEnv;
|
||||
use crate::static_data::MoveData;
|
||||
|
||||
register! {
|
||||
fn learned_move_get_learn_method<'a>(
|
||||
fn learned_move_get_learn_method(
|
||||
env: &WebAssemblyEnv,
|
||||
turn_choice: ExternRef<LearnedMove>,
|
||||
) -> u8 {
|
||||
@@ -16,7 +16,7 @@ register! {
|
||||
}
|
||||
}
|
||||
|
||||
fn learned_move_get_move_data<'a>(
|
||||
fn learned_move_get_move_data(
|
||||
env: &WebAssemblyEnv,
|
||||
turn_choice: ExternRef<LearnedMove>,
|
||||
) -> ExternRef<MoveData> {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::mem::transmute;
|
||||
|
||||
use crate::dynamic_data::{DamageSource, DynamicLibrary, Pokemon};
|
||||
use crate::dynamic_data::{DynamicLibrary, Pokemon};
|
||||
use crate::script_implementations::wasm::export_registry::register;
|
||||
use crate::script_implementations::wasm::extern_ref::ExternRef;
|
||||
use crate::script_implementations::wasm::script_resolver::WebAssemblyEnv;
|
||||
|
||||
@@ -7,10 +7,10 @@ use crate::script_implementations::wasm::script_resolver::WebAssemblyEnv;
|
||||
|
||||
register! {
|
||||
|
||||
fn turn_choice_get_user<'a>(
|
||||
fn turn_choice_get_user(
|
||||
env: &WebAssemblyEnv,
|
||||
turn_choice: ExternRef<TurnChoice<'a, 'a>>,
|
||||
) -> ExternRef<Pokemon<'a, 'a>> {
|
||||
turn_choice: ExternRef<TurnChoice>,
|
||||
) -> ExternRef<Pokemon> {
|
||||
let turn_choice = turn_choice.value(env).unwrap();
|
||||
ExternRef::new(env.data().as_ref(), turn_choice.user().as_ref().deref())
|
||||
}
|
||||
@@ -28,10 +28,10 @@ register! {
|
||||
}
|
||||
}
|
||||
|
||||
fn turn_choice_move_used_move<'a>(
|
||||
fn turn_choice_move_used_move(
|
||||
env: &WebAssemblyEnv,
|
||||
turn_choice: ExternRef<TurnChoice<'a, 'a>>,
|
||||
) -> ExternRef<LearnedMove<'a>> {
|
||||
turn_choice: ExternRef<TurnChoice>,
|
||||
) -> ExternRef<LearnedMove> {
|
||||
if let TurnChoice::Move(d) = turn_choice.value(env).unwrap() {
|
||||
return ExternRef::new(env.data().as_ref(), d.used_move().as_ref());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user