homm3tools icon indicating copy to clipboard operation
homm3tools copied to clipboard

[h3mlib] maps created are playable but show "Map is not playable" in Heroes 3's main menu

Open radekmie opened this issue 7 years ago • 6 comments

Separated from #31.

It must be something with the player settings - my map have (in the game) selected Castle mixed with random (random can be changed to Conflux only) and after saving it from the editor it has correct castles (these are taken from map somehow). I'm building a RoE map and currently h3m_player_enable is the only player-related code I'm using.

It happens with the hello world example too.

radekmie avatar Jun 11 '17 20:06 radekmie

Which objects are you adding to the map? I played around a little bit, expecting that adding heroes by name with h3m_add_object() would be a bit buggy because h3m_add_object() right now simply always adds the uncustomized version of objects (which is usually mostly fine, but for Heroes specifically it does not make much sense as it's not enough to actually place the correct hero) and it seems even buggier than I expected producing a bunch of strange results with the heroes sometimes not appearing on the map, wrong hero sprite (I expected hero type to be wrong since it's not being set but sprite I was expecting to be correct). Perhaps it simply becomes really buggy when you place more than one hero since I guess they will get the same hero type.

h3m_add_object() can be improved on the inside to not just set the default object details for the hero object. The expected result if I do for example h3m_object_add(h3m, "Orrin", 5, 5, 0, &od_index); is that I get a hero with the correct sprite in map editor and in-game with the correct hero type & portrait (portrait can be left to default) set to Orrin which is how it should work respectively for all heroes.

As for a minimal map example that currently works, here is one that should (empty dirt map with one town for Red and one for Blue): https://gist.github.com/potmdehex/cb58c27a477ebb3d34cbf7dca4f3e057

Could you post the code you are having issues with? Not impossible that there's another issue than the hero stuff I mention above.

potmdehex avatar Jun 12 '17 18:06 potmdehex

Here's a minimal example which cause the game crash (sometimes):

h3mlib_ctx_t h3m = NULL;
h3m_init_min(&h3m, H3M_FORMAT_ROE, H3M_SIZE_SMALL);
h3m_desc_set(h3m, "Test Desc");
h3m_name_set(h3m, "Test Name");
h3m_player_enable(h3m, 0);
h3m_player_enable(h3m, 1);
h3m_terrain_fill(h3m, H3M_TERRAIN_GRASS);
int object1 = 0;
h3m_object_add(h3m, "Castle", 5, 5, 0, &object1);
h3m_object_set_owner(h3m, object1, 0);
int object2 = 0;
h3m_object_add(h3m, "Rampart", 10, 5, 0, &object2);
h3m_object_set_owner(h3m, object2, 1);
h3m_write(h3m, "test.h3m");
h3m_exit(&h3m);

(quite similar)

I've checked it in the editor: "There are no problems with the map.". I've checked it in the game: "This map is not playable. Please load it...".

Your map have the same issue.

I'll try to isolate the error but it is quite time consuming. All I know is that it happens, when computer turn begins - it crashed on start only once or twice.


I know about that (bug?) with heroes, so I've implemented my own add hero function, which assigns correct sprite for each hero so it's not the case.

radekmie avatar Jun 13 '17 06:06 radekmie

Both your code and mine produces maps that I can run without crashing (didn't get any crash going through a few turns many times on each) in Heroes 3 Complete as well as HD Mod and HD Edition. Which version of the game are you using?

However something is indeed amiss with the current version of h3mlib, because the "This map is not playable. ..." desciption shows up on the menu in place of the real description and the bugged player settings with Random and Conflux are there. Seems to be the case regardless of which format the map is initialized to.

potmdehex avatar Jun 13 '17 12:06 potmdehex

Im using the GoG one and it's crashing only sometimes. I'll post here something more precise as soon as I'll get it. Meanwhile it's worth mentioning, that after saving this map in editor, player settings are less weird - in general taken from the only town.

radekmie avatar Jun 13 '17 20:06 radekmie

It turned out, that setting h3m.bi.any.has_hero to 1 solved this issue with not playable... message. Some maps are still crashing the game but I cannot isolate the reason.

radekmie avatar Jun 20 '17 14:06 radekmie

Sounds like a good find regarding h3m.bi.any.has_hero. We can keep the issue open for now as it's unexpected behavior when using those minimal PoCs that the "not playable" text appears even when they are playable (for one thing it replaces the real description). It should be set internally in a suitable place to the value the game expects.

Can you make another issue for the maps crashing the game where you attach/link the crashy maps? I'm used to debugging crashes in closed source software and Heroes 3 in particular so can have a look when I have time to prioritize it.

potmdehex avatar Jun 20 '17 15:06 potmdehex