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

Proposed by GunChleoc
Status: Merged
Merged at revision: 7646
Proposed branch: lp:~widelands-dev/widelands/hide_seafaring_buildings
Merge into: lp:widelands
Diff against target: 110 lines (+12/-1)
7 files modified
src/logic/building.cc (+2/-0)
src/logic/building.h (+2/-0)
src/wui/fieldaction.cc (+2/-0)
tribes/buildings/productionsites/atlanteans/shipyard/init.lua (+1/-0)
tribes/buildings/productionsites/barbarians/shipyard/init.lua (+2/-1)
tribes/buildings/productionsites/barbarians/weaving_mill/init.lua (+2/-0)
tribes/buildings/productionsites/empire/shipyard/init.lua (+1/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/hide_seafaring_buildings
Reviewer Review Type Date Requested Status
TiborB Approve
Review via email: mp+278830@code.launchpad.net

Description of the change

Shipyards and Barbarian Weaving Mill are hidden from the flag actions in non-seafaring maps. This prevents players from building completely useless seafaring buildings, especially when they are new to the game. The buildings are still listed in the Encyclopedia.

I implemented it like this:

Added a new "needs_seafaring" property to buildings' init.lua. When this is set and the map doesn't have a need for ships, these buildings are hidden from the building window. Might also come in useful for the AI?

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

This is usefull tweak.

AI just scans the map to identify portspaces - yes, small cheat...

However barbarian weaving mill might still be build if it finds out that the output is needed... but right now I dont know if it happens....

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc 2015-11-11 09:53:54 +0000
+++ src/logic/building.cc 2015-11-27 15:18:43 +0000
@@ -159,6 +159,8 @@
159159
160 directory_ = table.get_string("directory");160 directory_ = table.get_string("directory");
161161
162 m_needs_seafaring = table.has_key("needs_seafaring") ? table.get_bool("needs_seafaring") : false;
163
162 if (table.has_key("vision_range")) {164 if (table.has_key("vision_range")) {
163 m_vision_range = table.get_int("vision_range");165 m_vision_range = table.get_int("vision_range");
164 }166 }
165167
=== modified file 'src/logic/building.h'
--- src/logic/building.h 2015-11-11 09:53:54 +0000
+++ src/logic/building.h 2015-11-27 15:18:43 +0000
@@ -95,6 +95,7 @@
95 int32_t get_size() const {return m_size;}95 int32_t get_size() const {return m_size;}
96 bool get_ismine() const {return m_mine;}96 bool get_ismine() const {return m_mine;}
97 bool get_isport() const {return m_port;}97 bool get_isport() const {return m_port;}
98 bool needs_seafaring() const {return m_needs_seafaring;}
9899
99 // Returns the enhancement this building can become or100 // Returns the enhancement this building can become or
100 // INVALID_INDEX if it cannot be enhanced.101 // INVALID_INDEX if it cannot be enhanced.
@@ -144,6 +145,7 @@
144 int32_t m_size; // size of the building145 int32_t m_size; // size of the building
145 bool m_mine;146 bool m_mine;
146 bool m_port;147 bool m_port;
148 bool m_needs_seafaring; // This building should only be built on seafaring maps.
147 DescriptionIndex m_enhancement;149 DescriptionIndex m_enhancement;
148 DescriptionIndex m_enhanced_from; // The building this building was enhanced from, or INVALID_INDEX150 DescriptionIndex m_enhanced_from; // The building this building was enhanced from, or INVALID_INDEX
149 bool m_enhanced_building; // if it is one, it is bulldozable151 bool m_enhanced_building; // if it is one, it is bulldozable
150152
=== modified file 'src/wui/fieldaction.cc'
--- src/wui/fieldaction.cc 2015-11-20 18:16:22 +0000
+++ src/wui/fieldaction.cc 2015-11-27 15:18:43 +0000
@@ -507,6 +507,8 @@
507 if (dynamic_cast<const Game *>(&ibase().egbase())) {507 if (dynamic_cast<const Game *>(&ibase().egbase())) {
508 if (!building_descr->is_buildable() || !m_plr->is_building_type_allowed(building_index))508 if (!building_descr->is_buildable() || !m_plr->is_building_type_allowed(building_index))
509 continue;509 continue;
510 if (building_descr->needs_seafaring() && ibase().egbase().map().get_port_spaces().size() < 2)
511 continue;
510 } else if (!building_descr->is_buildable() && !building_descr->is_enhanced())512 } else if (!building_descr->is_buildable() && !building_descr->is_enhanced())
511 continue;513 continue;
512514
513515
=== modified file 'tribes/buildings/productionsites/atlanteans/shipyard/init.lua'
--- tribes/buildings/productionsites/atlanteans/shipyard/init.lua 2015-10-31 12:11:44 +0000
+++ tribes/buildings/productionsites/atlanteans/shipyard/init.lua 2015-11-27 15:18:43 +0000
@@ -8,6 +8,7 @@
8 directory = dirname,8 directory = dirname,
9 icon = dirname .. "menu.png",9 icon = dirname .. "menu.png",
10 size = "medium",10 size = "medium",
11 needs_seafaring = true,
1112
12 buildcost = {13 buildcost = {
13 log = 3,14 log = 3,
1415
=== modified file 'tribes/buildings/productionsites/barbarians/shipyard/init.lua'
--- tribes/buildings/productionsites/barbarians/shipyard/init.lua 2015-10-31 12:11:44 +0000
+++ tribes/buildings/productionsites/barbarians/shipyard/init.lua 2015-11-27 15:18:43 +0000
@@ -8,6 +8,7 @@
8 directory = dirname,8 directory = dirname,
9 icon = dirname .. "menu.png",9 icon = dirname .. "menu.png",
10 size = "medium",10 size = "medium",
11 needs_seafaring = true,
1112
12 buildcost = {13 buildcost = {
13 log = 3,14 log = 3,
@@ -74,7 +75,7 @@
74 -- TRANSLATORS: Completed/Skipped/Did not start constructing a ship because ...75 -- TRANSLATORS: Completed/Skipped/Did not start constructing a ship because ...
75 descname = _"constructing a ship",76 descname = _"constructing a ship",
76 actions = {77 actions = {
77 "check_map=seafaring", -- TODO(GunChleoc): We should make this check on game creation as well and remove it from the allowed buildings78 "check_map=seafaring",
78 "construct=barbarians_shipconstruction buildship 6",79 "construct=barbarians_shipconstruction buildship 6",
79 "animate=working 35000",80 "animate=working 35000",
80 "return=completed"81 "return=completed"
8182
=== modified file 'tribes/buildings/productionsites/barbarians/weaving_mill/init.lua'
--- tribes/buildings/productionsites/barbarians/weaving_mill/init.lua 2015-10-31 12:11:44 +0000
+++ tribes/buildings/productionsites/barbarians/weaving_mill/init.lua 2015-11-27 15:18:43 +0000
@@ -8,6 +8,7 @@
8 directory = dirname,8 directory = dirname,
9 icon = dirname .. "menu.png",9 icon = dirname .. "menu.png",
10 size = "big",10 size = "big",
11 needs_seafaring = true,
1112
12 buildcost = {13 buildcost = {
13 log = 5,14 log = 5,
@@ -58,6 +59,7 @@
58 descname = _"weaving",59 descname = _"weaving",
59 actions = {60 actions = {
60 "sleep=20000",61 "sleep=20000",
62 "check_map=seafaring",
61 "return=skipped unless economy needs cloth",63 "return=skipped unless economy needs cloth",
62 "consume=thatch_reed",64 "consume=thatch_reed",
63 "animate=working 25000",65 "animate=working 25000",
6466
=== modified file 'tribes/buildings/productionsites/empire/shipyard/init.lua'
--- tribes/buildings/productionsites/empire/shipyard/init.lua 2015-10-31 12:11:44 +0000
+++ tribes/buildings/productionsites/empire/shipyard/init.lua 2015-11-27 15:18:43 +0000
@@ -8,6 +8,7 @@
8 directory = dirname,8 directory = dirname,
9 icon = dirname .. "menu.png",9 icon = dirname .. "menu.png",
10 size = "medium",10 size = "medium",
11 needs_seafaring = true,
1112
12 buildcost = {13 buildcost = {
13 log = 3,14 log = 3,

Subscribers

People subscribed via source and target branches

to status/vote changes: