MantisBT - VCMI
View Issue Details
0002972VCMIRandom Map Generatorpublic2018-07-17 11:332023-10-28 20:51
Warmonger 
SXX 
normalblocksometimes
resolvedfixed 
1.next 
1.3.2 
0002972: RMG crashes
I have several issues with RMG in my build going to dump them here.
No tags attached.
png image.png (15,243) 2018-07-19 05:16
https://bugs.vcmi.eu/file_download.php?file_id=2918&type=bug
png
Issue History
2018-07-17 11:33WarmongerNew Issue
2018-07-17 11:33WarmongerAssigned To => Warmonger
2018-07-17 11:33WarmongerStatusnew => assigned
2018-07-17 11:34WarmongerNote Added: 0007590
2018-07-17 11:40WarmongerNote Edited: 0007590bug_revision_view_page.php?bugnote_id=7590#r3500
2018-07-17 11:40WarmongerNote Added: 0007591
2018-07-17 11:41WarmongerNote Edited: 0007591bug_revision_view_page.php?bugnote_id=7591#r3502
2018-07-17 11:43WarmongerNote Edited: 0007591bug_revision_view_page.php?bugnote_id=7591#r3503
2018-07-17 13:25WarmongerNote Added: 0007592
2018-07-17 13:31AVSNote Added: 0007593
2018-07-17 13:35WarmongerNote Added: 0007594
2018-07-17 13:37AVSNote Added: 0007595
2018-07-17 13:59WarmongerNote Added: 0007596
2018-07-19 05:12WarmongerNote Added: 0007598
2018-07-19 05:15WarmongerNote Added: 0007599
2018-07-19 05:16WarmongerFile Added: image.png
2018-07-19 05:16WarmongerAssigned ToWarmonger => SXX
2023-10-28 20:51NordsoftStatusassigned => resolved
2023-10-28 20:51NordsoftFixed in Version => 1.3.2
2023-10-28 20:51NordsoftResolutionopen => fixed

Notes
(0007590)
Warmonger   
2018-07-17 11:34   
(edited on: 2018-07-17 11:40)
When creating random map with default options, get access violation at AI player 2:

bool CGameState::isVisible(int3 pos, PlayerColor player)
{
    if(player == PlayerColor::NEUTRAL)
        return false;
    if(player.isSpectator())
        return true;

    return getPlayerTeam(player)->fogOfWarMap[pos.x][pos.y][pos.z];
}

On second try, it crashed at player 4.

(0007591)
Warmonger   
2018-07-17 11:40   
(edited on: 2018-07-17 11:43)
Unit tests fail with team mismatch:

[----------] 2 tests from MapManager
[ RUN ] MapManager.DrawTerrain_Type
[ OK ] MapManager.DrawTerrain_Type (96 ms)
[ RUN ] MapManager.DrawTerrain_View
[ OK ] MapManager.DrawTerrain_View (9 ms)
[----------] 2 tests from MapManager (105 ms total)

[----------] 3 tests from MapFormat
[ RUN ] MapFormat.Random
e:\programowanie\vcmi\source\test\map\mapcomparer.cpp(87): error: Expected: actual.team
      Which is: 1-byte object <00>
To be equal to: expected.team
      Which is: 1-byte object <03>
Google Test trace:
e:\programowanie\vcmi\source\test\map\cmapformattest.cpp(69): MapFormat_Random saved
e:\programowanie\vcmi\source\test\map\cmapformattest.cpp(67): MapFormat_Random serialized
e:\programowanie\vcmi\source\test\map\cmapformattest.cpp(60): MapFormat_Random generated
e:\programowanie\vcmi\source\test\map\cmapformattest.cpp(42): MapFormat_Random start
e:\programowanie\vcmi\source\test\map\mapcomparer.cpp(87): error: Expected: actual.team
      Which is: 1-byte object <03>
To be equal to: expected.team
      Which is: 1-byte object <00>
Google Test trace:
e:\programowanie\vcmi\source\test\map\cmapformattest.cpp(69): MapFormat_Random saved
e:\programowanie\vcmi\source\test\map\cmapformattest.cpp(67): MapFormat_Random serialized
e:\programowanie\vcmi\source\test\map\cmapformattest.cpp(60): MapFormat_Random generated
e:\programowanie\vcmi\source\test\map\cmapformattest.cpp(42): MapFormat_Random start
[ FAILED ] MapFormat.Random (949 ms)
[ RUN ] MapFormat.Objects
[ OK ] MapFormat.Objects (443 ms)
[ RUN ] MapFormat.Terrain
[ OK ] MapFormat.Terrain (20 ms)
[----------] 3 tests from MapFormat (1412 ms total)

This result is consistent after multiple tests.

(0007592)
Warmonger   
2018-07-17 13:25   
Daily builds also crash RMG, in different ways but not always. Regular game works fine.
(0007593)
AVS   
2018-07-17 13:31   
Test failure indicates problem in map format
(0007594)
Warmonger   
2018-07-17 13:35   
Right, but why it is working for everyone else?
(0007595)
AVS   
2018-07-17 13:37   
Might be compiler-dependent
(0007596)
Warmonger   
2018-07-17 13:59   
Sometimes (for a second time now) map is generated, but contains no monsters.

Might be an issue with "monster strength" blinking buttons.
(0007598)
Warmonger   
2018-07-19 05:12   
Map is generated correctly if you set SPECIFIC number of players in options
Not random

In
 CVCMIServer::prepareToStartGame()
si always contains infos about 8 players
Game crashes if there are less

This snippet in lobby defaults to 8 players at random setting

    // Generate player information
    mapInfo->mapHeader->players.clear();
    int playersToGen = PlayerColor::PLAYER_LIMIT_I;
    if(mapGenOptions->getPlayerCount() != CMapGenOptions::RANDOM_SIZE)
        playersToGen = mapGenOptions->getPlayerCount();
    mapInfo->mapHeader->howManyTeams = playersToGen;

    for(int i = 0; i < playersToGen; ++i)
    {
        PlayerInfo player;
        player.isFactionRandom = true;
        player.canComputerPlay = true;
        if(mapGenOptions->getCompOnlyPlayerCount() != CMapGenOptions::RANDOM_SIZE && i >= mapGenOptions->getHumanOnlyPlayerCount())
        {
            player.canHumanPlay = false;
        }
        else
        {
            player.canHumanPlay = true;
        }
        player.team = TeamID(i);
        player.hasMainTown = true;
        player.generateHeroAtMainTown = true;
        mapInfo->mapHeader->players.push_back(player);
    }

    mapInfoChanged(mapInfo, mapGenOptions);
(0007599)
Warmonger   
2018-07-19 05:15   
However, monster strength buttons are also broken as a separate issue

monsterStrength grows by 2 every time this function is entered

Buttons are stored in a map, so they grow when adresed incorrectly

Uploaded image from debugger.