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

Game not loading when adding new blocks #14

Open
cohaereo opened this issue Apr 27, 2018 · 8 comments
Open

Game not loading when adding new blocks #14

cohaereo opened this issue Apr 27, 2018 · 8 comments

Comments

@cohaereo
Copy link
Contributor

cohaereo commented Apr 27, 2018

So i was adding some more blocks (Block.c, Block.h, Player.c), and to my surprise the game showed me a black screen. I ran it through Citra, and it showed an error message: "Failed to load the texture romfs:/textures/entity/steve.png". After removing some blocks it ran again. https://i.imgur.com/aByzTLy.png

@RSDuck
Copy link
Owner

RSDuck commented Apr 27, 2018

can you please show me your source code?

@RSDuck
Copy link
Owner

RSDuck commented Apr 27, 2018

this might be caused by a buffer overflow.

the inventory size array has a length of 27. But here is l incremented further than the array length. This way you write into memory where some other data could be located which is then overwritten. C can be very nasty when it comes to these things.

Also I wouldn't use so many Block Ids just for the different types of wood, but instead use metadata.

EDIT: reserve 5 entries per log type in the metadata, so that it will be easier to implement block rotations one day

@cohaereo
Copy link
Contributor Author

Tried using metadata in the same way as you did with the wool blocks but with textures. Still crashes on boot (changes pushed in my fork)

@RSDuck
Copy link
Owner

RSDuck commented Apr 28, 2018

have you pushed your changes to Github?

@cohaereo
Copy link
Contributor Author

cohaereo commented Apr 28, 2018

Yes
EDIT: i did hit commit, forgot to push everything, my bad

@RSDuck
Copy link
Owner

RSDuck commented Apr 29, 2018

https://github.com/firewolfgames/craftus_reloaded/blob/master/source/blocks/Block.c#L22
Problem solved! The problem was that you missed the .png! But what's mysterious about it, is that no error was thrown, eventhough there is proper error handling there. It might be a problem with lodepng or the error handling simply wrong, which wouldn't be a surprise after realising that I used two variables which always contain the exact same content(https://github.com/RSDuck/craftus_reloaded/blob/master/source/rendering/TextureMap.c#L141).
Whatever, I revised the function that I load the file by myself(that's the reason why I found the error) and only using lodepng to decode the buffer. This is also more performant, because the buffer where the file is stored is only allocated a few times(and not everytime).

Anyhow, why have you changed the texture pack? There's a reason why I chose this one(besides that I like it more than the default 😄), namely because it's licensed under CC BY-SA, so there are no copyright infrigements when distributing it, as long you follow it's terms that the author has to be attributed and that the files have to stay under CC BY-SA.

@cohaereo
Copy link
Contributor Author

I feel stupid now 😂 anyways thanks!
I used the original texture pack just so i can make out whats what, was never actually supposed to get on github (i'll try to include it when pushing to my fork)

@cohaereo cohaereo reopened this May 20, 2018
@cohaereo
Copy link
Contributor Author

Actually it's not quite solved, still the same error

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