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

Possible duplication of functionality in screenshot.cpp #8252

Closed
techgeeknz opened this issue Jul 2, 2020 · 6 comments · Fixed by #10065
Closed

Possible duplication of functionality in screenshot.cpp #8252

techgeeknz opened this issue Jul 2, 2020 · 6 comments · Fixed by #10065
Labels
enhancement Issue would be a good enhancement; we accept Pull Requests! good first issue Good for newcomers

Comments

@techgeeknz
Copy link
Contributor

Version of OpenTTD

Since e04ca90

The introduction of the minimap screenshot feature appears to be duplicating functionality that will be used elsewhere for drawing the widgets within the minimap window; specifically, the GetMinimapOwner function is very likely to be replicating functionality used by the owner information overlay of the minimap window.

Expected result

We shouldn't have multiple codepaths that perform substantially similar functions.

@TrueBrain TrueBrain added enhancement Issue would be a good enhancement; we accept Pull Requests! good first issue Good for newcomers labels Jan 1, 2021
@sauntheninja2
Copy link

sauntheninja2 commented Apr 12, 2021

I would like to work on this issue but how would you eliminate duplication here?

@Phyrik
Copy link

Phyrik commented Jun 15, 2021

Hi, I'd also like to work on this if possible.

It looks like GetMinimapOwner in screenshot.cpp returns the Owner based on the tile given, and that is then used in MinimapScreenCallback to get the colour of the tile. This code seems to have been duplicated from GetSmallMapOwnerPixels in smallmap_gui.cpp, which returns the colour of the tile for the small map, with very little difference.

This could possibly be put into a new file, or an existing one, tasked with getting a colour for a specific world tile, which both the screenshot file and small map file could use instead.

I'm new to open source and OpenTTD development so please let me know if I got anything wrong or if there's a better solution!

@TrueBrain
Copy link
Member

I honestly suspect none of the devs really looked into it, as that most likely would also result in a solution :P But what you describe sounds good, but we won't really know till we see the code :D

I would say, just give it a spin, and make a Pull Request when you think it is done. We take it from there :)

As for new file or existing, I would go with an existing one. Finding a good place might be a bit tricky, but between the 500+ files we have I am sure it fits in one of them :D

@Phyrik
Copy link

Phyrik commented Jun 15, 2021

Thanks for the very quick response!

Yep, I'll try and work on a proper coded solution and open a PR when I think it's ready, as well as try to find somewhere the code could go.

@pon-droid
Copy link

Is it all good if I work on this issue ? I might not start this month since I have some stuff going on though.

@2TallTyler
Copy link
Member

No need to ask permission. Just do it and open a Pull Request. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue would be a good enhancement; we accept Pull Requests! good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants