Style and Clippy fixes.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-10-14 16:53:30 +02:00
parent 9efe1b4e22
commit 691bf7c12e
56 changed files with 354 additions and 249 deletions

View File

@@ -12,14 +12,14 @@ register! {
env: FunctionEnvMut<WebAssemblyEnv>,
side: ExternRef<BattleSide>,
) -> u8 {
if side.value_func(&env).unwrap().has_fled_battle() { 1 } else { 0 }
u8::from(side.value_func(&env).unwrap().has_fled_battle())
}
fn battleside_is_defeated(
env: FunctionEnvMut<WebAssemblyEnv>,
side: ExternRef<BattleSide>,
) -> u8 {
if side.value_func(&env).unwrap().is_defeated() { 1 } else { 0 }
u8::from(side.value_func(&env).unwrap().is_defeated())
}
fn battleside_get_side_index(
@@ -102,7 +102,7 @@ register! {
) -> u8 {
unsafe {
let c_name = CStr::from_ptr(env.data().data().get_raw_pointer(name_ptr));
if side.value_func(&env).unwrap().has_volatile_script(&c_name.as_ref().into()) { 1 } else { 0 }
u8::from(side.value_func(&env).unwrap().has_volatile_script(&c_name.as_ref().into()))
}
}

View File

@@ -10,10 +10,6 @@ register! {
battle_random: ExternRef<ChoiceQueue>,
pokemon: ExternRef<Pokemon>
) -> u8 {
if battle_random.value_func(&env).unwrap().move_pokemon_choice_next(pokemon.value_func(&env).unwrap()) {
1
} else {
0
}
u8::from(battle_random.value_func(&env).unwrap().move_pokemon_choice_next(pokemon.value_func(&env).unwrap()))
}
}

View File

@@ -16,7 +16,7 @@ register! {
env: FunctionEnvMut<WebAssemblyEnv>,
hit: ExternRef<HitData>,
) -> u8 {
if hit.value_func(&env).unwrap().is_critical() { 1 } else { 0 }
u8::from(hit.value_func(&env).unwrap().is_critical())
}
fn hit_data_fail(

View File

@@ -7,20 +7,26 @@ use wasmer::{FunctionEnv, FunctionEnvMut, Imports, StoreMut};
use crate::script_implementations::wasm::script_resolver::WebAssemblyEnv;
use crate::static_data::StaticData;
/// The battle registration
mod battle;
/// Battle random registration
mod battle_random;
/// Battle side registration
mod battle_side;
/// Choice queue registration.
mod choice_queue;
/// The executing move registration/
mod executing_move;
/// The hit data registration/
mod hit_data;
/// Learned move registration
mod learned_move;
/// The party registration.
mod party;
/// Pokemon registration
mod pokemon;
/// Turn choice registration
mod turn_choice;
mod hit_data;
mod battle;
register! {
fn dynamic_library_get_static_data(

View File

@@ -7,7 +7,7 @@ use crate::script_implementations::wasm::script::WebAssemblyScript;
use crate::script_implementations::wasm::script_resolver::WebAssemblyEnv;
use crate::static_data::{ClampedStatisticSet, Species};
use crate::static_data::{Item, StatisticSet};
use crate::{ScriptCategory, StringKey};
use crate::ScriptCategory;
use std::ffi::{c_char, CStr};
use wasmer::FunctionEnvMut;
@@ -134,11 +134,7 @@ register! {
self_inflicted: u8
) -> u8 {
unsafe{
if pokemon.value_func(&env).unwrap().change_stat_boost(transmute(stat), amount, self_inflicted == 1) {
1
} else {
0
}
u8::from(pokemon.value_func(&env).unwrap().change_stat_boost(transmute(stat), amount, self_inflicted == 1))
}
}
@@ -194,8 +190,7 @@ register! {
) -> u8 {
let name : *mut c_char = env.data().data().get_raw_pointer(name);
let name = unsafe { CStr::from_ptr(name) };
let key = StringKey::new(name.to_str().unwrap().into());
if pokemon.value_func(&env).unwrap().has_held_item(&key) { 1 } else { 0 }
u8::from(pokemon.value_func(&env).unwrap().has_held_item(&name.into()))
}
fn pokemon_heal(
@@ -204,7 +199,7 @@ register! {
amount: u32,
allow_revive: u8
) -> u8 {
if pokemon.value_func(&env).unwrap().heal(amount, allow_revive == 1) { 1 } else { 0 }
u8::from(pokemon.value_func(&env).unwrap().heal(amount, allow_revive == 1))
}
fn pokemon_clear_status(
@@ -261,7 +256,7 @@ register! {
) -> u8 {
unsafe {
let c_name = CStr::from_ptr(env.data().data().get_raw_pointer(name_ptr));
if pokemon.value_func(&env).unwrap().has_volatile_script(&c_name.as_ref().into()) { 1 } else { 0 }
u8::from(pokemon.value_func(&env).unwrap().has_volatile_script(&c_name.as_ref().into()))
}
}