Add-on and game crashes when terrain has more than 4 digits

Having trouble with the game? Report issues and get help here. Read this first!

Moderator: Forum Moderators

Forum rules
Before reporting issues in this section, you must read the following topic:
Post Reply
User avatar
Heindal
Posts: 1360
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Add-on and game crashes when terrain has more than 4 digits

Post by Heindal »

Hey guys,

I don't need support, but wanted to bring an odd behavior of the game to your attention. So far just 4 digits are allowed when creating a new terrain overlay. If a terrain overlay inside of an add-on has more the than 4 digits, e.g. ^GUS10, and you try to start the add-on the game will crash / close at once with any further notice. The log however will contain the error about the terrain. That's how I could find and fix it.


Regards

Heindal
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Soliton
Site Administrator
Posts: 1688
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Re: Add-on and game crashes when terrain has more than 4 digits

Post by Soliton »

Can you provide detailed reproduction steps? I cannot get the game to crash with a map with a terrain with more than 4 characters or when defining a terrain type with more than 4 characters. (Both of those cases show an error in the GUI for me.)
"If gameplay requires it, they can be made to live on Venus." -- scott
User avatar
Spannerbag
Posts: 538
Joined: December 18th, 2016, 6:14 pm
Location: Yes

Re: Add-on and game crashes when terrain has more than 4 digits

Post by Spannerbag »

Soliton wrote: April 16th, 2024, 8:22 am Can you provide detailed reproduction steps? I cannot get the game to crash with a map with a terrain with more than 4 characters or when defining a terrain type with more than 4 characters. (Both of those cases show an error in the GUI for me.)
Bit hazy here as it was ages ago but I had a similar issue with 1.16 (and maybe 1.14) when trying to use overlays on maps.

In AferEi I used the following code and it worked fine:

Code: Select all

    [terrain_mask]
      x,y=1,1
      border=yes
      mask=$mask_to_apply
      [rule]			# I'm too lazy to edit maps into masks so use snow as "-f" :-)
        new=Aa
        use_old=yes
      [/rule]
    [/terrain_mask]
However there I did not use custom terrain.

In Leafsea Burning I tried to use the same mechanism but could not get it to work because the game complained about custom terrain.
I did try to reduce the number of characters in the custom terrain to below 5 but still couldn't get the thing to work so ended up with one scenario with 8 (!) separate maps that are repeatedly replaced... but it works.

This was all a long time ago when I wasn't as familiar with campaign development so when I found a way that worked I ran with that.

I would then have been using Windows 7 (now 11) and haven't investigated on v1.18 or Windows 11 so this is all old info, but it might help?

So I think the core issue might be that [terrain_mask] and custom terrain together don't play nicely?
Also, I have vague memories of someone saying that the issue was maybe due to the minimap not knowing how to render custom terrain - tho' that might be a red herring...

If I get the time I'll try to reproduce the issue on 1.18 but sadly right now I can't do that, hence this post.

Hope these ramblings help somehow...

Cheers!
-- Spannerbag
SP Campaigns: After EI (v1.14) Leafsea Burning (v1.17, v1.16)
I suspect the universe is simpler than we think and stranger than we can know.
Also, I fear that beyond a certain point more intelligence does not necessarily benefit a species...
User avatar
Heindal
Posts: 1360
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Add-on and game crashes when terrain has more than 4 digits

Post by Heindal »

Hi Soliton,
Hi Spannerbag,

first of all you need a terrain folder and which contains Terrain.cfg and a Terrain_Graphics.cfg.

Inside the Terrain.cfg you define the types, so that they can be added via the editor and in which group.
This one caused the problem:

[terrain_type]
symbol_image=servedguest10
id=servedguest10
name= _ "Guest Served"
string=^GUS10
aliasof=_bas, Gg
mvt_alias=-,_bas,Gg
gives_income=false
editor_group=Trader
[/terrain_type]

Inside the Terrain_Graphics.cfg you define what the terrain is, in that case an overlay:

{OVERLAY *^GUS10 servedguest10}

Loading a scenario with that overlay crashes the game at once, even so it isn't used inside a map. Hope that was helpful, when I have more time I can provide you with an scenario, but for now I have to make a test run for the innkeeper upgrade of my add-on.

I'm using Windows 10, just in case.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Soliton
Site Administrator
Posts: 1688
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Re: Add-on and game crashes when terrain has more than 4 digits

Post by Soliton »

After tracking down a couple deprecated terrain graphics files to include I'm back to getting a GUI error for a terrain with more than 4 characters.

Please provide a complete test case.
"If gameplay requires it, they can be made to live on Venus." -- scott
User avatar
Heindal
Posts: 1360
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Add-on and game crashes when terrain has more than 4 digits

Post by Heindal »

Made an add-on for you: Soliton_Bugcampaign. Just download and start it.
It is based on A Simple Campaign, which is unfortunately not on the servers yet -,-.
Had to use an older version.

Have fun.

As I said, inside the terrain folder, check the file:
terrain-definitions.cfg

There you go:

[terrain_type]
# symbol_image is the image shown in the editor's tile palette.
# This image is looked for in the terrain/ subdirectory of the images/ subdirectories specified by all active [binary_paths]. These are data/core/ (always active) and data/add-ons/A_Simple_Campaign/ for this campaign.
# ".." however tells to step one directory up (from terrain/ into images/) (and then into images/scenery).
symbol_image="../scenery/gate-rusty-sw"
id=Tomanydigits
name=_ "To many digits"
string=^TOMANY
aliasof=Xt
editor_group=sc
[/terrain_type]


if you change the string to ^TOMA the campaign should work. Interesting:, I didn't even defined it inside the terrain.cfg, but it still breaks the game.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
Heindal
Posts: 1360
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Add-on and game crashes when terrain has more than 4 digits

Post by Heindal »

It even corrupts the map editor. I can not load the map editor any more, while this corrupted campaign is inside my add-on folder.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
User avatar
Heindal
Posts: 1360
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Add-on and game crashes when terrain has more than 4 digits

Post by Heindal »

Meh, as I don't see anything, as the game crashes, I made a mistake while making this campaign. I made a reference to a map in another add-on, you don't have. Gnarf. It is fixed now and the other bugs are fixed now as well. The current version is 0.4.

As some people already downloaded this campaign (which crashes the game and blocks the editor), I decided to deactivate the too long overlay.
You have to change it manually.

Note that the bug is caused by a to longer overlay inside the terrain definition AND the EDITOR for terrain needs to be defined inside the main.cfg.
This is already done in the uploaded campaign.


My fear is:

By adding such a long overlay, it might expand over a defined limit for terrain.

E.g. if the limit is 8 digits for terrain (three digits for base ^ four digits for overlay). You would get over this limit, if this is defined in C or C#, this can have some of the consequences I see. I would even say that this is a critical bug, as I could upload an add-on that could potentially crash the game.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Soliton
Site Administrator
Posts: 1688
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Re: Add-on and game crashes when terrain has more than 4 digits

Post by Soliton »

Ok, the trick is that you put the terrain behind the scenario define. I can reproduce it now. Same error but it's caught too late.
"If gameplay requires it, they can be made to live on Venus." -- scott
Post Reply