LiveSplit / asr

Helper crate to write auto splitters for LiveSplit One's auto splitting runtime.
https://livesplit.org/asr/asr
Apache License 2.0
10 stars 10 forks source link

Godot SceneTree get root not working #101

Open olvior opened 1 month ago

olvior commented 1 month ago

I am trying to make an autosplitter for a game made in Godot. When I start the wasm file it can locate the SceneTree but then when I call scene_tree.wait_get_root(&process).await; it hangs and never finds the root.

This is the rust code:

#![allow(dead_code)]

use asr::future::{next_tick, retry};
use asr::game_engine::godot::SceneTree;

use::asr::Address;
use::asr::Process;

asr::async_main!(stable);
static BLOODTHIEF_NAMES: [&str; 2] = [
    "bloodthief_v0.0",      // linux
    "bloodthief_v0.01.exe", // windows
];

async fn main() {
    let p_name = "bloodthief_v0.01.x86_64";
    // TODO: Set up some general state and settings.
    asr::set_tick_rate(1.0);

    loop {
        let process = wait_attach_bloodthief().await;
        if let Ok(base_address) = process.get_module_address(p_name) {
            process.until_closes(async {
                // TODO: Load some initial information from the process.
                asr::print_message("Locating SceneTree");
                let scene_tree = SceneTree::wait_locate(&process, base_address).await;
                asr::print_message("Locating root");
                let root = scene_tree.wait_get_root(&process).await;
                asr::print_message("Found root");
                asr::print_limited::<4096>(&root.print_tree::<64>(&process));

                loop {
                    // TODO: Do something on every tick.
                    asr::print_message("On tick");
                    next_tick().await;
                    every_tick(base_address);
                }
            }).await;
        }
    }
}

fn every_tick(base_address: Address) {
}

async fn wait_attach_bloodthief() -> Process {
    retry(|| {
        attach_bloodthief()
    }).await
}

fn attach_bloodthief() -> Option<Process> {
    BLOODTHIEF_NAMES.into_iter().find_map(Process::attach)
}
CryZe commented 1 month ago

The Godot support is very new and is very limited:

It's probably one of these limitations that you are running into.

olvior commented 1 month ago
  • Only Windows executables

I'm on Linux so thats why. What is the reason it does not work with Linux executables? I could try modify the source code if it is not something too difficult to get it working.

Jujstme commented 1 month ago

There's actually a lot that needs to be done to support Linux. The most blatant observation in the source is that we have no signature scan to use to look for the scenetree root. We provide only a specific address that's not gonna work for anything except very specific scenarios

CryZe commented 1 month ago

Also when I said 4.3, I actually meant 4.2. I'm working on 4.3 support, which should allow the code to handle more situations.

I'm not sure if you personally could do much unless you can figure out the location of the scene tree in memory yourself.

CryZe commented 1 month ago

@Jujstme I have a signature that at least works for 4.3 and 4.2. Not sure if it would work for Linux, probably not.

Jujstme commented 1 month ago

@Jujstme I have a signature that at least works for 4.3 and 4.2. Not sure if it would work for Linux, probably not.

Pretty much guaranteed it will not work on Linux.

olvior commented 1 month ago

Is support for Linux planned to come soon or is it not a priority/not going to happen?