wesnoth / wesnoth

An open source, turn-based strategy game with a high fantasy theme.
https://www.wesnoth.org/
GNU General Public License v2.0
5.52k stars 1.02k forks source link

World Conquest fails to start #9190

Closed soliton- closed 1 month ago

soliton- commented 2 months ago

Game and System Information

Description of the bug

Setting mode to 1399x943 Checking lua scripts... ok test_nplayers nil ...s/World_Conquest/lua/map/scenario_utils/bonus_points.lua:389: bad argument #-1 to 'filter' (string expected, got nil) stack traceback:

[C]: in field 'filter' ...s/World_Conquest/lua/map/scenario_utils/bonus_points.lua:389: in function '.world_conquest_tek_bonus_points' ...aigns/World_Conquest/lua/map/postgeneration/1A_Start.lua:150: in local 'fun' campaigns/World_Conquest/lua/map/wct_map_generator.lua:56: in upvalue 'run_postgeneration' campaigns/World_Conquest/lua/map/wct_map_generator.lua:73: in local 'mapgen_func' campaigns/World_Conquest/lua/map/main.lua:122: in function '.wc_ii_generate_scenario' (...tail calls...) [C]: in function '.xpcall' [string "..."]:8: in main chunk nil 20240810 20:28:14 error mapgen: Error when running lua_map_generator create_scenario. The generator was: World Conquest 1p bad return value: expected a config (table), found a nil 20240810 20:28:14 error general: Map generator error: Error when running lua_map_generator create_scenario. The generator was: World Conquest 1p bad return value: expected a config (table), found a nil

Steps to reproduce the behavior

Select Multiplayer -> Local Game -> Multiplayer Campaigns -> World Conquest

Expected behavior

World Conquest starts without error.

Additional context

No response

CelticMinstrel commented 2 months ago

Sounds like it's probably related to #8366

gfgtdf commented 2 months ago

The referenced line is https://github.com/wesnoth/wesnoth/blob/31658e2587d1a0ba230d2dcf562c5369ffb5b045/data/campaigns/World_Conquest/lua/map/scenario_utils/bonus_points.lua#L389

it creates a filter that uses f.find_in()

gfgtdf commented 2 months ago

This line

https://github.com/wesnoth/wesnoth/blob/31658e2587d1a0ba230d2dcf562c5369ffb5b045/src/scripting/lua_terrainfilter.cpp#L481

also pushes nil on the lua stack, when its only supposed to check in that case.

gfgtdf commented 2 months ago

I'm curious where the [string "..."]:8: in function <[string "..."]:8> in the stacktrace comes from, does anyone know ?

CelticMinstrel commented 2 months ago

Could it be referring to here?

https://github.com/wesnoth/wesnoth/blob/423481d4812a52f1882e4a5ab17e528fc81adc08/data/campaigns/World_Conquest/scenarios/WC_II_scenario.cfg#L210

gfgtdf commented 2 months ago

Quite likely, but then why is its twice in the stack, once at the top and once at the bottom?

CelticMinstrel commented 2 months ago

This line [...] also pushes nil on the lua stack, when its only supposed to check in that case.

So could the fix be to add a pop here?

https://github.com/wesnoth/wesnoth/blob/31658e2587d1a0ba230d2dcf562c5369ffb5b045/src/scripting/lua_terrainfilter.cpp#L484

Quite likely, but then why is its twice in the stack, once at the top and once at the bottom?

That… I can't explain…

gfgtdf commented 2 months ago

So could the fix be to add a pop here?

That could work, changing the -1 to a -2 in that line might also work.

Wedge009 commented 2 months ago

(Modified is a lie, it's added because of untracked files for some reason)

Not necessarily a lie - try making sure the sub-modules are up-to-date as well.

Wedge009 commented 2 months ago

Sounds like it's probably related to #8366

Confirmed it's 19f3682bdf0962af0a5afdb1a53ab9d49b345b9c (1.19.2) that causes this.

Pentarctagon commented 1 month ago

@CelticMinstrel can you look into fixing this then?

CelticMinstrel commented 1 month ago

Probably, unless @gfgtdf wants to do it?

soliton- commented 1 month ago

Would be good to get this fixed or revert 19f3682 for 1.19.4.

gfgtdf commented 1 month ago

Do we have a plan on when 1.19.4 happens?

gfgtdf commented 1 month ago

Anyways I committed the suggested change via my phone, so it's not really tested, I don't really have doubts that my change fixes a bug in the code, but still it would be nice if someone could verify whether it actually fixes the given case in this report.

Wedge009 commented 1 month ago

I'm not sure what that change is supposed to do but at 3af690331a5, I can start a 1-player WC game without apparent issue.

gfgtdf commented 1 month ago

Very good, thank you