Merge lp://staging/~widelands-dev/widelands/bug-1811030-desync-ai into lp://staging/widelands

Proposed by Notabilis
Status: Merged
Merged at revision: 8957
Proposed branch: lp://staging/~widelands-dev/widelands/bug-1811030-desync-ai
Merge into: lp://staging/widelands
Diff against target: 40 lines (+5/-5)
1 file modified
src/ai/defaultai_seafaring.cc (+5/-5)
To merge this branch: bzr merge lp://staging/~widelands-dev/widelands/bug-1811030-desync-ai
Reviewer Review Type Date Requested Status
Klaus Halfmann compile test Approve
Review via email: mp+361689@code.staging.launchpad.net

Commit message

Replacing logic_rand() with std::rand() in seafaring code of AI.
Should fix desyncs while network gaming.

Description of the change

Calls of logic_rand() have to be done on all participants of a network game. Since the AI code is only executed on the host, calling logic_rand() leads to different random numbers on the participants computers later on, resulting in desynchronized games.

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4391. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/478537625.
Appveyor build 4182. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1811030_desync_ai-4182.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

That code looks perfectly clear and should fix the bug.

Nonetheless I will try to reproduce it in the next days.
So this requires a Network game with at least two Humans and one AI player.
Anyone else with that branch on Disk?

Travis has only problems on OSX with homebrew, as I am compiling on OSX
using MacPorts I will verify OSX, too.

review: Approve (review)
Revision history for this message
Notabilis (notabilis27) wrote :

You should be able to test it with the savegame attached to the linked bug report. With trunk, the savegame desyncs immediately. With this branch you can continue playing. I tested it with two widelands instances running on my system, so no second computer/human should be required for testing.

If trying to reproduce the desync in a new game you have to wait until the AI starts expeditions, which might take some time.

Revision history for this message
kaputtnik (franku) wrote :

I am compiling this branch. Klaus, i will try to be in the lobby the next days.

Playing the map 'Crossing the Horizon' may speed up testing.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Tested this now, Notabilis hint was 100% correct, I got a desync right at the start.

This can go in.

@bunnybot merge

review: Approve (compile test)
Revision history for this message
kaputtnik (franku) wrote :

Notabilis, is this bug maybe also fixed with this branch?

https://bugs.launchpad.net/widelands/+bug/1800366

Revision history for this message
bunnybot (widelandsofficial) wrote :

Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways.

Travis build 4391. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/478537625.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

as travis had only unrelated Issues with OSX / homebrew:

@bunnybot merge force

kapputnik: that savegame from #1800366 shoud be to old,
but it smells just like thes situation I had.

Revision history for this message
Notabilis (notabilis27) wrote :

I compiled the game revision of the other bug report with the changes of this branch applied and it indeed seems to fix the issues there.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: