mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 15:13:16 +00:00
make get function for std map work
This commit is contained in:
parent
bd237869e7
commit
d15ccb2f5d
3 changed files with 19 additions and 48 deletions
|
@ -8,7 +8,6 @@ use modules::{Module, ModuleCtx, entity_sync::EntitySync};
|
||||||
use net::NetManager;
|
use net::NetManager;
|
||||||
use noita_api::add_lua_fn;
|
use noita_api::add_lua_fn;
|
||||||
use noita_api::addr_grabber::{grab_addrs, grabbed_globals};
|
use noita_api::addr_grabber::{grab_addrs, grabbed_globals};
|
||||||
use noita_api::noita::types::TagManager;
|
|
||||||
use noita_api::noita::world::ParticleWorldState;
|
use noita_api::noita::world::ParticleWorldState;
|
||||||
use noita_api::{
|
use noita_api::{
|
||||||
DamageModelComponent, EntityID, VariableStorageComponent,
|
DamageModelComponent, EntityID, VariableStorageComponent,
|
||||||
|
@ -330,41 +329,6 @@ fn module_on_world_init(_lua: LuaState) -> eyre::Result<()> {
|
||||||
|
|
||||||
fn module_on_world_update(_lua: LuaState) -> eyre::Result<()> {
|
fn module_on_world_update(_lua: LuaState) -> eyre::Result<()> {
|
||||||
//let _tracker = TimeTracker::new("on_world_update");
|
//let _tracker = TimeTracker::new("on_world_update");
|
||||||
if noita_api::raw::game_get_frame_num()? > 120 {
|
|
||||||
unsafe {
|
|
||||||
let gg = grabbed_globals()
|
|
||||||
.entity_manager
|
|
||||||
.as_ref()
|
|
||||||
.unwrap()
|
|
||||||
.as_ref()
|
|
||||||
.unwrap();
|
|
||||||
noita_api::print!("{:?}", gg.iter_component_managers().collect::<Vec<_>>());
|
|
||||||
if let Some(e) = gg
|
|
||||||
.iter_entities()
|
|
||||||
.find(|e| e.name.to_string() == "DEBUG_NAME:player")
|
|
||||||
{
|
|
||||||
noita_api::print!("{:?}", gg.iter_all_components(e).collect::<Vec<_>>())
|
|
||||||
}
|
|
||||||
let mgr = (0x01206fac as *const *const TagManager)
|
|
||||||
.as_ref()
|
|
||||||
.unwrap()
|
|
||||||
.as_ref()
|
|
||||||
.unwrap();
|
|
||||||
noita_api::print!("{:?}", mgr);
|
|
||||||
noita_api::print!("{:?}", mgr.tags.iter().collect::<Vec<_>>());
|
|
||||||
noita_api::print!("{:?}", mgr.tags.iter().collect::<Vec<_>>().len());
|
|
||||||
noita_api::print!("{:?}", mgr.tags.len);
|
|
||||||
let mgr = (0x01204b30 as *const *const TagManager)
|
|
||||||
.as_ref()
|
|
||||||
.unwrap()
|
|
||||||
.as_ref()
|
|
||||||
.unwrap();
|
|
||||||
noita_api::print!("{:?}", mgr);
|
|
||||||
noita_api::print!("{:?}", mgr.tags.iter().collect::<Vec<_>>());
|
|
||||||
noita_api::print!("{:?}", mgr.tags.iter().collect::<Vec<_>>().len());
|
|
||||||
noita_api::print!("{:?}", mgr.tags.len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
with_every_module(|ctx, module| module.on_world_update(ctx))
|
with_every_module(|ctx, module| module.on_world_update(ctx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,15 @@ impl<'a> StdString {
|
||||||
let actual_len = slice.iter().position(|&b| b == 0).unwrap_or(self.size);
|
let actual_len = slice.iter().position(|&b| b == 0).unwrap_or(self.size);
|
||||||
str::from_utf8(&slice[..actual_len]).unwrap()
|
str::from_utf8(&slice[..actual_len]).unwrap()
|
||||||
}
|
}
|
||||||
|
pub fn get(&self, index: usize) -> u8 {
|
||||||
|
unsafe {
|
||||||
|
if self.capacity <= 16 {
|
||||||
|
self.buffer.sso_buffer[index]
|
||||||
|
} else {
|
||||||
|
self.buffer.buffer.add(index).read()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
impl From<&str> for StdString {
|
impl From<&str> for StdString {
|
||||||
fn from(value: &str) -> Self {
|
fn from(value: &str) -> Self {
|
||||||
|
@ -90,17 +99,14 @@ impl PartialOrd for StdString {
|
||||||
impl Eq for StdString {}
|
impl Eq for StdString {}
|
||||||
impl Ord for StdString {
|
impl Ord for StdString {
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
match self.size.cmp(&other.size) {
|
let smallest = self.size.min(other.size);
|
||||||
Ordering::Less => Ordering::Less,
|
for i in 0..smallest {
|
||||||
Ordering::Equal => {
|
match self.get(i).cmp(&other.get(i)) {
|
||||||
if self == other {
|
Ordering::Equal => continue,
|
||||||
Ordering::Equal
|
non_eq => return non_eq,
|
||||||
} else {
|
|
||||||
Ordering::Less
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ordering::Greater => Ordering::Greater,
|
|
||||||
}
|
}
|
||||||
|
self.size.cmp(&other.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
|
@ -140,7 +146,8 @@ pub struct StdMapNode<K, V> {
|
||||||
pub parent: *const StdMapNode<K, V>,
|
pub parent: *const StdMapNode<K, V>,
|
||||||
pub right: *const StdMapNode<K, V>,
|
pub right: *const StdMapNode<K, V>,
|
||||||
pub color: bool,
|
pub color: bool,
|
||||||
pad: [u8; 3],
|
pub end: bool,
|
||||||
|
unk: [u8; 2],
|
||||||
pub key: K,
|
pub key: K,
|
||||||
pub value: V,
|
pub value: V,
|
||||||
}
|
}
|
||||||
|
@ -187,7 +194,7 @@ impl<K: 'static, V: 'static> StdMap<K, V> {
|
||||||
StdMapIter {
|
StdMapIter {
|
||||||
root: self.root,
|
root: self.root,
|
||||||
current: unsafe { self.root.as_ref().unwrap().parent },
|
current: unsafe { self.root.as_ref().unwrap().parent },
|
||||||
parents: Vec::with_capacity(12),
|
parents: Vec::with_capacity(8),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn iter_keys(&self) -> impl Iterator<Item = &'static K> {
|
pub fn iter_keys(&self) -> impl Iterator<Item = &'static K> {
|
||||||
|
|
|
@ -4,6 +4,6 @@ use crate::noita::types::{StdMap, StdString};
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TagManager {
|
pub struct TagManager {
|
||||||
unk1: [isize; 3],
|
unk1: [isize; 3],
|
||||||
pub tags: StdMap<StdString, usize>,
|
pub tags: StdMap<StdString, [u8; 4]>,
|
||||||
//TODO unk
|
//TODO unk
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue