MantisBT - VCMI
View Issue Details
0002681VCMIRandom Map Generatorpublic2017-05-26 15:402017-05-27 12:59
SXX 
Warmonger 
normalminoralways
resolvedfixed 
0.99 
1.next 
0002681: RMG crash when used creatures with zero AIValue
In CRmgTemplateZone::addAllPossibleObjects there is "creatureToCount" lamba that using float for "creaturesAmount" and if AIValue is zero then it's going to become +infinity which of course cause crash on rounding.

This particularly occurs with WoG mod enabled. So this have to be fixed OR we should just forbid to add creatures with zero AIValue and trigger error on loading.
No tags attached.
Issue History
2017-05-26 15:40SXXNew Issue
2017-05-26 15:40SXXStatusnew => assigned
2017-05-26 15:40SXXAssigned To => Warmonger
2017-05-26 16:11SXXNote Added: 0007047
2017-05-26 19:23SXXNote Added: 0007049
2017-05-27 09:11WarmongerNote Added: 0007052
2017-05-27 12:47WarmongerNote Added: 0007053
2017-05-27 12:59WarmongerNote Added: 0007054
2017-05-27 12:59WarmongerStatusassigned => resolved
2017-05-27 12:59WarmongerFixed in Version => 1.next
2017-05-27 12:59WarmongerResolutionopen => fixed

Notes
(0007047)
SXX   
2017-05-26 16:11   
Warmonger since RMG is your code it's up to you to decide how to handle that, but probably we should require AIValue for all loaded creatures.
(0007049)
SXX   
2017-05-26 19:23   
So just to be clear I suppose I stuck into that one due to some other resource loading priority problem on Linux and WoG actually have AIValue somewhere in assets and just not in JSON. Would still prefer if this one fixed.
(0007052)
Warmonger   
2017-05-27 09:11   
Surely json should not allow 0 AI value.
(0007053)
Warmonger   
2017-05-27 12:47   
Now interesting part: CRTRAITS.txt contains NOT_USED CREATURES, which indeed have 0 value. They should never show up, though.
(0007054)
Warmonger   
2017-05-27 12:59   
Added some sanity checks in https://github.com/vcmi/vcmi/commit/346d2ac588b62e65a8aa8e140acf5adf9661a6b9 [^]

Can't really test, this should never occur in a game without bugged mods.