talwat / pokeget-rs

A better rust version of pokeget.
MIT License
91 stars 3 forks source link

Cannot get random pokemon to work #6

Closed xarDeves closed 6 months ago

xarDeves commented 6 months ago

Hello, i cloned your project while also downloading all the necessary sprites, i am able to run the program and successfully display pokemon. (Note that i can only do that by name).

The problem i specifically face has to do with random pokemon, it seems that the path is wrong when passing in "random", both from the terminal and hardcoded.

The code i am operating on has been slightly changed, however this was an issue from the get-go. This issue is raised as a means for feedback on whether the "random" functionality is actually working, so as to determine whether my filetree/configuration is broken

P.S. i am working on windows.

Thank you.

talwat commented 6 months ago

I haven't tested on windows, which could be the reason. I'll check it out, thanks. Did you make sure that the pokesprite submodule is there?

xarDeves commented 6 months ago

yes, the paths are correct, and it is especially weird behaviour since when a pokemon name is passed it works.

i will test on linux as well...

On Mon, Jan 8, 2024, 2:31 PM Tal @.***> wrote:

I haven't tested on windows, which could be the reason. I'll check it out, thanks. Did you make sure that the pokesprite submodule is there?

— Reply to this email directly, view it on GitHub https://github.com/talwat/pokeget-rs/issues/6#issuecomment-1880919257, or unsubscribe https://github.com/notifications/unsubscribe-auth/APEKFUHH2PO76DLBVR7NWZ3YNPRJTAVCNFSM6AAAAABBRKOCOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBQHEYTSMRVG4 . You are receiving this because you authored the thread.Message ID: @.***>

talwat commented 6 months ago

random works fine on my end, can you try using cargo install to install pokeget instead?

xarDeves commented 6 months ago

tested on linux, still does not work. to be precise, i cloned your repo and downloaded pokesprites in /data

using cargo run -- random through my code editor's terminal, and pokeget random from the within the /target (while also copying pokesprites and trying to modify the path in sprites.rs)

in the installed version random works

i also noticed this... when using this code (both on linux and windows):

let path = &format!(
        "pokesprite/pokemon-gen8/{}/{}{}.png",
        if shiny { "shiny" } else { "regular" },
        if female && !is_random { "female/" } else { "" },
        filename
    );

    eprintln!("path {}", path);
    Data::get(path)
        .unwrap_or_else(|| {
            eprintln!("pokemon not found at path {}", path);
            exit(1);
        })
        .data
        .into_owned()

the output is (notice the ".png" at the start):

.png pokesprite/pokemon-gen8/regular/zarude
.pngmon not found at path pokesprite/pokemon-gen8/regular/zarude

sadly my literall 0 knowledge of rust does not help getting to the bottom of this...

talwat commented 6 months ago

Why not just clone with recursive submodules, like stated in the instructions? That should work, since there's probably an issue with nested directories. Or, there's a random newline being inserted somewhere? You said you made modifications which doesn't exactly inspire confidence, but you shouldn't need to change the path or anything.

in the installed version random works

Yeah, my guess is rust-embed is stupid or whatever.

xarDeves commented 6 months ago

thank you for your quick responses, i will look into it further and come back to the issue if i find a fix

On Mon, Jan 8, 2024, 11:12 PM Tal @.***> wrote:

Why not just clone with recursive submodules, like stated in the instructions? That should work, since there's probably an issue with nested directories. Or, there's a random newline being inserted somewhere? You said you made modifications which doesn't exactly inspire confidence, but you shouldn't need to change the path or anything.

in the installed version random works

Yeah, my guess is rust-embed is stupid or whatever.

— Reply to this email directly, view it on GitHub https://github.com/talwat/pokeget-rs/issues/6#issuecomment-1881828782, or unsubscribe https://github.com/notifications/unsubscribe-auth/APEKFUE7Y2WN4FQ7RFD5ILLYNROL7AVCNFSM6AAAAABBRKOCOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBRHAZDQNZYGI . You are receiving this because you authored the thread.Message ID: @.***>

xarDeves commented 6 months ago

Compiled and run the release build in both windows and linux. The issue persists, when addressing a pokemon with random, or any id i get "pokemon not found".

(used recursive cloning)

talwat commented 6 months ago

That's super strange, does cargo run random work? I'll try to reproduce the issue in a VM or something like that.

xarDeves commented 6 months ago

cargo run random and cargo run {id} do not work (in both linux and windows).

In both platforms, using both cargo run and the release build the printed path is: .pngsprite/pokemon-gen8/regular/{correct pokemon name}

I have tried different ways to apply the format! macro and also used std::path but to no avail, that ".png" always ends up in the beginning of the string, replacing the first four characters.

talwat commented 6 months ago

This is a really weird bug...

talwat commented 6 months ago

Could you make a repository with your current setup? Then I'll see if I can reproduce it, since it works fine for me.

xarDeves commented 6 months ago

The tests i've been running were done with your recursively cloned repo (latest commit of course). Nothing at all changed.

talwat commented 6 months ago

What version of rust are you using? Maybe it's that?

xarDeves commented 6 months ago

the pain... rust v1.75.0 (windows and linux)

Fyi my linux installation uses hyprland, maybe that messes things up ? but then again the exact same thing happens on windows.

talwat commented 6 months ago

Then I have pretty much no idea why this is happening. I'll leave this issue open in case someone else has a similar problem, but this is probably one of the strangest bugs i've encountered.

xarDeves commented 6 months ago

I just issued a pull request that fixed the bug.

Tested on windows and linux. Tested debug and release build.

talwat commented 6 months ago

Merged 👍, thanks so much!