Merge lp:~widelands-dev/widelands/bug-1395278-tribes-a-p into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7809
Proposed branch: lp:~widelands-dev/widelands/bug-1395278-tribes-a-p
Merge into: lp:widelands
Diff against target: 3668 lines (+724/-724)
29 files modified
src/ai/defaultai.cc (+1/-1)
src/graphic/animation.cc (+6/-6)
src/graphic/diranimations.h (+4/-4)
src/logic/map_objects/tribes/battle.cc (+99/-99)
src/logic/map_objects/tribes/battle.h (+11/-11)
src/logic/map_objects/tribes/building.cc (+116/-116)
src/logic/map_objects/tribes/building.h (+50/-50)
src/logic/map_objects/tribes/carrier.cc (+23/-23)
src/logic/map_objects/tribes/carrier.h (+2/-2)
src/logic/map_objects/tribes/constructionsite.cc (+62/-62)
src/logic/map_objects/tribes/constructionsite.h (+5/-5)
src/logic/map_objects/tribes/dismantlesite.cc (+27/-27)
src/logic/map_objects/tribes/militarysite.cc (+114/-114)
src/logic/map_objects/tribes/militarysite.h (+26/-26)
src/logic/map_objects/tribes/partially_finished_building.cc (+29/-29)
src/logic/map_objects/tribes/partially_finished_building.h (+12/-12)
src/logic/map_objects/tribes/production_program.cc (+4/-4)
src/logic/map_objects/tribes/productionsite.cc (+1/-1)
src/logic/map_objects/tribes/warehouse.cc (+4/-4)
src/logic/player.cc (+5/-5)
src/logic/player.h (+1/-1)
src/map_io/map_building_packet.cc (+2/-2)
src/map_io/map_buildingdata_packet.cc (+86/-86)
src/scripting/lua_map.cc (+1/-1)
src/wui/building_ui.cc (+13/-13)
src/wui/buildingwindow.cc (+4/-4)
src/wui/fieldaction.cc (+1/-1)
src/wui/soldiercapacitycontrol.cc (+5/-5)
src/wui/soldierlist.cc (+10/-10)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1395278-tribes-a-p
Reviewer Review Type Date Requested Status
SirVer code Approve
Review via email: mp+285395@code.launchpad.net

Commit message

Fixed member variable names in src/logic/map_objects/tribes from battle - partially_finished_building.

Description of the change

Fixed member variable names in src/logic/map_objects/tribes from battle - partially_finished_building.

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

Continuous integration builds have changed state:

Travis build 638. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/107834812.
Appveyor build 494. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1395278_tribes_a_p-494.

Revision history for this message
SirVer (sirver) wrote :

lgtm.

@bunnybot merge

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2016-02-03 10:01:08 +0000
+++ src/ai/defaultai.cc 2016-02-08 18:17:36 +0000
@@ -3114,7 +3114,7 @@
31143114
3115 // Get max radius of recursive workarea3115 // Get max radius of recursive workarea
3116 WorkareaInfo::size_type radius = 0;3116 WorkareaInfo::size_type radius = 0;
3117 const WorkareaInfo& workarea_info = site.bo->desc->m_workarea_info;3117 const WorkareaInfo& workarea_info = site.bo->desc->workarea_info_;
3118 for (const std::pair<uint32_t, std::set<std::string>>& temp_info : workarea_info) {3118 for (const std::pair<uint32_t, std::set<std::string>>& temp_info : workarea_info) {
3119 if (radius < temp_info.first) {3119 if (radius < temp_info.first) {
3120 radius = temp_info.first;3120 radius = temp_info.first;
31213121
=== modified file 'src/graphic/animation.cc'
--- src/graphic/animation.cc 2016-01-28 05:24:34 +0000
+++ src/graphic/animation.cc 2016-02-08 18:17:36 +0000
@@ -299,12 +299,12 @@
299 uint32_t dir5,299 uint32_t dir5,
300 uint32_t dir6)300 uint32_t dir6)
301{301{
302 m_animations[0] = dir1;302 animations_[0] = dir1;
303 m_animations[1] = dir2;303 animations_[1] = dir2;
304 m_animations[2] = dir3;304 animations_[2] = dir3;
305 m_animations[3] = dir4;305 animations_[3] = dir4;
306 m_animations[4] = dir5;306 animations_[4] = dir5;
307 m_animations[5] = dir6;307 animations_[5] = dir6;
308}308}
309309
310/*310/*
311311
=== modified file 'src/graphic/diranimations.h'
--- src/graphic/diranimations.h 2016-01-17 19:54:32 +0000
+++ src/graphic/diranimations.h 2016-02-08 18:17:36 +0000
@@ -33,20 +33,20 @@
33 uint32_t dir4 = 0, uint32_t dir5 = 0, uint32_t dir6 = 0);33 uint32_t dir4 = 0, uint32_t dir5 = 0, uint32_t dir6 = 0);
3434
35 uint32_t get_animation(Widelands::Direction const dir) const {35 uint32_t get_animation(Widelands::Direction const dir) const {
36 return m_animations[dir - 1];36 return animations_[dir - 1];
37 }37 }
38 void set_animation(const Widelands::Direction dir, const uint32_t anim) {38 void set_animation(const Widelands::Direction dir, const uint32_t anim) {
39 m_animations[dir - 1] = anim;39 animations_[dir - 1] = anim;
40 }40 }
4141
42 static DirAnimations null() {42 static DirAnimations null() {
43 return DirAnimations(0); // Since real animation IDs are positive, this is safe43 return DirAnimations(0); // Since real animation IDs are positive, this is safe
44 }44 }
4545
46 operator bool() const {return m_animations[0];}46 operator bool() const {return animations_[0];}
4747
48private:48private:
49 uint32_t m_animations[6];49 uint32_t animations_[6];
50};50};
5151
52#endif // end of include guard: WL_GRAPHIC_DIRANIMATIONS_H52#endif // end of include guard: WL_GRAPHIC_DIRANIMATIONS_H
5353
=== modified file 'src/logic/map_objects/tribes/battle.cc'
--- src/logic/map_objects/tribes/battle.cc 2015-11-28 22:29:26 +0000
+++ src/logic/map_objects/tribes/battle.cc 2016-02-08 18:17:36 +0000
@@ -45,22 +45,22 @@
45Battle::Battle ()45Battle::Battle ()
46 :46 :
47 MapObject(&g_battle_descr),47 MapObject(&g_battle_descr),
48 m_first(nullptr),48 first_(nullptr),
49 m_second(nullptr),49 second_(nullptr),
50 m_creationtime(0),50 creationtime_(0),
51 m_readyflags(0),51 readyflags_(0),
52 m_damage(0),52 damage_(0),
53 m_first_strikes(true),53 first_strikes_(true),
54 m_last_attack_hits(false)54 last_attack_hits_(false)
55{}55{}
5656
57Battle::Battle(Game & game, Soldier & First, Soldier & Second) :57Battle::Battle(Game & game, Soldier & First, Soldier & Second) :
58 MapObject (&g_battle_descr),58 MapObject (&g_battle_descr),
59 m_first (&First),59 first_ (&First),
60 m_second (&Second),60 second_ (&Second),
61 m_readyflags (0),61 readyflags_ (0),
62 m_damage (0),62 damage_ (0),
63 m_first_strikes(true)63 first_strikes_(true)
64{64{
65 assert(First.get_owner() != Second.get_owner());65 assert(First.get_owner() != Second.get_owner());
66 {66 {
@@ -81,30 +81,30 @@
81{81{
82 MapObject::init(egbase);82 MapObject::init(egbase);
8383
84 m_creationtime = egbase.get_gametime();84 creationtime_ = egbase.get_gametime();
8585
86 Game& game = dynamic_cast<Game&>(egbase);86 Game& game = dynamic_cast<Game&>(egbase);
8787
88 if (Battle* battle = m_first ->get_battle()) {88 if (Battle* battle = first_ ->get_battle()) {
89 battle->cancel(game, *m_first);89 battle->cancel(game, *first_);
90 }90 }
91 m_first->set_battle(game, this);91 first_->set_battle(game, this);
92 if (Battle* battle = m_second->get_battle()) {92 if (Battle* battle = second_->get_battle()) {
93 battle->cancel(game, *m_second);93 battle->cancel(game, *second_);
94 }94 }
95 m_second->set_battle(game, this);95 second_->set_battle(game, this);
96}96}
9797
9898
99void Battle::cleanup (EditorGameBase & egbase)99void Battle::cleanup (EditorGameBase & egbase)
100{100{
101 if (m_first) {101 if (first_) {
102 m_first ->set_battle(dynamic_cast<Game&>(egbase), nullptr);102 first_ ->set_battle(dynamic_cast<Game&>(egbase), nullptr);
103 m_first = nullptr;103 first_ = nullptr;
104 }104 }
105 if (m_second) {105 if (second_) {
106 m_second->set_battle(dynamic_cast<Game&>(egbase), nullptr);106 second_->set_battle(dynamic_cast<Game&>(egbase), nullptr);
107 m_second = nullptr;107 second_ = nullptr;
108 }108 }
109109
110 MapObject::cleanup(egbase);110 MapObject::cleanup(egbase);
@@ -116,11 +116,11 @@
116 */116 */
117void Battle::cancel(Game & game, Soldier & soldier)117void Battle::cancel(Game & game, Soldier & soldier)
118{118{
119 if (&soldier == m_first) {119 if (&soldier == first_) {
120 m_first = nullptr;120 first_ = nullptr;
121 soldier.set_battle(game, nullptr);121 soldier.set_battle(game, nullptr);
122 } else if (&soldier == m_second) {122 } else if (&soldier == second_) {
123 m_second = nullptr;123 second_ = nullptr;
124 soldier.set_battle(game, nullptr);124 soldier.set_battle(game, nullptr);
125 } else125 } else
126 return;126 return;
@@ -131,17 +131,17 @@
131131
132bool Battle::locked(Game & game)132bool Battle::locked(Game & game)
133{133{
134 if (!m_first || !m_second)134 if (!first_ || !second_)
135 return false;135 return false;
136 if (game.get_gametime() - m_creationtime < 1000)136 if (game.get_gametime() - creationtime_ < 1000)
137 return true; // don't change battles around willy-nilly137 return true; // don't change battles around willy-nilly
138 return m_first->get_position() == m_second->get_position();138 return first_->get_position() == second_->get_position();
139}139}
140140
141Soldier * Battle::opponent(Soldier& soldier)141Soldier * Battle::opponent(Soldier& soldier)
142{142{
143 assert(m_first == &soldier || m_second == &soldier);143 assert(first_ == &soldier || second_ == &soldier);
144 Soldier* other_soldier = m_first == &soldier ? m_second : m_first;144 Soldier* other_soldier = first_ == &soldier ? second_ : first_;
145 return other_soldier;145 return other_soldier;
146}146}
147147
@@ -153,35 +153,35 @@
153void Battle::get_battle_work(Game & game, Soldier & soldier)153void Battle::get_battle_work(Game & game, Soldier & soldier)
154{154{
155 // Identify what soldier is calling the routine155 // Identify what soldier is calling the routine
156 uint8_t const this_soldier_is = &soldier == m_first ? 1 : 2;156 uint8_t const this_soldier_is = &soldier == first_ ? 1 : 2;
157157
158 assert(m_first->get_battle() == this || m_second->get_battle() == this);158 assert(first_->get_battle() == this || second_->get_battle() == this);
159159
160 // Created this four 'states' of the battle:160 // Created this four 'states' of the battle:
161 // *First time entered, one enters :161 // *First time entered, one enters :
162 // oneReadyToFight, mark m_readyflags as he is ready to fight162 // oneReadyToFight, mark readyflags_ as he is ready to fight
163 // *Next time, the opponent enters:163 // *Next time, the opponent enters:
164 // bothReadyToFight, mark m_readyflags as 3 (round fighted)164 // bothReadyToFight, mark readyflags_ as 3 (round fighted)
165 // *Next time, the first enters again:165 // *Next time, the first enters again:
166 // roundFought, reset m_readyflags166 // roundFought, reset readyflags_
167 // *Opponent not on field yet, so one enters :167 // *Opponent not on field yet, so one enters :
168 // waitingForOpponent, if others are false168 // waitingForOpponent, if others are false
169169
170 bool const oneReadyToFight = (m_readyflags == 0);170 bool const oneReadyToFight = (readyflags_ == 0);
171 bool const roundFought = (m_readyflags == 3);171 bool const roundFought = (readyflags_ == 3);
172 bool const bothReadyToFight = ((this_soldier_is | m_readyflags) == 3) &&172 bool const bothReadyToFight = ((this_soldier_is | readyflags_) == 3) &&
173 (!roundFought);173 (!roundFought);
174 bool const waitingForOpponent = !(oneReadyToFight || roundFought || bothReadyToFight);174 bool const waitingForOpponent = !(oneReadyToFight || roundFought || bothReadyToFight);
175 std::string what_anim;175 std::string what_anim;
176176
177 // Apply pending damage177 // Apply pending damage
178 if (m_damage && oneReadyToFight) {178 if (damage_ && oneReadyToFight) {
179 // Current attacker is last defender, so damage goes to current attacker179 // Current attacker is last defender, so damage goes to current attacker
180 if (m_first_strikes)180 if (first_strikes_)
181 m_first ->damage(m_damage);181 first_ ->damage(damage_);
182 else182 else
183 m_second->damage(m_damage);183 second_->damage(damage_);
184 m_damage = 0;184 damage_ = 0;
185 }185 }
186186
187 if (soldier.get_current_hitpoints() < 1) {187 if (soldier.get_current_hitpoints() < 1) {
@@ -194,15 +194,15 @@
194 return schedule_destroy(game);194 return schedule_destroy(game);
195 }195 }
196196
197 if (!m_first || !m_second)197 if (!first_ || !second_)
198 return soldier.skip_act();198 return soldier.skip_act();
199199
200 // Here is a timeout to prevent battle freezes200 // Here is a timeout to prevent battle freezes
201 if (waitingForOpponent && (game.get_gametime() - m_creationtime) > 90 * 1000) {201 if (waitingForOpponent && (game.get_gametime() - creationtime_) > 90 * 1000) {
202 molog("[battle] soldier %u waiting for opponent %u too long (%5d sec), cancelling battle...\n",202 molog("[battle] soldier %u waiting for opponent %u too long (%5d sec), cancelling battle...\n",
203 soldier.serial(),203 soldier.serial(),
204 opponent(soldier)->serial(),204 opponent(soldier)->serial(),
205 (game.get_gametime() - m_creationtime) / 1000);205 (game.get_gametime() - creationtime_) / 1000);
206 cancel(game, soldier);206 cancel(game, soldier);
207 return;207 return;
208 }208 }
@@ -220,9 +220,9 @@
220 //220 //
221 if (oneReadyToFight) {221 if (oneReadyToFight) {
222 // My opponent is not ready to battle. Idle until he wakes me up.222 // My opponent is not ready to battle. Idle until he wakes me up.
223 assert(m_readyflags == 0);223 assert(readyflags_ == 0);
224 m_readyflags = this_soldier_is;224 readyflags_ = this_soldier_is;
225 assert(m_readyflags == this_soldier_is);225 assert(readyflags_ == this_soldier_is);
226226
227 what_anim = this_soldier_is == 1 ?227 what_anim = this_soldier_is == 1 ?
228 "evade_success_e" :228 "evade_success_e" :
@@ -236,12 +236,12 @@
236 // Time for one of us to hurt the other. Which one is on turn is decided236 // Time for one of us to hurt the other. Which one is on turn is decided
237 // by calculate_round.237 // by calculate_round.
238 assert238 assert
239 ((m_readyflags == 1 && this_soldier_is == 2) ||239 ((readyflags_ == 1 && this_soldier_is == 2) ||
240 (m_readyflags == 2 && this_soldier_is == 1));240 (readyflags_ == 2 && this_soldier_is == 1));
241241
242 // Both are now ready, mark flags, so our opponent can get new animation242 // Both are now ready, mark flags, so our opponent can get new animation
243 m_readyflags = 3;243 readyflags_ = 3;
244 assert(m_readyflags == 3);244 assert(readyflags_ == 3);
245245
246 // Resolve combat turn246 // Resolve combat turn
247 calculate_round(game);247 calculate_round(game);
@@ -253,23 +253,23 @@
253 if (roundFought) {253 if (roundFought) {
254 // Both of us were already ready. That means that we already fought and254 // Both of us were already ready. That means that we already fought and
255 // it is time to wait until both become ready.255 // it is time to wait until both become ready.
256 m_readyflags = 0;256 readyflags_ = 0;
257 }257 }
258258
259 // The function calculate_round inverts value of m_first_strikes, so259 // The function calculate_round inverts value of first_strikes_, so
260 // attacker will be the m_first when m_first_strikes = false and260 // attacker will be the first_ when first_strikes_ = false and
261 // attacker will be m_second when m_first_strikes = true261 // attacker will be second_ when first_strikes_ = true
262 molog262 molog
263 ("[battle] (%u) vs (%u) is %d, first strikes %d, last hit %d\n",263 ("[battle] (%u) vs (%u) is %d, first strikes %d, last hit %d\n",
264 soldier.serial(),264 soldier.serial(),
265 opponent(soldier)->serial(),265 opponent(soldier)->serial(),
266 this_soldier_is,266 this_soldier_is,
267 m_first_strikes,267 first_strikes_,
268 m_last_attack_hits);268 last_attack_hits_);
269269
270 if (this_soldier_is == 1) {270 if (this_soldier_is == 1) {
271 if (m_first_strikes) {271 if (first_strikes_) {
272 if (m_last_attack_hits) {272 if (last_attack_hits_) {
273 what_anim = "evade_failure_e";273 what_anim = "evade_failure_e";
274 }274 }
275 else {275 else {
@@ -277,7 +277,7 @@
277 }277 }
278 }278 }
279 else {279 else {
280 if (m_last_attack_hits) {280 if (last_attack_hits_) {
281 what_anim = "attack_success_e";281 what_anim = "attack_success_e";
282 }282 }
283 else {283 else {
@@ -285,8 +285,8 @@
285 }285 }
286 }286 }
287 } else {287 } else {
288 if (m_first_strikes) {288 if (first_strikes_) {
289 if (m_last_attack_hits) {289 if (last_attack_hits_) {
290 what_anim = "attack_success_w";290 what_anim = "attack_success_w";
291 }291 }
292 else {292 else {
@@ -294,7 +294,7 @@
294 }294 }
295 }295 }
296 else {296 else {
297 if (m_last_attack_hits) {297 if (last_attack_hits_) {
298 what_anim = "evade_failure_w";298 what_anim = "evade_failure_w";
299 }299 }
300 else {300 else {
@@ -312,25 +312,25 @@
312312
313void Battle::calculate_round(Game & game)313void Battle::calculate_round(Game & game)
314{314{
315 assert(!m_damage);315 assert(!damage_);
316316
317 Soldier * attacker;317 Soldier * attacker;
318 Soldier * defender;318 Soldier * defender;
319319
320 if (m_first_strikes) {320 if (first_strikes_) {
321 attacker = m_first;321 attacker = first_;
322 defender = m_second;322 defender = second_;
323 } else {323 } else {
324 attacker = m_second;324 attacker = second_;
325 defender = m_first;325 defender = first_;
326 }326 }
327327
328 m_first_strikes = !m_first_strikes;328 first_strikes_ = !first_strikes_;
329329
330 uint32_t const hit = game.logic_rand() % 100;330 uint32_t const hit = game.logic_rand() % 100;
331 if (hit > defender->get_evade()) {331 if (hit > defender->get_evade()) {
332 // Attacker hits!332 // Attacker hits!
333 m_last_attack_hits = true;333 last_attack_hits_ = true;
334334
335 assert(attacker->get_min_attack() <= attacker->get_max_attack());335 assert(attacker->get_min_attack() <= attacker->get_max_attack());
336 uint32_t const attack =336 uint32_t const attack =
@@ -338,11 +338,11 @@
338 (game.logic_rand()338 (game.logic_rand()
339 %339 %
340 (1 + attacker->get_max_attack() - attacker->get_min_attack()));340 (1 + attacker->get_max_attack() - attacker->get_min_attack()));
341 m_damage = attack - (attack * defender->get_defense()) / 100;341 damage_ = attack - (attack * defender->get_defense()) / 100;
342 }342 }
343 else {343 else {
344 // Defender evaded344 // Defender evaded
345 m_last_attack_hits = false;345 last_attack_hits_ = false;
346 }346 }
347}347}
348348
@@ -363,12 +363,12 @@
363363
364 Battle & battle = get<Battle>();364 Battle & battle = get<Battle>();
365365
366 battle.m_creationtime = fr.signed_32();366 battle.creationtime_ = fr.signed_32();
367 battle.m_readyflags = fr.unsigned_8();367 battle.readyflags_ = fr.unsigned_8();
368 battle.m_first_strikes = fr.unsigned_8();368 battle.first_strikes_ = fr.unsigned_8();
369 battle.m_damage = fr.unsigned_32();369 battle.damage_ = fr.unsigned_32();
370 m_first = fr.unsigned_32();370 first_ = fr.unsigned_32();
371 m_second = fr.unsigned_32();371 second_ = fr.unsigned_32();
372}372}
373373
374void Battle::Loader::load_pointers()374void Battle::Loader::load_pointers()
@@ -376,17 +376,17 @@
376 Battle & battle = get<Battle>();376 Battle & battle = get<Battle>();
377 try {377 try {
378 MapObject::Loader::load_pointers();378 MapObject::Loader::load_pointers();
379 if (m_first)379 if (first_)
380 try {380 try {
381 battle.m_first = &mol().get<Soldier>(m_first);381 battle.first_ = &mol().get<Soldier>(first_);
382 } catch (const WException & e) {382 } catch (const WException & e) {
383 throw wexception("soldier 1 (%u): %s", m_first, e.what());383 throw wexception("soldier 1 (%u): %s", first_, e.what());
384 }384 }
385 if (m_second)385 if (second_)
386 try {386 try {
387 battle.m_second = &mol().get<Soldier>(m_second);387 battle.second_ = &mol().get<Soldier>(second_);
388 } catch (const WException & e) {388 } catch (const WException & e) {
389 throw wexception("soldier 2 (%u): %s", m_second, e.what());389 throw wexception("soldier 2 (%u): %s", second_, e.what());
390 }390 }
391 } catch (const WException & e) {391 } catch (const WException & e) {
392 throw wexception("battle: %s", e.what());392 throw wexception("battle: %s", e.what());
@@ -401,14 +401,14 @@
401401
402 MapObject::save(egbase, mos, fw);402 MapObject::save(egbase, mos, fw);
403403
404 fw.signed_32(m_creationtime);404 fw.signed_32(creationtime_);
405 fw.unsigned_8(m_readyflags);405 fw.unsigned_8(readyflags_);
406 fw.unsigned_8(m_first_strikes);406 fw.unsigned_8(first_strikes_);
407 fw.unsigned_32(m_damage);407 fw.unsigned_32(damage_);
408408
409 // And now, the serials of the soldiers !409 // And now, the serials of the soldiers !
410 fw.unsigned_32(m_first ? mos.get_object_file_index(*m_first) : 0);410 fw.unsigned_32(first_ ? mos.get_object_file_index(*first_) : 0);
411 fw.unsigned_32(m_second ? mos.get_object_file_index(*m_second) : 0);411 fw.unsigned_32(second_ ? mos.get_object_file_index(*second_) : 0);
412}412}
413413
414414
415415
=== modified file 'src/logic/map_objects/tribes/battle.h'
--- src/logic/map_objects/tribes/battle.h 2015-11-29 09:43:15 +0000
+++ src/logic/map_objects/tribes/battle.h 2016-02-08 18:17:36 +0000
@@ -66,8 +66,8 @@
66 bool locked(Game &);66 bool locked(Game &);
6767
68 // The two soldiers involved in this fight.68 // The two soldiers involved in this fight.
69 Soldier * first() {return m_first;}69 Soldier * first() {return first_;}
70 Soldier * second() {return m_second;}70 Soldier * second() {return second_;}
7171
72 // Returns the other soldier involved in this battle. CHECKs that the given72 // Returns the other soldier involved in this battle. CHECKs that the given
73 // soldier is participating in this battle. Can return nullptr, but I have73 // soldier is participating in this battle. Can return nullptr, but I have
@@ -83,41 +83,41 @@
83 virtual void load(FileRead &);83 virtual void load(FileRead &);
84 void load_pointers() override;84 void load_pointers() override;
8585
86 Serial m_first;86 Serial first_;
87 Serial m_second;87 Serial second_;
88 };88 };
8989
90 void calculate_round(Game &);90 void calculate_round(Game &);
9191
92 Soldier * m_first;92 Soldier * first_;
93 Soldier * m_second;93 Soldier * second_;
9494
95 /**95 /**
96 * Gametime when the battle was created.96 * Gametime when the battle was created.
97 */97 */
98 int32_t m_creationtime;98 int32_t creationtime_;
9999
100 /**100 /**
101 * 1 if only the first soldier is ready, 2 if only the second soldier101 * 1 if only the first soldier is ready, 2 if only the second soldier
102 * is ready, 3 if both are ready.102 * is ready, 3 if both are ready.
103 */103 */
104 uint8_t m_readyflags;104 uint8_t readyflags_;
105105
106 /**106 /**
107 * Damage pending to apply. Damage is applied at end of round so animations107 * Damage pending to apply. Damage is applied at end of round so animations
108 * can show current action.108 * can show current action.
109 */109 */
110 uint32_t m_damage;110 uint32_t damage_;
111111
112 /**112 /**
113 * \c true if the first soldier is the next to strike.113 * \c true if the first soldier is the next to strike.
114 */114 */
115 bool m_first_strikes;115 bool first_strikes_;
116116
117 /**117 /**
118 * \c true if the last turn attacker damaged his opponent118 * \c true if the last turn attacker damaged his opponent
119 */119 */
120 bool m_last_attack_hits;120 bool last_attack_hits_;
121};121};
122122
123}123}
124124
=== modified file 'src/logic/map_objects/tribes/building.cc'
--- src/logic/map_objects/tribes/building.cc 2016-02-07 09:30:20 +0000
+++ src/logic/map_objects/tribes/building.cc 2016-02-08 18:17:36 +0000
@@ -60,15 +60,15 @@
60 :60 :
61 MapObjectDescr(_type, table.get_string("name"), init_descname, table),61 MapObjectDescr(_type, table.get_string("name"), init_descname, table),
62 egbase_ (egbase),62 egbase_ (egbase),
63 m_buildable (false),63 buildable_ (false),
64 m_size (BaseImmovable::SMALL),64 size_ (BaseImmovable::SMALL),
65 m_mine (false),65 mine_ (false),
66 m_port (false),66 port_ (false),
67 m_enhancement (INVALID_INDEX),67 enhancement_ (INVALID_INDEX),
68 m_enhanced_from (INVALID_INDEX),68 enhanced_from_ (INVALID_INDEX),
69 m_enhanced_building(false),69 enhanced_building_(false),
70 m_hints (table.get_table("aihints")),70 hints_ (table.get_table("aihints")),
71 m_vision_range (0)71 vision_range_ (0)
72{72{
73 if (!is_animation_known("idle")) {73 if (!is_animation_known("idle")) {
74 throw GameDataError("Building %s has no idle animation", table.get_string("name").c_str());74 throw GameDataError("Building %s has no idle animation", table.get_string("name").c_str());
@@ -84,17 +84,17 @@
84 try {84 try {
85 const std::string size = table.get_string("size");85 const std::string size = table.get_string("size");
86 if (boost::iequals(size, "small")) {86 if (boost::iequals(size, "small")) {
87 m_size = BaseImmovable::SMALL;87 size_ = BaseImmovable::SMALL;
88 } else if (boost::iequals(size, "medium")) {88 } else if (boost::iequals(size, "medium")) {
89 m_size = BaseImmovable::MEDIUM;89 size_ = BaseImmovable::MEDIUM;
90 } else if (boost::iequals(size, "big")) {90 } else if (boost::iequals(size, "big")) {
91 m_size = BaseImmovable::BIG;91 size_ = BaseImmovable::BIG;
92 } else if (boost::iequals(size, "mine")) {92 } else if (boost::iequals(size, "mine")) {
93 m_size = BaseImmovable::SMALL;93 size_ = BaseImmovable::SMALL;
94 m_mine = true;94 mine_ = true;
95 } else if (boost::iequals(size, "port")) {95 } else if (boost::iequals(size, "port")) {
96 m_size = BaseImmovable::BIG;96 size_ = BaseImmovable::BIG;
97 m_port = true;97 port_ = true;
98 } else {98 } else {
99 throw GameDataError99 throw GameDataError
100 ("expected %s but found \"%s\"",100 ("expected %s but found \"%s\"",
@@ -106,7 +106,7 @@
106 }106 }
107107
108 // Parse build options108 // Parse build options
109 m_destructible = table.has_key("destructible") ? table.get_bool("destructible") : true;109 destructible_ = table.has_key("destructible") ? table.get_bool("destructible") : true;
110110
111 if (table.has_key("enhancement")) {111 if (table.has_key("enhancement")) {
112 const std::string enh = table.get_string("enhancement");112 const std::string enh = table.get_string("enhancement");
@@ -116,14 +116,14 @@
116 }116 }
117 DescriptionIndex const en_i = egbase_.tribes().building_index(enh);117 DescriptionIndex const en_i = egbase_.tribes().building_index(enh);
118 if (egbase_.tribes().building_exists(en_i)) {118 if (egbase_.tribes().building_exists(en_i)) {
119 m_enhancement = en_i;119 enhancement_ = en_i;
120120
121 // Merge the enhancements workarea info into this building's121 // Merge the enhancements workarea info into this building's
122 // workarea info.122 // workarea info.
123 const BuildingDescr * tmp_enhancement = egbase_.tribes().get_building_descr(en_i);123 const BuildingDescr * tmp_enhancement = egbase_.tribes().get_building_descr(en_i);
124 for (std::pair<uint32_t, std::set<std::string>> area : tmp_enhancement->m_workarea_info)124 for (std::pair<uint32_t, std::set<std::string>> area : tmp_enhancement->workarea_info_)
125 {125 {
126 std::set<std::string> & strs = m_workarea_info[area.first];126 std::set<std::string> & strs = workarea_info_[area.first];
127 for (std::string str : area.second)127 for (std::string str : area.second)
128 strs.insert(str);128 strs.insert(str);
129 }129 }
@@ -135,10 +135,10 @@
135 }135 }
136136
137 if (table.has_key("buildcost")) {137 if (table.has_key("buildcost")) {
138 m_buildable = true;138 buildable_ = true;
139 try {139 try {
140 m_buildcost = Buildcost(table.get_table("buildcost"), egbase_.tribes());140 buildcost_ = Buildcost(table.get_table("buildcost"), egbase_.tribes());
141 m_return_dismantle = Buildcost(table.get_table("return_on_dismantle"), egbase_.tribes());141 return_dismantle_ = Buildcost(table.get_table("return_on_dismantle"), egbase_.tribes());
142 } catch (const WException & e) {142 } catch (const WException & e) {
143 throw wexception143 throw wexception
144 ("A buildable building must define \"buildcost\" and \"return_on_dismantle\": %s",144 ("A buildable building must define \"buildcost\" and \"return_on_dismantle\": %s",
@@ -146,10 +146,10 @@
146 }146 }
147 }147 }
148 if (table.has_key("enhancement_cost")) {148 if (table.has_key("enhancement_cost")) {
149 m_enhanced_building = true;149 enhanced_building_ = true;
150 try {150 try {
151 m_enhance_cost = Buildcost(table.get_table("enhancement_cost"), egbase_.tribes());151 enhance_cost_ = Buildcost(table.get_table("enhancement_cost"), egbase_.tribes());
152 m_return_enhanced = Buildcost(table.get_table("return_on_dismantle_on_enhanced"), egbase_.tribes());152 return_enhanced_ = Buildcost(table.get_table("return_on_dismantle_on_enhanced"), egbase_.tribes());
153 } catch (const WException & e) {153 } catch (const WException & e) {
154 throw wexception154 throw wexception
155 ("An enhanced building must define \"enhancement_cost\""155 ("An enhanced building must define \"enhancement_cost\""
@@ -159,10 +159,10 @@
159159
160 helptext_script_ = table.get_string("helptext_script");160 helptext_script_ = table.get_string("helptext_script");
161161
162 m_needs_seafaring = table.has_key("needs_seafaring") ? table.get_bool("needs_seafaring") : false;162 needs_seafaring_ = table.has_key("needs_seafaring") ? table.get_bool("needs_seafaring") : false;
163163
164 if (table.has_key("vision_range")) {164 if (table.has_key("vision_range")) {
165 m_vision_range = table.get_int("vision_range");165 vision_range_ = table.get_int("vision_range");
166 }166 }
167}167}
168168
@@ -177,10 +177,10 @@
177 const177 const
178{178{
179 Building & b = construct ? create_constructionsite() : create_object();179 Building & b = construct ? create_constructionsite() : create_object();
180 b.m_position = pos;180 b.position_ = pos;
181 b.set_owner(&owner);181 b.set_owner(&owner);
182 for (DescriptionIndex idx : former_buildings) {182 for (DescriptionIndex idx : former_buildings) {
183 b.m_old_buildings.push_back(idx);183 b.old_buildings_.push_back(idx);
184 }184 }
185 if (loading) {185 if (loading) {
186 b.Building::init(egbase);186 b.Building::init(egbase);
@@ -192,7 +192,7 @@
192192
193193
194int32_t BuildingDescr::suitability(const Map &, FCoords const fc) const {194int32_t BuildingDescr::suitability(const Map &, FCoords const fc) const {
195 return m_size <= (fc.field->nodecaps() & Widelands::BUILDCAPS_SIZEMASK);195 return size_ <= (fc.field->nodecaps() & Widelands::BUILDCAPS_SIZEMASK);
196}196}
197197
198/**198/**
@@ -212,7 +212,7 @@
212 */212 */
213uint32_t BuildingDescr::vision_range() const213uint32_t BuildingDescr::vision_range() const
214{214{
215 return m_vision_range ? m_vision_range : get_conquers() + 4;215 return vision_range_ ? vision_range_ : get_conquers() + 4;
216}216}
217217
218218
@@ -244,18 +244,18 @@
244244
245Building::Building(const BuildingDescr & building_descr) :245Building::Building(const BuildingDescr & building_descr) :
246 PlayerImmovable(building_descr),246 PlayerImmovable(building_descr),
247 m_optionswindow(nullptr),247 optionswindow_(nullptr),
248 m_flag (nullptr),248 flag_ (nullptr),
249 m_anim(0),249 anim_(0),
250 m_animstart(0),250 animstart_(0),
251 m_leave_time(0),251 leave_time_(0),
252 m_defeating_player(0),252 defeating_player_(0),
253 m_seeing(false)253 seeing_(false)
254{}254{}
255255
256Building::~Building()256Building::~Building()
257{257{
258 if (m_optionswindow)258 if (optionswindow_)
259 hide_options();259 hide_options();
260}260}
261261
@@ -294,9 +294,9 @@
294 return false;294 return false;
295 };295 };
296296
297 m_leave_queue.erase(297 leave_queue_.erase(
298 std::remove_if(m_leave_queue.begin(), m_leave_queue.end(), should_be_deleted),298 std::remove_if(leave_queue_.begin(), leave_queue_.end(), should_be_deleted),
299 m_leave_queue.end());299 leave_queue_.end());
300}300}
301301
302int32_t Building::get_size() const {return descr().get_size();}302int32_t Building::get_size() const {return descr().get_size();}
@@ -305,7 +305,7 @@
305305
306Flag & Building::base_flag()306Flag & Building::base_flag()
307{307{
308 return *m_flag;308 return *flag_;
309}309}
310310
311311
@@ -331,8 +331,8 @@
331331
332void Building::start_animation(EditorGameBase & egbase, uint32_t const anim)332void Building::start_animation(EditorGameBase & egbase, uint32_t const anim)
333{333{
334 m_anim = anim;334 anim_ = anim;
335 m_animstart = egbase.get_gametime();335 animstart_ = egbase.get_gametime();
336}336}
337337
338/*338/*
@@ -349,29 +349,29 @@
349 Map & map = egbase.map();349 Map & map = egbase.map();
350 Coords neighb;350 Coords neighb;
351351
352 set_position(egbase, m_position);352 set_position(egbase, position_);
353353
354 if (get_size() == BIG) {354 if (get_size() == BIG) {
355 map.get_ln(m_position, &neighb);355 map.get_ln(position_, &neighb);
356 set_position(egbase, neighb);356 set_position(egbase, neighb);
357357
358 map.get_tln(m_position, &neighb);358 map.get_tln(position_, &neighb);
359 set_position(egbase, neighb);359 set_position(egbase, neighb);
360360
361 map.get_trn(m_position, &neighb);361 map.get_trn(position_, &neighb);
362 set_position(egbase, neighb);362 set_position(egbase, neighb);
363 }363 }
364364
365 // Make sure the flag is there365 // Make sure the flag is there
366366
367367
368 map.get_brn(m_position, &neighb);368 map.get_brn(position_, &neighb);
369 {369 {
370 Flag * flag = dynamic_cast<Flag *>(map.get_immovable(neighb));370 Flag * flag = dynamic_cast<Flag *>(map.get_immovable(neighb));
371 if (!flag)371 if (!flag)
372 flag =372 flag =
373 new Flag (egbase, owner(), neighb);373 new Flag (egbase, owner(), neighb);
374 m_flag = flag;374 flag_ = flag;
375 flag->attach_building(egbase, *this);375 flag->attach_building(egbase, *this);
376 }376 }
377377
@@ -381,14 +381,14 @@
381 else381 else
382 start_animation(egbase, descr().get_animation("idle"));382 start_animation(egbase, descr().get_animation("idle"));
383383
384 m_leave_time = egbase.get_gametime();384 leave_time_ = egbase.get_gametime();
385}385}
386386
387387
388void Building::cleanup(EditorGameBase & egbase)388void Building::cleanup(EditorGameBase & egbase)
389{389{
390 if (m_defeating_player) {390 if (defeating_player_) {
391 Player & defeating_player = egbase.player(m_defeating_player);391 Player & defeating_player = egbase.player(defeating_player_);
392 if (descr().get_conquers()) {392 if (descr().get_conquers()) {
393 owner() .count_msite_lost ();393 owner() .count_msite_lost ();
394 defeating_player.count_msite_defeated ();394 defeating_player.count_msite_defeated ();
@@ -399,22 +399,22 @@
399 }399 }
400400
401 // Remove from flag401 // Remove from flag
402 m_flag->detach_building(egbase);402 flag_->detach_building(egbase);
403403
404 // Unset the building404 // Unset the building
405 unset_position(egbase, m_position);405 unset_position(egbase, position_);
406406
407 if (get_size() == BIG) {407 if (get_size() == BIG) {
408 Map & map = egbase.map();408 Map & map = egbase.map();
409 Coords neighb;409 Coords neighb;
410410
411 map.get_ln(m_position, &neighb);411 map.get_ln(position_, &neighb);
412 unset_position(egbase, neighb);412 unset_position(egbase, neighb);
413413
414 map.get_tln(m_position, &neighb);414 map.get_tln(position_, &neighb);
415 unset_position(egbase, neighb);415 unset_position(egbase, neighb);
416416
417 map.get_trn(m_position, &neighb);417 map.get_trn(position_, &neighb);
418 unset_position(egbase, neighb);418 unset_position(egbase, neighb);
419 }419 }
420420
@@ -447,18 +447,18 @@
447{447{
448 PositionList rv;448 PositionList rv;
449449
450 rv.push_back(m_position);450 rv.push_back(position_);
451 if (get_size() == BIG) {451 if (get_size() == BIG) {
452 Map & map = egbase.map();452 Map & map = egbase.map();
453 Coords neighb;453 Coords neighb;
454454
455 map.get_ln(m_position, &neighb);455 map.get_ln(position_, &neighb);
456 rv.push_back(neighb);456 rv.push_back(neighb);
457457
458 map.get_tln(m_position, &neighb);458 map.get_tln(position_, &neighb);
459 rv.push_back(neighb);459 rv.push_back(neighb);
460460
461 map.get_trn(m_position, &neighb);461 map.get_trn(position_, &neighb);
462 rv.push_back(neighb);462 rv.push_back(neighb);
463 }463 }
464 return rv;464 return rv;
@@ -474,7 +474,7 @@
474void Building::destroy(EditorGameBase & egbase)474void Building::destroy(EditorGameBase & egbase)
475{475{
476 const bool fire = burn_on_destroy();476 const bool fire = burn_on_destroy();
477 const Coords pos = m_position;477 const Coords pos = position_;
478 PlayerImmovable::destroy(egbase);478 PlayerImmovable::destroy(egbase);
479 // We are deleted. Only use stack variables beyond this point479 // We are deleted. Only use stack variables beyond this point
480 if (fire)480 if (fire)
@@ -541,24 +541,24 @@
541 */541 */
542bool Building::leave_check_and_wait(Game & game, Worker & w)542bool Building::leave_check_and_wait(Game & game, Worker & w)
543{543{
544 if (&w == m_leave_allow.get(game)) {544 if (&w == leave_allow_.get(game)) {
545 m_leave_allow = nullptr;545 leave_allow_ = nullptr;
546 return true;546 return true;
547 }547 }
548548
549 // Check time and queue549 // Check time and queue
550 uint32_t const time = game.get_gametime();550 uint32_t const time = game.get_gametime();
551551
552 if (m_leave_queue.empty()) {552 if (leave_queue_.empty()) {
553 if (m_leave_time <= time) {553 if (leave_time_ <= time) {
554 m_leave_time = time + BUILDING_LEAVE_INTERVAL;554 leave_time_ = time + BUILDING_LEAVE_INTERVAL;
555 return true;555 return true;
556 }556 }
557557
558 schedule_act(game, m_leave_time - time);558 schedule_act(game, leave_time_ - time);
559 }559 }
560560
561 m_leave_queue.push_back(&w);561 leave_queue_.push_back(&w);
562 return false;562 return false;
563}563}
564564
@@ -574,10 +574,10 @@
574void Building::leave_skip(Game &, Worker & w)574void Building::leave_skip(Game &, Worker & w)
575{575{
576 LeaveQueue::iterator const it =576 LeaveQueue::iterator const it =
577 std::find(m_leave_queue.begin(), m_leave_queue.end(), &w);577 std::find(leave_queue_.begin(), leave_queue_.end(), &w);
578578
579 if (it != m_leave_queue.end())579 if (it != leave_queue_.end())
580 m_leave_queue.erase(it);580 leave_queue_.erase(it);
581}581}
582582
583583
@@ -590,31 +590,31 @@
590{590{
591 uint32_t const time = game.get_gametime();591 uint32_t const time = game.get_gametime();
592592
593 if (m_leave_time <= time) {593 if (leave_time_ <= time) {
594 bool wakeup = false;594 bool wakeup = false;
595595
596 // Wake up one worker596 // Wake up one worker
597 while (!m_leave_queue.empty()) {597 while (!leave_queue_.empty()) {
598 upcast(Worker, worker, m_leave_queue[0].get(game));598 upcast(Worker, worker, leave_queue_[0].get(game));
599599
600 m_leave_queue.erase(m_leave_queue.begin());600 leave_queue_.erase(leave_queue_.begin());
601601
602 if (worker) {602 if (worker) {
603 m_leave_allow = worker;603 leave_allow_ = worker;
604604
605 if (worker->wakeup_leave_building(game, *this)) {605 if (worker->wakeup_leave_building(game, *this)) {
606 m_leave_time = time + BUILDING_LEAVE_INTERVAL;606 leave_time_ = time + BUILDING_LEAVE_INTERVAL;
607 wakeup = true;607 wakeup = true;
608 break;608 break;
609 }609 }
610 }610 }
611 }611 }
612612
613 if (!m_leave_queue.empty())613 if (!leave_queue_.empty())
614 schedule_act(game, m_leave_time - time);614 schedule_act(game, leave_time_ - time);
615615
616 if (!wakeup)616 if (!wakeup)
617 m_leave_time = time; // make sure leave_time doesn't get too far behind617 leave_time_ = time; // make sure leave_time doesn't get too far behind
618 }618 }
619619
620 PlayerImmovable::act(game, data);620 PlayerImmovable::act(game, data);
@@ -647,9 +647,9 @@
647void Building::draw647void Building::draw
648 (const EditorGameBase& game, RenderTarget& dst, const FCoords& coords, const Point& pos)648 (const EditorGameBase& game, RenderTarget& dst, const FCoords& coords, const Point& pos)
649{649{
650 if (coords == m_position) { // draw big buildings only once650 if (coords == position_) { // draw big buildings only once
651 dst.blit_animation(651 dst.blit_animation(
652 pos, m_anim, game.get_gametime() - m_animstart, get_owner()->get_playercolor());652 pos, anim_, game.get_gametime() - animstart_, get_owner()->get_playercolor());
653653
654 // door animation?654 // door animation?
655655
@@ -699,8 +699,8 @@
699 // if priority is defined for specific ware,699 // if priority is defined for specific ware,
700 // combine base priority and ware priority700 // combine base priority and ware priority
701 std::map<DescriptionIndex, int32_t>::const_iterator it =701 std::map<DescriptionIndex, int32_t>::const_iterator it =
702 m_ware_priorities.find(ware_index);702 ware_priorities_.find(ware_index);
703 if (it != m_ware_priorities.end())703 if (it != ware_priorities_.end())
704 priority = adjust704 priority = adjust
705 ? (priority * it->second / DEFAULT_PRIORITY)705 ? (priority * it->second / DEFAULT_PRIORITY)
706 : it->second;706 : it->second;
@@ -716,11 +716,11 @@
716void Building::collect_priorities716void Building::collect_priorities
717 (std::map<int32_t, std::map<DescriptionIndex, int32_t> > & p) const717 (std::map<int32_t, std::map<DescriptionIndex, int32_t> > & p) const
718{718{
719 if (m_ware_priorities.empty())719 if (ware_priorities_.empty())
720 return;720 return;
721 std::map<DescriptionIndex, int32_t> & ware_priorities = p[wwWARE];721 std::map<DescriptionIndex, int32_t> & ware_priorities = p[wwWARE];
722 std::map<DescriptionIndex, int32_t>::const_iterator it;722 std::map<DescriptionIndex, int32_t>::const_iterator it;
723 for (it = m_ware_priorities.begin(); it != m_ware_priorities.end(); ++it) {723 for (it = ware_priorities_.begin(); it != ware_priorities_.end(); ++it) {
724 if (it->second == DEFAULT_PRIORITY)724 if (it->second == DEFAULT_PRIORITY)
725 continue;725 continue;
726 ware_priorities[it->first] = it->second;726 ware_priorities[it->first] = it->second;
@@ -736,7 +736,7 @@
736 int32_t const new_priority)736 int32_t const new_priority)
737{737{
738 if (type == wwWARE) {738 if (type == wwWARE) {
739 m_ware_priorities[ware_index] = new_priority;739 ware_priorities_[ware_index] = new_priority;
740 }740 }
741}741}
742742
@@ -744,21 +744,21 @@
744void Building::log_general_info(const EditorGameBase & egbase) {744void Building::log_general_info(const EditorGameBase & egbase) {
745 PlayerImmovable::log_general_info(egbase);745 PlayerImmovable::log_general_info(egbase);
746746
747 molog("m_position: (%i, %i)\n", m_position.x, m_position.y);747 molog("position: (%i, %i)\n", position_.x, position_.y);
748 molog("m_flag: %p\n", m_flag);748 molog("flag: %p\n", flag_);
749 molog749 molog
750 ("* position: (%i, %i)\n",750 ("* position: (%i, %i)\n",
751 m_flag->get_position().x, m_flag->get_position().y);751 flag_->get_position().x, flag_->get_position().y);
752752
753 molog("m_anim: %s\n", descr().get_animation_name(m_anim).c_str());753 molog("anim: %s\n", descr().get_animation_name(anim_).c_str());
754 molog("m_animstart: %i\n", m_animstart);754 molog("animstart: %i\n", animstart_);
755755
756 molog("m_leave_time: %i\n", m_leave_time);756 molog("leave_time: %i\n", leave_time_);
757757
758 molog758 molog
759 ("m_leave_queue.size(): %lu\n",759 ("leave_queue.size(): %lu\n",
760 static_cast<long unsigned int>(m_leave_queue.size()));760 static_cast<long unsigned int>(leave_queue_.size()));
761 molog("m_leave_allow.get(): %p\n", m_leave_allow.get(egbase));761 molog("leave_allow.get(): %p\n", leave_allow_.get(egbase));
762}762}
763763
764764
@@ -788,7 +788,7 @@
788 */788 */
789void Building::set_seeing(bool see)789void Building::set_seeing(bool see)
790{790{
791 if (see == m_seeing)791 if (see == seeing_)
792 return;792 return;
793793
794 Player & player = owner();794 Player & player = owner();
@@ -801,7 +801,7 @@
801 player.unsee_area801 player.unsee_area
802 (Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));802 (Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range()));
803803
804 m_seeing = see;804 seeing_ = see;
805}805}
806806
807/**807/**
808808
=== modified file 'src/logic/map_objects/tribes/building.h'
--- src/logic/map_objects/tribes/building.h 2016-02-02 12:47:45 +0000
+++ src/logic/map_objects/tribes/building.h 2016-02-08 18:17:36 +0000
@@ -66,43 +66,43 @@
66 const LuaTable& t, const EditorGameBase& egbase);66 const LuaTable& t, const EditorGameBase& egbase);
67 ~BuildingDescr() override {}67 ~BuildingDescr() override {}
6868
69 bool is_buildable () const {return m_buildable;}69 bool is_buildable () const {return buildable_;}
70 bool is_destructible() const {return m_destructible;}70 bool is_destructible() const {return destructible_;}
71 bool is_enhanced () const {return m_enhanced_building;}71 bool is_enhanced () const {return enhanced_building_;}
7272
73 /**73 /**
74 * The build cost for direct construction74 * The build cost for direct construction
75 */75 */
76 const Buildcost & buildcost() const {return m_buildcost;}76 const Buildcost & buildcost() const {return buildcost_;}
7777
78 /**78 /**
79 * Returned wares for dismantling79 * Returned wares for dismantling
80 */80 */
81 const Buildcost & returned_wares() const {return m_return_dismantle;}81 const Buildcost & returned_wares() const {return return_dismantle_;}
8282
83 /**83 /**
84 * The build cost for enhancing a previous building84 * The build cost for enhancing a previous building
85 */85 */
86 const Buildcost & enhancement_cost() const {return m_enhance_cost;}86 const Buildcost & enhancement_cost() const {return enhance_cost_;}
8787
88 /**88 /**
89 * The returned wares for a enhaced building89 * The returned wares for a enhaced building
90 */90 */
91 const Buildcost & returned_wares_enhanced() const {return m_return_enhanced;}91 const Buildcost & returned_wares_enhanced() const {return return_enhanced_;}
9292
93 std::string helptext_script() const {return helptext_script_;}93 std::string helptext_script() const {return helptext_script_;}
94 int32_t get_size() const {return m_size;}94 int32_t get_size() const {return size_;}
95 bool get_ismine() const {return m_mine;}95 bool get_ismine() const {return mine_;}
96 bool get_isport() const {return m_port;}96 bool get_isport() const {return port_;}
97 bool needs_seafaring() const {return m_needs_seafaring;}97 bool needs_seafaring() const {return needs_seafaring_;}
9898
99 // Returns the enhancement this building can become or99 // Returns the enhancement this building can become or
100 // INVALID_INDEX if it cannot be enhanced.100 // INVALID_INDEX if it cannot be enhanced.
101 const DescriptionIndex & enhancement() const {return m_enhancement;}101 const DescriptionIndex & enhancement() const {return enhancement_;}
102 // Returns the building from which this building can be enhanced or102 // Returns the building from which this building can be enhanced or
103 // INVALID_INDEX if it cannot be built as an enhanced building.103 // INVALID_INDEX if it cannot be built as an enhanced building.
104 const DescriptionIndex& enhanced_from() const {return m_enhanced_from;}104 const DescriptionIndex& enhanced_from() const {return enhanced_from_;}
105 void set_enhanced_from(const DescriptionIndex& index) {m_enhanced_from = index;}105 void set_enhanced_from(const DescriptionIndex& index) {enhanced_from_ = index;}
106106
107 /// Create a building of this type in the game. Calls init, which does107 /// Create a building of this type in the game. Calls init, which does
108 /// different things for different types of buildings (such as conquering108 /// different things for different types of buildings (such as conquering
@@ -123,10 +123,10 @@
123 virtual uint32_t get_conquers() const;123 virtual uint32_t get_conquers() const;
124 virtual uint32_t vision_range() const;124 virtual uint32_t vision_range() const;
125125
126 WorkareaInfo m_workarea_info;126 WorkareaInfo workarea_info_;
127127
128 virtual int32_t suitability(const Map &, FCoords) const;128 virtual int32_t suitability(const Map &, FCoords) const;
129 const BuildingHints & hints() const {return m_hints;}129 const BuildingHints & hints() const {return hints_;}
130130
131protected:131protected:
132 virtual Building & create_object() const = 0;132 virtual Building & create_object() const = 0;
@@ -134,24 +134,24 @@
134134
135private:135private:
136 const EditorGameBase& egbase_;136 const EditorGameBase& egbase_;
137 bool m_buildable; // the player can build this himself137 bool buildable_; // the player can build this himself
138 bool m_destructible; // the player can destruct this himself138 bool destructible_; // the player can destruct this himself
139 Buildcost m_buildcost;139 Buildcost buildcost_;
140 Buildcost m_return_dismantle; // Returned wares on dismantle140 Buildcost return_dismantle_; // Returned wares on dismantle
141 Buildcost m_enhance_cost; // cost for enhancing141 Buildcost enhance_cost_; // cost for enhancing
142 Buildcost m_return_enhanced; // Returned ware for dismantling an enhanced building142 Buildcost return_enhanced_; // Returned ware for dismantling an enhanced building
143 std::string helptext_script_; // The path and filename to the building's helptext script143 std::string helptext_script_; // The path and filename to the building's helptext script
144 int32_t m_size; // size of the building144 int32_t size_; // size of the building
145 bool m_mine;145 bool mine_;
146 bool m_port;146 bool port_;
147 bool m_needs_seafaring; // This building should only be built on seafaring maps.147 bool needs_seafaring_; // This building should only be built on seafaring maps.
148 DescriptionIndex m_enhancement;148 DescriptionIndex enhancement_;
149 DescriptionIndex m_enhanced_from; // The building this building was enhanced from, or INVALID_INDEX149 DescriptionIndex enhanced_from_; // The building this building was enhanced from, or INVALID_INDEX
150 bool m_enhanced_building; // if it is one, it is bulldozable150 bool enhanced_building_; // if it is one, it is bulldozable
151 BuildingHints m_hints; // hints (knowledge) for computer players151 BuildingHints hints_; // hints (knowledge) for computer players
152152
153 // for migration, 0 is the default, meaning get_conquers() + 4153 // for migration, 0 is the default, meaning get_conquers() + 4
154 uint32_t m_vision_range;154 uint32_t vision_range_;
155 DISALLOW_COPY_AND_ASSIGN(BuildingDescr);155 DISALLOW_COPY_AND_ASSIGN(BuildingDescr);
156};156};
157157
@@ -190,7 +190,7 @@
190 Flag & base_flag() override;190 Flag & base_flag() override;
191 virtual uint32_t get_playercaps() const;191 virtual uint32_t get_playercaps() const;
192192
193 virtual Coords get_position() const {return m_position;}193 virtual Coords get_position() const {return position_;}
194 PositionList get_positions (const EditorGameBase &) const override;194 PositionList get_positions (const EditorGameBase &) const override;
195195
196 std::string info_string(const InfoStringFormat& format);196 std::string info_string(const InfoStringFormat& format);
@@ -198,8 +198,8 @@
198 // Return the overlay string that is displayed on the map view when enabled198 // Return the overlay string that is displayed on the map view when enabled
199 // by the player.199 // by the player.
200 const std::string& update_and_get_statistics_string() {200 const std::string& update_and_get_statistics_string() {
201 update_statistics_string(&m_statistics_string);201 update_statistics_string(&statistics_string_);
202 return m_statistics_string;202 return statistics_string_;
203 }203 }
204204
205 /// \returns the queue for a ware type or \throws WException.205 /// \returns the queue for a ware type or \throws WException.
@@ -238,7 +238,7 @@
238 * be the one being dismantled.238 * be the one being dismantled.
239 */239 */
240 const FormerBuildings get_former_buildings() {240 const FormerBuildings get_former_buildings() {
241 return m_old_buildings;241 return old_buildings_;
242 }242 }
243243
244 void log_general_info(const EditorGameBase &) override;244 void log_general_info(const EditorGameBase &) override;
@@ -249,7 +249,7 @@
249249
250 /// Stores the PlayerNumber of the player who has defeated this building.250 /// Stores the PlayerNumber of the player who has defeated this building.
251 void set_defeating_player(PlayerNumber const player_number) {251 void set_defeating_player(PlayerNumber const player_number) {
252 m_defeating_player = player_number;252 defeating_player_ = player_number;
253 }253 }
254254
255 void add_worker(Worker &) override;255 void add_worker(Worker &) override;
@@ -287,35 +287,35 @@
287287
288 void set_seeing(bool see);288 void set_seeing(bool see);
289289
290 UI::Window * m_optionswindow;290 UI::Window * optionswindow_;
291 Coords m_position;291 Coords position_;
292 Flag * m_flag;292 Flag * flag_;
293293
294 uint32_t m_anim;294 uint32_t anim_;
295 int32_t m_animstart;295 int32_t animstart_;
296296
297 using LeaveQueue = std::vector<OPtr<Worker>>;297 using LeaveQueue = std::vector<OPtr<Worker>>;
298 LeaveQueue m_leave_queue; // FIFO queue of workers leaving the building298 LeaveQueue leave_queue_; // FIFO queue of workers leaving the building
299 uint32_t m_leave_time; // when to wake the next one from leave queue299 uint32_t leave_time_; // when to wake the next one from leave queue
300 ObjectPointer m_leave_allow; // worker that is allowed to leave now300 ObjectPointer leave_allow_; // worker that is allowed to leave now
301301
302 // The player who has defeated this building.302 // The player who has defeated this building.
303 PlayerNumber m_defeating_player;303 PlayerNumber defeating_player_;
304304
305 int32_t m_priority; // base priority305 int32_t priority_; // base priority
306 std::map<DescriptionIndex, int32_t> m_ware_priorities;306 std::map<DescriptionIndex, int32_t> ware_priorities_;
307307
308 /// Whether we see our vision_range area based on workers in the building308 /// Whether we see our vision_range area based on workers in the building
309 bool m_seeing;309 bool seeing_;
310310
311 // Signals connected for the option window311 // Signals connected for the option window
312 std::vector<boost::signals2::connection> options_window_connections;312 std::vector<boost::signals2::connection> options_window_connections;
313313
314 // The former buildings names, with the current one in last position.314 // The former buildings names, with the current one in last position.
315 FormerBuildings m_old_buildings;315 FormerBuildings old_buildings_;
316316
317private:317private:
318 std::string m_statistics_string;318 std::string statistics_string_;
319};319};
320320
321}321}
322322
=== modified file 'src/logic/map_objects/tribes/carrier.cc'
--- src/logic/map_objects/tribes/carrier.cc 2015-11-28 22:29:26 +0000
+++ src/logic/map_objects/tribes/carrier.cc 2016-02-08 18:17:36 +0000
@@ -53,7 +53,7 @@
5353
54 top_state().ivar1 = 0;54 top_state().ivar1 = 0;
5555
56 m_promised_pickup_to = NOONE;56 promised_pickup_to_ = NOONE;
57}57}
5858
5959
@@ -85,13 +85,13 @@
85 }85 }
8686
87 // Check for pending wares87 // Check for pending wares
88 if (m_promised_pickup_to == NOONE)88 if (promised_pickup_to_ == NOONE)
89 find_pending_ware(game);89 find_pending_ware(game);
9090
91 if (m_promised_pickup_to != NOONE) {91 if (promised_pickup_to_ != NOONE) {
92 if (state.ivar1) {92 if (state.ivar1) {
93 state.ivar1 = 0;93 state.ivar1 = 0;
94 return start_task_transport(game, m_promised_pickup_to);94 return start_task_transport(game, promised_pickup_to_);
95 } else {95 } else {
96 // Short delay before we move to pick up96 // Short delay before we move to pick up
97 state.ivar1 = 1;97 state.ivar1 = 1;
@@ -126,10 +126,10 @@
126 */126 */
127void Carrier::road_pop(Game & game, State & /* state */)127void Carrier::road_pop(Game & game, State & /* state */)
128{128{
129 if (m_promised_pickup_to != NOONE && get_location(game)) {129 if (promised_pickup_to_ != NOONE && get_location(game)) {
130 Road & road = dynamic_cast<Road&>(*get_location(game));130 Road & road = dynamic_cast<Road&>(*get_location(game));
131 Flag & flag = road.get_flag(static_cast<Road::FlagId>(m_promised_pickup_to));131 Flag & flag = road.get_flag(static_cast<Road::FlagId>(promised_pickup_to_));
132 Flag & otherflag = road.get_flag(static_cast<Road::FlagId>(m_promised_pickup_to ^ 1));132 Flag & otherflag = road.get_flag(static_cast<Road::FlagId>(promised_pickup_to_ ^ 1));
133133
134 flag.cancel_pickup(game, otherflag);134 flag.cancel_pickup(game, otherflag);
135 }135 }
@@ -274,7 +274,7 @@
274 int32_t const ivar1 = state.ivar1;274 int32_t const ivar1 = state.ivar1;
275 if (!start_task_walktoflag(game, ivar1)) {275 if (!start_task_walktoflag(game, ivar1)) {
276276
277 m_promised_pickup_to = NOONE;277 promised_pickup_to_ = NOONE;
278278
279 Road & road = dynamic_cast<Road&>(*get_location(game));279 Road & road = dynamic_cast<Road&>(*get_location(game));
280 Flag & flag = road.get_flag(static_cast<Road::FlagId>(ivar1));280 Flag & flag = road.get_flag(static_cast<Road::FlagId>(ivar1));
@@ -307,7 +307,7 @@
307 Road & road = dynamic_cast<Road&>(*get_location(game));307 Road & road = dynamic_cast<Road&>(*get_location(game));
308 Flag & flag = road.get_flag(static_cast<Road::FlagId>(state.ivar1 ^ 1));308 Flag & flag = road.get_flag(static_cast<Road::FlagId>(state.ivar1 ^ 1));
309309
310 if (m_promised_pickup_to == (state.ivar1 ^ 1)) {310 if (promised_pickup_to_ == (state.ivar1 ^ 1)) {
311 // If there's an ware we acked, we can drop ours even if the flag is311 // If there's an ware we acked, we can drop ours even if the flag is
312 // flooded312 // flooded
313 other =313 other =
@@ -319,13 +319,13 @@
319 ("[Carrier]: strange: acked ware from busy flag no longer "319 ("[Carrier]: strange: acked ware from busy flag no longer "
320 "present.\n");320 "present.\n");
321321
322 m_promised_pickup_to = NOONE;322 promised_pickup_to_ = NOONE;
323 set_animation(game, descr().get_animation("idle"));323 set_animation(game, descr().get_animation("idle"));
324 return schedule_act(game, 20);324 return schedule_act(game, 20);
325 }325 }
326326
327 state.ivar1 = m_promised_pickup_to;327 state.ivar1 = promised_pickup_to_;
328 m_promised_pickup_to = NOONE;328 promised_pickup_to_ = NOONE;
329 }329 }
330330
331 // Drop our ware331 // Drop our ware
@@ -382,7 +382,7 @@
382 Flag & otherflag = road.get_flag(static_cast<Road::FlagId>(state.ivar1));382 Flag & otherflag = road.get_flag(static_cast<Road::FlagId>(state.ivar1));
383383
384384
385 if (m_promised_pickup_to == (state.ivar1 ^ 1)) {385 if (promised_pickup_to_ == (state.ivar1 ^ 1)) {
386 // All is well, we already acked an ware that we can pick up386 // All is well, we already acked an ware that we can pick up
387 // from this flag387 // from this flag
388 return false;388 return false;
@@ -392,7 +392,7 @@
392 ("MO(%u): transport: overload exchange: flag %u is fucked up",392 ("MO(%u): transport: overload exchange: flag %u is fucked up",
393 serial(), flag.serial());393 serial(), flag.serial());
394394
395 m_promised_pickup_to = state.ivar1 ^ 1;395 promised_pickup_to_ = state.ivar1 ^ 1;
396 return false;396 return false;
397 } else if (!start_task_walktoflag(game, state.ivar1 ^ 1, true))397 } else if (!start_task_walktoflag(game, state.ivar1 ^ 1, true))
398 start_task_waitforcapacity(game, flag); // wait one node away398 start_task_waitforcapacity(game, flag); // wait one node away
@@ -411,7 +411,7 @@
411 State & state = top_state();411 State & state = top_state();
412412
413 // Check if we've already acked something413 // Check if we've already acked something
414 if (m_promised_pickup_to != NOONE)414 if (promised_pickup_to_ != NOONE)
415 return false;415 return false;
416416
417 // If we are currently in a transport.417 // If we are currently in a transport.
@@ -438,7 +438,7 @@
438 return false;438 return false;
439439
440 // Ack it if we haven't440 // Ack it if we haven't
441 m_promised_pickup_to = flag;441 promised_pickup_to_ = flag;
442442
443 if (state.task == &taskRoad)443 if (state.task == &taskRoad)
444 send_signal(game, "ware");444 send_signal(game, "ware");
@@ -450,7 +450,7 @@
450450
451451
452/**452/**
453 * Find a pending ware on one of the road's flags, ack it and set m_promised_pickup_to453 * Find a pending ware on one of the road's flags, ack it and set promised_pickup_to_
454 * accordingly.454 * accordingly.
455 */455 */
456void Carrier::find_pending_ware(Game & game)456void Carrier::find_pending_ware(Game & game)
@@ -458,7 +458,7 @@
458 Road & road = dynamic_cast<Road&>(*get_location(game));458 Road & road = dynamic_cast<Road&>(*get_location(game));
459 uint32_t havewarebits = 0;459 uint32_t havewarebits = 0;
460460
461 assert(m_promised_pickup_to == NOONE);461 assert(promised_pickup_to_ == NOONE);
462462
463 if (road.get_flag(Road::FlagStart).has_pending_ware463 if (road.get_flag(Road::FlagStart).has_pending_ware
464 (game, road.get_flag(Road::FlagEnd))) {464 (game, road.get_flag(Road::FlagEnd))) {
@@ -477,7 +477,7 @@
477477
478 // Ack our decision478 // Ack our decision
479 if (havewarebits == 1) {479 if (havewarebits == 1) {
480 m_promised_pickup_to = START_FLAG;480 promised_pickup_to_ = START_FLAG;
481 if481 if
482 (!482 (!
483 road.get_flag(Road::FlagStart).ack_pickup483 road.get_flag(Road::FlagStart).ack_pickup
@@ -486,7 +486,7 @@
486 ("Carrier::find_pending_ware: start flag is messed up");486 ("Carrier::find_pending_ware: start flag is messed up");
487487
488 } else if (havewarebits == 2) {488 } else if (havewarebits == 2) {
489 m_promised_pickup_to = END_FLAG;489 promised_pickup_to_ = END_FLAG;
490 if490 if
491 (!491 (!
492 road.get_flag(Road::FlagEnd).ack_pickup492 road.get_flag(Road::FlagEnd).ack_pickup
@@ -575,7 +575,7 @@
575575
576 Worker::log_general_info(egbase);576 Worker::log_general_info(egbase);
577577
578 molog("m_promised_pickup_to = %i\n", m_promised_pickup_to);578 molog("promised_pickup_to = %i\n", promised_pickup_to_);
579}579}
580580
581/*581/*
@@ -601,7 +601,7 @@
601 uint8_t packet_version = fr.unsigned_8();601 uint8_t packet_version = fr.unsigned_8();
602 if (packet_version == kCurrentPacketVersion) {602 if (packet_version == kCurrentPacketVersion) {
603 Carrier & carrier = get<Carrier>();603 Carrier & carrier = get<Carrier>();
604 carrier.m_promised_pickup_to = fr.signed_32();604 carrier.promised_pickup_to_ = fr.signed_32();
605 } else {605 } else {
606 throw UnhandledVersionError("Carrier", packet_version, kCurrentPacketVersion);606 throw UnhandledVersionError("Carrier", packet_version, kCurrentPacketVersion);
607 }607 }
@@ -628,7 +628,7 @@
628 Worker::do_save(egbase, mos, fw);628 Worker::do_save(egbase, mos, fw);
629629
630 fw.unsigned_8(kCurrentPacketVersion);630 fw.unsigned_8(kCurrentPacketVersion);
631 fw.signed_32(m_promised_pickup_to);631 fw.signed_32(promised_pickup_to_);
632}632}
633633
634/**634/**
635635
=== modified file 'src/logic/map_objects/tribes/carrier.h'
--- src/logic/map_objects/tribes/carrier.h 2016-01-31 15:31:00 +0000
+++ src/logic/map_objects/tribes/carrier.h 2016-02-08 18:17:36 +0000
@@ -48,7 +48,7 @@
48 MO_DESCR(CarrierDescr)48 MO_DESCR(CarrierDescr)
4949
50 Carrier(const CarrierDescr & carrier_descr)50 Carrier(const CarrierDescr & carrier_descr)
51 : Worker(carrier_descr), m_promised_pickup_to(NOONE)51 : Worker(carrier_descr), promised_pickup_to_(NOONE)
52 {}52 {}
53 virtual ~Carrier() {}53 virtual ~Carrier() {}
5454
@@ -86,7 +86,7 @@
86 static const int32_t NOONE = -1;86 static const int32_t NOONE = -1;
87 static const int32_t START_FLAG = 0;87 static const int32_t START_FLAG = 0;
88 static const int32_t END_FLAG = 1;88 static const int32_t END_FLAG = 1;
89 int32_t m_promised_pickup_to;89 int32_t promised_pickup_to_;
9090
91 // saving and loading91 // saving and loading
92protected:92protected:
9393
=== modified file 'src/logic/map_objects/tribes/constructionsite.cc'
--- src/logic/map_objects/tribes/constructionsite.cc 2016-01-17 19:54:32 +0000
+++ src/logic/map_objects/tribes/constructionsite.cc 2016-02-08 18:17:36 +0000
@@ -65,8 +65,8 @@
6565
66ConstructionSite::ConstructionSite(const ConstructionSiteDescr & cs_descr) :66ConstructionSite::ConstructionSite(const ConstructionSiteDescr & cs_descr) :
67PartiallyFinishedBuilding (cs_descr),67PartiallyFinishedBuilding (cs_descr),
68m_fetchfromflag (0),68fetchfromflag_ (0),
69m_builder_idle (false)69builder_idle_ (false)
70{}70{}
7171
7272
@@ -83,14 +83,14 @@
83=======83=======
84*/84*/
85WaresQueue & ConstructionSite::waresqueue(DescriptionIndex const wi) {85WaresQueue & ConstructionSite::waresqueue(DescriptionIndex const wi) {
86 for (WaresQueue * ware : m_wares) {86 for (WaresQueue * ware : wares_) {
87 if (ware->get_ware() == wi) {87 if (ware->get_ware() == wi) {
88 return *ware;88 return *ware;
89 }89 }
90 }90 }
91 throw wexception91 throw wexception
92 ("%s (%u) (building %s) has no WaresQueue for %u",92 ("%s (%u) (building %s) has no WaresQueue for %u",
93 descr().name().c_str(), serial(), m_building->name().c_str(), wi);93 descr().name().c_str(), serial(), building_->name().c_str(), wi);
94}94}
9595
9696
@@ -102,7 +102,7 @@
102void ConstructionSite::set_building(const BuildingDescr & building_descr) {102void ConstructionSite::set_building(const BuildingDescr & building_descr) {
103 PartiallyFinishedBuilding::set_building(building_descr);103 PartiallyFinishedBuilding::set_building(building_descr);
104104
105 m_info.becomes = &building_descr;105 info_.becomes = &building_descr;
106}106}
107107
108/*108/*
@@ -115,31 +115,31 @@
115 PartiallyFinishedBuilding::init(egbase);115 PartiallyFinishedBuilding::init(egbase);
116116
117 const std::map<DescriptionIndex, uint8_t> * buildcost;117 const std::map<DescriptionIndex, uint8_t> * buildcost;
118 if (!m_old_buildings.empty()) {118 if (!old_buildings_.empty()) {
119 // Enhancement119 // Enhancement
120 DescriptionIndex was_index = m_old_buildings.back();120 DescriptionIndex was_index = old_buildings_.back();
121 const BuildingDescr* was_descr = owner().tribe().get_building_descr(was_index);121 const BuildingDescr* was_descr = owner().tribe().get_building_descr(was_index);
122 m_info.was = was_descr;122 info_.was = was_descr;
123 buildcost = &m_building->enhancement_cost();123 buildcost = &building_->enhancement_cost();
124 } else {124 } else {
125 buildcost = &m_building->buildcost();125 buildcost = &building_->buildcost();
126 }126 }
127127
128 // TODO(unknown): figure out whether planing is necessary128 // TODO(unknown): figure out whether planing is necessary
129129
130 // initialize the wares queues130 // initialize the wares queues
131 size_t const buildcost_size = buildcost->size();131 size_t const buildcost_size = buildcost->size();
132 m_wares.resize(buildcost_size);132 wares_.resize(buildcost_size);
133 std::map<DescriptionIndex, uint8_t>::const_iterator it = buildcost->begin();133 std::map<DescriptionIndex, uint8_t>::const_iterator it = buildcost->begin();
134134
135 for (size_t i = 0; i < buildcost_size; ++i, ++it) {135 for (size_t i = 0; i < buildcost_size; ++i, ++it) {
136 WaresQueue & wq =136 WaresQueue & wq =
137 *(m_wares[i] = new WaresQueue(*this, it->first, it->second));137 *(wares_[i] = new WaresQueue(*this, it->first, it->second));
138138
139 wq.set_callback(ConstructionSite::wares_queue_callback, this);139 wq.set_callback(ConstructionSite::wares_queue_callback, this);
140 wq.set_consume_interval(CONSTRUCTIONSITE_STEP_TIME);140 wq.set_consume_interval(CONSTRUCTIONSITE_STEP_TIME);
141141
142 m_work_steps += it->second;142 work_steps_ += it->second;
143 }143 }
144}144}
145145
@@ -154,19 +154,19 @@
154{154{
155 PartiallyFinishedBuilding::cleanup(egbase);155 PartiallyFinishedBuilding::cleanup(egbase);
156156
157 if (m_work_steps <= m_work_completed) {157 if (work_steps_ <= work_completed_) {
158 // Put the real building in place158 // Put the real building in place
159 DescriptionIndex becomes_idx = owner().tribe().building_index(m_building->name());159 DescriptionIndex becomes_idx = owner().tribe().building_index(building_->name());
160 m_old_buildings.push_back(becomes_idx);160 old_buildings_.push_back(becomes_idx);
161 Building & b =161 Building & b =
162 m_building->create(egbase, owner(), m_position, false, false, m_old_buildings);162 building_->create(egbase, owner(), position_, false, false, old_buildings_);
163 if (Worker * const builder = m_builder.get(egbase)) {163 if (Worker * const builder = builder_.get(egbase)) {
164 builder->reset_tasks(dynamic_cast<Game&>(egbase));164 builder->reset_tasks(dynamic_cast<Game&>(egbase));
165 builder->set_location(&b);165 builder->set_location(&b);
166 }166 }
167 // Open the new building window if needed167 // Open the new building window if needed
168 if (m_optionswindow) {168 if (optionswindow_) {
169 Point window_position = m_optionswindow->get_pos();169 Point window_position = optionswindow_->get_pos();
170 hide_options();170 hide_options();
171 InteractiveGameBase & igbase =171 InteractiveGameBase & igbase =
172 dynamic_cast<InteractiveGameBase&>(*egbase.get_ibase());172 dynamic_cast<InteractiveGameBase&>(*egbase.get_ibase());
@@ -183,10 +183,10 @@
183*/183*/
184bool ConstructionSite::burn_on_destroy()184bool ConstructionSite::burn_on_destroy()
185{185{
186 if (m_work_completed >= m_work_steps)186 if (work_completed_ >= work_steps_)
187 return false; // completed, so don't burn187 return false; // completed, so don't burn
188188
189 return m_work_completed || !m_old_buildings.empty();189 return work_completed_ || !old_buildings_.empty();
190}190}
191191
192/*192/*
@@ -196,9 +196,9 @@
196*/196*/
197bool ConstructionSite::fetch_from_flag(Game & game)197bool ConstructionSite::fetch_from_flag(Game & game)
198{198{
199 ++m_fetchfromflag;199 ++fetchfromflag_;
200200
201 if (Worker * const builder = m_builder.get(game))201 if (Worker * const builder = builder_.get(game))
202 builder->update_task_buildingwork(game);202 builder->update_task_buildingwork(game);
203203
204 return true;204 return true;
@@ -211,7 +211,7 @@
211===============211===============
212*/212*/
213bool ConstructionSite::get_building_work(Game & game, Worker & worker, bool) {213bool ConstructionSite::get_building_work(Game & game, Worker & worker, bool) {
214 if (&worker != m_builder.get(game)) {214 if (&worker != builder_.get(game)) {
215 // Not our construction worker; e.g. a miner leaving a mine215 // Not our construction worker; e.g. a miner leaving a mine
216 // that is supposed to be enhanced. Make him return to a warehouse216 // that is supposed to be enhanced. Make him return to a warehouse
217 worker.pop_task(game);217 worker.pop_task(game);
@@ -219,40 +219,40 @@
219 return true;219 return true;
220 }220 }
221221
222 if (!m_work_steps) // Happens for building without buildcost.222 if (!work_steps_) // Happens for building without buildcost.
223 schedule_destroy(game); // Complete the building immediately.223 schedule_destroy(game); // Complete the building immediately.
224224
225 // Check if one step has completed225 // Check if one step has completed
226 if (m_working) {226 if (working_) {
227 if (static_cast<int32_t>(game.get_gametime() - m_work_steptime) < 0) {227 if (static_cast<int32_t>(game.get_gametime() - work_steptime_) < 0) {
228 worker.start_task_idle228 worker.start_task_idle
229 (game,229 (game,
230 worker.descr().get_animation("work"),230 worker.descr().get_animation("work"),
231 m_work_steptime - game.get_gametime());231 work_steptime_ - game.get_gametime());
232 m_builder_idle = false;232 builder_idle_ = false;
233 return true;233 return true;
234 } else {234 } else {
235 //TODO(fweber): cause "construction sounds" to be played -235 //TODO(fweber): cause "construction sounds" to be played -
236 //perhaps dependent on kind of construction?236 //perhaps dependent on kind of construction?
237237
238 ++m_work_completed;238 ++work_completed_;
239 if (m_work_completed >= m_work_steps)239 if (work_completed_ >= work_steps_)
240 schedule_destroy(game);240 schedule_destroy(game);
241241
242 m_working = false;242 working_ = false;
243 }243 }
244 }244 }
245245
246 // Fetch wares from flag246 // Fetch wares from flag
247 if (m_fetchfromflag) {247 if (fetchfromflag_) {
248 --m_fetchfromflag;248 --fetchfromflag_;
249 m_builder_idle = false;249 builder_idle_ = false;
250 worker.start_task_fetchfromflag(game);250 worker.start_task_fetchfromflag(game);
251 return true;251 return true;
252 }252 }
253253
254 // Drop all the wares that are too much out to the flag.254 // Drop all the wares that are too much out to the flag.
255 for (WaresQueue * iqueue: m_wares) {255 for (WaresQueue * iqueue: wares_) {
256 WaresQueue * queue = iqueue;256 WaresQueue * queue = iqueue;
257 if (queue->get_filled() > queue->get_max_fill()) {257 if (queue->get_filled() > queue->get_max_fill()) {
258 queue->set_filled(queue->get_filled() - 1);258 queue->set_filled(queue->get_filled() - 1);
@@ -265,10 +265,10 @@
265 }265 }
266266
267 // Check if we've got wares to consume267 // Check if we've got wares to consume
268 if (m_work_completed < m_work_steps)268 if (work_completed_ < work_steps_)
269 {269 {
270 for (uint32_t i = 0; i < m_wares.size(); ++i) {270 for (uint32_t i = 0; i < wares_.size(); ++i) {
271 WaresQueue & wq = *m_wares[i];271 WaresQueue & wq = *wares_[i];
272272
273 if (!wq.get_filled())273 if (!wq.get_filled())
274 continue;274 continue;
@@ -279,19 +279,19 @@
279 //update consumption statistic279 //update consumption statistic
280 owner().ware_consumed(wq.get_ware(), 1);280 owner().ware_consumed(wq.get_ware(), 1);
281281
282 m_working = true;282 working_ = true;
283 m_work_steptime = game.get_gametime() + CONSTRUCTIONSITE_STEP_TIME;283 work_steptime_ = game.get_gametime() + CONSTRUCTIONSITE_STEP_TIME;
284284
285 worker.start_task_idle285 worker.start_task_idle
286 (game, worker.descr().get_animation("work"), CONSTRUCTIONSITE_STEP_TIME);286 (game, worker.descr().get_animation("work"), CONSTRUCTIONSITE_STEP_TIME);
287 m_builder_idle = false;287 builder_idle_ = false;
288 return true;288 return true;
289 }289 }
290 }290 }
291 // The only work we have got for you, is to run around to look cute ;)291 // The only work we have got for you, is to run around to look cute ;)
292 if (!m_builder_idle) {292 if (!builder_idle_) {
293 worker.set_animation(game, worker.descr().get_animation("idle"));293 worker.set_animation(game, worker.descr().get_animation("idle"));
294 m_builder_idle = true;294 builder_idle_ = true;
295 }295 }
296 worker.schedule_act(game, 2000);296 worker.schedule_act(game, 2000);
297 return true;297 return true;
@@ -308,8 +308,8 @@
308{308{
309 ConstructionSite & cs = *static_cast<ConstructionSite *>(data);309 ConstructionSite & cs = *static_cast<ConstructionSite *>(data);
310310
311 if (!cs.m_working)311 if (!cs.working_)
312 if (Worker * const builder = cs.m_builder.get(game))312 if (Worker * const builder = cs.builder_.get(game))
313 builder->update_task_buildingwork(game);313 builder->update_task_buildingwork(game);
314}314}
315315
@@ -323,27 +323,27 @@
323 (const EditorGameBase & game, RenderTarget & dst, const FCoords& coords, const Point& pos)323 (const EditorGameBase & game, RenderTarget & dst, const FCoords& coords, const Point& pos)
324{324{
325 const uint32_t gametime = game.get_gametime();325 const uint32_t gametime = game.get_gametime();
326 uint32_t tanim = gametime - m_animstart;326 uint32_t tanim = gametime - animstart_;
327327
328 if (coords != m_position)328 if (coords != position_)
329 return; // draw big buildings only once329 return; // draw big buildings only once
330330
331 // Draw the construction site marker331 // Draw the construction site marker
332 const RGBColor& player_color = get_owner()->get_playercolor();332 const RGBColor& player_color = get_owner()->get_playercolor();
333 dst.blit_animation(pos, m_anim, tanim, player_color);333 dst.blit_animation(pos, anim_, tanim, player_color);
334334
335 // Draw the partially finished building335 // Draw the partially finished building
336336
337 static_assert(0 <= CONSTRUCTIONSITE_STEP_TIME, "assert(0 <= CONSTRUCTIONSITE_STEP_TIME) failed.");337 static_assert(0 <= CONSTRUCTIONSITE_STEP_TIME, "assert(0 <= CONSTRUCTIONSITE_STEP_TIME) failed.");
338 m_info.totaltime = CONSTRUCTIONSITE_STEP_TIME * m_work_steps;338 info_.totaltime = CONSTRUCTIONSITE_STEP_TIME * work_steps_;
339 m_info.completedtime = CONSTRUCTIONSITE_STEP_TIME * m_work_completed;339 info_.completedtime = CONSTRUCTIONSITE_STEP_TIME * work_completed_;
340340
341 if (m_working) {341 if (working_) {
342 assert342 assert
343 (m_work_steptime343 (work_steptime_
344 <=344 <=
345 m_info.completedtime + CONSTRUCTIONSITE_STEP_TIME + gametime);345 info_.completedtime + CONSTRUCTIONSITE_STEP_TIME + gametime);
346 m_info.completedtime += CONSTRUCTIONSITE_STEP_TIME + gametime - m_work_steptime;346 info_.completedtime += CONSTRUCTIONSITE_STEP_TIME + gametime - work_steptime_;
347 }347 }
348348
349 uint32_t anim_idx;349 uint32_t anim_idx;
@@ -359,16 +359,16 @@
359 }359 }
360 const Animation& anim = g_gr->animations().get_animation(anim_idx);360 const Animation& anim = g_gr->animations().get_animation(anim_idx);
361 const size_t nr_frames = anim.nr_frames();361 const size_t nr_frames = anim.nr_frames();
362 cur_frame = m_info.totaltime ? m_info.completedtime * nr_frames / m_info.totaltime : 0;362 cur_frame = info_.totaltime ? info_.completedtime * nr_frames / info_.totaltime : 0;
363 // Redefine tanim363 // Redefine tanim
364 tanim = cur_frame * FRAME_LENGTH;364 tanim = cur_frame * FRAME_LENGTH;
365365
366 const uint16_t w = anim.width();366 const uint16_t w = anim.width();
367 const uint16_t h = anim.height();367 const uint16_t h = anim.height();
368368
369 uint32_t lines = h * m_info.completedtime * nr_frames;369 uint32_t lines = h * info_.completedtime * nr_frames;
370 if (m_info.totaltime)370 if (info_.totaltime)
371 lines /= m_info.totaltime;371 lines /= info_.totaltime;
372 assert(h * cur_frame <= lines);372 assert(h * cur_frame <= lines);
373 lines -= h * cur_frame; // This won't work if pictures have various sizes.373 lines -= h * cur_frame; // This won't work if pictures have various sizes.
374374
@@ -376,8 +376,8 @@
376 // draw the prev pic from top to where next image will be drawing376 // draw the prev pic from top to where next image will be drawing
377 dst.blit_animation(pos, anim_idx, tanim - FRAME_LENGTH, player_color,377 dst.blit_animation(pos, anim_idx, tanim - FRAME_LENGTH, player_color,
378 Rect(Point(0, 0), w, h - lines));378 Rect(Point(0, 0), w, h - lines));
379 } else if (!m_old_buildings.empty()) {379 } else if (!old_buildings_.empty()) {
380 DescriptionIndex prev_idx = m_old_buildings.back();380 DescriptionIndex prev_idx = old_buildings_.back();
381 const BuildingDescr* prev_building = owner().tribe().get_building_descr(prev_idx);381 const BuildingDescr* prev_building = owner().tribe().get_building_descr(prev_idx);
382 // Is the first picture but there was another building here before,382 // Is the first picture but there was another building here before,
383 // get its most fitting picture and draw it instead.383 // get its most fitting picture and draw it instead.
384384
=== modified file 'src/logic/map_objects/tribes/constructionsite.h'
--- src/logic/map_objects/tribes/constructionsite.h 2016-01-31 15:31:00 +0000
+++ src/logic/map_objects/tribes/constructionsite.h 2016-02-08 18:17:36 +0000
@@ -80,12 +80,12 @@
80public:80public:
81 ConstructionSite(const ConstructionSiteDescr & descr);81 ConstructionSite(const ConstructionSiteDescr & descr);
8282
83 const ConstructionsiteInformation & get_info() {return m_info;}83 const ConstructionsiteInformation & get_info() {return info_;}
8484
85 WaresQueue & waresqueue(DescriptionIndex) override;85 WaresQueue & waresqueue(DescriptionIndex) override;
8686
87 void set_building(const BuildingDescr &) override;87 void set_building(const BuildingDescr &) override;
88 const BuildingDescr & building() const {return *m_building;}88 const BuildingDescr & building() const {return *building_;}
8989
90 void init (EditorGameBase &) override;90 void init (EditorGameBase &) override;
91 void cleanup(EditorGameBase &) override;91 void cleanup(EditorGameBase &) override;
@@ -107,10 +107,10 @@
107 void draw(const EditorGameBase &, RenderTarget &, const FCoords&, const Point&) override;107 void draw(const EditorGameBase &, RenderTarget &, const FCoords&, const Point&) override;
108108
109private:109private:
110 int32_t m_fetchfromflag; // # of wares to fetch from flag110 int32_t fetchfromflag_; // # of wares to fetch from flag
111111
112 bool m_builder_idle; // used to determine whether the builder is idle112 bool builder_idle_; // used to determine whether the builder is idle
113 ConstructionsiteInformation m_info; // asked for by player point of view for the gameview113 ConstructionsiteInformation info_; // asked for by player point of view for the gameview
114};114};
115115
116}116}
117117
=== modified file 'src/logic/map_objects/tribes/dismantlesite.cc'
--- src/logic/map_objects/tribes/dismantlesite.cc 2016-01-17 19:54:32 +0000
+++ src/logic/map_objects/tribes/dismantlesite.cc 2016-02-08 18:17:36 +0000
@@ -68,14 +68,14 @@
68:68:
69PartiallyFinishedBuilding(gdescr)69PartiallyFinishedBuilding(gdescr)
70{70{
71 m_position = c;71 position_ = c;
72 set_owner(&plr);72 set_owner(&plr);
7373
74 assert(!former_buildings.empty());74 assert(!former_buildings.empty());
75 for (DescriptionIndex former_idx : former_buildings) {75 for (DescriptionIndex former_idx : former_buildings) {
76 m_old_buildings.push_back(former_idx);76 old_buildings_.push_back(former_idx);
77 }77 }
78 const BuildingDescr* cur_descr = owner().tribe().get_building_descr(m_old_buildings.back());78 const BuildingDescr* cur_descr = owner().tribe().get_building_descr(old_buildings_.back());
79 set_building(*cur_descr);79 set_building(*cur_descr);
8080
81 if (loading) {81 if (loading) {
@@ -109,14 +109,14 @@
109 count_returned_wares(this, wares);109 count_returned_wares(this, wares);
110110
111 std::map<DescriptionIndex, uint8_t>::const_iterator it = wares.begin();111 std::map<DescriptionIndex, uint8_t>::const_iterator it = wares.begin();
112 m_wares.resize(wares.size());112 wares_.resize(wares.size());
113113
114 for (size_t i = 0; i < wares.size(); ++i, ++it) {114 for (size_t i = 0; i < wares.size(); ++i, ++it) {
115 WaresQueue & wq =115 WaresQueue & wq =
116 *(m_wares[i] = new WaresQueue(*this, it->first, it->second));116 *(wares_[i] = new WaresQueue(*this, it->first, it->second));
117117
118 wq.set_filled(it->second);118 wq.set_filled(it->second);
119 m_work_steps += it->second;119 work_steps_ += it->second;
120 }120 }
121}121}
122122
@@ -154,7 +154,7 @@
154*/154*/
155bool DismantleSite::burn_on_destroy()155bool DismantleSite::burn_on_destroy()
156{156{
157 if (m_work_completed >= m_work_steps)157 if (work_completed_ >= work_steps_)
158 return false; // completed, so don't burn158 return false; // completed, so don't burn
159159
160 return true;160 return true;
@@ -166,7 +166,7 @@
166===============166===============
167*/167*/
168bool DismantleSite::get_building_work(Game & game, Worker & worker, bool) {168bool DismantleSite::get_building_work(Game & game, Worker & worker, bool) {
169 if (&worker != m_builder.get(game)) {169 if (&worker != builder_.get(game)) {
170 // Not our construction worker; e.g. a miner leaving a mine170 // Not our construction worker; e.g. a miner leaving a mine
171 // that is supposed to be enhanced. Make him return to a warehouse171 // that is supposed to be enhanced. Make him return to a warehouse
172 worker.pop_task(game);172 worker.pop_task(game);
@@ -174,15 +174,15 @@
174 return true;174 return true;
175 }175 }
176176
177 if (!m_work_steps) // Happens for building without buildcost.177 if (!work_steps_) // Happens for building without buildcost.
178 schedule_destroy(game); // Complete the building immediately.178 schedule_destroy(game); // Complete the building immediately.
179179
180 // Check if one step has completed180 // Check if one step has completed
181 if (static_cast<int32_t>(game.get_gametime() - m_work_steptime) >= 0 && m_working) {181 if (static_cast<int32_t>(game.get_gametime() - work_steptime_) >= 0 && working_) {
182 ++m_work_completed;182 ++work_completed_;
183183
184 for (uint32_t i = 0; i < m_wares.size(); ++i) {184 for (uint32_t i = 0; i < wares_.size(); ++i) {
185 WaresQueue & wq = *m_wares[i];185 WaresQueue & wq = *wares_[i];
186186
187 if (!wq.get_filled())187 if (!wq.get_filled())
188 continue;188 continue;
@@ -198,12 +198,12 @@
198 ware.init(game);198 ware.init(game);
199 worker.start_task_dropoff(game, ware);199 worker.start_task_dropoff(game, ware);
200200
201 m_working = false;201 working_ = false;
202 return true;202 return true;
203 }203 }
204 }204 }
205205
206 if (m_work_completed >= m_work_steps) {206 if (work_completed_ >= work_steps_) {
207 schedule_destroy(game);207 schedule_destroy(game);
208208
209 worker.pop_task(game);209 worker.pop_task(game);
@@ -214,12 +214,12 @@
214 worker.descr().get_right_walk_anims(false),214 worker.descr().get_right_walk_anims(false),
215 true);215 true);
216 worker.set_location(nullptr);216 worker.set_location(nullptr);
217 } else if (!m_working) {217 } else if (!working_) {
218 m_work_steptime = game.get_gametime() + DISMANTLESITE_STEP_TIME;218 work_steptime_ = game.get_gametime() + DISMANTLESITE_STEP_TIME;
219 worker.start_task_idle219 worker.start_task_idle
220 (game, worker.descr().get_animation("work"), DISMANTLESITE_STEP_TIME);220 (game, worker.descr().get_animation("work"), DISMANTLESITE_STEP_TIME);
221221
222 m_working = true;222 working_ = true;
223 }223 }
224 return true;224 return true;
225}225}
@@ -233,29 +233,29 @@
233 (const EditorGameBase& game, RenderTarget& dst, const FCoords& coords, const Point& pos)233 (const EditorGameBase& game, RenderTarget& dst, const FCoords& coords, const Point& pos)
234{234{
235 const uint32_t gametime = game.get_gametime();235 const uint32_t gametime = game.get_gametime();
236 uint32_t tanim = gametime - m_animstart;236 uint32_t tanim = gametime - animstart_;
237237
238 if (coords != m_position)238 if (coords != position_)
239 return; // draw big buildings only once239 return; // draw big buildings only once
240240
241 const RGBColor& player_color = get_owner()->get_playercolor();241 const RGBColor& player_color = get_owner()->get_playercolor();
242242
243 // Draw the construction site marker243 // Draw the construction site marker
244 dst.blit_animation(pos, m_anim, tanim, player_color);244 dst.blit_animation(pos, anim_, tanim, player_color);
245245
246 // Draw the partially dismantled building246 // Draw the partially dismantled building
247 static_assert(0 <= DISMANTLESITE_STEP_TIME, "assert(0 <= DISMANTLESITE_STEP_TIME) failed.");247 static_assert(0 <= DISMANTLESITE_STEP_TIME, "assert(0 <= DISMANTLESITE_STEP_TIME) failed.");
248 uint32_t total_time = DISMANTLESITE_STEP_TIME * m_work_steps;248 uint32_t total_time = DISMANTLESITE_STEP_TIME * work_steps_;
249 uint32_t completed_time = DISMANTLESITE_STEP_TIME * m_work_completed;249 uint32_t completed_time = DISMANTLESITE_STEP_TIME * work_completed_;
250250
251 if (m_working)251 if (working_)
252 completed_time += DISMANTLESITE_STEP_TIME + gametime - m_work_steptime;252 completed_time += DISMANTLESITE_STEP_TIME + gametime - work_steptime_;
253253
254 uint32_t anim_idx;254 uint32_t anim_idx;
255 try {255 try {
256 anim_idx = m_building->get_animation("unoccupied");256 anim_idx = building_->get_animation("unoccupied");
257 } catch (MapObjectDescr::AnimationNonexistent &) {257 } catch (MapObjectDescr::AnimationNonexistent &) {
258 anim_idx = m_building->get_animation("idle");258 anim_idx = building_->get_animation("idle");
259 }259 }
260 const Animation& anim = g_gr->animations().get_animation(anim_idx);260 const Animation& anim = g_gr->animations().get_animation(anim_idx);
261 const uint16_t w = anim.width();261 const uint16_t w = anim.width();
262262
=== modified file 'src/logic/map_objects/tribes/militarysite.cc'
--- src/logic/map_objects/tribes/militarysite.cc 2016-01-31 15:31:00 +0000
+++ src/logic/map_objects/tribes/militarysite.cc 2016-02-08 18:17:36 +0000
@@ -48,26 +48,26 @@
48 :48 :
49 BuildingDescr49 BuildingDescr
50 (init_descname, MapObjectType::MILITARYSITE, table, egbase),50 (init_descname, MapObjectType::MILITARYSITE, table, egbase),
51 m_conquer_radius (0),51 conquer_radius_ (0),
52 m_num_soldiers (0),52 num_soldiers_ (0),
53 m_heal_per_second (0)53 heal_per_second_ (0)
54{54{
55 i18n::Textdomain td("tribes");55 i18n::Textdomain td("tribes");
5656
57 m_conquer_radius = table.get_int("conquers");57 conquer_radius_ = table.get_int("conquers");
58 m_num_soldiers = table.get_int("max_soldiers");58 num_soldiers_ = table.get_int("max_soldiers");
59 m_heal_per_second = table.get_int("heal_per_second");59 heal_per_second_ = table.get_int("heal_per_second");
6060
61 if (m_conquer_radius > 0)61 if (conquer_radius_ > 0)
62 m_workarea_info[m_conquer_radius].insert(descname() + " conquer");62 workarea_info_[conquer_radius_].insert(descname() + " conquer");
63 m_prefers_heroes_at_start = table.get_bool("prefer_heroes");63 prefers_heroes_at_start_ = table.get_bool("prefer_heroes");
6464
65 std::unique_ptr<LuaTable> items_table = table.get_table("messages");65 std::unique_ptr<LuaTable> items_table = table.get_table("messages");
66 m_occupied_str = _(items_table->get_string("occupied"));66 occupied_str_ = _(items_table->get_string("occupied"));
67 m_aggressor_str = _(items_table->get_string("aggressor"));67 aggressor_str_ = _(items_table->get_string("aggressor"));
68 m_attack_str = _(items_table->get_string("attack"));68 attack_str_ = _(items_table->get_string("attack"));
69 m_defeated_enemy_str = _(items_table->get_string("defeated_enemy"));69 defeated_enemy_str_ = _(items_table->get_string("defeated_enemy"));
70 m_defeated_you_str = _(items_table->get_string("defeated_you"));70 defeated_you_str_ = _(items_table->get_string("defeated_you"));
71}71}
7272
73/**73/**
@@ -90,21 +90,21 @@
9090
91MilitarySite::MilitarySite(const MilitarySiteDescr & ms_descr) :91MilitarySite::MilitarySite(const MilitarySiteDescr & ms_descr) :
92Building(ms_descr),92Building(ms_descr),
93m_didconquer (false),93didconquer_ (false),
94m_capacity (ms_descr.get_max_number_of_soldiers()),94capacity_ (ms_descr.get_max_number_of_soldiers()),
95m_nexthealtime(0),95nexthealtime_(0),
96m_soldier_preference(ms_descr.m_prefers_heroes_at_start ? kPrefersHeroes : kPrefersRookies),96soldier_preference_(ms_descr.prefers_heroes_at_start_ ? kPrefersHeroes : kPrefersRookies),
97m_soldier_upgrade_try(false),97soldier_upgrade_try_(false),
98m_doing_upgrade_request(false)98doing_upgrade_request_(false)
99{99{
100 m_next_swap_soldiers_time = 0;100 next_swap_soldiers_time_ = 0;
101}101}
102102
103103
104MilitarySite::~MilitarySite()104MilitarySite::~MilitarySite()
105{105{
106 assert(!m_normal_soldier_request);106 assert(!normal_soldier_request_);
107 assert(!m_upgrade_soldier_request);107 assert(!upgrade_soldier_request_);
108}108}
109109
110110
@@ -120,25 +120,25 @@
120 uint32_t stationed = stationed_soldiers().size();120 uint32_t stationed = stationed_soldiers().size();
121121
122 if (present == stationed) {122 if (present == stationed) {
123 if (m_capacity > stationed) {123 if (capacity_ > stationed) {
124 /** TRANSLATORS: %1% is the number of soldiers the plural refers to */124 /** TRANSLATORS: %1% is the number of soldiers the plural refers to */
125 /** TRANSLATORS: %2% is the maximum number of soldier slots in the building */125 /** TRANSLATORS: %2% is the maximum number of soldier slots in the building */
126 *s += (boost::format(ngettext("%1% soldier (+%2%)",126 *s += (boost::format(ngettext("%1% soldier (+%2%)",
127 "%1% soldiers (+%2%)",127 "%1% soldiers (+%2%)",
128 stationed))128 stationed))
129 % stationed % (m_capacity - stationed)).str();129 % stationed % (capacity_ - stationed)).str();
130 } else {130 } else {
131 *s += (boost::format(ngettext("%u soldier", "%u soldiers", stationed))131 *s += (boost::format(ngettext("%u soldier", "%u soldiers", stationed))
132 % stationed).str();132 % stationed).str();
133 }133 }
134 } else {134 } else {
135 if (m_capacity > stationed) {135 if (capacity_ > stationed) {
136 /** TRANSLATORS: %1% is the number of soldiers the plural refers to */136 /** TRANSLATORS: %1% is the number of soldiers the plural refers to */
137 /** TRANSLATORS: %2% are currently open soldier slots in the building */137 /** TRANSLATORS: %2% are currently open soldier slots in the building */
138 /** TRANSLATORS: %3% is the maximum number of soldier slots in the building */138 /** TRANSLATORS: %3% is the maximum number of soldier slots in the building */
139 *s =139 *s =
140 (boost::format(ngettext("%1%(+%2%) soldier (+%3%)", "%1%(+%2%) soldiers (+%3%)", stationed))140 (boost::format(ngettext("%1%(+%2%) soldier (+%3%)", "%1%(+%2%) soldiers (+%3%)", stationed))
141 % present % (stationed - present) % (m_capacity - stationed)).str();141 % present % (stationed - present) % (capacity_ - stationed)).str();
142 } else {142 } else {
143 /** TRANSLATORS: %1% is the number of soldiers the plural refers to */143 /** TRANSLATORS: %1% is the number of soldiers the plural refers to */
144 /** TRANSLATORS: %2% are currently open soldier slots in the building */144 /** TRANSLATORS: %2% are currently open soldier slots in the building */
@@ -166,7 +166,7 @@
166 update_soldier_request();166 update_soldier_request();
167167
168 // schedule the first healing168 // schedule the first healing
169 m_nexthealtime = egbase.get_gametime() + 1000;169 nexthealtime_ = egbase.get_gametime() + 1000;
170 if (game)170 if (game)
171 schedule_act(*game, 1000);171 schedule_act(*game, 1000);
172}172}
@@ -182,10 +182,10 @@
182{182{
183 Building::set_economy(e);183 Building::set_economy(e);
184184
185 if (m_normal_soldier_request && e)185 if (normal_soldier_request_ && e)
186 m_normal_soldier_request->set_economy(e);186 normal_soldier_request_->set_economy(e);
187 if (m_upgrade_soldier_request && e)187 if (upgrade_soldier_request_ && e)
188 m_upgrade_soldier_request->set_economy(e);188 upgrade_soldier_request_->set_economy(e);
189}189}
190190
191/**191/**
@@ -196,25 +196,25 @@
196void MilitarySite::cleanup(EditorGameBase & egbase)196void MilitarySite::cleanup(EditorGameBase & egbase)
197{197{
198 // unconquer land198 // unconquer land
199 if (m_didconquer)199 if (didconquer_)
200 egbase.unconquer_area200 egbase.unconquer_area
201 (PlayerArea<Area<FCoords> >201 (PlayerArea<Area<FCoords> >
202 (owner().player_number(),202 (owner().player_number(),
203 Area<FCoords>203 Area<FCoords>
204 (egbase.map().get_fcoords(get_position()), descr().get_conquers())),204 (egbase.map().get_fcoords(get_position()), descr().get_conquers())),
205 m_defeating_player);205 defeating_player_);
206206
207 Building::cleanup(egbase);207 Building::cleanup(egbase);
208208
209 // Evict soldiers to get rid of requests209 // Evict soldiers to get rid of requests
210 while (m_capacity > 0) {210 while (capacity_ > 0) {
211 update_soldier_request();211 update_soldier_request();
212 --m_capacity;212 --capacity_;
213 }213 }
214 update_soldier_request();214 update_soldier_request();
215215
216 m_normal_soldier_request.reset();216 normal_soldier_request_.reset();
217 m_upgrade_soldier_request.reset();217 upgrade_soldier_request_.reset();
218}218}
219219
220220
@@ -246,7 +246,7 @@
246 return incorporate_upgraded_soldier(egbase, s) ? 0 : -1;246 return incorporate_upgraded_soldier(egbase, s) ? 0 : -1;
247 }247 }
248248
249 if (!m_didconquer) {249 if (!didconquer_) {
250 conquer_area(egbase);250 conquer_area(egbase);
251 // Building is now occupied - idle animation should be played251 // Building is now occupied - idle animation should be played
252 start_animation(egbase, descr().get_animation("idle"));252 start_animation(egbase, descr().get_animation("idle"));
@@ -258,7 +258,7 @@
258 descr().descname(),258 descr().descname(),
259 descr().icon_filename(),259 descr().icon_filename(),
260 descr().descname(),260 descr().descname(),
261 descr().m_occupied_str,261 descr().occupied_str_,
262 true);262 true);
263 }263 }
264 }264 }
@@ -285,7 +285,7 @@
285MilitarySite::find_least_suited_soldier()285MilitarySite::find_least_suited_soldier()
286{286{
287 const std::vector<Soldier *> present = present_soldiers();287 const std::vector<Soldier *> present = present_soldiers();
288 const int32_t multiplier = kPrefersHeroes == m_soldier_preference ? -1 : 1;288 const int32_t multiplier = kPrefersHeroes == soldier_preference_ ? -1 : 1;
289 int worst_soldier_level = INT_MIN;289 int worst_soldier_level = INT_MIN;
290 Soldier * worst_soldier = nullptr;290 Soldier * worst_soldier = nullptr;
291 for (Soldier* sld : present) {291 for (Soldier* sld : present) {
@@ -329,12 +329,12 @@
329 {329 {
330 int32_t old_level = kickoutCandidate->get_level(atrTotal);330 int32_t old_level = kickoutCandidate->get_level(atrTotal);
331 int32_t new_level = newguy->get_level(atrTotal);331 int32_t new_level = newguy->get_level(atrTotal);
332 if (kPrefersHeroes == m_soldier_preference && old_level >= new_level)332 if (kPrefersHeroes == soldier_preference_ && old_level >= new_level)
333 {333 {
334 return false;334 return false;
335 }335 }
336 else336 else
337 if (kPrefersRookies == m_soldier_preference && old_level <= new_level)337 if (kPrefersRookies == soldier_preference_ && old_level <= new_level)
338 {338 {
339 return false;339 return false;
340 }340 }
@@ -361,7 +361,7 @@
361MilitarySite::incorporate_upgraded_soldier(EditorGameBase & egbase, Soldier & s)361MilitarySite::incorporate_upgraded_soldier(EditorGameBase & egbase, Soldier & s)
362{362{
363 // Call to drop_least routine has side effects: it tries to drop a soldier. Order is important!363 // Call to drop_least routine has side effects: it tries to drop a soldier. Order is important!
364 if (stationed_soldiers().size() < m_capacity || drop_least_suited_soldier(true, &s))364 if (stationed_soldiers().size() < capacity_ || drop_least_suited_soldier(true, &s))
365 {365 {
366 Game & game = dynamic_cast<Game&>(egbase);366 Game & game = dynamic_cast<Game&>(egbase);
367 s.set_location(this);367 s.set_location(this);
@@ -400,25 +400,25 @@
400 std::vector<Soldier *> present = present_soldiers();400 std::vector<Soldier *> present = present_soldiers();
401 uint32_t const stationed = stationed_soldiers().size();401 uint32_t const stationed = stationed_soldiers().size();
402402
403 if (stationed < m_capacity) {403 if (stationed < capacity_) {
404 if (!m_normal_soldier_request) {404 if (!normal_soldier_request_) {
405 m_normal_soldier_request.reset405 normal_soldier_request_.reset
406 (new Request406 (new Request
407 (*this,407 (*this,
408 owner().tribe().soldier(),408 owner().tribe().soldier(),
409 MilitarySite::request_soldier_callback,409 MilitarySite::request_soldier_callback,
410 wwWORKER));410 wwWORKER));
411 m_normal_soldier_request->set_requirements (m_soldier_requirements);411 normal_soldier_request_->set_requirements (soldier_requirements_);
412 }412 }
413413
414 m_normal_soldier_request->set_count(m_capacity - stationed);414 normal_soldier_request_->set_count(capacity_ - stationed);
415 } else {415 } else {
416 m_normal_soldier_request.reset();416 normal_soldier_request_.reset();
417 }417 }
418418
419 if (m_capacity < present.size()) {419 if (capacity_ < present.size()) {
420 Game & game = dynamic_cast<Game&>(owner().egbase());420 Game & game = dynamic_cast<Game&>(owner().egbase());
421 for (uint32_t i = 0; i < present.size() - m_capacity; ++i) {421 for (uint32_t i = 0; i < present.size() - capacity_; ++i) {
422 Soldier & soldier = *present[i];422 Soldier & soldier = *present[i];
423 soldier.reset_tasks(game);423 soldier.reset_tasks(game);
424 soldier.start_task_leavebuilding(game, true);424 soldier.start_task_leavebuilding(game, true);
@@ -440,17 +440,17 @@
440void MilitarySite::update_upgrade_soldier_request()440void MilitarySite::update_upgrade_soldier_request()
441{441{
442 bool reqch = update_upgrade_requirements();442 bool reqch = update_upgrade_requirements();
443 if (!m_soldier_upgrade_try)443 if (!soldier_upgrade_try_)
444 return;444 return;
445445
446 bool do_rebuild_request = reqch;446 bool do_rebuild_request = reqch;
447447
448 if (m_upgrade_soldier_request)448 if (upgrade_soldier_request_)
449 {449 {
450 if (!m_upgrade_soldier_request->is_open())450 if (!upgrade_soldier_request_->is_open())
451 // If a replacement is already walking this way, let's not change our minds.451 // If a replacement is already walking this way, let's not change our minds.
452 do_rebuild_request = false;452 do_rebuild_request = false;
453 if (0 == m_upgrade_soldier_request->get_count())453 if (0 == upgrade_soldier_request_->get_count())
454 do_rebuild_request = true;454 do_rebuild_request = true;
455 }455 }
456 else456 else
@@ -458,15 +458,15 @@
458458
459 if (do_rebuild_request)459 if (do_rebuild_request)
460 {460 {
461 m_upgrade_soldier_request.reset461 upgrade_soldier_request_.reset
462 (new Request462 (new Request
463 (*this,463 (*this,
464 owner().tribe().soldier(),464 owner().tribe().soldier(),
465 MilitarySite::request_soldier_callback,465 MilitarySite::request_soldier_callback,
466 wwWORKER));466 wwWORKER));
467467
468 m_upgrade_soldier_request->set_requirements(m_soldier_upgrade_requirements);468 upgrade_soldier_request_->set_requirements(soldier_upgrade_requirements_);
469 m_upgrade_soldier_request->set_count(1);469 upgrade_soldier_request_->set_count(1);
470 }470 }
471}471}
472472
@@ -489,27 +489,27 @@
489 const uint32_t capacity = soldier_capacity();489 const uint32_t capacity = soldier_capacity();
490 const uint32_t stationed = stationed_soldiers().size();490 const uint32_t stationed = stationed_soldiers().size();
491491
492 if (m_doing_upgrade_request)492 if (doing_upgrade_request_)
493 {493 {
494 if (incd && m_upgrade_soldier_request) // update requests always ask for one soldier at time!494 if (incd && upgrade_soldier_request_) // update requests always ask for one soldier at time!
495 {495 {
496 m_upgrade_soldier_request.reset();496 upgrade_soldier_request_.reset();
497 }497 }
498 if (capacity > stationed)498 if (capacity > stationed)
499 {499 {
500 // Somebody is killing my soldiers in the middle of upgrade500 // Somebody is killing my soldiers in the middle of upgrade
501 // or I have kicked out his predecessor already.501 // or I have kicked out his predecessor already.
502 if (m_upgrade_soldier_request && (m_upgrade_soldier_request->is_open() ||502 if (upgrade_soldier_request_ && (upgrade_soldier_request_->is_open() ||
503 0 == m_upgrade_soldier_request->get_count())) {503 0 == upgrade_soldier_request_->get_count())) {
504504
505 // Economy was not able to find the soldiers I need.505 // Economy was not able to find the soldiers I need.
506 // I can safely drop the upgrade request and go to fill mode.506 // I can safely drop the upgrade request and go to fill mode.
507 m_upgrade_soldier_request.reset();507 upgrade_soldier_request_.reset();
508 }508 }
509 if (! m_upgrade_soldier_request)509 if (! upgrade_soldier_request_)
510 {510 {
511 //phoo -- I can safely request new soldiers.511 //phoo -- I can safely request new soldiers.
512 m_doing_upgrade_request = false;512 doing_upgrade_request_ = false;
513 update_normal_soldier_request();513 update_normal_soldier_request();
514 }514 }
515 // else -- ohno please help me! Player is in trouble -- evil grin515 // else -- ohno please help me! Player is in trouble -- evil grin
@@ -522,9 +522,9 @@
522 else // capacity == stationed size522 else // capacity == stationed size
523 {523 {
524 if524 if
525 (m_upgrade_soldier_request525 (upgrade_soldier_request_
526 && (!(m_upgrade_soldier_request->is_open()))526 && (!(upgrade_soldier_request_->is_open()))
527 && 1 == m_upgrade_soldier_request->get_count()527 && 1 == upgrade_soldier_request_->get_count()
528 && (!incd))528 && (!incd))
529 {529 {
530 drop_least_suited_soldier(false, nullptr);530 drop_least_suited_soldier(false, nullptr);
@@ -537,14 +537,14 @@
537 }537 }
538 else // not doing upgrade request538 else // not doing upgrade request
539 {539 {
540 if ((capacity != stationed) || (m_normal_soldier_request))540 if ((capacity != stationed) || (normal_soldier_request_))
541 update_normal_soldier_request();541 update_normal_soldier_request();
542542
543 if ((capacity == stationed) && (! m_normal_soldier_request))543 if ((capacity == stationed) && (! normal_soldier_request_))
544 {544 {
545 if (present_soldiers().size() == capacity)545 if (present_soldiers().size() == capacity)
546 {546 {
547 m_doing_upgrade_request = true;547 doing_upgrade_request_ = true;
548 update_upgrade_soldier_request();548 update_upgrade_soldier_request();
549 }549 }
550 // Note -- if there are non-present stationed soldiers, nothing gets550 // Note -- if there are non-present stationed soldiers, nothing gets
@@ -570,7 +570,7 @@
570 Building::act(game, data);570 Building::act(game, data);
571571
572 const int32_t timeofgame = game.get_gametime();572 const int32_t timeofgame = game.get_gametime();
573 if (m_normal_soldier_request && m_upgrade_soldier_request)573 if (normal_soldier_request_ && upgrade_soldier_request_)
574 {574 {
575 throw wexception("MilitarySite::act: Two soldier requests are ongoing -- should never happen!\n");575 throw wexception("MilitarySite::act: Two soldier requests are ongoing -- should never happen!\n");
576 }576 }
@@ -580,13 +580,13 @@
580 // to keep the game lightweight.580 // to keep the game lightweight.
581581
582 //TODO(unknown): I would need two new callbacks, to get rid ot this polling.582 //TODO(unknown): I would need two new callbacks, to get rid ot this polling.
583 if (timeofgame > m_next_swap_soldiers_time)583 if (timeofgame > next_swap_soldiers_time_)
584 {584 {
585 m_next_swap_soldiers_time = timeofgame + (m_soldier_upgrade_try ? 20000 : 100000);585 next_swap_soldiers_time_ = timeofgame + (soldier_upgrade_try_ ? 20000 : 100000);
586 update_soldier_request();586 update_soldier_request();
587 }587 }
588588
589 if (m_nexthealtime <= timeofgame) {589 if (nexthealtime_ <= timeofgame) {
590 uint32_t total_heal = descr().get_heal_per_second();590 uint32_t total_heal = descr().get_heal_per_second();
591 std::vector<Soldier *> soldiers = present_soldiers();591 std::vector<Soldier *> soldiers = present_soldiers();
592 uint32_t max_total_level = 0;592 uint32_t max_total_level = 0;
@@ -614,7 +614,7 @@
614 soldier_to_heal->heal(total_heal);614 soldier_to_heal->heal(total_heal);
615 }615 }
616616
617 m_nexthealtime = timeofgame + 1000;617 nexthealtime_ = timeofgame + 1000;
618 schedule_act(game, 1000);618 schedule_act(game, 1000);
619 }619 }
620}620}
@@ -644,7 +644,7 @@
644{644{
645 if (upcast(Soldier, soldier, &worker)) {645 if (upcast(Soldier, soldier, &worker)) {
646 // Evict soldiers that have returned home if the capacity is too low646 // Evict soldiers that have returned home if the capacity is too low
647 if (m_capacity < present_soldiers().size()) {647 if (capacity_ < present_soldiers().size()) {
648 worker.reset_tasks(game);648 worker.reset_tasks(game);
649 worker.start_task_leavebuilding(game, true);649 worker.start_task_leavebuilding(game, true);
650 return true;650 return true;
@@ -724,14 +724,14 @@
724}724}
725uint32_t MilitarySite::soldier_capacity() const725uint32_t MilitarySite::soldier_capacity() const
726{726{
727 return m_capacity;727 return capacity_;
728}728}
729729
730void MilitarySite::set_soldier_capacity(uint32_t const capacity) {730void MilitarySite::set_soldier_capacity(uint32_t const capacity) {
731 assert(min_soldier_capacity() <= capacity);731 assert(min_soldier_capacity() <= capacity);
732 assert (capacity <= max_soldier_capacity());732 assert (capacity <= max_soldier_capacity());
733 assert(m_capacity != capacity);733 assert(capacity_ != capacity);
734 m_capacity = capacity;734 capacity_ = capacity;
735 update_soldier_request();735 update_soldier_request();
736}736}
737737
@@ -758,19 +758,19 @@
758758
759759
760void MilitarySite::conquer_area(EditorGameBase & egbase) {760void MilitarySite::conquer_area(EditorGameBase & egbase) {
761 assert(!m_didconquer);761 assert(!didconquer_);
762 egbase.conquer_area762 egbase.conquer_area
763 (PlayerArea<Area<FCoords> >763 (PlayerArea<Area<FCoords> >
764 (owner().player_number(),764 (owner().player_number(),
765 Area<FCoords>765 Area<FCoords>
766 (egbase.map().get_fcoords(get_position()), descr().get_conquers())));766 (egbase.map().get_fcoords(get_position()), descr().get_conquers())));
767 m_didconquer = true;767 didconquer_ = true;
768}768}
769769
770770
771bool MilitarySite::can_attack()771bool MilitarySite::can_attack()
772{772{
773 return m_didconquer;773 return didconquer_;
774}774}
775775
776void MilitarySite::aggressor(Soldier & enemy)776void MilitarySite::aggressor(Soldier & enemy)
@@ -804,7 +804,7 @@
804 sj.soldier = temp_soldier;804 sj.soldier = temp_soldier;
805 sj.enemy = &enemy;805 sj.enemy = &enemy;
806 sj.stayhome = false;806 sj.stayhome = false;
807 m_soldierjobs.push_back(sj);807 soldierjobs_.push_back(sj);
808 temp_soldier->update_task_buildingwork(game);808 temp_soldier->update_task_buildingwork(game);
809 return;809 return;
810 }810 }
@@ -851,7 +851,7 @@
851 sj.soldier = defender;851 sj.soldier = defender;
852 sj.enemy = &enemy;852 sj.enemy = &enemy;
853 sj.stayhome = true;853 sj.stayhome = true;
854 m_soldierjobs.push_back(sj);854 soldierjobs_.push_back(sj);
855855
856 defender->update_task_buildingwork(game);856 defender->update_task_buildingwork(game);
857857
@@ -871,7 +871,7 @@
871 pgettext("building", "Lost!"),871 pgettext("building", "Lost!"),
872 descr().icon_filename(),872 descr().icon_filename(),
873 _("Militarysite lost!"),873 _("Militarysite lost!"),
874 descr().m_defeated_enemy_str,874 descr().defeated_enemy_str_,
875 false);875 false);
876 }876 }
877877
@@ -891,7 +891,7 @@
891 // In fact we do not conquer it, but place a new building of same type at891 // In fact we do not conquer it, but place a new building of same type at
892 // the old location.892 // the old location.
893893
894 Building::FormerBuildings former_buildings = m_old_buildings;894 Building::FormerBuildings former_buildings = old_buildings_;
895895
896 // The enemy conquers the building896 // The enemy conquers the building
897 // In fact we do not conquer it, but place a new building of same type at897 // In fact we do not conquer it, but place a new building of same type at
@@ -916,7 +916,7 @@
916 _("Enemy Defeated!"),916 _("Enemy Defeated!"),
917 newsite->descr().icon_filename(),917 newsite->descr().icon_filename(),
918 _("Enemy at site defeated!"),918 _("Enemy at site defeated!"),
919 newsite->descr().m_defeated_you_str,919 newsite->descr().defeated_you_str_,
920 true);920 true);
921921
922 return false;922 return false;
@@ -952,7 +952,7 @@
952 (this != militarysite &&952 (this != militarysite &&
953 &owner () == &militarysite->owner() &&953 &owner () == &militarysite->owner() &&
954 get_size() <= militarysite->get_size() &&954 get_size() <= militarysite->get_size() &&
955 militarysite->m_didconquer)955 militarysite->didconquer_)
956 return true;956 return true;
957 return false;957 return false;
958}958}
@@ -969,7 +969,7 @@
969 pgettext("building", "Attack!"),969 pgettext("building", "Attack!"),
970 descr().icon_filename(),970 descr().icon_filename(),
971 _("You are under attack"),971 _("You are under attack"),
972 discovered ? descr().m_aggressor_str : descr().m_attack_str,972 discovered ? descr().aggressor_str_ : descr().attack_str_,
973 false,973 false,
974 60 * 1000, 5);974 60 * 1000, 5);
975}975}
@@ -982,7 +982,7 @@
982*/982*/
983void MilitarySite::set_requirements (const Requirements & r)983void MilitarySite::set_requirements (const Requirements & r)
984{984{
985 m_soldier_requirements = r;985 soldier_requirements_ = r;
986}986}
987987
988/*988/*
@@ -992,7 +992,7 @@
992*/992*/
993void MilitarySite::clear_requirements ()993void MilitarySite::clear_requirements ()
994{994{
995 m_soldier_requirements = Requirements();995 soldier_requirements_ = Requirements();
996}996}
997997
998void MilitarySite::send_attacker998void MilitarySite::send_attacker
@@ -1007,7 +1007,7 @@
1007 sj.soldier = &soldier;1007 sj.soldier = &soldier;
1008 sj.enemy = &target;1008 sj.enemy = &target;
1009 sj.stayhome = false;1009 sj.stayhome = false;
1010 m_soldierjobs.push_back(sj);1010 soldierjobs_.push_back(sj);
10111011
1012 soldier.update_task_buildingwork1012 soldier.update_task_buildingwork
1013 (dynamic_cast<Game&>(owner().egbase()));1013 (dynamic_cast<Game&>(owner().egbase()));
@@ -1016,7 +1016,7 @@
10161016
1017bool MilitarySite::has_soldier_job(Soldier & soldier)1017bool MilitarySite::has_soldier_job(Soldier & soldier)
1018{1018{
1019 for (const SoldierJob& temp_job : m_soldierjobs) {1019 for (const SoldierJob& temp_job : soldierjobs_) {
1020 if (temp_job.soldier == &soldier) {1020 if (temp_job.soldier == &soldier) {
1021 return true;1021 return true;
1022 }1022 }
@@ -1032,14 +1032,14 @@
1032MapObject * MilitarySite::pop_soldier_job1032MapObject * MilitarySite::pop_soldier_job
1033 (Soldier * const soldier, bool * const stayhome)1033 (Soldier * const soldier, bool * const stayhome)
1034{1034{
1035 for (std::vector<SoldierJob>::iterator job_iter = m_soldierjobs.begin();1035 for (std::vector<SoldierJob>::iterator job_iter = soldierjobs_.begin();
1036 job_iter != m_soldierjobs.end(); ++job_iter)1036 job_iter != soldierjobs_.end(); ++job_iter)
1037 {1037 {
1038 if (job_iter->soldier == soldier) {1038 if (job_iter->soldier == soldier) {
1039 MapObject * const enemy = job_iter->enemy.get(owner().egbase());1039 MapObject * const enemy = job_iter->enemy.get(owner().egbase());
1040 if (stayhome)1040 if (stayhome)
1041 *stayhome = job_iter->stayhome;1041 *stayhome = job_iter->stayhome;
1042 m_soldierjobs.erase(job_iter);1042 soldierjobs_.erase(job_iter);
1043 return enemy;1043 return enemy;
1044 }1044 }
1045 }1045 }
@@ -1058,13 +1058,13 @@
1058bool1058bool
1059MilitarySite::update_upgrade_requirements()1059MilitarySite::update_upgrade_requirements()
1060{1060{
1061 int32_t soldier_upgrade_required_min = m_soldier_upgrade_requirements.get_min();1061 int32_t soldier_upgrade_required_min = soldier_upgrade_requirements_.get_min();
1062 int32_t soldier_upgrade_required_max = m_soldier_upgrade_requirements.get_max();1062 int32_t soldier_upgrade_required_max = soldier_upgrade_requirements_.get_max();
10631063
1064 if (kPrefersHeroes != m_soldier_preference && kPrefersRookies != m_soldier_preference)1064 if (kPrefersHeroes != soldier_preference_ && kPrefersRookies != soldier_preference_)
1065 {1065 {
1066 log("MilitarySite::swapSoldiers: error: Unknown player preference %d.\n", m_soldier_preference);1066 log("MilitarySite::swapSoldiers: error: Unknown player preference %d.\n", soldier_preference_);
1067 m_soldier_upgrade_try = false;1067 soldier_upgrade_try_ = false;
1068 return false;1068 return false;
1069 }1069 }
10701070
@@ -1078,29 +1078,29 @@
10781078
1079 // Micro-optimization: I assume that the majority of military sites have only level-zero1079 // Micro-optimization: I assume that the majority of military sites have only level-zero
1080 // soldiers and prefer rookies. Handle them separately.1080 // soldiers and prefer rookies. Handle them separately.
1081 m_soldier_upgrade_try = true;1081 soldier_upgrade_try_ = true;
1082 if (kPrefersRookies == m_soldier_preference) {1082 if (kPrefersRookies == soldier_preference_) {
1083 if (0 == wg_level)1083 if (0 == wg_level)
1084 {1084 {
1085 m_soldier_upgrade_try = false;1085 soldier_upgrade_try_ = false;
1086 return false;1086 return false;
1087 }1087 }
1088 }1088 }
10891089
1090 // Now I actually build the new requirements.1090 // Now I actually build the new requirements.
1091 int32_t reqmin = kPrefersHeroes == m_soldier_preference ? 1 + wg_level : 0;1091 int32_t reqmin = kPrefersHeroes == soldier_preference_ ? 1 + wg_level : 0;
1092 int32_t reqmax = kPrefersHeroes == m_soldier_preference ? SHRT_MAX : wg_level - 1;1092 int32_t reqmax = kPrefersHeroes == soldier_preference_ ? SHRT_MAX : wg_level - 1;
10931093
1094 bool maxchanged = reqmax != soldier_upgrade_required_max;1094 bool maxchanged = reqmax != soldier_upgrade_required_max;
1095 bool minchanged = reqmin != soldier_upgrade_required_min;1095 bool minchanged = reqmin != soldier_upgrade_required_min;
10961096
1097 if (maxchanged || minchanged)1097 if (maxchanged || minchanged)
1098 {1098 {
1099 if (m_upgrade_soldier_request && (m_upgrade_soldier_request->is_open()))1099 if (upgrade_soldier_request_ && (upgrade_soldier_request_->is_open()))
1100 {1100 {
1101 m_upgrade_soldier_request.reset();1101 upgrade_soldier_request_.reset();
1102 }1102 }
1103 m_soldier_upgrade_requirements = RequireAttribute(atrTotal, reqmin, reqmax);1103 soldier_upgrade_requirements_ = RequireAttribute(atrTotal, reqmin, reqmax);
11041104
1105 return true;1105 return true;
1106 }1106 }
@@ -1114,8 +1114,8 @@
1114MilitarySite::set_soldier_preference(MilitarySite::SoldierPreference p)1114MilitarySite::set_soldier_preference(MilitarySite::SoldierPreference p)
1115{1115{
1116 assert(kPrefersHeroes == p || kPrefersRookies == p);1116 assert(kPrefersHeroes == p || kPrefersRookies == p);
1117 m_soldier_preference = p;1117 soldier_preference_ = p;
1118 m_next_swap_soldiers_time = 0;1118 next_swap_soldiers_time_ = 0;
1119}1119}
11201120
1121}1121}
11221122
=== modified file 'src/logic/map_objects/tribes/militarysite.h'
--- src/logic/map_objects/tribes/militarysite.h 2016-01-31 15:31:00 +0000
+++ src/logic/map_objects/tribes/militarysite.h 2016-02-08 18:17:36 +0000
@@ -42,26 +42,26 @@
4242
43 Building & create_object() const override;43 Building & create_object() const override;
4444
45 uint32_t get_conquers() const override {return m_conquer_radius;}45 uint32_t get_conquers() const override {return conquer_radius_;}
46 uint32_t get_max_number_of_soldiers () const {46 uint32_t get_max_number_of_soldiers () const {
47 return m_num_soldiers;47 return num_soldiers_;
48 }48 }
49 uint32_t get_heal_per_second () const {49 uint32_t get_heal_per_second () const {
50 return m_heal_per_second;50 return heal_per_second_;
51 }51 }
5252
53 bool m_prefers_heroes_at_start;53 bool prefers_heroes_at_start_;
54 std::string m_occupied_str;54 std::string occupied_str_;
55 std::string m_aggressor_str;55 std::string aggressor_str_;
56 std::string m_attack_str;56 std::string attack_str_;
57 std::string m_defeated_enemy_str;57 std::string defeated_enemy_str_;
58 std::string m_defeated_you_str;58 std::string defeated_you_str_;
5959
6060
61private:61private:
62 uint32_t m_conquer_radius;62 uint32_t conquer_radius_;
63 uint32_t m_num_soldiers;63 uint32_t num_soldiers_;
64 uint32_t m_heal_per_second;64 uint32_t heal_per_second_;
65 DISALLOW_COPY_AND_ASSIGN(MilitarySiteDescr);65 DISALLOW_COPY_AND_ASSIGN(MilitarySiteDescr);
66};66};
6767
@@ -115,7 +115,7 @@
115 void set_requirements (const Requirements &);115 void set_requirements (const Requirements &);
116 void clear_requirements();116 void clear_requirements();
117 const Requirements & get_requirements () const {117 const Requirements & get_requirements () const {
118 return m_soldier_requirements;118 return soldier_requirements_;
119 }119 }
120120
121 void reinit_after_conqueration(Game &);121 void reinit_after_conqueration(Game &);
@@ -124,7 +124,7 @@
124124
125 void set_soldier_preference(SoldierPreference);125 void set_soldier_preference(SoldierPreference);
126 SoldierPreference get_soldier_preference() const {126 SoldierPreference get_soldier_preference() const {
127 return m_soldier_preference;127 return soldier_preference_;
128 }128 }
129129
130protected:130protected:
@@ -153,28 +153,28 @@
153153
154154
155private:155private:
156 Requirements m_soldier_requirements; // This is used to grab a bunch of soldiers: Anything goes156 Requirements soldier_requirements_; // This is used to grab a bunch of soldiers: Anything goes
157 RequireAttribute m_soldier_upgrade_requirements; // This is used when exchanging soldiers.157 RequireAttribute soldier_upgrade_requirements_; // This is used when exchanging soldiers.
158 std::unique_ptr<Request> m_normal_soldier_request; // filling the site158 std::unique_ptr<Request> normal_soldier_request_; // filling the site
159 std::unique_ptr<Request> m_upgrade_soldier_request; // seeking for better soldiers159 std::unique_ptr<Request> upgrade_soldier_request_; // seeking for better soldiers
160 bool m_didconquer;160 bool didconquer_;
161 uint32_t m_capacity;161 uint32_t capacity_;
162162
163 /**163 /**
164 * Next gametime where we should heal something.164 * Next gametime where we should heal something.
165 */165 */
166 int32_t m_nexthealtime;166 int32_t nexthealtime_;
167167
168 struct SoldierJob {168 struct SoldierJob {
169 Soldier * soldier;169 Soldier * soldier;
170 ObjectPointer enemy;170 ObjectPointer enemy;
171 bool stayhome;171 bool stayhome;
172 };172 };
173 std::vector<SoldierJob> m_soldierjobs;173 std::vector<SoldierJob> soldierjobs_;
174 SoldierPreference m_soldier_preference;174 SoldierPreference soldier_preference_;
175 int32_t m_next_swap_soldiers_time;175 int32_t next_swap_soldiers_time_;
176 bool m_soldier_upgrade_try; // optimization -- if everybody is zero-level, do not downgrade176 bool soldier_upgrade_try_; // optimization -- if everybody is zero-level, do not downgrade
177 bool m_doing_upgrade_request;177 bool doing_upgrade_request_;
178};178};
179179
180}180}
181181
=== modified file 'src/logic/map_objects/tribes/partially_finished_building.cc'
--- src/logic/map_objects/tribes/partially_finished_building.cc 2016-01-28 05:24:34 +0000
+++ src/logic/map_objects/tribes/partially_finished_building.cc 2016-02-08 18:17:36 +0000
@@ -33,12 +33,12 @@
33PartiallyFinishedBuilding::PartiallyFinishedBuilding33PartiallyFinishedBuilding::PartiallyFinishedBuilding
34 (const BuildingDescr & gdescr) :34 (const BuildingDescr & gdescr) :
35Building (gdescr),35Building (gdescr),
36m_building (nullptr),36building_ (nullptr),
37m_builder_request(nullptr),37builder_request_(nullptr),
38m_working (false),38working_ (false),
39m_work_steptime (0),39work_steptime_ (0),
40m_work_completed (0),40work_completed_ (0),
41m_work_steps (0)41work_steps_ (0)
42{}42{}
4343
44/*44/*
@@ -47,22 +47,22 @@
47===============47===============
48*/48*/
49void PartiallyFinishedBuilding::set_building(const BuildingDescr & building_descr) {49void PartiallyFinishedBuilding::set_building(const BuildingDescr & building_descr) {
50 assert(!m_building);50 assert(!building_);
5151
52 m_building = &building_descr;52 building_ = &building_descr;
53}53}
5454
55void PartiallyFinishedBuilding::cleanup(EditorGameBase & egbase) {55void PartiallyFinishedBuilding::cleanup(EditorGameBase & egbase) {
56 if (m_builder_request) {56 if (builder_request_) {
57 delete m_builder_request;57 delete builder_request_;
58 m_builder_request = nullptr;58 builder_request_ = nullptr;
59 }59 }
6060
61 for (WaresQueue * temp_ware : m_wares) {61 for (WaresQueue * temp_ware : wares_) {
62 temp_ware->cleanup();62 temp_ware->cleanup();
63 delete temp_ware;63 delete temp_ware;
64 }64 }
65 m_wares.clear();65 wares_.clear();
6666
67 Building::cleanup(egbase);67 Building::cleanup(egbase);
68}68}
@@ -73,7 +73,7 @@
73 if (upcast(Game, game, &egbase))73 if (upcast(Game, game, &egbase))
74 request_builder(*game);74 request_builder(*game);
7575
76 g_sound_handler.play_fx("create_construction_site", m_position, 255);76 g_sound_handler.play_fx("create_construction_site", position_, 255);
77}77}
7878
79/*79/*
@@ -85,16 +85,16 @@
85void PartiallyFinishedBuilding::set_economy(Economy * const e)85void PartiallyFinishedBuilding::set_economy(Economy * const e)
86{86{
87 if (Economy * const old = get_economy()) {87 if (Economy * const old = get_economy()) {
88 for (WaresQueue * temp_ware : m_wares) {88 for (WaresQueue * temp_ware : wares_) {
89 temp_ware->remove_from_economy(*old);89 temp_ware->remove_from_economy(*old);
90 }90 }
91 }91 }
92 Building::set_economy(e);92 Building::set_economy(e);
93 if (m_builder_request)93 if (builder_request_)
94 m_builder_request->set_economy(e);94 builder_request_->set_economy(e);
9595
96 if (e)96 if (e)
97 for (WaresQueue * temp_ware : m_wares) {97 for (WaresQueue * temp_ware : wares_) {
98 temp_ware->add_to_economy(*e);98 temp_ware->add_to_economy(*e);
99 }99 }
100}100}
@@ -107,9 +107,9 @@
107===============107===============
108*/108*/
109void PartiallyFinishedBuilding::request_builder(Game &) {109void PartiallyFinishedBuilding::request_builder(Game &) {
110 assert(!m_builder.is_set() && !m_builder_request);110 assert(!builder_.is_set() && !builder_request_);
111111
112 m_builder_request =112 builder_request_ =
113 new Request113 new Request
114 (*this,114 (*this,
115 owner().tribe().builder(),115 owner().tribe().builder(),
@@ -123,7 +123,7 @@
123===============123===============
124*/124*/
125int32_t PartiallyFinishedBuilding::get_size() const {125int32_t PartiallyFinishedBuilding::get_size() const {
126 return m_building->get_size();126 return building_->get_size();
127}127}
128128
129/*129/*
@@ -149,7 +149,7 @@
149*/149*/
150const Image* PartiallyFinishedBuilding::representative_image() const150const Image* PartiallyFinishedBuilding::representative_image() const
151{151{
152 return m_building->representative_image(&owner().get_playercolor());152 return building_->representative_image(&owner().get_playercolor());
153}153}
154154
155155
@@ -166,8 +166,8 @@
166 uint32_t thisstep = 0;166 uint32_t thisstep = 0;
167167
168 uint32_t ts = build_step_time();168 uint32_t ts = build_step_time();
169 if (m_working) {169 if (working_) {
170 thisstep = ts - (m_work_steptime - time);170 thisstep = ts - (work_steptime_ - time);
171 // The check below is necessary because we drive construction via171 // The check below is necessary because we drive construction via
172 // the construction worker in get_building_work(), and there can be172 // the construction worker in get_building_work(), and there can be
173 // a small delay between the worker completing his job and requesting173 // a small delay between the worker completing his job and requesting
@@ -176,9 +176,9 @@
176 thisstep = ts;176 thisstep = ts;
177 }177 }
178 thisstep = (thisstep << 16) / ts;178 thisstep = (thisstep << 16) / ts;
179 uint32_t total = (thisstep + (m_work_completed << 16));179 uint32_t total = (thisstep + (work_completed_ << 16));
180 if (m_work_steps)180 if (work_steps_)
181 total /= m_work_steps;181 total /= work_steps_;
182182
183 assert(total <= (1 << 16));183 assert(total <= (1 << 16));
184184
@@ -203,10 +203,10 @@
203203
204 PartiallyFinishedBuilding & b = dynamic_cast<PartiallyFinishedBuilding&>(target);204 PartiallyFinishedBuilding & b = dynamic_cast<PartiallyFinishedBuilding&>(target);
205205
206 b.m_builder = w;206 b.builder_ = w;
207207
208 delete &rq;208 delete &rq;
209 b.m_builder_request = nullptr;209 b.builder_request_ = nullptr;
210210
211 w->start_task_buildingwork(game);211 w->start_task_buildingwork(game);
212 b.set_seeing(true);212 b.set_seeing(true);
213213
=== modified file 'src/logic/map_objects/tribes/partially_finished_building.h'
--- src/logic/map_objects/tribes/partially_finished_building.h 2015-11-28 22:29:26 +0000
+++ src/logic/map_objects/tribes/partially_finished_building.h 2016-02-08 18:17:36 +0000
@@ -50,11 +50,11 @@
50 void init (EditorGameBase &) override;50 void init (EditorGameBase &) override;
51 void set_economy(Economy *) override;51 void set_economy(Economy *) override;
5252
53 uint32_t get_nrwaresqueues() {return m_wares.size();}53 uint32_t get_nrwaresqueues() {return wares_.size();}
54 WaresQueue * get_waresqueue(uint32_t const idx) {return m_wares[idx];}54 WaresQueue * get_waresqueue(uint32_t const idx) {return wares_[idx];}
5555
56 uint32_t get_built_per64k() const;56 uint32_t get_built_per64k() const;
57 Request * get_builder_request() {return m_builder_request;}57 Request * get_builder_request() {return builder_request_;}
58 static void request_builder_callback(Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);58 static void request_builder_callback(Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
5959
60private:60private:
@@ -64,19 +64,19 @@
64 virtual uint32_t build_step_time() const = 0;64 virtual uint32_t build_step_time() const = 0;
6565
66protected:66protected:
67 const BuildingDescr * m_building; // type of building that was or will become67 const BuildingDescr * building_; // type of building that was or will become
6868
69 Request * m_builder_request;69 Request * builder_request_;
70 OPtr<Worker> m_builder;70 OPtr<Worker> builder_;
7171
72 using Wares = std::vector<WaresQueue *>;72 using Wares = std::vector<WaresQueue *>;
73 Wares m_wares;73 Wares wares_;
7474
75 bool m_working; // true if the builder is currently working75 bool working_; // true if the builder is currently working
76 uint32_t m_work_steptime; // time when next step is completed76 uint32_t work_steptime_; // time when next step is completed
77 uint32_t m_work_completed; // how many steps have we done so far?77 uint32_t work_completed_; // how many steps have we done so far?
78 uint32_t m_work_steps; // how many steps (= wares) until we're done?78 uint32_t work_steps_; // how many steps (= wares) until we're done?
79 //Player::ConstructionsiteInformation * m_info; // asked for by player point of view for the gameview79 //Player::ConstructionsiteInformation * info_; // asked for by player point of view for the gameview
80};80};
8181
82}82}
8383
=== modified file 'src/logic/map_objects/tribes/production_program.cc'
--- src/logic/map_objects/tribes/production_program.cc 2016-02-01 16:18:17 +0000
+++ src/logic/map_objects/tribes/production_program.cc 2016-02-08 18:17:36 +0000
@@ -722,7 +722,7 @@
722722
723 for (const std::pair<uint32_t, std::set<std::string> >& area_info : worker_workarea_info) {723 for (const std::pair<uint32_t, std::set<std::string> >& area_info : worker_workarea_info) {
724 std::set<std::string> & building_radius_infos =724 std::set<std::string> & building_radius_infos =
725 descr->m_workarea_info[area_info.first];725 descr->workarea_info_[area_info.first];
726726
727 for (const std::string& worker_descname : area_info.second) {727 for (const std::string& worker_descname : area_info.second) {
728 std::string description = descr->descname();728 std::string description = descr->descname();
@@ -1228,7 +1228,7 @@
1228 % world.get_resource(m_resource)->descname())1228 % world.get_resource(m_resource)->descname())
1229 .str();1229 .str();
12301230
1231 descr->m_workarea_info[m_distance].insert(description);1231 descr->workarea_info_[m_distance].insert(description);
1232 } catch (const WException & e) {1232 } catch (const WException & e) {
1233 throw GameDataError("mine: %s", e.what());1233 throw GameDataError("mine: %s", e.what());
1234 }1234 }
@@ -1546,7 +1546,7 @@
1546void ProductionProgram::ActPlayFX::execute1546void ProductionProgram::ActPlayFX::execute
1547 (Game & game, ProductionSite & ps) const1547 (Game & game, ProductionSite & ps) const
1548{1548{
1549 g_sound_handler.play_fx(name, ps.m_position, priority);1549 g_sound_handler.play_fx(name, ps.position_, priority);
1550 return ps.program_step(game);1550 return ps.program_step(game);
1551}1551}
15521552
@@ -1562,7 +1562,7 @@
1562 workerprogram = params[1];1562 workerprogram = params[1];
1563 radius = boost::lexical_cast<uint32_t>(params[2]);1563 radius = boost::lexical_cast<uint32_t>(params[2]);
15641564
1565 std::set<std::string> & building_radius_infos = descr->m_workarea_info[radius];1565 std::set<std::string> & building_radius_infos = descr->workarea_info_[radius];
1566 std::string description = descr->name() + ' ' + production_program_name;1566 std::string description = descr->name() + ' ' + production_program_name;
1567 description += " construct ";1567 description += " construct ";
1568 description += objectname;1568 description += objectname;
15691569
=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc 2016-01-23 16:35:30 +0000
+++ src/logic/map_objects/tribes/productionsite.cc 2016-02-08 18:17:36 +0000
@@ -688,7 +688,7 @@
688 if (state.program->size() <= state.ip)688 if (state.program->size() <= state.ip)
689 return program_end(game, Completed);689 return program_end(game, Completed);
690690
691 if (m_anim != descr().get_animation(m_default_anim)) {691 if (anim_ != descr().get_animation(m_default_anim)) {
692 // Restart idle animation, which is the default692 // Restart idle animation, which is the default
693 start_animation(game, descr().get_animation(m_default_anim));693 start_animation(game, descr().get_animation(m_default_anim));
694 }694 }
695695
=== modified file 'src/logic/map_objects/tribes/warehouse.cc'
--- src/logic/map_objects/tribes/warehouse.cc 2016-02-07 06:10:47 +0000
+++ src/logic/map_objects/tribes/warehouse.cc 2016-02-08 18:17:36 +0000
@@ -261,7 +261,7 @@
261 m_heal_per_second = table.get_int("heal_per_second");261 m_heal_per_second = table.get_int("heal_per_second");
262 if (table.has_key("conquers")) {262 if (table.has_key("conquers")) {
263 m_conquers = table.get_int("conquers");263 m_conquers = table.get_int("conquers");
264 m_workarea_info[m_conquers].insert(descname() + " conquer");264 workarea_info_[m_conquers].insert(descname() + " conquer");
265 }265 }
266}266}
267267
@@ -629,7 +629,7 @@
629 (PlayerArea<Area<FCoords> >629 (PlayerArea<Area<FCoords> >
630 (owner().player_number(),630 (owner().player_number(),
631 Area<FCoords>(map.get_fcoords(get_position()), conquer_radius)),631 Area<FCoords>(map.get_fcoords(get_position()), conquer_radius)),
632 m_defeating_player);632 defeating_player_);
633633
634 // Unsee the area that we started seeing in init()634 // Unsee the area that we started seeing in init()
635 Player & player = owner();635 Player & player = owner();
@@ -903,7 +903,7 @@
903 // NOTE: This code lies about the TrainingAttributes of the new worker903 // NOTE: This code lies about the TrainingAttributes of the new worker
904 m_supply->remove_workers(worker_id, 1);904 m_supply->remove_workers(worker_id, 1);
905 const WorkerDescr & workerdescr = *game.tribes().get_worker_descr(worker_id);905 const WorkerDescr & workerdescr = *game.tribes().get_worker_descr(worker_id);
906 return workerdescr.create(game, owner(), this, m_position);906 return workerdescr.create(game, owner(), this, position_);
907 }907 }
908 }908 }
909909
@@ -1105,7 +1105,7 @@
1105 remove_workers(owner().tribe().safe_worker_index(input), buildcost.second);1105 remove_workers(owner().tribe().safe_worker_index(input), buildcost.second);
1106 }1106 }
11071107
1108 incorporate_worker(game, &w_desc.create(game, owner(), this, m_position));1108 incorporate_worker(game, &w_desc.create(game, owner(), this, position_));
11091109
1110 // Update PlannedWorkers::amount here if appropriate, because this function1110 // Update PlannedWorkers::amount here if appropriate, because this function
1111 // may have been called directly by the Economy.1111 // may have been called directly by the Economy.
11121112
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2016-01-28 05:24:34 +0000
+++ src/logic/player.cc 2016-02-08 18:17:36 +0000
@@ -1253,9 +1253,9 @@
12531253
1254Player::BuildingStatsVector* Player::get_mutable_building_statistics(const DescriptionIndex& i) {1254Player::BuildingStatsVector* Player::get_mutable_building_statistics(const DescriptionIndex& i) {
1255 DescriptionIndex const nr_buildings = egbase().tribes().nrbuildings();1255 DescriptionIndex const nr_buildings = egbase().tribes().nrbuildings();
1256 if (m_building_stats.size() < nr_buildings)1256 if (building_stats_.size() < nr_buildings)
1257 m_building_stats.resize(nr_buildings);1257 building_stats_.resize(nr_buildings);
1258 return &m_building_stats[i];1258 return &building_stats_[i];
1259}1259}
12601260
1261/**1261/**
@@ -1273,8 +1273,8 @@
1273 const size_t nr_buildings = egbase().tribes().nrbuildings();1273 const size_t nr_buildings = egbase().tribes().nrbuildings();
12741274
1275 // Get the valid vector for this1275 // Get the valid vector for this
1276 if (m_building_stats.size() < nr_buildings)1276 if (building_stats_.size() < nr_buildings)
1277 m_building_stats.resize(nr_buildings);1277 building_stats_.resize(nr_buildings);
12781278
1279 std::vector<BuildingStats>& stat =1279 std::vector<BuildingStats>& stat =
1280 *get_mutable_building_statistics(egbase().tribes().building_index(building_name.c_str()));1280 *get_mutable_building_statistics(egbase().tribes().building_index(building_name.c_str()));
12811281
=== modified file 'src/logic/player.h'
--- src/logic/player.h 2016-01-31 15:31:00 +0000
+++ src/logic/player.h 2016-02-08 18:17:36 +0000
@@ -613,7 +613,7 @@
613 */613 */
614 std::vector< std::vector<uint32_t> > m_ware_stocks;614 std::vector< std::vector<uint32_t> > m_ware_stocks;
615615
616 PlayerBuildingStats m_building_stats;616 PlayerBuildingStats building_stats_;
617617
618 DISALLOW_COPY_AND_ASSIGN(Player);618 DISALLOW_COPY_AND_ASSIGN(Player);
619};619};
620620
=== modified file 'src/map_io/map_building_packet.cc'
--- src/map_io/map_building_packet.cc 2016-02-06 11:11:24 +0000
+++ src/map_io/map_building_packet.cc 2016-02-08 18:17:36 +0000
@@ -142,12 +142,12 @@
142142
143 if (building->descr().type() == MapObjectType::CONSTRUCTIONSITE) {143 if (building->descr().type() == MapObjectType::CONSTRUCTIONSITE) {
144 upcast(PartiallyFinishedBuilding const, pfb, building);144 upcast(PartiallyFinishedBuilding const, pfb, building);
145 fw.c_string((*pfb->m_building).name().c_str());145 fw.c_string((*pfb->building_).name().c_str());
146 fw.unsigned_8(kTypeConstructionSite);146 fw.unsigned_8(kTypeConstructionSite);
147147
148 } else if (building->descr().type() == MapObjectType::DISMANTLESITE) {148 } else if (building->descr().type() == MapObjectType::DISMANTLESITE) {
149 upcast(PartiallyFinishedBuilding const, pfb, building);149 upcast(PartiallyFinishedBuilding const, pfb, building);
150 fw.c_string((*pfb->m_building).name().c_str());150 fw.c_string((*pfb->building_).name().c_str());
151 fw.unsigned_8(kTypeDismantleSite);151 fw.unsigned_8(kTypeDismantleSite);
152152
153 } else {153 } else {
154154
=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc 2016-02-07 06:10:47 +0000
+++ src/map_io/map_buildingdata_packet.cc 2016-02-08 18:17:36 +0000
@@ -87,7 +87,7 @@
87 if (fr.unsigned_8()) {87 if (fr.unsigned_8()) {
88 char const * const animation_name = fr.c_string();88 char const * const animation_name = fr.c_string();
89 try {89 try {
90 building.m_anim =90 building.anim_ =
91 building.descr().get_animation(animation_name);91 building.descr().get_animation(animation_name);
92 } catch (const MapObjectDescr::AnimationNonexistent &) {92 } catch (const MapObjectDescr::AnimationNonexistent &) {
93 log93 log
@@ -96,15 +96,15 @@
96 building.owner().tribe().name().c_str(),96 building.owner().tribe().name().c_str(),
97 building.descr().descname().c_str(),97 building.descr().descname().c_str(),
98 animation_name);98 animation_name);
99 building.m_anim = building.descr().get_animation("idle");99 building.anim_ = building.descr().get_animation("idle");
100 }100 }
101 } else {101 } else {
102 building.m_anim = 0;102 building.anim_ = 0;
103 }103 }
104 building.m_animstart = fr.unsigned_32();104 building.animstart_ = fr.unsigned_32();
105105
106 {106 {
107 Building::LeaveQueue & leave_queue = building.m_leave_queue;107 Building::LeaveQueue & leave_queue = building.leave_queue_;
108 leave_queue.resize(fr.unsigned_16());108 leave_queue.resize(fr.unsigned_16());
109109
110 for (Building::LeaveQueue::iterator queue_iter = leave_queue.begin();110 for (Building::LeaveQueue::iterator queue_iter = leave_queue.begin();
@@ -131,26 +131,26 @@
131 }131 }
132 }132 }
133133
134 building.m_leave_time = fr.unsigned_32();134 building.leave_time_ = fr.unsigned_32();
135135
136 if (uint32_t const leaver_serial = fr.unsigned_32())136 if (uint32_t const leaver_serial = fr.unsigned_32())
137 try {137 try {
138 building.m_leave_allow =138 building.leave_allow_ =
139 &mol.get<MapObject>(leaver_serial);139 &mol.get<MapObject>(leaver_serial);
140 } catch (const WException & e) {140 } catch (const WException & e) {
141 throw GameDataError141 throw GameDataError
142 ("leave allow item (%u): %s", leaver_serial, e.what());142 ("leave allow item (%u): %s", leaver_serial, e.what());
143 }143 }
144 else {144 else {
145 building.m_leave_allow = nullptr;145 building.leave_allow_ = nullptr;
146 }146 }
147147
148 while (fr.unsigned_8()) {148 while (fr.unsigned_8()) {
149 DescriptionIndex oldidx = building.owner().tribe().safe_building_index(fr.c_string());149 DescriptionIndex oldidx = building.owner().tribe().safe_building_index(fr.c_string());
150 building.m_old_buildings.push_back(oldidx);150 building.old_buildings_.push_back(oldidx);
151 }151 }
152 // Only construction sites may have an empty list152 // Only construction sites may have an empty list
153 if (building.m_old_buildings.empty() && !is_a(ConstructionSite, &building)) {153 if (building.old_buildings_.empty() && !is_a(ConstructionSite, &building)) {
154 throw GameDataError154 throw GameDataError
155 ("Failed to read %s %u: No former buildings informations.\n"155 ("Failed to read %s %u: No former buildings informations.\n"
156 "Your savegame is corrupted", building.descr().descname().c_str(), building.serial());156 "Your savegame is corrupted", building.descr().descname().c_str(), building.serial());
@@ -180,7 +180,7 @@
180 }180 }
181181
182 // Set economy now, some stuff below will count on this.182 // Set economy now, some stuff below will count on this.
183 building.set_economy(building.m_flag->get_economy());183 building.set_economy(building.flag_->get_economy());
184184
185 Game& game = dynamic_cast<Game&>(egbase);185 Game& game = dynamic_cast<Game&>(egbase);
186186
@@ -226,49 +226,49 @@
226 uint16_t const packet_version = fr.unsigned_16();226 uint16_t const packet_version = fr.unsigned_16();
227 if (packet_version == kCurrentPacketPFBuilding) {227 if (packet_version == kCurrentPacketPFBuilding) {
228 const TribeDescr & tribe = pfb.owner().tribe();228 const TribeDescr & tribe = pfb.owner().tribe();
229 pfb.m_building =229 pfb.building_ =
230 tribe.get_building_descr(tribe.safe_building_index(fr.c_string()));230 tribe.get_building_descr(tribe.safe_building_index(fr.c_string()));
231231
232 delete pfb.m_builder_request;232 delete pfb.builder_request_;
233 if (fr.unsigned_8()) {233 if (fr.unsigned_8()) {
234 pfb.m_builder_request =234 pfb.builder_request_ =
235 new Request235 new Request
236 (pfb,236 (pfb,
237 0,237 0,
238 PartiallyFinishedBuilding::request_builder_callback,238 PartiallyFinishedBuilding::request_builder_callback,
239 wwWORKER);239 wwWORKER);
240 pfb.m_builder_request->read(fr, game, mol);240 pfb.builder_request_->read(fr, game, mol);
241 } else241 } else
242 pfb.m_builder_request = nullptr;242 pfb.builder_request_ = nullptr;
243243
244 if (uint32_t const builder_serial = fr.unsigned_32()) {244 if (uint32_t const builder_serial = fr.unsigned_32()) {
245 try {245 try {
246 pfb.m_builder = &mol.get<Worker>(builder_serial);246 pfb.builder_ = &mol.get<Worker>(builder_serial);
247 } catch (const WException & e) {247 } catch (const WException & e) {
248 throw GameDataError248 throw GameDataError
249 ("builder (%u): %s", builder_serial, e.what());249 ("builder (%u): %s", builder_serial, e.what());
250 }250 }
251 } else251 } else
252 pfb.m_builder = nullptr;252 pfb.builder_ = nullptr;
253253
254 try {254 try {
255 uint16_t const size = fr.unsigned_16();255 uint16_t const size = fr.unsigned_16();
256 pfb.m_wares.resize(size);256 pfb.wares_.resize(size);
257 for (uint16_t i = 0; i < pfb.m_wares.size(); ++i)257 for (uint16_t i = 0; i < pfb.wares_.size(); ++i)
258 {258 {
259 pfb.m_wares[i] =259 pfb.wares_[i] =
260 new WaresQueue260 new WaresQueue
261 (pfb, INVALID_INDEX, 0);261 (pfb, INVALID_INDEX, 0);
262 pfb.m_wares[i]->read(fr, game, mol);262 pfb.wares_[i]->read(fr, game, mol);
263 }263 }
264 } catch (const WException & e) {264 } catch (const WException & e) {
265 throw GameDataError("wares: %s", e.what());265 throw GameDataError("wares: %s", e.what());
266 }266 }
267267
268 pfb.m_working = fr.unsigned_8 ();268 pfb.working_ = fr.unsigned_8 ();
269 pfb.m_work_steptime = fr.unsigned_32();269 pfb.work_steptime_ = fr.unsigned_32();
270 pfb.m_work_completed = fr.unsigned_32();270 pfb.work_completed_ = fr.unsigned_32();
271 pfb.m_work_steps = fr.unsigned_32();271 pfb.work_steps_ = fr.unsigned_32();
272 } else {272 } else {
273 throw UnhandledVersionError("MapBuildingdataPacket - Partially Finished Building",273 throw UnhandledVersionError("MapBuildingdataPacket - Partially Finished Building",
274 packet_version, kCurrentPacketPFBuilding);274 packet_version, kCurrentPacketPFBuilding);
@@ -289,15 +289,15 @@
289 if (packet_version >= kCurrentPacketVersionConstructionsite) {289 if (packet_version >= kCurrentPacketVersionConstructionsite) {
290 read_partially_finished_building(constructionsite, fr, game, mol);290 read_partially_finished_building(constructionsite, fr, game, mol);
291291
292 for (ConstructionSite::Wares::iterator wares_iter = constructionsite.m_wares.begin();292 for (ConstructionSite::Wares::iterator wares_iter = constructionsite.wares_.begin();
293 wares_iter != constructionsite.m_wares.end();293 wares_iter != constructionsite.wares_.end();
294 ++wares_iter) {294 ++wares_iter) {
295295
296 (*wares_iter)->set_callback296 (*wares_iter)->set_callback
297 (ConstructionSite::wares_queue_callback, &constructionsite);297 (ConstructionSite::wares_queue_callback, &constructionsite);
298 }298 }
299299
300 constructionsite.m_fetchfromflag = fr. signed_32();300 constructionsite.fetchfromflag_ = fr. signed_32();
301 } else {301 } else {
302 throw UnhandledVersionError("MapBuildingdataPacket - Constructionsite",302 throw UnhandledVersionError("MapBuildingdataPacket - Constructionsite",
303 packet_version, kCurrentPacketVersionConstructionsite);303 packet_version, kCurrentPacketVersionConstructionsite);
@@ -510,36 +510,36 @@
510 try {510 try {
511 uint16_t const packet_version = fr.unsigned_16();511 uint16_t const packet_version = fr.unsigned_16();
512 if (packet_version == kCurrentPacketVersionMilitarysite) {512 if (packet_version == kCurrentPacketVersionMilitarysite) {
513 militarysite.m_normal_soldier_request.reset();513 militarysite.normal_soldier_request_.reset();
514514
515 if (fr.unsigned_8()) {515 if (fr.unsigned_8()) {
516 militarysite.m_normal_soldier_request.reset516 militarysite.normal_soldier_request_.reset
517 (new Request517 (new Request
518 (militarysite,518 (militarysite,
519 0,519 0,
520 MilitarySite::request_soldier_callback,520 MilitarySite::request_soldier_callback,
521 wwWORKER));521 wwWORKER));
522 militarysite.m_normal_soldier_request->read(fr, game, mol);522 militarysite.normal_soldier_request_->read(fr, game, mol);
523 }523 }
524 else524 else
525 militarysite.m_normal_soldier_request.reset();525 militarysite.normal_soldier_request_.reset();
526526
527 if (fr.unsigned_8())527 if (fr.unsigned_8())
528 {528 {
529 militarysite.m_upgrade_soldier_request.reset529 militarysite.upgrade_soldier_request_.reset
530 (new Request530 (new Request
531 (militarysite,531 (militarysite,
532 (!militarysite.m_normal_soldier_request) ? 0532 (!militarysite.normal_soldier_request_) ? 0
533 : militarysite.owner().tribe().soldier(),533 : militarysite.owner().tribe().soldier(),
534 MilitarySite::request_soldier_callback,534 MilitarySite::request_soldier_callback,
535 wwWORKER));535 wwWORKER));
536 militarysite.m_upgrade_soldier_request->read(fr, game, mol);536 militarysite.upgrade_soldier_request_->read(fr, game, mol);
537 }537 }
538 else538 else
539 militarysite.m_upgrade_soldier_request.reset();539 militarysite.upgrade_soldier_request_.reset();
540540
541541
542 if ((militarysite.m_didconquer = fr.unsigned_8())) {542 if ((militarysite.didconquer_ = fr.unsigned_8())) {
543 // Add to map of military influence.543 // Add to map of military influence.
544 const Map & map = game.map();544 const Map & map = game.map();
545 Area<FCoords> a545 Area<FCoords> a
@@ -557,16 +557,16 @@
557 }557 }
558558
559 // capacity (modified by user)559 // capacity (modified by user)
560 militarysite.m_capacity = fr.unsigned_8();560 militarysite.capacity_ = fr.unsigned_8();
561 militarysite.m_nexthealtime = fr.signed_32();561 militarysite.nexthealtime_ = fr.signed_32();
562562
563 uint16_t reqmin = fr.unsigned_16();563 uint16_t reqmin = fr.unsigned_16();
564 uint16_t reqmax = fr.unsigned_16();564 uint16_t reqmax = fr.unsigned_16();
565 militarysite.m_soldier_upgrade_requirements = RequireAttribute(atrTotal, reqmin, reqmax);565 militarysite.soldier_upgrade_requirements_ = RequireAttribute(atrTotal, reqmin, reqmax);
566 militarysite.m_soldier_preference = static_cast<MilitarySite::SoldierPreference>(fr.unsigned_8());566 militarysite.soldier_preference_ = static_cast<MilitarySite::SoldierPreference>(fr.unsigned_8());
567 militarysite.m_next_swap_soldiers_time = fr.signed_32();567 militarysite.next_swap_soldiers_time_ = fr.signed_32();
568 militarysite.m_soldier_upgrade_try = 0 != fr.unsigned_8() ? true : false;568 militarysite.soldier_upgrade_try_ = 0 != fr.unsigned_8() ? true : false;
569 militarysite.m_doing_upgrade_request = 0 != fr.unsigned_8() ? true : false;569 militarysite.doing_upgrade_request_ = 0 != fr.unsigned_8() ? true : false;
570570
571 } else {571 } else {
572 throw UnhandledVersionError("MapBuildingdataPacket - Militarysite",572 throw UnhandledVersionError("MapBuildingdataPacket - Militarysite",
@@ -582,22 +582,22 @@
582 // Cmd_ChangeSoldierCapacity to the beginning of the game's command582 // Cmd_ChangeSoldierCapacity to the beginning of the game's command
583 // queue. But that would not work because the command queue is not read583 // queue. But that would not work because the command queue is not read
584 // yet and will be cleared before it is read.584 // yet and will be cleared before it is read.
585 if (militarysite.m_capacity < militarysite.min_soldier_capacity()) {585 if (militarysite.capacity_ < militarysite.min_soldier_capacity()) {
586 log586 log
587 ("WARNING: militarysite %u of player %u at (%i, %i) has capacity "587 ("WARNING: militarysite %u of player %u at (%i, %i) has capacity "
588 "set to %u but it must be at least %u. Changing to that value.\n",588 "set to %u but it must be at least %u. Changing to that value.\n",
589 militarysite.serial(), militarysite.owner().player_number(),589 militarysite.serial(), militarysite.owner().player_number(),
590 militarysite.get_position().x, militarysite.get_position().y,590 militarysite.get_position().x, militarysite.get_position().y,
591 militarysite.m_capacity, militarysite.min_soldier_capacity());591 militarysite.capacity_, militarysite.min_soldier_capacity());
592 militarysite.m_capacity = militarysite.min_soldier_capacity();592 militarysite.capacity_ = militarysite.min_soldier_capacity();
593 } else if (militarysite.max_soldier_capacity() < militarysite.m_capacity) {593 } else if (militarysite.max_soldier_capacity() < militarysite.capacity_) {
594 log594 log
595 ("WARNING: militarysite %u of player %u at (%i, %i) has capacity "595 ("WARNING: militarysite %u of player %u at (%i, %i) has capacity "
596 "set to %u but it can be at most %u. Changing to that value.\n",596 "set to %u but it can be at most %u. Changing to that value.\n",
597 militarysite.serial(), militarysite.owner().player_number(),597 militarysite.serial(), militarysite.owner().player_number(),
598 militarysite.get_position().x, militarysite.get_position().y,598 militarysite.get_position().x, militarysite.get_position().y,
599 militarysite.m_capacity, militarysite.max_soldier_capacity());599 militarysite.capacity_, militarysite.max_soldier_capacity());
600 militarysite.m_capacity = militarysite.max_soldier_capacity();600 militarysite.capacity_ = militarysite.max_soldier_capacity();
601 }601 }
602 } catch (const WException & e) {602 } catch (const WException & e) {
603 throw GameDataError("militarysite: %s", e.what());603 throw GameDataError("militarysite: %s", e.what());
@@ -898,16 +898,16 @@
898 // player immovable owner is already in existence packet898 // player immovable owner is already in existence packet
899899
900 // write the general stuff900 // write the general stuff
901 if (building->m_anim) {901 if (building->anim_) {
902 fw.unsigned_8(1);902 fw.unsigned_8(1);
903 fw.string(building->descr().get_animation_name(building->m_anim));903 fw.string(building->descr().get_animation_name(building->anim_));
904 } else904 } else
905 fw.unsigned_8(0);905 fw.unsigned_8(0);
906906
907 fw.unsigned_32(building->m_animstart);907 fw.unsigned_32(building->animstart_);
908908
909 {909 {
910 const Building::LeaveQueue & leave_queue = building->m_leave_queue;910 const Building::LeaveQueue & leave_queue = building->leave_queue_;
911 fw.unsigned_16(leave_queue.size());911 fw.unsigned_16(leave_queue.size());
912 for (const OPtr<Worker >& temp_queue: leave_queue) {912 for (const OPtr<Worker >& temp_queue: leave_queue) {
913 assert(mos.is_object_known(*temp_queue.get(egbase)));913 assert(mos.is_object_known(*temp_queue.get(egbase)));
@@ -915,8 +915,8 @@
915 (mos.get_object_file_index(*temp_queue.get(egbase)));915 (mos.get_object_file_index(*temp_queue.get(egbase)));
916 }916 }
917 }917 }
918 fw.unsigned_32(building->m_leave_time);918 fw.unsigned_32(building->leave_time_);
919 if (MapObject const * const o = building->m_leave_allow.get(egbase))919 if (MapObject const * const o = building->leave_allow_.get(egbase))
920 {920 {
921 assert(mos.is_object_known(*o));921 assert(mos.is_object_known(*o));
922 fw.unsigned_32(mos.get_object_file_index(*o));922 fw.unsigned_32(mos.get_object_file_index(*o));
@@ -925,7 +925,7 @@
925 }925 }
926 {926 {
927 const TribeDescr& td = building->owner().tribe();927 const TribeDescr& td = building->owner().tribe();
928 for (DescriptionIndex b_idx : building->m_old_buildings) {928 for (DescriptionIndex b_idx : building->old_buildings_) {
929 const BuildingDescr* b_descr = td.get_building_descr(b_idx);929 const BuildingDescr* b_descr = td.get_building_descr(b_idx);
930 fw.unsigned_8(1);930 fw.unsigned_8(1);
931 fw.string(b_descr->name());931 fw.string(b_descr->name());
@@ -976,31 +976,31 @@
976 fw.unsigned_16(kCurrentPacketPFBuilding);976 fw.unsigned_16(kCurrentPacketPFBuilding);
977977
978 // descriptions978 // descriptions
979 fw.string(pfb.m_building->name());979 fw.string(pfb.building_->name());
980980
981 // builder request981 // builder request
982 if (pfb.m_builder_request) {982 if (pfb.builder_request_) {
983 fw.unsigned_8(1);983 fw.unsigned_8(1);
984 pfb.m_builder_request->write(fw, game, mos);984 pfb.builder_request_->write(fw, game, mos);
985 } else985 } else
986 fw.unsigned_8(0);986 fw.unsigned_8(0);
987987
988 // builder988 // builder
989 if (Worker const * builder = pfb.m_builder.get(game)) {989 if (Worker const * builder = pfb.builder_.get(game)) {
990 assert(mos.is_object_known(*builder));990 assert(mos.is_object_known(*builder));
991 fw.unsigned_32(mos.get_object_file_index(*builder));991 fw.unsigned_32(mos.get_object_file_index(*builder));
992 } else992 } else
993 fw.unsigned_32(0);993 fw.unsigned_32(0);
994994
995 const uint16_t wares_size = pfb.m_wares.size();995 const uint16_t wares_size = pfb.wares_.size();
996 fw.unsigned_16(wares_size);996 fw.unsigned_16(wares_size);
997 for (uint16_t i = 0; i < wares_size; ++i)997 for (uint16_t i = 0; i < wares_size; ++i)
998 pfb.m_wares[i]->write(fw, game, mos);998 pfb.wares_[i]->write(fw, game, mos);
999999
1000 fw.unsigned_8 (pfb.m_working);1000 fw.unsigned_8 (pfb.working_);
1001 fw.unsigned_32(pfb.m_work_steptime);1001 fw.unsigned_32(pfb.work_steptime_);
1002 fw.unsigned_32(pfb.m_work_completed);1002 fw.unsigned_32(pfb.work_completed_);
1003 fw.unsigned_32(pfb.m_work_steps);1003 fw.unsigned_32(pfb.work_steps_);
1004}1004}
10051005
1006void MapBuildingdataPacket::write_constructionsite1006void MapBuildingdataPacket::write_constructionsite
@@ -1014,7 +1014,7 @@
10141014
1015 write_partially_finished_building(constructionsite, fw, game, mos);1015 write_partially_finished_building(constructionsite, fw, game, mos);
10161016
1017 fw.signed_32(constructionsite.m_fetchfromflag);1017 fw.signed_32(constructionsite.fetchfromflag_);
1018}1018}
10191019
1020void MapBuildingdataPacket::write_dismantlesite1020void MapBuildingdataPacket::write_dismantlesite
@@ -1134,40 +1134,40 @@
1134{1134{
1135 fw.unsigned_16(kCurrentPacketVersionMilitarysite);1135 fw.unsigned_16(kCurrentPacketVersionMilitarysite);
11361136
1137 if (militarysite.m_normal_soldier_request) {1137 if (militarysite.normal_soldier_request_) {
1138 fw.unsigned_8(1);1138 fw.unsigned_8(1);
1139 militarysite.m_normal_soldier_request->write(fw, game, mos);1139 militarysite.normal_soldier_request_->write(fw, game, mos);
1140 } else {1140 } else {
1141 fw.unsigned_8(0);1141 fw.unsigned_8(0);
1142 }1142 }
11431143
1144 if (militarysite.m_upgrade_soldier_request)1144 if (militarysite.upgrade_soldier_request_)
1145 {1145 {
1146 fw.unsigned_8(1);1146 fw.unsigned_8(1);
1147 militarysite.m_upgrade_soldier_request->write(fw, game, mos);1147 militarysite.upgrade_soldier_request_->write(fw, game, mos);
1148 }1148 }
1149 else1149 else
1150 fw.unsigned_8(0);1150 fw.unsigned_8(0);
11511151
11521152
1153 fw.unsigned_8(militarysite.m_didconquer);1153 fw.unsigned_8(militarysite.didconquer_);
1154 fw.unsigned_8(militarysite.m_capacity);1154 fw.unsigned_8(militarysite.capacity_);
1155 fw.signed_32(militarysite.m_nexthealtime);1155 fw.signed_32(militarysite.nexthealtime_);
11561156
1157 if (militarysite.m_normal_soldier_request)1157 if (militarysite.normal_soldier_request_)
1158 {1158 {
1159 if (militarysite.m_upgrade_soldier_request)1159 if (militarysite.upgrade_soldier_request_)
1160 {1160 {
1161 throw GameDataError1161 throw GameDataError
1162 ("Internal error in a MilitarySite -- cannot continue. Use previous autosave.");1162 ("Internal error in a MilitarySite -- cannot continue. Use previous autosave.");
1163 }1163 }
1164 }1164 }
1165 fw.unsigned_16(militarysite.m_soldier_upgrade_requirements.get_min());1165 fw.unsigned_16(militarysite.soldier_upgrade_requirements_.get_min());
1166 fw.unsigned_16(militarysite.m_soldier_upgrade_requirements.get_max());1166 fw.unsigned_16(militarysite.soldier_upgrade_requirements_.get_max());
1167 fw.unsigned_8(militarysite.m_soldier_preference);1167 fw.unsigned_8(militarysite.soldier_preference_);
1168 fw.signed_32(militarysite.m_next_swap_soldiers_time);1168 fw.signed_32(militarysite.next_swap_soldiers_time_);
1169 fw.unsigned_8(militarysite.m_soldier_upgrade_try ? 1 : 0);1169 fw.unsigned_8(militarysite.soldier_upgrade_try_ ? 1 : 0);
1170 fw.unsigned_8(militarysite.m_doing_upgrade_request ? 1 : 0);1170 fw.unsigned_8(militarysite.doing_upgrade_request_ ? 1 : 0);
11711171
1172}1172}
11731173
11741174
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2016-01-31 15:31:00 +0000
+++ src/scripting/lua_map.cc 2016-02-08 18:17:36 +0000
@@ -1638,7 +1638,7 @@
1638 (RO) the workarea_radius of the building as an int.1638 (RO) the workarea_radius of the building as an int.
1639*/1639*/
1640int LuaBuildingDescription::get_workarea_radius(lua_State * L) {1640int LuaBuildingDescription::get_workarea_radius(lua_State * L) {
1641 lua_pushinteger(L, get()->m_workarea_info.begin()->first);1641 lua_pushinteger(L, get()->workarea_info_.begin()->first);
1642 return 1;1642 return 1;
1643}1643}
16441644
16451645
=== modified file 'src/wui/building_ui.cc'
--- src/wui/building_ui.cc 2015-11-28 22:29:26 +0000
+++ src/wui/building_ui.cc 2016-02-08 18:17:36 +0000
@@ -33,21 +33,21 @@
33 */33 */
34void Building::show_options(InteractiveGameBase & igbase, bool avoid_fastclick, Point pos)34void Building::show_options(InteractiveGameBase & igbase, bool avoid_fastclick, Point pos)
35{35{
36 if (m_optionswindow) {36 if (optionswindow_) {
37 if (m_optionswindow->is_minimal())37 if (optionswindow_->is_minimal())
38 m_optionswindow->restore();38 optionswindow_->restore();
39 m_optionswindow->move_to_top();39 optionswindow_->move_to_top();
40 } else {40 } else {
41 create_options_window(igbase, m_optionswindow);41 create_options_window(igbase, optionswindow_);
42 if (upcast(BuildingWindow, bw, m_optionswindow)) {42 if (upcast(BuildingWindow, bw, optionswindow_)) {
43 bw->set_avoid_fastclick(avoid_fastclick);43 bw->set_avoid_fastclick(avoid_fastclick);
44 }44 }
45 // Run a first think here so that certain things like caps buttons45 // Run a first think here so that certain things like caps buttons
46 // get properly initialized46 // get properly initialized
47 m_optionswindow->think();47 optionswindow_->think();
48 }48 }
49 if (pos.x >= 0 && pos.y >= 0) {49 if (pos.x >= 0 && pos.y >= 0) {
50 m_optionswindow->set_pos(pos);50 optionswindow_->set_pos(pos);
51 }51 }
52}52}
5353
@@ -58,8 +58,8 @@
58{58{
59 for (boost::signals2::connection& c : options_window_connections)59 for (boost::signals2::connection& c : options_window_connections)
60 c.disconnect();60 c.disconnect();
61 delete m_optionswindow;61 delete optionswindow_;
62 m_optionswindow = nullptr;62 optionswindow_ = nullptr;
63}63}
6464
65/**65/**
@@ -67,10 +67,10 @@
67 */67 */
68void Building::refresh_options(InteractiveGameBase & igb) {68void Building::refresh_options(InteractiveGameBase & igb) {
69 // Only do something if there is actually a window69 // Only do something if there is actually a window
70 if (m_optionswindow) {70 if (optionswindow_) {
71 Point window_position = m_optionswindow->get_pos();71 Point window_position = optionswindow_->get_pos();
72 hide_options();72 hide_options();
73 show_options(igb, true);73 show_options(igb, true);
74 m_optionswindow->set_pos(window_position);74 optionswindow_->set_pos(window_position);
75 }75 }
76}76}
7777
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2016-01-29 08:37:22 +0000
+++ src/wui/buildingwindow.cc 2016-02-08 18:17:36 +0000
@@ -304,9 +304,9 @@
304 if (can_see) {304 if (can_see) {
305 WorkareaInfo wa_info;305 WorkareaInfo wa_info;
306 if (upcast(Widelands::ConstructionSite, csite, &building_)) {306 if (upcast(Widelands::ConstructionSite, csite, &building_)) {
307 wa_info = csite->building().m_workarea_info;307 wa_info = csite->building().workarea_info_;
308 } else {308 } else {
309 wa_info = building_.descr().m_workarea_info;309 wa_info = building_.descr().workarea_info_;
310 }310 }
311 if (!wa_info.empty()) {311 if (!wa_info.empty()) {
312 toggle_workarea_ = new UI::Button312 toggle_workarea_ = new UI::Button
@@ -471,9 +471,9 @@
471 }471 }
472 WorkareaInfo workarea_info;472 WorkareaInfo workarea_info;
473 if (upcast(Widelands::ConstructionSite, csite, &building_)) {473 if (upcast(Widelands::ConstructionSite, csite, &building_)) {
474 workarea_info = csite->building().m_workarea_info;474 workarea_info = csite->building().workarea_info_;
475 } else {475 } else {
476 workarea_info = building_.descr().m_workarea_info;476 workarea_info = building_.descr().workarea_info_;
477 }477 }
478 if (workarea_info.empty()) {478 if (workarea_info.empty()) {
479 return;479 return;
480480
=== modified file 'src/wui/fieldaction.cc'
--- src/wui/fieldaction.cc 2016-01-29 08:37:22 +0000
+++ src/wui/fieldaction.cc 2016-02-08 18:17:36 +0000
@@ -821,7 +821,7 @@
821{821{
822 if (ibase().show_workarea_preview_ && !m_workarea_preview_overlay_id) {822 if (ibase().show_workarea_preview_ && !m_workarea_preview_overlay_id) {
823 const WorkareaInfo& workarea_info =823 const WorkareaInfo& workarea_info =
824 m_plr->tribe().get_building_descr(Widelands::DescriptionIndex(idx))->m_workarea_info;824 m_plr->tribe().get_building_descr(Widelands::DescriptionIndex(idx))->workarea_info_;
825 m_workarea_preview_overlay_id = ibase().show_work_area(workarea_info, m_node);825 m_workarea_preview_overlay_id = ibase().show_work_area(workarea_info, m_node);
826 }826 }
827}827}
828828
=== modified file 'src/wui/soldiercapacitycontrol.cc'
--- src/wui/soldiercapacitycontrol.cc 2016-01-29 08:37:22 +0000
+++ src/wui/soldiercapacitycontrol.cc 2016-02-08 18:17:36 +0000
@@ -46,7 +46,7 @@
46 void click_increase();46 void click_increase();
4747
48 InteractiveGameBase & m_igb;48 InteractiveGameBase & m_igb;
49 Widelands::Building & m_building;49 Widelands::Building & building_;
5050
51 UI::Button m_decrease;51 UI::Button m_decrease;
52 UI::Button m_increase;52 UI::Button m_increase;
@@ -59,7 +59,7 @@
59:59:
60Box(parent, 0, 0, Horizontal),60Box(parent, 0, 0, Horizontal),
61m_igb(igb),61m_igb(igb),
62m_building(building),62building_(building),
63m_decrease63m_decrease
64 (this, "decrease", 0, 0, 32, 32,64 (this, "decrease", 0, 0, 32, 32,
65 g_gr->images().get("images/ui_basic/but4.png"),65 g_gr->images().get("images/ui_basic/but4.png"),
@@ -86,21 +86,21 @@
8686
87void SoldierCapacityControl::think()87void SoldierCapacityControl::think()
88{88{
89 SoldierControl * soldiers = dynamic_cast<SoldierControl *>(&m_building);89 SoldierControl * soldiers = dynamic_cast<SoldierControl *>(&building_);
90 uint32_t const capacity = soldiers->soldier_capacity();90 uint32_t const capacity = soldiers->soldier_capacity();
91 char buffer[sizeof("4294967295")];91 char buffer[sizeof("4294967295")];
9292
93 sprintf(buffer, "%2u", capacity);93 sprintf(buffer, "%2u", capacity);
94 m_value.set_text(buffer);94 m_value.set_text(buffer);
9595
96 bool const can_act = m_igb.can_act(m_building.owner().player_number());96 bool const can_act = m_igb.can_act(building_.owner().player_number());
97 m_decrease.set_enabled(can_act && soldiers->min_soldier_capacity() < capacity);97 m_decrease.set_enabled(can_act && soldiers->min_soldier_capacity() < capacity);
98 m_increase.set_enabled(can_act && soldiers->max_soldier_capacity() > capacity);98 m_increase.set_enabled(can_act && soldiers->max_soldier_capacity() > capacity);
99}99}
100100
101void SoldierCapacityControl::change_soldier_capacity(int delta)101void SoldierCapacityControl::change_soldier_capacity(int delta)
102{102{
103 m_igb.game().send_player_change_soldier_capacity(m_building, delta);103 m_igb.game().send_player_change_soldier_capacity(building_, delta);
104}104}
105105
106void SoldierCapacityControl::click_decrease()106void SoldierCapacityControl::click_decrease()
107107
=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc 2016-01-31 21:03:15 +0000
+++ src/wui/soldierlist.cc 2016-02-08 18:17:36 +0000
@@ -371,7 +371,7 @@
371 void think() override;371 void think() override;
372372
373 InteractiveGameBase & m_igb;373 InteractiveGameBase & m_igb;
374 Widelands::Building & m_building;374 Widelands::Building & building_;
375 SoldierPanel m_soldierpanel;375 SoldierPanel m_soldierpanel;
376 UI::Radiogroup m_soldier_preference;376 UI::Radiogroup m_soldier_preference;
377 UI::Textarea m_infotext;377 UI::Textarea m_infotext;
@@ -385,7 +385,7 @@
385UI::Box(&parent, 0, 0, UI::Box::Vertical),385UI::Box(&parent, 0, 0, UI::Box::Vertical),
386386
387m_igb(igb),387m_igb(igb),
388m_building(building),388building_(building),
389m_soldierpanel(*this, igb.egbase(), building),389m_soldierpanel(*this, igb.egbase(), building),
390m_infotext(this, _("Click soldier to send away"))390m_infotext(this, _("Click soldier to send away"))
391{391{
@@ -413,7 +413,7 @@
413413
414 UI::Box * buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal);414 UI::Box * buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal);
415415
416 bool can_act = m_igb.can_act(m_building.owner().player_number());416 bool can_act = m_igb.can_act(building_.owner().player_number());
417 if (upcast(Widelands::MilitarySite, ms, &building)) {417 if (upcast(Widelands::MilitarySite, ms, &building)) {
418 m_soldier_preference.add_button418 m_soldier_preference.add_button
419 (buttons, Point(0, 0),419 (buttons, Point(0, 0),
@@ -450,16 +450,16 @@
450450
451SoldierControl & SoldierList::soldiers() const451SoldierControl & SoldierList::soldiers() const
452{452{
453 return *dynamic_cast<SoldierControl *>(&m_building);453 return *dynamic_cast<SoldierControl *>(&building_);
454}454}
455455
456void SoldierList::think()456void SoldierList::think()
457{457{
458 // Only update the soldiers pref radio if player is spectator458 // Only update the soldiers pref radio if player is spectator
459 if (m_igb.can_act(m_building.owner().player_number())) {459 if (m_igb.can_act(building_.owner().player_number())) {
460 return;460 return;
461 }461 }
462 if (upcast(Widelands::MilitarySite, ms, &m_building)) {462 if (upcast(Widelands::MilitarySite, ms, &building_)) {
463 switch (ms->get_soldier_preference()) {463 switch (ms->get_soldier_preference()) {
464 case Widelands::MilitarySite::kPrefersRookies:464 case Widelands::MilitarySite::kPrefersRookies:
465 m_soldier_preference.set_state(0);465 m_soldier_preference.set_state(0);
@@ -495,20 +495,20 @@
495void SoldierList::eject(const Soldier * soldier)495void SoldierList::eject(const Soldier * soldier)
496{496{
497 uint32_t const capacity_min = soldiers().min_soldier_capacity();497 uint32_t const capacity_min = soldiers().min_soldier_capacity();
498 bool can_act = m_igb.can_act(m_building.owner().player_number());498 bool can_act = m_igb.can_act(building_.owner().player_number());
499 bool over_min = capacity_min < soldiers().present_soldiers().size();499 bool over_min = capacity_min < soldiers().present_soldiers().size();
500500
501 if (can_act && over_min)501 if (can_act && over_min)
502 m_igb.game().send_player_drop_soldier(m_building, soldier->serial());502 m_igb.game().send_player_drop_soldier(building_, soldier->serial());
503}503}
504504
505void SoldierList::set_soldier_preference(int32_t changed_to) {505void SoldierList::set_soldier_preference(int32_t changed_to) {
506#ifndef NDEBUG506#ifndef NDEBUG
507 upcast(Widelands::MilitarySite, ms, &m_building);507 upcast(Widelands::MilitarySite, ms, &building_);
508 assert(ms);508 assert(ms);
509#endif509#endif
510 m_igb.game().send_player_militarysite_set_soldier_preference510 m_igb.game().send_player_militarysite_set_soldier_preference
511 (m_building, changed_to == 0 ?511 (building_, changed_to == 0 ?
512 Widelands::MilitarySite::kPrefersRookies:512 Widelands::MilitarySite::kPrefersRookies:
513 Widelands::MilitarySite::kPrefersHeroes);513 Widelands::MilitarySite::kPrefersHeroes);
514}514}

Subscribers

People subscribed via source and target branches

to status/vote changes: