Minor changes and fixes

This commit is contained in:
2023-01-04 11:55:14 +01:00
parent f3f5b2acb0
commit 3c6aecb0e9
9 changed files with 22 additions and 12 deletions

View File

@@ -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")]

View File

@@ -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,