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.64k stars 370 forks source link

Hotseat multiplayer - Last human player gets to see all other human player maps revealed! #7781

Open Stisen1 opened 11 months ago

Stisen1 commented 11 months ago

Preliminary checks

Platform

Windows

Describe the bug

image

image

Normally you can't see what other players' revealed maps look like, while you play your own turn during a hotseat session.

BUT for some reason: When the last human player (who goes before any AI player) ends his/her turn, he/she gets to see all other human players' revealed maps, while watching the AI player(s) play their turn!!! It only happens as soon as an AI enters the last human player's revealed area of the map.

When does this trigger:

image

image

This does NOT happen at all in the original game. In the original game you only get to see your own revealed map, while the AI's walk around. I have tried both the above mentioned situations.

Save file

[three saves from multiplayer - Slugfest.zip] (https://github.com/ihhub/fheroes2/files/12672347/three.saves.from.multiplayer.-.Slugfest.zip)

Make the AI player movement walk as slowly as possible, so you get to have a good look on what happens. You get to see EVERYTHING!!!

Go through the source code of the original game and see why it works as intended there. Try to reproduce the solution in fheroes2 source code.

Additional info

No response

zenseii commented 11 months ago

Hi, @Stisen1.

Go through the source code of the original game and see why it works as intended there.

I don't know from where you have been told that we have the original Heroes 2 source code, but if we did then this project would get a Cease and Desist letter from Ubisoft before you could say "Blah".

This whole project is based purely on observing how the original game works, and figuring out our own way to implement that.

Copying from the original game's source code is copyright infringement, in other words illegal.

fheroes2 is an "engine recreation/remake", NOT a "mod", NOT a "source-port", and NOT a "decompilation of the original game".

We do not have the original Heroes 2 source code, and frankly speaking, I doubt the original Heroes 2 source code even exists anymore. I have no belief that Ubisoft has Heroes 2's source code, when they barely even had Heroes 3's source code - a game which released later.

Stisen1 commented 11 months ago

Arh... Now I see why you devs ask so many questions about how things work in the original game. I never got my head around how different the games' really are.

I was naive to believe, that you had access to the source code of the original game. I thought GOG had that one in their possesion...

So... Is a source code something like the files a musician uses for his digital editing of a soundtrack? For instans, I have made my own soundtracks with an Ejay demo. I have the soundtrack as an mp3-file, but I do NOT have the file for re-editting purposes anymore.

zenseii commented 11 months ago

@Stisen1. Yes, that is one way to look at it, or to make a comparison you're very familiar with, it would be like having the MO file of a translation, i.e. the compiled binary file, but not the PO file. Though for text files like those there wouldn't be much of a difference between the compiled and non-compiled file, but for entire programs like games it is day and night.

dood-apo commented 6 months ago

Reproduced this on the current master branch. Seems like a pretty big problem - hotseat with ai players is practically unplayable due to this bug.

Per my investigation it was introduced in PR #6809 , to be more precise by this change in game_startgame.cpp:

-                    world.ClearFog( player->GetColor() );
+                    // In Hot Seat mode there could be different alliances so we have to update fog directions for some cases.
+                    if ( isHotSeatGame ) {
+                        Maps::Tiles::updateFogDirectionsInArea( { 0, 0 }, { world.w(), world.h() }, hotSeatAIFogColors( player ) );
+                    }

Seems like for a pretty normal situation where every player (including AI) is on their own (no alliances), the code hotSeatAIFogColors treats all the human players as one big source of fog data for an AI to use while rendering its movement. Reverting this little part of the PR seems to fix the issue and make it behave more like in the OG (only the player directly before AI in the turn order can see its movements, but at least on his unveiled map only).

@Districh-ru , as an author of that PR, what do you think - is it safe to revert that part mentioned above?

Districh-ru commented 6 months ago

Hi, @dood-apo, this bug was introduced more earlier than the mentioned PR and was not solved in it. At that moment there was no proper solution to allow all players to see their opponents moves so the fog reveal logic was left unchanged (only slightly modified). :( The ideal solution wold be to implement recording off all players actions on the Adventure map and allow to see and replay opponents moves, in example like in Heroes 3: изображение

But for now we can try reproduce the OG behavior. But removing the mentioned code (including the hotSeatAIFogColors() function) will not fully solve the issue. This will not reveal the map on the AI move start, but we will see all new unveiled tiles by all allied AIs of all human players. :( изображение

To fix it we will also need to store the last human player color and use it instead of Players::HumanColors() in Maps::ClearFog() (maps.cpp) in this line:

const bool isHumanOrHumanFriend = !isAIPlayer || Players::isFriends( playerColor, Players::HumanColors() );