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

Cannot get random pokemon to work #6

Closed
xarDeves opened this issue Jan 8, 2024 · 17 comments
Closed

Cannot get random pokemon to work #6

xarDeves opened this issue Jan 8, 2024 · 17 comments

Comments

@xarDeves
Copy link
Contributor

xarDeves commented Jan 8, 2024

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

talwat commented Jan 8, 2024

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

xarDeves commented Jan 8, 2024 via email

@talwat
Copy link
Owner

talwat commented Jan 8, 2024

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

@xarDeves
Copy link
Contributor Author

xarDeves commented Jan 8, 2024

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

talwat commented Jan 8, 2024

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

xarDeves commented Jan 8, 2024 via email

@xarDeves
Copy link
Contributor Author

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

talwat commented Jan 10, 2024

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

@xarDeves
Copy link
Contributor Author

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

talwat commented Jan 10, 2024

This is a really weird bug...

@talwat
Copy link
Owner

talwat commented Jan 11, 2024

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

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

@talwat
Copy link
Owner

talwat commented Jan 11, 2024

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

@xarDeves
Copy link
Contributor Author

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

talwat commented Jan 11, 2024

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

I just issued a pull request that fixed the bug.

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

@talwat
Copy link
Owner

talwat commented Jan 14, 2024

Merged 👍, thanks so much!

@talwat talwat closed this as completed Jan 14, 2024
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

2 participants