GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1395278-tribes-t-z into lp:widelands.
Commit message: Refactored remaining member variables in tribes. Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1395278 in widelands: "Consolidate naming of member variables" https://bugs.launchpad.net/widelands/+bug/1395278 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1395278-tribes-t-z/+merge/285969 -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1395278-tribes-t-z into lp:widelands.
=== modified file 'src/logic/map_objects/tribes/trainingsite.cc' --- src/logic/map_objects/tribes/trainingsite.cc 2016-01-18 19:35:25 +0000 +++ src/logic/map_objects/tribes/trainingsite.cc 2016-02-13 14:28:04 +0000 @@ -39,28 +39,28 @@ namespace Widelands { -const uint32_t TrainingSite::training_state_multiplier = 12; +const uint32_t TrainingSite::training_state_multiplier_ = 12; TrainingSiteDescr::TrainingSiteDescr (const std::string& init_descname, const LuaTable& table, const EditorGameBase& egbase) : ProductionSiteDescr (init_descname, "", MapObjectType::TRAININGSITE, table, egbase), - m_num_soldiers (table.get_int("soldier_capacity")), - m_max_stall (table.get_int("trainer_patience")), + num_soldiers_ (table.get_int("soldier_capacity")), + max_stall_ (table.get_int("trainer_patience")), - m_train_hp (false), - m_train_attack (false), - m_train_defense (false), - m_train_evade (false), - m_min_hp (0), - m_min_attack (0), - m_min_defense (0), - m_min_evade (0), - m_max_hp (0), - m_max_attack (0), - m_max_defense (0), - m_max_evade (0) + train_hp_ (false), + train_attack_ (false), + train_defense_ (false), + train_evade_ (false), + min_hp_ (0), + min_attack_ (0), + min_defense_ (0), + min_evade_ (0), + max_hp_ (0), + max_attack_ (0), + max_defense_ (0), + max_evade_ (0) { // Read the range of levels that can update this building // TODO(unknown): This is currently hardcoded to "soldier" but it should search for @@ -70,31 +70,31 @@ std::unique_ptr<LuaTable> items_table; if (table.has_key("soldier hp")) { items_table = table.get_table("soldier hp"); - m_train_hp = true; - m_min_hp = items_table->get_int("min_level"); - m_max_hp = items_table->get_int("max_level"); + train_hp_ = true; + min_hp_ = items_table->get_int("min_level"); + max_hp_ = items_table->get_int("max_level"); add_training_inputs(*items_table.get(), &food_hp_, &weapons_hp_); } if (table.has_key("soldier attack")) { items_table = table.get_table("soldier attack"); - m_train_attack = true; - m_min_attack = items_table->get_int("min_level"); - m_max_attack = items_table->get_int("max_level"); + train_attack_ = true; + min_attack_ = items_table->get_int("min_level"); + max_attack_ = items_table->get_int("max_level"); add_training_inputs(*items_table.get(), &food_attack_, &weapons_attack_); } if (table.has_key("soldier defense")) { items_table = table.get_table("soldier defense"); - m_train_defense = true; - m_min_defense = items_table->get_int("min_level"); - m_max_defense = items_table->get_int("max_level"); + train_defense_ = true; + min_defense_ = items_table->get_int("min_level"); + max_defense_ = items_table->get_int("max_level"); add_training_inputs(*items_table.get(), &food_defense_, &weapons_defense_); } if (table.has_key("soldier evade")) { items_table = table.get_table("soldier evade"); - m_train_evade = true; - m_min_evade = items_table->get_int("min_level"); - m_max_evade = items_table->get_int("max_level"); + train_evade_ = true; + min_evade_ = items_table->get_int("min_level"); + max_evade_ = items_table->get_int("max_level"); add_training_inputs(*items_table.get(), &food_evade_, &weapons_evade_); } } @@ -115,13 +115,13 @@ int32_t TrainingSiteDescr::get_min_level(const TrainingAttribute at) const { switch (at) { case atrHP: - return m_min_hp; + return min_hp_; case atrAttack: - return m_min_attack; + return min_attack_; case atrDefense: - return m_min_defense; + return min_defense_; case atrEvade: - return m_min_evade; + return min_evade_; case atrTotal: throw wexception("Unknown attribute value!"); } @@ -137,13 +137,13 @@ int32_t TrainingSiteDescr::get_max_level(const TrainingAttribute at) const { switch (at) { case atrHP: - return m_max_hp; + return max_hp_; case atrAttack: - return m_max_attack; + return max_attack_; case atrDefense: - return m_max_defense; + return max_defense_; case atrEvade: - return m_max_evade; + return max_evade_; case atrTotal: throw wexception("Unknown attribute value!"); } @@ -153,7 +153,7 @@ int32_t TrainingSiteDescr::get_max_stall() const { - return m_max_stall; + return max_stall_; } void TrainingSiteDescr::add_training_inputs( @@ -188,18 +188,18 @@ TrainingSite::TrainingSite(const TrainingSiteDescr & d) : ProductionSite (d), -m_soldier_request(nullptr), -m_capacity (descr().get_max_number_of_soldiers()), -m_build_heroes (false), -m_result (Failed) +soldier_request_(nullptr), +capacity_ (descr().get_max_number_of_soldiers()), +build_heroes_ (false), +result_ (Failed) { // Initialize this in the constructor so that loading code may // overwrite priorities. calc_upgrades(); - m_current_upgrade = nullptr; + current_upgrade_ = nullptr; set_post_timer(6000); - training_failure_count.clear(); - max_stall_val = training_state_multiplier * d.get_max_stall(); + training_failure_count_.clear(); + max_stall_val_ = training_state_multiplier_ * d.get_max_stall(); if (d.get_train_hp()) init_kick_state(atrHP, d); @@ -228,7 +228,7 @@ upcast(Game, game, &egbase); - for (Soldier * soldier : m_soldiers) { + for (Soldier * soldier : soldiers_) { soldier->set_location_initially(*this); assert(!soldier->get_state()); // Should be newly created. @@ -249,8 +249,8 @@ { ProductionSite::set_economy(e); - if (m_soldier_request) - m_soldier_request->set_economy(e); + if (soldier_request_) + soldier_request_->set_economy(e); } /** @@ -260,8 +260,8 @@ */ void TrainingSite::cleanup(EditorGameBase & egbase) { - delete m_soldier_request; - m_soldier_request = nullptr; + delete soldier_request_; + soldier_request_ = nullptr; ProductionSite::cleanup(egbase); } @@ -275,9 +275,9 @@ // Note that the given Soldier might already be in the array // for loadgames. if - (std::find(m_soldiers.begin(), m_soldiers.end(), soldier) == - m_soldiers.end()) - m_soldiers.push_back(soldier); + (std::find(soldiers_.begin(), soldiers_.end(), soldier) == + soldiers_.end()) + soldiers_.push_back(soldier); if (upcast(Game, game, &owner().egbase())) schedule_act(*game, 100); @@ -290,9 +290,9 @@ if (upcast(Soldier, soldier, &w)) { std::vector<Soldier *>::iterator const it = - std::find(m_soldiers.begin(), m_soldiers.end(), soldier); - if (it != m_soldiers.end()) { - m_soldiers.erase(it); + std::find(soldiers_.begin(), soldiers_.end(), soldier); + if (it != soldiers_.end()) { + soldiers_.erase(it); if (game) schedule_act(*game, 100); @@ -307,9 +307,9 @@ * Request soldiers up to capacity, or let go of surplus soldiers. */ void TrainingSite::update_soldier_request() { - if (m_soldiers.size() < m_capacity) { - if (!m_soldier_request) { - m_soldier_request = + if (soldiers_.size() < capacity_) { + if (!soldier_request_) { + soldier_request_ = new Request (*this, owner().tribe().soldier(), @@ -344,16 +344,16 @@ descr().get_min_level(atrHP), descr().get_max_level(atrHP))); - m_soldier_request->set_requirements(r); + soldier_request_->set_requirements(r); } - m_soldier_request->set_count(m_capacity - m_soldiers.size()); - } else if (m_soldiers.size() >= m_capacity) { - delete m_soldier_request; - m_soldier_request = nullptr; + soldier_request_->set_count(capacity_ - soldiers_.size()); + } else if (soldiers_.size() >= capacity_) { + delete soldier_request_; + soldier_request_ = nullptr; - while (m_soldiers.size() > m_capacity) { - drop_soldier(**m_soldiers.rbegin()); + while (soldiers_.size() > capacity_) { + drop_soldier(**soldiers_.rbegin()); } } } @@ -378,7 +378,7 @@ Soldier& s = dynamic_cast<Soldier&>(*w); assert(s.get_location(game) == &tsite); - assert(tsite.m_soldier_request == &rq); + assert(tsite.soldier_request_ == &rq); tsite.incorporate_soldier(game, s); } @@ -411,12 +411,12 @@ std::vector<Soldier *> TrainingSite::present_soldiers() const { - return m_soldiers; + return soldiers_; } std::vector<Soldier *> TrainingSite::stationed_soldiers() const { - return m_soldiers; + return soldiers_; } uint32_t TrainingSite::min_soldier_capacity() const { @@ -427,14 +427,14 @@ } uint32_t TrainingSite::soldier_capacity() const { - return m_capacity; + return capacity_; } void TrainingSite::set_soldier_capacity(uint32_t const capacity) { assert(min_soldier_capacity() <= capacity); assert (capacity <= max_soldier_capacity()); - assert(m_capacity != capacity); - m_capacity = capacity; + assert(capacity_ != capacity); + capacity_ = capacity; update_soldier_request(); } @@ -452,13 +452,13 @@ Game & game = dynamic_cast<Game&>(owner().egbase()); std::vector<Soldier *>::iterator it = - std::find(m_soldiers.begin(), m_soldiers.end(), &soldier); - if (it == m_soldiers.end()) { + std::find(soldiers_.begin(), soldiers_.end(), &soldier); + if (it == soldiers_.end()) { molog("TrainingSite::drop_soldier: soldier not in training site"); return; } - m_soldiers.erase(it); + soldiers_.erase(it); soldier.reset_tasks(game); soldier.start_task_leavebuilding(game, true); @@ -476,16 +476,16 @@ { std::vector<Soldier *> droplist; - for (uint32_t i = 0; i < m_soldiers.size(); ++i) { - std::vector<Upgrade>::iterator it = m_upgrades.begin(); - for (; it != m_upgrades.end(); ++it) { - int32_t level = m_soldiers[i]->get_level(it->attribute); + for (uint32_t i = 0; i < soldiers_.size(); ++i) { + std::vector<Upgrade>::iterator it = upgrades_.begin(); + for (; it != upgrades_.end(); ++it) { + int32_t level = soldiers_[i]->get_level(it->attribute); if (level >= it->min && level <= it->max) break; } - if (it == m_upgrades.end()) - droplist.push_back(m_soldiers[i]); + if (it == upgrades_.end()) + droplist.push_back(soldiers_[i]); } // Drop soldiers only now, so that changes in the soldiers array don't @@ -504,9 +504,9 @@ Soldier * soldier_to_drop = nullptr; uint32_t highest_soldier_level_seen = 0; - for (uint32_t i = 0; i < m_soldiers.size(); ++i) + for (uint32_t i = 0; i < soldiers_.size(); ++i) { - uint32_t this_soldier_level = m_soldiers[i]->get_level(atrTotal); + uint32_t this_soldier_level = soldiers_[i]->get_level(atrTotal); bool this_soldier_is_safe = false; if (this_soldier_level <= highest_soldier_level_seen) @@ -517,14 +517,14 @@ } else { - for (const Upgrade& upgrade: m_upgrades) + for (const Upgrade& upgrade: upgrades_) if (! this_soldier_is_safe) { // Soldier is safe, if he: // - is below maximum, and // - is not in a stalled state // Check done separately for each art. - int32_t level = m_soldiers[i]->get_level(upgrade.attribute); + int32_t level = soldiers_[i]->get_level(upgrade.attribute); // Below maximum -check if (level > upgrade.max) @@ -533,8 +533,8 @@ } TypeAndLevel train_tl(upgrade.attribute, level); - TrainFailCount::iterator tstep = training_failure_count.find(train_tl); - if (tstep == training_failure_count.end()) + TrainFailCount::iterator tstep = training_failure_count_.find(train_tl); + if (tstep == training_failure_count_.end()) { log("\nTrainingSite::drop_stalled_soldiers: "); log("training step %d,%d not found in this school!\n", upgrade.attribute, level); @@ -544,7 +544,7 @@ tstep->second.second = 1; // a soldier is present at this level // Stalled state -check - if (max_stall_val > tstep->second.first) + if (max_stall_val_ > tstep->second.first) { this_soldier_is_safe = true; break; @@ -554,7 +554,7 @@ if (!this_soldier_is_safe) { // Make this soldier a kick-out candidate - soldier_to_drop = m_soldiers[i]; + soldier_to_drop = soldiers_[i]; highest_soldier_level_seen = this_soldier_level; } } @@ -583,7 +583,7 @@ void TrainingSite::program_end(Game & game, ProgramResult const result) { - m_result = result; + result_ = result; ProductionSite::program_end(game, result); // For unknown reasons sometimes there is a fully upgraded soldier // that failed to be send away, so at the end of this function @@ -591,19 +591,19 @@ // function were run bool leftover_soldiers_check = true; - if (m_current_upgrade) { - if (m_result == Completed) { + if (current_upgrade_) { + if (result_ == Completed) { drop_unupgradable_soldiers(game); leftover_soldiers_check = false; - m_current_upgrade->lastsuccess = true; - m_current_upgrade->failures = 0; + current_upgrade_->lastsuccess = true; + current_upgrade_->failures = 0; } else { - m_current_upgrade->failures++; + current_upgrade_->failures++; drop_stalled_soldiers(game); leftover_soldiers_check = false; } - m_current_upgrade = nullptr; + current_upgrade_ = nullptr; } if (leftover_soldiers_check) { @@ -627,7 +627,7 @@ uint32_t maxprio = 0; uint32_t maxcredit = 0; - for (Upgrade& upgrade : m_upgrades) { + for (Upgrade& upgrade : upgrades_) { if (upgrade.credit >= 10) { upgrade.credit -= 10; return start_upgrade(game, upgrade); @@ -645,7 +645,7 @@ uint32_t const multiplier = 1 + (10 - maxcredit) / maxprio; - for (Upgrade& upgrade : m_upgrades) { + for (Upgrade& upgrade : upgrades_) { upgrade.credit += multiplier * upgrade.prio; } } @@ -661,7 +661,7 @@ int32_t minlevel = upgrade.max; int32_t maxlevel = upgrade.min; - for (Soldier * soldier : m_soldiers) { + for (Soldier * soldier : soldiers_) { int32_t const level = soldier->get_level(upgrade.attribute); if (level > upgrade.max || level < upgrade.min) @@ -680,7 +680,7 @@ if (upgrade.lastsuccess || upgrade.lastattempt < 0) { // Start greedily on the first ever attempt, and restart greedily // after a sucessful upgrade - if (m_build_heroes) + if (build_heroes_) level = maxlevel; else level = minlevel; @@ -688,7 +688,7 @@ // The last attempt wasn't successful; // This happens e.g. when lots of low-level soldiers are present, // but the prerequisites for improving them aren't. - if (m_build_heroes) { + if (build_heroes_) { level = upgrade.lastattempt - 1; if (level < minlevel) level = maxlevel; @@ -699,7 +699,7 @@ } } - m_current_upgrade = &upgrade; + current_upgrade_ = &upgrade; upgrade.lastattempt = level; upgrade.lastsuccess = false; @@ -710,7 +710,7 @@ TrainingSite::Upgrade * TrainingSite::get_upgrade(TrainingAttribute const atr) { - for (Upgrade& upgrade : m_upgrades) { + for (Upgrade& upgrade : upgrades_) { if (upgrade.attribute == atr) { return &upgrade; } @@ -724,7 +724,7 @@ */ int32_t TrainingSite::get_pri(TrainingAttribute atr) { - for (const Upgrade& upgrade : m_upgrades) { + for (const Upgrade& upgrade : upgrades_) { if (upgrade.attribute == atr) { return upgrade.prio; } @@ -740,7 +740,7 @@ if (prio < 0) prio = 0; - for (Upgrade& upgrade : m_upgrades) { + for (Upgrade& upgrade : upgrades_) { if (upgrade.attribute == atr) { upgrade.prio = prio; return; @@ -764,14 +764,14 @@ u.lastattempt = -1; u.lastsuccess = false; u.failures = 0; - m_upgrades.push_back(u); + upgrades_.push_back(u); } /** - * Called once at initialization to populate \ref m_upgrades. + * Called once at initialization to populate \ref upgrades_. */ void TrainingSite::calc_upgrades() { - assert(m_upgrades.empty()); + assert(upgrades_.empty()); // TODO(unknown): This is currently hardcoded for "soldier" but it should allow any // soldier type name. @@ -790,10 +790,10 @@ TrainingSite::training_attempted(uint32_t type, uint32_t level) { TypeAndLevel key(type, level); - if (training_failure_count.find(key) == training_failure_count.end()) - training_failure_count[key] = std::make_pair(training_state_multiplier, 0); + if (training_failure_count_.find(key) == training_failure_count_.end()) + training_failure_count_[key] = std::make_pair(training_state_multiplier_, 0); else - training_failure_count[key].first += training_state_multiplier; + training_failure_count_[key].first += training_state_multiplier_; } /** @@ -805,14 +805,14 @@ { TypeAndLevel key(type, level); // Here I assume that key exists: training has been attempted before it can succeed. - training_failure_count[key].first = 0; + training_failure_count_[key].first = 0; } void TrainingSite::training_done() { TrainFailCount::iterator it; - for (it = training_failure_count.begin(); it != training_failure_count.end(); it++) + for (it = training_failure_count_.begin(); it != training_failure_count_.end(); it++) { // If a soldier is present at this training level, deteoriate if (it->second.second) === modified file 'src/logic/map_objects/tribes/trainingsite.h' --- src/logic/map_objects/tribes/trainingsite.h 2016-01-31 15:31:00 +0000 +++ src/logic/map_objects/tribes/trainingsite.h 2016-02-13 14:28:04 +0000 @@ -39,12 +39,12 @@ Building & create_object() const override; uint32_t get_max_number_of_soldiers() const { - return m_num_soldiers; + return num_soldiers_; } - bool get_train_hp () const {return m_train_hp;} - bool get_train_attack () const {return m_train_attack;} - bool get_train_defense() const {return m_train_defense;} - bool get_train_evade () const {return m_train_evade;} + bool get_train_hp () const {return train_hp_;} + bool get_train_attack () const {return train_attack_;} + bool get_train_defense() const {return train_defense_;} + bool get_train_evade () const {return train_evade_;} int32_t get_min_level(TrainingAttribute) const; int32_t get_max_level(TrainingAttribute) const; @@ -85,35 +85,35 @@ // struct and there should be a vector, indexed by Soldier_Index, // with that struct structs as element type. /** Maximum number of soldiers for a training site*/ - uint32_t m_num_soldiers; + uint32_t num_soldiers_; /** Number of rounds w/o successful training, after which a soldier is kicked out.**/ - uint32_t m_max_stall; + uint32_t max_stall_; /** Whether this site can train hitpoints*/ - bool m_train_hp; + bool train_hp_; /** Whether this site can train attack*/ - bool m_train_attack; + bool train_attack_; /** Whether this site can train defense*/ - bool m_train_defense; + bool train_defense_; /** Whether this site can train evasion*/ - bool m_train_evade; + bool train_evade_; /** Minimum hitpoints to which a soldier can drop at this site*/ - int32_t m_min_hp; + int32_t min_hp_; /** Minimum attacks to which a soldier can drop at this site*/ - int32_t m_min_attack; + int32_t min_attack_; /** Minimum defense to which a soldier can drop at this site*/ - int32_t m_min_defense; + int32_t min_defense_; /** Minimum evasion to which a soldier can drop at this site*/ - int32_t m_min_evade; + int32_t min_evade_; /** Maximum hitpoints a soldier can acquire at this site*/ - int32_t m_max_hp; + int32_t max_hp_; /** Maximum attack a soldier can acquire at this site*/ - int32_t m_max_attack; + int32_t max_attack_; /** Maximum defense a soldier can acquire at this site*/ - int32_t m_max_defense; + int32_t max_defense_; /** Maximum evasion a soldier can acquire at this site*/ - int32_t m_max_evade; + int32_t max_evade_; // For building help std::vector<std::vector<std::string>> food_hp_; @@ -125,8 +125,6 @@ std::vector<std::string> weapons_defense_; std::vector<std::string> weapons_evade_; - // Re-use of m_inputs to get the resources - // TrainingMap m_programs; DISALLOW_COPY_AND_ASSIGN(TrainingSiteDescr); }; @@ -167,14 +165,14 @@ void remove_worker(Worker &) override; bool get_build_heroes() { - return m_build_heroes; + return build_heroes_; } void set_build_heroes(bool b_heroes) { - m_build_heroes = b_heroes; + build_heroes_ = b_heroes; } void switch_heroes() { - m_build_heroes = !m_build_heroes; - molog("BUILD_HEROES: %s", m_build_heroes ? "TRUE" : "FALSE"); + build_heroes_ = !build_heroes_; + molog("BUILD_HEROES: %s", build_heroes_ ? "TRUE" : "FALSE"); } void set_economy(Economy * e) override; @@ -217,38 +215,37 @@ void drop_stalled_soldiers(Game &); Upgrade * get_upgrade(TrainingAttribute); -private: /// Open requests for soldiers. The soldiers can be under way or unavailable - Request * m_soldier_request; + Request * soldier_request_; /** The soldiers currently at the training site*/ - std::vector<Soldier *> m_soldiers; + std::vector<Soldier *> soldiers_; /** Number of soldiers that should be trained concurrently. * Equal or less to maximum number of soldiers supported by a training site. - * There is no guarantee there really are m_capacity soldiers in the + * There is no guarantee there really are capacity_ soldiers in the * building - some of them might still be under way or even not yet * available*/ - uint32_t m_capacity; + uint32_t capacity_; /** True, \b always upgrade already experienced soldiers first, when possible * False, \b always upgrade inexperienced soldiers first, when possible */ - bool m_build_heroes; - - std::vector<Upgrade> m_upgrades; - Upgrade * m_current_upgrade; - - ProgramResult m_result; /// The result of the last training program. + bool build_heroes_; + + std::vector<Upgrade> upgrades_; + Upgrade * current_upgrade_; + + ProgramResult result_; /// The result of the last training program. // These are used for kicking out soldiers prematurely - static const uint32_t training_state_multiplier; + static const uint32_t training_state_multiplier_; // Unuque key to address each training level of each war art using TypeAndLevel = std::pair<uint16_t, uint16_t>; // First entry is the "stallness", second is a bool using FailAndPresence = std::pair<uint16_t, uint8_t>; // first might wrap in a long play.. using TrainFailCount = std::map<TypeAndLevel, FailAndPresence>; - TrainFailCount training_failure_count; - uint32_t max_stall_val; + TrainFailCount training_failure_count_; + uint32_t max_stall_val_; void init_kick_state(const TrainingAttribute&, const TrainingSiteDescr&); === modified file 'src/logic/map_objects/tribes/tribe_descr.cc' --- src/logic/map_objects/tribes/tribe_descr.cc 2016-01-28 05:24:34 +0000 +++ src/logic/map_objects/tribes/tribe_descr.cc 2016-02-13 14:28:04 +0000 @@ -56,7 +56,7 @@ : name_(table.get_string("name")), descname_(info.descname), tribes_(init_tribes) { try { - m_initializations = info.initializations; + initializations_ = info.initializations; std::unique_ptr<LuaTable> items_table = table.get_table("animations"); frontier_animation_id_ = g_gr->animations().load(*items_table->get_table("frontier")); === modified file 'src/logic/map_objects/tribes/tribe_descr.h' --- src/logic/map_objects/tribes/tribe_descr.h 2016-01-24 20:11:53 +0000 +++ src/logic/map_objects/tribes/tribe_descr.h 2016-02-13 14:28:04 +0000 @@ -126,7 +126,7 @@ // Returns the initalization at 'index' (which must not be out of bounds). const TribeBasicInfo::Initialization& initialization(const uint8_t index) const { - return m_initializations.at(index); + return initializations_.at(index); } using WaresOrder = std::vector<std::vector<Widelands::DescriptionIndex>>; @@ -184,7 +184,7 @@ WaresOrder workers_order_; WaresOrderCoords workers_order_coords_; - std::vector<TribeBasicInfo::Initialization> m_initializations; + std::vector<TribeBasicInfo::Initialization> initializations_; DISALLOW_COPY_AND_ASSIGN(TribeDescr); }; === modified file 'src/logic/map_objects/tribes/warehouse.cc' --- src/logic/map_objects/tribes/warehouse.cc 2016-02-13 11:25:41 +0000 +++ src/logic/map_objects/tribes/warehouse.cc 2016-02-13 14:28:04 +0000 @@ -255,13 +255,13 @@ WarehouseDescr::WarehouseDescr (const std::string& init_descname, const LuaTable& table, const EditorGameBase& egbase) : BuildingDescr(init_descname, MapObjectType::WAREHOUSE, table, egbase), - m_conquers (0), - m_heal_per_second (0) + conquers_ (0), + heal_per_second_ (0) { - m_heal_per_second = table.get_int("heal_per_second"); + heal_per_second_ = table.get_int("heal_per_second"); if (table.has_key("conquers")) { - m_conquers = table.get_int("conquers"); - workarea_info_[m_conquers].insert(descname() + " conquer"); + conquers_ = table.get_int("conquers"); + workarea_info_[conquers_].insert(descname() + " conquer"); } } @@ -273,18 +273,18 @@ Warehouse::Warehouse(const WarehouseDescr & warehouse_descr) : Building(warehouse_descr), - m_supply(new WarehouseSupply(this)), - m_next_military_act(0), + supply_(new WarehouseSupply(this)), + next_military_act_(0), portdock_(nullptr) { - m_next_stock_remove_act = 0; + next_stock_remove_act_ = 0; cleanup_in_progress_ = false; } Warehouse::~Warehouse() { - delete m_supply; + delete supply_; } /** @@ -295,7 +295,7 @@ { const TribeDescr& tribe = owner().tribe(); - if (pw.index == INVALID_INDEX || !(pw.index < m_supply->get_workers().get_nrwareids())) { + if (pw.index == INVALID_INDEX || !(pw.index < supply_->get_workers().get_nrwareids())) { return false; } @@ -305,7 +305,7 @@ return false; } - if (!(pw.index < m_supply->get_workers().get_nrwareids())) { + if (!(pw.index < supply_->get_workers().get_nrwareids())) { return false; } @@ -380,12 +380,12 @@ DescriptionIndex const worker_index = worker_types_without_cost.at(--i); if (owner().is_worker_type_allowed(worker_index) && - m_next_worker_without_cost_spawn[i] == never()) + next_worker_without_cost_spawn_[i] == never()) { if (next_spawn == never()) { next_spawn = schedule_act(dynamic_cast<Game&>(egbase), WORKER_WITHOUT_COST_SPAWN_INTERVAL); } - m_next_worker_without_cost_spawn[i] = next_spawn; + next_worker_without_cost_spawn_[i] = next_spawn; log ("WARNING: player %u is allowed to create worker type %s but his " "%s %u at (%i, %i) does not have a next_spawn time set for that " @@ -400,10 +400,10 @@ // Ensure consistency of PlannedWorker requests { uint32_t pwidx = 0; - while (pwidx < m_planned_workers.size()) { - if (!_load_finish_planned_worker(m_planned_workers[pwidx])) { - m_planned_workers[pwidx].cleanup(); - m_planned_workers.erase(m_planned_workers.begin() + pwidx); + while (pwidx < planned_workers_.size()) { + if (!_load_finish_planned_worker(planned_workers_[pwidx])) { + planned_workers_[pwidx].cleanup(); + planned_workers_.erase(planned_workers_.begin() + pwidx); } else { pwidx++; } @@ -435,16 +435,16 @@ for (size_t i = 0; i < worker_types_without_cost.size(); ++i) { if (owner().is_worker_type_allowed(worker_types_without_cost.at(i))) { - m_next_worker_without_cost_spawn[i] = act_time; + next_worker_without_cost_spawn_[i] = act_time; } } } - // m_next_military_act is not touched in the loading code. Is only needed + // next_military_act_ is not touched in the loading code. Is only needed // if the warehouse is created in the game? I assume it's for the // conquer_radius thing - m_next_military_act = schedule_act(*game, 1000); + next_military_act_ = schedule_act(*game, 1000); - m_next_stock_remove_act = schedule_act(*game, 4000); + next_stock_remove_act_ = schedule_act(*game, 4000); log("Message: adding %s for player %i at (%d, %d)\n", to_string(descr().type()).c_str(), player.player_number(), position_.x, position_.y); @@ -501,14 +501,14 @@ void Warehouse::init_containers(Player& player) { DescriptionIndex const nr_wares = player.egbase().tribes().nrwares(); DescriptionIndex const nr_workers = player.egbase().tribes().nrworkers(); - m_supply->set_nrwares(nr_wares); - m_supply->set_nrworkers(nr_workers); + supply_->set_nrwares(nr_wares); + supply_->set_nrworkers(nr_workers); - m_ware_policy.resize(nr_wares, SP_Normal); - m_worker_policy.resize(nr_workers, SP_Normal); + ware_policy_.resize(nr_wares, SP_Normal); + worker_policy_.resize(nr_workers, SP_Normal); uint8_t nr_worker_types_without_cost = player.tribe().worker_types_without_cost().size(); - m_next_worker_without_cost_spawn.resize(nr_worker_types_without_cost, never()); + next_worker_without_cost_spawn_.resize(nr_worker_types_without_cost, never()); } /** @@ -603,7 +603,7 @@ for (uint32_t i = 0; i < stock; ++i) { launch_worker(*game, id, Requirements()).start_task_leavebuilding(*game, true); } - assert(!m_incorporated_workers.count(id) || m_incorporated_workers[id].empty()); + assert(!incorporated_workers_.count(id) || incorporated_workers_[id].empty()); } else { @@ -612,11 +612,11 @@ } } } - m_incorporated_workers.clear(); + incorporated_workers_.clear(); - while (!m_planned_workers.empty()) { - m_planned_workers.back().cleanup(); - m_planned_workers.pop_back(); + while (!planned_workers_.empty()) { + planned_workers_.back().cleanup(); + planned_workers_.pop_back(); } Map& map = egbase.map(); @@ -650,10 +650,10 @@ const std::vector<DescriptionIndex> & worker_types_without_cost = owner().tribe().worker_types_without_cost(); for (size_t i = worker_types_without_cost.size(); i;) - if (m_next_worker_without_cost_spawn[--i] <= gametime) { + if (next_worker_without_cost_spawn_[--i] <= gametime) { DescriptionIndex const id = worker_types_without_cost.at(i); if (owner().is_worker_type_allowed(id)) { - int32_t const stock = m_supply->stock_workers(id); + int32_t const stock = supply_->stock_workers(id); int32_t tdelta = WORKER_WITHOUT_COST_SPAWN_INTERVAL; if (stock < 100) { @@ -666,19 +666,19 @@ remove_workers(id, 1); } - m_next_worker_without_cost_spawn[i] = + next_worker_without_cost_spawn_[i] = schedule_act(game, tdelta); } else - m_next_worker_without_cost_spawn[i] = never(); + next_worker_without_cost_spawn_[i] = never(); } } // Military stuff: Kill the soldiers that are dead. - if (m_next_military_act <= gametime) { + if (next_military_act_ <= gametime) { DescriptionIndex const soldier_index = owner().tribe().soldier(); - if (m_incorporated_workers.count(soldier_index)) { - WorkerList & soldiers = m_incorporated_workers[soldier_index]; + if (incorporated_workers_.count(soldier_index)) { + WorkerList & soldiers = incorporated_workers_[soldier_index]; uint32_t total_heal = descr().get_heal_per_second(); // Using an explicit iterator, as we plan to erase some @@ -695,7 +695,7 @@ // Soldier dead ... if (!soldier || soldier->get_current_hitpoints() == 0) { it = soldiers.erase(it); - m_supply->remove_workers(soldier_index, 1); + supply_->remove_workers(soldier_index, 1); continue; } @@ -706,13 +706,13 @@ } } - m_next_military_act = schedule_act(game, 1000); + next_military_act_ = schedule_act(game, 1000); } - if (static_cast<int32_t>(m_next_stock_remove_act - gametime) <= 0) { + if (static_cast<int32_t>(next_stock_remove_act_ - gametime) <= 0) { check_remove_stock(game); - m_next_stock_remove_act = schedule_act(game, 4000); + next_stock_remove_act_ = schedule_act(game, 4000); } // Update planned workers; this is to update the request amounts and @@ -738,10 +738,10 @@ if (portdock_) portdock_->set_economy(e); - m_supply->set_economy(e); + supply_->set_economy(e); Building::set_economy(e); - for (const PlannedWorkers& pw : m_planned_workers) { + for (const PlannedWorkers& pw : planned_workers_) { for (Request * req : pw.requests) { req->set_economy(e); } @@ -757,20 +757,20 @@ const WareList & Warehouse::get_wares() const { - return m_supply->get_wares(); + return supply_->get_wares(); } const WareList & Warehouse::get_workers() const { - return m_supply->get_workers(); + return supply_->get_workers(); } PlayerImmovable::Workers Warehouse::get_incorporated_workers() { PlayerImmovable::Workers all_workers; - for (const std::pair<DescriptionIndex, WorkerList>& worker_pair : m_incorporated_workers) { + for (const std::pair<DescriptionIndex, WorkerList>& worker_pair : incorporated_workers_) { for (Worker * worker : worker_pair.second) { all_workers.push_back(worker); } @@ -782,28 +782,28 @@ /// Magically create wares in this warehouse. Updates the economy accordingly. void Warehouse::insert_wares(DescriptionIndex const id, uint32_t const count) { - m_supply->add_wares(id, count); + supply_->add_wares(id, count); } /// Magically destroy wares. void Warehouse::remove_wares(DescriptionIndex const id, uint32_t const count) { - m_supply->remove_wares(id, count); + supply_->remove_wares(id, count); } /// Magically create workers in this warehouse. Updates the economy accordingly. void Warehouse::insert_workers(DescriptionIndex const id, uint32_t const count) { - m_supply->add_workers(id, count); + supply_->add_workers(id, count); } /// Magically destroy workers. void Warehouse::remove_workers(DescriptionIndex const id, uint32_t const count) { - m_supply->remove_workers(id, count); + supply_->remove_workers(id, count); } @@ -813,14 +813,14 @@ { DescriptionIndex const carrierid = owner().tribe().carrier(); - if (!m_supply->stock_workers(carrierid)) + if (!supply_->stock_workers(carrierid)) { if (can_create_worker(game, carrierid)) { create_worker(game, carrierid); } } - if (m_supply->stock_workers(carrierid)) + if (supply_->stock_workers(carrierid)) { launch_worker(game, carrierid, Requirements()).start_task_fetchfromflag(game); } @@ -839,11 +839,11 @@ uint32_t sum = 0; do { - sum += m_supply->stock_workers(ware); + sum += supply_->stock_workers(ware); // NOTE: This code lies about the TrainingAttributes of non-instantiated workers. - if (m_incorporated_workers.count(ware)) { - for (Worker * worker : m_incorporated_workers[ware]) { + if (incorporated_workers_.count(ware)) { + for (Worker * worker : incorporated_workers_[ware]) { if (!req.check(*worker)) { // This is one of the workers in our sum. // But he is too stupid for this job @@ -864,16 +864,16 @@ (Game & game, DescriptionIndex worker_id, const Requirements & req) { do { - if (m_supply->stock_workers(worker_id)) { - uint32_t unincorporated = m_supply->stock_workers(worker_id); + if (supply_->stock_workers(worker_id)) { + uint32_t unincorporated = supply_->stock_workers(worker_id); // look if we got one of those in stock - if (m_incorporated_workers.count(worker_id)) { + if (incorporated_workers_.count(worker_id)) { // On cleanup, it could be that the worker was deleted under // us, so we erase the pointer we had to it and create a new // one. - remove_no_longer_existing_workers(game, &m_incorporated_workers[worker_id]); - WorkerList& incorporated_workers = m_incorporated_workers[worker_id]; + remove_no_longer_existing_workers(game, &incorporated_workers_[worker_id]); + WorkerList& incorporated_workers = incorporated_workers_[worker_id]; for (std::vector<Worker *>::iterator worker_iter = incorporated_workers.begin(); worker_iter != incorporated_workers.end(); ++worker_iter) @@ -886,18 +886,18 @@ worker->set_location(this); // back in a economy incorporated_workers.erase(worker_iter); - m_supply->remove_workers(worker_id, 1); + supply_->remove_workers(worker_id, 1); return *worker; } } } - assert(unincorporated <= m_supply->stock_workers(worker_id)); + assert(unincorporated <= supply_->stock_workers(worker_id)); if (unincorporated) { // Create a new one // NOTE: This code lies about the TrainingAttributes of the new worker - m_supply->remove_workers(worker_id, 1); + supply_->remove_workers(worker_id, 1); const WorkerDescr & workerdescr = *game.tribes().get_worker_descr(worker_id); return workerdescr.create(game, owner(), this, position_); } @@ -926,7 +926,7 @@ DescriptionIndex worker_index = owner().tribe().worker_index(w->descr().name().c_str()); - m_supply->add_workers(worker_index, 1); + supply_->add_workers(worker_index, 1); // We remove carriers, but we keep other workers around. // TODO(unknown): Remove all workers that do not have properties such as experience. @@ -942,9 +942,9 @@ } // Incorporate the worker - if (!m_incorporated_workers.count(worker_index)) - m_incorporated_workers[worker_index] = std::vector<Worker *>(); - m_incorporated_workers[worker_index].push_back(w); + if (!incorporated_workers_.count(worker_index)) + incorporated_workers_[worker_index] = std::vector<Worker *>(); + incorporated_workers_[worker_index].push_back(w); w->set_location(nullptr); // no longer in an economy @@ -963,7 +963,7 @@ ware.init(game); if (do_launch_ware(game, ware)) { - m_supply->remove_wares(ware_index, 1); + supply_->remove_wares(ware_index, 1); } return ware; } @@ -975,14 +975,14 @@ // Create a carrier const DescriptionIndex carrierid = owner().tribe().carrier(); - if (!m_supply->stock_workers(carrierid)) + if (!supply_->stock_workers(carrierid)) { if (can_create_worker(game, carrierid)) { create_worker(game, carrierid); } } - if (m_supply->stock_workers(carrierid)) + if (supply_->stock_workers(carrierid)) { Widelands::Worker & worker = launch_worker(game, carrierid, Requirements()); // Setup the carrier @@ -997,7 +997,7 @@ void Warehouse::incorporate_ware(EditorGameBase & egbase, WareInstance* ware) { - m_supply->add_wares(ware->descr_index(), 1); + supply_->add_wares(ware->descr_index(), 1); ware->destroy(egbase); } @@ -1015,7 +1015,7 @@ if (w) { w->schedule_incorporate(game); } else { - wh.m_supply->add_wares(ware, 1); + wh.supply_->add_wares(ware, 1); // This ware may be used to build planned workers, // so it seems like a good idea to update the associated requests @@ -1029,7 +1029,7 @@ */ void Warehouse::receive_ware(Game & /* game */, DescriptionIndex ware) { - m_supply->add_wares(ware, 1); + supply_->add_wares(ware, 1); } /** @@ -1048,10 +1048,10 @@ bool Warehouse::can_create_worker(Game &, DescriptionIndex const worker) const { assert(owner().tribe().has_worker(worker)); - if (!(worker < m_supply->get_workers().get_nrwareids())) + if (!(worker < supply_->get_workers().get_nrwareids())) throw wexception ("worker type %d does not exists (max is %d)", - worker, m_supply->get_workers().get_nrwareids()); + worker, supply_->get_workers().get_nrwareids()); const WorkerDescr& w_desc = *owner().tribe().get_worker_descr(worker); assert(&w_desc); @@ -1064,13 +1064,13 @@ const std::string & input_name = buildcost.first; DescriptionIndex id_w = owner().tribe().ware_index(input_name); if (owner().tribe().has_ware(id_w)) { - if (m_supply->stock_wares(id_w) < buildcost.second) { + if (supply_->stock_wares(id_w) < buildcost.second) { return false; } } else { id_w = owner().tribe().worker_index(input_name); if (owner().tribe().has_worker(id_w)) { - if (m_supply->stock_workers(id_w) < buildcost.second) { + if (supply_->stock_workers(id_w) < buildcost.second) { return false; } } else @@ -1107,7 +1107,7 @@ // may have been called directly by the Economy. // Do not update anything else about PlannedWorkers here, because this // function is called by _update_planned_workers, so avoid recursion - for (PlannedWorkers& planned_worker : m_planned_workers) { + for (PlannedWorkers& planned_worker : planned_workers_) { if (planned_worker.index == worker && planned_worker.amount) planned_worker.amount--; } @@ -1119,7 +1119,7 @@ */ uint32_t Warehouse::get_planned_workers(Game & /* game */, DescriptionIndex index) const { - for (const PlannedWorkers& pw : m_planned_workers) { + for (const PlannedWorkers& pw : planned_workers_) { if (pw.index == index) return pw.amount; } @@ -1154,7 +1154,7 @@ } } - for (const PlannedWorkers& pw : m_planned_workers) { + for (const PlannedWorkers& pw : planned_workers_) { if (pw.index == index) { assert(available.size() == pw.requests.size()); @@ -1176,7 +1176,7 @@ { PlannedWorkers * pw = nullptr; - for (PlannedWorkers& planned_worker : m_planned_workers) { + for (PlannedWorkers& planned_worker : planned_workers_) { if (planned_worker.index == index) { pw = &planned_worker; break; @@ -1187,8 +1187,8 @@ if (!amount) return; - m_planned_workers.push_back(PlannedWorkers()); - pw = &m_planned_workers.back(); + planned_workers_.push_back(PlannedWorkers()); + pw = &planned_workers_.back(); pw->index = index; pw->amount = 0; @@ -1239,11 +1239,11 @@ DescriptionIndex id_w = owner().tribe().ware_index(input_name); if (owner().tribe().has_ware(id_w)) { - supply = m_supply->stock_wares(id_w); + supply = supply_->stock_wares(id_w); } else { id_w = owner().tribe().worker_index(input_name); if (owner().tribe().has_worker(id_w)) { - supply = m_supply->stock_workers(id_w); + supply = supply_->stock_workers(id_w); } else throw wexception ("_update_planned_workers: bad buildcost '%s'", input_name.c_str()); @@ -1271,12 +1271,12 @@ void Warehouse::_update_all_planned_workers(Game & game) { uint32_t idx = 0; - while (idx < m_planned_workers.size()) { - _update_planned_workers(game, m_planned_workers[idx]); + while (idx < planned_workers_.size()) { + _update_planned_workers(game, planned_workers_[idx]); - if (!m_planned_workers[idx].amount) { - m_planned_workers[idx].cleanup(); - m_planned_workers.erase(m_planned_workers.begin() + idx); + if (!planned_workers_[idx].amount) { + planned_workers_[idx].cleanup(); + planned_workers_.erase(planned_workers_.begin() + idx); } else { idx++; } @@ -1286,14 +1286,14 @@ void Warehouse::enable_spawn (Game & game, uint8_t const worker_types_without_cost_index) { - assert(m_next_worker_without_cost_spawn[worker_types_without_cost_index] == never()); - m_next_worker_without_cost_spawn[worker_types_without_cost_index] = + assert(next_worker_without_cost_spawn_[worker_types_without_cost_index] == never()); + next_worker_without_cost_spawn_[worker_types_without_cost_index] = schedule_act(game, WORKER_WITHOUT_COST_SPAWN_INTERVAL); } void Warehouse::disable_spawn(uint8_t const worker_types_without_cost_index) { - assert(m_next_worker_without_cost_spawn[worker_types_without_cost_index] != never()); - m_next_worker_without_cost_spawn[worker_types_without_cost_index] = never(); + assert(next_worker_without_cost_spawn_[worker_types_without_cost_index] != never()); + next_worker_without_cost_spawn_[worker_types_without_cost_index] = never(); } @@ -1362,14 +1362,14 @@ Warehouse::StockPolicy Warehouse::get_ware_policy(DescriptionIndex ware) const { - assert(ware < static_cast<DescriptionIndex>(m_ware_policy.size())); - return m_ware_policy[ware]; + assert(ware < static_cast<DescriptionIndex>(ware_policy_.size())); + return ware_policy_[ware]; } Warehouse::StockPolicy Warehouse::get_worker_policy(DescriptionIndex ware) const { - assert(ware < static_cast<DescriptionIndex>(m_worker_policy.size())); - return m_worker_policy[ware]; + assert(ware < static_cast<DescriptionIndex>(worker_policy_.size())); + return worker_policy_[ware]; } Warehouse::StockPolicy Warehouse::get_stock_policy @@ -1384,15 +1384,15 @@ void Warehouse::set_ware_policy(DescriptionIndex ware, Warehouse::StockPolicy policy) { - assert(ware < static_cast<DescriptionIndex>(m_ware_policy.size())); - m_ware_policy[ware] = policy; + assert(ware < static_cast<DescriptionIndex>(ware_policy_.size())); + ware_policy_[ware] = policy; } void Warehouse::set_worker_policy (DescriptionIndex ware, Warehouse::StockPolicy policy) { - assert(ware < static_cast<DescriptionIndex>(m_worker_policy.size())); - m_worker_policy[ware] = policy; + assert(ware < static_cast<DescriptionIndex>(worker_policy_.size())); + worker_policy_[ware] = policy; } /** @@ -1402,7 +1402,7 @@ void Warehouse::check_remove_stock(Game & game) { if (base_flag().current_wares() < base_flag().total_capacity() / 2) { - for (DescriptionIndex ware = 0; ware < static_cast<DescriptionIndex>(m_ware_policy.size()); ++ware) { + for (DescriptionIndex ware = 0; ware < static_cast<DescriptionIndex>(ware_policy_.size()); ++ware) { if (get_ware_policy(ware) != SP_Remove || !get_wares().stock(ware)) continue; @@ -1411,7 +1411,7 @@ } } - for (DescriptionIndex widx = 0; widx < static_cast<DescriptionIndex>(m_worker_policy.size()); ++widx) { + for (DescriptionIndex widx = 0; widx < static_cast<DescriptionIndex>(worker_policy_.size()); ++widx) { if (get_worker_policy(widx) != SP_Remove || !get_workers().stock(widx)) continue; @@ -1436,9 +1436,9 @@ std::vector<Soldier *> rv; DescriptionIndex const soldier_index = owner().tribe().soldier(); - IncorporatedWorkers::const_iterator sidx = m_incorporated_workers.find(soldier_index); + IncorporatedWorkers::const_iterator sidx = incorporated_workers_.find(soldier_index); - if (sidx != m_incorporated_workers.end()) { + if (sidx != incorporated_workers_.end()) { const WorkerList & soldiers = sidx->second; for (Worker * temp_soldier: soldiers) { @@ -1456,14 +1456,14 @@ int Warehouse::outcorporate_soldier(EditorGameBase & /* egbase */, Soldier & soldier) { DescriptionIndex const soldier_index = owner().tribe().soldier(); - if (m_incorporated_workers.count(soldier_index)) { - WorkerList & soldiers = m_incorporated_workers[soldier_index]; + if (incorporated_workers_.count(soldier_index)) { + WorkerList & soldiers = incorporated_workers_[soldier_index]; WorkerList::iterator i = std::find (soldiers.begin(), soldiers.end(), &soldier); soldiers.erase(i); - m_supply->remove_workers(soldier_index, 1); + supply_->remove_workers(soldier_index, 1); } #ifndef NDEBUG else @@ -1488,7 +1488,7 @@ if (fleet) { molog("* fleet: %u\n", fleet->serial()); molog(" ships: %u, ports: %u\n", fleet->count_ships(), fleet->count_ports()); - molog(" m_act_pending: %s\n", (fleet->get_act_pending())?"true":"false"); + molog(" act_pending: %s\n", (fleet->get_act_pending())?"true":"false"); } else { molog("No fleet?!\n"); } === modified file 'src/logic/map_objects/tribes/warehouse.h' --- src/logic/map_objects/tribes/warehouse.h 2016-02-07 06:10:47 +0000 +++ src/logic/map_objects/tribes/warehouse.h 2016-02-13 14:28:04 +0000 @@ -54,15 +54,15 @@ Building & create_object() const override; - uint32_t get_conquers() const override {return m_conquers;} + uint32_t get_conquers() const override {return conquers_;} uint32_t get_heal_per_second () const { - return m_heal_per_second; + return heal_per_second_; } private: - int32_t m_conquers; - uint32_t m_heal_per_second; + int32_t conquers_; + uint32_t heal_per_second_; DISALLOW_COPY_AND_ASSIGN(WarehouseDescr); }; @@ -122,7 +122,7 @@ /// * Sets a next_spawn time for each buildable worker type without cost /// that the owning player is allowed to create and schedules act for for /// the spawn. - /// * Schedules act for military stuff (and sets m_next_military_act). + /// * Schedules act for military stuff (and sets next_military_act_). /// * Sees the area (since a warehouse is considered to be always occupied). /// * Conquers land if the the warehouse type is configured to do that. /// * Sends a message to the player about the creation of this warehouse. @@ -256,20 +256,20 @@ void _update_planned_workers(Game &, PlannedWorkers & pw); void _update_all_planned_workers(Game &); - WarehouseSupply * m_supply; + WarehouseSupply * supply_; - std::vector<StockPolicy> m_ware_policy; - std::vector<StockPolicy> m_worker_policy; + std::vector<StockPolicy> ware_policy_; + std::vector<StockPolicy> worker_policy_; // Workers who live here at the moment using WorkerList = std::vector<Worker *>; using IncorporatedWorkers = std::map<DescriptionIndex, WorkerList>; - IncorporatedWorkers m_incorporated_workers; - std::vector<Time> m_next_worker_without_cost_spawn; - Time m_next_military_act; - Time m_next_stock_remove_act; + IncorporatedWorkers incorporated_workers_; + std::vector<Time> next_worker_without_cost_spawn_; + Time next_military_act_; + Time next_stock_remove_act_; - std::vector<PlannedWorkers> m_planned_workers; + std::vector<PlannedWorkers> planned_workers_; PortDock * portdock_; === modified file 'src/logic/map_objects/tribes/warelist.cc' --- src/logic/map_objects/tribes/warelist.cc 2015-11-28 22:29:26 +0000 +++ src/logic/map_objects/tribes/warelist.cc 2016-02-13 14:28:04 +0000 @@ -32,9 +32,9 @@ */ WareList::~WareList() { - for (uint32_t id = 0; id < m_wares.size(); ++id) { - if (m_wares[id]) - log("WareList: %i items of %i left.\n", m_wares[id], id); + for (uint32_t id = 0; id < wares_.size(); ++id) { + if (wares_[id]) + log("WareList: %i items of %i left.\n", wares_[id], id); } } @@ -46,10 +46,10 @@ if (!count) return; - if (m_wares.size() <= i) - m_wares.resize(i + 1, 0); - m_wares[i] += count; - assert(m_wares[i] >= count); + if (wares_.size() <= i) + wares_.resize(i + 1, 0); + wares_[i] += count; + assert(wares_[i] >= count); changed(); } @@ -58,11 +58,11 @@ void WareList::add(const WareList & wl) { DescriptionIndex const nr_wares = wl.get_nrwareids(); - if (m_wares.size() < nr_wares) - m_wares.reserve(nr_wares); + if (wares_.size() < nr_wares) + wares_.reserve(nr_wares); for (DescriptionIndex i = 0; i < nr_wares; ++i) - if (wl.m_wares[i]) - add(i, wl.m_wares[i]); + if (wl.wares_[i]) + add(i, wl.wares_[i]); } @@ -73,9 +73,9 @@ if (!count) return; - assert(i < m_wares.size()); - assert(m_wares[i] >= count); - m_wares[i] -= count; + assert(i < wares_.size()); + assert(wares_[i] >= count); + wares_[i] -= count; changed(); } @@ -85,15 +85,15 @@ { DescriptionIndex const nr_wares = wl.get_nrwareids(); for (DescriptionIndex i = 0; i < nr_wares; ++i) - if (wl.m_wares[i]) - remove(i, wl.m_wares[i]); + if (wl.wares_[i]) + remove(i, wl.wares_[i]); } /** * Return the number of wares of a given type stored in this storage. */ WareList::WareCount WareList::stock(DescriptionIndex const id) const { - return id < m_wares.size() ? m_wares[id] : 0; + return id < wares_.size() ? wares_[id] : 0; } @@ -105,10 +105,10 @@ { uint32_t i = 0; - while (i < wl.m_wares.size()) { - const WareCount count = wl.m_wares[i]; - if (i < m_wares.size()) { - if (count != m_wares[i]) + while (i < wl.wares_.size()) { + const WareCount count = wl.wares_[i]; + if (i < wares_.size()) { + if (count != wares_[i]) return false; } else { if (count) // wl2 has 0 stock per definition @@ -117,8 +117,8 @@ ++i; } - while (i < m_wares.size()) { - if (m_wares[i]) // wl1 has 0 stock per definition + while (i < wares_.size()) { + if (wares_[i]) // wl1 has 0 stock per definition return false; ++i; } === modified file 'src/logic/map_objects/tribes/warelist.h' --- src/logic/map_objects/tribes/warelist.h 2015-11-28 22:29:26 +0000 +++ src/logic/map_objects/tribes/warelist.h 2016-02-13 14:28:04 +0000 @@ -38,13 +38,13 @@ WareList() {} ~WareList(); - void clear() {m_wares.clear();} /// Clear the storage + void clear() {wares_.clear();} /// Clear the storage using WareCount = uint32_t; using WareCountVector = std::vector<WareCount>; /// \return Highest possible ware id - DescriptionIndex get_nrwareids() const {return DescriptionIndex(m_wares.size());} + DescriptionIndex get_nrwareids() const {return DescriptionIndex(wares_.size());} void add (DescriptionIndex, WareCount = 1); void add(const WareList &); @@ -53,8 +53,8 @@ WareCount stock(DescriptionIndex) const; void set_nrwares(DescriptionIndex const i) { - assert(m_wares.empty()); - m_wares.resize(i, 0); + assert(wares_.empty()); + wares_.resize(i, 0); } bool operator== (const WareList &) const; @@ -63,7 +63,7 @@ mutable boost::signals2::signal<void ()> changed; private: - WareCountVector m_wares; + WareCountVector wares_; }; } === modified file 'src/logic/map_objects/tribes/worker.cc' --- src/logic/map_objects/tribes/worker.cc 2016-02-07 09:30:20 +0000 +++ src/logic/map_objects/tribes/worker.cc 2016-02-13 14:28:04 +0000 @@ -1021,17 +1021,17 @@ Worker::Worker(const WorkerDescr & worker_descr) : Bob (worker_descr), - m_economy (nullptr), - m_supply (nullptr), - m_transfer (nullptr), - m_current_exp(0) + economy_ (nullptr), + supply_ (nullptr), + transfer_ (nullptr), + current_exp_(0) { } Worker::~Worker() { - assert(!m_location.is_set()); - assert(!m_transfer); + assert(!location_.is_set()); + assert(!transfer_); } @@ -1040,29 +1040,29 @@ { Bob::log_general_info(egbase); - if (upcast(PlayerImmovable, loc, m_location.get(egbase))) { + if (upcast(PlayerImmovable, loc, location_.get(egbase))) { molog("* Owner: (%p)\n", &loc->owner()); molog("** Owner (plrnr): %i\n", loc->owner().player_number()); molog("* Economy: %p\n", loc->get_economy()); } - PlayerImmovable * imm = m_location.get(egbase); + PlayerImmovable * imm = location_.get(egbase); molog("location: %u\n", imm ? imm->serial() : 0); - molog("Economy: %p\n", m_economy); - molog("transfer: %p\n", m_transfer); + molog("Economy: %p\n", economy_); + molog("transfer: %p\n", transfer_); - if (upcast(WareInstance, ware, m_carried_ware.get(egbase))) { + if (upcast(WareInstance, ware, carried_ware_.get(egbase))) { molog - ("* m_carried_ware->get_ware() (id): %i\n", + ("* carried_ware->get_ware() (id): %i\n", ware->descr_index()); - molog("* m_carried_ware->get_economy() (): %p\n", ware->get_economy()); + molog("* carried_ware->get_economy() (): %p\n", ware->get_economy()); } molog - ("m_current_exp: %i / %i\n", - m_current_exp, descr().get_needed_experience()); + ("current_exp: %i / %i\n", + current_exp_, descr().get_needed_experience()); - molog("m_supply: %p\n", m_supply); + molog("supply: %p\n", supply_); } @@ -1076,28 +1076,28 @@ { assert(!location || ObjectPointer(location).get(owner().egbase())); - PlayerImmovable * const oldlocation = get_location(owner().egbase()); - if (oldlocation == location) + PlayerImmovable * const old_location = get_location(owner().egbase()); + if (old_location == location) return; - if (oldlocation) { - // Note: even though we have an oldlocation, m_economy may be zero - // (oldlocation got deleted) - oldlocation->remove_worker(*this); + if (old_location) { + // Note: even though we have an old location, economy_ may be zero + // (old_location got deleted) + old_location->remove_worker(*this); } else { if (!is_shipping()) { - assert(!m_economy); + assert(!economy_); } } - m_location = location; + location_ = location; if (location) { Economy * const eco = location->get_economy(); - if (!m_economy || (descr().type() == MapObjectType::SOLDIER)) { + if (!economy_ || (descr().type() == MapObjectType::SOLDIER)) { set_economy(eco); - } else if (m_economy != eco) { + } else if (economy_ != eco) { throw wexception ("Worker::set_location changes economy, but worker is no soldier"); } @@ -1124,22 +1124,22 @@ */ void Worker::set_economy(Economy * const economy) { - if (economy == m_economy) + if (economy == economy_) return; - if (m_economy) - m_economy->remove_workers + if (economy_) + economy_->remove_workers (owner().tribe().worker_index(descr().name().c_str()), 1); - m_economy = economy; + economy_ = economy; if (WareInstance * const ware = get_carried_ware(owner().egbase())) - ware->set_economy(m_economy); - if (m_supply) - m_supply->set_economy(m_economy); + ware->set_economy(economy_); + if (supply_) + supply_->set_economy(economy_); - if (m_economy) - m_economy->add_workers(owner().tribe().worker_index(descr().name().c_str()), 1); + if (economy_) + economy_->add_workers(owner().tribe().worker_index(descr().name().c_str()), 1); } @@ -1167,9 +1167,9 @@ { WareInstance * const ware = get_carried_ware(egbase); - if (m_supply) { - delete m_supply; - m_supply = nullptr; + if (supply_) { + delete supply_; + supply_ = nullptr; } if (ware) @@ -1204,7 +1204,7 @@ delete oldware; } - m_carried_ware = ware; + carried_ware_ = ware; ware->set_location(egbase, this); if (upcast(Game, game, &egbase)) ware->update(*game); @@ -1220,7 +1220,7 @@ if (ware) { ware->set_location(game, nullptr); - m_carried_ware = nullptr; + carried_ware_ = nullptr; } return ware; @@ -1261,11 +1261,11 @@ void Worker::create_needed_experience(Game & /* game */) { if (descr().get_needed_experience() == INVALID_INDEX) { - m_current_exp = INVALID_INDEX; + current_exp_ = INVALID_INDEX; return; } - m_current_exp = 0; + current_exp_ = 0; } @@ -1278,7 +1278,7 @@ */ DescriptionIndex Worker::gain_experience(Game & game) { return (descr().get_needed_experience() == INVALID_INDEX || - ++m_current_exp < descr().get_needed_experience()) ? + ++current_exp_ < descr().get_needed_experience()) ? INVALID_INDEX : level(game); } @@ -1304,8 +1304,8 @@ assert(t.has_worker(new_index)); // Inform the economy, that something has changed - m_economy->remove_workers(old_index, 1); - m_economy->add_workers (new_index, 1); + economy_->remove_workers(old_index, 1); + economy_->add_workers (new_index, 1); create_needed_experience(game); return old_index; // So that the caller knows what to replace him with. @@ -1354,21 +1354,21 @@ // (in that case, the transfer task already exists on the stack // when this is called). if (get_state(taskGowarehouse) || get_state(taskTransfer)) { - assert(!m_transfer); + assert(!transfer_); - m_transfer = t; + transfer_ = t; send_signal(game, "transfer"); } else { // just start a normal transfer push_task(game, taskTransfer); - m_transfer = t; + transfer_ = t; } } void Worker::transfer_pop(Game & /* game */, State & /* state */) { - if (m_transfer) { - m_transfer->has_failed(); - m_transfer = nullptr; + if (transfer_) { + transfer_->has_failed(); + transfer_ = nullptr; } } @@ -1384,7 +1384,7 @@ } // The request is no longer valid, the task has failed - if (!m_transfer) { + if (!transfer_) { molog("[transfer]: Fail (without transfer)\n"); send_signal(game, "fail"); @@ -1435,12 +1435,12 @@ // Figure out where to go bool success; PlayerImmovable * const nextstep = - m_transfer->get_next_step(location, success); + transfer_->get_next_step(location, success); if (!nextstep) { - Transfer * const t = m_transfer; + Transfer * const t = transfer_; - m_transfer = nullptr; + transfer_ = nullptr; if (success) { pop_task(game); @@ -1550,7 +1550,7 @@ */ void Worker::cancel_task_transfer(Game & game) { - m_transfer = nullptr; + transfer_ = nullptr; send_signal(game, "cancel"); } @@ -1946,7 +1946,7 @@ */ void Worker::start_task_gowarehouse(Game & game) { - assert(!m_supply); + assert(!supply_); push_task(game, taskGowarehouse); } @@ -1978,17 +1978,17 @@ } if (dynamic_cast<Warehouse const *>(location)) { - delete m_supply; - m_supply = nullptr; + delete supply_; + supply_ = nullptr; schedule_incorporate(game); return; } // If we got a transfer, use it - if (m_transfer) { - Transfer * const t = m_transfer; - m_transfer = nullptr; + if (transfer_) { + Transfer * const t = transfer_; + transfer_ = nullptr; molog("[gowarehouse]: Got transfer\n"); @@ -2011,8 +2011,8 @@ // check against disappearing warehouses, or the worker will just // idle on a flag until the end of days (actually, until either the // flag is removed or a warehouse connects to the Economy). - if (!m_supply) - m_supply = new IdleWorkerSupply(*this); + if (!supply_) + supply_ = new IdleWorkerSupply(*this); return start_task_idle(game, descr().get_animation("idle"), 1000); } @@ -2023,19 +2023,19 @@ if (signal == "transfer") { // We are assigned a transfer, make sure our supply disappears immediately // Otherwise, we might receive two transfers in a row. - delete m_supply; - m_supply = nullptr; + delete supply_; + supply_ = nullptr; } } void Worker::gowarehouse_pop(Game &, State &) { - delete m_supply; - m_supply = nullptr; + delete supply_; + supply_ = nullptr; - if (m_transfer) { - m_transfer->has_failed(); - m_transfer = nullptr; + if (transfer_) { + transfer_->has_failed(); + transfer_ = nullptr; } } @@ -2477,16 +2477,16 @@ } struct FindFlagWithPlayersWarehouse { - FindFlagWithPlayersWarehouse(const Player & owner) : m_owner(owner) {} + FindFlagWithPlayersWarehouse(const Player & owner) : owner_(owner) {} bool accept(const BaseImmovable & imm) const { if (upcast(Flag const, flag, &imm)) - if (&flag->owner() == &m_owner) + if (&flag->owner() == &owner_) if (flag->economy().warehouses().size()) return true; return false; } private: - const Player & m_owner; + const Player & owner_; }; void Worker::fugitive_update(Game & game, State & state) @@ -2925,8 +2925,8 @@ constexpr uint8_t kCurrentPacketVersion = 2; Worker::Loader::Loader() : - m_location(0), - m_carried_ware(0) + location_(0), + carried_ware_(0) { } @@ -2938,13 +2938,13 @@ if (packet_version == kCurrentPacketVersion) { Worker & worker = get<Worker>(); - m_location = fr.unsigned_32(); - m_carried_ware = fr.unsigned_32(); - worker.m_current_exp = fr.signed_32(); + location_ = fr.unsigned_32(); + carried_ware_ = fr.unsigned_32(); + worker.current_exp_ = fr.signed_32(); if (fr.unsigned_8()) { - worker.m_transfer = new Transfer(dynamic_cast<Game&>(egbase()), worker); - worker.m_transfer->read(fr, m_transfer); + worker.transfer_ = new Transfer(dynamic_cast<Game&>(egbase()), worker); + worker.transfer_->read(fr, transfer_); } } else { throw UnhandledVersionError("Worker", packet_version, kCurrentPacketVersion); @@ -2960,12 +2960,12 @@ Worker & worker = get<Worker>(); - if (m_location) - worker.set_location(&mol().get<PlayerImmovable>(m_location)); - if (m_carried_ware) - worker.m_carried_ware = &mol().get<WareInstance>(m_carried_ware); - if (worker.m_transfer) - worker.m_transfer->read_pointers(mol(), m_transfer); + if (location_) + worker.set_location(&mol().get<PlayerImmovable>(location_)); + if (carried_ware_) + worker.carried_ware_ = &mol().get<WareInstance>(carried_ware_); + if (worker.transfer_) + worker.transfer_->read_pointers(mol(), transfer_); } void Worker::Loader::load_finish() @@ -2980,7 +2980,7 @@ // us and will do so on load too. To make the order at which we are loaded // not a factor, we do not overwrite the economy they might have set for us // already. - if (PlayerImmovable * const location = worker.m_location.get(egbase())) { + if (PlayerImmovable * const location = worker.location_.get(egbase())) { worker.set_economy(location->get_economy()); } } @@ -3076,13 +3076,13 @@ Bob::save(egbase, mos, fw); fw.unsigned_8(kCurrentPacketVersion); - fw.unsigned_32(mos.get_object_file_index_or_zero(m_location.get(egbase))); - fw.unsigned_32(mos.get_object_file_index_or_zero(m_carried_ware.get(egbase))); - fw.signed_32(m_current_exp); + fw.unsigned_32(mos.get_object_file_index_or_zero(location_.get(egbase))); + fw.unsigned_32(mos.get_object_file_index_or_zero(carried_ware_.get(egbase))); + fw.signed_32(current_exp_); - if (m_transfer) { + if (transfer_) { fw.unsigned_8(1); - m_transfer->write(mos, fw); + transfer_->write(mos, fw); } else { fw.unsigned_8(0); } === modified file 'src/logic/map_objects/tribes/worker.h' --- src/logic/map_objects/tribes/worker.h 2016-02-02 12:38:05 +0000 +++ src/logic/map_objects/tribes/worker.h 2016-02-13 14:28:04 +0000 @@ -43,7 +43,7 @@ * - Work: the worker is running his working schedule */ class Worker : public Bob { - friend class Soldier; // allow access to m_supply + friend class Soldier; // allow access to supply_ friend struct WorkerProgram; friend struct MapBobdataPacket; @@ -80,32 +80,32 @@ Player & owner() const {assert(get_owner()); return *get_owner();} PlayerImmovable * get_location(EditorGameBase & egbase) { - return m_location.get(egbase); + return location_.get(egbase); } - OPtr<PlayerImmovable> get_location() const {return m_location;} - Economy * get_economy() const {return m_economy;} + OPtr<PlayerImmovable> get_location() const {return location_;} + Economy * get_economy() const {return economy_;} /// Sets the location of the worker initially. It may not have a previous /// location. Does not add the worker to the location's set of workers (it /// should be there already). The worker must already be in the same economy /// as the location. void set_location_initially(PlayerImmovable & location) { - assert(!m_location.is_set()); + assert(!location_.is_set()); assert(location.serial()); - assert(m_economy); - assert(m_economy == location.get_economy()); - m_location = &location; + assert(economy_); + assert(economy_ == location.get_economy()); + location_ = &location; } void set_location(PlayerImmovable *); void set_economy(Economy *); WareInstance * get_carried_ware(EditorGameBase & egbase) { - return m_carried_ware.get(egbase); + return carried_ware_.get(egbase); } WareInstance const * get_carried_ware(const EditorGameBase & egbase) const { - return m_carried_ware.get(egbase); + return carried_ware_.get(egbase); } void set_carried_ware(EditorGameBase &, WareInstance *); WareInstance * fetch_carried_ware(EditorGameBase &); @@ -131,7 +131,7 @@ void create_needed_experience(Game &); DescriptionIndex level (Game &); - int32_t get_current_experience() const {return m_current_exp;} + int32_t get_current_experience() const {return current_exp_;} bool needs_experience() const {return descr().get_needed_experience() != INVALID_INDEX;} // debug @@ -140,7 +140,7 @@ // worker-specific tasks void start_task_transfer(Game &, Transfer *); void cancel_task_transfer(Game &); - Transfer * get_transfer() const {return m_transfer;} + Transfer * get_transfer() const {return transfer_;} void start_task_shipping(Game &, PortDock*); void end_shipping(Game &); @@ -175,7 +175,7 @@ void draw(const EditorGameBase &, RenderTarget &, const Point&) const override; void init_auto_task(Game &) override; - bool does_carry_ware() {return m_carried_ware.is_set();} + bool does_carry_ware() {return carried_ware_.is_set();} void set_program_objvar(Game &, State &, MapObject * obj); @@ -242,12 +242,12 @@ bool run_playfx (Game &, State &, const Action &); bool run_construct (Game &, State &, const Action &); - OPtr<PlayerImmovable> m_location; ///< meta location of the worker - Economy * m_economy; ///< economy this worker is registered in - OPtr<WareInstance> m_carried_ware; ///< ware we are carrying - IdleWorkerSupply * m_supply; ///< supply while gowarehouse and not transfer - Transfer * m_transfer; ///< where we are currently being sent - int32_t m_current_exp; ///< current experience + OPtr<PlayerImmovable> location_; ///< meta location of the worker + Economy * economy_; ///< economy this worker is registered in + OPtr<WareInstance> carried_ware_; ///< ware we are carrying + IdleWorkerSupply * supply_; ///< supply while gowarehouse and not transfer + Transfer * transfer_; ///< where we are currently being sent + int32_t current_exp_; ///< current experience // saving and loading protected: @@ -264,9 +264,9 @@ const BobProgramBase * get_program(const std::string & name) override; private: - uint32_t m_location; - uint32_t m_carried_ware; - Transfer::ReadData m_transfer; + uint32_t location_; + uint32_t carried_ware_; + Transfer::ReadData transfer_; }; virtual Loader * create_loader(); === modified file 'src/map_io/map_buildingdata_packet.cc' --- src/map_io/map_buildingdata_packet.cc 2016-02-09 08:07:48 +0000 +++ src/map_io/map_buildingdata_packet.cc 2016-02-13 14:28:04 +0000 @@ -365,7 +365,7 @@ } } - assert(warehouse.m_incorporated_workers.empty()); + assert(warehouse.incorporated_workers_.empty()); { uint16_t const nrworkers = fr.unsigned_16(); for (uint16_t i = 0; i < nrworkers; ++i) { @@ -374,9 +374,9 @@ try { Worker & worker = mol.get<Worker>(worker_serial); const DescriptionIndex& worker_index = tribe.worker_index(worker.descr().name().c_str()); - if (!warehouse.m_incorporated_workers.count(worker_index)) - warehouse.m_incorporated_workers[worker_index] = std::vector<Worker *>(); - warehouse.m_incorporated_workers[worker_index].push_back(&worker); + if (!warehouse.incorporated_workers_.count(worker_index)) + warehouse.incorporated_workers_[worker_index] = std::vector<Worker *>(); + warehouse.incorporated_workers_[worker_index].push_back(&worker); } catch (const WException & e) { throw GameDataError ("incorporated worker #%u (%u): %s", @@ -415,7 +415,7 @@ assert(i < worker_types_without_cost.size()); if (worker_types_without_cost.at(i) == worker_index) { if - (warehouse.m_next_worker_without_cost_spawn[i] != never()) + (warehouse.next_worker_without_cost_spawn_[i] != never()) throw GameDataError ( "%s %u has a next_spawn time for worker type " @@ -423,8 +423,8 @@ "to %u\n", warehouse.descr().descname().c_str(), warehouse.serial(), worker_typename, next_spawn, - warehouse.m_next_worker_without_cost_spawn[i]); - warehouse.m_next_worker_without_cost_spawn[i] = next_spawn; + warehouse.next_worker_without_cost_spawn_[i]); + warehouse.next_worker_without_cost_spawn_[i] = next_spawn; break; } } @@ -437,10 +437,10 @@ // Consistency checks are in Warehouse::load_finish uint32_t nr_planned_workers = fr.unsigned_32(); while (nr_planned_workers--) { - warehouse.m_planned_workers.push_back + warehouse.planned_workers_.push_back (Warehouse::PlannedWorkers()); Warehouse::PlannedWorkers & pw = - warehouse.m_planned_workers.back(); + warehouse.planned_workers_.back(); pw.index = tribe.worker_index(fr.c_string()); pw.amount = fr.unsigned_32(); @@ -456,7 +456,7 @@ } } - warehouse.m_next_stock_remove_act = fr.unsigned_32(); + warehouse.next_stock_remove_act_ = fr.unsigned_32(); if (warehouse.descr().get_isport()) { if (Serial portdock = fr.unsigned_32()) { @@ -489,7 +489,7 @@ (Area<FCoords> (game.map().get_fcoords(warehouse.get_position()), warehouse.descr().vision_range())); - warehouse.m_next_military_act = game.get_gametime(); + warehouse.next_military_act_ = game.get_gametime(); //log("Read warehouse stuff for %p\n", &warehouse); } else { throw UnhandledVersionError("MapBuildingdataPacket - Warehouse", @@ -792,20 +792,20 @@ if (packet_version == kCurrentPacketVersionTrainingsite) { read_productionsite(trainingsite, fr, game, mol); - delete trainingsite.m_soldier_request; - trainingsite.m_soldier_request = nullptr; + delete trainingsite.soldier_request_; + trainingsite.soldier_request_ = nullptr; if (fr.unsigned_8()) { - trainingsite.m_soldier_request = + trainingsite.soldier_request_ = new Request (trainingsite, 0, TrainingSite::request_soldier_callback, wwWORKER); - trainingsite.m_soldier_request->read(fr, game, mol); + trainingsite.soldier_request_->read(fr, game, mol); } - trainingsite.m_capacity = fr.unsigned_8(); - trainingsite.m_build_heroes = fr.unsigned_8(); + trainingsite.capacity_ = fr.unsigned_8(); + trainingsite.build_heroes_ = fr.unsigned_8(); uint8_t const nr_upgrades = fr.unsigned_8(); for (uint8_t i = 0; i < nr_upgrades; ++i) { @@ -835,7 +835,7 @@ uint16_t spresence = fr.unsigned_8(); mapsize--; std::pair<uint16_t, uint8_t> t = std::make_pair(trainstall, spresence); - trainingsite.training_failure_count[std::make_pair(traintype, trainlevel)] = t; + trainingsite.training_failure_count_[std::make_pair(traintype, trainlevel)] = t; } } else { throw UnhandledVersionError("MapBuildingdataPacket - Trainingsite", @@ -851,22 +851,22 @@ // Cmd_ChangeSoldierCapacity to the beginning of the game's command // queue. But that would not work because the command queue is not read // yet and will be cleared before it is read. - if (trainingsite.m_capacity < trainingsite.min_soldier_capacity()) { + if (trainingsite.capacity_ < trainingsite.min_soldier_capacity()) { log ("WARNING: trainingsite %u of player %u at (%i, %i) has capacity " "set to %u but it must be at least %u. Changing to that value.\n", trainingsite.serial(), trainingsite.owner().player_number(), trainingsite.get_position().x, trainingsite.get_position().y, - trainingsite.m_capacity, trainingsite.min_soldier_capacity()); - trainingsite.m_capacity = trainingsite.min_soldier_capacity(); - } else if (trainingsite.max_soldier_capacity() < trainingsite.m_capacity) { + trainingsite.capacity_, trainingsite.min_soldier_capacity()); + trainingsite.capacity_ = trainingsite.min_soldier_capacity(); + } else if (trainingsite.max_soldier_capacity() < trainingsite.capacity_) { log ("WARNING: trainingsite %u of player %u at (%i, %i) has capacity " "set to %u but it can be at most %u. Changing to that value.\n", trainingsite.serial(), trainingsite.owner().player_number(), trainingsite.get_position().x, trainingsite.get_position().y, - trainingsite.m_capacity, trainingsite.max_soldier_capacity()); - trainingsite.m_capacity = trainingsite.max_soldier_capacity(); + trainingsite.capacity_, trainingsite.max_soldier_capacity()); + trainingsite.capacity_ = trainingsite.max_soldier_capacity(); } } catch (const WException & e) { throw GameDataError("trainingsite: %s", e.what()); @@ -1042,7 +1042,7 @@ // supply const TribeDescr & tribe = warehouse.owner().tribe(); - const WareList & wares = warehouse.m_supply->get_wares(); + const WareList & wares = warehouse.supply_->get_wares(); for (DescriptionIndex i = 0; i < wares.get_nrwareids (); ++i) { fw.unsigned_8(1); fw.string(tribe.get_ware_descr(i)->name()); @@ -1050,7 +1050,7 @@ fw.unsigned_8(warehouse.get_ware_policy(i)); } fw.unsigned_8(0); - const WareList & workers = warehouse.m_supply->get_workers(); + const WareList & workers = warehouse.supply_->get_workers(); for (DescriptionIndex i = 0; i < workers.get_nrwareids(); ++i) { fw.unsigned_8(1); fw.string(tribe.get_worker_descr(i)->name()); @@ -1061,14 +1061,14 @@ // Incorporated workers, write sorted after file-serial. uint32_t nworkers = 0; - for (const std::pair<DescriptionIndex, Warehouse::WorkerList>& cwt: warehouse.m_incorporated_workers) { + for (const std::pair<DescriptionIndex, Warehouse::WorkerList>& cwt: warehouse.incorporated_workers_) { nworkers += cwt.second.size(); } fw.unsigned_16(nworkers); using TWorkerMap = std::map<uint32_t, const Worker *>; TWorkerMap workermap; - for (const std::pair<DescriptionIndex, Warehouse::WorkerList>& cwt : warehouse.m_incorporated_workers) { + for (const std::pair<DescriptionIndex, Warehouse::WorkerList>& cwt : warehouse.incorporated_workers_) { for (Worker * temp_worker : cwt.second) { const Worker & w = *temp_worker; assert(mos.is_object_known(w)); @@ -1088,9 +1088,9 @@ const std::vector<DescriptionIndex> & worker_types_without_cost = tribe.worker_types_without_cost(); assert(worker_types_without_cost.size() == - warehouse.m_next_worker_without_cost_spawn.size()); + warehouse.next_worker_without_cost_spawn_.size()); for (uint8_t i = worker_types_without_cost.size(); i;) { - const Time& next_spawn = warehouse.m_next_worker_without_cost_spawn[--i]; + const Time& next_spawn = warehouse.next_worker_without_cost_spawn_[--i]; if (next_spawn != never()) { fw.string (tribe.get_worker_descr(tribe.worker_types_without_cost().at(i)) @@ -1101,8 +1101,8 @@ } fw.unsigned_8(0); // terminator for spawn times - fw.unsigned_32(warehouse.m_planned_workers.size()); - for (const Warehouse::PlannedWorkers& temp_worker : warehouse.m_planned_workers) { + fw.unsigned_32(warehouse.planned_workers_.size()); + for (const Warehouse::PlannedWorkers& temp_worker : warehouse.planned_workers_) { fw.c_string(tribe.get_worker_descr(temp_worker.index)->name()); fw.unsigned_32(temp_worker.amount); @@ -1113,7 +1113,7 @@ } } - fw.unsigned_32(warehouse.m_next_stock_remove_act); + fw.unsigned_32(warehouse.next_stock_remove_act_); if (warehouse.descr().get_isport()) { fw.unsigned_32(mos.get_object_file_index_or_zero(warehouse.portdock_)); @@ -1261,34 +1261,34 @@ // requests - if (trainingsite.m_soldier_request) { + if (trainingsite.soldier_request_) { fw.unsigned_8(1); - trainingsite.m_soldier_request->write(fw, game, mos); + trainingsite.soldier_request_->write(fw, game, mos); } else { fw.unsigned_8(0); } - fw.unsigned_8(trainingsite.m_capacity); - fw.unsigned_8(trainingsite.m_build_heroes); + fw.unsigned_8(trainingsite.capacity_); + fw.unsigned_8(trainingsite.build_heroes_); // upgrades - fw.unsigned_8(trainingsite.m_upgrades.size()); - for (uint8_t i = 0; i < trainingsite.m_upgrades.size(); ++i) { - const TrainingSite::Upgrade & upgrade = trainingsite.m_upgrades[i]; + fw.unsigned_8(trainingsite.upgrades_.size()); + for (uint8_t i = 0; i < trainingsite.upgrades_.size(); ++i) { + const TrainingSite::Upgrade & upgrade = trainingsite.upgrades_[i]; fw.unsigned_8(upgrade.attribute); fw.unsigned_8(upgrade.prio); fw.unsigned_8(upgrade.credit); fw.signed_32(upgrade.lastattempt); fw.signed_8(upgrade.lastsuccess); } - if (255 < trainingsite.training_failure_count.size()) + if (255 < trainingsite.training_failure_count_.size()) log ("Save TrainingSite: Failure counter has ridiculously many entries! (%u)\n", - static_cast<uint16_t>(trainingsite.training_failure_count.size())); - fw.unsigned_16(static_cast<uint16_t> (trainingsite.training_failure_count.size())); + static_cast<uint16_t>(trainingsite.training_failure_count_.size())); + fw.unsigned_16(static_cast<uint16_t> (trainingsite.training_failure_count_.size())); for - (TrainingSite::TrainFailCount::const_iterator i = trainingsite.training_failure_count.begin(); - i != trainingsite.training_failure_count.end(); i++) + (TrainingSite::TrainFailCount::const_iterator i = trainingsite.training_failure_count_.begin(); + i != trainingsite.training_failure_count_.end(); i++) { fw.unsigned_16(i->first.first); fw.unsigned_16(i->first.second);
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp