MantisBT - VCMI
View Issue Details
0003041VCMIMechanics - Adventure Mappublic2019-02-23 13:552019-02-24 16:43
mpech 
Nullkiller 
normalminoralways
resolvedfixed 
Ubuntu 16.04.5 LTS
 
0.next 
0003041: AI infinite loop due to town portal
Hi guys,

getting an infinite loop:

...
No town at destination tile
System message: Server encountered a problem: No town at destination tile
Hero Sandro cannot reach (45 36 1).
No town at destination tile
System message: Server encountered a problem: No town at destination tile
Hero Sandro cannot reach (45 36 1).
load map
end turn
see green never ending

By adding an assert(false) in TownPortalMechanics::applyAdventureEffects

    +++ b/lib/spells/AdventureSpellMechanics.cpp
    @@ -370,6 +370,8 @@ ESpellCastResult TownPortalMechanics::applyAdventureEffects(const SpellCastEnvir
                    if(tile.visitableObjects.empty() || tile.visitableObjects.back()->ID != Obj::TOWN)
                    {
                            env->complain("No town at destination tile");
    + assert(false);
                            return ESpellCastResult::ERROR;
                    }
 

in I get

    0000002 0x00007f8f509f5bd7 in __assert_fail_base (fmt=<optimized out>, [email protected]=0x7f8f52aee4ca "false",
        [email protected]=0x7f8f52acb330 "/home/mpech2/dl/vcmi/lib/spells/AdventureSpellMechanics.cpp", [email protected]=379,
        [email protected]=0x7f8f52acb7c0 <TownPortalMechanics::applyAdventureEffects(SpellCastEnvironment const*, AdventureSpellCastParameters const&) const::__PRETTY_FUNCTION__> "virtual ESpellCastResult TownPortalMechanics::applyAdventureEffects(const SpellCastEnvironment*, const AdventureSpellCastParameters&) const") at assert.c:92
    0000003 0x00007f8f509f5c82 in __GI___assert_fail ([email protected]=0x7f8f52aee4ca "false",
        [email protected]=0x7f8f52acb330 "/home/mpech2/dl/vcmi/lib/spells/AdventureSpellMechanics.cpp", [email protected]=379,
        [email protected]=0x7f8f52acb7c0 <TownPortalMechanics::applyAdventureEffects(SpellCastEnvironment const*, AdventureSpellCastParameters const&) const::__PRETTY_FUNCTION__> "virtual ESpellCastResult TownPortalMechanics::applyAdventureEffects(const SpellCastEnvironment*, const AdventureSpellCastParameters&) const") at assert.c:101
    0000004 0x00007f8f528abdec in TownPortalMechanics::applyAdventureEffects (this=<optimized out>, env=0x7f8f40006490, parameters=...)
        at /home/mpech2/dl/vcmi/lib/spells/AdventureSpellMechanics.cpp:379
    0000005 0x00007f8f528a76df in AdventureSpellMechanics::performCast ([email protected]=0x7f8f406e7ad0, [email protected]=0x7f8f40006490, parameters=...)
        at /home/mpech2/dl/vcmi/lib/spells/AdventureSpellMechanics.cpp:109
    0000006 0x00007f8f528a79b2 in AdventureSpellMechanics::adventureCast (this=0x7f8f406e7ad0, env=0x7f8f40006490, parameters=...)
        at /home/mpech2/dl/vcmi/lib/spells/AdventureSpellMechanics.cpp:63
    0000007 0x00007f8f528b6f22 in CSpell::adventureCast ([email protected]=0x7f8f40629200, env=0x7f8f40006490, parameters=...)
        at /home/mpech2/dl/vcmi/lib/spells/CSpellHandler.cpp:131
    0000008 0x0000000000504a23 in CastAdvSpell::applyGh (this=0x7f8f4000fff0, gh=0x7f8f4002b560) at /home/mpech2/dl/vcmi/server/NetPacksServer.cpp:360
    0000009 0x0000000000466ff9 in CApplyOnGH<CastAdvSpell>::applyOnGH (this=<optimized out>, gh=<optimized out>, pack=<optimized out>)
        at /home/mpech2/dl/vcmi/server/CGameHandler.cpp:194
    0000010 0x000000000044afa7 in CGameHandler::handleReceivedPack (this=0x7f8f4002b560, pack=0x7f8f4000fff0)
        at /home/mpech2/dl/vcmi/server/CGameHandler.cpp:1233
    0000011 0x00000000004d1cec in CVCMIServer::threadHandleClient (this=0x7ffd1994c810, c=std::shared_ptr (count 15, weak 1) 0x7f8f48000ad0)
        at /home/mpech2/dl/vcmi/server/CVCMIServer.cpp:319
    0000012 0x00000000004df3f8 in boost::_mfi::mf1<void, CVCMIServer, std::shared_ptr<CConnection> >::operator() (a1=..., p=<optimized out>,
        this=<optimized out>) at /usr/include/boost/bind/mem_fn_template.hpp:165
No tags attached.
zip inftp.zip (2,361,196) 2019-02-23 13:55
https://bugs.vcmi.eu/file_download.php?file_id=2990&type=bug
txt log.txt (6,481) 2019-02-23 15:26
https://bugs.vcmi.eu/file_download.php?file_id=2991&type=bug
? Dragon Lord.h3m (134,259) 2019-02-23 17:14
https://bugs.vcmi.eu/file_download.php?file_id=2993&type=bug
Issue History
2019-02-23 13:55mpechNew Issue
2019-02-23 13:55mpechFile Added: inftp.zip
2019-02-23 14:10AVSNote Added: 0007756
2019-02-23 15:07AVSAssigned To => AVS
2019-02-23 15:07AVSStatusnew => confirmed
2019-02-23 15:26AVSFile Added: log.txt
2019-02-23 15:50AVSAssigned ToAVS => Nullkiller
2019-02-23 15:50AVSStatusconfirmed => assigned
2019-02-23 16:58mpechFile Added: dragonLord.h3m
2019-02-23 16:59mpechNote Added: 0007757
2019-02-23 17:13AVSFile Deleted: dragonLord.h3m
2019-02-23 17:14AVSFile Added: Dragon Lord.h3m
2019-02-23 17:14AVSNote Added: 0007758
2019-02-23 17:35AVSNote Added: 0007759
2019-02-23 18:51AVSNote Added: 0007760
2019-02-24 13:19NullkillerNote Added: 0007761
2019-02-24 13:26AVSNote Added: 0007762
2019-02-24 13:38NullkillerNote Edited: 0007761bug_revision_view_page.php?bugnote_id=7761#r3565
2019-02-24 13:39NullkillerNote Added: 0007763
2019-02-24 13:49AVSNote Added: 0007764
2019-02-24 13:50NullkillerNote Added: 0007765
2019-02-24 15:42AVSNote Added: 0007766
2019-02-24 15:49mpechNote Added: 0007767
2019-02-24 16:43AVSNote Added: 0007768
2019-02-24 16:43AVSStatusassigned => resolved
2019-02-24 16:43AVSFixed in Version => 0.next
2019-02-24 16:43AVSResolutionopen => fixed

Notes
(0007756)
AVS   
2019-02-23 14:10   
The question is: is the town actually there?
(0007757)
mpech   
2019-02-23 16:59   
not sure if question was adressed to me, but in doubt I attached the map and it seems that the town does exist ("necropolis")
(0007758)
AVS   
2019-02-23 17:14   
Re-uploaded map without excess zipping.
(0007759)
AVS   
2019-02-23 17:35   
Actually there is additional bug in error handling, town is there but already occupied, I`ll fix it first.
(0007760)
AVS   
2019-02-23 18:51   
Now it correctly reports "Can't teleport to occupied town". The bug itself to be fixed still.
(0007761)
Nullkiller   
2019-02-24 13:19   
(edited on: 2019-02-24 13:38)
I expect that TSubgoal AdventureSpellCast::whatToDoToAchieve() should be altered to check if the town is free in order to fix it. I need a complete list of mods in order to be able to run it from the save file.

Probably this should work but without either client log file or list of mods I can nor launch the save neither guess more or less precisely where the bug is.

    if(spellID == SpellID::TOWN_PORTAL && town && town->visitingHero)
        throw cannotFulfillGoalException("The town is already occupied by " + town->visitingHero->name);

(0007762)
AVS   
2019-02-24 13:26   
@Nullkiller save contains all mods data inside, except graphics assets. In most cases it loads OK, at least it works for me (but I have a few mods installed). In general yes, mods should be listed in bug report.
(0007763)
Nullkiller   
2019-02-24 13:39   
@AVS disaster happened. Mod not found preserve.
(0007764)
AVS   
2019-02-24 13:49   
I have that, also HotA and Retreat are used in that save too.
Links to all these mods are in wiki
https://wiki.vcmi.eu/Mod_list [^]
(0007765)
Nullkiller   
2019-02-24 13:50   
@AVS, downloaded preserve and no it works
(0007766)
AVS   
2019-02-24 15:42   
I`ll check quick fix add push if it helps, proper fix should be added probably somewhere in AINodeStorage::calculateTownPortalTeleportations
(0007767)
mpech   
2019-02-24 15:49   
apologies for not having specified used mods, I will in the future...
mods used are
witchking artifacts
hota
Death valley
Preserve Town
Retreat
(0007768)
AVS   
2019-02-24 16:43   
Fix for infinite loop commited in https://github.com/vcmi/vcmi/commit/f36a86412e2dfc76af8dd16dc71bb9c29bb10885 [^]

https://github.com/vcmi/vcmi/pull/553 [^] to bring more robust fix for the problem but it is out of scope of this ticket.