ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.71k stars 375 forks source link

Flag's color on boat changes during movement #7354

Open ihhub opened 1 year ago

ihhub commented 1 year ago

Preliminary checks

Platform

Windows

Describe the bug

When a hero rides a boat the color of the flag sometimes changes to gray which is used for neutral army:

https://github.com/ihhub/fheroes2/assets/19829520/2b761e83-637e-484c-96b9-ee69ba89c23f

Save file

AI_fog_discvery.zip

Additional info

No response

Districh-ru commented 1 year ago

This is an issue of render priority (the order of rendering objects). By executing: https://github.com/ihhub/fheroes2/blob/2c66adf0f0a48ca9f9d031d9ae51cf9125cf8e05/src/fheroes2/gui/interface_gamearea.cpp#L255-L257 we put hero boat objects in the reversed order so the boat (with the default white flag) is rendered over the colored flag for the left part (x<0) of the sprite: while moving left the position remains and the sprite is moved to the left, so the flag becomes the left part. We might use here emplace_back() to fix this issue but this change can produce new rendering issues (I think that emplace_front() is used here for a reason). Or we can, better, expand the condition, in example: imagePos.x < 0 && imagePos.y >= 0 ... this needs a thorough check. We already have some rendering priority issues and currently it is not easy to make a common solution for all of them :( If I'll get an idea I'll try it in a new PR. Also we can fix this bug by deleting (making transparent) the neutral player boat flag - as neutral boats never move this will not produce new issues... изображение