Sitelet https://web.archive.org/web/20230118230629/https://github.com/OpenRCT2/OpenRCT2/issues/16033
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

Refactor remaining raw constants into sprites.h #16033

Open
ZehMatt opened this issue Nov 27, 2021 · 7 comments
Open

Refactor remaining raw constants into sprites.h #16033

ZehMatt opened this issue Nov 27, 2021 · 7 comments
Labels
good first issue Low hanging fruits good for people new to open source or OpenRCT2. refactor A task that will improve code readability, without changing outcome.

Comments

@ZehMatt
Copy link
Contributor

ZehMatt commented Nov 27, 2021

Constants like 29046 as seen here:

int32_t image_id = 29046 + ((((vehicle->sprite_direction / 8) + session->CurrentRotation) & 3) * 8)

Should be named SPR_SOME_NAME and put into sprites.h, there might be arrays that hold those. It should be easy to find them by looking for calls to PaintAddImageAsChild or PaintAddImageAsParent.

@ZehMatt ZehMatt added refactor A task that will improve code readability, without changing outcome. good first issue Low hanging fruits good for people new to open source or OpenRCT2. labels Nov 27, 2021
@sammy-soto10
Copy link

Hi, I am an undergraduate student looking to work on an open-source project for one of my classes. I would love the chance to take this issue on.

@ZehMatt
Copy link
Contributor Author

ZehMatt commented Jan 25, 2022

All yours

@tupaschoal
Copy link
Member

Sure, go ahead, and welcome :)

sammy-soto10 added a commit to sammy-soto10/OpenRCT2 that referenced this issue Jan 30, 2022
sammy-soto10 added a commit to sammy-soto10/OpenRCT2 that referenced this issue Jan 30, 2022
@tfai8308
Copy link
Contributor

tfai8308 commented Sep 9, 2022

Hey, it doesn't seem like this issue was ever resolved as far as I could tell. It's my first time trying out open source contributions, but does anyone mind if I give it a shot? I would love to use this as a learning experience in working with larger-scale projects.

@duncanspumpkin
Copy link
Contributor

Sure go ahead. Try not to do all of this at once. Do a file at a time and pr that. I think most of the renames will be in paint code try follow the naming convention used by for example the junior coaster.

@tfai8308
Copy link
Contributor

Okay, I'll work on individual files at a time and pr each of those as I complete them. If it's all the same to you, I'll begin with the original example regarding VehiclePaint.cpp/sprites.h and use #16553 as a sort of guidelines to get a feel for this process first.

I do want to ask also, from #16553, should this actually be added in the code somewhere

// Animation of 8 frames for the 4 rotations
constexpr std::array<std::array<uint32_t, 8>, 4> SplashEffect1 = {
    { 29014, 29015, 29016, 29017, 29018, 29019, 29020, 29021 },
    { 29022, ...},
    ...
};

or is it sufficient to put the entries into sprites.h as this?

SPR_SPLASH_EFFECT_1_NW_0 = 29014,
...
SPR_SPLASH_EFFECT_1_NE_0
...
SPR_SPLASH_EFFECT_1_SW_0
...
SPR_SPLASH_EFFECT_1_SE_0
...

@duncanspumpkin
Copy link
Contributor

Start with just adding the entries into the sprites.h and replacing the magic number (i.e. the same as 16553). Then fill in the gaps in the sprites.h file (i.e. frames 1-7: 29015, ...). Then if you understand the code if you could add a constexpr array as per my comment and use that in the code of vehicle paint. That final part is because we don't want to add with an image id as that forces us to keep the image id order.

tfai8308 added a commit to tfai8308/OpenRCT2 that referenced this issue Sep 11, 2022
tfai8308 added a commit to tfai8308/OpenRCT2 that referenced this issue Sep 26, 2022
Gymnasiast pushed a commit that referenced this issue Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Low hanging fruits good for people new to open source or OpenRCT2. refactor A task that will improve code readability, without changing outcome.
Projects
None yet
Development

No branches or pull requests

5 participants