MantisBT - VCMI
View Issue Details
0001985VCMIMechanics - Objectspublic2014-12-07 07:282014-12-22 09:47
SXX 
SXX 
normalcrashalways
closedfixed 
0.97 
0.97b 
0001985: Cartographer: attempt of tunnels reveal on map without underground cause server crash
In process of creating my testing map find out that such behaviour will cause crash while in vanilla heroes nothing would happen.

CCartographer::blockingDialogAnswered or CPrivilagedInfoCallback::getAllTiles need appropriate check if underground level exists or not.

Will try to fix it on my own.
  - Start game on attached map.
  - Go to cartographer.
  - Agree to buy a map.
No tags attached.
related to 0001986closed SXX Cartographers of same type not marked as visited after one of them visited 
? testCart.h3m (4,984) 2014-12-07 07:28
https://bugs.vcmi.eu/file_download.php?file_id=2030&type=bug
txt tunnelMapCrash_GDB_backtrace.txt (2,725) 2014-12-07 07:28
https://bugs.vcmi.eu/file_download.php?file_id=2031&type=bug
Issue History
2014-12-07 07:28SXXNew Issue
2014-12-07 07:28SXXStatusnew => assigned
2014-12-07 07:28SXXAssigned To => SXX
2014-12-07 07:28SXXFile Added: testCart.h3m
2014-12-07 07:28SXXFile Added: tunnelMapCrash_GDB_backtrace.txt
2014-12-07 08:39SXXNote Added: 0005198
2014-12-07 09:20WarmongerNote Added: 0005199
2014-12-07 10:50SXXRelationship addedrelated to 0001986
2014-12-07 10:52SXXNote Added: 0005202
2014-12-07 10:52SXXCategoryMechanics - Adventure Map => Mechanics - Objects
2014-12-07 11:34WarmongerNote Added: 0005203
2014-12-09 11:11SXXNote Added: 0005209
2014-12-09 12:50SXXStatusassigned => resolved
2014-12-09 12:50SXXFixed in Version => 0.97b
2014-12-09 12:50SXXResolutionopen => fixed
2014-12-22 09:47SXXStatusresolved => closed

Notes
(0005198)
SXX   
2014-12-07 08:39   
So easy way to bypass the crash would be just add such check to "CCartographer::blockingDialogAnswered":
void CCartographer::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const
{
    if(subID == 2 && !cb->gameState()->map->twoLevel)
        return;

So player won't lose any gold, building just would do nothing.

Though in vanilla Heroes 3 behaviour is different:

  - Cartographer building marked as visited.
  - Player lose 1000 gold.

Is there reason to stick to how it's work in vanilla, solution above would work or there need to be some better fix for such situation?
(0005199)
Warmonger   
2014-12-07 09:20   
IMO Cartographer which can't reveal anything should be marked as visited, but don't take away gold from player for nothing.
(0005202)
SXX   
2014-12-07 10:52   
Do you think it's should show dialog about map purchase at all?
Then if player agree don't take any gold and just mark it as visited?

...

Also in vanilla underground cartographer looks broken (do nothing) and land one reveal everything except water on both underground and ground layers. So VCMI works more correctly here.

PS: Find out other wrong behaviour and posted as 0001985
(0005203)
Warmonger   
2014-12-07 11:34   
If Cartographer cannot work correctly, it should display "visited" message on first hero visit and don't make any offer.
(0005209)
SXX   
2014-12-09 11:11   
Pull request:
https://github.com/vcmi/vcmi/pull/64 [^]

Few other improvements for Cartographer will be in separate pull requests as they're break saves.