Patch: The Rainfall River Generator

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Concerning the crashes on bigger maps:

A backtrace from gdb would be helpful, where / maybe in which data structure does it abort?

Of course it is also possible that you simply run into a bug that causes a segfault for you, but not on my system. But "without crash log" sounds like a more severe problem, like no memory left.

Flat maps need somewhat more memory as the heightlevel based iteration there finds a lot of tiles at height 1 or 2, where on steep maps, the tiles are more distributed among the heightlevels.

Although, coming back to my 500000 tiles in a std::set example, if I assume 50 bytes for each tile (I really hope that std::set needs less...), then I need 25 MB for that data structure. From that point of view, I don´t understand why I should have a memory problem (assuming that we don´t talk about 15 or 20 year old hardware...). Or do those std::set / std::map containers suffer from some memory fragmentation problems and in fact need much more memory? I hope not...

I will probably have a look on that, but (except you give me a reasonable stacktrace) after the algorithmic changes I currently work on.
User avatar
JGR
Tycoon
Tycoon
Posts: 2564
Joined: 08 Aug 2005 13:46
Location: Ipswich

Re: Patch: The Rainfall River Generator

Post by JGR »

ic111 wrote:Concerning the crashes on bigger maps:
I tried generating a 1024x1024 map and got the following:

Code: Select all

Error: Assertion failed at line 33 of /home/jgr/openttd/trunk2/src/tile_map.h: tile < MapSize()
Crashlog:

Code: Select all

*** OpenTTD Crash Report ***

Crash at: Tue Oct  6 22:18:13 2015
In game date: 1945-01-01 (0)

Crash reason:
 Signal:  Aborted (6)
 Message: Assertion failed at line 33 of /home/jgr/openttd/trunk2/src/tile_map.h: tile < MapSize()

OpenTTD version:
 Version:    g2f7f809e-rivers (0)
 NewGRF ver: 16006b0b
 Bits:       64
 Endian:     little
 Dedicated:  no
 Build date: Oct  6 2015 23:15:00

Stacktrace:
 [00] bin/openttd(_ZNK12CrashLogUnix13LogStacktraceEPcPKc+0x4a) [0x72cc5a]
 [01] bin/openttd(_ZNK8CrashLog12FillCrashLogEPcPKc+0xfc) [0x61064c]
 [02] bin/openttd(_ZNK8CrashLog12MakeCrashLogEv+0x7f) [0x6108ff]
 [03] bin/openttd() [0x72cbb5]
 [04] /lib/x86_64-linux-gnu/libc.so.6(+0x352f0) [0x7f816e5722f0]
 [05] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7f816e572267]
 [06] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7f816e573eca]
 [07] bin/openttd() [0x71a3eb]
 [08] bin/openttd() [0x4f82b0]
 [09] bin/openttd() [0x832e43]
 [10] bin/openttd(_Z19ExecuteTerraformingR16TerraformerStateb+0xf9) [0x833649]
 [11] bin/openttd(_Z20TerraformTileToSlopeji5Slope+0x80) [0x8349a0]
 [12] bin/openttd(_ZN22RainfallRiverGenerator19GenerateWiderRiversEbbPiPhP19DefineLakesIteratorRSt6vectorI21TileWithHeightAndFlowSaIS5_EE+0x4c1) [0x77c161]
 [13] bin/openttd(_ZN22RainfallRiverGenerator26TerraformAndGenerateRiversEPiPhP19DefineLakesIteratorS0_+0xb26) [0x7850c6]
 [14] bin/openttd(_ZN22RainfallRiverGenerator14GenerateRiversEv+0x327) [0x785487]
 [15] bin/openttd(_Z17GenerateLandscapeh+0x38a) [0x68ec6a]
 [16] bin/openttd() [0x657d4a]
 [17] bin/openttd(_ZN20ThreadObject_pthread10ThreadProcEv+0xb) [0x83b3eb]
 [18] bin/openttd(_ZN20ThreadObject_pthread12stThreadProcEPv+0x9) [0x83b459]
 [19] /lib/x86_64-linux-gnu/libpthread.so.0(+0x76aa) [0x7f817083c6aa]
 [20] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f816e643eed]

Operating system:
 Name:     Linux
 Release:  4.2.0
 Version:  #2 SMP Thu Sep 3 22:37:36 BST 2015
 Machine:  x86_64
 Compiler: GCC 4.9.2 "4.9.2"

Configuration:
 Blitter:      32bpp-anim
 Graphics set: OpenGFX (5538)
 Language:     /home/jgr/openttd/trunk2/bin/lang/english.lng
 Music driver: extmidi
 Music set:    OpenMSX (96)
 Network:      no
 Sound driver: sdl
 Sound set:    NoSound (2)
 Video driver: sdl

Fonts:
 Small:  sprite
 Medium: sprite
 Large:  sprite
 Mono:   sprite

AI Configuration (local: 255):

Libraries:
 FontConfig: 2.11.1
 FreeType:   2.5.2
 ICU i18n:   52.1
 ICU lx:     52.1
 LZMA:       5.1.0alpha
 LZO:        2.08
 PNG:        1.2.51
 SDL:        1.2.15
 Zlib:       1.2.8

---- gamelog start ----
Tick 0: new game started
Revision text changed to g2f7f809e-rive, savegame version 250, not modified, _openttd_newgrf_version = 0x16006b0b
New game mode: 1 landscape: 0
Added NewGRF: GRF ID 27711003, checksum 30EF819C36EA5E003976E26A8A25CF71, filename: 2cc_trainset-2.0.0beta5/2cctrainset.grf (md5sum matches)
Added NewGRF: GRF ID 44440A01, checksum FCEEC76CF44EC23E7FE9C88048CF11CC, filename: av8_aviators_aircraft_set-2.21/pb_av8w.grf (md5sum matches)
Added NewGRF: GRF ID 4D42000A, checksum BC3A0E791C74C1A04A3B90C3B2FA83A6, filename: bats-0.4/batsv0.4w.grf (md5sum matches)
Added NewGRF: GRF ID 54430201, checksum C837D48D657129DD915830D60D68E09F, filename: cs_stationset_v0.1-1/csstationsw.grf (md5sum matches)
Added NewGRF: GRF ID 54430202, checksum 081B62FD686AF2161866A0CF6EA043AC, filename: cs_platforms_set-1/csplatformsw.grf (md5sum matches)
Added NewGRF: GRF ID 4D4C0100, checksum 1E2A243600434194FB100E72E507D5EF, filename: dutch_catenary-1/dutchcatenary.grf (md5sum matches)
Added NewGRF: GRF ID 58534453, checksum 2E100BCA91DB8371CD9D57DBEC3AB0C8, filename: dutch_stations_set-1.0.0alpha/dutchstatw.grf (md5sum matches)
Added NewGRF: GRF ID 504A0110, checksum E8244C5278CB2408A818854DC11F8940, filename: dutch_station_addition_set-0.8/dstatadd_v0_8.grf (md5sum matches)
Added NewGRF: GRF ID F1250005, checksum 955C122CEFCC91F1EDAB646F7DF7D141, filename: firs_industry_replacement_set-1.4.4/firs.grf (md5sum matches)
Added NewGRF: GRF ID 504E0002, checksum 6E6944E09CE6C3AC130DF72C542EE4B1, filename: generic_buffers.0.1/buffers.grf (md5sum matches)
Added NewGRF: GRF ID 44550001, checksum E9DEC9B4FB1F0CAF683C5BBC248B7DF7, filename: germanrvw.grf (md5sum matches)
Added NewGRF: GRF ID 464B0000, checksum E266FE2217DE82D7C1F8968EC81A2915, filename: hungarian_stations-1/hungarian_stations.grf (md5sum matches)
Added NewGRF: GRF ID 464B0001, checksum B5A131DCAC1D7C7E24166EDEA2D106F1, filename: hungarian_stations_2-1/hungarian_stations2.grf (md5sum matches)
Added NewGRF: GRF ID 464B0002, checksum 9D3B823C988DB972503A72E58180D077, filename: hungarian_stations_3-1/hungarian_stations3.grf (md5sum matches)
Added NewGRF: GRF ID 4D560000, checksum A420B01EE556C4C8EC7E8A59E4CC05DB, filename: ikarus_set-6beta/testfilew.grf (md5sum matches)
Added NewGRF: GRF ID 4A430002, checksum 93EAC5F5396584B92D4C5F0AAAF3F6C5, filename: industrial_stations_renewal-1.0.2/indstatr.grf (md5sum matches)
Added NewGRF: GRF ID 4A430000, checksum A8B0E3328517AF70653FBDF7CDAFE005, filename: jcindstaw.grf (md5sum matches)
Added NewGRF: GRF ID 45530500, checksum 3A943F4E8E345F903F2CEF090A12346C, filename: japanese_stations-3.5/jpstations.grf (md5sum matches)
Added NewGRF: GRF ID 544B0202, checksum 86AEA2C5D258DC0CB5259155CE8835B0, filename: korean_bus_set-0.3.4/ko_bus_set.grf (md5sum matches)
Added NewGRF: GRF ID 4E474C56, checksum B780A10427B64320EE8529AD9711868E, filename: light_road_vehicle_set-0.2beta2/lrvs-0.2.grf (md5sum matches)
Added NewGRF: GRF ID 4D656F00, checksum 97C6741906450C460568C6F5F8FB997F, filename: LongBusesw.grf (md5sum matches)
Added NewGRF: GRF ID 4D656F03, checksum 380E73C6E0627AF7AD474923D970ECE2, filename: VolvoTrucksw.grf (md5sum matches)
Added NewGRF: GRF ID FBFB9905, checksum F747797A14AAA646402DC4E16DE5E82C, filename: longer_girder__steel_bridge.1/longergirdersteelbridge.grf (md5sum matches)
Added NewGRF: GRF ID 6D620C00, checksum 79F501FF2571BBC7E0713E3E86F513FB, filename: marico032.grf (md5sum matches)
Added NewGRF: GRF ID 45520500, checksum 7E30CA79D5A8B3A6CBE873E26096D7D2, filename: modernsuburbanw.GRF (md5sum matches)
Added NewGRF: GRF ID 58534D00, checksum 6F4C28B41F5127046DED0320D0BE533B, filename: modern_set.grf (md5sum matches)
Added NewGRF: GRF ID 41570102, checksum CD86DA4FC58F68393F060B8E0211AEC8, filename: modern_waypoint-2/modern_waypoint2.grf (md5sum matches)
Added NewGRF: GRF ID 44450002, checksum 94F025F7345888FC3062F233C569D248, filename: modular_locomotive_shed_stations-0.2.6/mlss026.grf (md5sum matches)
Added NewGRF: GRF ID 4672780A, checksum 7AF65E8BD107B5A4660031E1B4C4F822, filename: monkey_bar_bridge-1.4.1/monkeybarbridge.grf (md5sum matches)
Added NewGRF: GRF ID 686D6301, checksum ECFF8464F08FD6772E7A133C46FA43F2, filename: more_british_town_names-1.0/morebritishtownnames_1.grf (md5sum matches)
Added NewGRF: GRF ID 6D620601, checksum 44EB2F155862E4D4F0AB671D7021AF54, filename: newstatsw.grf (md5sum matches)
Added NewGRF: GRF ID 444A5401, checksum B9E9E16F258B32DC91E8BABEF037AFA7, filename: nutracks-r247/nutracks.grf (md5sum matches)
Added NewGRF: GRF ID FF4F4701, checksum AFCDC2958C1B7B27B5414ED5ED4A5739, filename: opengfx-0.4.1/ogfxe_extra.grf (md5sum matches)
Added NewGRF: GRF ID 43415000, checksum 4DA9FE9A87DD330EBAD43916771BAF21, filename: opengfx_airports-0.4.2/ogfx-airports.grf (md5sum matches)
Added NewGRF: GRF ID 4F472B34, checksum 136D889FDAEAA3491F8320248A04425C, filename: opengfx_landscape-1.1.2/ogfx-landscape.grf (md5sum matches)
Added NewGRF: GRF ID 1560B248, checksum 76BE5A3BA8C66817C14CFA05177D20D9, filename: redfish-0.4/redfish.grf (md5sum matches)
Added NewGRF: GRF ID 44508550, checksum BEE9D0982856E627DDF24902019413F8, filename: sbb_set-1.0e/sbbset.grf (md5sum matches)
Added NewGRF: GRF ID 52453C00, checksum C5B4EC240B33E2DB8D1EA64C97898B5E, filename: stolen_trees-1/stolentreesw_162.grf (md5sum matches)
Added NewGRF: GRF ID 4D4D9910, checksum 3CD3F4D0D98DDC0DB08E9AD74B88A9E2, filename: the_lighthouse_set-1.2/the_lighthouse_set_v1.2.grf (md5sum matches)
Added NewGRF: GRF ID 44442202, checksum 3DAC7433C0DA14AD3C5E8C89D73A6A2E, filename: uk_renewal_set_addon_pack.3.04/ukrsap1w.grf (md5sum matches)
Added NewGRF: GRF ID 44440111, checksum 9B5051E70D60EF2926A249B923AFB0CA, filename: uk_renewal_set.3.04/pb_ukrs.grf (md5sum matches)
Added NewGRF: GRF ID 72777473, checksum EBEAB33B398DE7F2921F853C496F6F91, filename: uk_town_set-2.2/ukts_2.2.grf (md5sum matches)
Added NewGRF: GRF ID 504E0001, checksum E7781323D2B0086E2E76342DAA036054, filename: uk_waypoints-1/ukwaypointsw.grf (md5sum matches)
Added NewGRF: GRF ID 54570200, checksum 3DEB9B30A6254AE8606A5A9A99A9A696, filename: usstatsw.grf (md5sum matches)
Added NewGRF: GRF ID 444E0400, checksum 735D3D74D5DCADBF1FD6EF7A9C5A3519, filename: vast_station_tiles-0.2.0/vast.grf (md5sum matches)
Added NewGRF: GRF ID 444E0C00, checksum B5D2AB5FC93A09E1FAB5F0DB82307ECF, filename: vast_fences-0.2.0/vastfences.grf (md5sum matches)
Added NewGRF: GRF ID 425F0101, checksum 5E6DC9FD3D9364AC6ABE21E6B4D8CE3E, filename: very_large_ships.0.1/vl_shipw.grf (md5sum matches)
---- gamelog end ----

*** End of OpenTTD Crash Report ***
Prettified backtrace courtesy of gdb:

Code: Select all

#0  0x00007f816e572267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
#1  0x00007f816e573eca in __GI_abort () at abort.c:89
#2  0x000000000072cbbf in HandleCrash(int) ()
#3  <signal handler called>
#4  0x00007f816e572267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
#5  0x00007f816e573eca in __GI_abort () at abort.c:89
#6  0x000000000071a3eb in error(char const*, ...) ()
#7  0x00000000004f82b0 in TileHeight ()
#8  0x0000000000832e43 in TerraformerState::GetHeightOfTile(unsigned int) ()
#9  0x0000000000833649 in ExecuteTerraforming(TerraformerState&, bool) ()
#10 0x00000000008349a0 in TerraformTileToSlope(unsigned int, int, Slope) ()
#11 0x000000000077c161 in RainfallRiverGenerator::GenerateWiderRivers(bool, bool, int*, unsigned char*, DefineLakesIterator*, std::vector<TileWithHeightAndFlow, std::allocator<TileWithHeightAndFlow> >&) ()
#12 0x00000000007850c6 in RainfallRiverGenerator::TerraformAndGenerateRivers(int*, unsigned char*, DefineLakesIterator*, int*) ()
#13 0x0000000000785487 in RainfallRiverGenerator::GenerateRivers() ()
#14 0x000000000068ec6a in GenerateLandscape(unsigned char) ()
#15 0x0000000000657d4a in _GenerateWorld(void*) ()
#16 0x000000000083b3eb in ThreadObject_pthread::ThreadProc() ()
#17 0x000000000083b459 in ThreadObject_pthread::stThreadProc(void*) ()
#18 0x00007f817083c6aa in start_thread (arg=0x7f8166feb700) at pthread_create.c:333
#19 0x00007f816e643eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
On an unrelated notes, the patch queue zips seem to have various temporaries and backup files in them as well as the series and expected patches.

EDIT:
Here's a backtrace when compiled with debug info, including locals.

Code: Select all

#0  0x00007fa1cb6ea267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
        resultvar = 0
        pid = 4934
        selftid = 4941
#1  0x00007fa1cb6ebeca in __GI_abort () at abort.c:89
        save_stage = 2
        act = {__sigaction_handler = {sa_handler = 0x7fa1cdfd0000, sa_sigaction = 0x7fa1cdfd0000}, sa_mask = {__val = {140332756242352, 16329784, 140332921470752, 0, 0, 0, 140332922372096, 140332756242208, 16329784, 16339424, 11150237, 
              0, 140332916006417, 0, 0, 3}}, sa_flags = -1005187520, sa_restorer = 0x1}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x000000000097f0d0 in HandleCrash (signum=6) at /home/jgr/openttd/trunk2/src/os/unix/crashlog_unix.cpp:177
        log = {<CrashLog> = {_vptr.CrashLog = 0xdd8290 <vtable for CrashLogUnix+16>, static message = 0x0, static gamelog_buffer = 0x7fa1c41533fc "\n*** End of OpenTTD Crash Report ***\n", static gamelog_last = 0x7fa1c4160f3f ""}, 
          signum = 6}
#3  <signal handler called>
No locals.
#4  0x00007fa1cb6ea267 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
        resultvar = 0
        pid = 4934
        selftid = 4941
#5  0x00007fa1cb6ebeca in __GI_abort () at abort.c:89
        save_stage = 2
        act = {__sigaction_handler = {sa_handler = 0x4, sa_sigaction = 0x4}, sa_mask = {__val = {10515066, 4495963175518209, 140332756243920, 3289781808, 140332922372096, 140332880908328, 16329784, 16339424, 8388608, 37667472, 
              140332879812764, 140332880927232, 140332880908328, 140332756244200, 140332879299760, 140332880892457}}, sa_flags = -839057408, sa_restorer = 0x7fa1cb845028}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#6  0x00007fa1cb6e303d in __assert_fail_base (fmt=0x7fa1cb845028 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0xf92c38 "tile < MapSize()", file=file@entry=0xf92c10 "/home/jgr/openttd/trunk2/src/tile_map.h", 
    line=line@entry=33, function=function@entry=0xf951e0 <_ZZL10TileHeightjE19__PRETTY_FUNCTION__> "uint TileHeight(TileIndex)") at assert.c:92
        str = 0x7fa184e14d70 "\220Mᄡ\177"
        total = 4096
#7  0x00007fa1cb6e30f2 in __GI___assert_fail (assertion=0xf92c38 "tile < MapSize()", file=0xf92c10 "/home/jgr/openttd/trunk2/src/tile_map.h", line=33, 
    function=0xf951e0 <_ZZL10TileHeightjE19__PRETTY_FUNCTION__> "uint TileHeight(TileIndex)") at assert.c:101
No locals.
#8  0x0000000000b11150 in TileHeight (tile=1048845) at /home/jgr/openttd/trunk2/src/tile_map.h:33
        __PRETTY_FUNCTION__ = "uint TileHeight(TileIndex)"
#9  0x0000000000b11883 in TerraformerState::GetHeightOfTile (this=0x7fa184db9450, tile=1048845) at /home/jgr/openttd/trunk2/src/terraform_cmd.cpp:88
        it = {first = 9, second = 0}
#10 0x0000000000b1254c in ExecuteTerraforming (terraformer_state=..., clear_in_execute=true) at /home/jgr/openttd/trunk2/src/terraform_cmd.cpp:327
        z_N = 3
        z_W = 2
        z_E = 2
        z_min = 2
        tile = 1047820
        z_S = 2
        z_max = 2
        tileh = 2228982872
        coa = 0x0
        indirectly_cleared = false
        it = 1047820
#11 0x00000000009f211a in RainfallRiverGenerator::ImproveByTerraforming (this=0x7fa1840008c0, tile=1046797, flow=152, tiles_fixed=std::set with 3155 elements = {...}, new_problem_tiles=std::set with 638 elements = {...}, 
    water_flow=0x7fa1844cc260, water_info=0x7fa1848cc270 "", define_lakes_iterator=0x7fa1844ace40, make_water_afterwards=false) at /home/jgr/openttd/trunk2/src/rivers_rainfall.cpp:3210
        height = 3
        slope = SLOPE_N
        actions = std::vector of length 13, capacity 16 = {{terraformer_state = {dirty_tiles = std::set with 9 elements = {[0] = 1045772, [1] = 1045773, [2] = 1045774, [3] = 1046796, [4] = 1046797, [5] = 1046798, [6] = 1047820, 
                [7] = 1047821, [8] = 1047822}, tile_to_new_height = std::map with 9 elements = {[1045772] = 3, [1045773] = 3, [1045774] = 3, [1046796] = 3, [1046797] = 2, [1046798] = 2, [1047820] = 3, [1047821] = 2, [1047822] = 2}}, 
            affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_FLAT, height = 2}, {terraformer_state = {dirty_tiles = std::set with 9 elements = {[0] = 1045772, [1] = 1045773, 
                [2] = 1045774, [3] = 1046796, [4] = 1046797, [5] = 1046798, [6] = 1047820, [7] = 1047821, [8] = 1047822}, tile_to_new_height = std::map with 9 elements = {[1045772] = 3, [1045773] = 3, [1045774] = 3, [1046796] = 3, 
                [1046797] = 3, [1046798] = 3, [1047820] = 3, [1047821] = 2, [1047822] = 2}}, affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_NW, height = 3}, {terraformer_state = {
              dirty_tiles = std::set with 9 elements = {[0] = 1045772, [1] = 1045773, [2] = 1045774, [3] = 1046796, [4] = 1046797, [5] = 1046798, [6] = 1047820, [7] = 1047821, [8] = 1047822}, 
              tile_to_new_height = std::map with 9 elements = {[1045772] = 3, [1045773] = 3, [1045774] = 3, [1046796] = 3, [1046797] = 3, [1046798] = 2, [1047820] = 3, [1047821] = 3, [1047822] = 2}}, 
            affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_NE, height = 3}, {terraformer_state = {dirty_tiles = std::set with 9 elements = {[0] = 1045772, [1] = 1045773, 
                [2] = 1045774, [3] = 1046796, [4] = 1046797, [5] = 1046798, [6] = 1047820, [7] = 1047821, [8] = 1047822}, tile_to_new_height = std::map with 9 elements = {[1045772] = 3, [1045773] = 3, [1045774] = 3, [1046796] = 3, 
                [1046797] = 3, [1046798] = 3, [1047820] = 3, [1047821] = 3, [1047822] = 3}}, affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_FLAT, height = 3}, {terraformer_state = {
              dirty_tiles = std::set with 9 elements = {[0] = 1045771, [1] = 1045772, [2] = 1045773, [3] = 1046795, [4] = 1046796, [5] = 1046797, [6] = 1047819, [7] = 1047820, [8] = 1047821}, 
              tile_to_new_height = std::map with 9 elements = {[1045771] = 3, [1045772] = 3, [1045773] = 3, [1046795] = 3, [1046796] = 2, [1046797] = 2, [1047819] = 3, [1047820] = 2, [1047821] = 2}}, 
            affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_FLAT, height = 2}, {terraformer_state = {dirty_tiles = std::set with 9 elements = {[0] = 1044748, [1] = 1044749, 
                [2] = 1044750, [3] = 1045772, [4] = 1045773, [5] = 1045774, [6] = 1046796, [7] = 1046797, [8] = 1046798}, tile_to_new_height = std::map with 9 elements = {[1044748] = 3, [1044749] = 3, [1044750] = 3, [1045772] = 3, 
                [1045773] = 2, [1045774] = 2, [1046796] = 3, [1046797] = 2, [1046798] = 2}}, affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_FLAT, height = 2}, {terraformer_state = {
              dirty_tiles = std::set with 9 elements = {[0] = 1044747, [1] = 1044748, [2] = 1044749, [3] = 1045771, [4] = 1045772, [5] = 1045773, [6] = 1046795, [7] = 1046796, [8] = 1046797}, 
              tile_to_new_height = std::map with 9 elements = {[1044747] = 3, [1044748] = 3, [1044749] = 3, [1045771] = 3, [1045772] = 2, [1045773] = 2, [1046795] = 3, [1046796] = 2, [1046797] = 2}}, 
            affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_FLAT, height = 2}, {terraformer_state = {dirty_tiles = std::set with 9 elements = {[0] = 1045771, [1] = 1045772, 
                [2] = 1045773, [3] = 1046795, [4] = 1046796, [5] = 1046797, [6] = 1047819, [7] = 1047820, [8] = 1047821}, tile_to_new_height = std::map with 9 elements = {[1045771] = 3, [1045772] = 3, [1045773] = 3, [1046795] = 3, 
                [1046796] = 3, [1046797] = 3, [1047819] = 3, [1047820] = 3, [1047821] = 3}}, affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_FLAT, height = 3}, {terraformer_state = {
              dirty_tiles = std::set with 9 elements = {[0] = 1044748, [1] = 1044749, [2] = 1044750, [3] = 1045772, [4] = 1045773, [5] = 1045774, [6] = 1046796, [7] = 1046797, [8] = 1046798}, 
              tile_to_new_height = std::map with 9 elements = {[1044748] = 3, [1044749] = 3, [1044750] = 3, [1045772] = 3, [1045773] = 3, [1045774] = 3, [1046796] = 3, [1046797] = 3, [1046798] = 3}}, 
            affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_FLAT, height = 3}, {terraformer_state = {dirty_tiles = std::set with 9 elements = {[0] = 1044749, [1] = 1044750, 
                [2] = 1044751, [3] = 1045773, [4] = 1045774, [5] = 1045775, [6] = 1046797, [7] = 1046798, [8] = 1046799}, tile_to_new_height = std::map with 9 elements = {[1044749] = 3, [1044750] = 3, [1044751] = 3, [1045773] = 3, 
                [1045774] = 3, [1045775] = 3, [1046797] = 3, [1046798] = 3, [1046799] = 3}}, affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_FLAT, height = 3}, {terraformer_state = {
              dirty_tiles = std::set with 11 elements = {[0] = 1044749, [1] = 1044750, [2] = 1044751, [3] = 1044752, [4] = 1045773, [5] = 1045774, [6] = 1045775, [7] = 1045776, [8] = 1046797, [9] = 1046798, [10] = 1046799}, 
              tile_to_new_height = std::map with 11 elements = {[1044749] = 3, [1044750] = 3, [1044751] = 3, [1044752] = 2, [1045773] = 3, [1045774] = 4, [1045775] = 4, [1045776] = 3, [1046797] = 3, [1046798] = 3, [1046799] = 3}}, 
            affected_tiles = std::set with 1 elements = {[0] = 1046797}, score = 1, success = true, slope = SLOPE_NW, height = 4}, {terraformer_state = {dirty_tiles = std::set with 0 elements, 
              tile_to_new_height = std::map with 0 elements}, affected_tiles = std::set with 0 elements, score = 0, success = false, slope = SLOPE_FLAT, height = 3}, {terraformer_state = {dirty_tiles = std::set with 0 elements, 
              tile_to_new_height = std::map with 0 elements}, affected_tiles = std::set with 0 elements, score = 0, success = false, slope = SLOPE_NE, height = 4}}
#12 0x00000000009f2eda in RainfallRiverGenerator::FixByLocalTerraforming (this=0x7fa1840008c0, problem_tiles=std::set with 1414 elements = {...}, water_flow=0x7fa1844cc260, water_info=0x7fa1848cc270 "", 
    define_lakes_iterator=0x7fa1844ace40) at /home/jgr/openttd/trunk2/src/rivers_rainfall.cpp:3407
        success = false
        tile = 1046797
        it = 1046797
        tiles_fixed = std::set with 3155 elements = {[0] = 1339, [1] = 1340, [2] = 1341, [3] = 3053, [4] = 3054, [5] = 12272, [6] = 13218, [7] = 13295, [8] = 13296, [9] = 14241, [10] = 14242, [11] = 14243, [12] = 14244, [13] = 15268, 
          [14] = 15269, [15] = 15270, [16] = 16178, [17] = 16179, [18] = 16180, [19] = 16294, [20] = 16295, [21] = 16296, [22] = 17202, [23] = 17203, [24] = 17321, [25] = 17322, [26] = 17323, [27] = 17354, [28] = 18220, [29] = 18221, 
          [30] = 18347, [31] = 18378, [32] = 19243, [33] = 19244, [34] = 19402, [35] = 20217, [36] = 20218, [37] = 20465, [38] = 21240, [39] = 21241, [40] = 21339, [41] = 21488, [42] = 21489, [43] = 21490, [44] = 22363, [45] = 22364, 
          [46] = 29421, [47] = 29989, [48] = 29990, [49] = 29991, [50] = 30445, [51] = 30446, [52] = 31014, [53] = 31469, [54] = 32038, [55] = 32877, [56] = 32878, [57] = 33901, [58] = 33902, [59] = 34845, [60] = 34846, [61] = 34926, 
          [62] = 35107, [63] = 35858, [64] = 35868, [65] = 35869, [66] = 36130, [67] = 36131, [68] = 36879, [69] = 36880, [70] = 36881, [71] = 36882, [72] = 36883, [73] = 37153, [74] = 37154, [75] = 37452, [76] = 37453, [77] = 38121, 
          [78] = 38122, [79] = 38123, [80] = 38174, [81] = 38175, [82] = 38176, [83] = 38476, [84] = 38927, [85] = 38928, [86] = 39145, [87] = 39147, [88] = 40168, [89] = 40169, [90] = 40812, [91] = 41192, [92] = 41835, [93] = 41836, 
          [94] = 42420, [95] = 42859, [96] = 43444, [97] = 43445, [98] = 44108, [99] = 44467, [100] = 44468, [101] = 44723, [102] = 45132, [103] = 45133, [104] = 45746, [105] = 45747, [106] = 45924, [107] = 45925, [108] = 46157, 
          [109] = 46770, [110] = 46779, [111] = 46941, [112] = 46942, [113] = 46946, [114] = 46947, [115] = 46948, [116] = 47802, [117] = 47803, [118] = 47966, [119] = 47967, [120] = 47969, [121] = 47970, [122] = 48284, [123] = 48285, 
          [124] = 48286, [125] = 48826, [126] = 49266, [127] = 49308, [128] = 49309, [129] = 49310, [130] = 50189, [131] = 50289, [132] = 50290, [133] = 50333, [134] = 50334, [135] = 50337, [136] = 50975, [137] = 51213, [138] = 51214, 
          [139] = 51313, [140] = 51361, [141] = 51362, [142] = 51661, [143] = 51662, [144] = 51999, [145] = 52386, [146] = 52415, [147] = 52416, [148] = 52685, [149] = 52686, [150] = 53260, [151] = 53438, [152] = 53439, [153] = 53670, 
          [154] = 53671, [155] = 53709, [156] = 53710, [157] = 53711, [158] = 54284, [159] = 54285, [160] = 54462, [161] = 54694, [162] = 54695, [163] = 54696, [164] = 57130, [165] = 57323, [166] = 57324, [167] = 58129, [168] = 58154, 
          [169] = 58155, [170] = 59153, [171] = 59154, [172] = 59405, [173] = 59406, [174] = 61648, [175] = 61909, [176] = 62254, [177] = 62255, [178] = 62443, [179] = 62444, [180] = 62671, [181] = 62672, [182] = 62673, [183] = 62933, 
          [184] = 62934, [185] = 62935, [186] = 63278, [187] = 63467, [188] = 63468, [189] = 63501, [190] = 63695, [191] = 63696, [192] = 63697, [193] = 64492, [194] = 64493, [195] = 64524, [196] = 64525, [197] = 64753, [198] = 64984, 
          [199] = 64985...}
        new_problem_tiles = std::set with 638 elements = {[0] = 1341, [1] = 3054, [2] = 13295, [3] = 13296, [4] = 16296, [5] = 17320, [6] = 17321, [7] = 17323, [8] = 19402, [9] = 21489, [10] = 21490, [11] = 22363, [12] = 32038, 
          [13] = 35868, [14] = 37153, [15] = 38123, [16] = 38176, [17] = 38927, [18] = 38928, [19] = 40169, [20] = 45747, [21] = 48826, [22] = 49310, [23] = 50334, [24] = 51213, [25] = 51214, [26] = 51999, [27] = 52386, [28] = 52687, 
          [29] = 53410, [30] = 53710, [31] = 53711, [32] = 54696, [33] = 55081, [34] = 56744, [35] = 57324, [36] = 59406, [37] = 61649, [38] = 62255, [39] = 62672, [40] = 62935, [41] = 63696, [42] = 63697, [43] = 64492, [44] = 64493, 
          [45] = 66010, [46] = 67033, [47] = 67034, [48] = 69643, [49] = 71082, [50] = 71471, [51] = 71885, [52] = 71886, [53] = 72908, [54] = 73706, [55] = 74954, [56] = 75181, [57] = 76893, [58] = 78018, [59] = 78022, [60] = 80478, 
          [61] = 80875, [62] = 80910, [63] = 81934, [64] = 83387, [65] = 83397, [66] = 84416, [67] = 84418, [68] = 86466, [69] = 87972, [70] = 92076, [71] = 93172, [72] = 99042, [73] = 99396, [74] = 106483, [75] = 107507, 
          [76] = 108531, [77] = 126894, [78] = 127887, [79] = 130686, [80] = 130687, [81] = 130690, [82] = 130693, [83] = 130694, [84] = 130872, [85] = 131153, [86] = 131154, [87] = 132084, [88] = 132085, [89] = 133000, [90] = 135803, 
          [91] = 139217, [92] = 139368, [93] = 142286, [94] = 143310, [95] = 143435, [96] = 145333, [97] = 147061, [98] = 152534, [99] = 164499, [100] = 164928, [101] = 164930, [102] = 165319, [103] = 165328, [104] = 165952, 
          [105] = 166345, [106] = 166350, [107] = 168591, [108] = 169614, [109] = 176751, [110] = 187385, [111] = 187798, [112] = 188409, [113] = 193522, [114] = 196198, [115] = 196199, [116] = 196591, [117] = 196596, [118] = 197620, 
          [119] = 199271, [120] = 200329, [121] = 200689, [122] = 200690, [123] = 207857, [124] = 209905, [125] = 209908, [126] = 209909, [127] = 211954, [128] = 212977, [129] = 213122, [130] = 215726, [131] = 222151, [132] = 235467, 
          [133] = 242715, [134] = 244687, [135] = 248791, [136] = 249963, [137] = 250908, [138] = 250987, [139] = 252629, [140] = 254286, [141] = 257747, [142] = 257886, [143] = 258771, [144] = 262172, [145] = 264184, [146] = 265821, 
          [147] = 266846, [148] = 266886, [149] = 267909, [150] = 267910, [151] = 268313, [152] = 270141, [153] = 270977, [154] = 271353, [155] = 271468, [156] = 272377, [157] = 273514, [158] = 277530, [159] = 277531, [160] = 278226, 
          [161] = 279543, [162] = 279599, [163] = 285722, [164] = 285922, [165] = 287734, [166] = 287735, [167] = 291832, [168] = 292509, [169] = 299030, [170] = 299031, [171] = 302382, [172] = 303095, [173] = 303405, [174] = 303406, 
          [175] = 304790, [176] = 304792, [177] = 304855, [178] = 306472, [179] = 307496, [180] = 308213, [181] = 308427, [182] = 309236, [183] = 310560, [184] = 311728, [185] = 312750, [186] = 312751, [187] = 313773, [188] = 313774, 
          [189] = 313776, [190] = 314000, [191] = 315499, [192] = 316403, [193] = 316404, [194] = 317866, [195] = 318098, [196] = 318126, [197] = 318610, [198] = 318611, [199] = 319544...}
        any_tile_improved = true
        number_of_iterations = 0
#13 0x00000000009f24cb in RainfallRiverGenerator::TryImproveProblemTiles (this=0x7fa1840008c0, problem_tiles=std::set with 1414 elements = {...}, water_flow=0x7fa1844cc260, water_info=0x7fa1848cc270 "", 
    define_lakes_iterator=0x7fa1844ace40) at /home/jgr/openttd/trunk2/src/rivers_rainfall.cpp:3258
No locals.
#14 0x00000000009f8585 in RainfallRiverGenerator::TerraformAndGenerateRivers (this=0x7fa1840008c0, water_flow=0x7fa1844cc260, water_info=0x7fa1848cc270 "", define_lakes_iterator=0x7fa1844ace40, max_river_flow=0x7fa1c4161ce0)
    at /home/jgr/openttd/trunk2/src/rivers_rainfall.cpp:4513
        water_tiles = std::vector of length 119450, capacity 131072 = {{tile = 57788, height = 0, flow = 40380}, {tile = 463424, height = 0, flow = 40333}, {tile = 637251, height = 0, flow = 25040}, {tile = 317873, height = 0, 
            flow = 24620}, {tile = 992886, height = 0, flow = 24178}, {tile = 657094, height = 0, flow = 22587}, {tile = 60581, height = 0, flow = 21578}, {tile = 393998, height = 0, flow = 21532}, {tile = 66008, height = 0, 
            flow = 19377}, {tile = 66009, height = 0, flow = 19374}, {tile = 401151, height = 0, flow = 17864}, {tile = 402175, height = 0, flow = 17863}, {tile = 403199, height = 0, flow = 17862}, {tile = 174721, height = 0, 
            flow = 17364}, {tile = 717128, height = 0, flow = 17063}, {tile = 649528, height = 0, flow = 16027}, {tile = 648503, height = 0, flow = 16023}, {tile = 649526, height = 0, flow = 15831}, {tile = 649525, height = 0, 
            flow = 15830}, {tile = 661801, height = 0, flow = 15829}, {tile = 717314, height = 0, flow = 15237}, {tile = 491072, height = 0, flow = 14851}, {tile = 492097, height = 0, flow = 14845}, {tile = 493122, height = 0, 
            flow = 14844}, {tile = 494146, height = 0, flow = 14842}, {tile = 494147, height = 0, flow = 14840}, {tile = 495172, height = 0, flow = 14838}, {tile = 496195, height = 0, flow = 14812}, {tile = 497218, height = 0, 
            flow = 14810}, {tile = 497217, height = 0, flow = 14779}, {tile = 497216, height = 0, flow = 14778}, {tile = 498241, height = 0, flow = 14777}, {tile = 499265, height = 0, flow = 14729}, {tile = 500289, height = 0, 
            flow = 14728}, {tile = 501313, height = 0, flow = 14725}, {tile = 502338, height = 0, flow = 14723}, {tile = 503363, height = 0, flow = 14720}, {tile = 504388, height = 0, flow = 14717}, {tile = 505412, height = 0, 
            flow = 14707}, {tile = 506435, height = 0, flow = 14698}, {tile = 254573, height = 0, flow = 13667}, {tile = 506434, height = 0, flow = 13595}, {tile = 506433, height = 0, flow = 13594}, {tile = 506432, height = 0, 
            flow = 13593}, {tile = 506431, height = 0, flow = 13418}, {tile = 507454, height = 0, flow = 13416}, {tile = 507453, height = 0, flow = 13415}, {tile = 507452, height = 0, flow = 13414}, {tile = 508475, height = 0, 
            flow = 13413}, {tile = 509499, height = 0, flow = 13399}, {tile = 510523, height = 0, flow = 13398}, {tile = 511548, height = 0, flow = 13397}, {tile = 512573, height = 0, flow = 13396}, {tile = 513598, height = 0, 
            flow = 13395}, {tile = 514623, height = 0, flow = 13347}, {tile = 515648, height = 0, flow = 13341}, {tile = 516672, height = 0, flow = 13334}, {tile = 517696, height = 0, flow = 13325}, {tile = 404223, height = 0, 
            flow = 13300}, {tile = 405247, height = 0, flow = 13297}, {tile = 406271, height = 0, flow = 13293}, {tile = 407294, height = 0, flow = 13290}, {tile = 408319, height = 0, flow = 13024}, {tile = 409344, height = 0, 
            flow = 13001}, {tile = 410368, height = 0, flow = 13000}, {tile = 411392, height = 0, flow = 12999}, {tile = 412416, height = 0, flow = 12998}, {tile = 413440, height = 0, flow = 12997}, {tile = 414464, height = 0, 
            flow = 12987}, {tile = 478766, height = 0, flow = 12921}, {tile = 479789, height = 0, flow = 12905}, {tile = 415489, height = 0, flow = 12810}, {tile = 416514, height = 0, flow = 12808}, {tile = 417538, height = 0, 
            flow = 12796}, {tile = 972542, height = 0, flow = 12769}, {tile = 900933, height = 0, flow = 12300}, {tile = 588619, height = 0, flow = 12223}, {tile = 518720, height = 0, flow = 11898}, {tile = 518719, height = 0, 
            flow = 11811}, {tile = 519742, height = 0, flow = 11810}, {tile = 519741, height = 0, flow = 11808}, {tile = 519740, height = 0, flow = 11807}, {tile = 519739, height = 0, flow = 11805}, {tile = 520763, height = 0, 
            flow = 11804}, {tile = 521787, height = 0, flow = 11802}, {tile = 522811, height = 0, flow = 11801}, {tile = 523835, height = 0, flow = 11791}, {tile = 524859, height = 0, flow = 11767}, {tile = 525882, height = 0, 
            flow = 11766}, {tile = 526906, height = 0, flow = 11765}, {tile = 527929, height = 0, flow = 11531}, {tile = 527928, height = 0, flow = 11523}, {tile = 526903, height = 0, flow = 11522}, {tile = 525878, height = 0, 
            flow = 11521}, {tile = 524853, height = 0, flow = 11520}, {tile = 523828, height = 0, flow = 11477}, {tile = 523827, height = 0, flow = 11476}, {tile = 523826, height = 0, flow = 11475}, {tile = 523825, height = 0, 
            flow = 11473}, {tile = 943889, height = 0, flow = 11473}, {tile = 524848, height = 0, flow = 11469}, {tile = 905499, height = 0, flow = 10469}, {tile = 247588, height = 0, flow = 10040}, {tile = 671436, height = 0, 
            flow = 9252}, {tile = 671437, height = 0, flow = 9241}, {tile = 359494, height = 0, flow = 9012}, {tile = 598851, height = 0, flow = 8983}, {tile = 592184, height = 0, flow = 8808}, {tile = 724284, height = 0, flow = 8556}, 
          {tile = 724283, height = 0, flow = 8553}, {tile = 724282, height = 0, flow = 8551}, {tile = 725305, height = 0, flow = 8429}, {tile = 161414, height = 0, flow = 8421}, {tile = 724279, height = 0, flow = 8400}, {tile = 723254, 
            height = 0, flow = 8399}, {tile = 723253, height = 0, flow = 8395}, {tile = 722228, height = 0, flow = 8394}, {tile = 721203, height = 0, flow = 8393}, {tile = 720178, height = 0, flow = 8391}, {tile = 721201, height = 0, 
            flow = 8358}, {tile = 722224, height = 0, flow = 8354}, {tile = 995941, height = 0, flow = 8351}, {tile = 723247, height = 0, flow = 8350}, {tile = 722222, height = 0, flow = 8348}, {tile = 722221, height = 0, flow = 8347}, 
          {tile = 721197, height = 0, flow = 8346}, {tile = 720172, height = 0, flow = 8344}, {tile = 719147, height = 0, flow = 8343}, {tile = 993890, height = 0, flow = 8328}, {tile = 993889, height = 0, flow = 8311}, {tile = 993888, 
            height = 0, flow = 8310}, {tile = 160391, height = 0, flow = 8265}, {tile = 159368, height = 0, flow = 8264}, {tile = 158343, height = 0, flow = 8256}, {tile = 157318, height = 0, flow = 8249}, {tile = 156293, height = 0, 
            flow = 8246}, {tile = 155269, height = 0, flow = 8242}, {tile = 154245, height = 0, flow = 8206}, {tile = 154244, height = 0, flow = 8205}, {tile = 153219, height = 0, flow = 8204}, {tile = 152194, height = 0, flow = 8203}, 
          {tile = 152195, height = 0, flow = 8187}, {tile = 153220, height = 0, flow = 8174}, {tile = 153221, height = 0, flow = 8172}, {tile = 153222, height = 0, flow = 8171}, {tile = 993887, height = 0, flow = 8163}, {tile = 992862, 
            height = 0, flow = 8162}, {tile = 991837, height = 0, flow = 8156}, {tile = 990812, height = 0, flow = 8154}, {tile = 990811, height = 0, flow = 8152}, {tile = 990810, height = 0, flow = 8151}, {tile = 990809, height = 0, 
            flow = 8038}, {tile = 990808, height = 0, flow = 8035}, {tile = 990807, height = 0, flow = 8034}, {tile = 990806, height = 0, flow = 8033}, {tile = 989783, height = 0, flow = 8031}, {tile = 989782, height = 0, flow = 8014}, 
          {tile = 990805, height = 0, flow = 8013}, {tile = 989780, height = 0, flow = 7970}, {tile = 988756, height = 0, flow = 7966}, {tile = 987731, height = 0, flow = 7961}, {tile = 986707, height = 0, flow = 7948}, {tile = 985683, 
            height = 0, flow = 7947}, {tile = 984658, height = 0, flow = 7943}, {tile = 577091, height = 0, flow = 7792}, {tile = 598850, height = 0, flow = 7654}, {tile = 599873, height = 0, flow = 7653}, {tile = 600896, height = 0, 
            flow = 7650}, {tile = 601919, height = 0, flow = 7649}, {tile = 602943, height = 0, flow = 7646}, {tile = 602942, height = 0, flow = 7642}, {tile = 603966, height = 0, flow = 7640}, {tile = 603967, height = 0, flow = 7636}, 
          {tile = 604992, height = 0, flow = 7634}, {tile = 606016, height = 0, flow = 7620}, {tile = 607040, height = 0, flow = 7619}, {tile = 606015, height = 0, flow = 7615}, {tile = 984657, height = 0, flow = 7615}, {tile = 604990, 
            height = 0, flow = 7566}, {tile = 604989, height = 0, flow = 7526}, {tile = 603965, height = 0, flow = 7515}, {tile = 602940, height = 0, flow = 7510}, {tile = 716278, height = 0, flow = 7508}, {tile = 601916, height = 0, 
            flow = 7467}, {tile = 600891, height = 0, flow = 7459}, {tile = 56744, height = 0, flow = 7439}, {tile = 55720, height = 0, flow = 7438}, {tile = 54696, height = 0, flow = 7436}, {tile = 918856, height = 0, flow = 7365}, {
            tile = 982794, height = 0, flow = 7337}, {tile = 983819, height = 0, flow = 7336}, {tile = 984843, height = 0, flow = 7335}, {tile = 242477, height = 0, flow = 7269}, {tile = 71871, height = 0, flow = 7239}, {tile = 71872, 
            height = 0, flow = 7238}, {tile = 72897, height = 0, flow = 7235}, {tile = 72898, height = 0, flow = 7234}, {tile = 73922, height = 0, flow = 7231}, {tile = 74946, height = 0, flow = 7230}, {tile = 75969, height = 0, 
            flow = 7227}...}
        extra_river_tiles = std::vector of length 46871, capacity 65536 = {{tile = 44463, value = 40380}, {tile = 44464, value = 40380}, {tile = 44465, value = 40380}, {tile = 44466, value = 40380}, {tile = 44467, value = 40380}, {
            tile = 44468, value = 40380}, {tile = 45487, value = 40380}, {tile = 45488, value = 40380}, {tile = 45489, value = 40380}, {tile = 45490, value = 40380}, {tile = 45491, value = 40380}, {tile = 45492, value = 40380}, {
            tile = 45493, value = 40380}, {tile = 45494, value = 40380}, {tile = 46512, value = 40380}, {tile = 46513, value = 40380}, {tile = 46514, value = 40380}, {tile = 46515, value = 40380}, {tile = 46516, value = 40380}, {
            tile = 46517, value = 40380}, {tile = 46518, value = 40380}, {tile = 46519, value = 40380}, {tile = 46520, value = 40380}, {tile = 46521, value = 40380}, {tile = 46522, value = 40380}, {tile = 46523, value = 40380}, {
            tile = 47532, value = 40380}, {tile = 47533, value = 40380}, {tile = 47536, value = 40380}, {tile = 47537, value = 40380}, {tile = 47538, value = 40380}, {tile = 47539, value = 40380}, {tile = 47540, value = 40380}, {
            tile = 47541, value = 40380}, {tile = 47542, value = 40380}, {tile = 47543, value = 40380}, {tile = 47544, value = 40380}, {tile = 47545, value = 40380}, {tile = 47546, value = 40380}, {tile = 47547, value = 40380}, {
            tile = 47548, value = 40380}, {tile = 47549, value = 40380}, {tile = 47550, value = 40380}, {tile = 47551, value = 40380}, {tile = 47552, value = 40380}, {tile = 47553, value = 40380}, {tile = 47554, value = 40380}, {
            tile = 48556, value = 40380}, {tile = 48557, value = 40380}, {tile = 48558, value = 40380}, {tile = 48559, value = 40380}, {tile = 48560, value = 40380}, {tile = 48561, value = 40380}, {tile = 48562, value = 40380}, {
            tile = 48563, value = 40380}, {tile = 48564, value = 40380}, {tile = 48565, value = 40380}, {tile = 48566, value = 40380}, {tile = 48567, value = 40380}, {tile = 48568, value = 40380}, {tile = 48569, value = 40380}, {
            tile = 48570, value = 40380}, {tile = 48571, value = 40380}, {tile = 48572, value = 40380}, {tile = 48573, value = 40380}, {tile = 48574, value = 40380}, {tile = 48575, value = 40380}, {tile = 48576, value = 40380}, {
            tile = 48577, value = 40380}, {tile = 48578, value = 40380}, {tile = 48579, value = 40380}, {tile = 49580, value = 40380}, {tile = 49582, value = 40380}, {tile = 49583, value = 40380}, {tile = 49585, value = 40380}, {
            tile = 49586, value = 40380}, {tile = 49587, value = 40380}, {tile = 49588, value = 40380}, {tile = 49589, value = 40380}, {tile = 49590, value = 40380}, {tile = 49591, value = 40380}, {tile = 49592, value = 40380}, {
            tile = 49593, value = 40380}, {tile = 49594, value = 40380}, {tile = 49595, value = 40380}, {tile = 49596, value = 40380}, {tile = 49597, value = 40380}, {tile = 49598, value = 40380}, {tile = 49599, value = 40380}, {
            tile = 49600, value = 40380}, {tile = 49601, value = 40380}, {tile = 49602, value = 40380}, {tile = 49603, value = 40380}, {tile = 49604, value = 40380}, {tile = 49605, value = 40380}, {tile = 50604, value = 40380}, {
            tile = 50605, value = 40380}, {tile = 50606, value = 40380}, {tile = 50607, value = 40380}, {tile = 50611, value = 40380}, {tile = 50612, value = 40380}, {tile = 50613, value = 40380}, {tile = 50615, value = 40380}, {
            tile = 50616, value = 40380}, {tile = 50617, value = 40380}, {tile = 50618, value = 40380}, {tile = 50619, value = 40380}, {tile = 50620, value = 40380}, {tile = 50621, value = 40380}, {tile = 50622, value = 40380}, {
            tile = 50623, value = 40380}, {tile = 50624, value = 40380}, {tile = 50625, value = 40380}, {tile = 50628, value = 40380}, {tile = 50629, value = 40380}, {tile = 50630, value = 40380}, {tile = 50631, value = 40380}, {
            tile = 51627, value = 40380}, {tile = 51628, value = 40380}, {tile = 51629, value = 40380}, {tile = 51630, value = 40380}, {tile = 51631, value = 40380}, {tile = 51634, value = 40380}, {tile = 51635, value = 40380}, {
            tile = 51636, value = 40380}, {tile = 51639, value = 40380}, {tile = 51640, value = 40380}, {tile = 51641, value = 40380}, {tile = 51642, value = 40380}, {tile = 51643, value = 40380}, {tile = 51644, value = 40380}, {
            tile = 51645, value = 40380}, {tile = 51646, value = 40380}, {tile = 51647, value = 40380}, {tile = 51648, value = 40380}, {tile = 51649, value = 40380}, {tile = 51650, value = 40380}, {tile = 51651, value = 40380}, {
            tile = 51652, value = 40380}, {tile = 51653, value = 40380}, {tile = 51654, value = 40380}, {tile = 51656, value = 40380}, {tile = 51657, value = 40380}, {tile = 52650, value = 40380}, {tile = 52651, value = 40380}, {
            tile = 52652, value = 40380}, {tile = 52653, value = 40380}, {tile = 52654, value = 40380}, {tile = 52655, value = 40380}, {tile = 52658, value = 40380}, {tile = 52659, value = 40380}, {tile = 52660, value = 40380}, {
            tile = 52664, value = 40380}, {tile = 52665, value = 40380}, {tile = 52666, value = 40380}, {tile = 52667, value = 40380}, {tile = 52668, value = 40380}, {tile = 52669, value = 40380}, {tile = 52670, value = 40380}, {
            tile = 52671, value = 40380}, {tile = 52672, value = 40380}, {tile = 52673, value = 40380}, {tile = 52674, value = 40380}, {tile = 52675, value = 40380}, {tile = 52677, value = 40380}, {tile = 52678, value = 40380}, {
            tile = 52679, value = 40380}, {tile = 52680, value = 40380}, {tile = 52684, value = 40380}, {tile = 53674, value = 40380}, {tile = 53676, value = 40380}, {tile = 53677, value = 40380}, {tile = 53678, value = 40380}, {
            tile = 53679, value = 40380}, {tile = 53683, value = 40380}, {tile = 53684, value = 40380}, {tile = 53688, value = 40380}, {tile = 53689, value = 40380}, {tile = 53690, value = 40380}, {tile = 53691, value = 40380}, {
            tile = 53692, value = 40380}, {tile = 53693, value = 40380}, {tile = 53694, value = 40380}, {tile = 53695, value = 40380}, {tile = 53696, value = 40380}, {tile = 53697, value = 40380}, {tile = 53698, value = 40380}, {
            tile = 53699, value = 40380}, {tile = 53700, value = 40380}, {tile = 53702, value = 40380}, {tile = 53703, value = 40380}, {tile = 53704, value = 40380}, {tile = 53705, value = 40380}, {tile = 53706, value = 40380}, {
            tile = 53707, value = 40380}, {tile = 53708, value = 40380}, {tile = 53709, value = 40380}, {tile = 54698, value = 40380}, {tile = 54699, value = 40380}, {tile = 54700, value = 40380}...}
        problem_tiles = std::set with 1414 elements = {[0] = 1340, [1] = 1341, [2] = 3053, [3] = 3054, [4] = 12272, [5] = 13218, [6] = 13295, [7] = 13296, [8] = 14244, [9] = 15270, [10] = 16296, [11] = 17203, [12] = 17321, 
          [13] = 17322, [14] = 17323, [15] = 17354, [16] = 19244, [17] = 19402, [18] = 20465, [19] = 21241, [20] = 21339, [21] = 21489, [22] = 21490, [23] = 22363, [24] = 30446, [25] = 31014, [26] = 32038, [27] = 33901, [28] = 34845, 
          [29] = 35107, [30] = 35858, [31] = 35868, [32] = 36879, [33] = 37153, [34] = 37453, [35] = 38122, [36] = 38123, [37] = 38175, [38] = 38176, [39] = 38927, [40] = 38928, [41] = 40169, [42] = 41836, [43] = 43445, [44] = 45133, 
          [45] = 45746, [46] = 45747, [47] = 46948, [48] = 47802, [49] = 47966, [50] = 47970, [51] = 48826, [52] = 49308, [53] = 49310, [54] = 50189, [55] = 50289, [56] = 50334, [57] = 50337, [58] = 50975, [59] = 51213, [60] = 51214, 
          [61] = 51999, [62] = 52386, [63] = 52686, [64] = 53260, [65] = 53410, [66] = 53439, [67] = 53710, [68] = 53711, [69] = 54694, [70] = 54696, [71] = 55081, [72] = 56744, [73] = 57323, [74] = 57324, [75] = 58129, [76] = 58155, 
          [77] = 59405, [78] = 59406, [79] = 62254, [80] = 62255, [81] = 62671, [82] = 62672, [83] = 62934, [84] = 62935, [85] = 63468, [86] = 63696, [87] = 63697, [88] = 64492, [89] = 64493, [90] = 64524, [91] = 65778, [92] = 66009, 
          [93] = 66010, [94] = 67033, [95] = 67034, [96] = 69642, [97] = 69643, [98] = 70104, [99] = 70862, [100] = 71081, [101] = 71082, [102] = 71470, [103] = 71471, [104] = 71885, [105] = 71886, [106] = 72908, [107] = 73705, 
          [108] = 73706, [109] = 73931, [110] = 74157, [111] = 74954, [112] = 75181, [113] = 75868, [114] = 75976, [115] = 76511, [116] = 76893, [117] = 76998, [118] = 77707, [119] = 78018, [120] = 78022, [121] = 78259, [122] = 80477, 
          [123] = 80478, [124] = 80793, [125] = 80874, [126] = 80875, [127] = 80909, [128] = 80910, [129] = 81934, [130] = 82363, [131] = 82534, [132] = 82924, [133] = 83387, [134] = 83397, [135] = 84415, [136] = 84416, [137] = 84417, 
          [138] = 84418, [139] = 86947, [140] = 87972, [141] = 89939, [142] = 90100, [143] = 92075, [144] = 92076, [145] = 93171, [146] = 93172, [147] = 96821, [148] = 97337, [149] = 97348, [150] = 98018, [151] = 99042, [152] = 99396, 
          [153] = 99397, [154] = 103496, [155] = 104235, [156] = 106310, [157] = 106482, [158] = 106483, [159] = 107507, [160] = 108531, [161] = 108619, [162] = 113743, [163] = 116814, [164] = 121399, [165] = 123824, [166] = 125871, 
          [167] = 126863, [168] = 126894, [169] = 127887, [170] = 129663, [171] = 129669, [172] = 129847, [173] = 130129, [174] = 130686, [175] = 130687, [176] = 130690, [177] = 130693, [178] = 130872, [179] = 131061, [180] = 131153, 
          [181] = 131154, [182] = 131985, [183] = 132084, [184] = 132085, [185] = 132443, [186] = 132998, [187] = 133000, [188] = 133071, [189] = 134032, [190] = 134127, [191] = 135802, [192] = 135803, [193] = 136270, [194] = 139216, 
          [195] = 139217, [196] = 139367, [197] = 139368, [198] = 140095, [199] = 142285...}
#15 0x00000000009fcd62 in RainfallRiverGenerator::GenerateRivers (this=0x7fa1840008c0) at /home/jgr/openttd/trunk2/src/rivers_rainfall.cpp:5253
        height_index = 0x7fa184000bc0
        number_of_flow_modifications = 20960
        lower_iterator = 0x7fa1840ac2f0
        flow_iterator = 0x7fa1844cc220
        water_flow = 0x7fa1844cc260
        water_info = 0x7fa1848cc270 ""
        define_lakes_iterator = 0x7fa1844ace40
        max_river_flow = -1005183744
        calculated_number_of_lower_tiles = 0x7fa1840ac320
        curve_flow_modificator = 0x7fa184cd51c0
        towns_generated = false
#16 0x0000000000884b28 in CreateRivers () at /home/jgr/openttd/trunk2/src/landscape.cpp:948
        river_generator = 0x7fa1840008c0
        generator = 1
        towns_created = 196
#17 0x0000000000884f5a in GenerateLandscape (mode=0 '\000') at /home/jgr/openttd/trunk2/src/landscape.cpp:1054
        steps = 0
        __PRETTY_FUNCTION__ = "bool GenerateLandscape(byte)"
#18 0x000000000082d1b8 in _GenerateWorld () at /home/jgr/openttd/trunk2/src/genworld.cpp:133
        towns_created = false
        _cur_company = {original = @0x13b0601, valid = true, original_value = {static begin = <optimised out>, static end = <optimised out>, static invalid = <optimised out>, m_val = 255 '\377'}, 
          file = 0xc9ce08 "/home/jgr/openttd/trunk2/src/genworld.cpp", line = 99}
#19 0x0000000000b1eb46 in ThreadObject_pthread::ThreadProc (this=0x2515620) at /home/jgr/openttd/trunk2/src/thread/thread_pthread.cpp:75
No locals.
#20 0x0000000000b1eb19 in ThreadObject_pthread::stThreadProc (thr=0x2515620) at /home/jgr/openttd/trunk2/src/thread/thread_pthread.cpp:63
No locals.
#21 0x00007fa1cd9b46aa in start_thread (arg=0x7fa1c4163700) at pthread_create.c:333
        __res = <optimised out>
        pd = 0x7fa1c4163700
        now = <optimised out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140332756252416, -2374591548888913367, 0, 140733114915471, 8388608, 37667472, 2326190284105640489, 2326208884283206185}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, 
            data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimised out>
        pagesize_m1 = <optimised out>
        sp = <optimised out>
        freesize = <optimised out>
        __PRETTY_FUNCTION__ = "start_thread"
#22 0x00007fa1cb7bbeed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
No locals.
Ex TTDPatch Coder
Patch Pack, Github
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Thanks for the excellent bug report, the issue was quickly found: I missed one line in the terraforming related refactoring some days ago. It was the line where it continues the loop for VOID tiles - the comment was a bit misleading. Unfortunately, on my testcase map (mostly ocean in the south) no terraforming on that map edge was necessary, so the issue didn´t showed up...

Beside this bugfix, this release contains numerous improvements for the tile finetuning algorithms. With them, the final lower everything until valid algorithm now has about 50 tiles to process, instead of 6500 before I started with those algorithms. The result should be a landscape where rivers follow much closer the heightmap, without digging into terrain too much. Especially, the problem that lakes where lowered because some single tile at the lake shore was lowered, and caused a whole cascade of lowering tiles should be gone.

So, from an algorithmic point of view, this is some sort of a milestone release.

The problem that rivers sometimes flow upwards needs to be fixed still, also the river endings to the ocean need to be improved.
For this, I am currently thinking about a breadth first search, which should at the same time be able to isolate logical rivers. On that basis, one might give rivers and lakes actually names.

(the idea is, start at the upper edge of some river, go down using breadth first search. Along the way, the flow will increase. If you find a tile that is, say, more than a few percent below the maximum flow found so far, you likely try to step upwards another river. Then stop.)

During that search, I can keep track about how far I came down so far, and if I go back again, I can perform appropriate terraforming.

BTW, thanks to some small merging errors, patch 400_Temp contains some small changes, so if you want to compile it without 320, then you have to apply them separately, e.g. move that patch before 320 temporarily. But honestly, given what I see concerning cities, my impression is that the city placer does a reasonable job in the meantime, at least for mountainous maps.
Attachments
rivers_v25.zip
(189.92 KiB) Downloaded 91 times
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

The aforementioned breadth first search.

The generator doesn´t yet do anything with it, but internally, with this release I for the first time have a concept of whole rivers as a data structure.

Turn (in rivers_rainfall.h) this logger to debug level 0 to see what it does:

Code: Select all

#define RAINFALL_DERIVE_RIVERS_LOG_LEVEL 9
Attachments
rivers_v26.zip
(196.08 KiB) Downloaded 87 times
Eddi
Tycoon
Tycoon
Posts: 8276
Joined: 17 Jan 2007 00:14

Re: Patch: The Rainfall River Generator

Post by Eddi »

ic111 wrote:Turn (in rivers_rainfall.h) this logger to debug level 0 to see what it does
log levels usually work the other way around, "0" is "don't say anything" and "9" is "spam the hell out of it."
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

The problem is, that OpenTTD has a fixed number of different loggers. One of them is "map". But in the generator, I don't need one, but about 10 different loggers I can use independent of each other.

Thus I use that #define statements to switch them on or off by modifying the number. As 0-messages are always printed out, I set those values to 9 usually, and change them to 0 once I need some set of messages.

For example, if terraforming-finetuning seems to do something strange, I set the corresponding #define to 0, generate a map, pick up a problematic tile, search in the output for its coordinates, and know quickly what happened to that tile during generation.

I know this is not as designed, but it does what I need, and the recompile needed is not that harmful as it affects only a few files.

It has a reason, why in modern systems, one can add different loggers as needed, often on a per-file-basis, e.g. in my real world work code

Code: Select all

private static final Logger log = LoggerFactory.getLogger(Foo.class);
... but unfortunately, not in OpenTTD.

And BTW, I regard those loggers (at least a big subset of them) as essential part of the patch; I says this because once in the case of more heightlevels, the first thing that happened on inclusion into trunk was removing the loggers.

Without those loggers, I would not be able to say anything about *why* the generator produced some particular situation.

Additionally, turning them on is a good starting point for someone who wants to understand how a particular algorithm works.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Patch: The Rainfall River Generator

Post by Alberth »

Instead of so many loggers, why not use a prefix notation instead?

Code: Select all

[tile-shuffle]Tile(143, 2079) moved to height 127
[water-filler]Tile(143, 2079) is water
and use 'grep' and friends to filter to only the relevant output?

Not sure it improves your chances to preserve the logging if it hits trunk, but it is perhaps an alternative solution to your problem.
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
JGR
Tycoon
Tycoon
Posts: 2564
Joined: 08 Aug 2005 13:46
Location: Ipswich

Re: Patch: The Rainfall River Generator

Post by JGR »

There is nothing stopping you adding more log categories as needed. It's just a few lines in src/debug.(h|cpp).
You could also treat the log level for a particular category as a bit field instead of a threshold.
Users who do want to look at the detailed logs probably won't want to recompile each time they change categories.
Ex TTDPatch Coder
Patch Pack, Github
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Alberth wrote:Instead of so many loggers, why not use a prefix notation instead?

Code: Select all

[tile-shuffle]Tile(143, 2079) moved to height 127
[water-filler]Tile(143, 2079) is water
and use 'grep' and friends to filter to only the relevant output?
We talk about log sizes, where performance becomes an issue. The fine tune tiles log increases running time of the algorithm from a few seconds to a few minutes for a 1024x1024 map.

If I start it in a plain shell, some logging settings nearly kill the shell window anyway (at least once I try to search in the window), when I start gdb in emacs, then the output buffer is surprisingly fast...

Thus: I simply cannot have logging being generated beside the logging I actually need.

Of course I can add more log categories, when I started with doing it that way I thought that they would be regarded as quite constant, i.e. shouldn't be changed that much.
Not sure it improves your chances to preserve the logging if it hits trunk, but it is perhaps an alternative solution to your problem.
Well, concerning the chances: Of course you can discuss for every log statement wether it is needed, and some certainly are not needed, i.e. for some I too would say, remove them. (mostly, for those, I already changed priority to a hardcoded 9).

Those with the constants are mostly a set that I identified to be useful during debugging. I.e. they simply affect my ability to sensefully do analysis (why does it do that?) on the code. After all, it is a partly heuristic algorithm, where you don't have binary "this is right" or "this is wrong" decisions...

What I just want to say: This is a topic to be discussed, not a "simply throw the logging away as first step" topic.
Users who do want to look at the detailed logs probably won't want to recompile each time they change categories.
... given what I found as infrastructure, the solution I use so far is one I can live with; I don't say it is perfect ...
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Some codechanges to deriving rivers, but not yet actual changes to the generation.
Attachments
rivers_v27.zip
(196.07 KiB) Downloaded 84 times
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Identifying tiles where a river flows upwards, but not yet changes to the generation.
Attachments
rivers_v28.zip
(198.44 KiB) Downloaded 81 times
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Preventing rivers flowing upwards - this release fixes some part of them.

One quite frequent condition is not yet fixed, namely if the upper tile is in a corner of the river, and both adjacent tiles are inclined. The reason is that the breadth first search (for good reasons) recognizes diagonal tiles as neighbor tiles, and thus the corner tile is found in the same iteration as one of the neighbor tiles.

(my condition for detecting upwards flow so far is that *all* tiles of an iteration are higher than a tile being found before - the background for this is that I fear I run into problem with wide rivers, where the height step can be distributed among several tiles, if I relax that condition, i.e. I might get false positives in such cases).

Furthermore, this release abstracts the algorithm "Breadth first search on tiles" to a separate class with virtual functions. It is placed in landscape_util.cpp, and might be used independent of this patch queue.
Attachments
rivers_v29.zip
(204.95 KiB) Downloaded 76 times
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Further progress. Most cases of upwards flow are gone, one that is remaining is when the river start is below its highest tile.

Then, the algorithm producing logical rivers produces two separate rivers (due to its top-down nature). Joining logical rivers in such a case should be a fixable task...


In the end, what I do here can be seen as a postprocessing step of transforming landscape into a river-appropriate landscape before. The initial flow algorithms did not produce upwards flow, but they partly worked on slopes that are not suitable for rivers, and need to be terraformed, with the side condition that rivers need to stay connected. Those algorithms do a hard job in iteratively terraforming landscape until all planned river tiles have appropriate slope. Additionally, wider rivers and valleys enter the story.

Finally, in this postprocessing step, I change the perspective towards having logical rivers, and fix the corner cases the above algorithms have produced. Luckily, fixing a hill water flows over, by lowering it by one heightlevel, is almost always possible without producing any river-inappropriate slope. Similar for raising a depression the river flows through.
Attachments
rivers_v30.zip
(212.8 KiB) Downloaded 77 times
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: Patch: The Rainfall River Generator

Post by wallyweb »

ic111 wrote:BTW, thanks to some small merging errors, patch 400_Temp contains some small changes, so if you want to compile it without 320, then you have to apply them separately, e.g. move that patch before 320 temporarily. But honestly, given what I see concerning cities, my impression is that the city placer does a reasonable job in the meantime, at least for mountainous maps.
Some players, when creating a scenario, have a need to explicitly place a specific number of cities instead of accepting random placement of a random number of cities. For this situation, a cityOn/cityOff switch would be very convenient.
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: Patch: The Rainfall River Generator

Post by wallyweb »

Here is the v30 "City On" Windows 32bit binary:
OpenTTD 1_5_2 Rainfall_v30_cityOn_Win32.7z
(4.39 MiB) Downloaded 76 times
Note that I still get crashes while the map generates in the scenario editor.
With rivers set to "few", I can only build 256x256 maximum.
With rivers set to "many" I can only build 512x512 maximum.
There are no crash logs.

Here is my system information:
system.png
system.png (24.62 KiB) Viewed 3187 times
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Some players, when creating a scenario, have a need to explicitly place a specific number of cities instead of accepting random placement of a random number of cities. For this situation, a cityOn/cityOff switch would be very convenien
It´s on the todo list, though I cannot promise when it will be implemented.
Note that I still get crashes while the map generates in the scenario editor.
With rivers set to "few", I can only build 256x256 maximum.
With rivers set to "many" I can only build 512x512 maximum.
There are no crash logs.
Hm, I know that my test-heightmap (1024x1024, quite mountainious, flow needed for river 200) is somewhat friendly towards the generator with respect to performance. This machine I use for testing has 2GB RAM, half of yours.

Thus I just generated two random test-maps:

(1) 1024x1024, Very flat, Moderate amount of water, Flow needed for river 200
(2) 1024x1024, Very flat, Little amount of water, Flow needed for river 50

Testcase (1) runs in moderate time, testcase (2) stays in the order of a few minutes at lake definition, but eventuallly steps over that one. In the end I saw that major parts of the map have become one giant lake.

So, I see a performance problem with lakes at very flat maps, but no crash, i.e. I cannot reproduce your problem. And my system diagnosis reported about RAM in the order of 500 or 600 MB being used.

Do you generate random maps, or do you use your favorite heightmap? You could use some heightmap to check wether the behaviour is deterministic, i.e. wether it always completes for 256x256 and never for 512x512, or wether behaviour is more random.

To conclude, I see no reason why generation should abort for performance reasons on your machine, maybe you trigger some segfault-related bug that only shows up on your operating system, and is somehow tolerated on mine. But still, then the missing crash log is strange.

EDIT: I attached the heightmap I use for testing. You might try generating it with the following settings: 1024x1024, Max height 60, Create river if flow >= 50, flow consumed per lake tile volume 0, flow modifications per 1000 tiles 30, wider rivers on multiplier 40, wider valleys on multiplier 5. All lake-related probabilities below are 0.
Attachments
TirolV5.6.png
(203.98 KiB) Not downloaded yet
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Additional question: When does it crash, what does the progress indicator show you last before the crash?
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: Patch: The Rainfall River Generator

Post by wallyweb »

ic111 wrote:Additional question: When does it crash, what does the progress indicator show you last before the crash?
Landscape Generation at about 7.
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Ok, so the problem seems to be near the beginning of the calculation. Otherwise you would see my messages about calculating number of lower tiles, flow, and so on.

You might do the following: Open file rivers_rainfall.cpp, search for that piece of code

Code: Select all

bool RainfallRiverGenerator::GenerateRivers()
{
	HeightIndex *height_index = new HeightIndex();

	SetGeneratingWorldProgress(GWP_RAINFALL_NUMBER_OF_LOWER, (MapSize() / 1000) + 1);
	DEBUG(map, RAINFALL_PROGRESS_LOG_LEVEL, "SetGeneratingWorldProgress: GWP_RAINFALL_NUMBER_OF_LOWER = %u", (MapSize() / 1000) + 1);

	/* For each tile, calculate the number of reachable lower tiles.  See the iterator for a more detailed
	 * description of that concept.  Start at the lowest parts of the map */
	NumberOfLowerHeightIterator *lower_iterator = new NumberOfLowerHeightIterator(height_index);
	for (uint h = 0; h <= _settings_game.construction.max_heightlevel; h++) {
		/* For a particular heightlevel, first look at the flat tiles, then at those with height difference 1,
		 * and finally at the steep tiles.  Having a look at map geometry, this order does what we want, beside
		 * the fact that the heightlevel is always the one of the north corner. */
		lower_iterator->Calculate(h, HLIM_ZERO_OR_ONE_CORNER_RAISED);
		lower_iterator->Calculate(h, HLIM_TWO_OR_THREE_CORNERS_RAISED);
		lower_iterator->Calculate(h, HLIM_STEEP);
	}

	int *calculated_number_of_lower_tiles = lower_iterator->GetNumberOfLowerTiles();
	(...)
This is the beginning of the main calculation function.
The question is, does it crash if you (after you made a copy of the file) remove everything but the very beginning of that function? E.g. such that it looks like:

Code: Select all

bool RainfallRiverGenerator::GenerateRivers()
{
	HeightIndex *height_index = new HeightIndex();
	delete height_index;
	return false
}
If yes, then the height index is the problem (in that case, please verify by also removing its creation, making the function completely empty). If no, you might do the same, but keep the code block above including the number of lower tiles calculation, followed again by

Code: Select all

	delete lower_iterator;
	delete height_index;
	return false;
}
Alternatively, people capable in doing this are invited to review the HeightIndex. That piece of code didn´t change for ages, I regard it as a piece of stable library code from the perspective of the river generator.

Specifically, does this piece of code constructing the data array of the index suffer from some problem?

Code: Select all

/** Allocates an index array as described in the class comment of HeightIndex.
 *  @return index array as described in the class comment of HeightIndex
 */
byte** HeightIndex::ConstructHeightArray()
{
	int log_x = MapLogX();
	int log_y = MapLogY();
	int min_log = min(log_x, log_y);

	byte** height = CallocT<byte*>(min_log + 1);
	for (int n = 1; n <= min_log; n++) {
		int size = (MapSizeX() * MapSizeY()) / (1 << (n + n));;
		DEBUG(map, 9, "height[%i] receives size %i, where log_x = %i, log_y = %i", n, size, log_x, log_y);
		height[n] = CallocT<byte>(size);
	}

	return height;
}
(as far as I remember, I left height[0] intentionally free, to make later work with indices easier and more straightforward)

Last, I attached a new version, with some improvements regarding river flowing upwards treatment. That problem should now be gone.
Attachments
rivers_v31.zip
(217.36 KiB) Downloaded 91 times
ic111
Director
Director
Posts: 608
Joined: 17 Jul 2007 17:56

Re: Patch: The Rainfall River Generator

Post by ic111 »

Additional: There seems to be one probably rather rare condition that stops generation at the end or after wider river/valley generation and before actually placing the water.

It happens once in several generations. Smells like an endless loop / recursion with an extremely rare condition (given that on a 1024x1024 map with its million of tiles, most cases one can think of happen several times).

Debugging question; When it runs in gdb, and I hit C+c C+c, then gdb stops, and I can enter bt to generate a backtrace. Unfortunately, in such situations, the backtrace always only contains some Mutex.
Do I have a chance to get the real location in application code in case of such an endless loop, or is this impossible for gdb? Is that Mutex backtrace in the right thread at all?
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Bing [Bot], Google Adsense [Bot], ino, ZaphodB and 3 guests