Merge lp:~widelands-dev/widelands/bug-1395278-logic2 into lp:widelands
- bug-1395278-logic2
- Merge into trunk
Proposed by
Klaus Halfmann
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 7865 | ||||
Proposed branch: | lp:~widelands-dev/widelands/bug-1395278-logic2 | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
3094 lines (+642/-642) 27 files modified
src/game_io/game_player_economies_packet.cc (+2/-2) src/game_io/game_player_info_packet.cc (+10/-10) src/logic/editor_game_base.cc (+3/-3) src/logic/map.cc (+7/-7) src/logic/mapastar.cc (+4/-4) src/logic/objective.h (+19/-19) src/logic/path.cc (+36/-36) src/logic/path.h (+21/-21) src/logic/pathfield.cc (+9/-9) src/logic/pathfield.h (+2/-2) src/logic/player.cc (+148/-148) src/logic/player.h (+71/-71) src/logic/playercommand.cc (+94/-94) src/logic/playercommand.h (+34/-34) src/logic/playersmanager.cc (+18/-18) src/logic/playersmanager.h (+8/-8) src/logic/replay.cc (+43/-43) src/logic/replay.h (+5/-5) src/logic/replay_game_controller.cc (+23/-23) src/logic/replay_game_controller.h (+6/-6) src/logic/save_handler.cc (+13/-13) src/logic/save_handler.h (+14/-14) src/logic/single_player_game_controller.cc (+38/-38) src/logic/single_player_game_controller.h (+9/-9) src/map_io/map_buildingdata_packet.cc (+2/-2) src/map_io/map_exploration_packet.cc (+1/-1) src/map_io/map_players_view_packet.cc (+2/-2) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/bug-1395278-logic2 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Widelands Developers | Pending | ||
Review via email: mp+287687@code.launchpad.net |
Commit message
Refactored more member variables in src/logic.
Description of the change
Review is ok for me, pure renaming, nothing else,
will play some open network game now...
To post a comment you must log in.
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote : | # |
Revision history for this message
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 790. State: passed. Details: https:/
Appveyor build 636. State: success. Details: https:/
Revision history for this message
GunChleoc (gunchleoc) wrote : | # |
Thanks for the review :)
@bunnybot merge
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/game_io/game_player_economies_packet.cc' |
2 | --- src/game_io/game_player_economies_packet.cc 2015-11-28 22:29:26 +0000 |
3 | +++ src/game_io/game_player_economies_packet.cc 2016-03-02 14:42:23 +0000 |
4 | @@ -48,7 +48,7 @@ |
5 | if (packet_version == kCurrentPacketVersion) { |
6 | iterate_players_existing(p, nr_players, game, player) |
7 | try { |
8 | - Player::Economies & economies = player->m_economies; |
9 | + Player::Economies & economies = player->economies_; |
10 | for (uint32_t i = 0; i < economies.size(); ++i) { |
11 | uint32_t value = fr.unsigned_32(); |
12 | if (value < 0xffffffff) { |
13 | @@ -106,7 +106,7 @@ |
14 | const Field & field_0 = map[0]; |
15 | PlayerNumber const nr_players = map.get_nrplayers(); |
16 | iterate_players_existing_const(p, nr_players, game, player) { |
17 | - const Player::Economies & economies = player->m_economies; |
18 | + const Player::Economies & economies = player->economies_; |
19 | for (Economy * temp_economy : economies) { |
20 | bool wrote_this_economy = false; |
21 | |
22 | |
23 | === modified file 'src/game_io/game_player_info_packet.cc' |
24 | --- src/game_io/game_player_info_packet.cc 2016-01-22 19:53:32 +0000 |
25 | +++ src/game_io/game_player_info_packet.cc 2016-03-02 14:42:23 +0000 |
26 | @@ -64,12 +64,12 @@ |
27 | player.read_statistics(fr); |
28 | player.read_remaining_shipnames(fr); |
29 | |
30 | - player.m_casualties = fr.unsigned_32(); |
31 | - player.m_kills = fr.unsigned_32(); |
32 | - player.m_msites_lost = fr.unsigned_32(); |
33 | - player.m_msites_defeated = fr.unsigned_32(); |
34 | - player.m_civil_blds_lost = fr.unsigned_32(); |
35 | - player.m_civil_blds_defeated = fr.unsigned_32(); |
36 | + player.casualties_ = fr.unsigned_32(); |
37 | + player.kills_ = fr.unsigned_32(); |
38 | + player.msites_lost_ = fr.unsigned_32(); |
39 | + player.msites_defeated_ = fr.unsigned_32(); |
40 | + player.civil_blds_lost_ = fr.unsigned_32(); |
41 | + player.civil_blds_defeated_ = fr.unsigned_32(); |
42 | } |
43 | } |
44 | game.read_statistics(fr); |
45 | @@ -95,9 +95,9 @@ |
46 | iterate_players_existing_const(p, nr_players, game, plr) { |
47 | fw.unsigned_8(1); // Player is in game. |
48 | |
49 | - fw.unsigned_8(plr->m_see_all); |
50 | + fw.unsigned_8(plr->see_all_); |
51 | |
52 | - fw.unsigned_8(plr->m_plnum); |
53 | + fw.unsigned_8(plr->player_number_); |
54 | fw.unsigned_8(plr->team_number()); |
55 | |
56 | fw.c_string(plr->tribe().name().c_str()); |
57 | @@ -107,8 +107,8 @@ |
58 | |
59 | // Economies are in a packet after map loading |
60 | |
61 | - fw.c_string(plr->m_name.c_str()); |
62 | - fw.c_string(plr->m_ai.c_str()); |
63 | + fw.c_string(plr->name_.c_str()); |
64 | + fw.c_string(plr->ai_.c_str()); |
65 | |
66 | plr->write_statistics(fw); |
67 | plr->write_remaining_shipnames(fw); |
68 | |
69 | === modified file 'src/logic/editor_game_base.cc' |
70 | --- src/logic/editor_game_base.cc 2016-02-08 20:44:17 +0000 |
71 | +++ src/logic/editor_game_base.cc 2016-03-02 14:42:23 +0000 |
72 | @@ -184,7 +184,7 @@ |
73 | (MapIndex const i, PlayerNumber const new_owner) |
74 | { |
75 | iterate_players_existing_const(plnum, MAX_PLAYERS, *this, p) { |
76 | - Player::Field & player_field = p->m_fields[i]; |
77 | + Player::Field & player_field = p->fields_[i]; |
78 | if (1 < player_field.vision) { |
79 | player_field.owner = new_owner; |
80 | } |
81 | @@ -195,7 +195,7 @@ |
82 | { |
83 | if (!Road::is_road_descr(descr)) |
84 | iterate_players_existing_const(plnum, MAX_PLAYERS, *this, p) { |
85 | - Player::Field & player_field = p->m_fields[i]; |
86 | + Player::Field & player_field = p->fields_[i]; |
87 | if (1 < player_field.vision) { |
88 | player_field.map_object_descr[TCoords<>::None] = descr; |
89 | } |
90 | @@ -523,7 +523,7 @@ |
91 | MapIndex const i = f .field - &first_field; |
92 | MapIndex const neighbour_i = neighbour.field - &first_field; |
93 | iterate_players_existing_const(plnum, MAX_PLAYERS, *this, p) { |
94 | - Player::Field & first_player_field = *p->m_fields; |
95 | + Player::Field & first_player_field = *p->fields_; |
96 | Player::Field & player_field = (&first_player_field)[i]; |
97 | if |
98 | (1 < player_field .vision |
99 | |
100 | === modified file 'src/logic/map.cc' |
101 | --- src/logic/map.cc 2016-02-22 08:50:04 +0000 |
102 | +++ src/logic/map.cc 2016-03-02 14:42:23 +0000 |
103 | @@ -1694,12 +1694,12 @@ |
104 | start = FCoords(instart, &operator[](instart)); |
105 | end = FCoords(inend, &operator[](inend)); |
106 | |
107 | - path.m_path.clear(); |
108 | + path.path_.clear(); |
109 | |
110 | // Some stupid cases... |
111 | if (start == end) { |
112 | - path.m_start = start; |
113 | - path.m_end = end; |
114 | + path.start_ = start; |
115 | + path.end_ = end; |
116 | return 0; // duh... |
117 | } |
118 | |
119 | @@ -1798,13 +1798,13 @@ |
120 | // Now unwind the taken route (even if we couldn't find a complete one!) |
121 | int32_t const result = cur == end ? curpf->real_cost : -1; |
122 | |
123 | - path.m_start = start; |
124 | - path.m_end = cur; |
125 | + path.start_ = start; |
126 | + path.end_ = cur; |
127 | |
128 | - path.m_path.clear(); |
129 | + path.path_.clear(); |
130 | |
131 | while (curpf->backlink != IDLE) { |
132 | - path.m_path.push_back(curpf->backlink); |
133 | + path.path_.push_back(curpf->backlink); |
134 | |
135 | // Reverse logic! (WALK_NW needs to find the SE neighbour) |
136 | get_neighbour(cur, get_reverse_dir(curpf->backlink), &cur); |
137 | |
138 | === modified file 'src/logic/mapastar.cc' |
139 | --- src/logic/mapastar.cc 2015-11-29 09:43:15 +0000 |
140 | +++ src/logic/mapastar.cc 2016-03-02 14:42:23 +0000 |
141 | @@ -31,8 +31,8 @@ |
142 | */ |
143 | void MapAStarBase::pathto(Coords dest, Path & path) const |
144 | { |
145 | - path.m_end = dest; |
146 | - path.m_path.clear(); |
147 | + path.end_ = dest; |
148 | + path.path_.clear(); |
149 | |
150 | Coords cur = dest; |
151 | for (;;) { |
152 | @@ -43,12 +43,12 @@ |
153 | if (pf.backlink == IDLE) |
154 | break; |
155 | |
156 | - path.m_path.push_back(pf.backlink); |
157 | + path.path_.push_back(pf.backlink); |
158 | |
159 | map.get_neighbour(cur, get_reverse_dir(pf.backlink), &cur); |
160 | } |
161 | |
162 | - path.m_start = cur; |
163 | + path.start_ = cur; |
164 | } |
165 | |
166 | } // namespace Widelands |
167 | |
168 | === modified file 'src/logic/objective.h' |
169 | --- src/logic/objective.h 2015-08-04 07:49:23 +0000 |
170 | +++ src/logic/objective.h 2016-03-02 14:42:23 +0000 |
171 | @@ -33,57 +33,57 @@ |
172 | class Objective { |
173 | public: |
174 | Objective(const std::string& init_name) |
175 | - : m_name(init_name), |
176 | - m_descname(init_name), |
177 | - m_descr(_("This objective has no description.")), |
178 | - m_visible(true), |
179 | - m_done(false) { |
180 | + : name_(init_name), |
181 | + descname_(init_name), |
182 | + descr_(_("This objective has no description.")), |
183 | + visible_(true), |
184 | + done_(false) { |
185 | } |
186 | |
187 | // Unique internal name of the objective. |
188 | const std::string& name() const { |
189 | - return m_name; |
190 | + return name_; |
191 | } |
192 | |
193 | // User facing (translated) descriptive name. |
194 | const std::string& descname() const { |
195 | - return m_descname; |
196 | + return descname_; |
197 | } |
198 | void set_descname(const std::string& new_name) { |
199 | - m_descname = new_name; |
200 | + descname_ = new_name; |
201 | } |
202 | |
203 | // Description text of this name. |
204 | const std::string& descr() const { |
205 | - return m_descr; |
206 | + return descr_; |
207 | } |
208 | void set_descr(const std::string& new_descr) { |
209 | - m_descr = new_descr; |
210 | + descr_ = new_descr; |
211 | } |
212 | |
213 | // True, if this objective is fulfilled. |
214 | bool done() const { |
215 | - return m_done; |
216 | + return done_; |
217 | } |
218 | |
219 | void set_done(bool t) { |
220 | - m_done = t; |
221 | + done_ = t; |
222 | } |
223 | |
224 | // True, if this objective is visible to the user. |
225 | bool visible() const { |
226 | - return m_visible; |
227 | + return visible_; |
228 | } |
229 | void set_visible(const bool t) { |
230 | - m_visible = t; |
231 | + visible_ = t; |
232 | } |
233 | |
234 | private: |
235 | - const std::string m_name; |
236 | - std::string m_descname; |
237 | - std::string m_descr; |
238 | - bool m_visible; |
239 | - bool m_done; |
240 | + const std::string name_; |
241 | + std::string descname_; |
242 | + std::string descr_; |
243 | + bool visible_; |
244 | + bool done_; |
245 | }; |
246 | } |
247 | |
248 | |
249 | === modified file 'src/logic/path.cc' |
250 | --- src/logic/path.cc 2015-11-29 09:43:15 +0000 |
251 | +++ src/logic/path.cc 2016-03-02 14:42:23 +0000 |
252 | @@ -33,9 +33,9 @@ |
253 | constexpr uint8_t kCurrentPacketVersion = 1; |
254 | |
255 | Path::Path(CoordPath & o) |
256 | - : m_start(o.get_start()), m_end(o.get_end()), m_path(o.steps()) |
257 | + : start_(o.get_start()), end_(o.get_end()), path_(o.steps()) |
258 | { |
259 | - std::reverse(m_path.begin(), m_path.end()); // path stored in reverse order |
260 | + std::reverse(path_.begin(), path_.end()); // path stored in reverse order |
261 | } |
262 | |
263 | /* |
264 | @@ -45,11 +45,11 @@ |
265 | */ |
266 | void Path::reverse() |
267 | { |
268 | - std::swap(m_start, m_end); |
269 | - std::reverse(m_path.begin(), m_path.end()); |
270 | + std::swap(start_, end_); |
271 | + std::reverse(path_.begin(), path_.end()); |
272 | |
273 | - for (uint32_t i = 0; i < m_path.size(); ++i) |
274 | - m_path[i] = get_reverse_dir(m_path[i]); |
275 | + for (uint32_t i = 0; i < path_.size(); ++i) |
276 | + path_[i] = get_reverse_dir(path_[i]); |
277 | } |
278 | |
279 | /* |
280 | @@ -58,8 +58,8 @@ |
281 | =============== |
282 | */ |
283 | void Path::append(const Map & map, const Direction dir) { |
284 | - m_path.insert(m_path.begin(), dir); // stores in reversed order! |
285 | - map.get_neighbour(m_end, dir, &m_end); |
286 | + path_.insert(path_.begin(), dir); // stores in reversed order! |
287 | + map.get_neighbour(end_, dir, &end_); |
288 | } |
289 | |
290 | /** |
291 | @@ -68,13 +68,13 @@ |
292 | void Path::save(FileWrite & fw) const |
293 | { |
294 | fw.unsigned_8(kCurrentPacketVersion); |
295 | - write_coords_32(&fw, m_start); |
296 | + write_coords_32(&fw, start_); |
297 | |
298 | // Careful: steps are stored in the reverse order in m_path |
299 | // However, we save them in the forward order, to make loading easier |
300 | - fw.unsigned_32(m_path.size()); |
301 | - for (uint32_t i = m_path.size(); i > 0; --i) |
302 | - write_direction_8(&fw, m_path[i - 1]); |
303 | + fw.unsigned_32(path_.size()); |
304 | + for (uint32_t i = path_.size(); i > 0; --i) |
305 | + write_direction_8(&fw, path_[i - 1]); |
306 | } |
307 | |
308 | /** |
309 | @@ -89,8 +89,8 @@ |
310 | uint8_t packet_version = fr.unsigned_8(); |
311 | if (packet_version == kCurrentPacketVersion) { |
312 | |
313 | - m_start = m_end = read_coords_32(&fr, map.extent()); |
314 | - m_path.clear(); |
315 | + start_ = end_ = read_coords_32(&fr, map.extent()); |
316 | + path_.clear(); |
317 | uint32_t steps = fr.unsigned_32(); |
318 | while (steps--) |
319 | append(map, read_direction_8(&fr)); |
320 | @@ -108,10 +108,10 @@ |
321 | =============== |
322 | */ |
323 | CoordPath::CoordPath(const Map & map, const Path & path) { |
324 | - m_coords.clear(); |
325 | - m_path.clear(); |
326 | + coords_.clear(); |
327 | + path_.clear(); |
328 | |
329 | - m_coords.push_back(path.get_start()); |
330 | + coords_.push_back(path.get_start()); |
331 | |
332 | Coords c = path.get_start(); |
333 | |
334 | @@ -119,9 +119,9 @@ |
335 | for (Path::StepVector::size_type i = 0; i < nr_steps; ++i) { |
336 | const char dir = path[i]; |
337 | |
338 | - m_path.push_back(dir); |
339 | + path_.push_back(dir); |
340 | map.get_neighbour(c, dir, &c); |
341 | - m_coords.push_back(c); |
342 | + coords_.push_back(c); |
343 | } |
344 | } |
345 | |
346 | @@ -130,8 +130,8 @@ |
347 | /// \return -1 if node is not part of this path. |
348 | int32_t CoordPath::get_index(Coords const c) const |
349 | { |
350 | - for (uint32_t i = 0; i < m_coords.size(); ++i) |
351 | - if (m_coords[i] == c) |
352 | + for (uint32_t i = 0; i < coords_.size(); ++i) |
353 | + if (coords_[i] == c) |
354 | return i; |
355 | |
356 | return -1; |
357 | @@ -145,11 +145,11 @@ |
358 | */ |
359 | void CoordPath::reverse() |
360 | { |
361 | - std::reverse(m_path.begin(), m_path.end()); |
362 | - std::reverse(m_coords.begin(), m_coords.end()); |
363 | + std::reverse(path_.begin(), path_.end()); |
364 | + std::reverse(coords_.begin(), coords_.end()); |
365 | |
366 | - for (uint32_t i = 0; i < m_path.size(); ++i) |
367 | - m_path[i] = get_reverse_dir(m_path[i]); |
368 | + for (uint32_t i = 0; i < path_.size(); ++i) |
369 | + path_[i] = get_reverse_dir(path_[i]); |
370 | } |
371 | |
372 | |
373 | @@ -159,10 +159,10 @@ |
374 | =============== |
375 | */ |
376 | void CoordPath::truncate(const std::vector<char>::size_type after) { |
377 | - assert(after <= m_path.size()); |
378 | + assert(after <= path_.size()); |
379 | |
380 | - m_path.erase(m_path.begin() + after, m_path.end()); |
381 | - m_coords.erase(m_coords.begin() + after + 1, m_coords.end()); |
382 | + path_.erase(path_.begin() + after, path_.end()); |
383 | + coords_.erase(coords_.begin() + after + 1, coords_.end()); |
384 | } |
385 | |
386 | /* |
387 | @@ -171,10 +171,10 @@ |
388 | =============== |
389 | */ |
390 | void CoordPath::trim_start(const std::vector<char>::size_type before) { |
391 | - assert(before <= m_path.size()); |
392 | + assert(before <= path_.size()); |
393 | |
394 | - m_path.erase(m_path.begin(), m_path.begin() + before); |
395 | - m_coords.erase(m_coords.begin(), m_coords.begin() + before); |
396 | + path_.erase(path_.begin(), path_.begin() + before); |
397 | + coords_.erase(coords_.begin(), coords_.begin() + before); |
398 | } |
399 | |
400 | /* |
401 | @@ -192,8 +192,8 @@ |
402 | const char dir = tail[i]; |
403 | |
404 | map.get_neighbour(c, dir, &c); |
405 | - m_path.push_back(dir); |
406 | - m_coords.push_back(c); |
407 | + path_.push_back(dir); |
408 | + coords_.push_back(c); |
409 | } |
410 | } |
411 | |
412 | @@ -206,9 +206,9 @@ |
413 | { |
414 | assert(tail.get_start() == get_end()); |
415 | |
416 | - m_path.insert(m_path.end(), tail.m_path.begin(), tail.m_path.end()); |
417 | - m_coords.insert |
418 | - (m_coords.end(), tail.m_coords.begin() + 1, tail.m_coords.end()); |
419 | + path_.insert(path_.end(), tail.path_.begin(), tail.path_.end()); |
420 | + coords_.insert |
421 | + (coords_.end(), tail.coords_.begin() + 1, tail.coords_.end()); |
422 | } |
423 | |
424 | } |
425 | |
426 | === modified file 'src/logic/path.h' |
427 | --- src/logic/path.h 2014-09-19 12:54:54 +0000 |
428 | +++ src/logic/path.h 2016-03-02 14:42:23 +0000 |
429 | @@ -42,54 +42,54 @@ |
430 | friend struct MapAStarBase; |
431 | |
432 | Path() {} |
433 | - Path(const Coords & c) : m_start(c), m_end(c) {} |
434 | + Path(const Coords & c) : start_(c), end_(c) {} |
435 | Path(CoordPath &); |
436 | |
437 | void reverse(); |
438 | |
439 | - Coords get_start() const {return m_start;} |
440 | - Coords get_end () const {return m_end;} |
441 | + Coords get_start() const {return start_;} |
442 | + Coords get_end () const {return end_;} |
443 | |
444 | using StepVector = std::vector<Direction>; |
445 | - StepVector::size_type get_nsteps() const {return m_path.size();} |
446 | + StepVector::size_type get_nsteps() const {return path_.size();} |
447 | Direction operator[](StepVector::size_type const i) const { |
448 | - assert(i < m_path.size()); |
449 | - return m_path[m_path.size() - i - 1]; |
450 | + assert(i < path_.size()); |
451 | + return path_[path_.size() - i - 1]; |
452 | } |
453 | |
454 | void append(const Map & map, Direction); |
455 | |
456 | void reorigin(const Coords & new_origin, const Extent & extent) { |
457 | - m_start.reorigin(new_origin, extent); |
458 | - m_end .reorigin(new_origin, extent); |
459 | + start_.reorigin(new_origin, extent); |
460 | + end_ .reorigin(new_origin, extent); |
461 | } |
462 | |
463 | void save(FileWrite & fw) const; |
464 | void load(FileRead & fr, const Map & map); |
465 | |
466 | private: |
467 | - Coords m_start; |
468 | - Coords m_end; |
469 | - StepVector m_path; |
470 | + Coords start_; |
471 | + Coords end_; |
472 | + StepVector path_; |
473 | }; |
474 | |
475 | // CoordPath is an extended path that also caches related Coords |
476 | struct CoordPath { |
477 | CoordPath() {} |
478 | - CoordPath(Coords c) {m_coords.push_back(c);} |
479 | + CoordPath(Coords c) {coords_.push_back(c);} |
480 | CoordPath(const Map & map, const Path & path); |
481 | |
482 | - Coords get_start() const {return m_coords.front();} |
483 | - Coords get_end () const {return m_coords.back ();} |
484 | - const std::vector<Coords> &get_coords() const {return m_coords;} |
485 | + Coords get_start() const {return coords_.front();} |
486 | + Coords get_end () const {return coords_.back ();} |
487 | + const std::vector<Coords> &get_coords() const {return coords_;} |
488 | |
489 | using StepVector = std::vector<Direction>; |
490 | - StepVector::size_type get_nsteps() const {return m_path.size();} |
491 | + StepVector::size_type get_nsteps() const {return path_.size();} |
492 | Direction operator[](StepVector::size_type const i) const { |
493 | - assert(i < m_path.size()); |
494 | - return m_path[i]; |
495 | + assert(i < path_.size()); |
496 | + return path_[i]; |
497 | } |
498 | - const StepVector & steps() const {return m_path;} |
499 | + const StepVector & steps() const {return path_;} |
500 | |
501 | int32_t get_index(Coords field) const; |
502 | |
503 | @@ -100,8 +100,8 @@ |
504 | void append(const CoordPath & tail); |
505 | |
506 | private: |
507 | - StepVector m_path; // directions |
508 | - std::vector<Coords> m_coords; // m_coords.size() == m_path.size() + 1 |
509 | + StepVector path_; // directions |
510 | + std::vector<Coords> coords_; // coords_.size() == path_.size() + 1 |
511 | }; |
512 | |
513 | } |
514 | |
515 | === modified file 'src/logic/pathfield.cc' |
516 | --- src/logic/pathfield.cc 2014-11-28 16:40:55 +0000 |
517 | +++ src/logic/pathfield.cc 2016-03-02 14:42:23 +0000 |
518 | @@ -28,20 +28,20 @@ |
519 | {} |
520 | |
521 | |
522 | -PathfieldManager::PathfieldManager() : m_nrfields(0) {} |
523 | +PathfieldManager::PathfieldManager() : nrfields_(0) {} |
524 | |
525 | |
526 | void PathfieldManager::set_size(uint32_t const nrfields) |
527 | { |
528 | - if (m_nrfields != nrfields) |
529 | - m_list.clear(); |
530 | + if (nrfields_ != nrfields) |
531 | + list_.clear(); |
532 | |
533 | - m_nrfields = nrfields; |
534 | + nrfields_ = nrfields; |
535 | } |
536 | |
537 | boost::shared_ptr<Pathfields> PathfieldManager::allocate() |
538 | { |
539 | - for (boost::shared_ptr<Pathfields>& pathfield : m_list) { |
540 | + for (boost::shared_ptr<Pathfields>& pathfield : list_) { |
541 | if (pathfield.use_count() == 1) { |
542 | ++pathfield->cycle; |
543 | if (!pathfield->cycle) { |
544 | @@ -51,18 +51,18 @@ |
545 | } |
546 | } |
547 | |
548 | - if (m_list.size() >= 8) |
549 | + if (list_.size() >= 8) |
550 | throw wexception("PathfieldManager::allocate: unbounded nesting?"); |
551 | |
552 | - boost::shared_ptr<Pathfields> pf(new Pathfields(m_nrfields)); |
553 | + boost::shared_ptr<Pathfields> pf(new Pathfields(nrfields_)); |
554 | clear(pf); |
555 | - m_list.push_back(pf); |
556 | + list_.push_back(pf); |
557 | return pf; |
558 | } |
559 | |
560 | void PathfieldManager::clear(const boost::shared_ptr<Pathfields> & pf) |
561 | { |
562 | - for (uint32_t i = 0; i < m_nrfields; ++i) |
563 | + for (uint32_t i = 0; i < nrfields_; ++i) |
564 | pf->fields[i].cycle = 0; |
565 | pf->cycle = 1; |
566 | } |
567 | |
568 | === modified file 'src/logic/pathfield.h' |
569 | --- src/logic/pathfield.h 2014-09-19 12:54:54 +0000 |
570 | +++ src/logic/pathfield.h 2016-03-02 14:42:23 +0000 |
571 | @@ -82,8 +82,8 @@ |
572 | |
573 | using List = std::vector<boost::shared_ptr<Pathfields>>; |
574 | |
575 | - uint32_t m_nrfields; |
576 | - List m_list; |
577 | + uint32_t nrfields_; |
578 | + List list_; |
579 | }; |
580 | |
581 | } |
582 | |
583 | === modified file 'src/logic/player.cc' |
584 | --- src/logic/player.cc 2016-02-18 08:42:46 +0000 |
585 | +++ src/logic/player.cc 2016-03-02 14:42:23 +0000 |
586 | @@ -140,45 +140,45 @@ |
587 | const TribeDescr & tribe_descr, |
588 | const std::string & name) |
589 | : |
590 | - m_egbase (the_egbase), |
591 | - m_initialization_index(initialization_index), |
592 | - m_team_number(0), |
593 | - m_team_player_uptodate(false), |
594 | - m_see_all (false), |
595 | - m_plnum (plnum), |
596 | - m_tribe (tribe_descr), |
597 | - m_casualties (0), |
598 | - m_kills (0), |
599 | - m_msites_lost (0), |
600 | - m_msites_defeated (0), |
601 | - m_civil_blds_lost (0), |
602 | - m_civil_blds_defeated(0), |
603 | - m_fields (nullptr), |
604 | - m_allowed_worker_types(the_egbase.tribes().nrworkers(), true), |
605 | - m_allowed_building_types(the_egbase.tribes().nrbuildings(), true), |
606 | - m_ai(""), |
607 | - m_current_produced_statistics(the_egbase.tribes().nrwares()), |
608 | - m_current_consumed_statistics(the_egbase.tribes().nrwares()), |
609 | - m_ware_productions(the_egbase.tribes().nrwares()), |
610 | - m_ware_consumptions(the_egbase.tribes().nrwares()), |
611 | - m_ware_stocks(the_egbase.tribes().nrwares()) |
612 | + egbase_ (the_egbase), |
613 | + initialization_index_(initialization_index), |
614 | + team_number_(0), |
615 | + team_player_uptodate_(false), |
616 | + see_all_ (false), |
617 | + player_number_ (plnum), |
618 | + tribe_ (tribe_descr), |
619 | + casualties_ (0), |
620 | + kills_ (0), |
621 | + msites_lost_ (0), |
622 | + msites_defeated_ (0), |
623 | + civil_blds_lost_ (0), |
624 | + civil_blds_defeated_(0), |
625 | + fields_ (nullptr), |
626 | + allowed_worker_types_(the_egbase.tribes().nrworkers(), true), |
627 | + allowed_building_types_(the_egbase.tribes().nrbuildings(), true), |
628 | + ai_(""), |
629 | + current_produced_statistics_(the_egbase.tribes().nrwares()), |
630 | + current_consumed_statistics_(the_egbase.tribes().nrwares()), |
631 | + ware_productions_(the_egbase.tribes().nrwares()), |
632 | + ware_consumptions_(the_egbase.tribes().nrwares()), |
633 | + ware_stocks_(the_egbase.tribes().nrwares()) |
634 | { |
635 | set_name(name); |
636 | |
637 | // Disallow workers that the player's tribe doesn't have. |
638 | - for (size_t worker_index = 0; worker_index < m_allowed_worker_types.size(); ++worker_index) { |
639 | + for (size_t worker_index = 0; worker_index < allowed_worker_types_.size(); ++worker_index) { |
640 | if (!tribe().has_worker(static_cast<DescriptionIndex>(worker_index))) { |
641 | - m_allowed_worker_types[worker_index] = false; |
642 | + allowed_worker_types_[worker_index] = false; |
643 | } |
644 | } |
645 | |
646 | // Disallow buildings that the player's tribe doesn't have and |
647 | // that aren't militarysites that the tribe could conquer. |
648 | - for (size_t i = 0; i < m_allowed_building_types.size(); ++i) { |
649 | + for (size_t i = 0; i < allowed_building_types_.size(); ++i) { |
650 | const DescriptionIndex& building_index = static_cast<DescriptionIndex>(i); |
651 | const BuildingDescr& descr = *tribe().get_building_descr(building_index); |
652 | if (!tribe().has_building(building_index) && descr.type() != MapObjectType::MILITARYSITE) { |
653 | - m_allowed_building_types[i] = false; |
654 | + allowed_building_types_[i] = false; |
655 | } |
656 | } |
657 | |
658 | @@ -201,22 +201,22 @@ |
659 | |
660 | //Populating remaining_shipnames vector |
661 | for (const auto& shipname : tribe_descr.get_ship_names()) { |
662 | - m_remaining_shipnames.insert(shipname); |
663 | + remaining_shipnames_.insert(shipname); |
664 | } |
665 | |
666 | } |
667 | |
668 | |
669 | Player::~Player() { |
670 | - delete[] m_fields; |
671 | + delete[] fields_; |
672 | } |
673 | |
674 | |
675 | void Player::create_default_infrastructure() { |
676 | const Map & map = egbase().map(); |
677 | - if (map.get_starting_pos(m_plnum)) { |
678 | + if (map.get_starting_pos(player_number_)) { |
679 | const TribeBasicInfo::Initialization & initialization = |
680 | - tribe().initialization(m_initialization_index); |
681 | + tribe().initialization(initialization_index_); |
682 | |
683 | Game & game = dynamic_cast<Game&>(egbase()); |
684 | |
685 | @@ -228,13 +228,13 @@ |
686 | game.enqueue_command(new CmdLuaCoroutine(game.get_gametime(), cr.release())); |
687 | |
688 | // Check if other starting positions are shared in and initialize them as well |
689 | - for (uint8_t n = 0; n < m_further_shared_in_player.size(); ++n) { |
690 | - Coords const further_pos = map.get_starting_pos(m_further_shared_in_player.at(n)); |
691 | + for (uint8_t n = 0; n < further_shared_in_player_.size(); ++n) { |
692 | + Coords const further_pos = map.get_starting_pos(further_shared_in_player_.at(n)); |
693 | |
694 | // Run the corresponding script |
695 | std::unique_ptr<LuaCoroutine> ncr = |
696 | game.lua() |
697 | - .run_script(tribe().initialization(m_further_initializations.at(n)).script) |
698 | + .run_script(tribe().initialization(further_initializations_.at(n)).script) |
699 | ->get_coroutine("func"); |
700 | ncr->push_arg(this); |
701 | ncr->push_arg(further_pos); |
702 | @@ -248,7 +248,7 @@ |
703 | "no starting position.\n" |
704 | "You can manually add a starting position with the Widelands " |
705 | "Editor to fix this problem."), |
706 | - static_cast<unsigned int>(m_plnum)); |
707 | + static_cast<unsigned int>(player_number_)); |
708 | } |
709 | |
710 | |
711 | @@ -260,7 +260,7 @@ |
712 | const Map & map = egbase().map(); |
713 | assert(map.get_width ()); |
714 | assert(map.get_height()); |
715 | - m_fields = new Field[map.max_index()]; |
716 | + fields_ = new Field[map.max_index()]; |
717 | } |
718 | |
719 | /** |
720 | @@ -268,8 +268,8 @@ |
721 | */ |
722 | void Player::set_team_number(TeamNumber team) |
723 | { |
724 | - m_team_number = team; |
725 | - m_team_player_uptodate = false; |
726 | + team_number_ = team; |
727 | + team_player_uptodate_ = false; |
728 | } |
729 | |
730 | /** |
731 | @@ -280,17 +280,17 @@ |
732 | { |
733 | return |
734 | &other != this && |
735 | - (!m_team_number || m_team_number != other.m_team_number); |
736 | + (!team_number_ || team_number_ != other.team_number_); |
737 | } |
738 | |
739 | /** |
740 | * Updates the vector containing allied players |
741 | */ |
742 | void Player::update_team_players() { |
743 | - m_team_player.clear(); |
744 | - m_team_player_uptodate = true; |
745 | + team_player_.clear(); |
746 | + team_player_uptodate_ = true; |
747 | |
748 | - if (!m_team_number) |
749 | + if (!team_number_) |
750 | return; |
751 | |
752 | for (PlayerNumber i = 1; i <= MAX_PLAYERS; ++i) { |
753 | @@ -299,8 +299,8 @@ |
754 | continue; |
755 | if (other == this) |
756 | continue; |
757 | - if (m_team_number == other->m_team_number) |
758 | - m_team_player.push_back(other); |
759 | + if (team_number_ == other->team_number_) |
760 | + team_player_.push_back(other); |
761 | } |
762 | } |
763 | |
764 | @@ -370,14 +370,14 @@ |
765 | void Player::message_object_removed(MessageId m_id) const |
766 | { |
767 | // Send delete command |
768 | - upcast(Game, game, &m_egbase); |
769 | + upcast(Game, game, &egbase_); |
770 | if (!game) { |
771 | return; |
772 | } |
773 | |
774 | game->cmdqueue().enqueue |
775 | (new CmdDeleteMessage |
776 | - (game->get_gametime(), m_plnum, m_id)); |
777 | + (game->get_gametime(), player_number_, m_id)); |
778 | } |
779 | |
780 | |
781 | @@ -391,25 +391,25 @@ |
782 | const Map & map = egbase().map(); |
783 | uint8_t buildcaps = fc.field->nodecaps(); |
784 | |
785 | - if (!fc.field->is_interior(m_plnum)) |
786 | + if (!fc.field->is_interior(player_number_)) |
787 | buildcaps = 0; |
788 | |
789 | // Check if a building's flag can't be build due to ownership |
790 | else if (buildcaps & BUILDCAPS_BUILDINGMASK) { |
791 | FCoords flagcoords; |
792 | map.get_brn(fc, &flagcoords); |
793 | - if (!flagcoords.field->is_interior(m_plnum)) |
794 | + if (!flagcoords.field->is_interior(player_number_)) |
795 | buildcaps &= ~BUILDCAPS_BUILDINGMASK; |
796 | |
797 | // Prevent big buildings that would swell over borders. |
798 | if |
799 | ((buildcaps & BUILDCAPS_BIG) == BUILDCAPS_BIG |
800 | && |
801 | - (!map.tr_n(fc).field->is_interior(m_plnum) |
802 | - || |
803 | - !map.tl_n(fc).field->is_interior(m_plnum) |
804 | - || |
805 | - !map. l_n(fc).field->is_interior(m_plnum))) |
806 | + (!map.tr_n(fc).field->is_interior(player_number_) |
807 | + || |
808 | + !map.tl_n(fc).field->is_interior(player_number_) |
809 | + || |
810 | + !map. l_n(fc).field->is_interior(player_number_))) |
811 | buildcaps &= ~BUILDCAPS_SMALL; |
812 | } |
813 | |
814 | @@ -553,7 +553,7 @@ |
815 | eg, pn, location, tribes.get_building_descr(b_idx)); |
816 | |
817 | return eg.warp_constructionsite( |
818 | - map.get_fcoords(location), m_plnum, b_idx, false, former_buildings); |
819 | + map.get_fcoords(location), player_number_, b_idx, false, former_buildings); |
820 | } |
821 | |
822 | |
823 | @@ -596,7 +596,7 @@ |
824 | } |
825 | |
826 | if (constructionsite) |
827 | - return &egbase().warp_constructionsite(c, m_plnum, idx, false, former_buildings); |
828 | + return &egbase().warp_constructionsite(c, player_number_, idx, false, former_buildings); |
829 | else { |
830 | return &descr->create(egbase(), *this, c, false, false, former_buildings); |
831 | } |
832 | @@ -722,11 +722,11 @@ |
833 | } |
834 | } |
835 | |
836 | -void Player::military_site_set_soldier_preference(PlayerImmovable & imm, uint8_t m_soldier_preference) |
837 | +void Player::military_site_set_soldier_preference(PlayerImmovable & imm, uint8_t soldier_preference) |
838 | { |
839 | if (&imm.owner() == this) |
840 | if (upcast(MilitarySite, milsite, &imm)) |
841 | - milsite->set_soldier_preference(static_cast<MilitarySite::SoldierPreference>(m_soldier_preference)); |
842 | + milsite->set_soldier_preference(static_cast<MilitarySite::SoldierPreference>(soldier_preference)); |
843 | } |
844 | |
845 | |
846 | @@ -773,11 +773,11 @@ |
847 | if (index_of_new_building != INVALID_INDEX) |
848 | building = |
849 | &egbase().warp_constructionsite |
850 | - (position, m_plnum, index_of_new_building, false, former_buildings); |
851 | + (position, player_number_, index_of_new_building, false, former_buildings); |
852 | else |
853 | building = |
854 | &egbase().warp_dismantlesite |
855 | - (position, m_plnum, false, former_buildings); |
856 | + (position, player_number_, false, former_buildings); |
857 | // Hereafter building points to the new building. |
858 | |
859 | // Reassign the workers and soldiers. |
860 | @@ -806,9 +806,9 @@ |
861 | |
862 | |
863 | void Player::allow_worker_type(DescriptionIndex const i, bool const allow) { |
864 | - assert(i < static_cast<int>(m_allowed_worker_types.size())); |
865 | + assert(i < static_cast<int>(allowed_worker_types_.size())); |
866 | assert(!allow || tribe().get_worker_descr(i)->is_buildable()); |
867 | - m_allowed_worker_types[i] = allow; |
868 | + allowed_worker_types_[i] = allow; |
869 | } |
870 | |
871 | |
872 | @@ -818,8 +818,8 @@ |
873 | * Disable or enable a building for a player |
874 | */ |
875 | void Player::allow_building_type(DescriptionIndex const i, bool const allow) { |
876 | - assert(i < m_allowed_building_types.size()); |
877 | - m_allowed_building_types[i] = allow; |
878 | + assert(i < allowed_building_types_.size()); |
879 | + allowed_building_types_[i] = allow; |
880 | } |
881 | |
882 | /* |
883 | @@ -828,21 +828,21 @@ |
884 | void Player::add_economy(Economy & economy) |
885 | { |
886 | if (!has_economy(economy)) |
887 | - m_economies.push_back(&economy); |
888 | + economies_.push_back(&economy); |
889 | } |
890 | |
891 | |
892 | void Player::remove_economy(Economy & economy) { |
893 | - for (std::vector<Economy *>::iterator economy_iter = m_economies.begin(); |
894 | - economy_iter != m_economies.end(); ++economy_iter) |
895 | + for (std::vector<Economy *>::iterator economy_iter = economies_.begin(); |
896 | + economy_iter != economies_.end(); ++economy_iter) |
897 | if (*economy_iter == &economy) { |
898 | - m_economies.erase(economy_iter); |
899 | + economies_.erase(economy_iter); |
900 | return; |
901 | } |
902 | } |
903 | |
904 | bool Player::has_economy(Economy & economy) const { |
905 | - for (Economy * temp_economy : m_economies) { |
906 | + for (Economy * temp_economy : economies_) { |
907 | if (temp_economy == &economy) { |
908 | return true; |
909 | } |
910 | @@ -854,7 +854,7 @@ |
911 | (Economy const * const economy) const |
912 | { |
913 | Economies::const_iterator const |
914 | - economies_end = m_economies.end(), economies_begin = m_economies.begin(); |
915 | + economies_end = economies_.end(), economies_begin = economies_.begin(); |
916 | for |
917 | (Economies::const_iterator it = economies_begin; |
918 | it != economies_end; |
919 | @@ -994,10 +994,10 @@ |
920 | assert(&map[0] <= f.field); |
921 | assert(f.field < &map[0] + map.max_index()); |
922 | |
923 | - Field & field = m_fields[f.field - &first_map_field]; |
924 | + Field & field = fields_[f.field - &first_map_field]; |
925 | |
926 | - assert(m_fields <= &field); |
927 | - assert(&field < m_fields + map.max_index()); |
928 | + assert(fields_ <= &field); |
929 | + assert(&field < fields_ + map.max_index()); |
930 | |
931 | { // discover everything (above the ground) in this field |
932 | field.terrains = f.field->get_terrains(); |
933 | @@ -1073,7 +1073,7 @@ |
934 | } |
935 | { // discover the D triangle and the SW edge of the top right neighbour |
936 | FCoords tr = map.tr_n(f); |
937 | - Field & tr_field = m_fields[tr.field - &first_map_field]; |
938 | + Field & tr_field = fields_[tr.field - &first_map_field]; |
939 | if (tr_field.vision <= 1) { |
940 | tr_field.terrains.d = tr.field->terrain_d(); |
941 | tr_field.roads &= ~(RoadType::kMask << RoadType::kSouthWest); |
942 | @@ -1082,7 +1082,7 @@ |
943 | } |
944 | { // discover both triangles and the SE edge of the top left neighbour |
945 | FCoords tl = map.tl_n(f); |
946 | - Field & tl_field = m_fields[tl.field - &first_map_field]; |
947 | + Field & tl_field = fields_[tl.field - &first_map_field]; |
948 | if (tl_field.vision <= 1) { |
949 | tl_field.terrains = tl.field->get_terrains(); |
950 | tl_field.roads &= ~(RoadType::kMask << RoadType::kSouthEast); |
951 | @@ -1091,7 +1091,7 @@ |
952 | } |
953 | { // discover the R triangle and the E edge of the left neighbour |
954 | FCoords l = map.l_n(f); |
955 | - Field & l_field = m_fields[l.field - &first_map_field]; |
956 | + Field & l_field = fields_[l.field - &first_map_field]; |
957 | if (l_field.vision <= 1) { |
958 | l_field.terrains.r = l.field->terrain_r(); |
959 | l_field.roads &= ~(RoadType::kMask << RoadType::kEast); |
960 | @@ -1116,16 +1116,16 @@ |
961 | |
962 | // If this is not already a forwarded call, we should inform allied players |
963 | // as well of this change. |
964 | - if (!m_team_player_uptodate) |
965 | + if (!team_player_uptodate_) |
966 | update_team_players(); |
967 | - if (!forward && !m_team_player.empty()) { |
968 | - for (uint8_t j = 0; j < m_team_player.size(); ++j) |
969 | - m_team_player[j]->see_node(map, first_map_field, f, gametime, true); |
970 | + if (!forward && !team_player_.empty()) { |
971 | + for (uint8_t j = 0; j < team_player_.size(); ++j) |
972 | + team_player_[j]->see_node(map, first_map_field, f, gametime, true); |
973 | } |
974 | |
975 | - Field & field = m_fields[f.field - &first_map_field]; |
976 | - assert(m_fields <= &field); |
977 | - assert (&field < m_fields + map.max_index()); |
978 | + Field & field = fields_[f.field - &first_map_field]; |
979 | + assert(fields_ <= &field); |
980 | + assert (&field < fields_ + map.max_index()); |
981 | Vision fvision = field.vision; |
982 | if (fvision == 0) |
983 | fvision = 1; |
984 | @@ -1138,17 +1138,17 @@ |
985 | void Player::unsee_node |
986 | (MapIndex const i, Time const gametime, bool const forward) |
987 | { |
988 | - Field & field = m_fields[i]; |
989 | + Field & field = fields_[i]; |
990 | if (field.vision <= 1) // Already does not see this |
991 | return; |
992 | |
993 | // If this is not already a forwarded call, we should inform allied players |
994 | // as well of this change. |
995 | - if (!m_team_player_uptodate) |
996 | + if (!team_player_uptodate_) |
997 | update_team_players(); |
998 | - if (!forward && !m_team_player.empty()) { |
999 | - for (uint8_t j = 0; j < m_team_player.size(); ++j) |
1000 | - m_team_player[j]->unsee_node(i, gametime, true); |
1001 | + if (!forward && !team_player_.empty()) { |
1002 | + for (uint8_t j = 0; j < team_player_.size(); ++j) |
1003 | + team_player_[j]->unsee_node(i, gametime, true); |
1004 | } |
1005 | |
1006 | --field.vision; |
1007 | @@ -1163,9 +1163,9 @@ |
1008 | */ |
1009 | void Player::sample_statistics() |
1010 | { |
1011 | - assert (m_ware_productions.size() == egbase().tribes().nrwares()); |
1012 | - assert (m_ware_consumptions.size() == egbase().tribes().nrwares()); |
1013 | - assert (m_ware_stocks.size() == egbase().tribes().nrwares()); |
1014 | + assert (ware_productions_.size() == egbase().tribes().nrwares()); |
1015 | + assert (ware_consumptions_.size() == egbase().tribes().nrwares()); |
1016 | + assert (ware_stocks_.size() == egbase().tribes().nrwares()); |
1017 | |
1018 | //calculate stocks |
1019 | std::vector<uint32_t> stocks(egbase().tribes().nrwares()); |
1020 | @@ -1185,14 +1185,14 @@ |
1021 | |
1022 | |
1023 | //update statistics |
1024 | - for (uint32_t i = 0; i < m_ware_productions.size(); ++i) { |
1025 | - m_ware_productions[i].push_back(m_current_produced_statistics[i]); |
1026 | - m_current_produced_statistics[i] = 0; |
1027 | - |
1028 | - m_ware_consumptions[i].push_back(m_current_consumed_statistics[i]); |
1029 | - m_current_consumed_statistics[i] = 0; |
1030 | - |
1031 | - m_ware_stocks[i].push_back(stocks[i]); |
1032 | + for (uint32_t i = 0; i < ware_productions_.size(); ++i) { |
1033 | + ware_productions_[i].push_back(current_produced_statistics_[i]); |
1034 | + current_produced_statistics_[i] = 0; |
1035 | + |
1036 | + ware_consumptions_[i].push_back(current_consumed_statistics_[i]); |
1037 | + current_consumed_statistics_[i] = 0; |
1038 | + |
1039 | + ware_stocks_[i].push_back(stocks[i]); |
1040 | } |
1041 | } |
1042 | |
1043 | @@ -1201,10 +1201,10 @@ |
1044 | * A ware was produced. Update the corresponding statistics. |
1045 | */ |
1046 | void Player::ware_produced(DescriptionIndex const wareid) { |
1047 | - assert (m_ware_productions.size() == egbase().tribes().nrwares()); |
1048 | + assert (ware_productions_.size() == egbase().tribes().nrwares()); |
1049 | assert(egbase().tribes().ware_exists(wareid)); |
1050 | |
1051 | - ++m_current_produced_statistics[wareid]; |
1052 | + ++current_produced_statistics_[wareid]; |
1053 | } |
1054 | |
1055 | |
1056 | @@ -1216,10 +1216,10 @@ |
1057 | * \param count the number of consumed wares |
1058 | */ |
1059 | void Player::ware_consumed(DescriptionIndex const wareid, uint8_t const count) { |
1060 | - assert (m_ware_consumptions.size() == egbase().tribes().nrwares()); |
1061 | + assert (ware_consumptions_.size() == egbase().tribes().nrwares()); |
1062 | assert(egbase().tribes().ware_exists(wareid)); |
1063 | |
1064 | - m_current_consumed_statistics[wareid] += count; |
1065 | + current_consumed_statistics_[wareid] += count; |
1066 | } |
1067 | |
1068 | |
1069 | @@ -1229,8 +1229,8 @@ |
1070 | const std::vector<uint32_t> * Player::get_ware_production_statistics |
1071 | (DescriptionIndex const ware) const |
1072 | { |
1073 | - assert(ware < static_cast<int>(m_ware_productions.size())); |
1074 | - return &m_ware_productions[ware]; |
1075 | + assert(ware < static_cast<int>(ware_productions_.size())); |
1076 | + return &ware_productions_[ware]; |
1077 | } |
1078 | |
1079 | |
1080 | @@ -1240,17 +1240,17 @@ |
1081 | const std::vector<uint32_t> * Player::get_ware_consumption_statistics |
1082 | (DescriptionIndex const ware) const { |
1083 | |
1084 | - assert(ware < static_cast<int>(m_ware_consumptions.size())); |
1085 | + assert(ware < static_cast<int>(ware_consumptions_.size())); |
1086 | |
1087 | - return &m_ware_consumptions[ware]; |
1088 | + return &ware_consumptions_[ware]; |
1089 | } |
1090 | |
1091 | const std::vector<uint32_t> * Player::get_ware_stock_statistics |
1092 | (DescriptionIndex const ware) const |
1093 | { |
1094 | - assert(ware < static_cast<int>(m_ware_stocks.size())); |
1095 | + assert(ware < static_cast<int>(ware_stocks_.size())); |
1096 | |
1097 | - return &m_ware_stocks[ware]; |
1098 | + return &ware_stocks_[ware]; |
1099 | } |
1100 | |
1101 | const Player::BuildingStatsVector& Player::get_building_statistics(const DescriptionIndex& i) const { |
1102 | @@ -1310,25 +1310,25 @@ |
1103 | */ |
1104 | |
1105 | void Player::set_ai(const std::string & ai) { |
1106 | - m_ai = ai; |
1107 | + ai_ = ai; |
1108 | } |
1109 | |
1110 | const std::string & Player::get_ai() const { |
1111 | - return m_ai; |
1112 | + return ai_; |
1113 | } |
1114 | |
1115 | /** |
1116 | * Pick random name from remaining names (if any) |
1117 | */ |
1118 | const std::string Player::pick_shipname() { |
1119 | - if (!m_remaining_shipnames.empty()) { |
1120 | + if (!remaining_shipnames_.empty()) { |
1121 | Game & game = dynamic_cast<Game&>(egbase()); |
1122 | assert (is_a(Game, &egbase())); |
1123 | - const uint32_t index = game.logic_rand() % m_remaining_shipnames.size(); |
1124 | - std::unordered_set<std::string>::iterator it = m_remaining_shipnames.begin(); |
1125 | + const uint32_t index = game.logic_rand() % remaining_shipnames_.size(); |
1126 | + std::unordered_set<std::string>::iterator it = remaining_shipnames_.begin(); |
1127 | std::advance(it, index); |
1128 | std::string new_name = *it; |
1129 | - m_remaining_shipnames.erase(it); |
1130 | + remaining_shipnames_.erase(it); |
1131 | return new_name; |
1132 | } |
1133 | return "Ship"; |
1134 | @@ -1342,7 +1342,7 @@ |
1135 | void Player::read_remaining_shipnames(FileRead & fr) { |
1136 | const uint16_t count = fr.unsigned_16(); |
1137 | for (uint16_t i = 0; i < count; ++i) { |
1138 | - m_remaining_shipnames.insert(fr.string()); |
1139 | + remaining_shipnames_.insert(fr.string()); |
1140 | } |
1141 | } |
1142 | |
1143 | @@ -1356,8 +1356,8 @@ |
1144 | uint16_t nr_wares = fr.unsigned_16(); |
1145 | uint16_t nr_entries = fr.unsigned_16(); |
1146 | |
1147 | - for (uint32_t i = 0; i < m_current_produced_statistics.size(); ++i) |
1148 | - m_ware_productions[i].resize(nr_entries); |
1149 | + for (uint32_t i = 0; i < current_produced_statistics_.size(); ++i) |
1150 | + ware_productions_[i].resize(nr_entries); |
1151 | |
1152 | for (uint16_t i = 0; i < nr_wares; ++i) { |
1153 | std::string name = fr.c_string(); |
1154 | @@ -1369,18 +1369,18 @@ |
1155 | continue; |
1156 | } |
1157 | |
1158 | - m_current_produced_statistics[idx] = fr.unsigned_32(); |
1159 | + current_produced_statistics_[idx] = fr.unsigned_32(); |
1160 | |
1161 | for (uint32_t j = 0; j < nr_entries; ++j) |
1162 | - m_ware_productions[idx][j] = fr.unsigned_32(); |
1163 | + ware_productions_[idx][j] = fr.unsigned_32(); |
1164 | } |
1165 | |
1166 | //read consumption statistics |
1167 | nr_wares = fr.unsigned_16(); |
1168 | nr_entries = fr.unsigned_16(); |
1169 | |
1170 | - for (uint32_t i = 0; i < m_current_consumed_statistics.size(); ++i) |
1171 | - m_ware_consumptions[i].resize(nr_entries); |
1172 | + for (uint32_t i = 0; i < current_consumed_statistics_.size(); ++i) |
1173 | + ware_consumptions_[i].resize(nr_entries); |
1174 | |
1175 | for (uint16_t i = 0; i < nr_wares; ++i) { |
1176 | std::string name = fr.c_string(); |
1177 | @@ -1392,18 +1392,18 @@ |
1178 | continue; |
1179 | } |
1180 | |
1181 | - m_current_consumed_statistics[idx] = fr.unsigned_32(); |
1182 | + current_consumed_statistics_[idx] = fr.unsigned_32(); |
1183 | |
1184 | for (uint32_t j = 0; j < nr_entries; ++j) |
1185 | - m_ware_consumptions[idx][j] = fr.unsigned_32(); |
1186 | + ware_consumptions_[idx][j] = fr.unsigned_32(); |
1187 | } |
1188 | |
1189 | //read stock statistics |
1190 | nr_wares = fr.unsigned_16(); |
1191 | nr_entries = fr.unsigned_16(); |
1192 | |
1193 | - for (uint32_t i = 0; i < m_ware_stocks.size(); ++i) |
1194 | - m_ware_stocks[i].resize(nr_entries); |
1195 | + for (uint32_t i = 0; i < ware_stocks_.size(); ++i) |
1196 | + ware_stocks_[i].resize(nr_entries); |
1197 | |
1198 | for (uint16_t i = 0; i < nr_wares; ++i) { |
1199 | std::string name = fr.c_string(); |
1200 | @@ -1416,23 +1416,23 @@ |
1201 | } |
1202 | |
1203 | for (uint32_t j = 0; j < nr_entries; ++j) |
1204 | - m_ware_stocks[idx][j] = fr.unsigned_32(); |
1205 | + ware_stocks_[idx][j] = fr.unsigned_32(); |
1206 | } |
1207 | |
1208 | //all statistics should have the same size |
1209 | - assert(m_ware_productions.size() == m_ware_consumptions.size()); |
1210 | - assert(m_ware_productions[0].size() == m_ware_consumptions[0].size()); |
1211 | + assert(ware_productions_.size() == ware_consumptions_.size()); |
1212 | + assert(ware_productions_[0].size() == ware_consumptions_[0].size()); |
1213 | |
1214 | - assert(m_ware_productions.size() == m_ware_stocks.size()); |
1215 | - assert(m_ware_productions[0].size() == m_ware_stocks[0].size()); |
1216 | + assert(ware_productions_.size() == ware_stocks_.size()); |
1217 | + assert(ware_productions_[0].size() == ware_stocks_[0].size()); |
1218 | } |
1219 | |
1220 | /** |
1221 | * Write remaining ship indexes to the give file |
1222 | */ |
1223 | void Player::write_remaining_shipnames(FileWrite & fw) const { |
1224 | - fw.unsigned_16(m_remaining_shipnames.size()); |
1225 | - for (const auto& shipname : m_remaining_shipnames) { |
1226 | + fw.unsigned_16(remaining_shipnames_.size()); |
1227 | + for (const auto& shipname : remaining_shipnames_) { |
1228 | fw.string(shipname); |
1229 | } |
1230 | } |
1231 | @@ -1442,37 +1442,37 @@ |
1232 | */ |
1233 | void Player::write_statistics(FileWrite & fw) const { |
1234 | //write produce statistics |
1235 | - fw.unsigned_16(m_current_produced_statistics.size()); |
1236 | - fw.unsigned_16(m_ware_productions[0].size()); |
1237 | + fw.unsigned_16(current_produced_statistics_.size()); |
1238 | + fw.unsigned_16(ware_productions_[0].size()); |
1239 | |
1240 | - for (uint8_t i = 0; i < m_current_produced_statistics.size(); ++i) { |
1241 | + for (uint8_t i = 0; i < current_produced_statistics_.size(); ++i) { |
1242 | fw.c_string |
1243 | (egbase().tribes().get_ware_descr(i)->name()); |
1244 | - fw.unsigned_32(m_current_produced_statistics[i]); |
1245 | - for (uint32_t j = 0; j < m_ware_productions[i].size(); ++j) |
1246 | - fw.unsigned_32(m_ware_productions[i][j]); |
1247 | + fw.unsigned_32(current_produced_statistics_[i]); |
1248 | + for (uint32_t j = 0; j < ware_productions_[i].size(); ++j) |
1249 | + fw.unsigned_32(ware_productions_[i][j]); |
1250 | } |
1251 | |
1252 | //write consume statistics |
1253 | - fw.unsigned_16(m_current_consumed_statistics.size()); |
1254 | - fw.unsigned_16(m_ware_consumptions[0].size()); |
1255 | + fw.unsigned_16(current_consumed_statistics_.size()); |
1256 | + fw.unsigned_16(ware_consumptions_[0].size()); |
1257 | |
1258 | - for (uint8_t i = 0; i < m_current_consumed_statistics.size(); ++i) { |
1259 | + for (uint8_t i = 0; i < current_consumed_statistics_.size(); ++i) { |
1260 | fw.c_string |
1261 | (egbase().tribes().get_ware_descr(i)->name()); |
1262 | - fw.unsigned_32(m_current_consumed_statistics[i]); |
1263 | - for (uint32_t j = 0; j < m_ware_consumptions[i].size(); ++j) |
1264 | - fw.unsigned_32(m_ware_consumptions[i][j]); |
1265 | + fw.unsigned_32(current_consumed_statistics_[i]); |
1266 | + for (uint32_t j = 0; j < ware_consumptions_[i].size(); ++j) |
1267 | + fw.unsigned_32(ware_consumptions_[i][j]); |
1268 | } |
1269 | |
1270 | //write stock statistics |
1271 | - fw.unsigned_16(m_ware_stocks.size()); |
1272 | - fw.unsigned_16(m_ware_stocks[0].size()); |
1273 | + fw.unsigned_16(ware_stocks_.size()); |
1274 | + fw.unsigned_16(ware_stocks_[0].size()); |
1275 | |
1276 | - for (uint8_t i = 0; i < m_ware_stocks.size(); ++i) { |
1277 | + for (uint8_t i = 0; i < ware_stocks_.size(); ++i) { |
1278 | fw.c_string(egbase().tribes().get_ware_descr(i)->name()); |
1279 | - for (uint32_t j = 0; j < m_ware_stocks[i].size(); ++j) |
1280 | - fw.unsigned_32(m_ware_stocks[i][j]); |
1281 | + for (uint32_t j = 0; j < ware_stocks_[i].size(); ++j) |
1282 | + fw.unsigned_32(ware_stocks_[i][j]); |
1283 | } |
1284 | } |
1285 | |
1286 | |
1287 | === modified file 'src/logic/player.h' |
1288 | --- src/logic/player.h 2016-02-18 08:42:46 +0000 |
1289 | +++ src/logic/player.h 2016-03-02 14:42:23 +0000 |
1290 | @@ -92,8 +92,8 @@ |
1291 | |
1292 | void allocate_map(); |
1293 | |
1294 | - const MessageQueue & messages() const {return m_messages;} |
1295 | - MessageQueue & messages() {return m_messages;} |
1296 | + const MessageQueue & messages() const {return messages_;} |
1297 | + MessageQueue & messages() {return messages_;} |
1298 | |
1299 | /// Adds the message to the queue. Takes ownership of the message. Assumes |
1300 | /// that it has been allocated in a separate memory block (not as a |
1301 | @@ -115,15 +115,15 @@ |
1302 | messages().set_message_status(id, status); |
1303 | } |
1304 | |
1305 | - const EditorGameBase & egbase() const {return m_egbase;} |
1306 | - EditorGameBase & egbase() {return m_egbase;} |
1307 | - PlayerNumber player_number() const {return m_plnum;} |
1308 | - TeamNumber team_number() const {return m_team_number;} |
1309 | - const RGBColor & get_playercolor() const {return Colors[m_plnum - 1];} |
1310 | - const TribeDescr & tribe() const {return m_tribe;} |
1311 | + const EditorGameBase & egbase() const {return egbase_;} |
1312 | + EditorGameBase & egbase() {return egbase_;} |
1313 | + PlayerNumber player_number() const {return player_number_;} |
1314 | + TeamNumber team_number() const {return team_number_;} |
1315 | + const RGBColor & get_playercolor() const {return Colors[player_number_ - 1];} |
1316 | + const TribeDescr & tribe() const {return tribe_;} |
1317 | |
1318 | - const std::string & get_name() const {return m_name;} |
1319 | - void set_name(const std::string & name) {m_name = name;} |
1320 | + const std::string & get_name() const {return name_;} |
1321 | + void set_name(const std::string & name) {name_ = name;} |
1322 | void set_team_number(TeamNumber team); |
1323 | |
1324 | void create_default_infrastructure(); |
1325 | @@ -133,8 +133,8 @@ |
1326 | bool is_hostile(const Player &) const; |
1327 | |
1328 | // For cheating |
1329 | - void set_see_all(bool const t) {m_see_all = t; m_view_changed = true;} |
1330 | - bool see_all() const {return m_see_all;} |
1331 | + void set_see_all(bool const t) {see_all_ = t; view_changed_ = true;} |
1332 | + bool see_all() const {return see_all_;} |
1333 | |
1334 | /// Data that are used and managed by AI. They are here to have it saved as a port of player's data |
1335 | struct AiPersistentState { |
1336 | @@ -380,17 +380,17 @@ |
1337 | DISALLOW_COPY_AND_ASSIGN(Field); |
1338 | }; |
1339 | |
1340 | - const Field * fields() const {return m_fields;} |
1341 | + const Field * fields() const {return fields_;} |
1342 | |
1343 | // See area |
1344 | Vision vision(MapIndex const i) const { |
1345 | // Node visible if > 1 |
1346 | - return (m_see_all ? 2 : 0) + m_fields[i].vision; |
1347 | + return (see_all_ ? 2 : 0) + fields_[i].vision; |
1348 | } |
1349 | |
1350 | bool has_view_changed() { |
1351 | - bool t = m_view_changed; |
1352 | - m_view_changed = false; |
1353 | + bool t = view_changed_; |
1354 | + view_changed_ = false; |
1355 | return t; |
1356 | } |
1357 | |
1358 | @@ -422,7 +422,7 @@ |
1359 | do { |
1360 | see_node(map, first_map_field, mr.location(), gametime); |
1361 | } while (mr.advance(map)); |
1362 | - m_view_changed = true; |
1363 | + view_changed_ = true; |
1364 | } |
1365 | |
1366 | /// Decrement this player's vision for each node in an area. |
1367 | @@ -433,25 +433,25 @@ |
1368 | MapRegion<Area<FCoords> > mr(map, area); |
1369 | do unsee_node(mr.location().field - &first_map_field, gametime); |
1370 | while (mr.advance(map)); |
1371 | - m_view_changed = true; |
1372 | + view_changed_ = true; |
1373 | } |
1374 | |
1375 | MilitaryInfluence military_influence(MapIndex const i) const { |
1376 | - return m_fields[i].military_influence; |
1377 | + return fields_[i].military_influence; |
1378 | } |
1379 | |
1380 | MilitaryInfluence & military_influence(MapIndex const i) { |
1381 | - return m_fields[i].military_influence; |
1382 | + return fields_[i].military_influence; |
1383 | } |
1384 | |
1385 | bool is_worker_type_allowed(const DescriptionIndex& i) const { |
1386 | - return m_allowed_worker_types.at(i); |
1387 | + return allowed_worker_types_.at(i); |
1388 | } |
1389 | void allow_worker_type(DescriptionIndex, bool allow); |
1390 | |
1391 | // Allowed buildings |
1392 | bool is_building_type_allowed(const DescriptionIndex& i) const { |
1393 | - return m_allowed_building_types[i]; |
1394 | + return allowed_building_types_[i]; |
1395 | } |
1396 | void allow_building_type(DescriptionIndex, bool allow); |
1397 | |
1398 | @@ -470,7 +470,7 @@ |
1399 | void bulldoze(PlayerImmovable &, bool recurse = false); |
1400 | void flagaction(Flag &); |
1401 | void start_stop_building(PlayerImmovable &); |
1402 | - void military_site_set_soldier_preference(PlayerImmovable &, uint8_t m_soldier_preference); |
1403 | + void military_site_set_soldier_preference(PlayerImmovable &, uint8_t soldier_preference); |
1404 | void start_or_cancel_expedition(Warehouse &); |
1405 | void enhance_building |
1406 | (Building *, DescriptionIndex index_of_new_building); |
1407 | @@ -483,9 +483,9 @@ |
1408 | using Economies = std::vector<Economy *>; |
1409 | Economies::size_type get_economy_number(Economy const *) const; |
1410 | Economy * get_economy_by_number(Economies::size_type const i) const { |
1411 | - return m_economies[i]; |
1412 | + return economies_[i]; |
1413 | } |
1414 | - uint32_t get_nr_economies() const {return m_economies.size();} |
1415 | + uint32_t get_nr_economies() const {return economies_.size();} |
1416 | |
1417 | // Military stuff |
1418 | void drop_soldier(PlayerImmovable &, Soldier &); |
1419 | @@ -498,18 +498,18 @@ |
1420 | void enemyflagaction |
1421 | (Flag &, PlayerNumber attacker, uint32_t count); |
1422 | |
1423 | - uint32_t casualties() const {return m_casualties;} |
1424 | - uint32_t kills () const {return m_kills;} |
1425 | - uint32_t msites_lost () const {return m_msites_lost;} |
1426 | - uint32_t msites_defeated () const {return m_msites_defeated;} |
1427 | - uint32_t civil_blds_lost () const {return m_civil_blds_lost;} |
1428 | - uint32_t civil_blds_defeated() const {return m_civil_blds_defeated;} |
1429 | - void count_casualty () {++m_casualties;} |
1430 | - void count_kill () {++m_kills;} |
1431 | - void count_msite_lost () {++m_msites_lost;} |
1432 | - void count_msite_defeated () {++m_msites_defeated;} |
1433 | - void count_civil_bld_lost () {++m_civil_blds_lost;} |
1434 | - void count_civil_bld_defeated() {++m_civil_blds_defeated;} |
1435 | + uint32_t casualties() const {return casualties_;} |
1436 | + uint32_t kills () const {return kills_;} |
1437 | + uint32_t msites_lost () const {return msites_lost_;} |
1438 | + uint32_t msites_defeated () const {return msites_defeated_;} |
1439 | + uint32_t civil_blds_lost () const {return civil_blds_lost_;} |
1440 | + uint32_t civil_blds_defeated() const {return civil_blds_defeated_;} |
1441 | + void count_casualty () {++casualties_;} |
1442 | + void count_kill () {++kills_;} |
1443 | + void count_msite_lost () {++msites_lost_;} |
1444 | + void count_msite_defeated () {++msites_defeated_;} |
1445 | + void count_civil_bld_lost () {++civil_blds_lost_;} |
1446 | + void count_civil_bld_defeated() {++civil_blds_defeated_;} |
1447 | |
1448 | // Statistics |
1449 | const BuildingStatsVector& get_building_statistics(const DescriptionIndex& i) const; |
1450 | @@ -538,8 +538,8 @@ |
1451 | |
1452 | // used in shared kingdom mode |
1453 | void add_further_starting_position(uint8_t plr, uint8_t init) { |
1454 | - m_further_shared_in_player.push_back(plr); |
1455 | - m_further_initializations .push_back(init); |
1456 | + further_shared_in_player_.push_back(plr); |
1457 | + further_initializations_ .push_back(init); |
1458 | } |
1459 | |
1460 | const std::string pick_shipname(); |
1461 | @@ -560,59 +560,59 @@ |
1462 | std::unique_ptr<Notifications::Subscriber<NoteFieldTerrainChanged>> |
1463 | field_terrain_changed_subscriber_; |
1464 | |
1465 | - MessageQueue m_messages; |
1466 | - |
1467 | - EditorGameBase & m_egbase; |
1468 | - uint8_t m_initialization_index; |
1469 | - std::vector<uint8_t> m_further_initializations; // used in shared kingdom mode |
1470 | - std::vector<uint8_t> m_further_shared_in_player; // '' '' '' '' '' |
1471 | - TeamNumber m_team_number; |
1472 | - std::vector<Player *> m_team_player; |
1473 | - bool m_team_player_uptodate; |
1474 | - bool m_see_all; |
1475 | - bool m_view_changed; |
1476 | - const PlayerNumber m_plnum; |
1477 | - const TribeDescr & m_tribe; // buildings, wares, workers, sciences |
1478 | - uint32_t m_casualties, m_kills; |
1479 | - uint32_t m_msites_lost, m_msites_defeated; |
1480 | - uint32_t m_civil_blds_lost, m_civil_blds_defeated; |
1481 | - std::unordered_set<std::string> m_remaining_shipnames; |
1482 | - |
1483 | - Field * m_fields; |
1484 | - std::vector<bool> m_allowed_worker_types; |
1485 | - std::vector<bool> m_allowed_building_types; |
1486 | - Economies m_economies; |
1487 | - std::string m_name; // Player name |
1488 | - std::string m_ai; /**< Name of preferred AI implementation */ |
1489 | + MessageQueue messages_; |
1490 | + |
1491 | + EditorGameBase & egbase_; |
1492 | + uint8_t initialization_index_; |
1493 | + std::vector<uint8_t> further_initializations_; // used in shared kingdom mode |
1494 | + std::vector<uint8_t> further_shared_in_player_; // '' '' '' '' '' |
1495 | + TeamNumber team_number_; |
1496 | + std::vector<Player *> team_player_; |
1497 | + bool team_player_uptodate_; |
1498 | + bool see_all_; |
1499 | + bool view_changed_; |
1500 | + const PlayerNumber player_number_; |
1501 | + const TribeDescr & tribe_; // buildings, wares, workers, sciences |
1502 | + uint32_t casualties_, kills_; |
1503 | + uint32_t msites_lost_, msites_defeated_; |
1504 | + uint32_t civil_blds_lost_, civil_blds_defeated_; |
1505 | + std::unordered_set<std::string> remaining_shipnames_; |
1506 | + |
1507 | + Field * fields_; |
1508 | + std::vector<bool> allowed_worker_types_; |
1509 | + std::vector<bool> allowed_building_types_; |
1510 | + Economies economies_; |
1511 | + std::string name_; // Player name |
1512 | + std::string ai_; /**< Name of preferred AI implementation */ |
1513 | |
1514 | /** |
1515 | * Wares produced (by ware id) since the last call to @ref sample_statistics |
1516 | */ |
1517 | - std::vector<uint32_t> m_current_produced_statistics; |
1518 | + std::vector<uint32_t> current_produced_statistics_; |
1519 | |
1520 | /** |
1521 | * Wares consumed (by ware id) since the last call to @ref sample_statistics |
1522 | */ |
1523 | - std::vector<uint32_t> m_current_consumed_statistics; |
1524 | + std::vector<uint32_t> current_consumed_statistics_; |
1525 | |
1526 | /** |
1527 | * Statistics of wares produced over the life of the game, indexed as |
1528 | - * m_ware_productions[ware id][time index] |
1529 | + * ware_productions_[ware id][time index] |
1530 | */ |
1531 | - std::vector< std::vector<uint32_t> > m_ware_productions; |
1532 | + std::vector< std::vector<uint32_t> > ware_productions_; |
1533 | |
1534 | /** |
1535 | * Statistics of wares consumed over the life of the game, indexed as |
1536 | - * m_ware_consumptions[ware_id][time_index] |
1537 | + * ware_consumptions_[ware_id][time_index] |
1538 | */ |
1539 | - std::vector< std::vector<uint32_t> > m_ware_consumptions; |
1540 | + std::vector< std::vector<uint32_t> > ware_consumptions_; |
1541 | |
1542 | /** |
1543 | * Statistics of wares stored inside of warehouses over the |
1544 | * life of the game, indexed as |
1545 | - * m_ware_stocks[ware_id][time_index] |
1546 | + * ware_stocks_[ware_id][time_index] |
1547 | */ |
1548 | - std::vector< std::vector<uint32_t> > m_ware_stocks; |
1549 | + std::vector< std::vector<uint32_t> > ware_stocks_; |
1550 | |
1551 | PlayerBuildingStats building_stats_; |
1552 | |
1553 | |
1554 | === modified file 'src/logic/playercommand.cc' |
1555 | --- src/logic/playercommand.cc 2016-02-09 16:29:48 +0000 |
1556 | +++ src/logic/playercommand.cc 2016-03-02 14:42:23 +0000 |
1557 | @@ -94,7 +94,7 @@ |
1558 | /*** class PlayerCommand ***/ |
1559 | |
1560 | PlayerCommand::PlayerCommand (const uint32_t time, const PlayerNumber s) |
1561 | - : GameLogicCommand (time), m_sender(s), m_cmdserial(0) |
1562 | + : GameLogicCommand (time), sender_(s), cmdserial_(0) |
1563 | {} |
1564 | |
1565 | PlayerCommand * PlayerCommand::deserialize (StreamRead & des) |
1566 | @@ -159,10 +159,10 @@ |
1567 | const uint16_t packet_version = fr.unsigned_16(); |
1568 | if (packet_version == kCurrentPacketVersionPlayerCommand) { |
1569 | GameLogicCommand::read(fr, egbase, mol); |
1570 | - m_sender = fr.unsigned_8 (); |
1571 | - if (!egbase.get_player(m_sender)) |
1572 | - throw GameDataError("player %u does not exist", m_sender); |
1573 | - m_cmdserial = fr.unsigned_32(); |
1574 | + sender_ = fr.unsigned_8 (); |
1575 | + if (!egbase.get_player(sender_)) |
1576 | + throw GameDataError("player %u does not exist", sender_); |
1577 | + cmdserial_ = fr.unsigned_32(); |
1578 | } else { |
1579 | throw UnhandledVersionError("PlayerCommand", packet_version, kCurrentPacketVersionPlayerCommand); |
1580 | } |
1581 | @@ -1127,22 +1127,22 @@ |
1582 | const int32_t init_type, const DescriptionIndex i, const int32_t init_priority) |
1583 | : |
1584 | PlayerCommand(init_duetime, init_sender), |
1585 | - m_serial (imm.serial()), |
1586 | - m_type (init_type), |
1587 | - m_index (i), |
1588 | - m_priority (init_priority) |
1589 | + serial_ (imm.serial()), |
1590 | + type_ (init_type), |
1591 | + index_ (i), |
1592 | + priority_ (init_priority) |
1593 | {} |
1594 | |
1595 | void CmdSetWarePriority::execute(Game & game) |
1596 | { |
1597 | - upcast(Building, psite, game.objects().get_object(m_serial)); |
1598 | + upcast(Building, psite, game.objects().get_object(serial_)); |
1599 | |
1600 | if (!psite) |
1601 | return; |
1602 | if (psite->owner().player_number() != sender()) |
1603 | return; |
1604 | |
1605 | - psite->set_priority(m_type, m_index, m_priority); |
1606 | + psite->set_priority(type_, index_, priority_); |
1607 | } |
1608 | |
1609 | constexpr uint16_t kCurrentPacketVersionCmdSetWarePriority = 1; |
1610 | @@ -1154,10 +1154,10 @@ |
1611 | |
1612 | PlayerCommand::write(fw, egbase, mos); |
1613 | |
1614 | - fw.unsigned_32(mos.get_object_file_index_or_zero(egbase.objects().get_object(m_serial))); |
1615 | - fw.unsigned_8(m_type); |
1616 | - fw.signed_32(m_index); |
1617 | - fw.signed_32(m_priority); |
1618 | + fw.unsigned_32(mos.get_object_file_index_or_zero(egbase.objects().get_object(serial_))); |
1619 | + fw.unsigned_8(type_); |
1620 | + fw.signed_32(index_); |
1621 | + fw.signed_32(priority_); |
1622 | } |
1623 | |
1624 | void CmdSetWarePriority::read |
1625 | @@ -1167,10 +1167,10 @@ |
1626 | const uint16_t packet_version = fr.unsigned_16(); |
1627 | if (packet_version == kCurrentPacketVersionCmdSetWarePriority) { |
1628 | PlayerCommand::read(fr, egbase, mol); |
1629 | - m_serial = get_object_serial_or_zero<Building>(fr.unsigned_32(), mol); |
1630 | - m_type = fr.unsigned_8(); |
1631 | - m_index = fr.signed_32(); |
1632 | - m_priority = fr.signed_32(); |
1633 | + serial_ = get_object_serial_or_zero<Building>(fr.unsigned_32(), mol); |
1634 | + type_ = fr.unsigned_8(); |
1635 | + index_ = fr.signed_32(); |
1636 | + priority_ = fr.signed_32(); |
1637 | } else { |
1638 | throw UnhandledVersionError("CmdSetWarePriority", |
1639 | packet_version, kCurrentPacketVersionCmdSetWarePriority); |
1640 | @@ -1183,20 +1183,20 @@ |
1641 | |
1642 | CmdSetWarePriority::CmdSetWarePriority(StreamRead & des) : |
1643 | PlayerCommand(0, des.unsigned_8()), |
1644 | - m_serial (des.unsigned_32()), |
1645 | - m_type (des.unsigned_8()), |
1646 | - m_index (des.signed_32()), |
1647 | - m_priority (des.signed_32()) |
1648 | + serial_ (des.unsigned_32()), |
1649 | + type_ (des.unsigned_8()), |
1650 | + index_ (des.signed_32()), |
1651 | + priority_ (des.signed_32()) |
1652 | {} |
1653 | |
1654 | void CmdSetWarePriority::serialize(StreamWrite & ser) |
1655 | { |
1656 | ser.unsigned_8(PLCMD_SETWAREPRIORITY); |
1657 | ser.unsigned_8(sender()); |
1658 | - ser.unsigned_32(m_serial); |
1659 | - ser.unsigned_8(m_type); |
1660 | - ser.signed_32(m_index); |
1661 | - ser.signed_32(m_priority); |
1662 | + ser.unsigned_32(serial_); |
1663 | + ser.unsigned_8(type_); |
1664 | + ser.signed_32(index_); |
1665 | + ser.signed_32(priority_); |
1666 | } |
1667 | |
1668 | /*** class Cmd_SetWareMaxFill ***/ |
1669 | @@ -1206,21 +1206,21 @@ |
1670 | const DescriptionIndex index, const uint32_t max_fill) |
1671 | : |
1672 | PlayerCommand(init_duetime, init_sender), |
1673 | - m_serial (imm.serial()), |
1674 | - m_index (index), |
1675 | - m_max_fill (max_fill) |
1676 | + serial_ (imm.serial()), |
1677 | + index_ (index), |
1678 | + max_fill_ (max_fill) |
1679 | {} |
1680 | |
1681 | void CmdSetWareMaxFill::execute(Game & game) |
1682 | { |
1683 | - upcast(Building, b, game.objects().get_object(m_serial)); |
1684 | + upcast(Building, b, game.objects().get_object(serial_)); |
1685 | |
1686 | if (!b) |
1687 | return; |
1688 | if (b->owner().player_number() != sender()) |
1689 | return; |
1690 | |
1691 | - b->waresqueue(m_index).set_max_fill(m_max_fill); |
1692 | + b->waresqueue(index_).set_max_fill(max_fill_); |
1693 | } |
1694 | |
1695 | constexpr uint16_t kCurrentPacketVersionCmdSetWareMaxFill = 1; |
1696 | @@ -1232,9 +1232,9 @@ |
1697 | |
1698 | PlayerCommand::write(fw, egbase, mos); |
1699 | |
1700 | - fw.unsigned_32(mos.get_object_file_index_or_zero(egbase.objects().get_object(m_serial))); |
1701 | - fw.signed_32(m_index); |
1702 | - fw.unsigned_32(m_max_fill); |
1703 | + fw.unsigned_32(mos.get_object_file_index_or_zero(egbase.objects().get_object(serial_))); |
1704 | + fw.signed_32(index_); |
1705 | + fw.unsigned_32(max_fill_); |
1706 | } |
1707 | |
1708 | void CmdSetWareMaxFill::read |
1709 | @@ -1244,9 +1244,9 @@ |
1710 | const uint16_t packet_version = fr.unsigned_16(); |
1711 | if (packet_version == kCurrentPacketVersionCmdSetWareMaxFill) { |
1712 | PlayerCommand::read(fr, egbase, mol); |
1713 | - m_serial = get_object_serial_or_zero<Building>(fr.unsigned_32(), mol); |
1714 | - m_index = fr.signed_32(); |
1715 | - m_max_fill = fr.unsigned_32(); |
1716 | + serial_ = get_object_serial_or_zero<Building>(fr.unsigned_32(), mol); |
1717 | + index_ = fr.signed_32(); |
1718 | + max_fill_ = fr.unsigned_32(); |
1719 | } else { |
1720 | throw UnhandledVersionError("CmdSetWareMaxFill", |
1721 | packet_version, kCurrentPacketVersionCmdSetWareMaxFill); |
1722 | @@ -1258,18 +1258,18 @@ |
1723 | |
1724 | CmdSetWareMaxFill::CmdSetWareMaxFill(StreamRead & des) : |
1725 | PlayerCommand(0, des.unsigned_8()), |
1726 | - m_serial (des.unsigned_32()), |
1727 | - m_index (des.signed_32()), |
1728 | - m_max_fill(des.unsigned_32()) |
1729 | + serial_ (des.unsigned_32()), |
1730 | + index_ (des.signed_32()), |
1731 | + max_fill_(des.unsigned_32()) |
1732 | {} |
1733 | |
1734 | void CmdSetWareMaxFill::serialize(StreamWrite & ser) |
1735 | { |
1736 | ser.unsigned_8(PLCMD_SETWAREMAXFILL); |
1737 | ser.unsigned_8(sender()); |
1738 | - ser.unsigned_32(m_serial); |
1739 | - ser.signed_32(m_index); |
1740 | - ser.unsigned_32(m_max_fill); |
1741 | + ser.unsigned_32(serial_); |
1742 | + ser.signed_32(index_); |
1743 | + ser.unsigned_32(max_fill_); |
1744 | } |
1745 | |
1746 | |
1747 | @@ -1278,7 +1278,7 @@ |
1748 | const uint32_t init_economy, const DescriptionIndex init_ware_type) |
1749 | : |
1750 | PlayerCommand(init_duetime, init_sender), |
1751 | - m_economy (init_economy), m_ware_type(init_ware_type) |
1752 | + economy_(init_economy), ware_type_(init_ware_type) |
1753 | {} |
1754 | |
1755 | void CmdChangeTargetQuantity::write |
1756 | @@ -1295,8 +1295,8 @@ |
1757 | { |
1758 | try { |
1759 | PlayerCommand::read(fr, egbase, mol); |
1760 | - m_economy = fr.unsigned_32(); |
1761 | - m_ware_type = |
1762 | + economy_ = fr.unsigned_32(); |
1763 | + ware_type_ = |
1764 | egbase.player(sender()).tribe().ware_index(fr.c_string()); |
1765 | } catch (const WException & e) { |
1766 | throw GameDataError("change target quantity: %s", e.what()); |
1767 | @@ -1306,8 +1306,8 @@ |
1768 | CmdChangeTargetQuantity::CmdChangeTargetQuantity(StreamRead & des) |
1769 | : |
1770 | PlayerCommand(0, des.unsigned_8()), |
1771 | - m_economy (des.unsigned_32()), |
1772 | - m_ware_type (des.unsigned_8()) |
1773 | + economy_ (des.unsigned_32()), |
1774 | + ware_type_ (des.unsigned_8()) |
1775 | {} |
1776 | |
1777 | void CmdChangeTargetQuantity::serialize(StreamWrite & ser) |
1778 | @@ -1325,7 +1325,7 @@ |
1779 | const uint32_t init_permanent) |
1780 | : |
1781 | CmdChangeTargetQuantity(init_duetime, init_sender, init_economy, init_ware_type), |
1782 | - m_permanent(init_permanent) |
1783 | + permanent_(init_permanent) |
1784 | {} |
1785 | |
1786 | void CmdSetWareTargetQuantity::execute(Game & game) |
1787 | @@ -1333,7 +1333,7 @@ |
1788 | Player & player = game.player(sender()); |
1789 | if (economy() < player.get_nr_economies() && game.tribes().ware_exists(ware_type())) { |
1790 | player.get_economy_by_number(economy())->set_ware_target_quantity |
1791 | - (ware_type(), m_permanent, duetime()); |
1792 | + (ware_type(), permanent_, duetime()); |
1793 | } |
1794 | } |
1795 | |
1796 | @@ -1344,7 +1344,7 @@ |
1797 | { |
1798 | fw.unsigned_16(kCurrentPacketVersionSetWareTargetQuantity); |
1799 | CmdChangeTargetQuantity::write(fw, egbase, mos); |
1800 | - fw.unsigned_32(m_permanent); |
1801 | + fw.unsigned_32(permanent_); |
1802 | } |
1803 | |
1804 | void CmdSetWareTargetQuantity::read |
1805 | @@ -1354,7 +1354,7 @@ |
1806 | const uint16_t packet_version = fr.unsigned_16(); |
1807 | if (packet_version == kCurrentPacketVersionSetWareTargetQuantity) { |
1808 | CmdChangeTargetQuantity::read(fr, egbase, mol); |
1809 | - m_permanent = fr.unsigned_32(); |
1810 | + permanent_ = fr.unsigned_32(); |
1811 | } else { |
1812 | throw UnhandledVersionError("CmdSetWareTargetQuantity", |
1813 | packet_version, kCurrentPacketVersionSetWareTargetQuantity); |
1814 | @@ -1367,7 +1367,7 @@ |
1815 | CmdSetWareTargetQuantity::CmdSetWareTargetQuantity(StreamRead & des) |
1816 | : |
1817 | CmdChangeTargetQuantity(des), |
1818 | - m_permanent (des.unsigned_32()) |
1819 | + permanent_ (des.unsigned_32()) |
1820 | { |
1821 | if (cmdserial() == 1) des.unsigned_32(); |
1822 | } |
1823 | @@ -1376,7 +1376,7 @@ |
1824 | { |
1825 | ser.unsigned_8 (PLCMD_SETWARETARGETQUANTITY); |
1826 | CmdChangeTargetQuantity::serialize(ser); |
1827 | - ser.unsigned_32(m_permanent); |
1828 | + ser.unsigned_32(permanent_); |
1829 | } |
1830 | |
1831 | |
1832 | @@ -1443,7 +1443,7 @@ |
1833 | const uint32_t init_permanent) |
1834 | : |
1835 | CmdChangeTargetQuantity(init_duetime, init_sender, init_economy, init_ware_type), |
1836 | - m_permanent(init_permanent) |
1837 | + permanent_(init_permanent) |
1838 | {} |
1839 | |
1840 | void CmdSetWorkerTargetQuantity::execute(Game & game) |
1841 | @@ -1451,7 +1451,7 @@ |
1842 | Player & player = game.player(sender()); |
1843 | if (economy() < player.get_nr_economies() && game.tribes().ware_exists(ware_type())) { |
1844 | player.get_economy_by_number(economy())->set_worker_target_quantity |
1845 | - (ware_type(), m_permanent, duetime()); |
1846 | + (ware_type(), permanent_, duetime()); |
1847 | } |
1848 | } |
1849 | |
1850 | @@ -1462,7 +1462,7 @@ |
1851 | { |
1852 | fw.unsigned_16(kCurrentPacketVersionSetWorkerTargetQuantity); |
1853 | CmdChangeTargetQuantity::write(fw, egbase, mos); |
1854 | - fw.unsigned_32(m_permanent); |
1855 | + fw.unsigned_32(permanent_); |
1856 | } |
1857 | |
1858 | void CmdSetWorkerTargetQuantity::read |
1859 | @@ -1472,7 +1472,7 @@ |
1860 | const uint16_t packet_version = fr.unsigned_16(); |
1861 | if (packet_version == kCurrentPacketVersionSetWorkerTargetQuantity) { |
1862 | CmdChangeTargetQuantity::read(fr, egbase, mol); |
1863 | - m_permanent = fr.unsigned_32(); |
1864 | + permanent_ = fr.unsigned_32(); |
1865 | } else { |
1866 | throw UnhandledVersionError("CmdSetWorkerTargetQuantity", |
1867 | packet_version, kCurrentPacketVersionSetWorkerTargetQuantity); |
1868 | @@ -1485,7 +1485,7 @@ |
1869 | CmdSetWorkerTargetQuantity::CmdSetWorkerTargetQuantity(StreamRead & des) |
1870 | : |
1871 | CmdChangeTargetQuantity(des), |
1872 | - m_permanent (des.unsigned_32()) |
1873 | + permanent_ (des.unsigned_32()) |
1874 | { |
1875 | if (cmdserial() == 1) des.unsigned_32(); |
1876 | } |
1877 | @@ -1494,7 +1494,7 @@ |
1878 | { |
1879 | ser.unsigned_8 (PLCMD_SETWORKERTARGETQUANTITY); |
1880 | CmdChangeTargetQuantity::serialize(ser); |
1881 | - ser.unsigned_32(m_permanent); |
1882 | + ser.unsigned_32(permanent_); |
1883 | } |
1884 | |
1885 | |
1886 | @@ -1827,7 +1827,7 @@ |
1887 | /*** struct PlayerMessageCommand ***/ |
1888 | |
1889 | PlayerMessageCommand::PlayerMessageCommand(StreamRead & des) : |
1890 | -PlayerCommand (0, des.unsigned_8()), m_message_id(des.unsigned_32()) |
1891 | +PlayerCommand (0, des.unsigned_8()), message_id_(des.unsigned_32()) |
1892 | {} |
1893 | |
1894 | constexpr uint16_t kCurrentPacketVersionPlayerMessageCommand = 1; |
1895 | @@ -1839,8 +1839,8 @@ |
1896 | const uint16_t packet_version = fr.unsigned_16(); |
1897 | if (packet_version == kCurrentPacketVersionPlayerMessageCommand) { |
1898 | PlayerCommand::read(fr, egbase, mol); |
1899 | - m_message_id = MessageId(fr.unsigned_32()); |
1900 | - if (!m_message_id) |
1901 | + message_id_ = MessageId(fr.unsigned_32()); |
1902 | + if (!message_id_) |
1903 | throw GameDataError |
1904 | ("(player %u): message id is null", sender()); |
1905 | } else { |
1906 | @@ -1899,14 +1899,14 @@ |
1907 | Warehouse::StockPolicy policy) |
1908 | : PlayerCommand(time, p) |
1909 | { |
1910 | - m_warehouse = wh.serial(); |
1911 | - m_isworker = isworker; |
1912 | - m_ware = ware; |
1913 | - m_policy = policy; |
1914 | + warehouse_ = wh.serial(); |
1915 | + isworker_ = isworker; |
1916 | + ware_ = ware; |
1917 | + policy_ = policy; |
1918 | } |
1919 | |
1920 | CmdSetStockPolicy::CmdSetStockPolicy() |
1921 | -: PlayerCommand(), m_warehouse(0), m_isworker(false), m_policy() |
1922 | +: PlayerCommand(), warehouse_(0), isworker_(false), policy_() |
1923 | { |
1924 | } |
1925 | |
1926 | @@ -1914,7 +1914,7 @@ |
1927 | { |
1928 | // Sanitize data that could have come from the network |
1929 | if (Player * plr = game.get_player(sender())) { |
1930 | - if (upcast(Warehouse, warehouse, game.objects().get_object(m_warehouse))) |
1931 | + if (upcast(Warehouse, warehouse, game.objects().get_object(warehouse_))) |
1932 | { |
1933 | if (&warehouse->owner() != plr) { |
1934 | log |
1935 | @@ -1923,7 +1923,7 @@ |
1936 | return; |
1937 | } |
1938 | |
1939 | - switch (m_policy) { |
1940 | + switch (policy_) { |
1941 | case Warehouse::SP_Normal: |
1942 | case Warehouse::SP_Prefer: |
1943 | case Warehouse::SP_DontStock: |
1944 | @@ -1931,22 +1931,22 @@ |
1945 | break; |
1946 | } |
1947 | |
1948 | - if (m_isworker) { |
1949 | - if (!(game.tribes().worker_exists(m_ware))) { |
1950 | + if (isworker_) { |
1951 | + if (!(game.tribes().worker_exists(ware_))) { |
1952 | log |
1953 | ("Cmd_SetStockPolicy: sender %u, worker %u does not exist\n", |
1954 | - sender(), m_ware); |
1955 | + sender(), ware_); |
1956 | return; |
1957 | } |
1958 | - warehouse->set_worker_policy(m_ware, m_policy); |
1959 | + warehouse->set_worker_policy(ware_, policy_); |
1960 | } else { |
1961 | - if (!(game.tribes().ware_exists(m_ware))) { |
1962 | + if (!(game.tribes().ware_exists(ware_))) { |
1963 | log |
1964 | ("Cmd_SetStockPolicy: sender %u, ware %u does not exist\n", |
1965 | - sender(), m_ware); |
1966 | + sender(), ware_); |
1967 | return; |
1968 | } |
1969 | - warehouse->set_ware_policy(m_ware, m_policy); |
1970 | + warehouse->set_ware_policy(ware_, policy_); |
1971 | } |
1972 | } |
1973 | } |
1974 | @@ -1955,20 +1955,20 @@ |
1975 | CmdSetStockPolicy::CmdSetStockPolicy(StreamRead & des) |
1976 | : PlayerCommand(0, des.unsigned_8()) |
1977 | { |
1978 | - m_warehouse = des.unsigned_32(); |
1979 | - m_isworker = des.unsigned_8(); |
1980 | - m_ware = DescriptionIndex(des.unsigned_8()); |
1981 | - m_policy = static_cast<Warehouse::StockPolicy>(des.unsigned_8()); |
1982 | + warehouse_ = des.unsigned_32(); |
1983 | + isworker_ = des.unsigned_8(); |
1984 | + ware_ = DescriptionIndex(des.unsigned_8()); |
1985 | + policy_ = static_cast<Warehouse::StockPolicy>(des.unsigned_8()); |
1986 | } |
1987 | |
1988 | void CmdSetStockPolicy::serialize(StreamWrite & ser) |
1989 | { |
1990 | ser.unsigned_8(PLCMD_SETSTOCKPOLICY); |
1991 | ser.unsigned_8(sender()); |
1992 | - ser.unsigned_32(m_warehouse); |
1993 | - ser.unsigned_8(m_isworker); |
1994 | - ser.unsigned_8(m_ware); |
1995 | - ser.unsigned_8(m_policy); |
1996 | + ser.unsigned_32(warehouse_); |
1997 | + ser.unsigned_8(isworker_); |
1998 | + ser.unsigned_8(ware_); |
1999 | + ser.unsigned_8(policy_); |
2000 | } |
2001 | |
2002 | constexpr uint8_t kCurrentPacketVersionCmdSetStockPolicy = 1; |
2003 | @@ -1980,10 +1980,10 @@ |
2004 | uint8_t packet_version = fr.unsigned_8(); |
2005 | if (packet_version == kCurrentPacketVersionCmdSetStockPolicy) { |
2006 | PlayerCommand::read(fr, egbase, mol); |
2007 | - m_warehouse = fr.unsigned_32(); |
2008 | - m_isworker = fr.unsigned_8(); |
2009 | - m_ware = DescriptionIndex(fr.unsigned_8()); |
2010 | - m_policy = static_cast<Warehouse::StockPolicy>(fr.unsigned_8()); |
2011 | + warehouse_ = fr.unsigned_32(); |
2012 | + isworker_ = fr.unsigned_8(); |
2013 | + ware_ = DescriptionIndex(fr.unsigned_8()); |
2014 | + policy_ = static_cast<Warehouse::StockPolicy>(fr.unsigned_8()); |
2015 | } else { |
2016 | throw UnhandledVersionError("CmdSetStockPolicy", |
2017 | packet_version, kCurrentPacketVersionCmdSetStockPolicy); |
2018 | @@ -1998,10 +1998,10 @@ |
2019 | { |
2020 | fw.unsigned_8(kCurrentPacketVersionCmdSetStockPolicy); |
2021 | PlayerCommand::write(fw, egbase, mos); |
2022 | - fw.unsigned_32(m_warehouse); |
2023 | - fw.unsigned_8(m_isworker); |
2024 | - fw.unsigned_8(m_ware); |
2025 | - fw.unsigned_8(m_policy); |
2026 | + fw.unsigned_32(warehouse_); |
2027 | + fw.unsigned_8(isworker_); |
2028 | + fw.unsigned_8(ware_); |
2029 | + fw.unsigned_8(policy_); |
2030 | } |
2031 | |
2032 | } |
2033 | |
2034 | === modified file 'src/logic/playercommand.h' |
2035 | --- src/logic/playercommand.h 2016-02-09 16:29:48 +0000 |
2036 | +++ src/logic/playercommand.h 2016-03-02 14:42:23 +0000 |
2037 | @@ -47,11 +47,11 @@ |
2038 | PlayerCommand (uint32_t time, PlayerNumber); |
2039 | |
2040 | /// For savegame loading |
2041 | - PlayerCommand() : GameLogicCommand(0), m_sender(0), m_cmdserial(0) {} |
2042 | + PlayerCommand() : GameLogicCommand(0), sender_(0), cmdserial_(0) {} |
2043 | |
2044 | - PlayerNumber sender () const {return m_sender;} |
2045 | - uint32_t cmdserial() const {return m_cmdserial;} |
2046 | - void set_cmdserial(const uint32_t s) {m_cmdserial = s;} |
2047 | + PlayerNumber sender () const {return sender_;} |
2048 | + uint32_t cmdserial() const {return cmdserial_;} |
2049 | + void set_cmdserial(const uint32_t s) {cmdserial_ = s;} |
2050 | |
2051 | virtual void serialize (StreamWrite &) = 0; |
2052 | static Widelands::PlayerCommand * deserialize (StreamRead &); |
2053 | @@ -61,8 +61,8 @@ |
2054 | void read (FileRead &, EditorGameBase &, MapObjectLoader &) override; |
2055 | |
2056 | private: |
2057 | - PlayerNumber m_sender; |
2058 | - uint32_t m_cmdserial; |
2059 | + PlayerNumber sender_; |
2060 | + uint32_t cmdserial_; |
2061 | }; |
2062 | |
2063 | struct CmdBulldoze:public PlayerCommand { |
2064 | @@ -422,10 +422,10 @@ |
2065 | // For savegame loading |
2066 | CmdSetWarePriority() : |
2067 | PlayerCommand(), |
2068 | - m_serial(0), |
2069 | - m_type(0), |
2070 | - m_index(), |
2071 | - m_priority(0) |
2072 | + serial_(0), |
2073 | + type_(0), |
2074 | + index_(), |
2075 | + priority_(0) |
2076 | {} |
2077 | CmdSetWarePriority |
2078 | (uint32_t duetime, PlayerNumber sender, |
2079 | @@ -444,14 +444,14 @@ |
2080 | void serialize (StreamWrite &) override; |
2081 | |
2082 | private: |
2083 | - Serial m_serial; |
2084 | - int32_t m_type; ///< this is always WARE right now |
2085 | - DescriptionIndex m_index; |
2086 | - int32_t m_priority; |
2087 | + Serial serial_; |
2088 | + int32_t type_; ///< this is always WARE right now |
2089 | + DescriptionIndex index_; |
2090 | + int32_t priority_; |
2091 | }; |
2092 | |
2093 | struct CmdSetWareMaxFill : public PlayerCommand { |
2094 | - CmdSetWareMaxFill() : PlayerCommand(), m_serial(0), m_index(), m_max_fill(0) {} // For savegame loading |
2095 | + CmdSetWareMaxFill() : PlayerCommand(), serial_(0), index_(), max_fill_(0) {} // For savegame loading |
2096 | CmdSetWareMaxFill |
2097 | (uint32_t duetime, PlayerNumber, |
2098 | PlayerImmovable &, |
2099 | @@ -469,13 +469,13 @@ |
2100 | void serialize (StreamWrite &) override; |
2101 | |
2102 | private: |
2103 | - Serial m_serial; |
2104 | - DescriptionIndex m_index; |
2105 | - uint32_t m_max_fill; |
2106 | + Serial serial_; |
2107 | + DescriptionIndex index_; |
2108 | + uint32_t max_fill_; |
2109 | }; |
2110 | |
2111 | struct CmdChangeTargetQuantity : public PlayerCommand { |
2112 | - CmdChangeTargetQuantity() : PlayerCommand(), m_economy(0), m_ware_type() {} // For savegame loading. |
2113 | + CmdChangeTargetQuantity() : PlayerCommand(), economy_(0), ware_type_() {} // For savegame loading. |
2114 | CmdChangeTargetQuantity |
2115 | (uint32_t duetime, PlayerNumber sender, |
2116 | uint32_t economy, DescriptionIndex index); |
2117 | @@ -489,17 +489,17 @@ |
2118 | void serialize (StreamWrite &) override; |
2119 | |
2120 | protected: |
2121 | - uint32_t economy () const {return m_economy;} |
2122 | - DescriptionIndex ware_type() const {return m_ware_type;} |
2123 | + uint32_t economy () const {return economy_;} |
2124 | + DescriptionIndex ware_type() const {return ware_type_;} |
2125 | |
2126 | private: |
2127 | - uint32_t m_economy; |
2128 | - DescriptionIndex m_ware_type; |
2129 | + uint32_t economy_; |
2130 | + DescriptionIndex ware_type_; |
2131 | }; |
2132 | |
2133 | |
2134 | struct CmdSetWareTargetQuantity : public CmdChangeTargetQuantity { |
2135 | - CmdSetWareTargetQuantity() : CmdChangeTargetQuantity(), m_permanent(0) {} |
2136 | + CmdSetWareTargetQuantity() : CmdChangeTargetQuantity(), permanent_(0) {} |
2137 | CmdSetWareTargetQuantity |
2138 | (uint32_t duetime, PlayerNumber sender, |
2139 | uint32_t economy, DescriptionIndex index, |
2140 | @@ -517,7 +517,7 @@ |
2141 | void serialize (StreamWrite &) override; |
2142 | |
2143 | private: |
2144 | - uint32_t m_permanent; |
2145 | + uint32_t permanent_; |
2146 | }; |
2147 | |
2148 | struct CmdResetWareTargetQuantity : public CmdChangeTargetQuantity { |
2149 | @@ -539,7 +539,7 @@ |
2150 | }; |
2151 | |
2152 | struct CmdSetWorkerTargetQuantity : public CmdChangeTargetQuantity { |
2153 | - CmdSetWorkerTargetQuantity() : CmdChangeTargetQuantity(), m_permanent(0) {} |
2154 | + CmdSetWorkerTargetQuantity() : CmdChangeTargetQuantity(), permanent_(0) {} |
2155 | CmdSetWorkerTargetQuantity |
2156 | (uint32_t duetime, PlayerNumber sender, |
2157 | uint32_t economy, DescriptionIndex index, |
2158 | @@ -557,7 +557,7 @@ |
2159 | void serialize (StreamWrite &) override; |
2160 | |
2161 | private: |
2162 | - uint32_t m_permanent; |
2163 | + uint32_t permanent_; |
2164 | }; |
2165 | |
2166 | struct CmdResetWorkerTargetQuantity : public CmdChangeTargetQuantity { |
2167 | @@ -683,7 +683,7 @@ |
2168 | PlayerMessageCommand () : PlayerCommand() {} // for savegames |
2169 | PlayerMessageCommand |
2170 | (const uint32_t t, const PlayerNumber p, const MessageId i) |
2171 | - : PlayerCommand(t, p), m_message_id(i) |
2172 | + : PlayerCommand(t, p), message_id_(i) |
2173 | {} |
2174 | |
2175 | void write(FileWrite &, EditorGameBase &, MapObjectSaver &) override; |
2176 | @@ -691,10 +691,10 @@ |
2177 | |
2178 | PlayerMessageCommand(StreamRead &); |
2179 | |
2180 | - MessageId message_id() const {return m_message_id;} |
2181 | + MessageId message_id() const {return message_id_;} |
2182 | |
2183 | private: |
2184 | - MessageId m_message_id; |
2185 | + MessageId message_id_; |
2186 | }; |
2187 | |
2188 | struct CmdMessageSetStatusRead : public PlayerMessageCommand { |
2189 | @@ -751,10 +751,10 @@ |
2190 | void read (FileRead &, EditorGameBase &, MapObjectLoader &) override; |
2191 | |
2192 | private: |
2193 | - Serial m_warehouse; |
2194 | - bool m_isworker; |
2195 | - DescriptionIndex m_ware; |
2196 | - Warehouse::StockPolicy m_policy; |
2197 | + Serial warehouse_; |
2198 | + bool isworker_; |
2199 | + DescriptionIndex ware_; |
2200 | + Warehouse::StockPolicy policy_; |
2201 | }; |
2202 | |
2203 | } |
2204 | |
2205 | === modified file 'src/logic/playersmanager.cc' |
2206 | --- src/logic/playersmanager.cc 2015-10-18 15:41:10 +0000 |
2207 | +++ src/logic/playersmanager.cc 2016-03-02 14:42:23 +0000 |
2208 | @@ -31,10 +31,10 @@ |
2209 | namespace Widelands { |
2210 | |
2211 | PlayersManager::PlayersManager(EditorGameBase& egbase) : |
2212 | -m_egbase(egbase), |
2213 | -m_number_of_players(0) |
2214 | +egbase_(egbase), |
2215 | +number_of_players_(0) |
2216 | { |
2217 | - memset(m_players, 0, sizeof(m_players)); |
2218 | + memset(players_, 0, sizeof(players_)); |
2219 | } |
2220 | |
2221 | PlayersManager::~PlayersManager() |
2222 | @@ -44,12 +44,12 @@ |
2223 | |
2224 | void PlayersManager::cleanup() |
2225 | { |
2226 | - const Player * const * const players_end = m_players + MAX_PLAYERS; |
2227 | - for (Player * * p = m_players; p < players_end; ++p) { |
2228 | + const Player * const * const players_end = players_ + MAX_PLAYERS; |
2229 | + for (Player * * p = players_; p < players_end; ++p) { |
2230 | delete *p; |
2231 | *p = nullptr; |
2232 | } |
2233 | - m_number_of_players = 0; |
2234 | + number_of_players_ = 0; |
2235 | } |
2236 | |
2237 | |
2238 | @@ -58,12 +58,12 @@ |
2239 | assert(1 <= plnum); |
2240 | assert(plnum <= MAX_PLAYERS); |
2241 | |
2242 | - Player * & p = m_players[plnum - 1]; |
2243 | + Player * & p = players_[plnum - 1]; |
2244 | if (p) { |
2245 | delete p; |
2246 | p = nullptr; |
2247 | if (plnum <= UserSettings::highest_playernum()) { |
2248 | - m_number_of_players--; |
2249 | + number_of_players_--; |
2250 | } |
2251 | } |
2252 | } |
2253 | @@ -78,22 +78,22 @@ |
2254 | assert(1 <= player_number); |
2255 | assert(player_number <= MAX_PLAYERS); |
2256 | |
2257 | - Player * & p = m_players[player_number - 1]; |
2258 | + Player * & p = players_[player_number - 1]; |
2259 | if (p) { |
2260 | delete p; |
2261 | if (player_number <= UserSettings::highest_playernum()) { |
2262 | - m_number_of_players--; |
2263 | + number_of_players_--; |
2264 | } |
2265 | } |
2266 | p = new Player |
2267 | - (m_egbase, |
2268 | + (egbase_, |
2269 | player_number, |
2270 | initialization_index, |
2271 | - *m_egbase.tribes().get_tribe_descr(m_egbase.tribes().tribe_index(tribe)), |
2272 | + *egbase_.tribes().get_tribe_descr(egbase_.tribes().tribe_index(tribe)), |
2273 | name); |
2274 | p->set_team_number(team); |
2275 | if (player_number <= UserSettings::highest_playernum()) { |
2276 | - m_number_of_players++; |
2277 | + number_of_players_++; |
2278 | } |
2279 | return p; |
2280 | } |
2281 | @@ -102,21 +102,21 @@ |
2282 | { |
2283 | // Ensure we don't have a status for it yet |
2284 | std::vector<PlayerEndStatus>::iterator it; |
2285 | - for (it = m_players_end_status.begin(); it != m_players_end_status.end(); ++it) { |
2286 | + for (it = players_end_status_.begin(); it != players_end_status_.end(); ++it) { |
2287 | PlayerEndStatus pes = *it; |
2288 | if (pes.player == status.player) { |
2289 | throw wexception("Player End status for player %d already reported", pes.player); |
2290 | } |
2291 | } |
2292 | - m_players_end_status.push_back(status); |
2293 | + players_end_status_.push_back(status); |
2294 | |
2295 | // If all results have been gathered, save game and show summary screen |
2296 | - if (m_players_end_status.size() < m_number_of_players) { |
2297 | + if (players_end_status_.size() < number_of_players_) { |
2298 | return; |
2299 | } |
2300 | |
2301 | - if (m_egbase.get_igbase()) { |
2302 | - m_egbase.get_igbase()->show_game_summary(); |
2303 | + if (egbase_.get_igbase()) { |
2304 | + egbase_.get_igbase()->show_game_summary(); |
2305 | } |
2306 | } |
2307 | |
2308 | |
2309 | === modified file 'src/logic/playersmanager.h' |
2310 | --- src/logic/playersmanager.h 2014-09-10 13:03:40 +0000 |
2311 | +++ src/logic/playersmanager.h 2016-03-02 14:42:23 +0000 |
2312 | @@ -74,20 +74,20 @@ |
2313 | Player * get_player(int32_t n) const { |
2314 | assert(1 <= n); |
2315 | assert (n <= MAX_PLAYERS); |
2316 | - return m_players[n - 1]; |
2317 | + return players_[n - 1]; |
2318 | } |
2319 | Player & player(int32_t n) const { |
2320 | assert(1 <= n); |
2321 | assert (n <= MAX_PLAYERS); |
2322 | - return *m_players[n - 1]; |
2323 | + return *players_[n - 1]; |
2324 | } |
2325 | |
2326 | /** |
2327 | * \return the number of players (human or ai) |
2328 | */ |
2329 | - uint8_t get_number_of_players() {return m_number_of_players;} |
2330 | + uint8_t get_number_of_players() {return number_of_players_;} |
2331 | |
2332 | - const std::vector<PlayerEndStatus> & get_players_end_status() {return m_players_end_status;} |
2333 | + const std::vector<PlayerEndStatus> & get_players_end_status() {return players_end_status_;} |
2334 | |
2335 | /** |
2336 | * Adds a new player status for a player that left the game. |
2337 | @@ -95,10 +95,10 @@ |
2338 | void add_player_end_status(const PlayerEndStatus & status); |
2339 | |
2340 | private: |
2341 | - Player * m_players[MAX_PLAYERS]; |
2342 | - EditorGameBase & m_egbase; |
2343 | - uint8_t m_number_of_players; |
2344 | - std::vector<PlayerEndStatus> m_players_end_status; |
2345 | + Player* players_[MAX_PLAYERS]; |
2346 | + EditorGameBase& egbase_; |
2347 | + uint8_t number_of_players_; |
2348 | + std::vector<PlayerEndStatus> players_end_status_; |
2349 | }; |
2350 | } |
2351 | |
2352 | |
2353 | === modified file 'src/logic/replay.cc' |
2354 | --- src/logic/replay.cc 2016-02-09 16:29:48 +0000 |
2355 | +++ src/logic/replay.cc 2016-03-02 14:42:23 +0000 |
2356 | @@ -83,17 +83,17 @@ |
2357 | */ |
2358 | ReplayReader::ReplayReader(Game & game, const std::string & filename) |
2359 | { |
2360 | - m_replaytime = 0; |
2361 | + replaytime_ = 0; |
2362 | |
2363 | { |
2364 | GameLoader gl(filename + WLGF_SUFFIX, game); |
2365 | gl.load_game(); |
2366 | } |
2367 | |
2368 | - m_cmdlog = g_fs->open_stream_read(filename); |
2369 | + cmdlog_ = g_fs->open_stream_read(filename); |
2370 | |
2371 | try { |
2372 | - const uint32_t magic = m_cmdlog->unsigned_32(); |
2373 | + const uint32_t magic = cmdlog_->unsigned_32(); |
2374 | if (magic == 0x2E21A100) |
2375 | // Note: This was never released as part of a build |
2376 | throw wexception |
2377 | @@ -104,14 +104,14 @@ |
2378 | throw wexception |
2379 | ("%s apparently not a valid replay file", filename.c_str()); |
2380 | |
2381 | - const uint8_t packet_version = m_cmdlog->unsigned_8(); |
2382 | + const uint8_t packet_version = cmdlog_->unsigned_8(); |
2383 | if (packet_version != kCurrentPacketVersion) { |
2384 | throw UnhandledVersionError("ReplayReader", packet_version, kCurrentPacketVersion); |
2385 | } |
2386 | - game.rng().read_state(*m_cmdlog); |
2387 | + game.rng().read_state(*cmdlog_); |
2388 | } |
2389 | catch (...) { |
2390 | - delete m_cmdlog; |
2391 | + delete cmdlog_; |
2392 | throw; |
2393 | } |
2394 | } |
2395 | @@ -122,7 +122,7 @@ |
2396 | */ |
2397 | ReplayReader::~ReplayReader() |
2398 | { |
2399 | - delete m_cmdlog; |
2400 | + delete cmdlog_; |
2401 | } |
2402 | |
2403 | |
2404 | @@ -135,22 +135,22 @@ |
2405 | */ |
2406 | Command * ReplayReader::get_next_command(const uint32_t time) |
2407 | { |
2408 | - if (!m_cmdlog) |
2409 | + if (!cmdlog_) |
2410 | return nullptr; |
2411 | |
2412 | - if (static_cast<int32_t>(m_replaytime - time) > 0) |
2413 | + if (static_cast<int32_t>(replaytime_ - time) > 0) |
2414 | return nullptr; |
2415 | |
2416 | try { |
2417 | - uint8_t pkt = m_cmdlog->unsigned_8(); |
2418 | + uint8_t pkt = cmdlog_->unsigned_8(); |
2419 | |
2420 | switch (pkt) { |
2421 | case pkt_playercommand: { |
2422 | - m_replaytime = m_cmdlog->unsigned_32(); |
2423 | + replaytime_ = cmdlog_->unsigned_32(); |
2424 | |
2425 | - uint32_t duetime = m_cmdlog->unsigned_32(); |
2426 | - uint32_t cmdserial = m_cmdlog->unsigned_32(); |
2427 | - PlayerCommand & cmd = *PlayerCommand::deserialize(*m_cmdlog); |
2428 | + uint32_t duetime = cmdlog_->unsigned_32(); |
2429 | + uint32_t cmdserial = cmdlog_->unsigned_32(); |
2430 | + PlayerCommand & cmd = *PlayerCommand::deserialize(*cmdlog_); |
2431 | cmd.set_duetime (duetime); |
2432 | cmd.set_cmdserial(cmdserial); |
2433 | |
2434 | @@ -158,18 +158,18 @@ |
2435 | } |
2436 | |
2437 | case pkt_syncreport: { |
2438 | - uint32_t duetime = m_cmdlog->unsigned_32(); |
2439 | + uint32_t duetime = cmdlog_->unsigned_32(); |
2440 | Md5Checksum hash; |
2441 | - m_cmdlog->data(hash.data, sizeof(hash.data)); |
2442 | + cmdlog_->data(hash.data, sizeof(hash.data)); |
2443 | |
2444 | return new CmdReplaySyncRead(duetime, hash); |
2445 | } |
2446 | |
2447 | case pkt_end: { |
2448 | - uint32_t endtime = m_cmdlog->unsigned_32(); |
2449 | + uint32_t endtime = cmdlog_->unsigned_32(); |
2450 | log("REPLAY: End of replay (gametime: %u)\n", endtime); |
2451 | - delete m_cmdlog; |
2452 | - m_cmdlog = nullptr; |
2453 | + delete cmdlog_; |
2454 | + cmdlog_ = nullptr; |
2455 | return nullptr; |
2456 | } |
2457 | |
2458 | @@ -178,8 +178,8 @@ |
2459 | } |
2460 | } catch (const WException & e) { |
2461 | log("REPLAY: Caught exception %s\n", e.what()); |
2462 | - delete m_cmdlog; |
2463 | - m_cmdlog = nullptr; |
2464 | + delete cmdlog_; |
2465 | + cmdlog_ = nullptr; |
2466 | } |
2467 | |
2468 | return nullptr; |
2469 | @@ -191,7 +191,7 @@ |
2470 | */ |
2471 | bool ReplayReader::end_of_replay() |
2472 | { |
2473 | - return m_cmdlog == nullptr; |
2474 | + return cmdlog_ == nullptr; |
2475 | } |
2476 | |
2477 | |
2478 | @@ -223,20 +223,20 @@ |
2479 | * and the game has changed into running state. |
2480 | */ |
2481 | ReplayWriter::ReplayWriter(Game & game, const std::string & filename) |
2482 | - : m_game(game), m_filename(filename) |
2483 | + : game_(game), filename_(filename) |
2484 | { |
2485 | g_fs->ensure_directory_exists(REPLAY_DIR); |
2486 | |
2487 | - SaveHandler & save_handler = m_game.save_handler(); |
2488 | + SaveHandler & save_handler = game_.save_handler(); |
2489 | |
2490 | std::string error; |
2491 | - if (!save_handler.save_game(m_game, m_filename + WLGF_SUFFIX, &error)) |
2492 | + if (!save_handler.save_game(game_, filename_ + WLGF_SUFFIX, &error)) |
2493 | throw wexception("Failed to save game for replay: %s", error.c_str()); |
2494 | |
2495 | log("Reloading the game from replay\n"); |
2496 | game.cleanup_for_load(); |
2497 | { |
2498 | - GameLoader gl(m_filename + WLGF_SUFFIX, game); |
2499 | + GameLoader gl(filename_ + WLGF_SUFFIX, game); |
2500 | gl.load_game(); |
2501 | } |
2502 | game.postload(); |
2503 | @@ -245,11 +245,11 @@ |
2504 | game.enqueue_command |
2505 | (new CmdReplaySyncWrite(game.get_gametime() + kSyncInterval)); |
2506 | |
2507 | - m_cmdlog = g_fs->open_stream_write(filename); |
2508 | - m_cmdlog->unsigned_32(kReplayMagic); |
2509 | - m_cmdlog->unsigned_8(kCurrentPacketVersion); |
2510 | + cmdlog_ = g_fs->open_stream_write(filename); |
2511 | + cmdlog_->unsigned_32(kReplayMagic); |
2512 | + cmdlog_->unsigned_8(kCurrentPacketVersion); |
2513 | |
2514 | - game.rng().write_state(*m_cmdlog); |
2515 | + game.rng().write_state(*cmdlog_); |
2516 | } |
2517 | |
2518 | |
2519 | @@ -258,10 +258,10 @@ |
2520 | */ |
2521 | ReplayWriter::~ReplayWriter() |
2522 | { |
2523 | - m_cmdlog->unsigned_8(pkt_end); |
2524 | - m_cmdlog->unsigned_32(m_game.get_gametime()); |
2525 | + cmdlog_->unsigned_8(pkt_end); |
2526 | + cmdlog_->unsigned_32(game_.get_gametime()); |
2527 | |
2528 | - delete m_cmdlog; |
2529 | + delete cmdlog_; |
2530 | } |
2531 | |
2532 | |
2533 | @@ -270,16 +270,16 @@ |
2534 | */ |
2535 | void ReplayWriter::send_player_command(PlayerCommand * cmd) |
2536 | { |
2537 | - m_cmdlog->unsigned_8(pkt_playercommand); |
2538 | + cmdlog_->unsigned_8(pkt_playercommand); |
2539 | // The semantics of the timestamp is |
2540 | // "There will be no more player commands that are due *before* the |
2541 | // given time". |
2542 | - m_cmdlog->unsigned_32(m_game.get_gametime()); |
2543 | - m_cmdlog->unsigned_32(cmd->duetime()); |
2544 | - m_cmdlog->unsigned_32(cmd->cmdserial()); |
2545 | - cmd->serialize(*m_cmdlog); |
2546 | + cmdlog_->unsigned_32(game_.get_gametime()); |
2547 | + cmdlog_->unsigned_32(cmd->duetime()); |
2548 | + cmdlog_->unsigned_32(cmd->cmdserial()); |
2549 | + cmd->serialize(*cmdlog_); |
2550 | |
2551 | - m_cmdlog->flush(); |
2552 | + cmdlog_->flush(); |
2553 | } |
2554 | |
2555 | |
2556 | @@ -288,10 +288,10 @@ |
2557 | */ |
2558 | void ReplayWriter::send_sync(const Md5Checksum & hash) |
2559 | { |
2560 | - m_cmdlog->unsigned_8(pkt_syncreport); |
2561 | - m_cmdlog->unsigned_32(m_game.get_gametime()); |
2562 | - m_cmdlog->data(hash.data, sizeof(hash.data)); |
2563 | - m_cmdlog->flush(); |
2564 | + cmdlog_->unsigned_8(pkt_syncreport); |
2565 | + cmdlog_->unsigned_32(game_.get_gametime()); |
2566 | + cmdlog_->data(hash.data, sizeof(hash.data)); |
2567 | + cmdlog_->flush(); |
2568 | } |
2569 | |
2570 | } |
2571 | |
2572 | === modified file 'src/logic/replay.h' |
2573 | --- src/logic/replay.h 2014-09-19 12:54:54 +0000 |
2574 | +++ src/logic/replay.h 2016-03-02 14:42:23 +0000 |
2575 | @@ -58,9 +58,9 @@ |
2576 | bool end_of_replay(); |
2577 | |
2578 | private: |
2579 | - StreamRead * m_cmdlog; |
2580 | + StreamRead * cmdlog_; |
2581 | |
2582 | - uint32_t m_replaytime; |
2583 | + uint32_t replaytime_; |
2584 | }; |
2585 | |
2586 | /** |
2587 | @@ -75,9 +75,9 @@ |
2588 | void send_sync(const Md5Checksum &); |
2589 | |
2590 | private: |
2591 | - Game & m_game; |
2592 | - StreamWrite * m_cmdlog; |
2593 | - std::string m_filename; |
2594 | + Game & game_; |
2595 | + StreamWrite* cmdlog_; |
2596 | + std::string filename_; |
2597 | }; |
2598 | |
2599 | } |
2600 | |
2601 | === modified file 'src/logic/replay_game_controller.cc' |
2602 | --- src/logic/replay_game_controller.cc 2015-11-21 11:59:00 +0000 |
2603 | +++ src/logic/replay_game_controller.cc 2016-03-02 14:42:23 +0000 |
2604 | @@ -27,23 +27,23 @@ |
2605 | |
2606 | |
2607 | ReplayGameController::ReplayGameController(Widelands::Game & game, const std::string & filename) : |
2608 | - m_game(game), |
2609 | - m_lastframe(SDL_GetTicks()), |
2610 | - m_time(m_game.get_gametime()), |
2611 | - m_speed(1000), |
2612 | - m_paused(false) |
2613 | + game_(game), |
2614 | + lastframe_(SDL_GetTicks()), |
2615 | + time_(game_.get_gametime()), |
2616 | + speed_(1000), |
2617 | + paused_(false) |
2618 | { |
2619 | - m_game.set_game_controller(this); |
2620 | + game_.set_game_controller(this); |
2621 | |
2622 | // We have to create an empty map, otherwise nothing will load properly |
2623 | game.set_map(new Widelands::Map); |
2624 | - m_replayreader.reset(new Widelands::ReplayReader(m_game, filename)); |
2625 | + replayreader_.reset(new Widelands::ReplayReader(game_, filename)); |
2626 | } |
2627 | |
2628 | void ReplayGameController::think() { |
2629 | uint32_t curtime = SDL_GetTicks(); |
2630 | - int32_t frametime = curtime - m_lastframe; |
2631 | - m_lastframe = curtime; |
2632 | + int32_t frametime = curtime - lastframe_; |
2633 | + lastframe_ = curtime; |
2634 | |
2635 | // prevent crazy frametimes |
2636 | if (frametime < 0) |
2637 | @@ -53,18 +53,18 @@ |
2638 | |
2639 | frametime = frametime * real_speed() / 1000; |
2640 | |
2641 | - m_time = m_game.get_gametime() + frametime; |
2642 | + time_ = game_.get_gametime() + frametime; |
2643 | |
2644 | - if (m_replayreader) { |
2645 | + if (replayreader_) { |
2646 | while |
2647 | (Widelands::Command * const cmd = |
2648 | - m_replayreader->get_next_command(m_time)) |
2649 | - m_game.enqueue_command(cmd); |
2650 | + replayreader_->get_next_command(time_)) |
2651 | + game_.enqueue_command(cmd); |
2652 | |
2653 | - if (m_replayreader->end_of_replay()) { |
2654 | - m_replayreader.reset(nullptr); |
2655 | - m_game.enqueue_command |
2656 | - (new CmdReplayEnd(m_time = m_game.get_gametime())); |
2657 | + if (replayreader_->end_of_replay()) { |
2658 | + replayreader_.reset(nullptr); |
2659 | + game_.enqueue_command |
2660 | + (new CmdReplayEnd(time_ = game_.get_gametime())); |
2661 | } |
2662 | } |
2663 | } |
2664 | @@ -74,7 +74,7 @@ |
2665 | } |
2666 | |
2667 | int32_t ReplayGameController::get_frametime() { |
2668 | - return m_time - m_game.get_gametime(); |
2669 | + return time_ - game_.get_gametime(); |
2670 | } |
2671 | |
2672 | GameController::GameType ReplayGameController::get_game_type() { |
2673 | @@ -82,23 +82,23 @@ |
2674 | } |
2675 | |
2676 | uint32_t ReplayGameController::real_speed() { |
2677 | - return m_paused ? 0 : m_speed; |
2678 | + return paused_ ? 0 : speed_; |
2679 | } |
2680 | |
2681 | uint32_t ReplayGameController::desired_speed() { |
2682 | - return m_speed; |
2683 | + return speed_; |
2684 | } |
2685 | |
2686 | void ReplayGameController::set_desired_speed(uint32_t const speed) { |
2687 | - m_speed = speed; |
2688 | + speed_ = speed; |
2689 | } |
2690 | |
2691 | bool ReplayGameController::is_paused() { |
2692 | - return m_paused; |
2693 | + return paused_; |
2694 | } |
2695 | |
2696 | void ReplayGameController::set_paused(bool const paused) { |
2697 | - m_paused = paused; |
2698 | + paused_ = paused; |
2699 | } |
2700 | |
2701 | void ReplayGameController::CmdReplayEnd::execute (Widelands::Game & game) { |
2702 | |
2703 | === modified file 'src/logic/replay_game_controller.h' |
2704 | --- src/logic/replay_game_controller.h 2016-02-09 16:29:48 +0000 |
2705 | +++ src/logic/replay_game_controller.h 2016-03-02 14:42:23 +0000 |
2706 | @@ -51,12 +51,12 @@ |
2707 | virtual Widelands::QueueCommandTypes id() const; |
2708 | }; |
2709 | |
2710 | - Widelands::Game & m_game; |
2711 | - std::unique_ptr<Widelands::ReplayReader> m_replayreader; |
2712 | - int32_t m_lastframe; |
2713 | - int32_t m_time; |
2714 | - uint32_t m_speed; |
2715 | - bool m_paused; |
2716 | + Widelands::Game & game_; |
2717 | + std::unique_ptr<Widelands::ReplayReader> replayreader_; |
2718 | + int32_t lastframe_; |
2719 | + int32_t time_; |
2720 | + uint32_t speed_; |
2721 | + bool paused_; |
2722 | }; |
2723 | |
2724 | #endif // end of include guard: WL_LOGIC_REPLAY_GAME_CONTROLLER_H |
2725 | |
2726 | === modified file 'src/logic/save_handler.cc' |
2727 | --- src/logic/save_handler.cc 2016-02-21 10:13:05 +0000 |
2728 | +++ src/logic/save_handler.cc 2016-03-02 14:42:23 +0000 |
2729 | @@ -46,21 +46,21 @@ |
2730 | initialize(realtime); |
2731 | std::string filename = autosave_filename_; |
2732 | |
2733 | - if (!m_allow_saving) { |
2734 | + if (!allow_saving_) { |
2735 | return; |
2736 | } |
2737 | if (game.is_replay()) { |
2738 | return; |
2739 | } |
2740 | |
2741 | - if (m_save_requested) { |
2742 | - if (!m_save_filename.empty()) { |
2743 | - filename = m_save_filename; |
2744 | + if (save_requested_) { |
2745 | + if (!save_filename_.empty()) { |
2746 | + filename = save_filename_; |
2747 | } |
2748 | |
2749 | log("Autosave: save requested : %s\n", filename.c_str()); |
2750 | - m_save_requested = false; |
2751 | - m_save_filename = ""; |
2752 | + save_requested_ = false; |
2753 | + save_filename_ = ""; |
2754 | } else { |
2755 | const int32_t autosave_interval_in_seconds = |
2756 | g_options.pull_section("global").get_int("autosave", DEFAULT_AUTOSAVE_INTERVAL * 60); |
2757 | @@ -68,14 +68,14 @@ |
2758 | return; // no autosave requested |
2759 | } |
2760 | |
2761 | - const int32_t elapsed = (realtime - m_last_saved_realtime) / 1000; |
2762 | + const int32_t elapsed = (realtime - last_saved_realtime_) / 1000; |
2763 | if (elapsed < autosave_interval_in_seconds) { |
2764 | return; |
2765 | } |
2766 | |
2767 | if (game.game_controller()->is_paused()) { // check if game is paused |
2768 | // Wait 30 seconds until next save try |
2769 | - m_last_saved_realtime = m_last_saved_realtime + 30000; |
2770 | + last_saved_realtime_ = last_saved_realtime_ + 30000; |
2771 | return; |
2772 | } |
2773 | //roll autosaves |
2774 | @@ -132,7 +132,7 @@ |
2775 | g_fs->fs_rename(backup_filename, complete_filename); |
2776 | } |
2777 | // Wait 30 seconds until next save try |
2778 | - m_last_saved_realtime = m_last_saved_realtime + 30000; |
2779 | + last_saved_realtime_ = last_saved_realtime_ + 30000; |
2780 | return; |
2781 | } else { |
2782 | // if backup file was created, time to remove it |
2783 | @@ -142,18 +142,18 @@ |
2784 | |
2785 | log("Autosave: save took %d ms\n", SDL_GetTicks() - realtime); |
2786 | game.get_ibase()->log_message(_("Game saved")); |
2787 | - m_last_saved_realtime = realtime; |
2788 | + last_saved_realtime_ = realtime; |
2789 | } |
2790 | |
2791 | /** |
2792 | * Initialize autosave timer |
2793 | */ |
2794 | void SaveHandler::initialize(uint32_t realtime) { |
2795 | - if (m_initialized) |
2796 | + if (initialized_) |
2797 | return; |
2798 | |
2799 | - m_last_saved_realtime = realtime; |
2800 | - m_initialized = true; |
2801 | + last_saved_realtime_ = realtime; |
2802 | + initialized_ = true; |
2803 | } |
2804 | |
2805 | /* |
2806 | |
2807 | === modified file 'src/logic/save_handler.h' |
2808 | --- src/logic/save_handler.h 2016-02-18 18:12:48 +0000 |
2809 | +++ src/logic/save_handler.h 2016-03-02 14:42:23 +0000 |
2810 | @@ -32,8 +32,8 @@ |
2811 | |
2812 | class SaveHandler { |
2813 | public: |
2814 | - SaveHandler() : m_last_saved_realtime(0), m_initialized(false), m_allow_saving(true), |
2815 | - m_save_requested(false), m_save_filename(""), autosave_filename_("wl_autosave") {} |
2816 | + SaveHandler() : last_saved_realtime_(0), initialized_(false), allow_saving_(true), |
2817 | + save_requested_(false), save_filename_(""), autosave_filename_("wl_autosave") {} |
2818 | void think(Widelands::Game &); |
2819 | std::string create_file_name(const std::string& dir, const std::string& filename) const; |
2820 | bool save_game |
2821 | @@ -42,24 +42,24 @@ |
2822 | std::string * error = nullptr); |
2823 | |
2824 | static std::string get_base_dir() {return "save";} |
2825 | - const std::string get_cur_filename() {return m_current_filename;} |
2826 | - void set_current_filename(const std::string& filename) {m_current_filename = filename;} |
2827 | + const std::string get_cur_filename() {return current_filename_;} |
2828 | + void set_current_filename(const std::string& filename) {current_filename_ = filename;} |
2829 | void set_autosave_filename(const std::string& filename) {autosave_filename_ = filename;} |
2830 | - void set_allow_saving(bool t) {m_allow_saving = t;} |
2831 | - bool get_allow_saving() {return m_allow_saving;} |
2832 | + void set_allow_saving(bool t) {allow_saving_ = t;} |
2833 | + bool get_allow_saving() {return allow_saving_;} |
2834 | void request_save(const std::string& filename = "") |
2835 | { |
2836 | - m_save_requested = true; |
2837 | - m_save_filename = filename; |
2838 | + save_requested_ = true; |
2839 | + save_filename_ = filename; |
2840 | } |
2841 | |
2842 | private: |
2843 | - uint32_t m_last_saved_realtime; |
2844 | - bool m_initialized; |
2845 | - bool m_allow_saving; |
2846 | - bool m_save_requested; |
2847 | - std::string m_save_filename; |
2848 | - std::string m_current_filename; |
2849 | + uint32_t last_saved_realtime_; |
2850 | + bool initialized_; |
2851 | + bool allow_saving_; |
2852 | + bool save_requested_; |
2853 | + std::string save_filename_; |
2854 | + std::string current_filename_; |
2855 | std::string autosave_filename_; |
2856 | |
2857 | void initialize(uint32_t gametime); |
2858 | |
2859 | === modified file 'src/logic/single_player_game_controller.cc' |
2860 | --- src/logic/single_player_game_controller.cc 2015-11-08 17:31:06 +0000 |
2861 | +++ src/logic/single_player_game_controller.cc 2016-03-02 14:42:23 +0000 |
2862 | @@ -32,31 +32,31 @@ |
2863 | (Widelands::Game & game, |
2864 | bool const useai, |
2865 | Widelands::PlayerNumber const local) |
2866 | - : m_game (game), |
2867 | - m_useai (useai), |
2868 | - m_lastframe (SDL_GetTicks()), |
2869 | - m_time (m_game.get_gametime()), |
2870 | - m_speed |
2871 | + : game_ (game), |
2872 | + use_ai_ (useai), |
2873 | + lastframe_ (SDL_GetTicks()), |
2874 | + time_ (game_.get_gametime()), |
2875 | + speed_ |
2876 | (g_options.pull_section("global").get_natural |
2877 | ("speed_of_new_game", 1000)), |
2878 | - m_paused(false), |
2879 | - m_player_cmdserial(0), |
2880 | - m_local (local) |
2881 | + paused_(false), |
2882 | + player_cmdserial_(0), |
2883 | + local_ (local) |
2884 | { |
2885 | } |
2886 | |
2887 | SinglePlayerGameController::~SinglePlayerGameController() |
2888 | { |
2889 | - for (uint32_t i = 0; i < m_computerplayers.size(); ++i) |
2890 | - delete m_computerplayers[i]; |
2891 | - m_computerplayers.clear(); |
2892 | + for (uint32_t i = 0; i < computerplayers_.size(); ++i) |
2893 | + delete computerplayers_[i]; |
2894 | + computerplayers_.clear(); |
2895 | } |
2896 | |
2897 | void SinglePlayerGameController::think() |
2898 | { |
2899 | uint32_t const curtime = SDL_GetTicks(); |
2900 | - int32_t frametime = curtime - m_lastframe; |
2901 | - m_lastframe = curtime; |
2902 | + int32_t frametime = curtime - lastframe_; |
2903 | + lastframe_ = curtime; |
2904 | |
2905 | // prevent crazy frametimes |
2906 | if (frametime < 0) |
2907 | @@ -66,20 +66,20 @@ |
2908 | |
2909 | frametime = frametime * real_speed() / 1000; |
2910 | |
2911 | - m_time = m_game.get_gametime() + frametime; |
2912 | - |
2913 | - if (m_useai && m_game.is_loaded()) { |
2914 | - const Widelands::PlayerNumber nr_players = m_game.map().get_nrplayers(); |
2915 | - iterate_players_existing(p, nr_players, m_game, plr) |
2916 | - if (p != m_local) { |
2917 | - |
2918 | - if (p > m_computerplayers.size()) |
2919 | - m_computerplayers.resize(p); |
2920 | - if (!m_computerplayers[p - 1]) |
2921 | - m_computerplayers[p - 1] = |
2922 | + time_ = game_.get_gametime() + frametime; |
2923 | + |
2924 | + if (use_ai_ && game_.is_loaded()) { |
2925 | + const Widelands::PlayerNumber nr_players = game_.map().get_nrplayers(); |
2926 | + iterate_players_existing(p, nr_players, game_, plr) |
2927 | + if (p != local_) { |
2928 | + |
2929 | + if (p > computerplayers_.size()) |
2930 | + computerplayers_.resize(p); |
2931 | + if (!computerplayers_[p - 1]) |
2932 | + computerplayers_[p - 1] = |
2933 | ComputerPlayer::get_implementation |
2934 | - (plr->get_ai())->instantiate(m_game, p); |
2935 | - m_computerplayers[p - 1]->think(); |
2936 | + (plr->get_ai())->instantiate(game_, p); |
2937 | + computerplayers_[p - 1]->think(); |
2938 | } |
2939 | } |
2940 | } |
2941 | @@ -87,13 +87,13 @@ |
2942 | void SinglePlayerGameController::send_player_command |
2943 | (Widelands::PlayerCommand & pc) |
2944 | { |
2945 | - pc.set_cmdserial(++m_player_cmdserial); |
2946 | - m_game.enqueue_command (&pc); |
2947 | + pc.set_cmdserial(++player_cmdserial_); |
2948 | + game_.enqueue_command (&pc); |
2949 | } |
2950 | |
2951 | int32_t SinglePlayerGameController::get_frametime() |
2952 | { |
2953 | - return m_time - m_game.get_gametime(); |
2954 | + return time_ - game_.get_gametime(); |
2955 | } |
2956 | |
2957 | GameController::GameType SinglePlayerGameController::get_game_type() |
2958 | @@ -103,41 +103,41 @@ |
2959 | |
2960 | uint32_t SinglePlayerGameController::real_speed() |
2961 | { |
2962 | - if (m_paused) |
2963 | + if (paused_) |
2964 | return 0; |
2965 | else |
2966 | - return m_speed; |
2967 | + return speed_; |
2968 | } |
2969 | |
2970 | uint32_t SinglePlayerGameController::desired_speed() |
2971 | { |
2972 | - return m_speed; |
2973 | + return speed_; |
2974 | } |
2975 | |
2976 | void SinglePlayerGameController::set_desired_speed(uint32_t const speed) |
2977 | { |
2978 | - m_speed = speed; |
2979 | + speed_ = speed; |
2980 | } |
2981 | |
2982 | bool SinglePlayerGameController::is_paused() |
2983 | { |
2984 | - return m_paused; |
2985 | + return paused_; |
2986 | } |
2987 | |
2988 | void SinglePlayerGameController::set_paused(bool paused) |
2989 | { |
2990 | - m_paused = paused; |
2991 | + paused_ = paused; |
2992 | } |
2993 | |
2994 | void SinglePlayerGameController::report_result |
2995 | (uint8_t p_nr, Widelands::PlayerEndResult result, const std::string & info) |
2996 | { |
2997 | Widelands::PlayerEndStatus pes; |
2998 | - Widelands::Player* player = m_game.get_player(p_nr); |
2999 | + Widelands::Player* player = game_.get_player(p_nr); |
3000 | assert(player); |
3001 | pes.player = player->player_number(); |
3002 | - pes.time = m_game.get_gametime(); |
3003 | + pes.time = game_.get_gametime(); |
3004 | pes.result = result; |
3005 | pes.info = info; |
3006 | - m_game.player_manager()->add_player_end_status(pes); |
3007 | + game_.player_manager()->add_player_end_status(pes); |
3008 | } |
3009 | |
3010 | === modified file 'src/logic/single_player_game_controller.h' |
3011 | --- src/logic/single_player_game_controller.h 2015-03-01 09:21:20 +0000 |
3012 | +++ src/logic/single_player_game_controller.h 2016-03-02 14:42:23 +0000 |
3013 | @@ -42,15 +42,15 @@ |
3014 | void report_result(uint8_t player, Widelands::PlayerEndResult result, const std::string & info) override; |
3015 | |
3016 | private: |
3017 | - Widelands::Game & m_game; |
3018 | - bool m_useai; |
3019 | - int32_t m_lastframe; |
3020 | - int32_t m_time; |
3021 | - uint32_t m_speed; ///< current game speed, in milliseconds per second |
3022 | - bool m_paused; |
3023 | - uint32_t m_player_cmdserial; |
3024 | - Widelands::PlayerNumber m_local; |
3025 | - std::vector<ComputerPlayer *> m_computerplayers; |
3026 | + Widelands::Game & game_; |
3027 | + bool use_ai_; |
3028 | + int32_t lastframe_; |
3029 | + int32_t time_; |
3030 | + uint32_t speed_; ///< current game speed, in milliseconds per second |
3031 | + bool paused_; |
3032 | + uint32_t player_cmdserial_; |
3033 | + Widelands::PlayerNumber local_; |
3034 | + std::vector<ComputerPlayer *> computerplayers_; |
3035 | }; |
3036 | |
3037 | #endif // end of include guard: WL_LOGIC_SINGLE_PLAYER_GAME_CONTROLLER_H |
3038 | |
3039 | === modified file 'src/map_io/map_buildingdata_packet.cc' |
3040 | --- src/map_io/map_buildingdata_packet.cc 2016-02-17 16:20:45 +0000 |
3041 | +++ src/map_io/map_buildingdata_packet.cc 2016-03-02 14:42:23 +0000 |
3042 | @@ -477,7 +477,7 @@ |
3043 | Area<FCoords> a |
3044 | (map.get_fcoords(warehouse.get_position()), conquer_radius); |
3045 | const Field & first_map_field = map[0]; |
3046 | - Player::Field * const player_fields = player.m_fields; |
3047 | + Player::Field * const player_fields = player.fields_; |
3048 | MapRegion<Area<FCoords> > mr(map, a); |
3049 | do |
3050 | player_fields[mr.location().field - &first_map_field] |
3051 | @@ -547,7 +547,7 @@ |
3052 | militarysite.descr().get_conquers()); |
3053 | const Field & first_map_field = map[0]; |
3054 | Player::Field * const player_fields = |
3055 | - militarysite.owner().m_fields; |
3056 | + militarysite.owner().fields_; |
3057 | MapRegion<Area<FCoords> > mr(map, a); |
3058 | do |
3059 | player_fields[mr.location().field - &first_map_field] |
3060 | |
3061 | === modified file 'src/map_io/map_exploration_packet.cc' |
3062 | --- src/map_io/map_exploration_packet.cc 2015-10-24 15:42:37 +0000 |
3063 | +++ src/map_io/map_exploration_packet.cc 2016-03-02 14:42:23 +0000 |
3064 | @@ -64,7 +64,7 @@ |
3065 | for (uint8_t j = 0; j < nr_players; ++j) { |
3066 | bool see = data & (1 << j); |
3067 | if (Player * const player = egbase.get_player(j + 1)) |
3068 | - player->m_fields[i].vision = see ? 1 : 0; |
3069 | + player->fields_[i].vision = see ? 1 : 0; |
3070 | else if (see) |
3071 | log |
3072 | ("MapExplorationPacket::read: WARNING: Player %u, " |
3073 | |
3074 | === modified file 'src/map_io/map_players_view_packet.cc' |
3075 | --- src/map_io/map_players_view_packet.cc 2016-01-18 19:35:25 +0000 |
3076 | +++ src/map_io/map_players_view_packet.cc 2016-03-02 14:42:23 +0000 |
3077 | @@ -305,7 +305,7 @@ |
3078 | Field & first_field = map[0]; |
3079 | const PlayerNumber nr_players = map.get_nrplayers(); |
3080 | iterate_players_existing_const(plnum, nr_players, egbase, player) { |
3081 | - Player::Field * const player_fields = player->m_fields; |
3082 | + Player::Field * const player_fields = player->fields_; |
3083 | uint32_t const gametime = egbase.get_gametime(); |
3084 | |
3085 | char unseen_times_filename[FILENAME_SIZE]; |
3086 | @@ -903,7 +903,7 @@ |
3087 | Field & first_field = map[0]; |
3088 | const PlayerNumber nr_players = map.get_nrplayers(); |
3089 | iterate_players_existing_const(plnum, nr_players, egbase, player) |
3090 | - if (const Player::Field * const player_fields = player->m_fields) { |
3091 | + if (const Player::Field * const player_fields = player->fields_) { |
3092 | FileWrite unseen_times_file; |
3093 | FileWrite node_immovable_kinds_file; |
3094 | FileWrite node_immovables_file; |
Played this for seom 40 Minutes now, had no Problems whatsoever