MantisBT - VCMI
View Issue Details
0002060VCMIAI - Adventure Mappublic2015-02-09 17:452015-10-15 03:00
SXX 
Ivan 
normalmajoralways
closedfixed 
0.97b 
0.98 
0002060: After loading game FuzzyHelper::estimateBankDanger not work properly
As result it's will always return zero danger for banks and AI will no longer able set goals properly: all heroes that not powerful enough to win will be sent to banks and die.

This one is somewhat tricky problem that me and @AVS spend multiple hours to investigate. It's happen because after loading the game "CBankInstanceConstructor::levels" no longer contain sub JSON vector called "guards". Without "guards" info "CBankInfo::getPossibleGuards" no longer able to return proper power of certain bank.

Though "chance", "combat_value" and "reward" are loaded properly. Full structure may be found here:
/config/objects/creatureBanks.json
Also we checked several things here:

  - On saving it's looks like "levels" are serialized properly.
  - In save file binary it's also looks like all information in place.
  - Even on loading of save it's looks like that "guards" vector it's looks like that serializer attempt to read it, but this isn't 100% checked.

So most likely something bad happen within deserialization process.

If you want to get more useful data set breakpoint here:
/lib/mapObjects/CommonConstructors.cpp:431
std::unique_ptr<IObjectInfo> CBankInstanceConstructor::getObjectInfo(ObjectTemplate tmpl) 
const
{
    return std::unique_ptr<IObjectInfo>(new CBankInfo(levels));
}
No tags attached.
related to 0001918closed Warmonger AI Overconfident About Creature Banks 
? AI_SXX_Naga_bank.h3m (1,890) 2015-02-09 17:45
https://bugs.vcmi.eu/file_download.php?file_id=2100&type=bug
zip bug_ai_banks_danger.zip (400,818) 2015-02-09 17:51
https://bugs.vcmi.eu/file_download.php?file_id=2101&type=bug
Issue History
2015-02-09 17:45SXXNew Issue
2015-02-09 17:45SXXStatusnew => assigned
2015-02-09 17:45SXXAssigned To => Warmonger
2015-02-09 17:45SXXFile Added: AI_SXX_Naga_bank.h3m
2015-02-09 17:51SXXFile Added: bug_ai_banks_danger.zip
2015-02-09 17:52SXXNote Added: 0005433
2015-02-09 18:03SXXNote Added: 0005434
2015-02-09 18:41SXXNote Added: 0005435
2015-02-10 10:10AVSRelationship addedrelated to 0001918
2015-03-18 08:07SXXNote Added: 0005655
2015-03-18 08:09SXXNote Edited: 0005655bug_revision_view_page.php?bugnote_id=5655#r2890
2015-03-29 11:00WarmongerAssigned ToWarmonger =>
2015-03-29 11:02WarmongerNote Added: 0005665
2015-03-29 11:02WarmongerStatusassigned => new
2015-03-29 14:51SXXNote Added: 0005669
2015-03-30 21:24IvanAssigned To => Ivan
2015-03-30 21:24IvanStatusnew => assigned
2015-03-30 22:01IvanNote Added: 0005676
2015-03-30 22:01IvanStatusassigned => resolved
2015-03-30 22:01IvanFixed in Version => 0.98
2015-03-30 22:01IvanResolutionopen => fixed
2015-10-15 03:00SXXStatusresolved => closed

Notes
(0005433)
SXX   
2015-02-09 17:52   
Also attached special test map I used for easier testing.
(0005434)
SXX   
2015-02-09 18:03   
Also it's possible that it's should be duplicate of 0001918, but may be separate problem too.
(0005435)
SXX   
2015-02-09 18:41   
And here is one more other addition so it's won't be forgotten. Before I find out that problem with banks caused by actual game bug I'm get an idea that it's would be great to add some "memory" for the VCAI.

So VCMI originally threat banks danger based on config files because it's can't know actual level of the object. Though once hero visited bank and die here AI should "remember" what exactly level of bank it is and as result threat it's danger more carefully.

Also had idea to make sure that next hero that visit bank should be at least a bit more powerful that previous hero that died here.
(0005655)
SXX   
2015-03-18 08:07   
(edited on: 2015-03-18 08:09)
Bump this one as it's currently biggest problem with VCAI.
If anyone may want to help with it this may be extremely useful.

(0005665)
Warmonger   
2015-03-29 11:02   
Not sure why it's assigned to me. Probably Ivan is the guy responsible both for JSon parser and object rewrite.
(0005669)
SXX   
2015-03-29 14:51   
I think it's just assigned automatically. :-)
(0005676)
Ivan   
2015-03-30 22:01   
Now this is an interesting bug. I still have no idea why this happened but seems to be fixed now.

Short version - serialized *changed* key of std::map insert of loading new key into a buffer (variable on stack)

As result - data from this key was overwritten by subsequent loading.

Weird. But should be fixed.
https://github.com/vcmi/vcmi/commit/376b2436f842a3d977e96b094d0916f8ee19d144 [^]