MantisBT - VCMI
View Issue Details
0002389VCMIGUI - Otherpublic2016-01-19 07:142016-01-19 10:06
vmarkovtsev 
 
normalminoralways
newopen 
DarwinMacOSX10.11.2
0.98f 
 
0002389: CComponent::getSubtitleInternal segfaults on unknown town buildings
std::string CComponent::getSubtitleInternal() at client/widgets/CComponent.cpp near line 177

case building: return CGI->townh->factions[subtype]->town->buildings[BuildingID(val)]->Name()

If val is not contained in the mapping, nullptr is returned and std::string segfaults later on.
Use map "The Lord of War", load the attached save. End turn. In this particular case, Barbarian town has the following structures:

0: Гильдия Магов 1 уровня
1: Гильдия Магов 2 уровня
2: Гильдия Магов 3 уровня
5: Таверна
7: Форт
8: Цитадель
9: Замок
10: Сельская управа
11: Префектура
12: Муниципалитет
13: Капитолий
14: Рынок
15: Хранилище ресурсов
16: Кузница
17: Чёрный ход
18: Столовая
19: Столовая
21: Гильдия наёмников
22: Двор баллист
23: Храм валгаллы
26: Памятник богам войны

But 27 is requested.
No tags attached.
? The Lord of War.h3m (152,581) 2016-01-19 07:14
https://bugs.vcmi.eu/file_download.php?file_id=2436&type=bug
zip save.zip (2,390,088) 2016-01-19 07:15
https://bugs.vcmi.eu/file_download.php?file_id=2437&type=bug
Issue History
2016-01-19 07:14vmarkovtsevNew Issue
2016-01-19 07:14vmarkovtsevFile Added: The Lord of War.h3m
2016-01-19 07:15vmarkovtsevFile Added: save.zip
2016-01-19 07:39vmarkovtsevNote Added: 0006310
2016-01-19 08:20AVSNote Added: 0006311
2016-01-19 08:28AVSNote Added: 0006312
2016-01-19 09:45WarmongerNote Added: 0006313
2016-01-19 10:06AVSNote Added: 0006314

Notes
(0006310)
vmarkovtsev   
2016-01-19 07:39   
https://github.com/vcmi/vcmi/pull/158 [^]
(0006311)
AVS   
2016-01-19 08:20   
The question is why 27 is requested? May be the bug is in other place.
(0006312)
AVS   
2016-01-19 08:28   
Looks like Barbarian town has missing entries:

"extraTownHall": { "id" : 27, "requires" : [ "townHall" ], "mode" : "auto" },
"extraCityHall": { "id" : 28, "requires" : [ "cityHall" ], "mode" : "auto" },
"extraCapitol": { "id" : 29, "requires" : [ "capitol" ], "mode" : "auto" }

Need to check all other towns too.
(0006313)
Warmonger   
2016-01-19 09:45   
"Auto" buildings are just decorative and have no own function. There is also no reason to display them in a message.
(0006314)
AVS   
2016-01-19 10:06   
Now I found a bug.

The problem is that when map is loading, "extra" buildings are added even if the town have no "extra" buildings.

CMapLoaderH3M::convertBuildings

...

    if(ret.find(BuildingID::CITY_HALL) != ret.end())
    {
        ret.insert(BuildingID::EXTRA_CITY_HALL);
    }
    if(ret.find(BuildingID::TOWN_HALL) != ret.end())
    {
        ret.insert(BuildingID::EXTRA_TOWN_HALL);
    }
    if(ret.find(BuildingID::CAPITOL) != ret.end())
    {
        ret.insert(BuildingID::EXTRA_CAPITOL);
    }