Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Godot SceneTree get root not working #101

Open
olvior opened this issue Aug 29, 2024 · 7 comments
Open

Godot SceneTree get root not working #101

olvior opened this issue Aug 29, 2024 · 7 comments

Comments

@olvior
Copy link

olvior commented Aug 29, 2024

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
Copy link
Collaborator

CryZe commented Aug 29, 2024

The Godot support is very new and is very limited:

  • It only support Godot 4.3 atm
  • Only release builds
  • Only Windows executables

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

@olvior
Copy link
Author

olvior commented Aug 29, 2024

  • 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
Copy link
Contributor

Jujstme commented Aug 29, 2024

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
Copy link
Collaborator

CryZe commented Aug 29, 2024

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
Copy link
Collaborator

CryZe commented Aug 29, 2024

@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
Copy link
Contributor

Jujstme commented Aug 29, 2024

@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
Copy link
Author

olvior commented Aug 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@CryZe @Jujstme @olvior and others