Assertion "dataSize == 256" failed

I tried to build and run with the latest commit on “develop” branch. When running vcmiclient directly on my Ubuntu 14.04 (64-bit) machine, wired thing happened:

CObjectClassesHandler.cpp:119 : virtual std::vector CObjectClassesHandler::loadLegacyData(size_t): Assertion “dataSize == 256” failed.

So I attached gdb to this and printed out the dataSize when it failed. The dataSize was 0. I then read the code:

CLegacyConfigParser parser(“Data/Objects.txt”);

size_t totalNumber = parser.readNumber(); // first line contains number of objects to read and nothing else
parser.endLine();

for (size_t i=0; i<totalNumber; i++)
{
    ObjectTemplate templ;
    templ.readTxt(parser);
    parser.endLine();
    std::pair<si32, si32> key(templ.id.num, templ.subid);
    legacyTemplates.insert(std::make_pair(key, templ));
}

std::vector<JsonNode> ret(dataSize);// create storage for 256 objects
assert(dataSize == 256);

I’m sure I have installed data from Heroes3 correctly. Anybody can help? Thank you!

Are you running GOG version of H3 data? Some localization?

Exactly, I’m running with the data from GOG. Seems like you’ve known the answer already :slight_smile:

I’m not sure what localization means here though…

After looking into it for a while, it’s when the

handlers.insert(std::make_pair(“objects”, ContentTypeHandler(VLC->objtypeh, “object”)));

was called that failed the assertion.

Can you please get full backtrace from GDB?

And yeah while I not sure if everything valid with your assets and config location, but can you try to built older version of code? Better one from end of 2015 since after that we merged some filesystem refactoring changes.

I just switched to 16.04 and can’t even check how it’s works on 14.04.

PS: And if older version of code works then git bisect will help to find what’s break it.

Thanks for the help SSX. I’ll post the gdb statck trace. I just rolled back all the way to the commit that is just before the loadLegacyData function was checked in. But when I tried to build, I got these errors:

make[2]: *** No rule to make target ../include/vstd/CLoggerBase.h', needed bylib/cotire/vcmi_CXX_prefix.hxx.gch’. Stop.
make[2]: *** Waiting for unfinished jobs…

And this was the error I got when I switch back to the master branch. I’m not that familiar with CMake and couldn’t figure out the cause after a while. Could you tell me the cause and how to fix it? Thanks a lot.

Sorry. Wish to answer yesterday, but had unexpected networking loss.
All you need is just do “make clean” or run CMake again so it’s make new PCH.

Yeah, thanks SXX. I figured it out myself. I spent a lot of time yesterday building a real “executable” vcmiclient, but without luck. I’ve tried multiple versions such as 0.95, 0.93, 0.92, 0.91… all the way back to 0.90 until some outdated boost functions couldn’t be found. Non of them worked for me.

Then I found the old vcmi repository on my laptop which was pulled from SVN in the past. I compiled the version 0.95, it worked fine and I spent some time playing with it.

In sum, none of the versions from Github worked for me. The code from SVN worked well. I believe SVN used to be the old repository for VCMI of Linux? Could you tell me how did you configured your Ubuntu to work with the latest development code on Github? Thanks!

You shouldn’t really spend so much time on building it.
I just meant is that might be broken just in few last months.

All you need to make is working is make sure that you built with valid prefix:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_LAUNCHER=1

Also all files is in “~/.local/share/vcmi/Data” directory:

H3ab_ahd.snd  H3ab_ahd.vid  H3ab_bmp.lod  H3ab_spr.lod  H3bitmap.lod  H3sprite.lod  Heroes3.snd  VIDEO.VID

Contents of “Mods” directory from repository must be in:

/usr/share/vcmi/Mods/

And “config” content should be in:

/usr/share/vcmi/config

I’ll re-test it with Ubuntu 14.04 livecd and hopefully find out what’s wrong.

So I successfully built and run it on live VM under Ubuntu 14.04.5.
All works fine with assets I use which is weird.

I also tried to install assets from GOG using vcmibuilder:

vcmibuilder --gog setup_homm3_complete_2.0.0.16.exe

Again that worked just fine.

Thanks a lot SXX. Sorry for my late response. I’ve sucessfully built it and got it run. I did get several issues though, including linking problem, rmg exception, libgl issue, which seems not smoothly. I guess the main reason is I had some legacy library installed and some link file linked to incorrect places.

The libgl error is mainly because I ssh to my ubuntu laptop and typed

vcmiclient

run command on my mac terminal. Somehow the X11-server can’t be run correctly on my Mac (it worked for the build on SVN trunk (0.95)). But it’s not the concern here.

Anyway, it builds and runs successfully. Thanks a lot for you help. BTW, when I was reading at the code, I’m wondering what exactly is the CStack? What is the main purpose of maintaining such a data structure? Is it used to represent the creatures queue in the battle?

Actually VCMI can now run natively on MacOS just fine since @vmarkovtsev fixed all related problems.

What exactly you mean as “used to”? It’s actually does.

There are situations in H3 where stacks in battle isn’t same thing as CArmedInstance army since there at least special merging rules when someone attack town with visiting hero in it and armies has to be merged (this is not implemented in VCMI just yet, but it’s critical for gameplay).

Also there is tons of different option you may note CStack have that simply not used outside of battle. Another thing is that’s handy for CStack to be separate bonus node since that way it’s easier to make sure all battle-wide bonuses only are only remain in battle.

PS: Also if you wish to contribute feel free to jump on IRC #vcmi at freenode.net
We also setup Slack yesterday, but there no invite page for it yet.
So you can ask any questions there if you want to work on something and need operative answers.

UPD: Just in case: army merging does implemented :slight_smile:

Hi SXX, thanks for the info. I’ll try my first pull request later today. Could you tell me when will this event happen? Is there a link to the events on freenode and slack?

Sent PM to me or Dydzio: we’ll give you invite on slack. Everyone allowed to give invites to anyone since it’s not anything private.

UPD: Forgot to say. If someone want access to slack then please PM your email since for now it’s only way to do that. Later on we’ll have page that will sent invites automatically.