MantisBT - VCMI
View Issue Details
0001229VCMIModspublic2013-03-04 17:362014-05-30 17:43
Warmonger 
Ivan 
highcrashrandom
closedfixed 
0.92 
0.930.93 
0001229: Random artifacts are not indexed properly
Artifacts added as last ones (probably after artifact 256) are not indexed properly on adventure map. Sometimes they do work, but sometimes they show different index upon picking, sometimes game crashes when they are picked.

Additionally, sometimes different artifacts appear twice on "Testy Arts 4" map, even though they should not as they are drawn without replacement (0000119). Game also crashes when these are picked.
Install Withcking Arts and this mod
https://www.dropbox.com/s/7z3ps1jjb3lojp8/H4arts.rar?m [^]

There should be about 259 artifacts in total. Try to pick Crusader's Mace http://www.heroesofmightandmagic.com/heroes4/images/artifacts/minor_weapons.gif [^] or Logbook of The Master Sailor http://www.heroesofmightandmagic.com/heroes4/images/artifacts/minor_texts.gif [^] to get crash (random).
Two mentioned artifacts arethe very last in the list of
VCMI\Mods\H4 arts - hero\mod.json

Which is probably also last processed (alphabetically) file with artifacts.
No tags attached.
jpg 2013-05-31_HelmBoots092c.jpg (28,825) 2013-05-31 06:28
https://bugs.vcmi.eu/file_download.php?file_id=1297&type=bug
jpg
Issue History
2013-03-04 17:36WarmongerNew Issue
2013-03-04 17:40WarmongerNote Added: 0003430
2013-03-04 18:15IvanNote Added: 0003431
2013-03-04 18:19IvanNote Edited: 0003431bug_revision_view_page.php?bugnote_id=3431#r2139
2013-03-04 18:37WarmongerNote Added: 0003432
2013-03-04 21:00AlexVinSNote Added: 0003434
2013-03-04 21:02AlexVinSNote Edited: 0003434bug_revision_view_page.php?bugnote_id=3434#r2141
2013-03-12 16:14IvanNote Added: 0003441
2013-03-12 19:41WarmongerNote Added: 0003442
2013-03-12 19:45WarmongerNote Edited: 0003442bug_revision_view_page.php?bugnote_id=3442#r2153
2013-03-29 11:42WarmongerNote Added: 0003470
2013-03-29 13:38WarmongerNote Added: 0003471
2013-03-29 13:40WarmongerNote Edited: 0003471bug_revision_view_page.php?bugnote_id=3471#r2159
2013-03-29 13:46WarmongerNote Edited: 0003471bug_revision_view_page.php?bugnote_id=3471#r2160
2013-03-29 16:35WarmongerSummaryArtifacts over 256 are not indexed properly => Random artifacts are not indexed properly
2013-03-29 18:59IvanNote Added: 0003474
2013-03-29 19:11IvanNote Edited: 0003474bug_revision_view_page.php?bugnote_id=3474#r2164
2013-03-29 19:11IvanAssigned To => Ivan
2013-03-29 19:11IvanStatusnew => assigned
2013-03-29 19:17IvanNote Added: 0003476
2013-03-29 19:17IvanStatusassigned => resolved
2013-03-29 19:17IvanFixed in Version => 0.93
2013-03-29 19:17IvanResolutionopen => fixed
2013-05-31 06:28ZamolxisFile Added: 2013-05-31_HelmBoots092c.jpg
2013-05-31 06:30ZamolxisNote Added: 0003613
2013-05-31 06:30ZamolxisNote Edited: 0003613bug_revision_view_page.php?bugnote_id=3613#r2237
2013-05-31 11:26IvanNote Added: 0003615
2013-05-31 12:50IvanNote Edited: 0003615bug_revision_view_page.php?bugnote_id=3615#r2241
2014-05-30 17:43beegeeStatusresolved => closed

Notes
(0003430)
Warmonger   
2013-03-04 17:40   
I didn't find anything that would explain this bug in ArtifactID, adventure object subID or def list indexed by int.

It is possible, however, that this bug holds also for other types of objects, such as creatures.
(0003431)
Ivan   
2013-03-04 18:15   
(edited on: 2013-03-04 18:19)
I'm not sure that this is related to 256 - list in mod.json does not have anything to do with load order: artifacts in one mod are always loaded alphabetically and load order of mods is (somewhat) random - hashmap in filesystem.

Check log file to see real load order ("loaded artifact XXX" messages)

For example one of arts you mentioned have index < 200 and I still have the crash.

This one looks more like desync (likely during map initialization).

UPD: got exactly same crash even after disabling dosen of arts from one of mods. Not 256 problem.

(0003432)
Warmonger   
2013-03-04 18:37   
Strange, as I noticed issues just today and only with recently added artifacts.

Something could also be wrong with the mod itself, but I added lots of arts already with no problems :?
(0003434)
AlexVinS   
2013-03-04 21:00   
(edited on: 2013-03-04 21:02)
In witchkings mod "imglarge.json" is not emplty but its empty in H4 mod. May be an issue or it`s unused?

(0003441)
Ivan   
2013-03-12 16:14   
Mysteriously solved? No longer reproducible for me. At least not with rev. 3289, these 3 mods + testy 4 map
(0003442)
Warmonger   
2013-03-12 19:41   
(edited on: 2013-03-12 19:45)
Bug still persists.
One thing I noticed: it does not seem to happen in FIRST game you run after opening application, but does in next ones when you return to main menu.

(0003470)
Warmonger   
2013-03-29 11:42   
This part of code is suspicious:

        case Obj::ARTIFACT:
        case Obj::RANDOM_ART:
        case Obj::RANDOM_TREASURE_ART:
        case Obj::RANDOM_MINOR_ART:
        case Obj::RANDOM_MAJOR_ART:
        case Obj::RANDOM_RELIC_ART:
        case Obj::SPELL_SCROLL:
            {
                int artID = -1;
                int spellID = -1;
                CGArtifact * art = new CGArtifact();
                nobj = art;

                readMessageAndGuards(art->message, art);

                if(defInfo->id == Obj::SPELL_SCROLL)
                {
                    spellID = reader.readUInt32();
                    artID = 1;
                }
                else if(defInfo->id == Obj::ARTIFACT)
                {
                    //specific artifact
                    artID = defInfo->subid;
                }

                art->storedArtifact = createArtifact(artID, spellID);
                break;

If artifact is not set or is not a scroll, new artifact with ID = -1 is created. The code is not correct even if it should never trigger (which I assume). Will investigate this part.
(0003471)
Warmonger   
2013-03-29 13:38   
(edited on: 2013-03-29 13:46)
Debugging shows that real artifact stored in objects is different than what def shows. For example, both subtype of object and artifact ID are 55 (Vampire's Cowl), but adventure map def is Logbook of The Master Sailor (new art).

Game crashes when hero tries to equip artifatc in different slot than it should.
There must be some desync on game end / map reload, but I can't find anything.

(0003474)
Ivan   
2013-03-29 18:59   
(edited on: 2013-03-29 19:11)
Desync is in CArtHandler::getArtSync. That's well-chosen name :)

Don't know where it comes from exactly but it definitely here - parameter rand is same on both client and server but returned values are not.

Probably due to internal state (erasePicked flag) but can't say for sure - I'm not familiar with that code.

EDIT: found it

(0003476)
Ivan   
2013-03-29 19:17   
Should be fixed, rev 3298
(0003613)
Zamolxis   
2013-05-31 06:30   
@Ivan/Warmonger: is this the same with what I still see in 0.92c, namely all WoG artifacts showing wrong image when I pick them up? (see screenshot)

Very easy to reproduce by loading the VCMI_Tests_2012 map and check artifacts around Sir Mullich.

(0003615)
Ivan   
2013-05-31 11:26   
(edited on: 2013-05-31 12:50)
In future - it is better to either set this to "feedback" or open new report. I often have resolved/closed filtered out to see only unresolved reports.

On topic - unrelated but will check this out. I think I know where this one is coming from.

UPD: fixed.