Skip to content

Commit

Permalink
init_load_removal_pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKnauth committed Jun 3, 2024
1 parent e7485aa commit e0b3136
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/hollow_knight_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::iter::FusedIterator;
use std::mem;
use std::collections::BTreeMap;
use asr::file_format::{elf, pe};
use asr::future::next_tick;
use asr::future::{next_tick, retry};
use asr::watcher::Pair;
use asr::{Address, PointerSize, Process};
use asr::game_engine::unity::mono::{self, Image, Module, UnityPointer};
Expand Down Expand Up @@ -1093,6 +1093,38 @@ impl GameManagerFinder {
process.read_pointer(a, self.string_list_offests.pointer_size)
}

pub async fn init_load_removal_pointers(&self, process: &Process) {
retry(|| self.get_game_state(process)).await;
next_tick().await;
retry(|| self.get_ui_state(process)).await;
next_tick().await;
retry(|| self.get_scene_name(process)).await;
next_tick().await;
retry(|| self.get_next_scene_name(process)).await;
next_tick().await;
retry(|| self.camera_teleporting(process)).await;
next_tick().await;
retry(|| self.accepting_input(process)).await;
next_tick().await;
retry(|| self.tile_map_dirty(process)).await;
next_tick().await;
retry(|| self.deref_pointer(process, &self.player_data_pointers.version)).await;
next_tick().await;
retry(|| self.uses_scene_transition_routine(process)).await;
next_tick().await;
retry(|| self.get_health(process)).await;
next_tick().await;
self.hazard_respawning(process);
next_tick().await;
self.hero_transition_state(process);
next_tick().await;
self.hero_recoil(process);
next_tick().await;
self.hazard_death(process);
next_tick().await;
self.hero_dead(process);
}

pub fn get_scene_name(&self, process: &Process) -> Option<String> {
let s = self.deref_pointer(process, &self.pointers.scene_name).ok()?;
read_string_object(process, &self.string_list_offests, s)
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ async fn main() {
#[cfg(debug_assertions)]
asr::print_message(&format!("scenes_grub_rescued: {:?}", scenes_grub_rescued));

next_tick().await;
// Initialize pointers for load-remover before timer is running
game_manager_finder.init_load_removal_pointers(&process).await;
next_tick().await;
asr::print_message("Initialized load removal pointers");
next_tick().await;

loop {
tick_action(&process, &mut state, &game_manager_finder, &mut scene_store, &mut player_data_store, &mut scene_data_store).await;

Expand Down

0 comments on commit e0b3136

Please sign in to comment.