Setting resources via LUA API broken in Editor
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
widelands |
Fix Released
|
Medium
|
TiborB |
Bug Description
When setting resources on new map with field.resource='x' and field.resource_
The resource is set, when playing a geologist can identify it properly (I have resource like coal in mind now), but a newly built mine reports "no resources left".
When looking on the field with DBG, resource type is properly set, but resource amount is shown like 10/0. I noticed when looking at other maps, that second number is usually non-zero.
Similar problem I noticed with fishes.
To reproduce the error, you need debug compilation of widelands. I enclosed a lua script test_resources.lua, it should be placed in share/widelands
use("aux"
and now place one headquarters (required to be able to play the game), save, start new single player game and test it. Build a mine f.e. on created fields and see that it doesnt work.
Regards
Related branches
- SirVer: Approve
-
Diff: 412 lines (+73/-41)17 files modifiedsrc/editor/map_generator.cc (+1/-1)
src/editor/tools/editor_decrease_resources_tool.cc (+2/-2)
src/editor/tools/editor_increase_resources_tool.cc (+2/-2)
src/editor/tools/editor_set_resources_tool.cc (+4/-4)
src/logic/field.h (+4/-4)
src/logic/findnode.cc (+2/-2)
src/logic/map.cc (+2/-2)
src/logic/production_program.cc (+1/-1)
src/logic/worker.cc (+3/-3)
src/map_io/map_resources_packet.cc (+2/-2)
src/map_io/s2map.cc (+1/-1)
src/scripting/lua_map.cc (+18/-1)
src/scripting/lua_map.h (+1/-0)
src/wui/game_debug_ui.cc (+2/-2)
test/maps/lua_testsuite.wmf/scripting/cfield.lua (+7/-8)
test/maps/lua_testsuite.wmf/scripting/efield.lua (+12/-4)
test/maps/lua_testsuite.wmf/scripting/gfield.lua (+9/-2)
tags: | added: lua |
Changed in widelands: | |
assignee: | nobody → TiborB (tiborb95) |
Changed in widelands: | |
status: | Fix Committed → Fix Released |
Quick grabbing through the source code shows that Field.* _starting_ res_amount( ) is never called in src/scripting/ . The implications of using this during the game are not clear to me and must be tested carefully, but in the editor, a call to set_resources() should definitively also change the starting resources.