MantisBT - VCMI
View Issue Details
0003060VCMIAI - Adventure Mappublic2019-05-16 09:022019-05-21 14:45
Ubuntu 16.04.6 LTS 
0003060: core in CMap.cpp::getTile

- witchkings artifacts
- hota
- death valley
- retreat
- preserve town

running develop (aee4bb728) 9May

console output
vcmiserver: /media/data/mpech/dl/vcmi/lib/mapping/CMap.cpp:390: TerrainTile& CMap::getTile(const int3&): Assertion `isInTheMap(tile)' failed.
vcmiclient: /media/data/mpech/dl/vcmi/lib/mapping/CMap.cpp:390: TerrainTile& CMap::getTile(const int3&): Assertion `isInTheMap(tile)' failed.
Aborted (core dumped)

0000002 0x00007f589431dbd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x7f5896363c21 "isInTheMap(tile)",
    file=file@entry=0x7f5896363b28 "/media/data/mpech/dl/vcmi/lib/mapping/CMap.cpp", line=line@entry=390,
    function=function@entry=0x7f58963645c0 <CMap::getTile(int3 const&)::__PRETTY_FUNCTION__> "TerrainTile& CMap::getTile(const int3&)") at assert.c:92
0000003 0x00007f589431dc82 in __GI___assert_fail (assertion=assertion@entry=0x7f5896363c21 "isInTheMap(tile)",
    file=file@entry=0x7f5896363b28 "/media/data/mpech/dl/vcmi/lib/mapping/CMap.cpp", line=line@entry=390,
    function=function@entry=0x7f58963645c0 <CMap::getTile(int3 const&)::__PRETTY_FUNCTION__> "TerrainTile& CMap::getTile(const int3&)")
    at assert.c:101
0000004 0x00007f5895f8426d in CMap::getTile (this=0x7f588478e290, tile=...) at /media/data/mpech/dl/vcmi/lib/mapping/CMap.cpp:390
0000005 0x00007f589632931f in NewObject::applyGs (this=this@entry=0x7f588bffeb00, gs=gs@entry=0x7f5884787880)
    at /media/data/mpech/dl/vcmi/lib/NetPacksLib.cpp:679
0000006 0x00007f58962767af in CApplyOnGS<NewObject>::applyOnGS (this=<optimized out>, gs=0x7f5884787880, pack=0x7f588bffeb00)
    at /media/data/mpech/dl/vcmi/lib/CGameState.cpp:63
0000007 0x00007f589625f24e in CGameState::apply (this=0x7f5884787880, pack=pack@entry=0x7f588bffeb00) at /media/data/mpech/dl/vcmi/lib/CGameState.cpp:1968
0000008 0x0000000000444a2d in CGameHandler::sendAndApply (this=0x7f588402b8f0, pack=0x7f588bffeb00)

load attached save, end turn
No tags attached.
zip (1,727,436) 2019-05-16 09:02
Issue History
2019-05-16 09:02mpechNew Issue
2019-05-16 09:02mpechFile Added:
2019-05-16 11:15mpechNote Added: 0007788
2019-05-16 13:04mpechNote Added: 0007789
2019-05-16 13:04mpechNote Edited: 0007789bug_revision_view_page.php?bugnote_id=7789#r3571
2019-05-16 13:04mpechNote Edited: 0007789bug_revision_view_page.php?bugnote_id=7789#r3572
2019-05-18 17:36DydzioAssigned To => Dydzio
2019-05-18 17:36DydzioStatusnew => assigned
2019-05-18 17:42DydzioNote Added: 0007792
2019-05-21 14:45DydzioStatusassigned => resolved
2019-05-21 14:45DydzioFixed in Version =>
2019-05-21 14:45DydzioResolutionopen => fixed

2019-05-16 11:15   
looking a bit further:
wrong offset is pos.x == 144 (==width)

> CApplyOnGS<NewObject>::applyOnGS
wrong CApplyOnGS<NewObject> for which pos.x == 144 holds Obj ID ==8

problematic Obj ID == 8 maps to CGameHandler::buildBoat and indeed adding
    int3 tile2 = tile + int3(1,0,0);
    if (!gs->map->isInTheMap(tile2))
        return false;

does complain

error occurs because in attached screenshot, shipyard lies on the almost border of the map.
bestLocation may (not checked) return the tile (143,0,0) which is at the utmost limit (x axis) of the map but line
> no.pos = tile + int3(1,0,0);
makes the generated boat go out of the map

code seem to be old and there must be a reason I don't understand why we add int3(1,0,0) to the bestLocation()??
2019-05-16 13:04   
I ended up modifying CObjectHandler.cpp so I can play

IBoatGenerator::EGeneratorState IBoatGenerator::shipyardStatus() const
    int3 tile = bestLocation();
    const TerrainTile *t = IObjectInterface::cb->getTile(tile);
        return TILE_BLOCKED; //no available water
    else if (!o->cb->gameState()->map->isInTheMap(tile+int3(1,0,0))) // poor code dupe from CGameHandler.cpp
        return TILE_BLOCKED;

but propagating the (1,0,0)offset seem rather rather ugly

2019-05-18 17:42   
Fixed in: [^]