widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #05962
[Merge] lp:~widelands-dev/widelands/bug-1395278-map_objects into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1395278-map_objects into lp:widelands.
Commit message:
Fixed member variables in src/logic/map_objects, but not in its subdirectories.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1395278-map_objects/+merge/285290
Fixed member variables in src/logic/map_objects, but not in its subdirectories - I will refactor those separately.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1395278-map_objects into lp:widelands.
=== modified file 'src/economy/ware_instance.cc'
--- src/economy/ware_instance.cc 2016-01-17 09:54:31 +0000
+++ src/economy/ware_instance.cc 2016-02-07 09:53:38 +0000
@@ -311,7 +311,7 @@
*/
void WareInstance::update(Game & game)
{
- if (!m_descr) // Upsy, we're not even initialized. Happens on load
+ if (!descr_) // Upsy, we're not even initialized. Happens on load
return;
MapObject * const loc = m_location.get(game);
@@ -435,7 +435,7 @@
throw wexception
("MO(%u): ware(%s): do not know how to move from building %u (%s at (%u,%u)) "
"to %u (%s) -> not a warehouse!",
- serial(), m_descr->name().c_str(), building.serial(),
+ serial(), descr_->name().c_str(), building.serial(),
building.descr().name().c_str(), building.get_position().x,
building.get_position().y, nextstep->serial(),
nextstep->descr().name().c_str());
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2016-02-05 20:07:10 +0000
+++ src/logic/map.cc 2016-02-07 09:53:38 +0000
@@ -372,15 +372,15 @@
for (c.x = 0; c.x < m_width; ++c.x, ++c.field) {
assert(c.field == &operator[] (c));
if (upcast(Immovable, immovable, c.field->get_immovable()))
- immovable->m_position = c;
+ immovable->position_ = c;
for
(Bob * bob = c.field->get_first_bob();
bob;
bob = bob->get_next_bob())
{
- bob->m_position.x = c.x;
- bob->m_position.y = c.y;
- bob->m_position.field = c.field;
+ bob->position_.x = c.x;
+ bob->position_.y = c.y;
+ bob->position_.field = c.field;
}
}
=== modified file 'src/logic/map_objects/bob.cc'
--- src/logic/map_objects/bob.cc 2016-01-23 12:42:00 +0000
+++ src/logic/map_objects/bob.cc 2016-02-07 09:53:38 +0000
@@ -95,18 +95,18 @@
Bob::Bob(const BobDescr & _descr) :
MapObject (&_descr),
-m_owner (nullptr),
-m_position (FCoords(Coords(0, 0), nullptr)), // not linked anywhere
-m_linknext (nullptr),
-m_linkpprev (nullptr),
-m_anim (0),
-m_animstart (0),
-m_walking (IDLE),
-m_walkstart (0),
-m_walkend (0),
-m_actid (0),
-m_actscheduled (false),
-m_in_act (false)
+owner_ (nullptr),
+position_ (FCoords(Coords(0, 0), nullptr)), // not linked anywhere
+linknext_ (nullptr),
+linkpprev_ (nullptr),
+anim_ (0),
+animstart_ (0),
+walking_ (IDLE),
+walkstart_ (0),
+walkend_ (0),
+actid_ (0),
+actscheduled_ (false),
+in_act_ (false)
{}
@@ -115,9 +115,9 @@
*/
Bob::~Bob()
{
- if (m_position.field) {
+ if (position_.field) {
molog
- ("MapObject::~MapObject: m_pos.field != 0, cleanup() not "
+ ("MapObject::~MapObject: pos_.field != 0, cleanup() not "
"called!\n");
abort();
}
@@ -146,17 +146,17 @@
*/
void Bob::cleanup(EditorGameBase & egbase)
{
- while (!m_stack.empty()) { // bobs in the editor do not have tasks
+ while (!stack_.empty()) { // bobs in the editor do not have tasks
do_pop_task(dynamic_cast<Game&>(egbase));
}
set_owner(nullptr); // implicitly remove ourselves from owner's map
- if (m_position.field) {
- m_position.field = nullptr;
- *m_linkpprev = m_linknext;
- if (m_linknext)
- m_linknext->m_linkpprev = m_linkpprev;
+ if (position_.field) {
+ position_.field = nullptr;
+ *linkpprev_ = linknext_;
+ if (linknext_)
+ linknext_->linkpprev_ = linkpprev_;
}
MapObject::cleanup(egbase);
@@ -174,20 +174,20 @@
// Eliminate spurious calls of act().
// These calls are to be expected and perfectly normal, e.g. when a carrier's
// idle task is interrupted by the request to pick up a ware from a flag.
- if (data != m_actid)
+ if (data != actid_)
return;
- ++m_actid;
- m_actscheduled = false;
+ ++actid_;
+ actscheduled_ = false;
- if (m_stack.empty()) {
- m_signal = "";
+ if (stack_.empty()) {
+ signal_ = "";
init_auto_task(game);
- if (m_stack.empty())
+ if (stack_.empty())
throw wexception
("MO(%u): init_auto_task() failed to set a task", serial());
- if (!m_actscheduled)
+ if (!actscheduled_)
throw wexception
("MO(%u): init_auto_task() failed to schedule something", serial());
@@ -203,20 +203,20 @@
*/
void Bob::do_act(Game & game)
{
- assert(!m_in_act);
- assert(m_stack.size());
+ assert(!in_act_);
+ assert(stack_.size());
- m_in_act = true;
+ in_act_ = true;
const Task & task = *top_state().task;
(this->*task.update)(game, top_state());
- if (!m_actscheduled)
+ if (!actscheduled_)
throw wexception
("MO(%u): update[%s] failed to act", serial(), task.name);
- m_in_act = false;
+ in_act_ = false;
}
@@ -226,8 +226,8 @@
void Bob::schedule_destroy(Game & game)
{
MapObject::schedule_destroy(game);
- ++m_actid; // to skip over any updates that may be scheduled
- m_actscheduled = true;
+ ++actid_; // to skip over any updates that may be scheduled
+ actscheduled_ = true;
}
@@ -237,8 +237,8 @@
*/
void Bob::schedule_act(Game & game, uint32_t tdelta)
{
- MapObject::schedule_act(game, tdelta, m_actid);
- m_actscheduled = true;
+ MapObject::schedule_act(game, tdelta, actid_);
+ actscheduled_ = true;
}
@@ -247,9 +247,9 @@
*/
void Bob::skip_act()
{
- assert(m_in_act);
+ assert(in_act_);
- m_actscheduled = true;
+ actscheduled_ = true;
}
@@ -262,9 +262,9 @@
void Bob::push_task(Game & game, const Task & task, uint32_t const tdelta)
{
assert(!task.unique || !get_state(task));
- assert(m_in_act || m_stack.empty());
+ assert(in_act_ || stack_.empty());
- m_stack.push_back(State(&task));
+ stack_.push_back(State(&task));
schedule_act(game, tdelta);
}
@@ -282,7 +282,7 @@
delete state.path;
delete state.route;
- m_stack.pop_back();
+ stack_.pop_back();
}
@@ -294,7 +294,7 @@
*/
void Bob::pop_task(Game & game)
{
- assert(m_in_act);
+ assert(in_act_);
do_pop_task(game);
@@ -308,9 +308,9 @@
*/
Bob::State * Bob::get_state(const Task & task)
{
- std::vector<State>::iterator it = m_stack.end();
+ std::vector<State>::iterator it = stack_.end();
- while (it != m_stack.begin()) {
+ while (it != stack_.begin()) {
--it;
if (it->task == &task)
@@ -322,9 +322,9 @@
Bob::State const * Bob::get_state(const Task & task) const
{
- std::vector<State>::const_iterator it = m_stack.end();
+ std::vector<State>::const_iterator it = stack_.end();
- while (it != m_stack.begin()) {
+ while (it != stack_.begin()) {
--it;
if (it->task == &task)
@@ -340,9 +340,9 @@
*/
void Bob::signal_handled()
{
- assert(m_in_act);
+ assert(in_act_);
- m_signal.clear();
+ signal_.clear();
}
/**
@@ -361,14 +361,14 @@
{
assert(*sig); // use set_signal() for signal removal
- for (uint32_t i = 0; i < m_stack.size(); ++i) {
- State & state = m_stack[i];
+ for (uint32_t i = 0; i < stack_.size(); ++i) {
+ State & state = stack_[i];
if (state.task->signal_immediate)
(this->*state.task->signal_immediate)(game, state, sig);
}
- m_signal = sig;
+ signal_ = sig;
schedule_act(game, 10);
}
@@ -381,12 +381,12 @@
*/
void Bob::reset_tasks(Game & game)
{
- while (!m_stack.empty())
+ while (!stack_.empty())
do_pop_task(game);
- m_signal.clear();
+ signal_.clear();
- ++m_actid;
+ ++actid_;
schedule_act(game, 10);
}
@@ -476,32 +476,32 @@
using Cache = std::map<CoordData, bool, CoordOrdering>;
BlockedTracker(Game & game, Bob & bob, const Coords & finaldest)
- : m_game(game), m_bob(bob), m_map(game.map()), m_finaldest(finaldest)
+ : game_(game), bob_(bob), map_(game.map()), finaldest_(finaldest)
{
- nrblocked = 0;
- disabled = false;
+ nrblocked_ = 0;
+ disabled_ = false;
}
// This heuristic tries to unblock fields that are close to the destination,
// in the hope that subsequent pathfinding will find a way to bring us
// closer, if not complete to, the destination
void unblock() {
- uint32_t origblocked = nrblocked;
- int unblockprob = nrblocked;
+ uint32_t origblocked = nrblocked_;
+ int unblockprob = nrblocked_;
for
- (Cache::iterator it = nodes.begin();
- it != nodes.end() && unblockprob > 0;
+ (Cache::iterator it = nodes_.begin();
+ it != nodes_.end() && unblockprob > 0;
++it)
{
if (it->second) {
if
- (static_cast<int32_t>(m_game.logic_rand() % origblocked)
+ (static_cast<int32_t>(game_.logic_rand() % origblocked)
<
unblockprob)
{
it->second = false;
- --nrblocked;
+ --nrblocked_;
unblockprob -= 2;
}
}
@@ -509,46 +509,46 @@
}
bool is_blocked(const FCoords & field) {
- if (disabled)
+ if (disabled_)
return false;
CoordData cd;
cd.coord = field;
- cd.dist = m_map.calc_distance(field, m_finaldest);
+ cd.dist = map_.calc_distance(field, finaldest_);
- Cache::iterator it = nodes.find(cd);
- if (it != nodes.end())
+ Cache::iterator it = nodes_.find(cd);
+ if (it != nodes_.end())
return it->second;
- bool const blocked = m_bob.check_node_blocked(m_game, field, false);
- nodes.insert(std::make_pair(cd, blocked));
+ bool const blocked = bob_.check_node_blocked(game_, field, false);
+ nodes_.insert(std::make_pair(cd, blocked));
if (blocked)
- ++nrblocked;
+ ++nrblocked_;
return blocked;
}
- Game & m_game;
- Bob & m_bob;
- Map & m_map;
- Coords m_finaldest;
- Cache nodes;
- int nrblocked;
- bool disabled;
+ Game & game_;
+ Bob & bob_;
+ Map & map_;
+ Coords finaldest_;
+ Cache nodes_;
+ int nrblocked_;
+ bool disabled_;
};
struct CheckStepBlocked {
- CheckStepBlocked(BlockedTracker & tracker) : m_tracker(tracker) {}
+ CheckStepBlocked(BlockedTracker & tracker) : tracker_(tracker) {}
bool allowed(Map &, FCoords, FCoords end, int32_t, CheckStep::StepId) const
{
- if (end == m_tracker.m_finaldest)
+ if (end == tracker_.finaldest_)
return true;
- return !m_tracker.is_blocked(end);
+ return !tracker_.is_blocked(end);
}
bool reachable_dest(Map &, FCoords) const {return true;}
- BlockedTracker & m_tracker;
+ BlockedTracker & tracker_;
};
/**
@@ -582,20 +582,20 @@
cstep.add(CheckStepBlocked(tracker));
if (forceall)
- tracker.disabled = true;
+ tracker.disabled_ = true;
Map & map = game.map();
- if (map.findpath(m_position, dest, persist, path, cstep) < 0) {
- if (!tracker.nrblocked)
+ if (map.findpath(position_, dest, persist, path, cstep) < 0) {
+ if (!tracker.nrblocked_)
return false;
tracker.unblock();
- if (map.findpath(m_position, dest, persist, path, cstep) < 0) {
- if (!tracker.nrblocked)
+ if (map.findpath(position_, dest, persist, path, cstep) < 0) {
+ if (!tracker.nrblocked_)
return false;
- tracker.disabled = true;
- if (map.findpath(m_position, dest, persist, path, cstep) < 0)
+ tracker.disabled_ = true;
+ if (map.findpath(position_, dest, persist, path, cstep) < 0)
return false;
}
}
@@ -699,7 +699,7 @@
>=
path->get_nsteps())
{
- assert(m_position == path->get_end());
+ assert(position_ == path->get_end());
return pop_task(game); // success
} else if (state.ivar1 == state.ivar3)
// We have stepped all steps that we were asked for.
@@ -762,29 +762,29 @@
void Bob::move_update(Game & game, State &)
{
- if (static_cast<uint32_t>(m_walkend) <= game.get_gametime()) {
+ if (static_cast<uint32_t>(walkend_) <= game.get_gametime()) {
end_walk();
return pop_task(game);
} else
// Only end the task once we've actually completed the step
// Ignore signals until then
- return schedule_act(game, m_walkend - game.get_gametime());
+ return schedule_act(game, walkend_ - game.get_gametime());
}
/// Calculates the actual position to draw on from the base node position.
/// This function takes walking etc. into account.
///
-/// pos is the location, in pixels, of the node m_position (height is already
+/// pos is the location, in pixels, of the node position_ (height is already
/// taken into account).
Point Bob::calc_drawpos(const EditorGameBase & game, const Point pos) const
{
const Map & map = game.get_map();
- const FCoords end = m_position;
+ const FCoords end = position_;
FCoords start;
Point spos = pos, epos = pos;
- switch (m_walking) {
+ switch (walking_) {
case WALK_NW:
map.get_brn(end, &start);
spos.x += TRIANGLE_WIDTH / 2;
@@ -823,12 +823,12 @@
spos.y += end.field->get_height() * HEIGHT_FACTOR;
spos.y -= start.field->get_height() * HEIGHT_FACTOR;
- assert(static_cast<uint32_t>(m_walkstart) <= game.get_gametime());
- assert(m_walkstart < m_walkend);
+ assert(static_cast<uint32_t>(walkstart_) <= game.get_gametime());
+ assert(walkstart_ < walkend_);
float f =
- static_cast<float>(game.get_gametime() - m_walkstart)
+ static_cast<float>(game.get_gametime() - walkstart_)
/
- (m_walkend - m_walkstart);
+ (walkend_ - walkstart_);
if (f < 0)
f = 0;
@@ -849,13 +849,13 @@
void Bob::draw
(const EditorGameBase & egbase, RenderTarget & dst, const Point& pos) const
{
- if (m_anim) {
+ if (anim_) {
auto* const owner = get_owner();
if (owner != nullptr) {
- dst.blit_animation(calc_drawpos(egbase, pos), m_anim, egbase.get_gametime() - m_animstart,
+ dst.blit_animation(calc_drawpos(egbase, pos), anim_, egbase.get_gametime() - animstart_,
owner->get_playercolor());
} else {
- dst.blit_animation(calc_drawpos(egbase, pos), m_anim, egbase.get_gametime() - m_animstart);
+ dst.blit_animation(calc_drawpos(egbase, pos), anim_, egbase.get_gametime() - animstart_);
}
}
}
@@ -866,8 +866,8 @@
*/
void Bob::set_animation(EditorGameBase & egbase, uint32_t const anim)
{
- m_anim = anim;
- m_animstart = egbase.get_gametime();
+ anim_ = anim;
+ animstart_ = egbase.get_gametime();
}
@@ -885,13 +885,13 @@
FCoords newnode;
Map & map = game.map();
- map.get_neighbour(m_position, dir, &newnode);
+ map.get_neighbour(position_, dir, &newnode);
// Move capability check
if (!force) {
CheckStepDefault cstep(descr().movecaps());
- if (!cstep.allowed(map, m_position, newnode, dir, CheckStep::stepNormal))
+ if (!cstep.allowed(map, position_, newnode, dir, CheckStep::stepNormal))
return -1;
}
@@ -901,12 +901,12 @@
return -2;
// Move is go
- int32_t const tdelta = map.calc_cost(m_position, dir);
+ int32_t const tdelta = map.calc_cost(position_, dir);
assert(tdelta);
- m_walking = dir;
- m_walkstart = game.get_gametime();
- m_walkend = m_walkstart + tdelta;
+ walking_ = dir;
+ walkstart_ = game.get_gametime();
+ walkend_ = walkstart_ + tdelta;
set_position(game, newnode);
set_animation(game, a);
@@ -941,13 +941,13 @@
*/
void Bob::set_owner(Player * const player)
{
- if (m_owner && m_position.field)
- m_owner->unsee_area(Area<FCoords>(get_position(), descr().vision_range()));
-
- m_owner = player;
-
- if (m_owner != nullptr && m_position.field)
- m_owner->see_area(Area<FCoords>(get_position(), descr().vision_range()));
+ if (owner_ && position_.field)
+ owner_->unsee_area(Area<FCoords>(get_position(), descr().vision_range()));
+
+ owner_ = player;
+
+ if (owner_ != nullptr && position_.field)
+ owner_->see_area(Area<FCoords>(get_position(), descr().vision_range()));
}
@@ -959,27 +959,27 @@
*/
void Bob::set_position(EditorGameBase & egbase, const Coords & coords)
{
- FCoords oldposition = m_position;
+ FCoords oldposition = position_;
- if (m_position.field) {
- *m_linkpprev = m_linknext;
- if (m_linknext)
- m_linknext->m_linkpprev = m_linkpprev;
+ if (position_.field) {
+ *linkpprev_ = linknext_;
+ if (linknext_)
+ linknext_->linkpprev_ = linkpprev_;
}
- m_position = egbase.map().get_fcoords(coords);
-
- m_linknext = m_position.field->bobs;
- m_linkpprev = &m_position.field->bobs;
- if (m_linknext)
- m_linknext->m_linkpprev = &m_linknext;
- *m_linkpprev = this;
-
- if (m_owner != nullptr) {
- m_owner->see_area(Area<FCoords>(get_position(), descr().vision_range()));
+ position_ = egbase.map().get_fcoords(coords);
+
+ linknext_ = position_.field->bobs;
+ linkpprev_ = &position_.field->bobs;
+ if (linknext_)
+ linknext_->linkpprev_ = &linknext_;
+ *linkpprev_ = this;
+
+ if (owner_ != nullptr) {
+ owner_->see_area(Area<FCoords>(get_position(), descr().vision_range()));
if (oldposition.field)
- m_owner->unsee_area(Area<FCoords>(oldposition, descr().vision_range()));
+ owner_->unsee_area(Area<FCoords>(oldposition, descr().vision_range()));
}
// Since pretty much everything in Widelands eventually results in the
@@ -1000,46 +1000,46 @@
/// Give debug information.
void Bob::log_general_info(const EditorGameBase & egbase)
{
- molog("Owner: %p\n", m_owner);
- molog("Postition: (%i, %i)\n", m_position.x, m_position.y);
- molog("ActID: %i\n", m_actid);
- molog("ActScheduled: %s\n", m_actscheduled ? "true" : "false");
+ molog("Owner: %p\n", owner_);
+ molog("Postition: (%i, %i)\n", position_.x, position_.y);
+ molog("ActID: %i\n", actid_);
+ molog("ActScheduled: %s\n", actscheduled_ ? "true" : "false");
molog
("Animation: %s\n",
- m_anim ? descr().get_animation_name(m_anim).c_str() : "\\<none\\>");
-
- molog("AnimStart: %i\n", m_animstart);
- molog("WalkingDir: %i\n", m_walking);
- molog("WalkingStart: %i\n", m_walkstart);
- molog("WalkEnd: %i\n", m_walkend);
-
- molog("Signal: %s\n", m_signal.c_str());
-
- molog("Stack size: %lu\n", static_cast<long unsigned int>(m_stack.size()));
-
- for (size_t i = 0; i < m_stack.size(); ++i) {
+ anim_ ? descr().get_animation_name(anim_).c_str() : "\\<none\\>");
+
+ molog("AnimStart: %i\n", animstart_);
+ molog("WalkingDir: %i\n", walking_);
+ molog("WalkingStart: %i\n", walkstart_);
+ molog("WalkEnd: %i\n", walkend_);
+
+ molog("Signal: %s\n", signal_.c_str());
+
+ molog("Stack size: %lu\n", static_cast<long unsigned int>(stack_.size()));
+
+ for (size_t i = 0; i < stack_.size(); ++i) {
molog
("Stack dump %lu/%lu\n",
static_cast<long unsigned int>(i + 1),
- static_cast<long unsigned int>(m_stack.size()));
-
- molog("* task->name: %s\n", m_stack[i].task->name);
-
- molog("* ivar1: %i\n", m_stack[i].ivar1);
- molog("* ivar2: %i\n", m_stack[i].ivar2);
- molog("* ivar3: %i\n", m_stack[i].ivar3);
-
- molog("* object pointer: %p\n", m_stack[i].objvar1.get(egbase));
- molog("* svar1: %s\n", m_stack[i].svar1.c_str());
-
- molog("* coords: (%i, %i)\n", m_stack[i].coords.x, m_stack[i].coords.y);
+ static_cast<long unsigned int>(stack_.size()));
+
+ molog("* task->name: %s\n", stack_[i].task->name);
+
+ molog("* ivar1: %i\n", stack_[i].ivar1);
+ molog("* ivar2: %i\n", stack_[i].ivar2);
+ molog("* ivar3: %i\n", stack_[i].ivar3);
+
+ molog("* object pointer: %p\n", stack_[i].objvar1.get(egbase));
+ molog("* svar1: %s\n", stack_[i].svar1.c_str());
+
+ molog("* coords: (%i, %i)\n", stack_[i].coords.x, stack_[i].coords.y);
molog("* diranims:");
for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) {
- molog(" %d", m_stack[i].diranims.get_animation(dir));
+ molog(" %d", stack_[i].diranims.get_animation(dir));
}
- molog("\n* path: %p\n", m_stack[i].path);
- if (m_stack[i].path) {
- const Path & path = *m_stack[i].path;
+ molog("\n* path: %p\n", stack_[i].path);
+ if (stack_[i].path) {
+ const Path & path = *stack_[i].path;
Path::StepVector::size_type nr_steps = path.get_nsteps();
molog
("** Path length: %lu\n",
@@ -1052,9 +1052,9 @@
static_cast<long unsigned int>(j + 1),
static_cast<long unsigned int>(nr_steps), path[j]);
}
- molog("* route: %p\n", m_stack[i].route);
+ molog("* route: %p\n", stack_[i].route);
- molog("* program: %p\n", m_stack[i].route);
+ molog("* program: %p\n", stack_[i].route);
}
}
@@ -1099,22 +1099,22 @@
bob.set_position(egbase(), read_coords_32(&fr));
std::string animname = fr.c_string();
- bob.m_anim = animname.size() ? bob.descr().get_animation(animname) : 0;
- bob.m_animstart = fr.signed_32();
- bob.m_walking = static_cast<WalkingDir>(read_direction_8_allow_null(&fr));
- if (bob.m_walking) {
- bob.m_walkstart = fr.signed_32();
- bob.m_walkend = fr.signed_32();
+ bob.anim_ = animname.size() ? bob.descr().get_animation(animname) : 0;
+ bob.animstart_ = fr.signed_32();
+ bob.walking_ = static_cast<WalkingDir>(read_direction_8_allow_null(&fr));
+ if (bob.walking_) {
+ bob.walkstart_ = fr.signed_32();
+ bob.walkend_ = fr.signed_32();
}
- bob.m_actid = fr.unsigned_32();
- bob.m_signal = fr.c_string();
+ bob.actid_ = fr.unsigned_32();
+ bob.signal_ = fr.c_string();
uint32_t stacksize = fr.unsigned_32();
- bob.m_stack.resize(stacksize);
+ bob.stack_.resize(stacksize);
states.resize(stacksize);
for (uint32_t i = 0; i < stacksize; ++i) {
- State & state = bob.m_stack[i];
+ State & state = bob.stack_[i];
LoadState & loadstate = states[i];
state.task = get_task(fr.c_string());
@@ -1159,8 +1159,8 @@
MapObject::Loader::load_pointers();
Bob & bob = get<Bob>();
- for (uint32_t i = 0; i < bob.m_stack.size(); ++i) {
- State & state = bob.m_stack[i];
+ for (uint32_t i = 0; i < bob.stack_.size(); ++i) {
+ State & state = bob.stack_[i];
LoadState & loadstate = states[i];
if (loadstate.objvar1)
@@ -1180,7 +1180,7 @@
// See bug #537392 for more information:
// https://bugs.launchpad.net/widelands/+bug/537392
Bob & bob = get<Bob>();
- if (bob.m_stack.empty() && !egbase().get_gametime())
+ if (bob.stack_.empty() && !egbase().get_gametime())
if (upcast(Game, game, &egbase())) {
bob.init_auto_task(*game);
}
@@ -1208,25 +1208,25 @@
fw.unsigned_8(kCurrentPacketVersion);
- fw.unsigned_8(m_owner ? m_owner->player_number() : 0);
- write_coords_32(&fw, m_position);
-
- // m_linkpprev and m_linknext are recreated automatically
-
- fw.c_string(m_anim ? descr().get_animation_name(m_anim) : "");
- fw.signed_32(m_animstart);
- write_direction_8_allow_null(&fw, m_walking);
- if (m_walking) {
- fw.signed_32(m_walkstart);
- fw.signed_32(m_walkend);
+ fw.unsigned_8(owner_ ? owner_->player_number() : 0);
+ write_coords_32(&fw, position_);
+
+ // linkprev_ and linknext_ are recreated automatically
+
+ fw.c_string(anim_ ? descr().get_animation_name(anim_) : "");
+ fw.signed_32(animstart_);
+ write_direction_8_allow_null(&fw, walking_);
+ if (walking_) {
+ fw.signed_32(walkstart_);
+ fw.signed_32(walkend_);
}
- fw.unsigned_32(m_actid);
- fw.c_string(m_signal);
+ fw.unsigned_32(actid_);
+ fw.c_string(signal_);
- fw.unsigned_32(m_stack.size());
- for (unsigned int i = 0; i < m_stack.size(); ++i) {
- const State & state = m_stack[i];
+ fw.unsigned_32(stack_.size());
+ for (unsigned int i = 0; i < stack_.size(); ++i) {
+ const State & state = stack_[i];
fw.c_string(state.task->name);
fw.signed_32(state.ivar1);
=== modified file 'src/logic/map_objects/bob.h'
--- src/logic/map_objects/bob.h 2016-01-08 21:00:39 +0000
+++ src/logic/map_objects/bob.h 2016-02-07 09:53:38 +0000
@@ -226,8 +226,8 @@
MO_DESCR(BobDescr)
- uint32_t get_current_anim() const {return m_anim;}
- int32_t get_animstart() const {return m_animstart;}
+ uint32_t get_current_anim() const {return anim_;}
+ int32_t get_animstart() const {return animstart_;}
void init(EditorGameBase &) override;
void cleanup(EditorGameBase &) override;
@@ -237,10 +237,10 @@
void skip_act();
Point calc_drawpos(const EditorGameBase &, Point) const;
void set_owner(Player *);
- Player * get_owner() const {return m_owner;}
+ Player * get_owner() const {return owner_;}
void set_position(EditorGameBase &, const Coords &);
- const FCoords & get_position() const {return m_position;}
- Bob * get_next_bob() const {return m_linknext;}
+ const FCoords & get_position() const {return position_;}
+ Bob * get_next_bob() const {return linknext_;}
/// Check whether this bob should be able to move onto the given node.
///
@@ -297,11 +297,11 @@
void start_task_move(Game & game, int32_t dir, const DirAnimations &, bool);
// higher level handling (task-based)
- State & top_state() {assert(m_stack.size()); return *m_stack.rbegin();}
- State * get_state() {return m_stack.size() ? &*m_stack.rbegin() : nullptr;}
-
-
- std::string get_signal() {return m_signal;}
+ State & top_state() {assert(stack_.size()); return *stack_.rbegin();}
+ State * get_state() {return stack_.size() ? &*stack_.rbegin() : nullptr;}
+
+
+ std::string get_signal() {return signal_;}
State * get_state(const Task &);
State const * get_state(const Task &) const;
void push_task(Game & game, const Task & task, uint32_t tdelta = 10);
@@ -316,7 +316,7 @@
void set_animation(EditorGameBase &, uint32_t anim);
/// \return true if we're currently walking
- bool is_walking() {return m_walking != IDLE;}
+ bool is_walking() {return walking_ != IDLE;}
/**
@@ -324,7 +324,7 @@
* It is only introduced here because profiling showed
* that soldiers spend a lot of time in the node blocked check.
*/
- Bob * get_next_on_field() const {return m_linknext;}
+ Bob * get_next_on_field() const {return linknext_;}
protected:
Bob(const BobDescr & descr);
@@ -344,25 +344,25 @@
* Call this from your task_act() function that was scheduled after
* start_walk().
*/
- void end_walk() {m_walking = IDLE;}
+ void end_walk() {walking_ = IDLE;}
static Task const taskIdle;
static Task const taskMovepath;
static Task const taskMove;
- Player * m_owner; ///< can be 0
- FCoords m_position; ///< where are we right now?
- Bob * m_linknext; ///< next object on this node
- Bob * * m_linkpprev;
- uint32_t m_anim;
- int32_t m_animstart; ///< gametime when the animation was started
- WalkingDir m_walking;
- int32_t m_walkstart; ///< start time (used for interpolation)
- int32_t m_walkend; ///< end time (used for interpolation)
+ Player * owner_; ///< can be 0
+ FCoords position_; ///< where are we right now?
+ Bob * linknext_; ///< next object on this node
+ Bob * * linkpprev_;
+ uint32_t anim_;
+ int32_t animstart_; ///< gametime when the animation was started
+ WalkingDir walking_;
+ int32_t walkstart_; ///< start time (used for interpolation)
+ int32_t walkend_; ///< end time (used for interpolation)
// Task framework variables
- std::vector<State> m_stack;
+ std::vector<State> stack_;
/**
* Every time a Bob acts, this counter is incremented.
@@ -371,7 +371,7 @@
* only the earliest \ref Cmd_Act issued during one act phase is actually
* executed. Subsequent \ref Cmd_Act could interfere and are eliminated.
*/
- uint32_t m_actid;
+ uint32_t actid_;
/**
* Whether something was scheduled during this act phase.
@@ -380,9 +380,9 @@
* Bobs that hang themselves up. So e.g. \ref skip_act() also sets this
* to \c true, even though it technically doesn't schedule anything.
*/
- bool m_actscheduled;
- bool m_in_act; ///< if do_act is currently running
- std::string m_signal;
+ bool actscheduled_;
+ bool in_act_; ///< if do_act is currently running
+ std::string signal_;
// saving and loading
protected:
=== modified file 'src/logic/map_objects/checkstep.cc'
--- src/logic/map_objects/checkstep.cc 2015-11-28 22:29:26 +0000
+++ src/logic/map_objects/checkstep.cc 2016-02-07 09:53:38 +0000
@@ -91,13 +91,13 @@
{
NodeCaps const endcaps = end.field->nodecaps();
- if (endcaps & m_movecaps)
+ if (endcaps & movecaps_)
return true;
// Swimming bobs are allowed to move from a water field to a shore field
NodeCaps const startcaps = start.field->nodecaps();
- if ((endcaps & MOVECAPS_WALK) && (startcaps & m_movecaps & MOVECAPS_SWIM))
+ if ((endcaps & MOVECAPS_WALK) && (startcaps & movecaps_ & MOVECAPS_SWIM))
return true;
return false;
@@ -107,8 +107,8 @@
{
NodeCaps const caps = dest.field->nodecaps();
- if (!(caps & m_movecaps)) {
- if (!((m_movecaps & MOVECAPS_SWIM) && (caps & MOVECAPS_WALK)))
+ if (!(caps & movecaps_)) {
+ if (!((movecaps_ & MOVECAPS_SWIM) && (caps & MOVECAPS_WALK)))
return false;
if (!map.can_reach_by_water(dest))
@@ -137,19 +137,19 @@
// Make sure to not find paths where we walk onto an unwalkable node, then
// then back onto a walkable node.
- if (!m_onlyend && id != CheckStep::stepFirst && !(startcaps & m_movecaps))
+ if (!onlyend_ && id != CheckStep::stepFirst && !(startcaps & movecaps_))
return false;
- if (endcaps & m_movecaps)
+ if (endcaps & movecaps_)
return true;
// We can't move onto the node using normal rules.
// If onlyend is true, exception rules only apply for the last step.
- if (m_onlyend && id != CheckStep::stepLast)
+ if (onlyend_ && id != CheckStep::stepLast)
return false;
// If the previous field was walkable, we can move onto this one
- if (startcaps & m_movecaps)
+ if (startcaps & movecaps_)
return true;
return false;
@@ -166,16 +166,16 @@
CheckStep::StepId const id)
const
{
- uint8_t const endcaps = m_player.get_buildcaps(end);
+ uint8_t const endcaps = player_.get_buildcaps(end);
// Calculate cost and passability
if
- (!(endcaps & m_movecaps)
+ (!(endcaps & movecaps_)
&&
!
((endcaps & MOVECAPS_WALK)
&&
- (m_player.get_buildcaps(start) & m_movecaps & MOVECAPS_SWIM)))
+ (player_.get_buildcaps(start) & movecaps_ & MOVECAPS_SWIM)))
return false;
// Check for blocking immovables
@@ -197,8 +197,8 @@
{
NodeCaps const caps = dest.field->nodecaps();
- if (!(caps & m_movecaps)) {
- if (!((m_movecaps & MOVECAPS_SWIM) && (caps & MOVECAPS_WALK)))
+ if (!(caps & movecaps_)) {
+ if (!((movecaps_ & MOVECAPS_SWIM) && (caps & MOVECAPS_WALK)))
return false;
if (!map.can_reach_by_water(dest))
@@ -212,7 +212,7 @@
bool CheckStepLimited::allowed
(Map &, FCoords, FCoords const end, int32_t, CheckStep::StepId) const
{
- return m_allowed_locations.find(end) != m_allowed_locations.end();
+ return allowed_locations_.find(end) != allowed_locations_.end();
}
bool CheckStepLimited::reachable_dest(Map &, FCoords) const {
=== modified file 'src/logic/map_objects/checkstep.h'
--- src/logic/map_objects/checkstep.h 2015-11-28 22:29:26 +0000
+++ src/logic/map_objects/checkstep.h 2016-02-07 09:53:38 +0000
@@ -128,7 +128,7 @@
* bobs moving onto the shore).
*/
struct CheckStepDefault {
- CheckStepDefault(uint8_t const movecaps) : m_movecaps(movecaps) {}
+ CheckStepDefault(uint8_t const movecaps) : movecaps_(movecaps) {}
bool allowed
(Map &, FCoords start, FCoords end, int32_t dir, CheckStep::StepId)
@@ -136,7 +136,7 @@
bool reachable_dest(Map &, FCoords dest) const;
private:
- uint8_t m_movecaps;
+ uint8_t movecaps_;
};
@@ -147,7 +147,7 @@
*/
struct CheckStepWalkOn {
CheckStepWalkOn(uint8_t const movecaps, bool const onlyend) :
- m_movecaps(movecaps), m_onlyend(onlyend) {}
+ movecaps_(movecaps), onlyend_(onlyend) {}
bool allowed
(Map &, FCoords start, FCoords end, int32_t dir, CheckStep::StepId)
@@ -155,8 +155,8 @@
bool reachable_dest(Map &, FCoords dest) const;
private:
- uint8_t m_movecaps;
- bool m_onlyend;
+ uint8_t movecaps_;
+ bool onlyend_;
};
@@ -169,7 +169,7 @@
*/
struct CheckStepRoad {
CheckStepRoad(const Player & player, uint8_t const movecaps)
- : m_player(player), m_movecaps(movecaps)
+ : player_(player), movecaps_(movecaps)
{}
bool allowed
@@ -178,8 +178,8 @@
bool reachable_dest(Map &, FCoords dest) const;
private:
- const Player & m_player;
- uint8_t m_movecaps;
+ const Player & player_;
+ uint8_t movecaps_;
};
/**
@@ -187,7 +187,7 @@
* only checks whether the target is an allowed location.
*/
struct CheckStepLimited {
- void add_allowed_location(const Coords & c) {m_allowed_locations.insert(c);}
+ void add_allowed_location(const Coords & c) {allowed_locations_.insert(c);}
bool allowed
(Map &, FCoords start, FCoords end, int32_t dir, CheckStep::StepId)
const;
@@ -198,7 +198,7 @@
// does not matter, as long as it is system independent (for parallel
// simulation).
// The only thing that matters is whether a location is in the set.
- std::set<Coords, Coords::OrderingFunctor> m_allowed_locations;
+ std::set<Coords, Coords::OrderingFunctor> allowed_locations_;
};
=== modified file 'src/logic/map_objects/immovable.cc'
--- src/logic/map_objects/immovable.cc 2016-02-05 19:46:37 +0000
+++ src/logic/map_objects/immovable.cc 2016-02-07 09:53:38 +0000
@@ -146,7 +146,7 @@
ImmovableProgram::ImmovableProgram(const std::string& init_name,
const std::vector<std::string>& lines,
ImmovableDescr* immovable)
- : m_name(init_name) {
+ : name_(init_name) {
for (const std::string& line : lines) {
std::vector<std::string> parts;
boost::split(parts, line, boost::is_any_of("="));
@@ -175,9 +175,9 @@
throw GameDataError(
"unknown command type \"%s\" in immovable \"%s\"", parts[0].c_str(), immovable->name().c_str());
}
- m_actions.push_back(action);
+ actions_.push_back(action);
}
- if (m_actions.empty())
+ if (actions_.empty())
throw GameDataError("no actions");
}
@@ -197,14 +197,14 @@
MapObjectDescr::OwnerType input_type) :
MapObjectDescr(
MapObjectType::IMMOVABLE, table.get_string("name"), init_descname, table),
- m_size(BaseImmovable::NONE),
+ size_(BaseImmovable::NONE),
owner_type_(input_type) {
if (!is_animation_known("idle")) {
throw GameDataError("Immovable %s has no idle animation", table.get_string("name").c_str());
}
if (table.has_key("size")) {
- m_size = string_to_size(table.get_string("size"));
+ size_ = string_to_size(table.get_string("size"));
}
if (table.has_key("terrain_affinity")) {
@@ -219,7 +219,7 @@
std::unique_ptr<LuaTable> programs = table.get_table("programs");
for (const std::string& program_name : programs->keys<std::string>()) {
try {
- m_programs[program_name] = new ImmovableProgram(
+ programs_[program_name] = new ImmovableProgram(
program_name, programs->get_table(program_name)->array_entries<std::string>(), this);
} catch (const std::exception& e) {
throw wexception("Error in program %s: %s", program_name.c_str(), e.what());
@@ -252,7 +252,7 @@
const Tribes& tribes) :
ImmovableDescr(init_descname, table, MapObjectDescr::OwnerType::kTribe) {
if (table.has_key("buildcost")) {
- m_buildcost = Buildcost(table.get_table("buildcost"), tribes);
+ buildcost_ = Buildcost(table.get_table("buildcost"), tribes);
}
}
@@ -269,10 +269,10 @@
}
void ImmovableDescr::make_sure_default_program_is_there() {
- if (!m_programs.count("program")) { // default program
+ if (!programs_.count("program")) { // default program
assert(is_animation_known("idle"));
char parameters[] = "idle";
- m_programs["program"] = new ImmovableProgram(
+ programs_["program"] = new ImmovableProgram(
"program", new ImmovableProgram::ActAnimate(parameters, *this));
}
}
@@ -282,9 +282,9 @@
*/
ImmovableDescr::~ImmovableDescr()
{
- while (m_programs.size()) {
- delete m_programs.begin()->second;
- m_programs.erase(m_programs.begin());
+ while (programs_.size()) {
+ delete programs_.begin()->second;
+ programs_.erase(programs_.begin());
}
}
@@ -295,9 +295,9 @@
ImmovableProgram const * ImmovableDescr::get_program
(const std::string & program_name) const
{
- Programs::const_iterator const it = m_programs.find(program_name);
+ Programs::const_iterator const it = programs_.find(program_name);
- if (it == m_programs.end())
+ if (it == programs_.end())
throw GameDataError
("immovable %s has no program \"%s\"",
name().c_str(), program_name.c_str());
@@ -314,7 +314,7 @@
{
assert(this);
Immovable & result = *new Immovable(*this);
- result.m_position = coords;
+ result.position_ = coords;
result.init(egbase);
return result;
}
@@ -330,14 +330,14 @@
Immovable::Immovable(const ImmovableDescr & imm_descr) :
BaseImmovable (imm_descr),
-m_owner(nullptr),
-m_anim (0),
-m_animstart (0),
-m_program (nullptr),
-m_program_ptr (0),
-m_anim_construction_total(0),
-m_anim_construction_done(0),
-m_program_step(0)
+owner_(nullptr),
+anim_ (0),
+animstart_ (0),
+program_ (nullptr),
+program_ptr_ (0),
+anim_construction_total_(0),
+anim_construction_done_(0),
+program_step_(0)
{}
Immovable::~Immovable()
@@ -349,7 +349,7 @@
{
PositionList rv;
- rv.push_back(m_position);
+ rv.push_back(position_);
return rv;
}
@@ -365,22 +365,22 @@
void Immovable::set_owner(Player * player)
{
- m_owner = player;
+ owner_ = player;
}
void Immovable::start_animation
(const EditorGameBase & egbase, uint32_t const anim)
{
- m_anim = anim;
- m_animstart = egbase.get_gametime();
- m_anim_construction_done = m_anim_construction_total = 0;
+ anim_ = anim;
+ animstart_ = egbase.get_gametime();
+ anim_construction_done_ = anim_construction_total_ = 0;
}
void Immovable::increment_program_pointer()
{
- m_program_ptr = (m_program_ptr + 1) % m_program->size();
- m_action_data.reset(nullptr);
+ program_ptr_ = (program_ptr_ + 1) % program_->size();
+ action_data_.reset(nullptr);
}
@@ -391,15 +391,15 @@
{
BaseImmovable::init(egbase);
- set_position(egbase, m_position);
+ set_position(egbase, position_);
// Set animation data according to current program state.
- ImmovableProgram const * prog = m_program;
+ ImmovableProgram const * prog = program_;
if (!prog) {
prog = descr().get_program("program");
assert(prog != nullptr);
}
- if (upcast(ImmovableProgram::ActAnimate const, act_animate, &(*prog)[m_program_ptr]))
+ if (upcast(ImmovableProgram::ActAnimate const, act_animate, &(*prog)[program_ptr_]))
start_animation(egbase, act_animate->animation());
if (upcast(Game, game, &egbase)) {
@@ -413,7 +413,7 @@
*/
void Immovable::cleanup(EditorGameBase & egbase)
{
- unset_position(egbase, m_position);
+ unset_position(egbase, position_);
BaseImmovable::cleanup(egbase);
}
@@ -423,11 +423,11 @@
* Switch the currently running program.
*/
void Immovable::switch_program(Game& game, const std::string& program_name) {
- m_program = descr().get_program(program_name);
- assert(m_program != nullptr);
- m_program_ptr = 0;
- m_program_step = 0;
- m_action_data.reset(nullptr);
+ program_ = descr().get_program(program_name);
+ assert(program_ != nullptr);
+ program_ptr_ = 0;
+ program_step_ = 0;
+ action_data_.reset(nullptr);
schedule_act(game, 1);
}
@@ -438,9 +438,9 @@
{
BaseImmovable::act(game, data);
- if (m_program_step <= game.get_gametime()) {
+ if (program_step_ <= game.get_gametime()) {
// Might delete itself!
- (*m_program)[m_program_ptr].execute(game, *this);
+ (*program_)[program_ptr_].execute(game, *this);
}
}
@@ -448,9 +448,9 @@
void Immovable::draw
(const EditorGameBase& game, RenderTarget& dst, const FCoords&, const Point& pos)
{
- if (m_anim) {
- if (!m_anim_construction_total)
- dst.blit_animation(pos, m_anim, game.get_gametime() - m_animstart);
+ if (anim_) {
+ if (!anim_construction_total_)
+ dst.blit_animation(pos, anim_, game.get_gametime() - animstart_);
else
draw_construction(game, dst, pos);
}
@@ -460,25 +460,25 @@
(const EditorGameBase & game, RenderTarget & dst, const Point pos)
{
const ImmovableProgram::ActConstruction * constructionact = nullptr;
- if (m_program_ptr < m_program->size())
+ if (program_ptr_ < program_->size())
constructionact = dynamic_cast<const ImmovableProgram::ActConstruction *>
- (&(*m_program)[m_program_ptr]);
+ (&(*program_)[program_ptr_]);
const uint32_t steptime = constructionact ? constructionact->buildtime() : 5000;
uint32_t done = 0;
- if (m_anim_construction_done > 0) {
- done = steptime * (m_anim_construction_done - 1);
- done += std::min(steptime, game.get_gametime() - m_animstart);
+ if (anim_construction_done_ > 0) {
+ done = steptime * (anim_construction_done_ - 1);
+ done += std::min(steptime, game.get_gametime() - animstart_);
}
- uint32_t total = m_anim_construction_total * steptime;
+ uint32_t total = anim_construction_total_ * steptime;
if (done > total)
done = total;
- const Animation& anim = g_gr->animations().get_animation(m_anim);
+ const Animation& anim = g_gr->animations().get_animation(anim_);
const size_t nr_frames = anim.nr_frames();
- uint32_t frametime = g_gr->animations().get_animation(m_anim).frametime();
+ uint32_t frametime = g_gr->animations().get_animation(anim_).frametime();
uint32_t units_per_frame = (total + nr_frames - 1) / nr_frames;
const size_t current_frame = done / units_per_frame;
const uint16_t curw = anim.width();
@@ -490,23 +490,23 @@
const RGBColor& player_color = get_owner()->get_playercolor();
if (current_frame > 0) {
// Not the first pic, so draw the previous one in the back
- dst.blit_animation(pos, m_anim, (current_frame - 1) * frametime, player_color);
+ dst.blit_animation(pos, anim_, (current_frame - 1) * frametime, player_color);
}
assert(lines <= curh);
- dst.blit_animation(pos, m_anim, current_frame * frametime, player_color,
+ dst.blit_animation(pos, anim_, current_frame * frametime, player_color,
Rect(Point(0, curh - lines), curw, lines));
// Additionally, if statistics are enabled, draw a progression string
if (game.get_ibase()->get_display_flags() & InteractiveBase::dfShowStatistics) {
unsigned int percent = (100 * done / total);
- m_construct_string =
+ construct_string_ =
(boost::format("<font color=%s>%s</font>")
% UI_FONT_CLR_DARK.hex_value() % (boost::format(_("%i%% built")) % percent).str())
.str();
- m_construct_string = as_uifont(m_construct_string);
+ construct_string_ = as_uifont(construct_string_);
dst.blit(pos - Point(0, 48),
- UI::g_fh1->render(m_construct_string),
+ UI::g_fh1->render(construct_string_),
BlendMode::UseAlpha,
UI::Align::kCenter);
}
@@ -522,7 +522,7 @@
*/
void Immovable::set_action_data(ImmovableActionData * data)
{
- m_action_data.reset(data);
+ action_data_.reset(data);
}
@@ -554,24 +554,24 @@
}
// Position
- imm.m_position = read_coords_32(&fr, egbase().map().extent());
- imm.set_position(egbase(), imm.m_position);
+ imm.position_ = read_coords_32(&fr, egbase().map().extent());
+ imm.set_position(egbase(), imm.position_);
// Animation
char const * const animname = fr.c_string();
try {
- imm.m_anim = imm.descr().get_animation(animname);
+ imm.anim_ = imm.descr().get_animation(animname);
} catch (const MapObjectDescr::AnimationNonexistent &) {
- imm.m_anim = imm.descr().main_animation();
+ imm.anim_ = imm.descr().main_animation();
log
("Warning: (%s) Animation \"%s\" not found, using animation %s).\n",
- imm.descr().name().c_str(), animname, imm.descr().get_animation_name(imm.m_anim).c_str());
+ imm.descr().name().c_str(), animname, imm.descr().get_animation_name(imm.anim_).c_str());
}
- imm.m_animstart = fr.signed_32();
+ imm.animstart_ = fr.signed_32();
if (packet_version >= 4) {
- imm.m_anim_construction_total = fr.unsigned_32();
- if (imm.m_anim_construction_total)
- imm.m_anim_construction_done = fr.unsigned_32();
+ imm.anim_construction_total_ = fr.unsigned_32();
+ if (imm.anim_construction_total_)
+ imm.anim_construction_done_ = fr.unsigned_32();
}
{ // program
@@ -586,14 +586,14 @@
if (program_name.empty())
program_name = "program";
}
- imm.m_program = imm.descr().get_program(program_name);
+ imm.program_ = imm.descr().get_program(program_name);
}
- imm.m_program_ptr = fr.unsigned_32();
+ imm.program_ptr_ = fr.unsigned_32();
- if (!imm.m_program) {
- imm.m_program_ptr = 0;
+ if (!imm.program_) {
+ imm.program_ptr_ = 0;
} else {
- if (imm.m_program_ptr >= imm.m_program->size()) {
+ if (imm.program_ptr_ >= imm.program_->size()) {
// Try to not fail if the program of some immovable has changed
// significantly.
// Note that in some cases, the immovable may end up broken despite
@@ -601,19 +601,19 @@
log
("Warning: Immovable '%s', size of program '%s' seems to have "
"changed.\n",
- imm.descr().name().c_str(), imm.m_program->name().c_str());
- imm.m_program_ptr = 0;
+ imm.descr().name().c_str(), imm.program_->name().c_str());
+ imm.program_ptr_ = 0;
}
}
if (packet_version > 6) {
- imm.m_program_step = fr.unsigned_32();
+ imm.program_step_ = fr.unsigned_32();
} else {
- imm.m_program_step = fr.signed_32();
+ imm.program_step_ = fr.signed_32();
}
if (packet_version >= 3 && packet_version <= 5) {
- imm.m_reserved_by_worker = fr.unsigned_8();
+ imm.reserved_by_worker_ = fr.unsigned_8();
}
if (packet_version >= 4) {
std::string dataname = fr.c_string();
@@ -637,7 +637,7 @@
imm.schedule_act(*game, 1);
egbase().inform_players_about_immovable
- (Map::get_index(imm.m_position, egbase().map().get_width()),
+ (Map::get_index(imm.position_, egbase().map().get_width()),
&imm.descr());
}
@@ -662,24 +662,24 @@
BaseImmovable::save(egbase, mos, fw);
fw.unsigned_8(get_owner() ? get_owner()->player_number() : 0);
- write_coords_32(&fw, m_position);
+ write_coords_32(&fw, position_);
// Animations
- fw.string(descr().get_animation_name(m_anim));
- fw.signed_32(m_animstart);
- fw.unsigned_32(m_anim_construction_total);
- if (m_anim_construction_total)
- fw.unsigned_32(m_anim_construction_done);
+ fw.string(descr().get_animation_name(anim_));
+ fw.signed_32(animstart_);
+ fw.unsigned_32(anim_construction_total_);
+ if (anim_construction_total_)
+ fw.unsigned_32(anim_construction_done_);
// Program Stuff
- fw.string(m_program ? m_program->name() : "");
-
- fw.unsigned_32(m_program_ptr);
- fw.unsigned_32(m_program_step);
-
- if (m_action_data) {
- fw.c_string(m_action_data->name());
- m_action_data->save(fw, *this);
+ fw.string(program_ ? program_->name() : "");
+
+ fw.unsigned_32(program_ptr_);
+ fw.unsigned_32(program_step_);
+
+ if (action_data_) {
+ fw.c_string(action_data_->name());
+ action_data_->save(fw, *this);
} else {
fw.c_string("");
}
@@ -747,16 +747,16 @@
if (!descr.is_animation_known(animation_name)) {
throw GameDataError("Unknown animation: %s.", animation_name);
}
- m_id = descr.get_animation(animation_name);
+ id_ = descr.get_animation(animation_name);
if (!reached_end) { // The next parameter is the duration.
char * endp;
long int const value = strtol(parameters, &endp, 0);
if (*endp || value <= 0)
throw GameDataError("expected %s but found \"%s\"", "duration in ms", parameters);
- m_duration = value;
+ duration_ = value;
} else {
- m_duration = 0; // forever
+ duration_ = 0; // forever
}
} catch (const WException & e) {
throw GameDataError("animate: %s", e.what());
@@ -769,9 +769,9 @@
void ImmovableProgram::ActAnimate::execute
(Game & game, Immovable & immovable) const
{
- immovable.start_animation(game, m_id);
+ immovable.start_animation(game, id_);
immovable.program_step(
- game, m_duration ? 1 + game.logic_rand() % m_duration + game.logic_rand() % m_duration : 0);
+ game, duration_ ? 1 + game.logic_rand() % duration_ + game.logic_rand() % duration_ : 0);
}
@@ -1066,15 +1066,15 @@
if (params.size() != 3)
throw GameDataError("usage: animation-name buildtime decaytime");
- m_buildtime = atoi(params[1].c_str());
- m_decaytime = atoi(params[2].c_str());
+ buildtime_ = atoi(params[1].c_str());
+ decaytime_ = atoi(params[2].c_str());
std::string animation_name = params[0];
if (!descr.is_animation_known(animation_name)) {
throw GameDataError("unknown animation \"%s\" in immovable program for immovable \"%s\"",
animation_name.c_str(), descr.name().c_str());
}
- m_animid = descr.get_animation(animation_name);
+ animid_ = descr.get_animation(animation_name);
} catch (const WException & e) {
throw GameDataError("construction: %s", e.what());
@@ -1121,8 +1121,8 @@
d = new ActConstructionData;
imm.set_action_data(d);
- imm.start_animation(g, m_animid);
- imm.m_anim_construction_total = imm.descr().buildcost().total();
+ imm.start_animation(g, animid_);
+ imm.anim_construction_total_ = imm.descr().buildcost().total();
} else {
// Perhaps we are called due to the construction timeout of the last construction step
Buildcost remaining;
@@ -1152,10 +1152,10 @@
randdecay -= it->second;
}
- imm.m_anim_construction_done = d->delivered.total();
+ imm.anim_construction_done_ = d->delivered.total();
}
- imm.m_program_step = imm.schedule_act(g, m_decaytime);
+ imm.program_step_ = imm.schedule_act(g, decaytime_);
}
/**
@@ -1200,8 +1200,8 @@
else
d->delivered[index] = 1;
- m_anim_construction_done = d->delivered.total();
- m_animstart = game.get_gametime();
+ anim_construction_done_ = d->delivered.total();
+ animstart_ = game.get_gametime();
molog("construct_ware: total %u delivered: %u", index, d->delivered[index]);
@@ -1209,14 +1209,14 @@
construct_remaining_buildcost(game, &remaining);
const ImmovableProgram::ActConstruction * action =
- dynamic_cast<const ImmovableProgram::ActConstruction *>(&(*m_program)[m_program_ptr]);
+ dynamic_cast<const ImmovableProgram::ActConstruction *>(&(*program_)[program_ptr_]);
assert(action != nullptr);
if (remaining.empty()) {
// Wait for the last building animation to finish.
- m_program_step = schedule_act(game, action->buildtime());
+ program_step_ = schedule_act(game, action->buildtime());
} else {
- m_program_step = schedule_act(game, action->decaytime());
+ program_step_ = schedule_act(game, action->decaytime());
}
return true;
@@ -1246,7 +1246,7 @@
* Zero-initialize
*/
PlayerImmovable::PlayerImmovable(const MapObjectDescr & mo_descr) :
- BaseImmovable(mo_descr), m_owner(nullptr), m_economy(nullptr)
+ BaseImmovable(mo_descr), owner_(nullptr), economy_(nullptr)
{}
/**
@@ -1254,10 +1254,10 @@
*/
PlayerImmovable::~PlayerImmovable()
{
- if (m_workers.size())
+ if (workers_.size())
log
("PlayerImmovable::~PlayerImmovable: %lu workers left!\n",
- static_cast<long unsigned int>(m_workers.size()));
+ static_cast<long unsigned int>(workers_.size()));
}
/**
@@ -1265,13 +1265,13 @@
*/
void PlayerImmovable::set_economy(Economy * const e)
{
- if (m_economy == e)
+ if (economy_ == e)
return;
- for (uint32_t i = 0; i < m_workers.size(); ++i)
- m_workers[i]->set_economy(e);
+ for (uint32_t i = 0; i < workers_.size(); ++i)
+ workers_[i]->set_economy(e);
- m_economy = e;
+ economy_ = e;
}
/**
@@ -1283,7 +1283,7 @@
*/
void PlayerImmovable::add_worker(Worker & w)
{
- m_workers.push_back(&w);
+ workers_.push_back(&w);
}
/**
@@ -1293,10 +1293,10 @@
*/
void PlayerImmovable::remove_worker(Worker & w)
{
- for (Workers::iterator worker_iter = m_workers.begin(); worker_iter != m_workers.end(); ++worker_iter)
+ for (Workers::iterator worker_iter = workers_.begin(); worker_iter != workers_.end(); ++worker_iter)
if (*worker_iter == &w) {
- *worker_iter = *(m_workers.end() - 1);
- return m_workers.pop_back();
+ *worker_iter = *(workers_.end() - 1);
+ return workers_.pop_back();
}
throw wexception("PlayerImmovable::remove_worker: not in list");
@@ -1307,9 +1307,9 @@
* Set the immovable's owner. Currently, it can only be set once.
*/
void PlayerImmovable::set_owner(Player * const new_owner) {
- assert(m_owner == nullptr);
+ assert(owner_ == nullptr);
- m_owner = new_owner;
+ owner_ = new_owner;
Notifications::publish(NoteImmovable(this, NoteImmovable::Ownership::GAINED));
}
@@ -1327,8 +1327,8 @@
*/
void PlayerImmovable::cleanup(EditorGameBase & egbase)
{
- while (!m_workers.empty())
- m_workers[0]->set_location(nullptr);
+ while (!workers_.empty())
+ workers_[0]->set_location(nullptr);
Notifications::publish(NoteImmovable(this, NoteImmovable::Ownership::LOST));
@@ -1366,9 +1366,9 @@
BaseImmovable::log_general_info(egbase);
molog("this: %p\n", this);
- molog("m_owner: %p\n", m_owner);
- molog("* player nr: %i\n", m_owner->player_number());
- molog("m_economy: %p\n", m_economy);
+ molog("owner_: %p\n", owner_);
+ molog("player_number: %i\n", owner_->player_number());
+ molog("economy_: %p\n", economy_);
}
constexpr uint8_t kCurrentPacketVersionPlayerImmovable = 1;
@@ -1398,7 +1398,7 @@
if (!owner)
throw GameDataError("owning player %u does not exist", owner_number);
- imm.m_owner = owner;
+ imm.owner_ = owner;
} else {
throw UnhandledVersionError("PlayerImmovable", packet_version, kCurrentPacketVersionPlayerImmovable);
}
=== modified file 'src/logic/map_objects/immovable.h'
--- src/logic/map_objects/immovable.h 2016-01-31 15:31:00 +0000
+++ src/logic/map_objects/immovable.h 2016-02-07 09:53:38 +0000
@@ -120,14 +120,14 @@
ImmovableDescr(const std::string& init_descname, const LuaTable&, const Tribes& tribes);
~ImmovableDescr() override;
- int32_t get_size() const {return m_size;}
+ int32_t get_size() const {return size_;}
ImmovableProgram const * get_program(const std::string &) const;
Immovable & create(EditorGameBase &, Coords) const;
MapObjectDescr::OwnerType owner_type() const {return owner_type_;}
- const Buildcost & buildcost() const {return m_buildcost;}
+ const Buildcost & buildcost() const {return buildcost_;}
// Returns the editor category.
@@ -142,15 +142,15 @@
const TerrainAffinity& terrain_affinity() const;
protected:
- int32_t m_size;
- Programs m_programs;
+ int32_t size_;
+ Programs programs_;
/// Whether this ImmovableDescr belongs to a tribe or the world
const MapObjectDescr::OwnerType owner_type_;
/// Buildcost for externally constructible immovables (for ship construction)
/// \see ActConstruction
- Buildcost m_buildcost;
+ Buildcost buildcost_;
private:
// Common constructor functions for tribes and world.
@@ -175,10 +175,10 @@
Immovable(const ImmovableDescr &);
~Immovable();
- Player * get_owner() const {return m_owner;}
+ Player * get_owner() const {return owner_;}
void set_owner(Player * player);
- Coords get_position() const {return m_position;}
+ Coords get_position() const {return position_;}
PositionList get_positions (const EditorGameBase &) const override;
int32_t get_size () const override;
@@ -187,7 +187,7 @@
void program_step(Game & game, uint32_t const delay = 1) {
if (delay)
- m_program_step = schedule_act(game, delay);
+ program_step_ = schedule_act(game, delay);
increment_program_pointer();
}
@@ -205,23 +205,23 @@
void set_action_data(ImmovableActionData * data);
template<typename T>
T * get_action_data() {
- if (!m_action_data)
+ if (!action_data_)
return nullptr;
- if (T * data = dynamic_cast<T *>(m_action_data.get()))
+ if (T * data = dynamic_cast<T *>(action_data_.get()))
return data;
set_action_data(nullptr);
return nullptr;
}
protected:
- Player * m_owner;
- Coords m_position;
-
- uint32_t m_anim;
- int32_t m_animstart;
-
- const ImmovableProgram * m_program;
- uint32_t m_program_ptr; ///< index of next instruction to execute
+ Player * owner_;
+ Coords position_;
+
+ uint32_t anim_;
+ int32_t animstart_;
+
+ const ImmovableProgram * program_;
+ uint32_t program_ptr_; ///< index of next instruction to execute
/* GCC 4.0 has problems with friend declarations: It doesn't allow
* substructures of friend classes private access but we rely on this behaviour
@@ -232,23 +232,23 @@
*/
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 0)
public:
- uint32_t m_anim_construction_total;
- uint32_t m_anim_construction_done;
- int32_t m_program_step;
+ uint32_t anim_construction_total_;
+ uint32_t anim_construction_done_;
+ uint32_t program_step_;
protected:
#else
- uint32_t m_anim_construction_total;
- uint32_t m_anim_construction_done;
- uint32_t m_program_step; ///< time of next step
+ uint32_t anim_construction_total_;
+ uint32_t anim_construction_done_;
+ uint32_t program_step_; ///< time of next step
#endif
- std::string m_construct_string;
+ std::string construct_string_;
/**
* Private persistent data for the currently active program action.
*
* \warning Use get_action_data to access this.
*/
- std::unique_ptr<ImmovableActionData> m_action_data;
+ std::unique_ptr<ImmovableActionData> action_data_;
// Load/save support
protected:
@@ -287,10 +287,10 @@
PlayerImmovable(const MapObjectDescr &);
virtual ~PlayerImmovable();
- Player * get_owner() const {return m_owner;}
- Player & owner() const {return *m_owner;}
- Economy * get_economy() const {return m_economy;}
- Economy & economy() const {return *m_economy;}
+ Player * get_owner() const {return owner_;}
+ Player & owner() const {return *owner_;}
+ Economy * get_economy() const {return economy_;}
+ Economy & economy() const {return *economy_;}
virtual Flag & base_flag() = 0;
@@ -306,7 +306,7 @@
* immovable. This is not the same as the list of production
* workers returned by \ref ProductionSite::get_production_workers
*/
- const Workers & get_workers() const {return m_workers;}
+ const Workers & get_workers() const {return workers_;}
void log_general_info(const EditorGameBase &) override;
@@ -332,10 +332,10 @@
void cleanup(EditorGameBase &) override;
private:
- Player * m_owner;
- Economy * m_economy;
+ Player * owner_;
+ Economy * economy_;
- Workers m_workers;
+ Workers workers_;
// load/save support
protected:
=== modified file 'src/logic/map_objects/immovable_program.h'
--- src/logic/map_objects/immovable_program.h 2015-11-28 22:29:26 +0000
+++ src/logic/map_objects/immovable_program.h 2016-02-07 09:53:38 +0000
@@ -65,10 +65,10 @@
struct ActAnimate : public Action {
ActAnimate(char * parameters, ImmovableDescr &);
void execute(Game &, Immovable &) const override;
- uint32_t animation() const {return m_id;}
+ uint32_t animation() const {return id_;}
private:
- uint32_t m_id;
- Duration m_duration;
+ uint32_t id_;
+ Duration duration_;
};
/// Transforms the immovable into another immovable or into a bob
@@ -163,20 +163,20 @@
ActConstruction(char* parameters, ImmovableDescr&);
void execute(Game &, Immovable &) const override;
- Duration buildtime() const {return m_buildtime;}
- Duration decaytime() const {return m_decaytime;}
+ Duration buildtime() const {return buildtime_;}
+ Duration decaytime() const {return decaytime_;}
private:
- uint32_t m_animid;
- Duration m_buildtime;
- Duration m_decaytime;
+ uint32_t animid_;
+ Duration buildtime_;
+ Duration decaytime_;
};
/// Create a program with a single action.
ImmovableProgram(char const * const _name, Action * const action)
- : m_name(_name)
+ : name_(_name)
{
- m_actions.push_back(action);
+ actions_.push_back(action);
}
// Create an immovable program from a number of lines.
@@ -185,24 +185,24 @@
ImmovableDescr* immovable);
~ImmovableProgram() {
- for (Action * action : m_actions) {
+ for (Action * action : actions_) {
delete action;
}
}
- const std::string & name() const {return m_name;}
- size_t size() const {return m_actions.size();}
+ const std::string & name() const {return name_;}
+ size_t size() const {return actions_.size();}
const Action & operator[](size_t const idx) const {
- assert(idx < m_actions.size());
- return *m_actions[idx];
+ assert(idx < actions_.size());
+ return *actions_[idx];
}
using Actions = std::vector<Action *>;
- const Actions & actions() const {return m_actions;}
+ const Actions & actions() const {return actions_;}
private:
- std::string m_name;
- Actions m_actions;
+ std::string name_;
+ Actions actions_;
};
struct ImmovableActionData {
=== modified file 'src/logic/map_objects/map_object.cc'
--- src/logic/map_objects/map_object.cc 2016-01-18 05:12:51 +0000
+++ src/logic/map_objects/map_object.cc 2016-02-07 09:53:38 +0000
@@ -150,10 +150,10 @@
ObjectManager::~ObjectManager()
{
// better not throw an exception in a destructor...
- if (!m_objects.empty())
+ if (!objects_.empty())
log("ObjectManager: ouch! remaining objects\n");
- log("lastserial: %i\n", m_lastserial);
+ log("lastserial: %i\n", lastserial_);
}
/**
@@ -161,11 +161,11 @@
*/
void ObjectManager::cleanup(EditorGameBase & egbase)
{
- while (!m_objects.empty()) {
- MapObjectMap::iterator it = m_objects.begin();
+ while (!objects_.empty()) {
+ MapObjectMap::iterator it = objects_.begin();
it->second->remove(egbase);
}
- m_lastserial = 0;
+ lastserial_ = 0;
}
/**
@@ -173,10 +173,10 @@
*/
void ObjectManager::insert(MapObject * obj)
{
- ++m_lastserial;
- assert(m_lastserial);
- obj->m_serial = m_lastserial;
- m_objects[m_lastserial] = obj;
+ ++lastserial_;
+ assert(lastserial_);
+ obj->serial_ = lastserial_;
+ objects_[lastserial_] = obj;
}
/**
@@ -184,7 +184,7 @@
*/
void ObjectManager::remove(MapObject & obj)
{
- m_objects.erase(obj.m_serial);
+ objects_.erase(obj.serial_);
}
/*
@@ -193,7 +193,7 @@
std::vector<Serial> ObjectManager::all_object_serials_ordered () const {
std::vector<Serial> rv;
- for (const std::pair<Serial, MapObject *>& o : m_objects) {
+ for (const std::pair<Serial, MapObject *>& o : objects_) {
rv.push_back(o.first);
}
@@ -204,11 +204,11 @@
MapObject * ObjectPointer::get(const EditorGameBase & egbase)
{
- if (!m_serial)
+ if (!serial_)
return nullptr;
- MapObject * const obj = egbase.objects().get_object(m_serial);
+ MapObject * const obj = egbase.objects().get_object(serial_);
if (!obj)
- m_serial = 0;
+ serial_ = 0;
return obj;
}
@@ -217,7 +217,7 @@
// that is pointed to.
// That is, a 'const ObjectPointer' behaves like a 'ObjectPointer * const'.
MapObject * ObjectPointer::get(const EditorGameBase & egbase) const {
- return m_serial ? egbase.objects().get_object(m_serial) : nullptr;
+ return serial_ ? egbase.objects().get_object(serial_) : nullptr;
}
@@ -233,7 +233,7 @@
MapObjectDescr::MapObjectDescr(const MapObjectType init_type,
const std::string& init_name,
const std::string& init_descname)
- : m_type(init_type), m_name(init_name), m_descname(init_descname),
+ : type_(init_type), name_(init_name), descname_(init_descname),
representative_image_filename_(""), icon_filename_("") {
}
MapObjectDescr::MapObjectDescr(const MapObjectType init_type,
@@ -258,16 +258,16 @@
}
}
}
-MapObjectDescr::~MapObjectDescr() {m_anims.clear();}
-
-
-uint32_t MapObjectDescr::s_dyn_attribhigh =
+MapObjectDescr::~MapObjectDescr() {anims_.clear();}
+
+
+uint32_t MapObjectDescr::dyn_attribhigh_ =
MapObject::HIGHEST_FIXED_ATTRIBUTE;
-MapObjectDescr::AttribMap MapObjectDescr::s_dyn_attribs;
+MapObjectDescr::AttribMap MapObjectDescr::dyn_attribs_;
bool MapObjectDescr::is_animation_known(const std::string & animname) const {
- return (m_anims.count(animname) == 1);
+ return (anims_.count(animname) == 1);
}
/**
@@ -280,7 +280,7 @@
throw GameDataError
("Tried to add already existing animation \"%s\"", animname.c_str());
} else {
- m_anims.insert(std::pair<std::string, uint32_t>(animname, anim));
+ anims_.insert(std::pair<std::string, uint32_t>(animname, anim));
}
}
@@ -299,7 +299,7 @@
std::string MapObjectDescr::get_animation_name(uint32_t const anim) const {
- for (const std::pair<std::string, uint32_t>& temp_anim : m_anims) {
+ for (const std::pair<std::string, uint32_t>& temp_anim : anims_) {
if (temp_anim.second == anim) {
return temp_anim.first;
}
@@ -332,7 +332,7 @@
* Search for the attribute in the attribute list
*/
bool MapObjectDescr::has_attribute(uint32_t const attr) const {
- for (const uint32_t& attrib : m_attributes) {
+ for (const uint32_t& attrib : attributes_) {
if (attrib == attr) {
return true;
}
@@ -347,7 +347,7 @@
void MapObjectDescr::add_attribute(uint32_t const attr)
{
if (!has_attribute(attr))
- m_attributes.push_back(attr);
+ attributes_.push_back(attr);
}
void MapObjectDescr::add_attributes(const std::vector<std::string>& attributes,
@@ -368,9 +368,9 @@
* before and add_if_not_exists = true, we add it to the map. Else, throws exception.
*/
uint32_t MapObjectDescr::get_attribute_id(const std::string & name, bool add_if_not_exists) {
- AttribMap::iterator it = s_dyn_attribs.find(name);
+ AttribMap::iterator it = dyn_attribs_.find(name);
- if (it != s_dyn_attribs.end()) {
+ if (it != dyn_attribs_.end()) {
return it->second;
}
@@ -383,12 +383,12 @@
if (!add_if_not_exists) {
throw GameDataError("get_attribute_id: attribute '%s' not found!\n", name.c_str());
} else {
- ++s_dyn_attribhigh;
- s_dyn_attribs[name] = s_dyn_attribhigh;
+ ++dyn_attribhigh_;
+ dyn_attribs_[name] = dyn_attribhigh_;
}
- assert(s_dyn_attribhigh != 0); // wrap around seems *highly* unlikely ;)
+ assert(dyn_attribhigh_ != 0); // wrap around seems *highly* unlikely ;)
- return s_dyn_attribhigh;
+ return dyn_attribhigh_;
}
/**
@@ -397,8 +397,8 @@
*/
std::string MapObjectDescr::get_attribute_name(uint32_t id) {
for
- (AttribMap::iterator iter = s_dyn_attribs.begin();
- iter != s_dyn_attribs.end(); ++iter)
+ (AttribMap::iterator iter = dyn_attribs_.begin();
+ iter != dyn_attribs_.end(); ++iter)
{
if (iter->second == id)
return iter->first;
@@ -418,10 +418,10 @@
* Zero-initialize a map object
*/
MapObject::MapObject(const MapObjectDescr * const the_descr) :
-m_descr(the_descr),
-m_serial(0),
-m_logsink(nullptr),
-m_reserved_by_worker(false)
+descr_(the_descr),
+serial_(0),
+logsink_(nullptr),
+reserved_by_worker_(false)
{}
@@ -431,7 +431,7 @@
*/
void MapObject::remove(EditorGameBase & egbase)
{
- removed(m_serial); // Signal call
+ removed(serial_); // Signal call
cleanup(egbase);
delete this;
}
@@ -523,7 +523,7 @@
*/
void MapObject::set_logsink(LogSink * const sink)
{
- m_logsink = sink;
+ logsink_ = sink;
}
@@ -534,7 +534,7 @@
*/
void MapObject::molog(char const * fmt, ...) const
{
- if (!g_verbose && !m_logsink)
+ if (!g_verbose && !logsink_)
return;
va_list va;
@@ -544,20 +544,20 @@
vsnprintf(buffer, sizeof(buffer), fmt, va);
va_end(va);
- if (m_logsink)
- m_logsink->log(buffer);
+ if (logsink_)
+ logsink_->log(buffer);
- log("MO(%u,%s): %s", m_serial, descr().name().c_str(), buffer);
+ log("MO(%u,%s): %s", serial_, descr().name().c_str(), buffer);
}
bool MapObject::is_reserved_by_worker() const
{
- return m_reserved_by_worker;
+ return reserved_by_worker_;
}
void MapObject::set_reserved_by_worker(bool reserve)
{
- m_reserved_by_worker = reserve;
+ reserved_by_worker_ = reserve;
}
@@ -593,7 +593,7 @@
}
if (packet_version == kCurrentPacketVersionMapObject) {
- get_object()->m_reserved_by_worker = fr.unsigned_8();
+ get_object()->reserved_by_worker_ = fr.unsigned_8();
}
} catch (const WException & e) {
throw wexception("map object: %s", e.what());
@@ -636,7 +636,7 @@
fw.unsigned_8(kCurrentPacketVersionMapObject);
fw.unsigned_32(mos.get_object_file_index(*this));
- fw.unsigned_8(m_reserved_by_worker);
+ fw.unsigned_8(reserved_by_worker_);
}
std::string to_string(const MapObjectType type) {
=== modified file 'src/logic/map_objects/map_object.h'
--- src/logic/map_objects/map_object.h 2016-01-10 12:20:22 +0000
+++ src/logic/map_objects/map_object.h 2016-02-07 09:53:38 +0000
@@ -106,16 +106,16 @@
const LuaTable& table);
virtual ~MapObjectDescr();
- const std::string & name() const {return m_name;}
- const std::string & descname() const {return m_descname;}
+ const std::string & name() const {return name_;}
+ const std::string & descname() const {return descname_;}
// Type of the MapObjectDescr.
- MapObjectType type() const {return m_type;}
+ MapObjectType type() const {return type_;}
struct AnimationNonexistent {};
uint32_t get_animation(char const * const anim) const {
- std::map<std::string, uint32_t>::const_iterator it = m_anims.find(anim);
- if (it == m_anims.end())
+ std::map<std::string, uint32_t>::const_iterator it = anims_.find(anim);
+ if (it == anims_.end())
throw AnimationNonexistent();
return it->second;
}
@@ -124,7 +124,7 @@
}
uint32_t main_animation() const {
- return !m_anims.empty()? m_anims.begin()->second : 0;
+ return !anims_.empty()? anims_.begin()->second : 0;
}
std::string get_animation_name(uint32_t) const; ///< needed for save, debug
@@ -161,13 +161,13 @@
using AttribMap = std::map<std::string, uint32_t>;
using Attributes = std::vector<uint32_t>;
- const MapObjectType m_type; /// Subclasses pick from the enum above
- std::string const m_name; /// The name for internal reference
- std::string const m_descname; /// A localized Descriptive name
- Attributes m_attributes;
- Anims m_anims;
- static uint32_t s_dyn_attribhigh; ///< highest attribute ID used
- static AttribMap s_dyn_attribs;
+ const MapObjectType type_; /// Subclasses pick from the enum above
+ std::string const name_; /// The name for internal reference
+ std::string const descname_; /// A localized Descriptive name
+ Attributes attributes_;
+ Anims anims_;
+ static uint32_t dyn_attribhigh_; ///< highest attribute ID used
+ static AttribMap dyn_attribs_;
std::string representative_image_filename_; // Image for big represenations, e.g. on buttons
std::string icon_filename_; // Filename for the menu icon
@@ -209,7 +209,7 @@
/// or additional member variable, go ahead
#define MO_DESCR(type) \
public: const type & descr() const { \
- return dynamic_cast<const type&>(*m_descr); \
+ return dynamic_cast<const type&>(*descr_); \
} \
class MapObject {
@@ -245,7 +245,7 @@
virtual ~MapObject() {}
public:
- Serial serial() const {return m_serial;}
+ Serial serial() const {return serial_;}
/**
* Is called right before the object will be removed from
@@ -285,7 +285,7 @@
virtual void create_debug_panels
(const EditorGameBase & egbase, UI::TabPanel & tabs);
- LogSink * get_logsink() {return m_logsink;}
+ LogSink * get_logsink() {return logsink_;}
void set_logsink(LogSink *);
/// Called when a new logsink is set. Used to give general information.
@@ -331,12 +331,12 @@
* all Loader objects should be deleted.
*/
struct Loader {
- EditorGameBase * m_egbase;
- MapObjectLoader * m_mol;
- MapObject * m_object;
+ EditorGameBase * egbase_;
+ MapObjectLoader * mol_;
+ MapObject * object_;
protected:
- Loader() : m_egbase(nullptr), m_mol(nullptr), m_object(nullptr) {}
+ Loader() : egbase_(nullptr), mol_(nullptr), object_(nullptr) {}
public:
virtual ~Loader() {}
@@ -344,16 +344,16 @@
void init
(EditorGameBase & e, MapObjectLoader & m, MapObject & object)
{
- m_egbase = &e;
- m_mol = &m;
- m_object = &object;
+ egbase_ = &e;
+ mol_ = &m;
+ object_ = &object;
}
- EditorGameBase & egbase () {return *m_egbase;}
- MapObjectLoader & mol () {return *m_mol;}
- MapObject * get_object() {return m_object;}
+ EditorGameBase & egbase () {return *egbase_;}
+ MapObjectLoader & mol () {return *mol_;}
+ MapObject * get_object() {return object_;}
template<typename T> T & get() {
- return dynamic_cast<T&>(*m_object);
+ return dynamic_cast<T&>(*object_);
}
protected:
@@ -382,9 +382,9 @@
void molog(char const * fmt, ...) const
__attribute__((format(printf, 2, 3)));
- const MapObjectDescr * m_descr;
- Serial m_serial;
- LogSink * m_logsink;
+ const MapObjectDescr * descr_;
+ Serial serial_;
+ LogSink * logsink_;
/**
* MapObjects like trees are reserved by a worker that is walking
@@ -392,7 +392,7 @@
* work on the same tree simultaneously or two hunters try to hunt
* the same animal.
*/
- bool m_reserved_by_worker;
+ bool reserved_by_worker_;
private:
DISALLOW_COPY_AND_ASSIGN(MapObject);
@@ -410,14 +410,14 @@
struct ObjectManager {
using MapObjectMap = boost::unordered_map<Serial, MapObject *>;
- ObjectManager() {m_lastserial = 0;}
+ ObjectManager() {lastserial_ = 0;}
~ObjectManager();
void cleanup(EditorGameBase &);
MapObject * get_object(Serial const serial) const {
- const MapObjectMap::const_iterator it = m_objects.find(serial);
- return it != m_objects.end() ? it->second : nullptr;
+ const MapObjectMap::const_iterator it = objects_.find(serial);
+ return it != objects_.end() ? it->second : nullptr;
}
void insert(MapObject *);
@@ -426,8 +426,8 @@
bool object_still_available(const MapObject * const t) const {
if (!t)
return false;
- MapObjectMap::const_iterator it = m_objects.begin();
- while (it != m_objects.end()) {
+ MapObjectMap::const_iterator it = objects_.begin();
+ while (it != objects_.end()) {
if (it->second == t)
return true;
++it;
@@ -442,8 +442,8 @@
std::vector<Serial> all_object_serials_ordered () const;
private:
- Serial m_lastserial;
- MapObjectMap m_objects;
+ Serial lastserial_;
+ MapObjectMap objects_;
DISALLOW_COPY_AND_ASSIGN(ObjectManager);
};
@@ -453,16 +453,16 @@
*/
struct ObjectPointer {
// Provide default constructor to shut up cppcheck.
- ObjectPointer() {m_serial = 0;}
- ObjectPointer(MapObject * const obj) {m_serial = obj ? obj->m_serial : 0;}
+ ObjectPointer() {serial_ = 0;}
+ ObjectPointer(MapObject * const obj) {serial_ = obj ? obj->serial_ : 0;}
// can use standard copy constructor and assignment operator
ObjectPointer & operator= (MapObject * const obj) {
- m_serial = obj ? obj->m_serial : 0;
+ serial_ = obj ? obj->serial_ : 0;
return *this;
}
- bool is_set() const {return m_serial;}
+ bool is_set() const {return serial_;}
// TODO(unknown): dammit... without an EditorGameBase object, we can't implement a
// MapObject* operator (would be _really_ nice)
@@ -470,19 +470,19 @@
MapObject * get(const EditorGameBase & egbase) const;
bool operator< (const ObjectPointer & other) const {
- return m_serial < other.m_serial;
+ return serial_ < other.serial_;
}
bool operator== (const ObjectPointer & other) const {
- return m_serial == other.m_serial;
+ return serial_ == other.serial_;
}
bool operator!= (const ObjectPointer & other) const {
- return m_serial != other.m_serial;
+ return serial_ != other.serial_;
}
- uint32_t serial() const {return m_serial;}
+ uint32_t serial() const {return serial_;}
private:
- uint32_t m_serial;
+ uint32_t serial_;
};
template<class T>
=== modified file 'src/logic/map_objects/tribes/building.cc'
--- src/logic/map_objects/tribes/building.cc 2016-02-02 12:47:45 +0000
+++ src/logic/map_objects/tribes/building.cc 2016-02-07 09:53:38 +0000
@@ -854,7 +854,7 @@
Message * msg = new Message
(msgtype, game.get_gametime(), title, icon_filename, heading, rt_description,
- get_position(), (link_to_building_lifetime ? m_serial : 0));
+ get_position(), (link_to_building_lifetime ? serial_ : 0));
if (throttle_time)
owner().add_message_with_timeout
=== modified file 'src/logic/map_objects/tribes/ship.cc'
--- src/logic/map_objects/tribes/ship.cc 2016-01-28 05:54:47 +0000
+++ src/logic/map_objects/tribes/ship.cc 2016-02-07 09:53:38 +0000
@@ -1013,7 +1013,7 @@
heading,
rt_description,
get_position(),
- m_serial);
+ serial_);
get_owner()->add_message(game, *msg);
}
=== modified file 'src/logic/map_objects/tribes/soldier.cc'
--- src/logic/map_objects/tribes/soldier.cc 2016-01-28 05:24:34 +0000
+++ src/logic/map_objects/tribes/soldier.cc 2016-02-07 09:53:38 +0000
@@ -1503,7 +1503,7 @@
_("Logic error"),
messagetext,
get_position(),
- m_serial));
+ serial_));
opponent.owner().add_message
(game,
*new Message
@@ -1514,7 +1514,7 @@
_("Logic error"),
messagetext,
opponent.get_position(),
- m_serial));
+ serial_));
game.game_controller()->set_desired_speed(0);
return pop_task(game);
}
=== modified file 'src/logic/map_objects/tribes/worker.cc'
--- src/logic/map_objects/tribes/worker.cc 2016-02-05 20:11:46 +0000
+++ src/logic/map_objects/tribes/worker.cc 2016-02-07 09:53:38 +0000
@@ -953,7 +953,7 @@
rdescr->descname(),
message,
position,
- m_serial),
+ serial_),
300000, 8);
}
}
@@ -1300,7 +1300,7 @@
const TribeDescr & t = owner().tribe();
DescriptionIndex const old_index = t.worker_index(descr().name());
DescriptionIndex const new_index = descr().becomes();
- m_descr = t.get_worker_descr(new_index);
+ descr_ = t.get_worker_descr(new_index);
assert(t.has_worker(new_index));
// Inform the economy, that something has changed
@@ -1846,7 +1846,7 @@
_("Worker got lost!"),
message,
get_position()),
- m_serial);
+ serial_);
set_location(nullptr);
return pop_task(game);
}
Follow ups