Warzone2100 / warzone2100

Command the forces of The Project in a battle to rebuild the world after mankind has been nearly destroyed by nuclear missiles. A 100% free and open source real-time strategy game for Windows, macOS, Linux, BSD+
https://wz2100.net
GNU General Public License v2.0
3.23k stars 532 forks source link

Crash upon call to generateFractalValueNoise() #4142

Open aco4 opened 1 day ago

aco4 commented 1 day ago

I'm making a script generated map. I'm using the built-in noise generator (https://github.com/Warzone2100/warzone2100/pull/2341). It crashes when certain values are passed to the function. For example, the following is fine:

heightmap = generateFractalValueNoise(
    /* map width                       */ 250,
    /* map length                      */ 250,
    /* range of first layer            */ 510,
    /* range decay (crispness)         */ 3,
    /* resolution of 1st layer (scale) */ 21, // 21
    /* normalize to range              */ 510
    /* rigged regions                  */);

But the following crashes the game with no error message:

heightmap = generateFractalValueNoise(
    /* map width                       */ 250,
    /* map length                      */ 250,
    /* range of first layer            */ 510,
    /* range decay (crispness)         */ 3,
    /* resolution of 1st layer (scale) */ 38, // 38
    /* normalize to range              */ 510
    /* rigged regions                  */);

The following also crashes:

heightmap = generateFractalValueNoise(
    /* map width                       */ 250,
    /* map length                      */ 250,
    /* range of first layer            */ 510,
    /* range decay (crispness)         */ 2, // 2
    /* resolution of 1st layer (scale) */ 21, // 21
    /* normalize to range              */ 510
    /* rigged regions                  */);
--- Starting log [[WIN_USER_FOLDER]\Warzone 2100 Portable-4.5.5\Warzone 2100\logs\WZlog-1122_005824.txt]---
info    |00:58:25: [wzChangeFullscreenDisplayMode:2266] Changing fullscreen mode to [0] 1366x768
info    |00:58:25: [createGLContext:185] Requested OpenGL 3.3 context
info    |00:58:25: [initGLContext:3716] OpenGL Vendor: Intel
info    |00:58:25: [initGLContext:3719] OpenGL Renderer: Intel(R) UHD Graphics
info    |00:58:25: [initGLContext:3722] OpenGL Version: 3.3.0 - Build 30.0.101.1692
info    |00:58:25: [initGLContext:3981] Success
info    |00:58:25: [_initialize:3508]   * Instanced rendering support was detected

To Reproduce

Download this script-generated map, which uses crispness=3 and scale=21. It works fine.

10c-Expanse2.zip

Download this script-generated map, which uses crispness=3 and scale=38. It crashes.

10c-Expanse2.zip

Download this script-generated map, which uses crispness=2 and scale=21. It crashes.

10c-Expanse2.zip

Expected behavior

Shouldn't crash

System

aco4 commented 1 day ago

The noise generator seems to suffer from other issues, limiting its usability. The layers tend to shrink each loop for some reason.

past-due commented 21 hours ago

For reference, here is a map that uses it (and some of the original thinking behind it): https://forums.wz2100.net/viewtopic.php?f=49&t=16523

aco4 commented 15 hours ago

Yes I saw that one but it seems to use "safe" values (scale = 20). Anything other than 20 or 21 causes issues.