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
1=== modified file 'src/logic/building.cc'
2--- src/logic/building.cc 2015-11-11 09:53:54 +0000
3+++ src/logic/building.cc 2015-11-27 15:18:43 +0000
4@@ -159,6 +159,8 @@
5
6 directory_ = table.get_string("directory");
7
8+ m_needs_seafaring = table.has_key("needs_seafaring") ? table.get_bool("needs_seafaring") : false;
9+
10 if (table.has_key("vision_range")) {
11 m_vision_range = table.get_int("vision_range");
12 }
13
14=== modified file 'src/logic/building.h'
15--- src/logic/building.h 2015-11-11 09:53:54 +0000
16+++ src/logic/building.h 2015-11-27 15:18:43 +0000
17@@ -95,6 +95,7 @@
18 int32_t get_size() const {return m_size;}
19 bool get_ismine() const {return m_mine;}
20 bool get_isport() const {return m_port;}
21+ bool needs_seafaring() const {return m_needs_seafaring;}
22
23 // Returns the enhancement this building can become or
24 // INVALID_INDEX if it cannot be enhanced.
25@@ -144,6 +145,7 @@
26 int32_t m_size; // size of the building
27 bool m_mine;
28 bool m_port;
29+ bool m_needs_seafaring; // This building should only be built on seafaring maps.
30 DescriptionIndex m_enhancement;
31 DescriptionIndex m_enhanced_from; // The building this building was enhanced from, or INVALID_INDEX
32 bool m_enhanced_building; // if it is one, it is bulldozable
33
34=== modified file 'src/wui/fieldaction.cc'
35--- src/wui/fieldaction.cc 2015-11-20 18:16:22 +0000
36+++ src/wui/fieldaction.cc 2015-11-27 15:18:43 +0000
37@@ -507,6 +507,8 @@
38 if (dynamic_cast<const Game *>(&ibase().egbase())) {
39 if (!building_descr->is_buildable() || !m_plr->is_building_type_allowed(building_index))
40 continue;
41+ if (building_descr->needs_seafaring() && ibase().egbase().map().get_port_spaces().size() < 2)
42+ continue;
43 } else if (!building_descr->is_buildable() && !building_descr->is_enhanced())
44 continue;
45
46
47=== modified file 'tribes/buildings/productionsites/atlanteans/shipyard/init.lua'
48--- tribes/buildings/productionsites/atlanteans/shipyard/init.lua 2015-10-31 12:11:44 +0000
49+++ tribes/buildings/productionsites/atlanteans/shipyard/init.lua 2015-11-27 15:18:43 +0000
50@@ -8,6 +8,7 @@
51 directory = dirname,
52 icon = dirname .. "menu.png",
53 size = "medium",
54+ needs_seafaring = true,
55
56 buildcost = {
57 log = 3,
58
59=== modified file 'tribes/buildings/productionsites/barbarians/shipyard/init.lua'
60--- tribes/buildings/productionsites/barbarians/shipyard/init.lua 2015-10-31 12:11:44 +0000
61+++ tribes/buildings/productionsites/barbarians/shipyard/init.lua 2015-11-27 15:18:43 +0000
62@@ -8,6 +8,7 @@
63 directory = dirname,
64 icon = dirname .. "menu.png",
65 size = "medium",
66+ needs_seafaring = true,
67
68 buildcost = {
69 log = 3,
70@@ -74,7 +75,7 @@
71 -- TRANSLATORS: Completed/Skipped/Did not start constructing a ship because ...
72 descname = _"constructing a ship",
73 actions = {
74- "check_map=seafaring", -- TODO(GunChleoc): We should make this check on game creation as well and remove it from the allowed buildings
75+ "check_map=seafaring",
76 "construct=barbarians_shipconstruction buildship 6",
77 "animate=working 35000",
78 "return=completed"
79
80=== modified file 'tribes/buildings/productionsites/barbarians/weaving_mill/init.lua'
81--- tribes/buildings/productionsites/barbarians/weaving_mill/init.lua 2015-10-31 12:11:44 +0000
82+++ tribes/buildings/productionsites/barbarians/weaving_mill/init.lua 2015-11-27 15:18:43 +0000
83@@ -8,6 +8,7 @@
84 directory = dirname,
85 icon = dirname .. "menu.png",
86 size = "big",
87+ needs_seafaring = true,
88
89 buildcost = {
90 log = 5,
91@@ -58,6 +59,7 @@
92 descname = _"weaving",
93 actions = {
94 "sleep=20000",
95+ "check_map=seafaring",
96 "return=skipped unless economy needs cloth",
97 "consume=thatch_reed",
98 "animate=working 25000",
99
100=== modified file 'tribes/buildings/productionsites/empire/shipyard/init.lua'
101--- tribes/buildings/productionsites/empire/shipyard/init.lua 2015-10-31 12:11:44 +0000
102+++ tribes/buildings/productionsites/empire/shipyard/init.lua 2015-11-27 15:18:43 +0000
103@@ -8,6 +8,7 @@
104 directory = dirname,
105 icon = dirname .. "menu.png",
106 size = "medium",
107+ needs_seafaring = true,
108
109 buildcost = {
110 log = 3,

Subscribers

People subscribed via source and target branches

to status/vote changes: