Merge lp:~gunchleoc/widelands/mapobject_cleanup into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7112
Proposed branch: lp:~gunchleoc/widelands/mapobject_cleanup
Merge into: lp:widelands
Diff against target: 274 lines (+17/-53)
12 files modified
src/logic/building.cc (+0/-11)
src/logic/building.h (+0/-1)
src/logic/constructionsite.cc (+3/-3)
src/logic/dismantlesite.cc (+1/-1)
src/logic/partially_finished_building.cc (+0/-13)
src/logic/partially_finished_building.h (+0/-1)
src/logic/player.cc (+1/-1)
src/logic/soldier.cc (+5/-5)
src/logic/worker.cc (+3/-3)
src/logic/worker.h (+1/-11)
src/wui/buildingwindow.cc (+1/-1)
src/wui/productionsitewindow.cc (+2/-2)
To merge this branch: bzr merge lp:~gunchleoc/widelands/mapobject_cleanup
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+226804@code.launchpad.net

Description of the change

More Map_Object_Descr cleanup

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

Looks good.

review: Needs Fixing
Revision history for this message
SirVer (sirver) wrote :

... but couple of comments :).

review: Needs Fixing
Revision history for this message
GunChleoc (gunchleoc) wrote :

The first 2 comments are dealt with. For the last one, I need a code sample in https://bugs.launchpad.net/widelands/+bug/1203629

Revision history for this message
GunChleoc (gunchleoc) wrote :

Let's skip the last one and merge, since I'll take on the other bug anyway.

Revision history for this message
SirVer (sirver) :
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 2014-07-15 10:02:22 +0000
3+++ src/logic/building.cc 2014-07-17 09:17:25 +0000
4@@ -503,17 +503,6 @@
5 }
6
7
8-/*
9-===============
10-Building::get_ui_anim [virtual]
11-
12-Return the animation ID that is used for the building in UI items
13-(the building UI, messages, etc..)
14-===============
15-*/
16-uint32_t Building::get_ui_anim() const {return descr().get_ui_anim();}
17-
18-
19 #define FORMAT(key, value) case key: result << value; break
20 std::string Building::info_string(const std::string & format) {
21 std::ostringstream result;
22
23=== modified file 'src/logic/building.h'
24--- src/logic/building.h 2014-07-16 05:54:49 +0000
25+++ src/logic/building.h 2014-07-17 09:17:25 +0000
26@@ -186,7 +186,6 @@
27 char const * type_name() const override {return "building";}
28 virtual int32_t get_size () const override;
29 virtual bool get_passable() const override;
30- virtual uint32_t get_ui_anim () const;
31
32 virtual Flag & base_flag() override;
33 virtual uint32_t get_playercaps() const;
34
35=== modified file 'src/logic/constructionsite.cc'
36--- src/logic/constructionsite.cc 2014-07-15 10:02:22 +0000
37+++ src/logic/constructionsite.cc 2014-07-17 09:17:25 +0000
38@@ -245,7 +245,7 @@
39 if (static_cast<int32_t>(game.get_gametime() - m_work_steptime) < 0) {
40 worker.start_task_idle
41 (game,
42- worker.get_animation("work"),
43+ worker.descr().get_animation("work"),
44 m_work_steptime - game.get_gametime());
45 m_builder_idle = false;
46 return true;
47@@ -301,14 +301,14 @@
48 m_work_steptime = game.get_gametime() + CONSTRUCTIONSITE_STEP_TIME;
49
50 worker.start_task_idle
51- (game, worker.get_animation("work"), CONSTRUCTIONSITE_STEP_TIME);
52+ (game, worker.descr().get_animation("work"), CONSTRUCTIONSITE_STEP_TIME);
53 m_builder_idle = false;
54 return true;
55 }
56 }
57 // The only work we have got for you, is to run around to look cute ;)
58 if (!m_builder_idle) {
59- worker.set_animation(game, worker.get_animation("idle"));
60+ worker.set_animation(game, worker.descr().get_animation("idle"));
61 m_builder_idle = true;
62 }
63 worker.schedule_act(game, 2000);
64
65=== modified file 'src/logic/dismantlesite.cc'
66--- src/logic/dismantlesite.cc 2014-07-14 21:52:13 +0000
67+++ src/logic/dismantlesite.cc 2014-07-17 09:17:25 +0000
68@@ -220,7 +220,7 @@
69 } else if (not m_working) {
70 m_work_steptime = game.get_gametime() + DISMANTLESITE_STEP_TIME;
71 worker.start_task_idle
72- (game, worker.get_animation("work"), DISMANTLESITE_STEP_TIME);
73+ (game, worker.descr().get_animation("work"), DISMANTLESITE_STEP_TIME);
74
75 m_working = true;
76 }
77
78=== modified file 'src/logic/partially_finished_building.cc'
79--- src/logic/partially_finished_building.cc 2014-07-14 21:52:13 +0000
80+++ src/logic/partially_finished_building.cc 2014-07-17 09:17:25 +0000
81@@ -142,19 +142,6 @@
82
83 /*
84 ===============
85-Return the animation for the building that is in construction, as this
86-should be more useful to the player.
87-===============
88-*/
89-uint32_t Partially_Finished_Building::get_ui_anim() const
90-{
91- return m_building->get_animation("idle");
92-}
93-
94-
95-
96-/*
97-===============
98 Return the completion "percentage", where 2^16 = completely built,
99 0 = nothing built.
100 ===============
101
102=== modified file 'src/logic/partially_finished_building.h'
103--- src/logic/partially_finished_building.h 2014-07-05 16:41:51 +0000
104+++ src/logic/partially_finished_building.h 2014-07-17 09:17:25 +0000
105@@ -48,7 +48,6 @@
106
107 virtual int32_t get_size() const override;
108 virtual uint32_t get_playercaps() const override;
109- virtual uint32_t get_ui_anim() const override;
110
111 virtual void set_economy(Economy *) override;
112
113
114=== modified file 'src/logic/player.cc'
115--- src/logic/player.cc 2014-07-16 08:23:42 +0000
116+++ src/logic/player.cc 2014-07-17 09:17:25 +0000
117@@ -870,7 +870,7 @@
118 void Player::drop_soldier(PlayerImmovable & imm, Soldier & soldier) {
119 if (&imm.owner() != this)
120 return;
121- if (soldier.get_worker_type() != Worker_Descr::SOLDIER)
122+ if (soldier.descr().get_worker_type() != Worker_Descr::SOLDIER)
123 return;
124 if (upcast(SoldierControl, ctrl, &imm))
125 ctrl->dropSoldier(soldier);
126
127=== modified file 'src/logic/soldier.cc'
128--- src/logic/soldier.cc 2014-07-15 10:02:22 +0000
129+++ src/logic/soldier.cc 2014-07-17 09:17:25 +0000
130@@ -856,7 +856,7 @@
131 // We are at enemy building flag, and a defender is coming, sleep until he
132 // "wake up"s me
133 if (signal == "sleep") {
134- return start_task_idle(game, get_animation("idle"), -1);
135+ return start_task_idle(game, descr().get_animation("idle"), -1);
136 }
137
138 upcast(Building, location, get_location(game));
139@@ -964,7 +964,7 @@
140 // we check for a battle
141 // Note that we *should* be woken via sendSpaceSignals,
142 // so the timeout is just an additional safety net.
143- return start_task_idle(game, get_animation("idle"), 5000);
144+ return start_task_idle(game, descr().get_animation("idle"), 5000);
145 }
146
147 // Count remaining defenders
148@@ -1182,7 +1182,7 @@
149 // we check for a battle
150 // Note that we *should* be woken via sendSpaceSignals,
151 // so the timeout is just an additional safety net.
152- return start_task_idle(game, get_animation("idle"), 5000);
153+ return start_task_idle(game, descr().get_animation("idle"), 5000);
154
155 // If we only are defending our home ...
156 if (state.ivar1 & CF_DEFEND_STAYHOME) {
157@@ -1335,7 +1335,7 @@
158 }
159 }
160 // If the enemy is not in our land, wait
161- return start_task_idle(game, get_animation("idle"), 250);
162+ return start_task_idle(game, descr().get_animation("idle"), 250);
163 }
164
165 void Soldier::defense_pop(Game & game, State &)
166@@ -1454,7 +1454,7 @@
167 if (signal.size()) {
168 if (signal == "blocked") {
169 signal_handled();
170- return start_task_idle(game, get_animation("idle"), 5000);
171+ return start_task_idle(game, descr().get_animation("idle"), 5000);
172 } else if
173 (signal == "location" || signal == "battle" || signal == "wakeup")
174 signal_handled();
175
176=== modified file 'src/logic/worker.cc'
177--- src/logic/worker.cc 2014-07-16 08:23:42 +0000
178+++ src/logic/worker.cc 2014-07-17 09:17:25 +0000
179@@ -1137,7 +1137,7 @@
180
181 // NOTE we have to explicitly check Worker_Descr::SOLDIER, as SOLDIER is
182 // NOTE as well defined in an enum in instances.h
183- if (!m_economy || (get_worker_type() == Worker_Descr::SOLDIER)) {
184+ if (!m_economy || (descr().get_worker_type() == Worker_Descr::SOLDIER)) {
185 set_economy(eco);
186 } else if (m_economy != eco) {
187 throw wexception
188@@ -1447,7 +1447,7 @@
189 molog("[transfer]: Blocked by a battle\n");
190
191 signal_handled();
192- return start_task_idle(game, get_animation("idle"), 500);
193+ return start_task_idle(game, descr().get_animation("idle"), 500);
194 } else {
195 molog("[transfer]: Cancel due to signal '%s'\n", signal.c_str());
196 return pop_task(game);
197@@ -2051,7 +2051,7 @@
198 if (!m_supply)
199 m_supply = new IdleWorkerSupply(*this);
200
201- return start_task_idle(game, get_animation("idle"), 1000);
202+ return start_task_idle(game, descr().get_animation("idle"), 1000);
203 }
204
205 void Worker::gowarehouse_signalimmediate
206
207=== modified file 'src/logic/worker.h'
208--- src/logic/worker.h 2014-07-15 10:02:22 +0000
209+++ src/logic/worker.h 2014-07-17 09:17:25 +0000
210@@ -77,16 +77,9 @@
211 Worker(const Worker_Descr &);
212 virtual ~Worker();
213
214- virtual Worker_Descr::Worker_Type get_worker_type() const {
215- return descr().get_worker_type();
216- }
217 char const * type_name() const override {return "worker";}
218 virtual Bob::Type get_bob_type() const override {return Bob::WORKER;}
219
220- uint32_t get_animation(char const * const str) const {
221- return descr().get_animation(str);
222- }
223-
224 Player & owner() const {assert(get_owner()); return *get_owner();}
225 PlayerImmovable * get_location(Editor_Game_Base & egbase) {
226 return m_location.get(egbase);
227@@ -140,11 +133,8 @@
228 void create_needed_experience(Game &);
229 Ware_Index level (Game &);
230
231- int32_t get_needed_experience() const {
232- return descr().get_level_experience();
233- }
234 int32_t get_current_experience() const {return m_current_exp;}
235- bool needs_experience() const {return get_needed_experience() != -1;}
236+ bool needs_experience() const {return descr().get_level_experience() != -1;}
237
238 // debug
239 virtual void log_general_info(const Editor_Game_Base &) override;
240
241=== modified file 'src/wui/buildingwindow.cc'
242--- src/wui/buildingwindow.cc 2014-07-16 05:33:19 +0000
243+++ src/wui/buildingwindow.cc 2014-07-17 09:17:25 +0000
244@@ -115,7 +115,7 @@
245 {
246 UI::Window::draw(dst);
247
248- const Animation& anim = g_gr->animations().get_animation(building().get_ui_anim());
249+ const Animation& anim = g_gr->animations().get_animation(building().descr().get_ui_anim());
250
251 const Image* dark_frame = ImageTransformations::change_luminosity
252 (&anim.representative_image(building().owner().get_playercolor()), 1.22, true);
253
254=== modified file 'src/wui/productionsitewindow.cc'
255--- src/wui/productionsitewindow.cc 2014-07-15 10:02:22 +0000
256+++ src/wui/productionsitewindow.cc 2014-07-17 09:17:25 +0000
257@@ -168,7 +168,7 @@
258 if
259 (worker->get_current_experience() != -1
260 and
261- worker->get_needed_experience () != -1)
262+ worker->descr().get_level_experience () != -1)
263 {
264 assert(worker->descr().becomes() != Widelands::INVALID_INDEX);
265
266@@ -178,7 +178,7 @@
267 (buffer, sizeof(buffer),
268 "%i/%i",
269 worker->get_current_experience(),
270- worker->get_needed_experience());
271+ worker->descr().get_level_experience());
272
273 er.set_string(1, buffer);
274 er.set_string

Subscribers

People subscribed via source and target branches

to status/vote changes: