Trunk discussion / complains

Some feature request:

  • I’ve messed with Town Hall background (on which town hall icons are placed).
    And It only allows 8-bit graphics.
    Is it possible to add 24bit/32bit support of PNG/BMPs?
    I tried to place hall icons on some fantasy picture (saved result as 8bit), and colours were broken while in game.
    It will be cool to use some graphics, not default brown background same for all standard towns.

Does anyone have the time to update the build VCMI wiki with the latest qt changes?

I am going to redo the whole page after Visual 2013 is out.
I’m considering publishing the Boost/Qt binaries and putting together some script to automate the whole setup procedure, it’s becoming to troublesome.

As for now, setting the QtDir macro in the property sheet should be enough to get launcher building.

VCMI client crashes when you click on the highscore, campaign, etc. button. The error log shows something like “bad function call”. After further investigation I found out where the error comes from.

To the constructor of the mentioned buttons a empty function object of type std::function<void()>() will be passed. The function object is wrapped by a CFunctionList instance. The CFunctionList internally uses boost::function, whereas the boost::function will be initialized by a empty std::function object. The bool conversion operator of boost::function simply checks if the object is initalized by something. The bool conversion operator is used to check if the function object contains something and can be called. The problem is that the check fails if the boost::function object is initialized by an empty std::function object. The boost::function operator() invokes the std::function operator() which causes the bad function call exception.

Let’s look at this example:

std::function<void()> foo;
if (!foo) std::cout << "foo is empty" << std::endl;

auto baz = boost::function<void()>(foo);
if (!baz) std::cout << "baz is empty" << std::endl;

Console output:

foo is empty

Is it possible to change boost::function to std::function in the CFunctionList class? Initializing std::function with std::function in the CFunctionList template constructor invokes the copy constructor which is OK and would print the following console message when changing the previous example:

foo is empty
baz is empty

I don’t know if there are any potential problems which may arise, that’s why I’m asking. Are there any reasons to stay on boost::function? The code uses boost::bind a lot which can be converted implicitely to std::function. Boost::bind always returns a initialized boost::function object and there are no not initialized boost::function objects somewhere else in the code, so this should be OK. By the way, can we move to std::bind now?

Besides fixing that bug if the solution is approriate I would like to add a informational dialog box showing a message like “Sorry, this feature is not implemented!” when clicking on the highscore button, etc.

I replaced function/bind with std equivalents as part of C++03 -> C++11 switch but then Tow reverted this due to compile issues with Visual Studio.
Don’t know if this problem is still present in VS 2013

Good idea, will do.

UPD: Almost forgot - right now I’m considering implementing some basic unicode support. Will explain in detail once it will reach more-less finished state.

Any objections if I’ll start using boost-locale library? This is relatively new library so it will require at least boost 1.48.

First of all I totally want to appreciate your stunning progress on this classic but epic game.
The bug I’d like to mention is already known, a failed function call when accessing the highscores. Is there any fix yet, otherwise it’s kind of unsatisfying to see your game crashing after completing a chapter or a single game. Sadly I have not enough experience with VS to try it on myself. By the way greetings from germany.

Which battle AI is the better and more stable one, BattleAI or StupidAI? StupidAI is the default setting, so what’s the current state of the BattleAI?

BattleAI is definitlely smarter (not brainless), not sure about stability, though. I didn’t have much issues with either AI, all the problems came from engine itself.

What did I miss?

It looks that I again forgot about DLL_LINKAGE :frowning:
File lib/CGeneralTextHandler.h - functions in Unicode namespace don’t have this define.
Will commit fix soon.

BattleAI is meant to fully replace StupidAI as a default AI. It has no stability issues I know of.

Can’t launch game at all, even with all additional mods disabled. launcher reads:

File <unknown> is not a valid JSON file!
At line 1, position 0 error: Not a valid UTF-8 file

While client crashes with following message

This is warning that will fire if any json files contain non-unicode characters (like Polish). Should not cause any crashes but may result in broken text rendering.

Try removing config/modSettings.json file - I have changed its format to allow storing some extra data like checksum. VCMI should have updated its format without crash - will check this.

I implemented the output stream operator<< for various classes (BattleAction, BattleHex,…) to enable better logging and debugging.

That’s the new log message when the client sends a package during battle (holds BattleAction):

Send battle action to server: [BattleAction: side '0', stackNumber '1', actionType 'Walk and attack', destinationTile '[BattleHex: x '7', y '1', hex '24']', additionalInfo '7', selectedStack '-1']

That’s the old generic log message which will be logged when sending a package (of any type):

Sending a request "10MakeAction". It'll have an ID=19.

The generic log message is hard to read. If you want to implement further operator<<, then try to use the format I used. operator<< for polymorphic types is difficulter to implement, but possible. One can define a operator<< for the super type and call a protected abstract method toString for example which subclasses override.

I will add how to write output stream operators to our coding guidelines.

I wonder if it would be possible that an IDE use the operator<< for displaying contents of variables while debugging. Perhaps it would be possible with a plugin or an extension. The plugin has to call an simple expression when showing the content of a variable. Especially for enumerations like BattleAction.actionType this is useful

std::stringstream ss;
ss << variable;
ss.str();

In fact, after deleting modSettings.json, launcher crashes immediatelly. File was created at game launch, though it’s empty.

But no crash this time I hope? I do have launcher crash but client should work OK with empty/non-existing modSettings.json

I think I fixed all these bugs. VCMI (both client and launcher) should start with or without modSettings.json, and should work with 0.94 format.

I figured out some bug was caused by the old version of True Type fonts. It changed when I updated the mod from repo, though can’t roll changes back.

modSettings file is now generated correctly, though I have some problems with decompression.

Exception is thrown in function
CCompressedStream::readMore(ui8 *data, si64 size)
VCMI_Client_log.txt (12.4 KB)

According to log VCMI crashes during checksum calculation for “wog rus” mod. Works for me. Can you try disabling this mod to make sure that this is where crash comes from?

  • I’ve improved a bit error reporting here - can you re-test vcmi with latest revision?
  • Can you check what file causes crash? If this happens in checksum calculation then you can access filename in calculateModChecksum() function.

It helped when I uninstalled WoG rus mod altogether, though the journey doesn’t end here yet :wink:

EDIT: Fail in this line - unsupported charset

		CLegacyConfigParser parser("DATA/GENRLTXT.TXT");
		parser.endLine();
		do
		{
			allTexts.push_back(parser.readString());
		}
		while (parser.endLine());

However, as far as I know I use English GENERALTXT.txt file.