Opened 3 years ago

Closed 3 years ago

#6261 closed defect (fixed)

Random map Ngorongoro does not generate deterministically

Reported by: Feldfeld Owned by: wraitii
Priority: Must Have Milestone: Alpha 25
Component: Core engine Keywords:
Cc: Patch: Phab:D4203

Description

https://wildfiregames.com/forum/topic/41264-alpha-25-pre-releaserelease-candidate-build-testing/?do=findComment&comment=444280

Step to reproduce: generate Ngorongoro in Atlas, seed 9404, change to 2 players and map size normal. Generate a few times. At some point the whole map (with base locations as well) will be different. I think it can also happen to have 2 generations with the same base locations but with different animal/resource placement on the map (meaning the randomness would "desync" at a later time)

I looked at Ngorongoro js source and didn't find anything odd. I tried to generate 2 different but similar maps (heightmaps or with playerPlacementRandom for bases), and didn't manage to reproduce on these.

Attachments (1)

6261_ticket_screenshot.jpg (136.7 KB ) - added by Langbart 3 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Feldfeld, 3 years ago

I tried in a24 release and the bug didn't happen. Maybe remove that map temporarily and leave it as a mod if the bug only happens in this map. (maybe this undeterministic nature would easily trigger multiplayer OOS?)

One way to find the issue, if nothing better is found, could be to binary search through the diffs until the one that introduced the bug is found.

comment:2 by Langbart, 3 years ago

I can also reproduce the problem on the Ngorongoro map. In the screenshot below, I first tested it with 6 players on A24 without any problems. With the latest SVN I noticed that the location of the player bases in the replay is different from the active player.
The next step is to find the commit number that caused the problem.

by Langbart, 3 years ago

Attachment: 6261_ticket_screenshot.jpg added

comment:3 by wraitii, 3 years ago

Patch: Phab:D4203

comment:4 by Silier, 3 years ago

Milestone: Alpha 26Alpha 25

comment:5 by Silier, 3 years ago

Owner: set to wraitii

comment:6 by wraitii, 3 years ago

Resolution: fixed
Status: newclosed

In 25843:

Fix loading grayscale heightmaps for RM maps.

rP2113 introduced code to read Heightmap images into RM terrain data. However, the original diff contained a bug where it read Out-of-bounds array data for grayscale images. This bug was hidden by another issue until D1816 / rP22892, which changed the code and made the OOB read actually relevant. The effect was twofold:

  • The height chosen was not the max of the 3 color channels, but the max of the 3 neighboring pixel (thus slightly lowering the quality of generated maps)
  • The height for the bottom-right coordinates were random memory values, thus garbage.

This random height ended up resulting in non-deterministic map generation, which was reported on Ngorongoro.

The cause of this silent failure is that the transformation to BGRA is not applied for grayscale images, as the alpha transformation is processed first and exits. This is not per-se buggy, so it is not changed here.
The fixed behaviour is specialized for the common grayscale case, and retains the max-of-3-color-channel intended behaviour otherwise.

Fixes #6261.

Reported by: Feldfeld

Differential Revision: https://code.wildfiregames.com/D4203

Note: See TracTickets for help on using tickets.