Minor changes and fixes
This commit is contained in:
parent
f3f5b2acb0
commit
3c6aecb0e9
|
@ -3,7 +3,7 @@ use alloc::boxed::Box;
|
|||
use core::any::Any;
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
use pkmn_lib_interface::app_interface::{
|
||||
BattleSide, DamageSource, ExecutingMove, Pokemon, TurnChoice,
|
||||
BattleSide, DamageSource, DataLibrary, ExecutingMove, Pokemon, TurnChoice,
|
||||
};
|
||||
use pkmn_lib_interface::handling::{Script, ScriptCapabilities};
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@ edition = "2021"
|
|||
mock_data = []
|
||||
|
||||
[dependencies]
|
||||
wee_alloc = "0.4.5"
|
||||
cstr_core = { version = "0.2.6", features = ["nightly"]}
|
||||
enumflags2 = { version = "0.7.5", default-features = false }
|
||||
spin = { version = "0.9.4", default-features = false, features = ["rwlock"] }
|
||||
paste = { version = "1.0.7" }
|
||||
hashbrown = { version = "0.12.3" }
|
||||
dlmalloc = { version = "0.2.4", features = ["global"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ impl Battle {
|
|||
unsafe { battle_get_pokemon(self.inner.reference, side, index).get_value() }
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "mock_data"))]
|
||||
pub fn find_party_for_pokemon(&self, pokemon: &Pokemon) -> Option<BattleParty> {
|
||||
unsafe {
|
||||
battle_find_party_for_pokemon(self.inner.reference, pokemon.reference()).get_value()
|
||||
|
|
|
@ -23,6 +23,7 @@ impl ExternalReferenceType for ChoiceQueue {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "mock_data"))]
|
||||
extern "wasm" {
|
||||
fn choice_queue_move_pokemon_choice_next(
|
||||
r: ExternRef<ChoiceQueue>,
|
||||
|
|
|
@ -126,6 +126,7 @@ impl ExternalReferenceType for HitData {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "mock_data"))]
|
||||
extern "wasm" {
|
||||
fn executing_move_get_number_of_targets(r: ExternRef<ExecutingMove>) -> usize;
|
||||
fn executing_move_get_number_of_hits(r: ExternRef<ExecutingMove>) -> u8;
|
||||
|
|
|
@ -36,12 +36,12 @@ impl DataLibrary<Item> for ItemLibrary {
|
|||
|
||||
#[cfg(not(feature = "mock_data"))]
|
||||
fn _get_ref_by_name(ptr: ExternRef<Self>, name: ExternRef<StringKey>) -> ExternRef<Item> {
|
||||
unsafe { move_library_get_move(ptr, name) }
|
||||
unsafe { item_library_get_item(ptr, name) }
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "mock_data"))]
|
||||
fn _get_ref_by_hash(ptr: ExternRef<Self>, hash: u32) -> ExternRef<Item> {
|
||||
unsafe { move_library_get_move_by_hash(ptr, hash) }
|
||||
unsafe { item_library_get_item_by_hash(ptr, hash) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,11 +56,11 @@ impl ExternalReferenceType for ItemLibrary {
|
|||
|
||||
#[cfg(not(feature = "mock_data"))]
|
||||
extern "wasm" {
|
||||
fn move_library_get_move(
|
||||
fn item_library_get_item(
|
||||
ptr: ExternRef<ItemLibrary>,
|
||||
name: ExternRef<StringKey>,
|
||||
) -> ExternRef<Item>;
|
||||
fn move_library_get_move_by_hash(ptr: ExternRef<ItemLibrary>, hash: u32) -> ExternRef<Item>;
|
||||
fn item_library_get_item_by_hash(ptr: ExternRef<ItemLibrary>, hash: u32) -> ExternRef<Item>;
|
||||
}
|
||||
|
||||
#[cfg(feature = "mock_data")]
|
||||
|
|
|
@ -10,7 +10,7 @@ pub mod type_library;
|
|||
|
||||
use crate::app_interface::species_library::SpeciesLibrary;
|
||||
use crate::app_interface::type_library::TypeLibrary;
|
||||
use crate::app_interface::LevelInt;
|
||||
use crate::app_interface::{get_hash, LevelInt};
|
||||
use crate::handling::cached_value::CachedValue;
|
||||
use crate::handling::Cacheable;
|
||||
pub use item_library::*;
|
||||
|
@ -179,6 +179,13 @@ where
|
|||
v
|
||||
}
|
||||
|
||||
fn get_by_str(&self, name: &str) -> Option<T>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self.get_by_hash(get_hash(name))
|
||||
}
|
||||
|
||||
fn get_by_hash(&self, hash: u32) -> Option<T>
|
||||
where
|
||||
Self: Sized,
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#![feature(repr128)]
|
||||
#![feature(downcast_unchecked)]
|
||||
#![feature(panic_info_message)]
|
||||
#![feature(const_btree_new)]
|
||||
#![feature(wasm_abi)]
|
||||
#![feature(thread_local)]
|
||||
#![feature(build_hasher_simple_hash_one)]
|
||||
|
@ -18,10 +17,10 @@
|
|||
|
||||
extern crate alloc;
|
||||
extern crate core;
|
||||
extern crate wee_alloc;
|
||||
extern crate dlmalloc;
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
||||
static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc {};
|
||||
|
||||
use crate::app_interface::list::ImmutableList;
|
||||
use crate::app_interface::Statistic;
|
||||
|
|
|
@ -14,9 +14,10 @@ extern "wasm" {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "mock_data"))]
|
||||
pub fn print_raw(s: CString) {
|
||||
pub fn print_raw(s: &[u8]) {
|
||||
unsafe {
|
||||
_print(s.as_ptr());
|
||||
let cstring = CString::from_vec_unchecked(s.to_vec());
|
||||
_print(cstring.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue