Merge lp:~widelands-dev/widelands/market into lp:widelands

Proposed by SirVer
Status: Merged
Merged at revision: 8457
Proposed branch: lp:~widelands-dev/widelands/market
Merge into: lp:widelands
Diff against target: 1038 lines (+562/-64)
33 files modified
data/tribes/barbarians.lua (+3/-0)
data/tribes/buildings/markets/barbarians/market/helptexts.lua (+28/-0)
data/tribes/buildings/markets/barbarians/market/init.lua (+56/-0)
data/tribes/init.lua (+7/-0)
data/tribes/scripting/starting_conditions/barbarians/fortified_village.lua (+1/-0)
data/tribes/scripting/starting_conditions/barbarians/headquarters.lua (+1/-0)
data/tribes/scripting/starting_conditions/barbarians/trading_outpost.lua (+1/-0)
doc/sphinx/extract_rst.py (+2/-0)
regression_test.py (+1/-1)
src/logic/CMakeLists.txt (+2/-0)
src/logic/map_objects/map_object.cc (+2/-0)
src/logic/map_objects/map_object.h (+1/-0)
src/logic/map_objects/tribes/market.cc (+45/-0)
src/logic/map_objects/tribes/market.h (+51/-0)
src/logic/map_objects/tribes/productionsite.cc (+26/-23)
src/logic/map_objects/tribes/productionsite.h (+10/-1)
src/logic/map_objects/tribes/tribes.cc (+7/-0)
src/logic/map_objects/tribes/tribes.h (+4/-0)
src/scripting/lua_map.cc (+116/-26)
src/scripting/lua_map.h (+58/-0)
src/scripting/lua_root.cc (+31/-6)
src/scripting/lua_root.h (+7/-6)
src/website/map_object_info.cc (+3/-0)
src/wui/interactive_gamebase.cc (+1/-0)
test/maps/lua_testsuite.wmf/scripting/tribes_descriptions.lua (+1/-1)
test/maps/market_trading.wmf/elemental (+12/-0)
test/maps/market_trading.wmf/objective (+4/-0)
test/maps/market_trading.wmf/player_names (+16/-0)
test/maps/market_trading.wmf/player_position (+6/-0)
test/maps/market_trading.wmf/port_spaces (+7/-0)
test/maps/market_trading.wmf/scripting/init.lua (+28/-0)
test/maps/market_trading.wmf/scripting/test_market_can_be_build.lua (+13/-0)
test/maps/market_trading.wmf/version (+11/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/market
Reviewer Review Type Date Requested Status
kaputtnik (community) testing Approve
SirVer Needs Resubmitting
GunChleoc Needs Fixing
Review via email: mp+330830@code.launchpad.net

Commit message

Adds a new building type called 'Market' that will be the trading building for land-based trading. The building is only added to the barbarians and is is disabled in all barbarian scenarios and start conditions.

This merge request (MR) adds the (massive) boilerplate and a simple test that the new building can actually be build. I'd like to get this in before adding the logic, so future MRs are smaller.

The test is run with the regular regression test runs, but can be run standalone using:

./build/debug/src/widelands --datadir=data --datadir_for_testing=test --scenario=maps/market_trading.wmf --script=maps/market_trading.wmf/scripting/test_market_can_be_build.lua

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 2668. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/275899451.
Appveyor build 2489. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_market-2489.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Code LTGM, except for 1 nit that has to be fixed - there's a string that should not end up on Transifex.

Not tested yet.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I just started a multiplayer game with varying starting conditions on collectors and got 4 coroutine errors:

3x plr nil value
1x 'barbarians_market' was not understood as an argument

review: Needs Fixing
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 2674. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/276227148.
Appveyor build 2495. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_market-2495.

Revision history for this message
SirVer (sirver) wrote :

> I just started a multiplayer game with varying starting conditions on collectors and got 4 coroutine errors:

Should all be fixed now, please take another look.

review: Needs Resubmitting
Revision history for this message
kaputtnik (franku) wrote :

No errors anymore. Tested single player with three different tribes.

review: Approve (testing)
Revision history for this message
SirVer (sirver) wrote :

Fixed the nit that Gun asked for. Thanks for testing and code review!

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Error merging this proposal:

Output:
stdout:

stderr:
bzr: ERROR: Parameter "Merged lp:~widelands-dev/widelands/market:\nAdds a new building type called 'Market' that will be the trading building for land-based trading. The building is only added to the barbarians and is is disabled in all barbarian scenarios and start conditions.\n\nThis merge request (MR) adds the (massive) boilerplate and a simple test that the new building can actually be build. I'd like to get this in before adding the logic, so future MRs are smaller.\n\nThe test is run with the regular regression test runs, but can be run standalone using:\n\n./build/debug/src/widelands --datadir=data --datadir_for_testing=test \\\n\xc2\xa0\xc2\xa0\xc2\xa0--scenario=maps/market_trading.wmf \\\n\xc2\xa0\xc2\xa0\xc2\xa0--script=maps/market_trading.wmf/scripting/test_market_can_be_build.lua" encoding is unsupported by ascii application locale.

Revision history for this message
SirVer (sirver) wrote :

removed non-breaking space from commit message.

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Error merging this proposal:

Output:
stdout:

stderr:
+N data/tribes/buildings/markets/
+N data/tribes/buildings/markets/barbarians/
+N data/tribes/buildings/markets/barbarians/market/
+N data/tribes/buildings/markets/barbarians/market/build_00.png
+N data/tribes/buildings/markets/barbarians/market/helptexts.lua
+N data/tribes/buildings/markets/barbarians/market/idle_00.png
+N data/tribes/buildings/markets/barbarians/market/idle_00_pc.png
+N data/tribes/buildings/markets/barbarians/market/init.lua
+N data/tribes/buildings/markets/barbarians/market/menu.png
+N src/logic/map_objects/tribes/market.cc
+N src/logic/map_objects/tribes/market.h
+N test/maps/market_trading.wmf/
+N test/maps/market_trading.wmf/binary/
+N test/maps/market_trading.wmf/binary/heights
+N test/maps/market_trading.wmf/binary/mapobjects
+N test/maps/market_trading.wmf/binary/resource
+N test/maps/market_trading.wmf/binary/terrain
+N test/maps/market_trading.wmf/elemental
+N test/maps/market_trading.wmf/minimap.png
+N test/maps/market_trading.wmf/objective
+N test/maps/market_trading.wmf/player_names
+N test/maps/market_trading.wmf/player_position
+N test/maps/market_trading.wmf/port_spaces
+N test/maps/market_trading.wmf/scripting/
+N test/maps/market_trading.wmf/scripting/init.lua
+N test/maps/market_trading.wmf/scripting/test_market_can_be_build.lua
+N test/maps/market_trading.wmf/version
 M data/tribes/barbarians.lua
 M data/tribes/init.lua
 M data/tribes/scripting/starting_conditions/barbarians/fortified_village.lua
 M data/tribes/scripting/starting_conditions/barbarians/headquarters.lua
 M data/tribes/scripting/starting_conditions/barbarians/trading_outpost.lua
 M doc/sphinx/extract_rst.py
 M regression_test.py
 M src/logic/CMakeLists.txt
 M src/logic/map_objects/map_object.cc
 M src/logic/map_objects/map_object.h
 M src/logic/map_objects/tribes/productionsite.cc
 M src/logic/map_objects/tribes/productionsite.h
 M src/logic/map_objects/tribes/tribes.cc
 M src/logic/map_objects/tribes/tribes.h
 M src/scripting/lua_map.cc
 M src/scripting/lua_map.h
 M src/scripting/lua_root.cc
 M src/scripting/lua_root.h
 M src/website/map_object_info.cc
 M src/wui/interactive_gamebase.cc
 M test/maps/lua_testsuite.wmf/scripting/tribes_descriptions.lua
Conflict adding file src/logic/map_objects/tribes/market.cc. Moved existing file to src/logic/map_objects/tribes/market.cc.moved.
Conflict adding file test/maps/market_trading.wmf. Moved existing file to test/maps/market_trading.wmf.moved.
2 conflicts encountered.

Revision history for this message
SirVer (sirver) wrote :
Revision history for this message
GunChleoc (gunchleoc) wrote :

BTW I just noticed another error in a file name:

'test/maps/market_trading.wmf/scripting/test_market_can_be_build.lua' ->
'test/maps/market_trading.wmf/scripting/test_market_can_be_built.lua'

Yep, English is fun... feel free to fix this in a follow-up branch.

Revision history for this message
SirVer (sirver) wrote :

Will fix in the next branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/tribes/barbarians.lua'
--- data/tribes/barbarians.lua 2017-07-19 20:40:32 +0000
+++ data/tribes/barbarians.lua 2017-09-18 07:21:55 +0000
@@ -176,6 +176,9 @@
176 "barbarians_warehouse",176 "barbarians_warehouse",
177 "barbarians_port",177 "barbarians_port",
178178
179 -- Markets
180 "barbarians_market",
181
179 -- Small182 -- Small
180 "barbarians_quarry",183 "barbarians_quarry",
181 "barbarians_lumberjacks_hut",184 "barbarians_lumberjacks_hut",
182185
=== added directory 'data/tribes/buildings/markets'
=== added directory 'data/tribes/buildings/markets/barbarians'
=== added directory 'data/tribes/buildings/markets/barbarians/market'
=== added file 'data/tribes/buildings/markets/barbarians/market/build_00.png'
183Binary files data/tribes/buildings/markets/barbarians/market/build_00.png 1970-01-01 00:00:00 +0000 and data/tribes/buildings/markets/barbarians/market/build_00.png 2017-09-18 07:21:55 +0000 differ186Binary files data/tribes/buildings/markets/barbarians/market/build_00.png 1970-01-01 00:00:00 +0000 and data/tribes/buildings/markets/barbarians/market/build_00.png 2017-09-18 07:21:55 +0000 differ
=== added file 'data/tribes/buildings/markets/barbarians/market/helptexts.lua'
--- data/tribes/buildings/markets/barbarians/market/helptexts.lua 1970-01-01 00:00:00 +0000
+++ data/tribes/buildings/markets/barbarians/market/helptexts.lua 2017-09-18 07:21:55 +0000
@@ -0,0 +1,28 @@
1-- This include can be removed when all help texts have been defined.
2include "tribes/scripting/help/global_helptexts.lua"
3
4function building_helptext_lore()
5 -- TRANSLATORS#: Lore helptext for a building
6 return no_lore_text_yet()
7end
8
9function building_helptext_lore_author()
10 -- TRANSLATORS#: Lore author helptext for a building
11 return no_lore_author_text_yet()
12end
13
14function building_helptext_purpose()
15 -- TODO(sirver): Document market once its use stabilizes.
16 -- TRANSLATORS#: Purpose helptext for a building
17 return ""
18end
19
20function building_helptext_note()
21 -- TRANSLATORS#: Note helptext for a building
22 return ""
23end
24
25function building_helptext_performance()
26 -- TRANSLATORS#: Performance helptext for a building
27 return ""
28end
029
=== added file 'data/tribes/buildings/markets/barbarians/market/idle_00.png'
1Binary files data/tribes/buildings/markets/barbarians/market/idle_00.png 1970-01-01 00:00:00 +0000 and data/tribes/buildings/markets/barbarians/market/idle_00.png 2017-09-18 07:21:55 +0000 differ30Binary files data/tribes/buildings/markets/barbarians/market/idle_00.png 1970-01-01 00:00:00 +0000 and data/tribes/buildings/markets/barbarians/market/idle_00.png 2017-09-18 07:21:55 +0000 differ
=== added file 'data/tribes/buildings/markets/barbarians/market/idle_00_pc.png'
2Binary files data/tribes/buildings/markets/barbarians/market/idle_00_pc.png 1970-01-01 00:00:00 +0000 and data/tribes/buildings/markets/barbarians/market/idle_00_pc.png 2017-09-18 07:21:55 +0000 differ31Binary files data/tribes/buildings/markets/barbarians/market/idle_00_pc.png 1970-01-01 00:00:00 +0000 and data/tribes/buildings/markets/barbarians/market/idle_00_pc.png 2017-09-18 07:21:55 +0000 differ
=== added file 'data/tribes/buildings/markets/barbarians/market/init.lua'
--- data/tribes/buildings/markets/barbarians/market/init.lua 1970-01-01 00:00:00 +0000
+++ data/tribes/buildings/markets/barbarians/market/init.lua 2017-09-18 07:21:55 +0000
@@ -0,0 +1,56 @@
1-- RST
2-- .. _lua_tribes_buildings_markets:
3--
4-- Markets
5-- -------
6--
7-- TODO(sirver, trading): Add useful documentation here
8dirname = path.dirname(__file__)
9
10tribes:new_market_type {
11 msgctxt = "barbarians_building",
12 name = "barbarians_market",
13 -- TRANSLATORS: This is a building name used in lists of buildings
14 descname = pgettext("barbarians_building", "Market"),
15 helptext_script = dirname .. "helptexts.lua",
16 icon = dirname .. "menu.png",
17 size = "medium",
18
19 buildcost = {
20 log = 8,
21 blackwood = 6,
22 granite = 4,
23 grout = 3,
24 iron = 1,
25 thatch_reed = 4,
26 gold = 2,
27 },
28 return_on_dismantle = {
29 log = 4,
30 blackwood = 3,
31 granite = 3,
32 grout = 1,
33 iron = 1,
34 thatch_reed = 2,
35 gold = 1,
36 },
37
38 animations = {
39 idle = {
40 pictures = path.list_files(dirname .. "idle_??.png"),
41 hotspot = { 67, 80 },
42 },
43 build = {
44 pictures = path.list_files(dirname .. "build_??.png"),
45 hotspot = { 67, 80 },
46 }
47 },
48
49 aihints = {
50 prohibited_till = 1000
51 },
52
53 working_positions = {
54 barbarians_ox = 10,
55 },
56}
057
=== added file 'data/tribes/buildings/markets/barbarians/market/menu.png'
1Binary files data/tribes/buildings/markets/barbarians/market/menu.png 1970-01-01 00:00:00 +0000 and data/tribes/buildings/markets/barbarians/market/menu.png 2017-09-18 07:21:55 +0000 differ58Binary files data/tribes/buildings/markets/barbarians/market/menu.png 1970-01-01 00:00:00 +0000 and data/tribes/buildings/markets/barbarians/market/menu.png 2017-09-18 07:21:55 +0000 differ
=== modified file 'data/tribes/init.lua'
--- data/tribes/init.lua 2017-02-12 09:10:57 +0000
+++ data/tribes/init.lua 2017-09-18 07:21:55 +0000
@@ -290,6 +290,13 @@
290 end)290 end)
291291
292 -- ===================================292 -- ===================================
293 -- Markets
294 -- ===================================
295
296 print_loading_message("┃ Markets", function()
297 include "tribes/buildings/markets/barbarians/market/init.lua"
298 end)
299 -- ===================================
293 -- Productionsites300 -- Productionsites
294 -- ===================================301 -- ===================================
295302
296303
=== modified file 'data/tribes/scripting/starting_conditions/barbarians/fortified_village.lua'
--- data/tribes/scripting/starting_conditions/barbarians/fortified_village.lua 2016-12-03 16:37:13 +0000
+++ data/tribes/scripting/starting_conditions/barbarians/fortified_village.lua 2017-09-18 07:21:55 +0000
@@ -19,6 +19,7 @@
19 sf = shared_in_start19 sf = shared_in_start
20 else20 else
21 plr:allow_workers("all")21 plr:allow_workers("all")
22 plr:forbid_buildings{"barbarians_market"}
22 end23 end
2324
24 local h = plr:place_building("barbarians_citadel", sf, false, true)25 local h = plr:place_building("barbarians_citadel", sf, false, true)
2526
=== modified file 'data/tribes/scripting/starting_conditions/barbarians/headquarters.lua'
--- data/tribes/scripting/starting_conditions/barbarians/headquarters.lua 2016-03-30 07:23:59 +0000
+++ data/tribes/scripting/starting_conditions/barbarians/headquarters.lua 2017-09-18 07:21:55 +0000
@@ -18,6 +18,7 @@
18 sf = shared_in_start18 sf = shared_in_start
19 else19 else
20 player:allow_workers("all")20 player:allow_workers("all")
21 player:forbid_buildings{"barbarians_market"}
21 end22 end
2223
23 hq = prefilled_buildings(player, { "barbarians_headquarters", sf.x, sf.y,24 hq = prefilled_buildings(player, { "barbarians_headquarters", sf.x, sf.y,
2425
=== modified file 'data/tribes/scripting/starting_conditions/barbarians/trading_outpost.lua'
--- data/tribes/scripting/starting_conditions/barbarians/trading_outpost.lua 2016-11-01 13:58:24 +0000
+++ data/tribes/scripting/starting_conditions/barbarians/trading_outpost.lua 2017-09-18 07:21:55 +0000
@@ -18,6 +18,7 @@
18 sf = shared_in_start18 sf = shared_in_start
19 else19 else
20 player:allow_workers("all")20 player:allow_workers("all")
21 player:forbid_buildings{"barbarians_market"}
21 end22 end
2223
23 hq = prefilled_buildings(player, { "barbarians_headquarters", sf.x, sf.y,24 hq = prefilled_buildings(player, { "barbarians_headquarters", sf.x, sf.y,
2425
=== modified file 'doc/sphinx/extract_rst.py'
--- doc/sphinx/extract_rst.py 2017-09-01 07:56:47 +0000
+++ doc/sphinx/extract_rst.py 2017-09-18 07:21:55 +0000
@@ -44,6 +44,8 @@
44 'trainingsite', 'lua_tribes_buildings'),44 'trainingsite', 'lua_tribes_buildings'),
45 ('data/tribes/buildings/warehouses/atlanteans/headquarters',45 ('data/tribes/buildings/warehouses/atlanteans/headquarters',
46 'warehouse', 'lua_tribes_buildings'),46 'warehouse', 'lua_tribes_buildings'),
47 ('data/tribes/buildings/markets/barbarians/market',
48 'market', 'lua_tribes_buildings'),
47 ('data/tribes/buildings/partially_finished/constructionsite',49 ('data/tribes/buildings/partially_finished/constructionsite',
48 'constructionsite', 'lua_tribes_buildings'),50 'constructionsite', 'lua_tribes_buildings'),
49 ('data/tribes/buildings/partially_finished/dismantlesite',51 ('data/tribes/buildings/partially_finished/dismantlesite',
5052
=== modified file 'regression_test.py'
--- regression_test.py 2016-08-14 07:59:55 +0000
+++ regression_test.py 2017-09-18 07:21:55 +0000
@@ -217,7 +217,7 @@
217 args = parse_args()217 args = parse_args()
218218
219 WidelandsTestCase.path_to_widelands_binary = args.binary219 WidelandsTestCase.path_to_widelands_binary = args.binary
220 print("Using '{}' binary.".format(args.binary)) 220 print("Using '{}' binary.".format(args.binary))
221 WidelandsTestCase.do_use_random_directory = not args.nonrandom221 WidelandsTestCase.do_use_random_directory = not args.nonrandom
222 WidelandsTestCase.keep_output_around = args.keep_around222 WidelandsTestCase.keep_output_around = args.keep_around
223223
224224
=== modified file 'src/logic/CMakeLists.txt'
--- src/logic/CMakeLists.txt 2017-08-11 15:30:42 +0000
+++ src/logic/CMakeLists.txt 2017-09-18 07:21:55 +0000
@@ -166,6 +166,8 @@
166 map_objects/tribes/constructionsite.h166 map_objects/tribes/constructionsite.h
167 map_objects/tribes/dismantlesite.cc167 map_objects/tribes/dismantlesite.cc
168 map_objects/tribes/dismantlesite.h168 map_objects/tribes/dismantlesite.h
169 map_objects/tribes/market.cc
170 map_objects/tribes/market.h
169 map_objects/tribes/militarysite.cc171 map_objects/tribes/militarysite.cc
170 map_objects/tribes/militarysite.h172 map_objects/tribes/militarysite.h
171 map_objects/tribes/partially_finished_building.cc173 map_objects/tribes/partially_finished_building.cc
172174
=== modified file 'src/logic/map_objects/map_object.cc'
--- src/logic/map_objects/map_object.cc 2017-08-16 13:23:15 +0000
+++ src/logic/map_objects/map_object.cc 2017-09-18 07:21:55 +0000
@@ -653,6 +653,8 @@
653 return "dismantlesite";653 return "dismantlesite";
654 case MapObjectType::WAREHOUSE:654 case MapObjectType::WAREHOUSE:
655 return "warehouse";655 return "warehouse";
656 case MapObjectType::MARKET:
657 return "market";
656 case MapObjectType::PRODUCTIONSITE:658 case MapObjectType::PRODUCTIONSITE:
657 return "productionsite";659 return "productionsite";
658 case MapObjectType::MILITARYSITE:660 case MapObjectType::MILITARYSITE:
659661
=== modified file 'src/logic/map_objects/map_object.h'
--- src/logic/map_objects/map_object.h 2017-07-03 19:24:02 +0000
+++ src/logic/map_objects/map_object.h 2017-09-18 07:21:55 +0000
@@ -82,6 +82,7 @@
82 CONSTRUCTIONSITE, // Building -- Constructionsite82 CONSTRUCTIONSITE, // Building -- Constructionsite
83 DISMANTLESITE, // Building -- Dismantlesite83 DISMANTLESITE, // Building -- Dismantlesite
84 WAREHOUSE, // Building -- Warehouse84 WAREHOUSE, // Building -- Warehouse
85 MARKET, // Building -- Market
85 PRODUCTIONSITE, // Building -- Productionsite86 PRODUCTIONSITE, // Building -- Productionsite
86 MILITARYSITE, // Building -- Productionsite -- Militarysite87 MILITARYSITE, // Building -- Productionsite -- Militarysite
87 TRAININGSITE // Building -- Productionsite -- Trainingsite88 TRAININGSITE // Building -- Productionsite -- Trainingsite
8889
=== added file 'src/logic/map_objects/tribes/market.cc'
--- src/logic/map_objects/tribes/market.cc 1970-01-01 00:00:00 +0000
+++ src/logic/map_objects/tribes/market.cc 2017-09-18 07:21:55 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) 2006-2017 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 */
19
20#include "logic/map_objects/tribes/market.h"
21
22#include "base/i18n.h"
23#include "logic/map_objects/tribes/productionsite.h"
24
25namespace Widelands {
26
27MarketDescr::MarketDescr(const std::string& init_descname,
28 const LuaTable& table,
29 const EditorGameBase& egbase)
30 : BuildingDescr(init_descname, MapObjectType::MARKET, table, egbase) {
31 i18n::Textdomain td("tribes");
32
33 parse_working_positions(egbase, table.get_table("working_positions").get(), &working_positions_);
34 // TODO(sirver,trading): Add actual logic here.
35}
36
37Building& MarketDescr::create_object() const {
38 return *new Market(*this);
39}
40
41Market::Market(const MarketDescr& the_descr) : Building(the_descr) {}
42
43Market::~Market() {}
44
45} // namespace Widelands
046
=== added file 'src/logic/map_objects/tribes/market.h'
--- src/logic/map_objects/tribes/market.h 1970-01-01 00:00:00 +0000
+++ src/logic/map_objects/tribes/market.h 2017-09-18 07:21:55 +0000
@@ -0,0 +1,51 @@
1/*
2 * Copyright (C) 2006-2017 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 *
18 */
19
20#ifndef WL_LOGIC_MAP_OBJECTS_TRIBES_MARKET_H
21#define WL_LOGIC_MAP_OBJECTS_TRIBES_MARKET_H
22
23#include "logic/map_objects/tribes/building.h"
24
25namespace Widelands {
26
27class MarketDescr : public BuildingDescr {
28public:
29 MarketDescr(const std::string& init_descname, const LuaTable& t, const EditorGameBase& egbase);
30 ~MarketDescr() override {
31 }
32
33 Building& create_object() const override;
34
35private:
36 BillOfMaterials working_positions_;
37};
38
39class Market : public Building {
40 MO_DESCR(MarketDescr)
41public:
42 explicit Market(const MarketDescr& descr);
43 ~Market() override;
44
45private:
46 DISALLOW_COPY_AND_ASSIGN(Market);
47};
48
49} // namespace Widelands
50
51#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_TRIBES_MARKET_H
052
=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc 2017-08-16 04:31:56 +0000
+++ src/logic/map_objects/tribes/productionsite.cc 2017-09-18 07:21:55 +0000
@@ -45,7 +45,31 @@
4545
46namespace Widelands {46namespace Widelands {
4747
48static const size_t STATISTICS_VECTOR_LENGTH = 20;48namespace {
49
50constexpr size_t STATISTICS_VECTOR_LENGTH = 20;
51
52} // namespace
53
54void parse_working_positions(const EditorGameBase& egbase,
55 LuaTable* items_table,
56 BillOfMaterials* working_positions) {
57 for (const std::string& worker_name : items_table->keys<std::string>()) {
58 int amount = items_table->get_int(worker_name);
59 try {
60 if (amount < 1 || 255 < amount) {
61 throw wexception("count is out of range 1 .. 255");
62 }
63 DescriptionIndex const woi = egbase.tribes().worker_index(worker_name);
64 if (!egbase.tribes().worker_exists(woi)) {
65 throw wexception("invalid");
66 }
67 working_positions->push_back(std::pair<DescriptionIndex, uint32_t>(woi, amount));
68 } catch (const WException& e) {
69 throw wexception("%s=\"%d\": %s", worker_name.c_str(), amount, e.what());
70 }
71 }
72}
4973
50/*74/*
51==============================================================================75==============================================================================
@@ -146,28 +170,7 @@
146 }170 }
147 }171 }
148172
149 items_table = table.get_table("working_positions");173 parse_working_positions(egbase, table.get_table("working_positions").get(), &working_positions_);
150 for (const std::string& worker_name : items_table->keys<std::string>()) {
151 int amount = items_table->get_int(worker_name);
152 try {
153 if (amount < 1 || 255 < amount) {
154 throw wexception("count is out of range 1 .. 255");
155 }
156 DescriptionIndex const woi = egbase.tribes().worker_index(worker_name);
157 if (egbase.tribes().worker_exists(woi)) {
158 for (const auto& wp : working_positions()) {
159 if (wp.first == woi) {
160 throw wexception("duplicated");
161 }
162 }
163 working_positions_.push_back(std::pair<DescriptionIndex, uint32_t>(woi, amount));
164 } else {
165 throw wexception("invalid");
166 }
167 } catch (const WException& e) {
168 throw wexception("%s=\"%d\": %s", worker_name.c_str(), amount, e.what());
169 }
170 }
171174
172 // Get programs175 // Get programs
173 items_table = table.get_table("programs");176 items_table = table.get_table("programs");
174177
=== modified file 'src/logic/map_objects/tribes/productionsite.h'
--- src/logic/map_objects/tribes/productionsite.h 2017-06-24 08:47:46 +0000
+++ src/logic/map_objects/tribes/productionsite.h 2017-09-18 07:21:55 +0000
@@ -374,6 +374,15 @@
374 : ps(init_ps), player(init_player) {374 : ps(init_ps), player(init_player) {
375 }375 }
376};376};
377}377
378// Parses the descriptions of the working positions from 'items_table' and
379// fills in 'working_positions'. Throws an error if the table contains invalid
380// values.
381void parse_working_positions(const EditorGameBase& egbase,
382 LuaTable* items_table,
383 BillOfMaterials* working_positions);
384
385} // namespace Widelands
386
378387
379#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_TRIBES_PRODUCTIONSITE_H388#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_TRIBES_PRODUCTIONSITE_H
380389
=== modified file 'src/logic/map_objects/tribes/tribes.cc'
--- src/logic/map_objects/tribes/tribes.cc 2017-03-23 07:36:36 +0000
+++ src/logic/map_objects/tribes/tribes.cc 2017-09-18 07:21:55 +0000
@@ -121,6 +121,13 @@
121 table, egbase));121 table, egbase));
122}122}
123123
124void Tribes::add_market_type(const LuaTable& table, const EditorGameBase& egbase) {
125 i18n::Textdomain td("tribes");
126 buildings_->add(new MarketDescr(
127 pgettext_expr(table.get_string("msgctxt").c_str(), table.get_string("descname").c_str()),
128 table, egbase));
129}
130
124void Tribes::add_immovable_type(const LuaTable& table) {131void Tribes::add_immovable_type(const LuaTable& table) {
125 i18n::Textdomain td("tribes");132 i18n::Textdomain td("tribes");
126 immovables_->add(new ImmovableDescr(133 immovables_->add(new ImmovableDescr(
127134
=== modified file 'src/logic/map_objects/tribes/tribes.h'
--- src/logic/map_objects/tribes/tribes.h 2017-03-23 07:36:36 +0000
+++ src/logic/map_objects/tribes/tribes.h 2017-09-18 07:21:55 +0000
@@ -38,6 +38,7 @@
38#include "logic/map_objects/tribes/tribe_descr.h"38#include "logic/map_objects/tribes/tribe_descr.h"
39#include "logic/map_objects/tribes/ware_descr.h"39#include "logic/map_objects/tribes/ware_descr.h"
40#include "logic/map_objects/tribes/warehouse.h"40#include "logic/map_objects/tribes/warehouse.h"
41#include "logic/map_objects/tribes/market.h"
41#include "logic/map_objects/tribes/worker_descr.h"42#include "logic/map_objects/tribes/worker_descr.h"
42#include "scripting/lua_table.h"43#include "scripting/lua_table.h"
4344
@@ -82,6 +83,9 @@
82 /// Adds this building type to the tribe description.83 /// Adds this building type to the tribe description.
83 void add_warehouse_type(const LuaTable& table, const EditorGameBase& egbase);84 void add_warehouse_type(const LuaTable& table, const EditorGameBase& egbase);
8485
86 /// Adds this building type to the tribe description.
87 void add_market_type(const LuaTable& table, const EditorGameBase& egbase);
88
85 /// Adds this immovable type to the tribe description.89 /// Adds this immovable type to the tribe description.
86 void add_immovable_type(const LuaTable& table);90 void add_immovable_type(const LuaTable& table);
8791
8892
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2017-09-03 13:03:56 +0000
+++ src/scripting/lua_map.cc 2017-09-18 07:21:55 +0000
@@ -618,6 +618,8 @@
618 return CAST_TO_LUA(MilitarySiteDescr, LuaMilitarySiteDescription);618 return CAST_TO_LUA(MilitarySiteDescr, LuaMilitarySiteDescription);
619 case MapObjectType::WAREHOUSE:619 case MapObjectType::WAREHOUSE:
620 return CAST_TO_LUA(WarehouseDescr, LuaWarehouseDescription);620 return CAST_TO_LUA(WarehouseDescr, LuaWarehouseDescription);
621 case MapObjectType::MARKET:
622 return CAST_TO_LUA(MarketDescr, LuaMarketDescription);
621 case MapObjectType::TRAININGSITE:623 case MapObjectType::TRAININGSITE:
622 return CAST_TO_LUA(TrainingSiteDescr, LuaTrainingSiteDescription);624 return CAST_TO_LUA(TrainingSiteDescr, LuaTrainingSiteDescription);
623 default:625 default:
@@ -684,17 +686,19 @@
684 return CAST_TO_LUA(Building);686 return CAST_TO_LUA(Building);
685 case MapObjectType::WAREHOUSE:687 case MapObjectType::WAREHOUSE:
686 return CAST_TO_LUA(Warehouse);688 return CAST_TO_LUA(Warehouse);
689 case MapObjectType::MARKET:
690 return CAST_TO_LUA(Market);
687 case MapObjectType::PRODUCTIONSITE:691 case MapObjectType::PRODUCTIONSITE:
688 return CAST_TO_LUA(ProductionSite);692 return CAST_TO_LUA(ProductionSite);
689 case MapObjectType::MILITARYSITE:693 case MapObjectType::MILITARYSITE:
690 return CAST_TO_LUA(MilitarySite);694 return CAST_TO_LUA(MilitarySite);
691 case MapObjectType::TRAININGSITE:695 case MapObjectType::TRAININGSITE:
692 return CAST_TO_LUA(TrainingSite);696 return CAST_TO_LUA(TrainingSite);
693 case (MapObjectType::MAPOBJECT):697 case MapObjectType::MAPOBJECT:
694 case (MapObjectType::BATTLE):698 case MapObjectType::BATTLE:
695 case (MapObjectType::BOB):699 case MapObjectType::BOB:
696 case (MapObjectType::FLEET):700 case MapObjectType::FLEET:
697 case (MapObjectType::WARE):701 case MapObjectType::WARE:
698 throw LuaError((boost::format("upcasted_map_object_to_lua: Unknown %i") %702 throw LuaError((boost::format("upcasted_map_object_to_lua: Unknown %i") %
699 static_cast<int>(mo->descr().type()))703 static_cast<int>(mo->descr().type()))
700 .str());704 .str());
@@ -2746,6 +2750,33 @@
2746}2750}
27472751
2748/* RST2752/* RST
2753MarketDescription
2754-----------------
2755
2756.. class:: MarketDescription
2757
2758 Child of: :class:`MapObjectDescription`, :class:`ImmovableDescription`, :class:`BuildingDescription`
2759
2760 A static description of a tribe's market, so it can be used in help files
2761 without having to access an actual building on the map. A Market is used for
2762 trading over land with other players. See the parent classes for more
2763 properties.
2764*/
2765const char LuaMarketDescription::className[] = "MarketDescription";
2766const MethodType<LuaMarketDescription> LuaMarketDescription::Methods[] = {
2767 {nullptr, nullptr},
2768};
2769const PropertyType<LuaMarketDescription> LuaMarketDescription::Properties[] = {
2770 {nullptr, nullptr, nullptr},
2771};
2772
2773/*
2774 ==========================================================
2775 PROPERTIES
2776 ==========================================================
2777 */
2778
2779/* RST
2749WareDescription2780WareDescription
2750---------------2781---------------
27512782
@@ -3664,36 +3695,38 @@
3664 assert(desc != nullptr);3695 assert(desc != nullptr);
36653696
3666 switch (desc->type()) {3697 switch (desc->type()) {
3667 case (MapObjectType::BUILDING):3698 case MapObjectType::BUILDING:
3668 return CAST_TO_LUA(BuildingDescr, LuaBuildingDescription);3699 return CAST_TO_LUA(BuildingDescr, LuaBuildingDescription);
3669 case (MapObjectType::CONSTRUCTIONSITE):3700 case MapObjectType::CONSTRUCTIONSITE:
3670 return CAST_TO_LUA(ConstructionSiteDescr, LuaConstructionSiteDescription);3701 return CAST_TO_LUA(ConstructionSiteDescr, LuaConstructionSiteDescription);
3671 case (MapObjectType::DISMANTLESITE):3702 case MapObjectType::DISMANTLESITE:
3672 return CAST_TO_LUA(DismantleSiteDescr, LuaDismantleSiteDescription);3703 return CAST_TO_LUA(DismantleSiteDescr, LuaDismantleSiteDescription);
3673 case (MapObjectType::PRODUCTIONSITE):3704 case MapObjectType::PRODUCTIONSITE:
3674 return CAST_TO_LUA(ProductionSiteDescr, LuaProductionSiteDescription);3705 return CAST_TO_LUA(ProductionSiteDescr, LuaProductionSiteDescription);
3675 case (MapObjectType::MILITARYSITE):3706 case MapObjectType::MILITARYSITE:
3676 return CAST_TO_LUA(MilitarySiteDescr, LuaMilitarySiteDescription);3707 return CAST_TO_LUA(MilitarySiteDescr, LuaMilitarySiteDescription);
3677 case (MapObjectType::TRAININGSITE):3708 case MapObjectType::TRAININGSITE:
3678 return CAST_TO_LUA(TrainingSiteDescr, LuaTrainingSiteDescription);3709 return CAST_TO_LUA(TrainingSiteDescr, LuaTrainingSiteDescription);
3679 case (MapObjectType::WAREHOUSE):3710 case MapObjectType::WAREHOUSE:
3680 return CAST_TO_LUA(WarehouseDescr, LuaWarehouseDescription);3711 return CAST_TO_LUA(WarehouseDescr, LuaWarehouseDescription);
3681 case (MapObjectType::IMMOVABLE):3712 case MapObjectType::MARKET:
3713 return CAST_TO_LUA(MarketDescr, LuaMarketDescription);
3714 case MapObjectType::IMMOVABLE:
3682 return CAST_TO_LUA(ImmovableDescr, LuaImmovableDescription);3715 return CAST_TO_LUA(ImmovableDescr, LuaImmovableDescription);
3683 case (MapObjectType::WORKER):3716 case MapObjectType::WORKER:
3684 case (MapObjectType::CARRIER):3717 case MapObjectType::CARRIER:
3685 case (MapObjectType::SOLDIER):3718 case MapObjectType::SOLDIER:
3686 return CAST_TO_LUA(WorkerDescr, LuaWorkerDescription);3719 return CAST_TO_LUA(WorkerDescr, LuaWorkerDescription);
3687 case (MapObjectType::MAPOBJECT):3720 case MapObjectType::MAPOBJECT:
3688 case (MapObjectType::BATTLE):3721 case MapObjectType::BATTLE:
3689 case (MapObjectType::BOB):3722 case MapObjectType::BOB:
3690 case (MapObjectType::CRITTER):3723 case MapObjectType::CRITTER:
3691 case (MapObjectType::FLEET):3724 case MapObjectType::FLEET:
3692 case (MapObjectType::SHIP):3725 case MapObjectType::SHIP:
3693 case (MapObjectType::FLAG):3726 case MapObjectType::FLAG:
3694 case (MapObjectType::ROAD):3727 case MapObjectType::ROAD:
3695 case (MapObjectType::PORTDOCK):3728 case MapObjectType::PORTDOCK:
3696 case (MapObjectType::WARE):3729 case MapObjectType::WARE:
3697 return CAST_TO_LUA(MapObjectDescr, LuaMapObjectDescription);3730 return CAST_TO_LUA(MapObjectDescr, LuaMapObjectDescription);
3698 }3731 }
3699 NEVER_HERE();3732 NEVER_HERE();
@@ -5036,6 +5069,51 @@
5036}5069}
50375070
5038/* RST5071/* RST
5072Market
5073---------
5074
5075.. class:: Market
5076
5077 Child of: :class:`Building`, :class:`HasWares`, :class:`HasWorkers`
5078
5079 A Market used for trading with other players.
5080
5081 More properties are available through this object's
5082 :class:`MarketDescription`, which you can access via :any:`MapObject.descr`.
5083*/
5084const char LuaMarket::className[] = "Market";
5085const MethodType<LuaMarket> LuaMarket::Methods[] = {
5086 // TODO(sirver,trading): Implement and fix documentation.
5087 // METHOD(LuaMarket, set_wares),
5088 // METHOD(LuaMarket, get_wares),
5089 // METHOD(LuaMarket, set_workers),
5090 // METHOD(LuaMarket, get_workers),
5091 {nullptr, nullptr},
5092};
5093const PropertyType<LuaMarket> LuaMarket::Properties[] = {
5094 {nullptr, nullptr, nullptr},
5095};
5096
5097/*
5098 ==========================================================
5099 PROPERTIES
5100 ==========================================================
5101 */
5102
5103/*
5104 ==========================================================
5105 LUA METHODS
5106 ==========================================================
5107 */
5108
5109/*
5110 ==========================================================
5111 C METHODS
5112 ==========================================================
5113 */
5114
5115
5116/* RST
5039MilitarySite5117MilitarySite
5040--------------5118--------------
50415119
@@ -6362,6 +6440,11 @@
6362 add_parent<LuaWarehouseDescription, LuaMapObjectDescription>(L);6440 add_parent<LuaWarehouseDescription, LuaMapObjectDescription>(L);
6363 lua_pop(L, 1); // Pop the meta table6441 lua_pop(L, 1); // Pop the meta table
63646442
6443 register_class<LuaMarketDescription>(L, "map", true);
6444 add_parent<LuaMarketDescription, LuaBuildingDescription>(L);
6445 add_parent<LuaMarketDescription, LuaMapObjectDescription>(L);
6446 lua_pop(L, 1); // Pop the meta table
6447
6365 register_class<LuaWareDescription>(L, "map", true);6448 register_class<LuaWareDescription>(L, "map", true);
6366 add_parent<LuaWareDescription, LuaMapObjectDescription>(L);6449 add_parent<LuaWareDescription, LuaMapObjectDescription>(L);
6367 lua_pop(L, 1); // Pop the meta table6450 lua_pop(L, 1); // Pop the meta table
@@ -6450,6 +6533,13 @@
6450 add_parent<LuaWarehouse, LuaMapObject>(L);6533 add_parent<LuaWarehouse, LuaMapObject>(L);
6451 lua_pop(L, 1); // Pop the meta table6534 lua_pop(L, 1); // Pop the meta table
64526535
6536 register_class<LuaMarket>(L, "map", true);
6537 add_parent<LuaMarket, LuaBuilding>(L);
6538 add_parent<LuaMarket, LuaPlayerImmovable>(L);
6539 add_parent<LuaMarket, LuaBaseImmovable>(L);
6540 add_parent<LuaMarket, LuaMapObject>(L);
6541 lua_pop(L, 1); // Pop the meta table
6542
6453 register_class<LuaProductionSite>(L, "map", true);6543 register_class<LuaProductionSite>(L, "map", true);
6454 add_parent<LuaProductionSite, LuaBuilding>(L);6544 add_parent<LuaProductionSite, LuaBuilding>(L);
6455 add_parent<LuaProductionSite, LuaPlayerImmovable>(L);6545 add_parent<LuaProductionSite, LuaPlayerImmovable>(L);
64566546
=== modified file 'src/scripting/lua_map.h'
--- src/scripting/lua_map.h 2017-06-25 19:12:30 +0000
+++ src/scripting/lua_map.h 2017-09-18 07:21:55 +0000
@@ -502,6 +502,37 @@
502 CASTED_GET_DESCRIPTION(WarehouseDescr)502 CASTED_GET_DESCRIPTION(WarehouseDescr)
503};503};
504504
505class LuaMarketDescription : public LuaBuildingDescription {
506public:
507 LUNA_CLASS_HEAD(LuaMarketDescription);
508
509 virtual ~LuaMarketDescription() {
510 }
511
512 LuaMarketDescription() {
513 }
514 explicit LuaMarketDescription(const Widelands::MarketDescr* const warehousedescr)
515 : LuaBuildingDescription(warehousedescr) {
516 }
517 explicit LuaMarketDescription(lua_State* L) : LuaBuildingDescription(L) {
518 }
519
520 /*
521 * Properties
522 */
523
524 /*
525 * Lua methods
526 */
527
528 /*
529 * C methods
530 */
531
532private:
533 CASTED_GET_DESCRIPTION(MarketDescr)
534};
535
505class LuaWareDescription : public LuaMapObjectDescription {536class LuaWareDescription : public LuaMapObjectDescription {
506public:537public:
507 LUNA_CLASS_HEAD(LuaWareDescription);538 LUNA_CLASS_HEAD(LuaWareDescription);
@@ -1075,6 +1106,33 @@
1075 CASTED_GET(Warehouse)1106 CASTED_GET(Warehouse)
1076};1107};
10771108
1109class LuaMarket : public LuaBuilding {
1110public:
1111 LUNA_CLASS_HEAD(LuaMarket);
1112
1113 LuaMarket() {
1114 }
1115 explicit LuaMarket(Widelands::Market& mo) : LuaBuilding(mo) {
1116 }
1117 explicit LuaMarket(lua_State* L) : LuaBuilding(L) {
1118 }
1119 virtual ~LuaMarket() {
1120 }
1121
1122 /*
1123 * Properties
1124 */
1125
1126 /*
1127 * Lua Methods
1128 */
1129
1130 /*
1131 * C Methods
1132 */
1133 CASTED_GET(Market)
1134};
1135
1078class LuaProductionSite : public LuaBuilding {1136class LuaProductionSite : public LuaBuilding {
1079public:1137public:
1080 LUNA_CLASS_HEAD(LuaProductionSite);1138 LUNA_CLASS_HEAD(LuaProductionSite);
10811139
=== modified file 'src/scripting/lua_root.cc'
--- src/scripting/lua_root.cc 2017-09-03 10:13:32 +0000
+++ src/scripting/lua_root.cc 2017-09-18 07:21:55 +0000
@@ -503,19 +503,20 @@
503503
504const char LuaTribes::className[] = "Tribes";504const char LuaTribes::className[] = "Tribes";
505const MethodType<LuaTribes> LuaTribes::Methods[] = {505const MethodType<LuaTribes> LuaTribes::Methods[] = {
506 METHOD(LuaTribes, new_carrier_type),
506 METHOD(LuaTribes, new_constructionsite_type),507 METHOD(LuaTribes, new_constructionsite_type),
507 METHOD(LuaTribes, new_dismantlesite_type),508 METHOD(LuaTribes, new_dismantlesite_type),
509 METHOD(LuaTribes, new_immovable_type),
510 METHOD(LuaTribes, new_market_type),
508 METHOD(LuaTribes, new_militarysite_type),511 METHOD(LuaTribes, new_militarysite_type),
509 METHOD(LuaTribes, new_productionsite_type),512 METHOD(LuaTribes, new_productionsite_type),
513 METHOD(LuaTribes, new_ship_type),
514 METHOD(LuaTribes, new_soldier_type),
510 METHOD(LuaTribes, new_trainingsite_type),515 METHOD(LuaTribes, new_trainingsite_type),
516 METHOD(LuaTribes, new_tribe),
517 METHOD(LuaTribes, new_ware_type),
511 METHOD(LuaTribes, new_warehouse_type),518 METHOD(LuaTribes, new_warehouse_type),
512 METHOD(LuaTribes, new_immovable_type),
513 METHOD(LuaTribes, new_ship_type),
514 METHOD(LuaTribes, new_ware_type),
515 METHOD(LuaTribes, new_carrier_type),
516 METHOD(LuaTribes, new_soldier_type),
517 METHOD(LuaTribes, new_worker_type),519 METHOD(LuaTribes, new_worker_type),
518 METHOD(LuaTribes, new_tribe),
519 {0, 0},520 {0, 0},
520};521};
521const PropertyType<LuaTribes> LuaTribes::Properties[] = {522const PropertyType<LuaTribes> LuaTribes::Properties[] = {
@@ -691,6 +692,30 @@
691}692}
692693
693/* RST694/* RST
695 .. method:: new_market_type{table}
696
697 Adds a new market building type. Takes a single argument, a table with
698 the descriptions. See :ref:`lua_tribes_buildings_markets` for detailed
699 documentation.
700
701 :returns: :const:`0`
702*/
703int LuaTribes::new_market_type(lua_State* L) {
704 if (lua_gettop(L) != 2) {
705 report_error(L, "Takes only one argument.");
706 }
707
708 try {
709 LuaTable table(L); // Will pop the table eventually.
710 EditorGameBase& egbase = get_egbase(L);
711 egbase.mutable_tribes()->add_market_type(table, egbase);
712 } catch (std::exception& e) {
713 report_error(L, "%s", e.what());
714 }
715 return 0;
716}
717
718/* RST
694 .. method:: new_immovable_type{table}719 .. method:: new_immovable_type{table}
695720
696 Adds a new immovable type. Takes a single argument, a table with721 Adds a new immovable type. Takes a single argument, a table with
697722
=== modified file 'src/scripting/lua_root.h'
--- src/scripting/lua_root.h 2017-06-24 08:47:46 +0000
+++ src/scripting/lua_root.h 2017-09-18 07:21:55 +0000
@@ -159,19 +159,20 @@
159 /*159 /*
160 * Lua methods160 * Lua methods
161 */161 */
162 int new_carrier_type(lua_State* L);
162 int new_constructionsite_type(lua_State* L);163 int new_constructionsite_type(lua_State* L);
163 int new_dismantlesite_type(lua_State* L);164 int new_dismantlesite_type(lua_State* L);
165 int new_immovable_type(lua_State* L);
166 int new_market_type(lua_State* L);
164 int new_militarysite_type(lua_State* L);167 int new_militarysite_type(lua_State* L);
165 int new_productionsite_type(lua_State* L);168 int new_productionsite_type(lua_State* L);
169 int new_ship_type(lua_State* L);
170 int new_soldier_type(lua_State* L);
166 int new_trainingsite_type(lua_State* L);171 int new_trainingsite_type(lua_State* L);
172 int new_tribe(lua_State* L);
173 int new_ware_type(lua_State* L);
167 int new_warehouse_type(lua_State* L);174 int new_warehouse_type(lua_State* L);
168 int new_immovable_type(lua_State* L);
169 int new_ship_type(lua_State* L);
170 int new_ware_type(lua_State* L);
171 int new_carrier_type(lua_State* L);
172 int new_soldier_type(lua_State* L);
173 int new_worker_type(lua_State* L);175 int new_worker_type(lua_State* L);
174 int new_tribe(lua_State* L);
175176
176 /*177 /*
177 * C methods178 * C methods
178179
=== modified file 'src/website/map_object_info.cc'
--- src/website/map_object_info.cc 2017-01-30 14:40:12 +0000
+++ src/website/map_object_info.cc 2017-09-18 07:21:55 +0000
@@ -301,6 +301,9 @@
301 case MapObjectType::WAREHOUSE:301 case MapObjectType::WAREHOUSE:
302 fw.write_key_value_string("type", "warehouse");302 fw.write_key_value_string("type", "warehouse");
303 break;303 break;
304 case MapObjectType::MARKET:
305 fw.write_key_value_string("type", "market");
306 break;
304 case MapObjectType::MILITARYSITE:307 case MapObjectType::MILITARYSITE:
305 fw.write_key_value_string("type", "militarysite");308 fw.write_key_value_string("type", "militarysite");
306 break;309 break;
307310
=== modified file 'src/wui/interactive_gamebase.cc'
--- src/wui/interactive_gamebase.cc 2017-09-01 15:45:59 +0000
+++ src/wui/interactive_gamebase.cc 2017-09-18 07:21:55 +0000
@@ -205,6 +205,7 @@
205 *this, registry, *dynamic_cast<Widelands::Warehouse*>(building), avoid_fastclick);205 *this, registry, *dynamic_cast<Widelands::Warehouse*>(building), avoid_fastclick);
206 };206 };
207 break;207 break;
208 // TODO(sirver,trading): Add UI for market.
208 default:209 default:
209 log("Unable to show window for building '%s', type '%s'.\n", building->descr().name().c_str(),210 log("Unable to show window for building '%s', type '%s'.\n", building->descr().name().c_str(),
210 to_string(building->descr().type()).c_str());211 to_string(building->descr().type()).c_str());
211212
=== modified file 'test/maps/lua_testsuite.wmf/scripting/tribes_descriptions.lua'
--- test/maps/lua_testsuite.wmf/scripting/tribes_descriptions.lua 2016-11-12 09:13:55 +0000
+++ test/maps/lua_testsuite.wmf/scripting/tribes_descriptions.lua 2017-09-18 07:21:55 +0000
@@ -28,7 +28,7 @@
28 local tribe = egbase:get_tribe_description("atlanteans")28 local tribe = egbase:get_tribe_description("atlanteans")
29 assert_equal(42, #tribe.buildings)29 assert_equal(42, #tribe.buildings)
30 tribe = egbase:get_tribe_description("barbarians")30 tribe = egbase:get_tribe_description("barbarians")
31 assert_equal(51, #tribe.buildings)31 assert_equal(52, #tribe.buildings)
32 tribe = egbase:get_tribe_description("empire")32 tribe = egbase:get_tribe_description("empire")
33 assert_equal(52, #tribe.buildings)33 assert_equal(52, #tribe.buildings)
3434
3535
=== added directory 'test/maps/market_trading.wmf'
=== added directory 'test/maps/market_trading.wmf/binary'
=== added file 'test/maps/market_trading.wmf/binary/heights'
36Binary files test/maps/market_trading.wmf/binary/heights 1970-01-01 00:00:00 +0000 and test/maps/market_trading.wmf/binary/heights 2017-09-18 07:21:55 +0000 differ36Binary files test/maps/market_trading.wmf/binary/heights 1970-01-01 00:00:00 +0000 and test/maps/market_trading.wmf/binary/heights 2017-09-18 07:21:55 +0000 differ
=== added file 'test/maps/market_trading.wmf/binary/mapobjects'
37Binary files test/maps/market_trading.wmf/binary/mapobjects 1970-01-01 00:00:00 +0000 and test/maps/market_trading.wmf/binary/mapobjects 2017-09-18 07:21:55 +0000 differ37Binary files test/maps/market_trading.wmf/binary/mapobjects 1970-01-01 00:00:00 +0000 and test/maps/market_trading.wmf/binary/mapobjects 2017-09-18 07:21:55 +0000 differ
=== added file 'test/maps/market_trading.wmf/binary/resource'
38Binary files test/maps/market_trading.wmf/binary/resource 1970-01-01 00:00:00 +0000 and test/maps/market_trading.wmf/binary/resource 2017-09-18 07:21:55 +0000 differ38Binary files test/maps/market_trading.wmf/binary/resource 1970-01-01 00:00:00 +0000 and test/maps/market_trading.wmf/binary/resource 2017-09-18 07:21:55 +0000 differ
=== added file 'test/maps/market_trading.wmf/binary/terrain'
39Binary files test/maps/market_trading.wmf/binary/terrain 1970-01-01 00:00:00 +0000 and test/maps/market_trading.wmf/binary/terrain 2017-09-18 07:21:55 +0000 differ39Binary files test/maps/market_trading.wmf/binary/terrain 1970-01-01 00:00:00 +0000 and test/maps/market_trading.wmf/binary/terrain 2017-09-18 07:21:55 +0000 differ
=== added file 'test/maps/market_trading.wmf/elemental'
--- test/maps/market_trading.wmf/elemental 1970-01-01 00:00:00 +0000
+++ test/maps/market_trading.wmf/elemental 2017-09-18 07:21:55 +0000
@@ -0,0 +1,12 @@
1# Automatically created by Widelands (Release)
2
3[global]
4packet_version="1"
5map_w="64"
6map_h="64"
7nr_players="2"
8name="market_trading"
9author="SirVer"
10descr="no description defined"
11hint=
12tags=
013
=== added file 'test/maps/market_trading.wmf/minimap.png'
1Binary files test/maps/market_trading.wmf/minimap.png 1970-01-01 00:00:00 +0000 and test/maps/market_trading.wmf/minimap.png 2017-09-18 07:21:55 +0000 differ14Binary files test/maps/market_trading.wmf/minimap.png 1970-01-01 00:00:00 +0000 and test/maps/market_trading.wmf/minimap.png 2017-09-18 07:21:55 +0000 differ
=== added file 'test/maps/market_trading.wmf/objective'
--- test/maps/market_trading.wmf/objective 1970-01-01 00:00:00 +0000
+++ test/maps/market_trading.wmf/objective 2017-09-18 07:21:55 +0000
@@ -0,0 +1,4 @@
1# Automatically created by Widelands (Release)
2
3[global]
4packet_version="2"
05
=== added file 'test/maps/market_trading.wmf/player_names'
--- test/maps/market_trading.wmf/player_names 1970-01-01 00:00:00 +0000
+++ test/maps/market_trading.wmf/player_names 2017-09-18 07:21:55 +0000
@@ -0,0 +1,16 @@
1# Automatically created by Widelands (Release)
2
3[global]
4packet_version="2"
5
6[player_1]
7name="Player 1"
8tribe="barbarians"
9ai="empty"
10closeable="false"
11
12[player_2]
13name="Player 2"
14tribe="barbarians"
15ai="empty"
16closeable="false"
017
=== added file 'test/maps/market_trading.wmf/player_position'
--- test/maps/market_trading.wmf/player_position 1970-01-01 00:00:00 +0000
+++ test/maps/market_trading.wmf/player_position 2017-09-18 07:21:55 +0000
@@ -0,0 +1,6 @@
1# Automatically created by Widelands (Release)
2
3[global]
4packet_version="2"
5player_1="21 27"
6player_2="45 27"
07
=== added file 'test/maps/market_trading.wmf/port_spaces'
--- test/maps/market_trading.wmf/port_spaces 1970-01-01 00:00:00 +0000
+++ test/maps/market_trading.wmf/port_spaces 2017-09-18 07:21:55 +0000
@@ -0,0 +1,7 @@
1# Automatically created by Widelands (Release)
2
3[global]
4packet_version="1"
5number_of_port_spaces="0"
6
7[port_spaces]
08
=== added directory 'test/maps/market_trading.wmf/scripting'
=== added file 'test/maps/market_trading.wmf/scripting/init.lua'
--- test/maps/market_trading.wmf/scripting/init.lua 1970-01-01 00:00:00 +0000
+++ test/maps/market_trading.wmf/scripting/init.lua 2017-09-18 07:21:55 +0000
@@ -0,0 +1,28 @@
1include "scripting/lunit.lua"
2include "scripting/coroutine.lua"
3include "scripting/infrastructure.lua"
4include "scripting/ui.lua"
5
6game = wl.Game()
7map = game.map
8p1 = game.players[1]
9p2 = game.players[2]
10p1.see_all = true
11
12p1:allow_workers("all")
13
14function full_headquarters(player, x, y)
15 prefilled_buildings(player, { "barbarians_headquarters", x, y })
16 hq = player:get_buildings("barbarians_headquarters")[1]
17 for idx,descr in ipairs(game:get_tribe_description("barbarians").wares) do
18 hq:set_wares(descr.name, 350)
19 end
20 for idx,descr in ipairs(game:get_tribe_description("barbarians").workers) do
21 hq:set_workers(descr.name, 50)
22 end
23end
24
25full_headquarters(p1, 22, 25)
26full_headquarters(p2, 32, 25)
27
28game.desired_speed = 50000
029
=== added file 'test/maps/market_trading.wmf/scripting/test_market_can_be_build.lua'
--- test/maps/market_trading.wmf/scripting/test_market_can_be_build.lua 1970-01-01 00:00:00 +0000
+++ test/maps/market_trading.wmf/scripting/test_market_can_be_build.lua 2017-09-18 07:21:55 +0000
@@ -0,0 +1,13 @@
1run(function()
2 sleep(2000)
3
4 market = p2:place_building("barbarians_market", map:get_field(35, 25), true, true)
5 connected_road(p2, market.flag, "l,l,l|", true)
6
7 while #p2:get_buildings("barbarians_market") == 0 do
8 sleep(10000)
9 end
10 print("# All Tests passed.")
11 wl.ui.MapView():close()
12end)
13
014
=== added file 'test/maps/market_trading.wmf/version'
--- test/maps/market_trading.wmf/version 1970-01-01 00:00:00 +0000
+++ test/maps/market_trading.wmf/version 2017-09-18 07:21:55 +0000
@@ -0,0 +1,11 @@
1# Automatically created by Widelands (Release)
2
3[global]
4map_source_url=
5map_release=
6map_creator_version=
7map_version_major="0"
8map_version_minor="1"
9map_version_timestamp="1505478312"
10packet_version="1"
11packet_compatibility="1"

Subscribers

People subscribed via source and target branches

to status/vote changes: