widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #05948
[Merge] lp:~widelands-dev/widelands/bug-1395278-base-economy into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1395278-base-economy into lp:widelands.
Commit message:
- Fixed member variable names in src/basic and src/economy.
- Removed some compatibility code from map_flagdata_packet.cc.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1395278-base-economy/+merge/285289
- Fixed member variable names in src/basic and src/economy.
- Removed some compatibility code from map_flagdata_packet.cc.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1395278-base-economy into lp:widelands.
=== modified file 'src/base/exceptions.cc'
--- src/base/exceptions.cc 2016-01-02 12:36:38 +0000
+++ src/base/exceptions.cc 2016-02-07 07:48:48 +0000
@@ -40,11 +40,11 @@
}
std::ostringstream ost;
ost << '[' << file << ':' << line << "] " << buffer;
- m_what = ost.str();
+ what_ = ost.str();
}
char const * WException::what() const noexcept {
- return m_what.c_str();
+ return what_.c_str();
}
@@ -52,7 +52,7 @@
* class warning implementation
*/
WLWarning::WLWarning(char const * const et, char const * const em, ...) :
- m_title(et)
+ title_(et)
{
char buffer[512];
{
@@ -61,14 +61,14 @@
vsnprintf(buffer, sizeof(buffer), em, va);
va_end(va);
}
- m_what = buffer;
+ what_ = buffer;
}
char const * WLWarning::title() const
{
- return m_title.c_str();
+ return title_.c_str();
}
char const * WLWarning::what() const noexcept {
- return m_what.c_str();
+ return what_.c_str();
}
=== modified file 'src/base/warning.h'
--- src/base/warning.h 2014-09-14 16:08:13 +0000
+++ src/base/warning.h 2016-02-07 07:48:48 +0000
@@ -49,8 +49,8 @@
protected:
WLWarning() {}
- std::string m_what;
- std::string m_title;
+ std::string what_;
+ std::string title_;
};
#endif // end of include guard: WL_BASE_WARNING_H
=== modified file 'src/base/wexception.h'
--- src/base/wexception.h 2016-01-18 19:35:25 +0000
+++ src/base/wexception.h 2016-02-07 07:48:48 +0000
@@ -54,7 +54,7 @@
protected:
WException() {}
- std::string m_what;
+ std::string what_;
};
#define wexception(...) WException(__FILE__, __LINE__, __VA_ARGS__)
=== modified file 'src/economy/cmd_call_economy_balance.cc'
--- src/economy/cmd_call_economy_balance.cc 2015-11-21 10:16:52 +0000
+++ src/economy/cmd_call_economy_balance.cc 2016-02-07 07:48:48 +0000
@@ -34,8 +34,8 @@
(uint32_t const starttime, Economy * const economy, uint32_t const timerid)
: GameLogicCommand(starttime)
{
- m_flag = economy->get_arbitrary_flag();
- m_timerid = timerid;
+ flag_ = economy->get_arbitrary_flag();
+ timerid_ = timerid;
}
/**
@@ -44,8 +44,8 @@
*/
void CmdCallEconomyBalance::execute(Game & game)
{
- if (Flag * const flag = m_flag.get(game))
- flag->get_economy()->balance(m_timerid);
+ if (Flag * const flag = flag_.get(game))
+ flag->get_economy()->balance(timerid_);
}
constexpr uint16_t kCurrentPacketVersion = 3;
@@ -62,8 +62,8 @@
GameLogicCommand::read(fr, egbase, mol);
uint32_t serial = fr.unsigned_32();
if (serial)
- m_flag = &mol.get<Flag>(serial);
- m_timerid = fr.unsigned_32();
+ flag_ = &mol.get<Flag>(serial);
+ timerid_ = fr.unsigned_32();
} else {
throw UnhandledVersionError("CmdCallEconomyBalance", packet_version, kCurrentPacketVersion);
}
@@ -78,11 +78,11 @@
// Write Base Commands
GameLogicCommand::write(fw, egbase, mos);
- if (Flag * const flag = m_flag.get(egbase))
+ if (Flag * const flag = flag_.get(egbase))
fw.unsigned_32(mos.get_object_file_index(*flag));
else
fw.unsigned_32(0);
- fw.unsigned_32(m_timerid);
+ fw.unsigned_32(timerid_);
}
}
=== modified file 'src/economy/cmd_call_economy_balance.h'
--- src/economy/cmd_call_economy_balance.h 2015-12-04 18:27:36 +0000
+++ src/economy/cmd_call_economy_balance.h 2016-02-07 07:48:48 +0000
@@ -31,7 +31,7 @@
struct CmdCallEconomyBalance : public GameLogicCommand {
- CmdCallEconomyBalance () : GameLogicCommand(0), m_timerid(0) {} ///< for load and save
+ CmdCallEconomyBalance () : GameLogicCommand(0), timerid_(0) {} ///< for load and save
CmdCallEconomyBalance (uint32_t starttime, Economy *, uint32_t timerid);
@@ -43,8 +43,8 @@
void read (FileRead &, EditorGameBase &, MapObjectLoader &) override;
private:
- OPtr<Flag> m_flag;
- uint32_t m_timerid;
+ OPtr<Flag> flag_;
+ uint32_t timerid_;
};
}
=== modified file 'src/economy/economy.cc'
--- src/economy/economy.cc 2016-01-08 21:00:39 +0000
+++ src/economy/economy.cc 2016-02-07 07:48:48 +0000
@@ -42,18 +42,18 @@
namespace Widelands {
Economy::Economy(Player & player) :
- m_owner(player),
- m_request_timerid(0)
+ owner_(player),
+ request_timerid_(0)
{
const TribeDescr & tribe = player.tribe();
DescriptionIndex const nr_wares = player.egbase().tribes().nrwares();
DescriptionIndex const nr_workers = player.egbase().tribes().nrworkers();
- m_wares.set_nrwares(nr_wares);
- m_workers.set_nrwares(nr_workers);
+ wares_.set_nrwares(nr_wares);
+ workers_.set_nrwares(nr_workers);
player.add_economy(*this);
- m_ware_target_quantities = new TargetQuantity[nr_wares];
+ ware_target_quantities_ = new TargetQuantity[nr_wares];
for (DescriptionIndex i = 0; i < nr_wares; ++i) {
TargetQuantity tq;
if (tribe.has_ware(i)) {
@@ -63,36 +63,36 @@
tq.permanent = 0;
}
tq.last_modified = 0;
- m_ware_target_quantities[i] = tq;
+ ware_target_quantities_[i] = tq;
}
- m_worker_target_quantities = new TargetQuantity[nr_workers];
+ worker_target_quantities_ = new TargetQuantity[nr_workers];
for (DescriptionIndex i = 0; i < nr_workers; ++i) {
TargetQuantity tq;
tq.permanent =
tribe.get_worker_descr(i)->default_target_quantity();
tq.last_modified = 0;
- m_worker_target_quantities[i] = tq;
+ worker_target_quantities_[i] = tq;
}
- m_router =
+ router_ =
new Router(boost::bind(&Economy::_reset_all_pathfinding_cycles, this));
}
Economy::~Economy()
{
- m_owner.remove_economy(*this);
+ owner_.remove_economy(*this);
- if (m_requests.size())
+ if (requests_.size())
log("Warning: Economy still has requests left on destruction\n");
- if (m_flags.size())
+ if (flags_.size())
log("Warning: Economy still has flags left on destruction\n");
- if (m_warehouses.size())
+ if (warehouses_.size())
log("Warning: Economy still has warehouses left on destruction\n");
- delete[] m_ware_target_quantities;
- delete[] m_worker_target_quantities;
+ delete[] ware_target_quantities_;
+ delete[] worker_target_quantities_;
- delete m_router;
+ delete router_;
}
@@ -101,10 +101,10 @@
*/
Flag* Economy::get_arbitrary_flag()
{
- if (m_flags.empty())
+ if (flags_.empty())
return nullptr;
- return m_flags[0];
+ return flags_[0];
}
/**
@@ -138,7 +138,7 @@
if (!e)
return;
- e->m_split_checks.push_back(std::make_pair(OPtr<Flag>(&f1), OPtr<Flag>(&f2)));
+ e->split_checks_.push_back(std::make_pair(OPtr<Flag>(&f1), OPtr<Flag>(&f2)));
e->rebalance_supply(); // the real split-checking is done during rebalance
}
@@ -147,10 +147,10 @@
EditorGameBase & egbase = owner().egbase();
Map & map = egbase.map();
- while (m_split_checks.size()) {
- Flag * f1 = m_split_checks.back().first.get(egbase);
- Flag * f2 = m_split_checks.back().second.get(egbase);
- m_split_checks.pop_back();
+ while (split_checks_.size()) {
+ Flag * f1 = split_checks_.back().first.get(egbase);
+ Flag * f2 = split_checks_.back().second.get(egbase);
+ split_checks_.pop_back();
if (!f1 || !f2) {
if (!f1 && !f2)
@@ -161,12 +161,12 @@
continue;
// Handle the case when two or more roads are removed simultaneously
- RouteAStar<AStarZeroEstimator> astar(*m_router, wwWORKER, AStarZeroEstimator());
+ RouteAStar<AStarZeroEstimator> astar(*router_, wwWORKER, AStarZeroEstimator());
astar.push(*f1);
std::set<OPtr<Flag> > reachable;
while (RoutingNode * current = astar.step())
reachable.insert(¤t->base_flag());
- if (reachable.size() != m_flags.size())
+ if (reachable.size() != flags_.size())
_split(reachable);
continue;
}
@@ -181,7 +181,7 @@
// reached from f1. These nodes induce a connected subgraph.
// This means that the newly created economy, which contains all the
// flags that have been split, is already connected.
- RouteAStar<AStarEstimator> astar(*m_router, wwWORKER, AStarEstimator(map, *f2));
+ RouteAStar<AStarEstimator> astar(*router_, wwWORKER, AStarEstimator(map, *f2));
astar.push(*f1);
std::set<OPtr<Flag> > reachable;
@@ -216,7 +216,7 @@
Map & map = owner().egbase().map();
return
- m_router->find_route(start, end, route, type, cost_cutoff, map);
+ router_->find_route(start, end, route, type, cost_cutoff, map);
}
struct ZeroEstimator {
@@ -243,7 +243,7 @@
return nullptr;
// A-star with zero estimator = Dijkstra
- RouteAStar<ZeroEstimator> astar(*m_router, type);
+ RouteAStar<ZeroEstimator> astar(*router_, type);
astar.push(start);
while (RoutingNode * current = astar.step()) {
@@ -274,7 +274,7 @@
{
assert(flag.get_economy() == nullptr);
- m_flags.push_back(&flag);
+ flags_.push_back(&flag);
flag.set_economy(this);
flag.reset_path_finding_cycle();
@@ -291,7 +291,7 @@
_remove_flag(flag);
// automatically delete the economy when it becomes empty.
- if (m_flags.empty())
+ if (flags_.empty())
delete this;
}
@@ -304,10 +304,10 @@
flag.set_economy(nullptr);
// fast remove
- for (Flags::iterator flag_iter = m_flags.begin(); flag_iter != m_flags.end(); ++flag_iter) {
+ for (Flags::iterator flag_iter = flags_.begin(); flag_iter != flags_.end(); ++flag_iter) {
if (*flag_iter == &flag) {
- *flag_iter = *(m_flags.end() - 1);
- return m_flags.pop_back();
+ *flag_iter = *(flags_.end() - 1);
+ return flags_.pop_back();
}
}
throw wexception("trying to remove nonexistent flag");
@@ -319,7 +319,7 @@
*/
void Economy::_reset_all_pathfinding_cycles()
{
- for (Flag * flag : m_flags) {
+ for (Flag * flag : flags_) {
flag->reset_path_finding_cycle();
}
}
@@ -336,7 +336,7 @@
uint32_t const permanent,
Time const mod_time)
{
- TargetQuantity & tq = m_ware_target_quantities[ware_type];
+ TargetQuantity & tq = ware_target_quantities_[ware_type];
tq.permanent = permanent;
tq.last_modified = mod_time;
}
@@ -347,7 +347,7 @@
uint32_t const permanent,
Time const mod_time)
{
- TargetQuantity & tq = m_worker_target_quantities[ware_type];
+ TargetQuantity & tq = worker_target_quantities_[ware_type];
tq.permanent = permanent;
tq.last_modified = mod_time;
}
@@ -363,7 +363,7 @@
{
//log("%p: add(%i, %i)\n", this, id, count);
- m_wares.add(id, count);
+ wares_.add(id, count);
_start_request_timer();
// TODO(unknown): add to global player inventory?
@@ -372,7 +372,7 @@
{
//log("%p: add(%i, %i)\n", this, id, count);
- m_workers.add(id, count);
+ workers_.add(id, count);
_start_request_timer();
// TODO(unknown): add to global player inventory?
@@ -386,10 +386,10 @@
*/
void Economy::remove_wares(DescriptionIndex const id, uint32_t const count)
{
- assert(m_owner.egbase().tribes().ware_exists(id));
- //log("%p: remove(%i, %i) from %i\n", this, id, count, m_wares.stock(id));
+ assert(owner_.egbase().tribes().ware_exists(id));
+ //log("%p: remove(%i, %i) from %i\n", this, id, count, wares_.stock(id));
- m_wares.remove(id, count);
+ wares_.remove(id, count);
// TODO(unknown): remove from global player inventory?
}
@@ -401,9 +401,9 @@
*/
void Economy::remove_workers(DescriptionIndex const id, uint32_t const count)
{
- //log("%p: remove(%i, %i) from %i\n", this, id, count, m_workers.stock(id));
+ //log("%p: remove(%i, %i) from %i\n", this, id, count, workers_.stock(id));
- m_workers.remove(id, count);
+ workers_.remove(id, count);
// TODO(unknown): remove from global player inventory?
}
@@ -415,7 +415,7 @@
*/
void Economy::add_warehouse(Warehouse & wh)
{
- m_warehouses.push_back(&wh);
+ warehouses_.push_back(&wh);
}
/**
@@ -423,10 +423,10 @@
*/
void Economy::remove_warehouse(Warehouse & wh)
{
- for (size_t i = 0; i < m_warehouses.size(); ++i)
- if (m_warehouses[i] == &wh) {
- m_warehouses[i] = *m_warehouses.rbegin();
- m_warehouses.pop_back();
+ for (size_t i = 0; i < warehouses_.size(); ++i)
+ if (warehouses_[i] == &wh) {
+ warehouses_[i] = *warehouses_.rbegin();
+ warehouses_.pop_back();
return;
}
@@ -434,7 +434,7 @@
// This assert was modified, since on loading, warehouses might try to
// remove themselves from their own economy, though they weren't added
// (since they weren't initialized)
- assert(m_warehouses.empty());
+ assert(warehouses_.empty());
}
/**
@@ -448,7 +448,7 @@
assert(&owner());
- m_requests.push_back(&req);
+ requests_.push_back(&req);
// Try to fulfill the request
_start_request_timer();
@@ -461,9 +461,9 @@
bool Economy::_has_request(Request & req)
{
return
- std::find(m_requests.begin(), m_requests.end(), &req)
+ std::find(requests_.begin(), requests_.end(), &req)
!=
- m_requests.end();
+ requests_.end();
}
/**
@@ -473,16 +473,16 @@
void Economy::remove_request(Request & req)
{
RequestList::iterator const it =
- std::find(m_requests.begin(), m_requests.end(), &req);
+ std::find(requests_.begin(), requests_.end(), &req);
- if (it == m_requests.end()) {
+ if (it == requests_.end()) {
log("WARNING: remove_request(%p) not in list\n", &req);
return;
}
- *it = *m_requests.rbegin();
+ *it = *requests_.rbegin();
- m_requests.pop_back();
+ requests_.pop_back();
}
/**
@@ -490,7 +490,7 @@
*/
void Economy::add_supply(Supply & supply)
{
- m_supplies.add_supply(supply);
+ supplies_.add_supply(supply);
_start_request_timer();
}
@@ -500,7 +500,7 @@
*/
void Economy::remove_supply(Supply & supply)
{
- m_supplies.remove_supply(supply);
+ supplies_.remove_supply(supply);
}
@@ -510,7 +510,7 @@
// we have a target quantity set
if (t > 0) {
uint32_t quantity = 0;
- for (const Warehouse * wh : m_warehouses) {
+ for (const Warehouse * wh : warehouses_) {
quantity += wh->get_wares().stock(ware_type);
if (t <= quantity)
return false;
@@ -519,7 +519,7 @@
// we have target quantity set to 0, we need to check if there is an open request
} else {
- for (const Request * temp_req : m_requests) {
+ for (const Request * temp_req : requests_) {
const Request & req = *temp_req;
if (req.get_type() == wwWARE && req.get_index() == ware_type)
@@ -536,7 +536,7 @@
// we have a target quantity set
if (t > 0) {
uint32_t quantity = 0;
- for (const Warehouse * wh : m_warehouses) {
+ for (const Warehouse * wh : warehouses_) {
quantity += wh->get_workers().stock(worker_type);
if (t <= quantity)
return false;
@@ -545,7 +545,7 @@
// we have target quantity set to 0, we need to check if there is an open request
} else {
- for (const Request * temp_req : m_requests) {
+ for (const Request * temp_req : requests_) {
const Request & req = *temp_req;
if (req.get_type() == wwWORKER && req.get_index() == worker_type)
@@ -564,17 +564,17 @@
*/
void Economy::_merge(Economy & e)
{
- for (const DescriptionIndex& ware_index : m_owner.tribe().wares()) {
- TargetQuantity other_tq = e.m_ware_target_quantities[ware_index];
- TargetQuantity& this_tq = m_ware_target_quantities[ware_index];
+ for (const DescriptionIndex& ware_index : owner_.tribe().wares()) {
+ TargetQuantity other_tq = e.ware_target_quantities_[ware_index];
+ TargetQuantity& this_tq = ware_target_quantities_[ware_index];
if (this_tq.last_modified < other_tq.last_modified) {
this_tq = other_tq;
}
}
- for (const DescriptionIndex& worker_index : m_owner.tribe().workers()) {
- TargetQuantity other_tq = e.m_worker_target_quantities[worker_index];
- TargetQuantity& this_tq = m_worker_target_quantities[worker_index];
+ for (const DescriptionIndex& worker_index : owner_.tribe().workers()) {
+ TargetQuantity other_tq = e.worker_target_quantities_[worker_index];
+ TargetQuantity& this_tq = worker_target_quantities_[worker_index];
if (this_tq.last_modified < other_tq.last_modified) {
this_tq = other_tq;
}
@@ -585,25 +585,25 @@
// window for *this where the options window for e is, to give the user
// some continuity.
if
- (e.m_optionswindow_registry.window &&
- !m_optionswindow_registry.window)
+ (e.optionswindow_registry_.window &&
+ !optionswindow_registry_.window)
{
- m_optionswindow_registry.x = e.m_optionswindow_registry.x;
- m_optionswindow_registry.y = e.m_optionswindow_registry.y;
+ optionswindow_registry_.x = e.optionswindow_registry_.x;
+ optionswindow_registry_.y = e.optionswindow_registry_.y;
show_options_window();
}
for (std::vector<Flag *>::size_type i = e.get_nrflags() + 1; --i;) {
assert(i == e.get_nrflags());
- Flag & flag = *e.m_flags[0];
+ Flag & flag = *e.flags_[0];
e._remove_flag(flag); // do not delete other economy yet!
add_flag(flag);
}
// Remember that the other economy may not have been connected before the merge
- m_split_checks.insert(m_split_checks.end(), e.m_split_checks.begin(), e.m_split_checks.end());
+ split_checks_.insert(split_checks_.end(), e.split_checks_.begin(), e.split_checks_.end());
// implicitly delete the economy
delete &e;
@@ -616,19 +616,19 @@
{
assert(!flags.empty());
- Economy & e = *new Economy(m_owner);
+ Economy & e = *new Economy(owner_);
- for (const DescriptionIndex& ware_index : m_owner.tribe().wares()) {
- e.m_ware_target_quantities[ware_index] = m_ware_target_quantities[ware_index];
+ for (const DescriptionIndex& ware_index : owner_.tribe().wares()) {
+ e.ware_target_quantities_[ware_index] = ware_target_quantities_[ware_index];
}
- for (const DescriptionIndex& worker_index : m_owner.tribe().workers()) {
- e.m_worker_target_quantities[worker_index] = m_worker_target_quantities[worker_index];
+ for (const DescriptionIndex& worker_index : owner_.tribe().workers()) {
+ e.worker_target_quantities_[worker_index] = worker_target_quantities_[worker_index];
}
for (const OPtr<Flag> temp_flag : flags) {
Flag & flag = *temp_flag.get(owner().egbase());
- assert(m_flags.size() > 1); // We will not be deleted in remove_flag, right?
+ assert(flags_.size() > 1); // We will not be deleted in remove_flag, right?
remove_flag(flag);
e.add_flag(flag);
}
@@ -644,10 +644,10 @@
*/
void Economy::_start_request_timer(int32_t const delta)
{
- if (upcast(Game, game, &m_owner.egbase()))
+ if (upcast(Game, game, &owner_.egbase()))
game->cmdqueue().enqueue
(new CmdCallEconomyBalance
- (game->get_gametime() + delta, this, m_request_timerid));
+ (game->get_gametime() + delta, this, request_timerid_));
}
@@ -669,8 +669,8 @@
available_supplies.clear();
- for (size_t i = 0; i < m_supplies.get_nrsupplies(); ++i) {
- Supply & supp = m_supplies[i];
+ for (size_t i = 0; i < supplies_.get_nrsupplies(); ++i) {
+ Supply & supp = supplies_[i];
// Just skip if supply does not provide required ware
if (!supp.nr_supplies(game, req))
@@ -692,7 +692,7 @@
// std::map quarantees uniqueness, practically it means that if more wares are on the same flag, only
// first one will be inserted into available_supplies
- available_supplies.insert(std::make_pair(ud, &m_supplies[i]));
+ available_supplies.insert(std::make_pair(ud, &supplies_[i]));
}
// Now available supplies have been sorted by distance to requestor
@@ -776,7 +776,7 @@
*/
void Economy::_process_requests(Game & game, RSPairStruct & s)
{
- for (Request * temp_req : m_requests) {
+ for (Request * temp_req : requests_) {
Request & req = *temp_req;
// We somehow get desynced request lists that don't trigger desync
@@ -865,7 +865,7 @@
}
-std::unique_ptr<Soldier> Economy::m_soldier_prototype = nullptr; // minimal invasive fix of bug 1236538
+std::unique_ptr<Soldier> Economy::soldier_prototype_ = nullptr; // minimal invasive fix of bug 1236538
/**
* Check whether there is a supply for the given request. If the request is a
@@ -884,16 +884,16 @@
// Minimal invasive fix of bug 1236538: never create a rookie for a request
// that required a hero.
if (upcast(const SoldierDescr, s_desc, &w_desc)) {
- if (!m_soldier_prototype) {
+ if (!soldier_prototype_) {
Soldier* test_rookie = static_cast<Soldier*> (&(s_desc->create_object()));
- m_soldier_prototype.reset(test_rookie);
+ soldier_prototype_.reset(test_rookie);
}
soldier_level_check = true;
} else {
soldier_level_check = false;
}
- for (Request * temp_req : m_requests) {
+ for (Request * temp_req : requests_) {
const Request & req = *temp_req;
if (req.get_type() != wwWORKER || req.get_index() != index)
@@ -901,13 +901,13 @@
// need to check for each request separately, because esp. soldier
// requests have different specific requirements
- if (m_supplies.have_supplies(game, req))
+ if (supplies_.have_supplies(game, req))
continue;
// Requests for heroes should not trigger the creation of more rookies
if (soldier_level_check)
{
- if (!(req.get_requirements().check(*m_soldier_prototype)))
+ if (!(req.get_requirements().check(*soldier_prototype_)))
continue;
}
@@ -931,7 +931,7 @@
total_available.insert(total_available.begin(), cost.size(), 0);
for (uint32_t n_wh = 0; n_wh < warehouses().size(); ++n_wh) {
- Warehouse * wh = m_warehouses[n_wh];
+ Warehouse * wh = warehouses_[n_wh];
uint32_t planned = wh->get_planned_workers(game, index);
total_planned += planned;
@@ -980,7 +980,7 @@
// of loss of land or silly player actions.
Warehouse * wh_with_plan = nullptr;
for (uint32_t n_wh = 0; n_wh < warehouses().size(); ++n_wh) {
- Warehouse * wh = m_warehouses[n_wh];
+ Warehouse * wh = warehouses_[n_wh];
uint32_t planned = wh->get_planned_workers(game, index);
uint32_t reduce = std::min(planned, total_planned - can_create);
@@ -1000,7 +1000,7 @@
uint32_t plan_goal = std::min(can_create, demand);
for (uint32_t n_wh = 0; n_wh < warehouses().size(); ++n_wh) {
- Warehouse * wh = m_warehouses[n_wh];
+ Warehouse * wh = warehouses_[n_wh];
uint32_t supply =
wh->calc_available_for_worker(game, index)[scarcest_idx];
@@ -1016,7 +1016,7 @@
if (plan_at_least_one && 0 == total_planned) {
Warehouse * wh = find_closest_warehouse(open_request->target_flag());
if (nullptr == wh)
- wh = m_warehouses[0];
+ wh = warehouses_[0];
wh->plan_workers(game, index, 1);
}
}
@@ -1061,8 +1061,8 @@
using Assignments = std::vector<std::pair<Supply *, Warehouse *>>;
Assignments assignments;
- for (uint32_t idx = 0; idx < m_supplies.get_nrsupplies(); ++idx) {
- Supply & supply = m_supplies[idx];
+ for (uint32_t idx = 0; idx < supplies_.get_nrsupplies(); ++idx) {
+ Supply & supply = supplies_[idx];
if (supply.has_storage())
continue;
@@ -1078,8 +1078,8 @@
// Stock of particular ware in preferred warehouse
uint32_t preferred_wh_stock = std::numeric_limits<uint32_t>::max();
- for (uint32_t nwh = 0; nwh < m_warehouses.size(); ++nwh) {
- Warehouse * wh = m_warehouses[nwh];
+ for (uint32_t nwh = 0; nwh < warehouses_.size(); ++nwh) {
+ Warehouse * wh = warehouses_[nwh];
Warehouse::StockPolicy policy = wh->get_stock_policy(type, ware);
if (policy == Warehouse::SP_Prefer) {
haveprefer = true;
@@ -1130,7 +1130,7 @@
}
// Actually start with the transfers in a separate second phase,
- // to avoid potential future problems caused by the m_supplies changing
+ // to avoid potential future problems caused by the supplies_ changing
// under us in some way.
::StreamWrite & ss = game.syncstream();
ss.unsigned_32(0x02decafa); // appears as facade02 in sync stream
@@ -1150,10 +1150,10 @@
*/
void Economy::balance(uint32_t const timerid)
{
- if (m_request_timerid != timerid) {
+ if (request_timerid_ != timerid) {
return;
}
- ++m_request_timerid;
+ ++request_timerid_;
Game & game = dynamic_cast<Game&>(owner().egbase());
=== modified file 'src/economy/economy.h'
--- src/economy/economy.h 2016-01-08 21:00:39 +0000
+++ src/economy/economy.h 2016-02-07 07:48:48 +0000
@@ -96,7 +96,7 @@
Economy(Player &);
~Economy();
- Player & owner() const {return m_owner;}
+ Player & owner() const {return owner_;}
static void check_merge(Flag &, Flag &);
static void check_split(Flag &, Flag &);
@@ -113,7 +113,7 @@
uint32_t cost_cutoff = 0,
const WarehouseAcceptFn & acceptfn = WarehouseAcceptFn());
- std::vector<Flag *>::size_type get_nrflags() const {return m_flags.size();}
+ std::vector<Flag *>::size_type get_nrflags() const {return flags_.size();}
void add_flag(Flag &);
void remove_flag(Flag &);
@@ -132,7 +132,7 @@
void add_warehouse(Warehouse &);
void remove_warehouse(Warehouse &);
- const std::vector<Warehouse *>& warehouses() const {return m_warehouses;}
+ const std::vector<Warehouse *>& warehouses() const {return warehouses_;}
void add_request(Request &);
void remove_request(Request &);
@@ -142,10 +142,10 @@
/// information about this economy
WareList::WareCount stock_ware (DescriptionIndex const i) {
- return m_wares .stock(i);
+ return wares_ .stock(i);
}
WareList::WareCount stock_worker(DescriptionIndex const i) {
- return m_workers.stock(i);
+ return workers_.stock(i);
}
/// Whether the economy needs more of this ware type.
@@ -159,25 +159,25 @@
bool needs_worker(DescriptionIndex) const;
const TargetQuantity & ware_target_quantity (DescriptionIndex const i) const {
- return m_ware_target_quantities[i];
+ return ware_target_quantities_[i];
}
TargetQuantity & ware_target_quantity (DescriptionIndex const i) {
- return m_ware_target_quantities[i];
+ return ware_target_quantities_[i];
}
const TargetQuantity & worker_target_quantity(DescriptionIndex const i) const {
- return m_worker_target_quantities[i];
+ return worker_target_quantities_[i];
}
TargetQuantity & worker_target_quantity(DescriptionIndex const i) {
- return m_worker_target_quantities[i];
+ return worker_target_quantities_[i];
}
void show_options_window();
UI::UniqueWindow::Registry& optionswindow_registry() {
- return m_optionswindow_registry;
+ return optionswindow_registry_;
}
- const WareList & get_wares () const {return m_wares;}
- const WareList & get_workers() const {return m_workers;}
+ const WareList & get_wares () const {return wares_;}
+ const WareList & get_workers() const {return workers_;}
///< called by \ref Cmd_Call_Economy_Balance
void balance(uint32_t timerid);
@@ -227,32 +227,32 @@
/*************/
using RequestList = std::vector<Request *>;
- Player & m_owner;
+ Player & owner_;
using Flags = std::vector<Flag *>;
- Flags m_flags;
- WareList m_wares; ///< virtual storage with all wares in this Economy
- WareList m_workers; ///< virtual storage with all workers in this Economy
- std::vector<Warehouse *> m_warehouses;
-
- RequestList m_requests; ///< requests
- SupplyList m_supplies;
-
- TargetQuantity * m_ware_target_quantities;
- TargetQuantity * m_worker_target_quantities;
- Router * m_router;
+ Flags flags_;
+ WareList wares_; ///< virtual storage with all wares in this Economy
+ WareList workers_; ///< virtual storage with all workers in this Economy
+ std::vector<Warehouse *> warehouses_;
+
+ RequestList requests_; ///< requests
+ SupplyList supplies_;
+
+ TargetQuantity * ware_target_quantities_;
+ TargetQuantity * worker_target_quantities_;
+ Router * router_;
using SplitPair = std::pair<OPtr<Flag>, OPtr<Flag>>;
- std::vector<SplitPair> m_split_checks;
+ std::vector<SplitPair> split_checks_;
/**
* ID for the next request balancing timer. Used to throttle
* excessive calls to the request/supply balancing logic.
*/
- uint32_t m_request_timerid;
+ uint32_t request_timerid_;
- static std::unique_ptr<Soldier> m_soldier_prototype;
- UI::UniqueWindow::Registry m_optionswindow_registry;
+ static std::unique_ptr<Soldier> soldier_prototype_;
+ UI::UniqueWindow::Registry optionswindow_registry_;
// 'list' of unique providers
std::map<UniqueDistance, Supply*> available_supplies;
=== modified file 'src/economy/economy_data_packet.cc'
--- src/economy/economy_data_packet.cc 2015-11-28 22:29:26 +0000
+++ src/economy/economy_data_packet.cc 2016-02-07 07:48:48 +0000
@@ -37,7 +37,7 @@
uint16_t const packet_version = fr.unsigned_16();
if (packet_version == kCurrentPacketVersion) {
try {
- const TribeDescr& tribe = m_eco->owner().tribe();
+ const TribeDescr& tribe = eco_->owner().tribe();
while (Time const last_modified = fr.unsigned_32()) {
char const * const type_name = fr.c_string();
uint32_t const permanent = fr.unsigned_32();
@@ -49,7 +49,7 @@
"ignoring\n",
type_name);
} else {
- Economy::TargetQuantity& tq = m_eco->m_ware_target_quantities[i];
+ Economy::TargetQuantity& tq = eco_->ware_target_quantities_[i];
if (tq.last_modified) {
throw GameDataError("duplicated entry for %s", type_name);
}
@@ -66,7 +66,7 @@
"ignoring\n",
type_name);
} else {
- Economy::TargetQuantity& tq = m_eco->m_worker_target_quantities[i];
+ Economy::TargetQuantity& tq = eco_->worker_target_quantities_[i];
if (tq.last_modified) {
throw GameDataError("duplicated entry for %s", type_name);
}
@@ -85,7 +85,7 @@
} catch (const WException & e) {
throw GameDataError("target quantities: %s", e.what());
}
- m_eco->m_request_timerid = fr.unsigned_32();
+ eco_->request_timerid_ = fr.unsigned_32();
} else {
throw UnhandledVersionError("EconomyDataPacket", packet_version, kCurrentPacketVersion);
}
@@ -97,10 +97,10 @@
void EconomyDataPacket::write(FileWrite & fw)
{
fw.unsigned_16(kCurrentPacketVersion);
- const TribeDescr & tribe = m_eco->owner().tribe();
+ const TribeDescr & tribe = eco_->owner().tribe();
for (const DescriptionIndex& ware_index : tribe.wares()) {
const Economy::TargetQuantity & tq =
- m_eco->m_ware_target_quantities[ware_index];
+ eco_->ware_target_quantities_[ware_index];
if (Time const last_modified = tq.last_modified) {
fw.unsigned_32(last_modified);
fw.c_string(tribe.get_ware_descr(ware_index)->name());
@@ -109,7 +109,7 @@
}
for (const DescriptionIndex& worker_index : tribe.workers()) {
const Economy::TargetQuantity & tq =
- m_eco->m_worker_target_quantities[worker_index];
+ eco_->worker_target_quantities_[worker_index];
if (Time const last_modified = tq.last_modified) {
fw.unsigned_32(last_modified);
fw.c_string(tribe.get_worker_descr(worker_index)->name());
@@ -117,7 +117,7 @@
}
}
fw.unsigned_32(0); // terminator
- fw.unsigned_32(m_eco->m_request_timerid);
+ fw.unsigned_32(eco_->request_timerid_);
}
}
=== modified file 'src/economy/economy_data_packet.h'
--- src/economy/economy_data_packet.h 2014-09-19 12:54:54 +0000
+++ src/economy/economy_data_packet.h 2016-02-07 07:48:48 +0000
@@ -31,13 +31,13 @@
class EconomyDataPacket {
public:
- EconomyDataPacket(Economy * e) : m_eco(e) {}
+ EconomyDataPacket(Economy * e) : eco_(e) {}
void read(FileRead &);
void write(FileWrite &);
private:
- Economy * m_eco;
+ Economy * eco_;
};
}
=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc 2015-11-29 09:43:15 +0000
+++ src/economy/flag.cc 2016-02-07 07:48:48 +0000
@@ -48,14 +48,14 @@
*/
Flag::Flag() :
PlayerImmovable(g_flag_descr),
-m_animstart(0),
-m_building(nullptr),
-m_ware_capacity(8),
-m_ware_filled(0),
-m_wares(new PendingWare[m_ware_capacity]),
-m_always_call_for_flag(nullptr)
+animstart_(0),
+building_(nullptr),
+ware_capacity_(8),
+ware_filled_(0),
+wares_(new PendingWare[ware_capacity_]),
+always_call_for_flag_(nullptr)
{
- for (uint32_t i = 0; i < 6; ++i) m_roads[i] = nullptr;
+ for (uint32_t i = 0; i < 6; ++i) roads_[i] = nullptr;
}
/**
@@ -64,18 +64,18 @@
*/
Flag::~Flag()
{
- if (m_ware_filled)
+ if (ware_filled_)
log("Flag: ouch! wares left\n");
- delete[] m_wares;
+ delete[] wares_;
- if (m_building)
+ if (building_)
log("Flag: ouch! building left\n");
- if (m_flag_jobs.size())
+ if (flag_jobs_.size())
log("Flag: ouch! flagjobs left\n");
for (int32_t i = 0; i < 6; ++i)
- if (m_roads[i])
+ if (roads_[i])
log("Flag: ouch! road left\n");
}
@@ -102,9 +102,9 @@
return false;
};
- m_capacity_wait.erase(
- std::remove_if(m_capacity_wait.begin(), m_capacity_wait.end(), should_be_deleted),
- m_capacity_wait.end());
+ capacity_wait_.erase(
+ std::remove_if(capacity_wait_.begin(), capacity_wait_.end(), should_be_deleted),
+ capacity_wait_.end());
}
/**
@@ -114,13 +114,13 @@
(EditorGameBase & egbase, Player & owning_player, Coords const coords)
:
PlayerImmovable (g_flag_descr),
- m_building (nullptr),
- m_ware_capacity (8),
- m_ware_filled (0),
- m_wares (new PendingWare[m_ware_capacity]),
- m_always_call_for_flag(nullptr)
+ building_ (nullptr),
+ ware_capacity_ (8),
+ ware_filled_ (0),
+ wares_ (new PendingWare[ware_capacity_]),
+ always_call_for_flag_(nullptr)
{
- for (uint32_t i = 0; i < 6; ++i) m_roads[i] = nullptr;
+ for (uint32_t i = 0; i < 6; ++i) roads_[i] = nullptr;
set_owner(&owning_player);
@@ -146,7 +146,7 @@
}
void Flag::set_flag_position(Coords coords) {
- m_position = coords;
+ position_ = coords;
}
int32_t Flag::get_size() const
@@ -176,19 +176,19 @@
PlayerImmovable::set_economy(e);
- for (int32_t i = 0; i < m_ware_filled; ++i)
- m_wares[i].ware->set_economy(e);
-
- if (m_building)
- m_building->set_economy(e);
-
- for (const FlagJob& temp_job : m_flag_jobs) {
+ for (int32_t i = 0; i < ware_filled_; ++i)
+ wares_[i].ware->set_economy(e);
+
+ if (building_)
+ building_->set_economy(e);
+
+ for (const FlagJob& temp_job : flag_jobs_) {
temp_job.request->set_economy(e);
}
for (int8_t i = 0; i < 6; ++i) {
- if (m_roads[i])
- m_roads[i]->set_economy(e);
+ if (roads_[i])
+ roads_[i]->set_economy(e);
}
}
@@ -197,15 +197,15 @@
*/
void Flag::attach_building(EditorGameBase & egbase, Building & building)
{
- assert(!m_building || m_building == &building);
+ assert(!building_ || building_ == &building);
- m_building = &building;
+ building_ = &building;
const Map & map = egbase.map();
egbase.set_road
- (map.get_fcoords(map.tl_n(m_position)),
+ (map.get_fcoords(map.tl_n(position_)),
RoadType::kSouthEast,
- m_building->get_size() == BaseImmovable::SMALL? RoadType::kNormal : RoadType::kBusy);
+ building_->get_size() == BaseImmovable::SMALL? RoadType::kNormal : RoadType::kBusy);
building.set_economy(get_economy());
}
@@ -215,15 +215,15 @@
*/
void Flag::detach_building(EditorGameBase & egbase)
{
- assert(m_building);
+ assert(building_);
- m_building->set_economy(nullptr);
+ building_->set_economy(nullptr);
const Map & map = egbase.map();
egbase.set_road
- (map.get_fcoords(map.tl_n(m_position)), RoadType::kSouthEast, RoadType::kNone);
+ (map.get_fcoords(map.tl_n(position_)), RoadType::kSouthEast, RoadType::kNone);
- m_building = nullptr;
+ building_ = nullptr;
}
/**
@@ -231,10 +231,10 @@
*/
void Flag::attach_road(int32_t const dir, Road * const road)
{
- assert(!m_roads[dir - 1] || m_roads[dir - 1] == road);
+ assert(!roads_[dir - 1] || roads_[dir - 1] == road);
- m_roads[dir - 1] = road;
- m_roads[dir - 1]->set_economy(get_economy());
+ roads_[dir - 1] = road;
+ roads_[dir - 1]->set_economy(get_economy());
}
/**
@@ -242,10 +242,10 @@
*/
void Flag::detach_road(int32_t const dir)
{
- assert(m_roads[dir - 1]);
+ assert(roads_[dir - 1]);
- m_roads[dir - 1]->set_economy(nullptr);
- m_roads[dir - 1] = nullptr;
+ roads_[dir - 1]->set_economy(nullptr);
+ roads_[dir - 1] = nullptr;
}
/**
@@ -255,7 +255,7 @@
(const EditorGameBase &) const
{
PositionList rv;
- rv.push_back(m_position);
+ rv.push_back(position_);
return rv;
}
@@ -265,7 +265,7 @@
void Flag::get_neighbours(WareWorker type, RoutingNodeNeighbours & neighbours)
{
for (int8_t i = 0; i < 6; ++i) {
- Road * const road = m_roads[i];
+ Road * const road = roads_[i];
if (!road)
continue;
@@ -286,8 +286,8 @@
neighbours.push_back(n);
}
- if (m_building && m_building->descr().get_isport()) {
- Warehouse * wh = static_cast<Warehouse *>(m_building);
+ if (building_ && building_->descr().get_isport()) {
+ Warehouse * wh = static_cast<Warehouse *>(building_);
if (PortDock * pd = wh->get_portdock()) {
pd->add_neighbours(neighbours);
}
@@ -300,7 +300,7 @@
Road * Flag::get_road(Flag & flag)
{
for (int8_t i = 0; i < 6; ++i)
- if (Road * const road = m_roads[i])
+ if (Road * const road = roads_[i])
if
(&road->get_flag(Road::FlagStart) == &flag ||
&road->get_flag(Road::FlagEnd) == &flag)
@@ -343,7 +343,7 @@
*/
bool Flag::has_capacity() const
{
- return (m_ware_filled < m_ware_capacity);
+ return (ware_filled_ < ware_capacity_);
}
/**
@@ -354,7 +354,7 @@
*/
void Flag::wait_for_capacity(Game &, Worker & bob)
{
- m_capacity_wait.push_back(&bob);
+ capacity_wait_.push_back(&bob);
}
/**
@@ -363,18 +363,18 @@
void Flag::skip_wait_for_capacity(Game &, Worker & w)
{
CapacityWaitQueue::iterator const it =
- std::find(m_capacity_wait.begin(), m_capacity_wait.end(), &w);
- if (it != m_capacity_wait.end())
- m_capacity_wait.erase(it);
+ std::find(capacity_wait_.begin(), capacity_wait_.end(), &w);
+ if (it != capacity_wait_.end())
+ capacity_wait_.erase(it);
}
void Flag::add_ware(EditorGameBase & egbase, WareInstance & ware)
{
- assert(m_ware_filled < m_ware_capacity);
+ assert(ware_filled_ < ware_capacity_);
- PendingWare & pi = m_wares[m_ware_filled++];
+ PendingWare & pi = wares_[ware_filled_++];
pi.ware = &ware;
pi.pending = false;
pi.nextstep = nullptr;
@@ -406,11 +406,11 @@
* for a building destination.
*/
bool Flag::has_pending_ware(Game &, Flag & dest) {
- for (int32_t i = 0; i < m_ware_filled; ++i) {
- if (!m_wares[i].pending)
+ for (int32_t i = 0; i < ware_filled_; ++i) {
+ if (!wares_[i].pending)
continue;
- if (m_wares[i].nextstep != &dest)
+ if (wares_[i].nextstep != &dest)
continue;
return true;
@@ -435,25 +435,25 @@
int32_t highest_pri = -1;
int32_t i_pri = -1;
- for (int32_t i = 0; i < m_ware_filled; ++i) {
- if (!m_wares[i].pending)
- continue;
-
- if (m_wares[i].nextstep != &destflag)
- continue;
-
- if (m_wares[i].priority > highest_pri) {
- highest_pri = m_wares[i].priority;
+ for (int32_t i = 0; i < ware_filled_; ++i) {
+ if (!wares_[i].pending)
+ continue;
+
+ if (wares_[i].nextstep != &destflag)
+ continue;
+
+ if (wares_[i].priority > highest_pri) {
+ highest_pri = wares_[i].priority;
i_pri = i;
// Increase ware priority, it matters only if the ware has to wait.
- if (m_wares[i].priority < MAX_TRANSFER_PRIORITY)
- m_wares[i].priority++;
+ if (wares_[i].priority < MAX_TRANSFER_PRIORITY)
+ wares_[i].priority++;
}
}
if (i_pri >= 0) {
- m_wares[i_pri].pending = false;
+ wares_[i_pri].pending = false;
return true;
}
@@ -469,22 +469,22 @@
int32_t lowest_prio = MAX_TRANSFER_PRIORITY + 1;
int32_t i_pri = -1;
- for (int32_t i = 0; i < m_ware_filled; ++i) {
- if (m_wares[i].pending)
- continue;
-
- if (m_wares[i].nextstep != &destflag)
- continue;
-
- if (m_wares[i].priority < lowest_prio) {
- lowest_prio = m_wares[i].priority;
+ for (int32_t i = 0; i < ware_filled_; ++i) {
+ if (wares_[i].pending)
+ continue;
+
+ if (wares_[i].nextstep != &destflag)
+ continue;
+
+ if (wares_[i].priority < lowest_prio) {
+ lowest_prio = wares_[i].priority;
i_pri = i;
}
}
if (i_pri >= 0) {
- m_wares[i_pri].pending = true;
- m_wares[i_pri].ware->update(game); // will call call_carrier() if necessary
+ wares_[i_pri].pending = true;
+ wares_[i_pri].ware->update(game); // will call call_carrier() if necessary
return true;
}
@@ -496,9 +496,9 @@
*/
void Flag::wake_up_capacity_queue(Game & game)
{
- while (!m_capacity_wait.empty()) {
- Worker * const w = m_capacity_wait[0].get(game);
- m_capacity_wait.erase(m_capacity_wait.begin());
+ while (!capacity_wait_.empty()) {
+ Worker * const w = capacity_wait_[0].get(game);
+ capacity_wait_.erase(capacity_wait_.begin());
if (w && w->wakeup_flag_capacity(game, *this))
break;
}
@@ -515,12 +515,12 @@
{
int32_t best_index = -1;
- for (int32_t i = 0; i < m_ware_filled; ++i) {
- if (m_wares[i].nextstep != &dest)
+ for (int32_t i = 0; i < ware_filled_; ++i) {
+ if (wares_[i].nextstep != &dest)
continue;
// We prefer to retrieve wares that have already been acked
- if (best_index < 0 || !m_wares[i].pending)
+ if (best_index < 0 || !wares_[i].pending)
best_index = i;
}
@@ -528,11 +528,11 @@
return nullptr;
// move the other wares up the list and return this one
- WareInstance * const ware = m_wares[best_index].ware;
- --m_ware_filled;
+ WareInstance * const ware = wares_[best_index].ware;
+ --ware_filled_;
memmove
- (&m_wares[best_index], &m_wares[best_index + 1],
- sizeof(m_wares[0]) * (m_ware_filled - best_index));
+ (&wares_[best_index], &wares_[best_index + 1],
+ sizeof(wares_[0]) * (ware_filled_ - best_index));
ware->set_location(game, nullptr);
@@ -549,8 +549,8 @@
Flag::Wares Flag::get_wares() {
Wares rv;
- for (int32_t i = 0; i < m_ware_filled; ++i)
- rv.push_back(m_wares[i].ware);
+ for (int32_t i = 0; i < ware_filled_; ++i)
+ rv.push_back(wares_[i].ware);
return rv;
}
@@ -561,14 +561,14 @@
*/
void Flag::remove_ware(EditorGameBase & egbase, WareInstance * const ware)
{
- for (int32_t i = 0; i < m_ware_filled; ++i) {
- if (m_wares[i].ware != ware)
+ for (int32_t i = 0; i < ware_filled_; ++i) {
+ if (wares_[i].ware != ware)
continue;
- --m_ware_filled;
+ --ware_filled_;
memmove
- (&m_wares[i], &m_wares[i + 1],
- sizeof(m_wares[0]) * (m_ware_filled - i));
+ (&wares_[i], &wares_[i + 1],
+ sizeof(wares_[0]) * (ware_filled_ - i));
if (upcast(Game, game, &egbase))
wake_up_capacity_queue(*game);
@@ -591,7 +591,7 @@
* nextstep is compared with the cached data, and a new carrier is only called
* if that data hasn't changed.
*
- * This behaviour is overridden by m_always_call_for_step, which is set by
+ * This behaviour is overridden by always_call_for_step_, which is set by
* update_wares() to ensure that new carriers are called when roads are
* split, for example.
*/
@@ -602,11 +602,11 @@
int32_t i = 0;
// Find the PendingWare entry
- for (; i < m_ware_filled; ++i) {
- if (m_wares[i].ware != &ware)
+ for (; i < ware_filled_; ++i) {
+ if (wares_[i].ware != &ware)
continue;
- pi = &m_wares[i];
+ pi = &wares_[i];
break;
}
@@ -620,7 +620,7 @@
}
// Find out whether we need to do anything
- if (pi->nextstep == nextstep && pi->nextstep != m_always_call_for_flag)
+ if (pi->nextstep == nextstep && pi->nextstep != always_call_for_flag_)
return; // no update needed
pi->nextstep = nextstep;
@@ -690,21 +690,21 @@
*/
void Flag::update_wares(Game & game, Flag * const other)
{
- m_always_call_for_flag = other;
-
- for (int32_t i = 0; i < m_ware_filled; ++i)
- m_wares[i].ware->update(game);
-
- m_always_call_for_flag = nullptr;
+ always_call_for_flag_ = other;
+
+ for (int32_t i = 0; i < ware_filled_; ++i)
+ wares_[i].ware->update(game);
+
+ always_call_for_flag_ = nullptr;
}
void Flag::init(EditorGameBase & egbase)
{
PlayerImmovable::init(egbase);
- set_position(egbase, m_position);
+ set_position(egbase, position_);
- m_animstart = egbase.get_gametime();
+ animstart_ = egbase.get_gametime();
}
/**
@@ -714,13 +714,13 @@
{
//molog("Flag::cleanup\n");
- while (!m_flag_jobs.empty()) {
- delete m_flag_jobs.begin()->request;
- m_flag_jobs.erase(m_flag_jobs.begin());
+ while (!flag_jobs_.empty()) {
+ delete flag_jobs_.begin()->request;
+ flag_jobs_.erase(flag_jobs_.begin());
}
- while (m_ware_filled) {
- WareInstance & ware = *m_wares[--m_ware_filled].ware;
+ while (ware_filled_) {
+ WareInstance & ware = *wares_[--ware_filled_].ware;
ware.set_location(egbase, nullptr);
ware.destroy (egbase);
@@ -728,22 +728,22 @@
//molog(" wares destroyed\n");
- if (m_building) {
- m_building->remove(egbase); // immediate death
- assert(!m_building);
+ if (building_) {
+ building_->remove(egbase); // immediate death
+ assert(!building_);
}
for (int8_t i = 0; i < 6; ++i) {
- if (m_roads[i]) {
- m_roads[i]->remove(egbase); // immediate death
- assert(!m_roads[i]);
+ if (roads_[i]) {
+ roads_[i]->remove(egbase); // immediate death
+ assert(!roads_[i]);
}
}
if (Economy * e = get_economy())
e->remove_flag(*this);
- unset_position(egbase, m_position);
+ unset_position(egbase, position_);
//molog(" done\n");
@@ -753,15 +753,15 @@
/**
* Destroy the building as well.
*
- * \note This is needed in addition to the call to m_building->remove() in
+ * \note This is needed in addition to the call to building_->remove() in
* \ref Flag::cleanup(). This function is needed to ensure a fire is created
* when a player removes a flag.
*/
void Flag::destroy(EditorGameBase & egbase)
{
- if (m_building) {
- m_building->destroy(egbase);
- assert(!m_building);
+ if (building_) {
+ building_->destroy(egbase);
+ assert(!building_);
}
PlayerImmovable::destroy(egbase);
@@ -781,7 +781,7 @@
(*this, workerware, Flag::flag_job_request_callback, wwWORKER);
j.program = programname;
- m_flag_jobs.push_back(j);
+ flag_jobs_.push_back(j);
}
/**
@@ -799,15 +799,15 @@
assert(w);
- for (FlagJobs::iterator flag_iter = flag.m_flag_jobs.begin();
- flag_iter != flag.m_flag_jobs.end();
+ for (FlagJobs::iterator flag_iter = flag.flag_jobs_.begin();
+ flag_iter != flag.flag_jobs_.end();
++flag_iter) {
if (flag_iter->request == &rq) {
delete &rq;
w->start_task_program(game, flag_iter->program);
- flag.m_flag_jobs.erase(flag_iter);
+ flag.flag_jobs_.erase(flag_iter);
return;
}
}
@@ -817,17 +817,17 @@
void Flag::log_general_info(const Widelands::EditorGameBase & egbase)
{
- molog("Flag at %i,%i\n", m_position.x, m_position.y);
+ molog("Flag at %i,%i\n", position_.x, position_.y);
Widelands::PlayerImmovable::log_general_info(egbase);
- if (m_ware_filled) {
+ if (ware_filled_) {
molog("Wares at flag:\n");
- for (int i = 0; i < m_ware_filled; ++i) {
- PendingWare & pi = m_wares[i];
+ for (int i = 0; i < ware_filled_; ++i) {
+ PendingWare & pi = wares_[i];
molog
(" %i/%i: %s(%i), nextstep %i, %s\n",
- i + 1, m_ware_capacity,
+ i + 1, ware_capacity_,
pi.ware->descr().name().c_str(), pi.ware->serial(),
pi.nextstep.serial(),
pi.pending ? "pending" : "acked by carrier");
=== modified file 'src/economy/flag.h'
--- src/economy/flag.h 2015-11-28 22:29:26 +0000
+++ src/economy/flag.h 2016-02-07 07:48:48 +0000
@@ -57,7 +57,7 @@
* worker is to execute. Once execution of the program has finished, the worker
* will return to a warehouse.
*
- * Important: Do not access m_roads directly. get_road() and others use
+ * Important: Do not access roads_ directly. get_road() and others use
* WALK_xx in all "direction" parameters.
*/
struct Flag : public PlayerImmovable, public RoutingNode {
@@ -84,23 +84,23 @@
Flag & base_flag() override;
- const Coords & get_position() const override {return m_position;}
+ const Coords & get_position() const override {return position_;}
PositionList get_positions (const EditorGameBase &) const override;
void get_neighbours(WareWorker type, RoutingNodeNeighbours &) override;
- int32_t get_waitcost() const {return m_ware_filled;}
+ int32_t get_waitcost() const {return ware_filled_;}
void set_economy(Economy *) override;
- Building * get_building() const {return m_building;}
+ Building * get_building() const {return building_;}
void attach_building(EditorGameBase &, Building &);
void detach_building(EditorGameBase &);
bool has_road() const {
return
- m_roads[0] || m_roads[1] || m_roads[2] ||
- m_roads[3] || m_roads[4] || m_roads[5];
+ roads_[0] || roads_[1] || roads_[2] ||
+ roads_[3] || roads_[4] || roads_[5];
}
- Road * get_road(uint8_t const dir) const {return m_roads[dir - 1];}
+ Road * get_road(uint8_t const dir) const {return roads_[dir - 1];}
uint8_t nr_of_roads() const;
void attach_road(int32_t dir, Road *);
void detach_road(int32_t dir);
@@ -110,8 +110,8 @@
bool is_dead_end() const;
bool has_capacity() const;
- uint32_t total_capacity() {return m_ware_capacity;}
- uint32_t current_wares() const {return m_ware_filled;}
+ uint32_t total_capacity() {return ware_capacity_;}
+ uint32_t current_wares() const {return ware_filled_;}
void wait_for_capacity(Game &, Worker &);
void skip_wait_for_capacity(Game &, Worker &);
void add_ware(EditorGameBase &, WareInstance &);
@@ -155,25 +155,25 @@
std::string program;
};
- Coords m_position;
- int32_t m_animstart;
-
- Building * m_building; ///< attached building (replaces road WALK_NW)
- Road * m_roads[6]; ///< WALK_xx - 1 as index
-
- int32_t m_ware_capacity; ///< size of m_wares array
- int32_t m_ware_filled; ///< number of wares currently on the flag
- PendingWare * m_wares; ///< wares currently on the flag
+ Coords position_;
+ int32_t animstart_;
+
+ Building * building_; ///< attached building (replaces road WALK_NW)
+ Road * roads_[6]; ///< WALK_xx - 1 as index
+
+ int32_t ware_capacity_; ///< size of wares_ array
+ int32_t ware_filled_; ///< number of wares currently on the flag
+ PendingWare * wares_; ///< wares currently on the flag
/// call_carrier() will always call a carrier when the destination is
/// the given flag
- Flag * m_always_call_for_flag;
+ Flag * always_call_for_flag_;
using CapacityWaitQueue = std::vector<OPtr<Worker>>;
- CapacityWaitQueue m_capacity_wait; ///< workers waiting for capacity
+ CapacityWaitQueue capacity_wait_; ///< workers waiting for capacity
using FlagJobs = std::list<FlagJob>;
- FlagJobs m_flag_jobs;
+ FlagJobs flag_jobs_;
};
extern FlagDescr g_flag_descr;
=== modified file 'src/economy/fleet.cc'
--- src/economy/fleet.cc 2016-01-06 19:11:20 +0000
+++ src/economy/fleet.cc 2016-02-07 07:48:48 +0000
@@ -58,8 +58,8 @@
*/
Fleet::Fleet(Player & player) :
MapObject(&g_fleet_descr),
- m_owner(player),
- m_act_pending(false)
+ owner_(player),
+ act_pending_(false)
{
}
@@ -69,7 +69,7 @@
*/
bool Fleet::active() const
{
- return !m_ships.empty() && !m_ports.empty();
+ return !ships_.empty() && !ports_.empty();
}
/**
@@ -79,9 +79,9 @@
*/
void Fleet::set_economy(Economy * e)
{
- if (!m_ships.empty()) {
- if (!m_ports.empty()) {
- e = m_ports[0]->get_economy();
+ if (!ships_.empty()) {
+ if (!ports_.empty()) {
+ e = ports_[0]->get_economy();
}
#ifndef NDEBUG
else
@@ -89,7 +89,7 @@
#endif
if (upcast(Game, game, &owner().egbase())) {
- for (Ship * temp_ship : m_ships) {
+ for (Ship * temp_ship : ships_) {
temp_ship->set_economy(*game, e);
}
}
@@ -104,7 +104,7 @@
{
MapObject::init(egbase);
- if (m_ships.empty() && m_ports.empty()) {
+ if (ships_.empty() && ports_.empty()) {
molog("Empty fleet initialized; disband immediately\n");
remove(egbase);
return;
@@ -144,11 +144,11 @@
Map & map = egbase.map();
MapAStar<StepEvalFindFleet> astar(map, StepEvalFindFleet());
- for (const Ship * temp_ship : m_ships) {
+ for (const Ship * temp_ship : ships_) {
astar.push(temp_ship->get_position());
}
- for (const PortDock * temp_port : m_ports) {
+ for (const PortDock * temp_port : ports_) {
BaseImmovable::PositionList pos = temp_port->get_positions(egbase);
for (const Coords& temp_pos : pos) {
@@ -166,8 +166,8 @@
// this test, might be removed after some time
if (dock->get_fleet() == nullptr) {
log ("The dock on %3dx%3d withouth a fleet!\n",
- dock->m_dockpoints.front().x,
- dock->m_dockpoints.front().y);
+ dock->dockpoints_.front().x,
+ dock->dockpoints_.front().y);
}
if (dock->get_fleet() != this && dock->get_owner() == get_owner()) {
dock->get_fleet()->merge(egbase, this);
@@ -200,36 +200,36 @@
*/
void Fleet::merge(EditorGameBase & egbase, Fleet * other)
{
- if (m_ports.empty() && !other->m_ports.empty()) {
+ if (ports_.empty() && !other->ports_.empty()) {
other->merge(egbase, this);
return;
}
- while (!other->m_ships.empty()) {
- Ship * ship = other->m_ships.back();
- other->m_ships.pop_back();
+ while (!other->ships_.empty()) {
+ Ship * ship = other->ships_.back();
+ other->ships_.pop_back();
add_ship(ship);
}
- uint32_t old_nrports = m_ports.size();
- m_ports.insert(m_ports.end(), other->m_ports.begin(), other->m_ports.end());
- m_portpaths.resize((m_ports.size() * (m_ports.size() - 1)) / 2);
+ uint32_t old_nrports = ports_.size();
+ ports_.insert(ports_.end(), other->ports_.begin(), other->ports_.end());
+ portpaths_.resize((ports_.size() * (ports_.size() - 1)) / 2);
- for (uint32_t j = 1; j < other->m_ports.size(); ++j) {
+ for (uint32_t j = 1; j < other->ports_.size(); ++j) {
for (uint32_t i = 0; i < j; ++i) {
portpath(old_nrports + i, old_nrports + j) = other->portpath(i, j);
}
}
- for (uint32_t idx = old_nrports; idx < m_ports.size(); ++idx) {
- m_ports[idx]->set_fleet(this);
+ for (uint32_t idx = old_nrports; idx < ports_.size(); ++idx) {
+ ports_[idx]->set_fleet(this);
}
- if (!m_ships.empty() && !m_ports.empty())
+ if (!ships_.empty() && !ports_.empty())
check_merge_economy();
- other->m_ports.clear();
- other->m_portpaths.clear();
+ other->ports_.clear();
+ other->portpaths_.clear();
other->remove(egbase);
update(egbase);
@@ -240,35 +240,35 @@
*/
void Fleet::check_merge_economy()
{
- if (m_ports.empty() || m_ships.empty())
+ if (ports_.empty() || ships_.empty())
return;
- Flag & base = m_ports[0]->base_flag();
- for (uint32_t i = 1; i < m_ports.size(); ++i) {
+ Flag & base = ports_[0]->base_flag();
+ for (uint32_t i = 1; i < ports_.size(); ++i) {
// Note: economy of base flag may of course be changed by the merge!
- base.get_economy()->check_merge(base, m_ports[i]->base_flag());
+ base.get_economy()->check_merge(base, ports_[i]->base_flag());
}
}
void Fleet::cleanup(EditorGameBase & egbase)
{
- while (!m_ports.empty()) {
- PortDock * pd = m_ports.back();
- m_ports.pop_back();
+ while (!ports_.empty()) {
+ PortDock * pd = ports_.back();
+ ports_.pop_back();
pd->set_fleet(nullptr);
- if (!m_ports.empty() && !m_ships.empty()) {
+ if (!ports_.empty() && !ships_.empty()) {
// This is required when, during end-of-game cleanup,
// the fleet gets removed before the ports
- Flag & base = m_ports[0]->base_flag();
+ Flag & base = ports_[0]->base_flag();
Economy::check_split(base, pd->base_flag());
}
}
- m_portpaths.clear();
+ portpaths_.clear();
- while (!m_ships.empty()) {
- m_ships.back()->set_fleet(nullptr);
- m_ships.pop_back();
+ while (!ships_.empty()) {
+ ships_.back()->set_fleet(nullptr);
+ ships_.pop_back();
}
MapObject::cleanup(egbase);
@@ -278,14 +278,14 @@
{
assert(i < j);
- return m_portpaths[((j - 1) * j) / 2 + i];
+ return portpaths_[((j - 1) * j) / 2 + i];
}
const Fleet::PortPath & Fleet::portpath(uint32_t i, uint32_t j) const
{
assert(i < j);
- return m_portpaths[((j - 1) * j) / 2 + i];
+ return portpaths_[((j - 1) * j) / 2 + i];
}
Fleet::PortPath & Fleet::portpath_bidir(uint32_t i, uint32_t j, bool & reverse)
@@ -315,10 +315,10 @@
*/
bool Fleet::get_path(PortDock & start, PortDock & end, Path & path)
{
- uint32_t startidx = std::find(m_ports.begin(), m_ports.end(), &start) - m_ports.begin();
- uint32_t endidx = std::find(m_ports.begin(), m_ports.end(), &end) - m_ports.begin();
+ uint32_t startidx = std::find(ports_.begin(), ports_.end(), &start) - ports_.begin();
+ uint32_t endidx = std::find(ports_.begin(), ports_.end(), &end) - ports_.begin();
- if (startidx >= m_ports.size() || endidx >= m_ports.size())
+ if (startidx >= ports_.size() || endidx >= ports_.size())
return false;
bool reverse;
@@ -338,13 +338,13 @@
}
uint32_t Fleet::count_ships(){
- return m_ships.size();
+ return ships_.size();
}
uint32_t Fleet::count_ships_heading_here(EditorGameBase & egbase, PortDock * port){
uint32_t ships_on_way = 0;
- for (uint16_t s = 0; s < m_ships.size(); s += 1){
- if (m_ships[s]->get_destination(egbase) == port){
+ for (uint16_t s = 0; s < ships_.size(); s += 1){
+ if (ships_[s]->get_destination(egbase) == port){
ships_on_way += 1;
}
}
@@ -353,17 +353,17 @@
}
uint32_t Fleet::count_ports(){
- return m_ports.size();
+ return ports_.size();
}
bool Fleet::get_act_pending(){
- return m_act_pending;
+ return act_pending_;
}
void Fleet::add_neighbours(PortDock & pd, std::vector<RoutingNodeNeighbour> & neighbours)
{
- uint32_t idx = std::find(m_ports.begin(), m_ports.end(), &pd) - m_ports.begin();
+ uint32_t idx = std::find(ports_.begin(), ports_.end(), &pd) - ports_.begin();
- for (uint32_t otheridx = 0; otheridx < m_ports.size(); ++otheridx) {
+ for (uint32_t otheridx = 0; otheridx < ports_.size(); ++otheridx) {
if (idx == otheridx)
continue;
@@ -377,7 +377,7 @@
if (pp.cost >= 0) {
// TODO(unknown): keep statistics on average transport time instead of using the arbitrary 2x factor
- RoutingNodeNeighbour neighb(&m_ports[otheridx]->base_flag(), 2 * pp.cost);
+ RoutingNodeNeighbour neighb(&ports_[otheridx]->base_flag(), 2 * pp.cost);
neighbours.push_back(neighb);
}
}
@@ -385,26 +385,26 @@
void Fleet::add_ship(Ship * ship)
{
- m_ships.push_back(ship);
+ ships_.push_back(ship);
ship->set_fleet(this);
if (upcast(Game, game, &owner().egbase())) {
- if (m_ports.empty())
+ if (ports_.empty())
ship->set_economy(*game, nullptr);
else
- ship->set_economy(*game, m_ports[0]->get_economy());
+ ship->set_economy(*game, ports_[0]->get_economy());
}
- if (m_ships.size() == 1) {
+ if (ships_.size() == 1) {
check_merge_economy();
}
}
void Fleet::remove_ship(EditorGameBase & egbase, Ship * ship)
{
- std::vector<Ship *>::iterator it = std::find(m_ships.begin(), m_ships.end(), ship);
- if (it != m_ships.end()) {
- *it = m_ships.back();
- m_ships.pop_back();
+ std::vector<Ship *>::iterator it = std::find(ships_.begin(), ships_.end(), ship);
+ if (it != ships_.end()) {
+ *it = ships_.back();
+ ships_.pop_back();
}
ship->set_fleet(nullptr);
if (upcast(Game, game, &egbase))
@@ -414,16 +414,16 @@
update(egbase);
}
- if (m_ships.empty()) {
- if (m_ports.empty()) {
+ if (ships_.empty()) {
+ if (ports_.empty()) {
remove(egbase);
} else {
- Flag & base = m_ports[0]->base_flag();
- for (uint32_t i = 1; i < m_ports.size(); ++i) {
+ Flag & base = ports_[0]->base_flag();
+ for (uint32_t i = 1; i < ports_.size(); ++i) {
// since two ports can be connected by land, it is possible that
// disconnecting a previous port also disconnects later ports
- if (base.get_economy() == m_ports[i]->base_flag().get_economy())
- Economy::check_split(base, m_ports[i]->base_flag());
+ if (base.get_economy() == ports_[i]->base_flag().get_economy())
+ Economy::check_split(base, ports_[i]->base_flag());
}
}
}
@@ -455,7 +455,7 @@
};
/**
- * Fill in all unknown paths to connect the port m_ports[idx] to the rest of the ports.
+ * Fill in all unknown paths to connect the port ports_[idx] to the rest of the ports.
*
* Note that this is done lazily, i.e. the first time a path is actually requested,
* because path finding is flaky during map loading.
@@ -465,7 +465,7 @@
Map & map = egbase.map();
StepEvalFindPorts se;
- for (uint32_t i = 0; i < m_ports.size(); ++i) {
+ for (uint32_t i = 0; i < ports_.size(); ++i) {
if (i == idx)
continue;
@@ -475,7 +475,7 @@
StepEvalFindPorts::Target tgt;
tgt.idx = i;
- tgt.pos = m_ports[i]->get_warehouse()->get_position();
+ tgt.pos = ports_[i]->get_warehouse()->get_position();
se.targets.push_back(tgt);
}
@@ -484,7 +484,7 @@
MapAStar<StepEvalFindPorts> astar(map, se);
- BaseImmovable::PositionList src(m_ports[idx]->get_positions(egbase));
+ BaseImmovable::PositionList src(ports_[idx]->get_positions(egbase));
for (const Coords& temp_pos : src) {
astar.push(temp_pos);
}
@@ -505,7 +505,7 @@
continue;
}
- uint32_t otheridx = std::find(m_ports.begin(), m_ports.end(), pd) - m_ports.begin();
+ uint32_t otheridx = std::find(ports_.begin(), ports_.end(), pd) - ports_.begin();
if (idx == otheridx)
continue;
@@ -538,47 +538,47 @@
void Fleet::add_port(EditorGameBase & /* egbase */, PortDock * port)
{
- m_ports.push_back(port);
+ ports_.push_back(port);
port->set_fleet(this);
- if (m_ports.size() == 1) {
- set_economy(m_ports[0]->get_economy());
+ if (ports_.size() == 1) {
+ set_economy(ports_[0]->get_economy());
} else {
- if (!m_ships.empty())
- m_ports[0]->get_economy()->check_merge(m_ports[0]->base_flag(), port->base_flag());
+ if (!ships_.empty())
+ ports_[0]->get_economy()->check_merge(ports_[0]->base_flag(), port->base_flag());
}
- m_portpaths.resize((m_ports.size() * (m_ports.size() - 1)) / 2);
+ portpaths_.resize((ports_.size() * (ports_.size() - 1)) / 2);
}
void Fleet::remove_port(EditorGameBase & egbase, PortDock * port)
{
- std::vector<PortDock *>::iterator it = std::find(m_ports.begin(), m_ports.end(), port);
- if (it != m_ports.end()) {
- uint32_t gap = it - m_ports.begin();
+ std::vector<PortDock *>::iterator it = std::find(ports_.begin(), ports_.end(), port);
+ if (it != ports_.end()) {
+ uint32_t gap = it - ports_.begin();
for (uint32_t i = 0; i < gap; ++i) {
- portpath(i, gap) = portpath(i, m_ports.size() - 1);
+ portpath(i, gap) = portpath(i, ports_.size() - 1);
}
- for (uint32_t i = gap + 1; i < m_ports.size() - 1; ++i) {
- portpath(gap, i) = portpath(i, m_ports.size() - 1);
+ for (uint32_t i = gap + 1; i < ports_.size() - 1; ++i) {
+ portpath(gap, i) = portpath(i, ports_.size() - 1);
if (portpath(gap, i).path)
portpath(gap, i).path->reverse();
}
- m_portpaths.resize((m_ports.size() * (m_ports.size() - 1)) / 2);
+ portpaths_.resize((ports_.size() * (ports_.size() - 1)) / 2);
- *it = m_ports.back();
- m_ports.pop_back();
+ *it = ports_.back();
+ ports_.pop_back();
}
port->set_fleet(nullptr);
- if (m_ports.empty()) {
+ if (ports_.empty()) {
set_economy(nullptr);
} else {
- set_economy(m_ports[0]->get_economy());
- if (!m_ships.empty())
- Economy::check_split(m_ports[0]->base_flag(), port->base_flag());
+ set_economy(ports_[0]->get_economy());
+ if (!ships_.empty())
+ Economy::check_split(ports_[0]->base_flag(), port->base_flag());
}
- if (m_ships.empty() && m_ports.empty()) {
+ if (ships_.empty() && ports_.empty()) {
remove(egbase);
} else if (is_a(Game, &egbase)) {
// Some ship perhaps lose their destination now, so new a destination must be appointed (if any)
@@ -594,7 +594,7 @@
*/
PortDock * Fleet::get_dock(Flag & flag) const
{
- for (PortDock * temp_port : m_ports) {
+ for (PortDock * temp_port : ports_) {
if (&temp_port->base_flag() == &flag)
return temp_port;
}
@@ -610,7 +610,7 @@
*/
PortDock * Fleet::get_dock(EditorGameBase & egbase, Coords field_coords) const
{
- for (PortDock * temp_port : m_ports) {
+ for (PortDock * temp_port : ports_) {
for (Coords tmp_coords : temp_port->get_positions(egbase)) {
if (tmp_coords == field_coords){
return temp_port;
@@ -626,9 +626,9 @@
*/
PortDock * Fleet::get_arbitrary_dock() const
{
- if (m_ports.empty())
+ if (ports_.empty())
return nullptr;
- return m_ports[0];
+ return ports_[0];
}
/**
@@ -636,13 +636,13 @@
*/
void Fleet::update(EditorGameBase & egbase)
{
- if (m_act_pending){
+ if (act_pending_){
return;
}
if (upcast(Game, game, &egbase)) {
schedule_act(*game, 100);
- m_act_pending = true;
+ act_pending_ = true;
}
}
@@ -654,13 +654,13 @@
*/
void Fleet::act(Game & game, uint32_t /* data */)
{
- m_act_pending = false;
+ act_pending_ = false;
if (!active()) {
// If we are here, most likely act() was called by a port with waiting wares or an expedition ready
// although there are still no ships. We can't handle it now, so we reschedule the act()
schedule_act(game, 5000); // retry in the next time
- m_act_pending = true;
+ act_pending_ = true;
return;
}
@@ -669,7 +669,7 @@
// we need to calculate what ship is to be send to which port
// for this we will have temporary data structure with format
// <<ship,port>,score>
- // where ship and port are not objects but positions in m_ports and m_ships
+ // where ship and port are not objects but positions in ports_ and ships_
// this is to allow native hashing
std::map<std::pair<uint16_t, uint16_t>, uint16_t> scores;
@@ -692,21 +692,21 @@
// first we go over ships - idle ones (=without destination)
// then over wares on these ships and create first ship-port
// pairs with score
- for (uint16_t s = 0; s < m_ships.size(); s += 1){
- if (m_ships[s]->get_destination(game)) {
+ for (uint16_t s = 0; s < ships_.size(); s += 1){
+ if (ships_[s]->get_destination(game)) {
continue;
}
- if (m_ships[s]->get_ship_state() != Ship::TRANSPORT) {
+ if (ships_[s]->get_ship_state() != Ship::TRANSPORT) {
continue; // in expedition obviously
}
- for (uint16_t i = 0; i < m_ships[s]->get_nritems(); i += 1){
- PortDock * dst = m_ships[s]->m_items[i].get_destination(game);
+ for (uint16_t i = 0; i < ships_[s]->get_nritems(); i += 1){
+ PortDock * dst = ships_[s]->items_[i].get_destination(game);
if (!dst) {
// if wares without destination on ship without destination
// such ship can be send to any port, and should be sent
// to some port, so we add 1 point to score for each port
- for (uint16_t p = 0; p < m_ports.size(); p += 1){
+ for (uint16_t p = 0; p < ports_.size(); p += 1){
mapping.first = s;
mapping.second = p;
scores[mapping] += 1;
@@ -715,8 +715,8 @@
}
bool destination_found = false; //just a functional check
- for (uint16_t p = 0; p < m_ports.size(); p += 1){
- if (m_ports[p] == m_ships[s]->m_items[i].get_destination(game)){
+ for (uint16_t p = 0; p < ports_.size(); p += 1){
+ if (ports_[p] == ships_[s]->items_[i].get_destination(game)){
mapping.first = s;
mapping.second = p;
scores[mapping] += (i == 0)?8:1;
@@ -729,16 +729,16 @@
// during my testing this situation never happened
throw wexception("A ware with destination that does not match any of player's"
" ports, ship %u, ware's destination: %u",
- m_ships[s]->serial(),
- m_ships[s]->m_items[i].get_destination(game)->serial());
+ ships_[s]->serial(),
+ ships_[s]->items_[i].get_destination(game)->serial());
}
}
}
// now opposite aproach - we go over ports to find out those that have wares
// waiting for ship then find candidate ships to satisfy the requests
- for (uint16_t p = 0; p < m_ports.size(); p += 1){
- PortDock & pd = *m_ports[p];
+ for (uint16_t p = 0; p < ports_.size(); p += 1){
+ PortDock & pd = *ports_[p];
if (!pd.get_need_ship()){
continue;
}
@@ -753,24 +753,24 @@
// scoring and entering the pair into scores (or increasing existing
// score if the pair is already there)
- for (uint16_t s = 0; s < m_ships.size(); s += 1){
+ for (uint16_t s = 0; s < ships_.size(); s += 1){
- if (m_ships[s]->get_destination(game)) {
+ if (ships_[s]->get_destination(game)) {
continue; // already has destination
}
- if (m_ships[s]->get_ship_state() != Ship::TRANSPORT) {
+ if (ships_[s]->get_ship_state() != Ship::TRANSPORT) {
continue; // in expedition obviously
}
mapping.first = s;
mapping.second = p;
// folowing aproximately considers free capacity of a ship
- scores[mapping] += ((m_ships[s]->get_nritems() > 15)?1:3)
+ scores[mapping] += ((ships_[s]->get_nritems() > 15)?1:3)
+
std::min(
- m_ships[s]->descr().get_capacity() - m_ships[s]->get_nritems(),
- m_ports[p]->count_waiting()) / 3;
+ ships_[s]->descr().get_capacity() - ships_[s]->get_nritems(),
+ ports_[p]->count_waiting()) / 3;
}
}
@@ -784,16 +784,16 @@
// - if above fails, we calculate path "manually"
int16_t route_length = -1;
- PortDock * current_portdock = get_dock(game, m_ships[ship_port_relation.first.first]->get_position());
+ PortDock * current_portdock = get_dock(game, ships_[ship_port_relation.first.first]->get_position());
if (current_portdock) { // we try to use precalculated paths of game
// we are in the same portdock
- if (current_portdock == m_ports[ship_port_relation.first.second]) {
+ if (current_portdock == ports_[ship_port_relation.first.second]) {
route_length = 0;
} else { // it is different portdock then
Path tmp_path;
- if (get_path(*current_portdock, *m_ports[ship_port_relation.first.second], tmp_path)) {
+ if (get_path(*current_portdock, *ports_[ship_port_relation.first.second], tmp_path)) {
route_length = tmp_path.get_nsteps();
}
}
@@ -801,8 +801,8 @@
// most probably the ship is not in a portdock (should not happen frequently)
if (route_length == -1) {
- route_length = m_ships[ship_port_relation.first.first]->calculate_sea_route
- (game, *m_ports[ship_port_relation.first.second]);
+ route_length = ships_[ship_port_relation.first.first]->calculate_sea_route
+ (game, *ports_[ship_port_relation.first.second]);
}
// now we have length of route, so we need to calculate score
@@ -841,15 +841,15 @@
}
// making sure the winner has no destination set
- assert(!m_ships[best_ship]->get_destination(game));
+ assert(!ships_[best_ship]->get_destination(game));
// now actual setting destination for "best ship"
- m_ships[best_ship]->set_destination(game, *m_ports[best_port]);
+ ships_[best_ship]->set_destination(game, *ports_[best_port]);
molog("... ship %u sent to port %u, wares onboard: %2d, the port is asking for a ship: %s\n",
- m_ships[best_ship]->serial(),
- m_ports[best_port]->serial(),
- m_ships[best_ship]->get_nritems(),
- (m_ports[best_port]->get_need_ship())?"yes":"no");
+ ships_[best_ship]->serial(),
+ ports_[best_port]->serial(),
+ ships_[best_ship]->get_nritems(),
+ (ports_[best_port]->get_need_ship())?"yes":"no");
// pruning the scores table
// the ship that was just sent somewhere cannot be send elsewhere :)
@@ -881,7 +881,7 @@
molog("... there are %" PRIuS " ports requesting ship(s) we cannot satisfy yet\n",
waiting_ports.size());
schedule_act(game, 5000); // retry next time
- m_act_pending = true;
+ act_pending_ = true;
}
}
@@ -889,7 +889,7 @@
{
MapObject::log_general_info(egbase);
- molog ("%" PRIuS " ships and %" PRIuS " ports\n", m_ships.size(), m_ports.size());
+ molog ("%" PRIuS " ships and %" PRIuS " ports\n", ships_.size(), ports_.size());
}
constexpr uint8_t kCurrentPacketVersion = 4;
@@ -905,16 +905,16 @@
Fleet & fleet = get<Fleet>();
uint32_t nrships = fr.unsigned_32();
- m_ships.resize(nrships);
+ ships_.resize(nrships);
for (uint32_t i = 0; i < nrships; ++i)
- m_ships[i] = fr.unsigned_32();
+ ships_[i] = fr.unsigned_32();
uint32_t nrports = fr.unsigned_32();
- m_ports.resize(nrports);
+ ports_.resize(nrports);
for (uint32_t i = 0; i < nrports; ++i)
- m_ports[i] = fr.unsigned_32();
+ ports_[i] = fr.unsigned_32();
- fleet.m_act_pending = fr.unsigned_8();
+ fleet.act_pending_ = fr.unsigned_8();
}
void Fleet::Loader::load_pointers()
@@ -925,20 +925,20 @@
// Act commands created during loading are not persistent, so we need to undo any
// changes to the pending state.
- bool save_act_pending = fleet.m_act_pending;
-
- for (const uint32_t& temp_ship : m_ships) {
- fleet.m_ships.push_back(&mol().get<Ship>(temp_ship));
- fleet.m_ships.back()->set_fleet(&fleet);
- }
- for (const uint32_t& temp_port: m_ports) {
- fleet.m_ports.push_back(&mol().get<PortDock>(temp_port));
- fleet.m_ports.back()->set_fleet(&fleet);
- }
-
- fleet.m_portpaths.resize((fleet.m_ports.size() * (fleet.m_ports.size() - 1)) / 2);
-
- fleet.m_act_pending = save_act_pending;
+ bool save_act_pending = fleet.act_pending_;
+
+ for (const uint32_t& temp_ship : ships_) {
+ fleet.ships_.push_back(&mol().get<Ship>(temp_ship));
+ fleet.ships_.back()->set_fleet(&fleet);
+ }
+ for (const uint32_t& temp_port: ports_) {
+ fleet.ports_.push_back(&mol().get<PortDock>(temp_port));
+ fleet.ports_.back()->set_fleet(&fleet);
+ }
+
+ fleet.portpaths_.resize((fleet.ports_.size() * (fleet.ports_.size() - 1)) / 2);
+
+ fleet.act_pending_ = save_act_pending;
}
void Fleet::Loader::load_finish()
@@ -947,11 +947,11 @@
Fleet & fleet = get<Fleet>();
- if (!fleet.m_ports.empty()) {
- if (!fleet.m_ships.empty())
+ if (!fleet.ports_.empty()) {
+ if (!fleet.ships_.empty())
fleet.check_merge_economy();
- fleet.set_economy(fleet.m_ports[0]->get_economy());
+ fleet.set_economy(fleet.ports_[0]->get_economy());
}
}
@@ -991,20 +991,20 @@
fw.unsigned_8(HeaderFleet);
fw.unsigned_8(kCurrentPacketVersion);
- fw.unsigned_8(m_owner.player_number());
+ fw.unsigned_8(owner_.player_number());
MapObject::save(egbase, mos, fw);
- fw.unsigned_32(m_ships.size());
- for (const Ship * temp_ship : m_ships) {
+ fw.unsigned_32(ships_.size());
+ for (const Ship * temp_ship : ships_) {
fw.unsigned_32(mos.get_object_file_index(*temp_ship));
}
- fw.unsigned_32(m_ports.size());
- for (const PortDock * temp_port : m_ports) {
+ fw.unsigned_32(ports_.size());
+ for (const PortDock * temp_port : ports_) {
fw.unsigned_32(mos.get_object_file_index(*temp_port));
}
- fw.unsigned_8(m_act_pending);
+ fw.unsigned_8(act_pending_);
}
} // namespace Widelands
=== modified file 'src/economy/fleet.h'
--- src/economy/fleet.h 2015-11-29 09:43:15 +0000
+++ src/economy/fleet.h 2016-02-07 07:48:48 +0000
@@ -76,8 +76,8 @@
Fleet(Player & player);
- Player * get_owner() const {return &m_owner;}
- Player & owner() const {return m_owner;}
+ Player * get_owner() const {return &owner_;}
+ Player & owner() const {return owner_;}
PortDock * get_dock(Flag & flag) const;
PortDock * get_dock(EditorGameBase &, Coords) const;
@@ -119,19 +119,19 @@
PortPath & portpath_bidir(uint32_t i, uint32_t j, bool & reverse);
const PortPath & portpath_bidir(uint32_t i, uint32_t j, bool & reverse) const;
- Player & m_owner;
- std::vector<Ship *> m_ships;
- std::vector<PortDock *> m_ports;
+ Player & owner_;
+ std::vector<Ship *> ships_;
+ std::vector<PortDock *> ports_;
- bool m_act_pending;
+ bool act_pending_;
/**
* Store all pairs shortest paths between port docks
*
- * Let i < j, then the path from m_ports[i] to m_ports[j] is stored in
- * m_portpaths[binom(j,2) + i]
+ * Let i < j, then the path from ports_[i] to ports_[j] is stored in
+ * portpaths_[binom(j,2) + i]
*/
- std::vector<PortPath> m_portpaths;
+ std::vector<PortPath> portpaths_;
// saving and loading
protected:
@@ -143,8 +143,8 @@
void load_finish() override;
private:
- std::vector<uint32_t> m_ships;
- std::vector<uint32_t> m_ports;
+ std::vector<uint32_t> ships_;
+ std::vector<uint32_t> ports_;
};
public:
=== modified file 'src/economy/idleworkersupply.cc'
--- src/economy/idleworkersupply.cc 2016-01-08 21:00:39 +0000
+++ src/economy/idleworkersupply.cc 2016-02-07 07:48:48 +0000
@@ -35,7 +35,7 @@
/**
* Automatically register with the worker's economy.
*/
-IdleWorkerSupply::IdleWorkerSupply(Worker & w) : m_worker (w), m_economy(nullptr)
+IdleWorkerSupply::IdleWorkerSupply(Worker & w) : worker_ (w), economy_(nullptr)
{
set_economy(w.get_economy());
}
@@ -55,11 +55,11 @@
*/
void IdleWorkerSupply::set_economy(Economy * const e)
{
- if (m_economy != e) {
- if (m_economy)
- m_economy->remove_supply(*this);
- if ((m_economy = e))
- m_economy-> add_supply(*this);
+ if (economy_ != e) {
+ if (economy_)
+ economy_->remove_supply(*this);
+ if ((economy_ = e))
+ economy_-> add_supply(*this);
}
}
@@ -78,13 +78,13 @@
bool IdleWorkerSupply::has_storage() const
{
- return m_worker.get_transfer();
+ return worker_.get_transfer();
}
void IdleWorkerSupply::get_ware_type(WareWorker & type, DescriptionIndex & ware) const
{
type = wwWORKER;
- ware = m_worker.descr().worker_index();
+ ware = worker_.descr().worker_index();
}
/**
@@ -92,7 +92,7 @@
*/
PlayerImmovable * IdleWorkerSupply::get_position(Game & game)
{
- return m_worker.get_location(game);
+ return worker_.get_location(game);
}
@@ -100,11 +100,11 @@
{
assert
(req.get_type() != wwWORKER ||
- m_worker.owner().tribe().has_worker(req.get_index()));
+ worker_.owner().tribe().has_worker(req.get_index()));
if
(req.get_type() == wwWORKER &&
- m_worker.descr().can_act_as(req.get_index()) &&
- req.get_requirements().check(m_worker))
+ worker_.descr().can_act_as(req.get_index()) &&
+ req.get_requirements().check(worker_))
return 1;
return 0;
@@ -124,20 +124,20 @@
if (req.get_type() != wwWORKER)
throw wexception("IdleWorkerSupply: not a worker request");
if
- (!m_worker.descr().can_act_as(req.get_index()) ||
- !req.get_requirements().check(m_worker))
+ (!worker_.descr().can_act_as(req.get_index()) ||
+ !req.get_requirements().check(worker_))
throw wexception("IdleWorkerSupply: worker type mismatch");
- return m_worker;
+ return worker_;
}
void IdleWorkerSupply::send_to_storage(Game & game, Warehouse * wh)
{
assert(!has_storage());
- Transfer * t = new Transfer(game, m_worker);
+ Transfer * t = new Transfer(game, worker_);
t->set_destination(*wh);
- m_worker.start_task_transfer(game, t);
+ worker_.start_task_transfer(game, t);
}
}
=== modified file 'src/economy/idleworkersupply.h'
--- src/economy/idleworkersupply.h 2016-01-06 20:04:59 +0000
+++ src/economy/idleworkersupply.h 2016-02-07 07:48:48 +0000
@@ -44,8 +44,8 @@
Worker & launch_worker(Game &, const Request &) override;
private:
- Worker & m_worker;
- Economy * m_economy;
+ Worker & worker_;
+ Economy * economy_;
};
}
=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc 2016-01-28 05:24:34 +0000
+++ src/economy/portdock.cc 2016-02-07 07:48:48 +0000
@@ -54,14 +54,14 @@
PortDock::PortDock(Warehouse* wh)
: PlayerImmovable(g_portdock_descr),
- m_fleet(nullptr),
- m_warehouse(wh),
- m_need_ship(false),
- m_expedition_ready(false) {
+ fleet_(nullptr),
+ warehouse_(wh),
+ need_ship_(false),
+ expedition_ready_(false) {
}
PortDock::~PortDock() {
- assert(m_expedition_bootstrap.get() == nullptr);
+ assert(expedition_bootstrap_.get() == nullptr);
}
/**
@@ -75,11 +75,11 @@
* @note This only works properly when called before @ref init
*/
void PortDock::add_position(Coords where) {
- m_dockpoints.push_back(where);
+ dockpoints_.push_back(where);
}
Warehouse* PortDock::get_warehouse() const {
- return m_warehouse;
+ return warehouse_;
}
/**
@@ -88,7 +88,7 @@
* @warning This should only be called via @ref Fleet itself.
*/
void PortDock::set_fleet(Fleet* fleet) {
- m_fleet = fleet;
+ fleet_ = fleet;
}
int32_t PortDock::get_size() const {
@@ -100,11 +100,11 @@
}
PortDock::PositionList PortDock::get_positions(const EditorGameBase&) const {
- return m_dockpoints;
+ return dockpoints_;
}
Flag& PortDock::base_flag() {
- return m_warehouse->base_flag();
+ return warehouse_->base_flag();
}
/**
@@ -112,8 +112,8 @@
* has the given flag.
*/
PortDock* PortDock::get_dock(Flag& flag) const {
- if (m_fleet)
- return m_fleet->get_dock(flag);
+ if (fleet_)
+ return fleet_->get_dock(flag);
return nullptr;
}
@@ -128,17 +128,17 @@
return;
PlayerImmovable::set_economy(e);
- if (m_fleet)
- m_fleet->set_economy(e);
+ if (fleet_)
+ fleet_->set_economy(e);
if (upcast(Game, game, &owner().egbase())) {
- for (ShippingItem& shipping_item : m_waiting) {
+ for (ShippingItem& shipping_item : waiting_) {
shipping_item.set_economy(*game, e);
}
}
- if (m_expedition_bootstrap)
- m_expedition_bootstrap->set_economy(e);
+ if (expedition_bootstrap_)
+ expedition_bootstrap_->set_economy(e);
}
void PortDock::draw(const EditorGameBase&, RenderTarget&, const FCoords&, const Point&) {
@@ -148,7 +148,7 @@
void PortDock::init(EditorGameBase& egbase) {
PlayerImmovable::init(egbase);
- for (const Coords& coords : m_dockpoints) {
+ for (const Coords& coords : dockpoints_) {
set_position(egbase, coords);
}
@@ -170,52 +170,52 @@
Warehouse* wh = nullptr;
- if (egbase.objects().object_still_available(m_warehouse)) {
+ if (egbase.objects().object_still_available(warehouse_)) {
//we need to remember this for possible recreation of portdock
- wh = m_warehouse;
+ wh = warehouse_;
// Transfer all our wares into the warehouse.
if (upcast(Game, game, &egbase)) {
- for (ShippingItem& shipping_item : m_waiting) {
+ for (ShippingItem& shipping_item : waiting_) {
WareInstance* ware;
shipping_item.get(*game, &ware, nullptr);
if (ware) {
ware->cancel_moving();
- m_warehouse->incorporate_ware(*game, ware);
+ warehouse_->incorporate_ware(*game, ware);
} else {
- shipping_item.set_location(*game, m_warehouse);
+ shipping_item.set_location(*game, warehouse_);
shipping_item.end_shipping(*game);
}
}
}
- m_waiting.clear();
- m_warehouse->m_portdock = nullptr;
+ waiting_.clear();
+ warehouse_->portdock_ = nullptr;
}
if (upcast(Game, game, &egbase)) {
- for (ShippingItem& shipping_item : m_waiting) {
+ for (ShippingItem& shipping_item : waiting_) {
shipping_item.remove(*game);
}
}
- if (m_fleet)
- m_fleet->remove_port(egbase, this);
+ if (fleet_)
+ fleet_->remove_port(egbase, this);
- for (const Coords& coords : m_dockpoints) {
+ for (const Coords& coords : dockpoints_) {
unset_position(egbase, coords);
}
- if (m_expedition_bootstrap) {
- m_expedition_bootstrap->cleanup(egbase);
- m_expedition_bootstrap.reset(nullptr);
+ if (expedition_bootstrap_) {
+ expedition_bootstrap_->cleanup(egbase);
+ expedition_bootstrap_.reset(nullptr);
}
PlayerImmovable::cleanup(egbase);
// Now let's attempt to recreate the portdock.
if (wh) {
- if (!wh->m_cleanup_in_progress){
+ if (!wh->cleanup_in_progress_) {
if (upcast(Game, game, &egbase)) {
if (game->is_loaded()) { //do not attempt when shutting down
wh->restore_portdock_or_destroy(egbase);
@@ -230,15 +230,15 @@
* Add the flags of all ports that can be reached via this dock.
*/
void PortDock::add_neighbours(std::vector<RoutingNodeNeighbour>& neighbours) {
- if (m_fleet && m_fleet->active())
- m_fleet->add_neighbours(*this, neighbours);
+ if (fleet_ && fleet_->active())
+ fleet_->add_neighbours(*this, neighbours);
}
/**
* The given @p ware enters the dock, waiting to be transported away.
*/
void PortDock::add_shippingitem(Game& game, WareInstance& ware) {
- m_waiting.push_back(ShippingItem(ware));
+ waiting_.push_back(ShippingItem(ware));
ware.set_location(game, this);
ware.update(game);
}
@@ -248,11 +248,11 @@
* its route.
*/
void PortDock::update_shippingitem(Game& game, WareInstance& ware) {
- for (std::vector<ShippingItem>::iterator item_iter = m_waiting.begin();
- item_iter != m_waiting.end();
+ for (std::vector<ShippingItem>::iterator item_iter = waiting_.begin();
+ item_iter != waiting_.end();
++item_iter) {
- if (item_iter->m_object.serial() == ware.serial()) {
+ if (item_iter->object_.serial() == ware.serial()) {
_update_shippingitem(game, item_iter);
return;
}
@@ -263,7 +263,7 @@
* The given @p worker enters the dock, waiting to be transported away.
*/
void PortDock::add_shippingitem(Game& game, Worker& worker) {
- m_waiting.push_back(ShippingItem(worker));
+ waiting_.push_back(ShippingItem(worker));
worker.set_location(this);
update_shippingitem(game, worker);
}
@@ -273,11 +273,11 @@
* updated its route.
*/
void PortDock::update_shippingitem(Game& game, Worker& worker) {
- for (std::vector<ShippingItem>::iterator item_iter = m_waiting.begin();
- item_iter != m_waiting.end();
+ for (std::vector<ShippingItem>::iterator item_iter = waiting_.begin();
+ item_iter != waiting_.end();
++item_iter) {
- if (item_iter->m_object.serial() == worker.serial()) {
+ if (item_iter->object_.serial() == worker.serial()) {
_update_shippingitem(game, item_iter);
return;
}
@@ -294,12 +294,12 @@
if (dst && dst->get_economy() == get_economy()) {
set_need_ship(game, true);
} else {
- it->set_location(game, m_warehouse);
+ it->set_location(game, warehouse_);
it->end_shipping(game);
- *it = m_waiting.back();
- m_waiting.pop_back();
+ *it = waiting_.back();
+ waiting_.pop_back();
- if (m_waiting.empty())
+ if (waiting_.empty())
set_need_ship(game, false);
}
}
@@ -313,19 +313,19 @@
ship.withdraw_items(game, *this, items_brought_by_ship);
for (ShippingItem& shipping_item : items_brought_by_ship) {
- shipping_item.set_location(game, m_warehouse);
+ shipping_item.set_location(game, warehouse_);
shipping_item.end_shipping(game);
}
- if (m_expedition_ready) {
- assert(m_expedition_bootstrap.get() != nullptr);
+ if (expedition_ready_) {
+ assert(expedition_bootstrap_.get() != nullptr);
// Only use an empty ship.
if (ship.get_nritems() < 1) {
// Load the ship
std::vector<Worker*> workers;
std::vector<WareInstance*> wares;
- m_expedition_bootstrap->get_waiting_workers_and_wares(
+ expedition_bootstrap_->get_waiting_workers_and_wares(
game, owner().tribe(), &workers, &wares);
for (Worker* worker : workers) {
@@ -342,47 +342,47 @@
cancel_expedition(game);
if (upcast(InteractiveGameBase, igb, game.get_ibase()))
ship.refresh_window(*igb);
- return m_fleet->update(game);
+ return fleet_->update(game);
}
}
- if (ship.get_nritems() < ship.descr().get_capacity() && !m_waiting.empty()) {
+ if (ship.get_nritems() < ship.descr().get_capacity() && !waiting_.empty()) {
uint32_t nrload =
- std::min<uint32_t>(m_waiting.size(), ship.descr().get_capacity() - ship.get_nritems());
+ std::min<uint32_t>(waiting_.size(), ship.descr().get_capacity() - ship.get_nritems());
while (nrload--) {
// Check if the item has still a valid destination
- if (m_waiting.back().get_destination(game)) {
+ if (waiting_.back().get_destination(game)) {
// Destination is valid, so we load the item onto the ship
- ship.add_item(game, m_waiting.back());
+ ship.add_item(game, waiting_.back());
} else {
// The item has no valid destination anymore, so we just carry it
// back in the warehouse
- m_waiting.back().set_location(game, m_warehouse);
- m_waiting.back().end_shipping(game);
+ waiting_.back().set_location(game, warehouse_);
+ waiting_.back().end_shipping(game);
}
- m_waiting.pop_back();
+ waiting_.pop_back();
}
- if (m_waiting.empty()){
+ if (waiting_.empty()){
set_need_ship(game, false);
}
}
- m_fleet->update(game);
+ fleet_->update(game);
}
void PortDock::set_need_ship(Game& game, bool need) {
molog("set_need_ship(%s)\n", need ? "true" : "false");
- if (need == m_need_ship)
+ if (need == need_ship_)
return;
- m_need_ship = need;
+ need_ship_ = need;
- if (m_fleet) {
+ if (fleet_) {
molog("... trigger fleet update\n");
- m_fleet->update(game);
+ fleet_->update(game);
}
}
@@ -392,7 +392,7 @@
uint32_t PortDock::count_waiting(WareWorker waretype, DescriptionIndex wareindex) {
uint32_t count = 0;
- for (ShippingItem& shipping_item : m_waiting) {
+ for (ShippingItem& shipping_item : waiting_) {
WareInstance* ware;
Worker* worker;
shipping_item.get(owner().egbase(), &ware, &worker);
@@ -413,67 +413,67 @@
* Return the number of wares or workers waiting at the dock.
*/
uint32_t PortDock::count_waiting() {
- return m_waiting.size();
+ return waiting_.size();
}
/// \returns whether an expedition was started or is even ready
bool PortDock::expedition_started() {
- return (m_expedition_bootstrap.get() != nullptr) || m_expedition_ready;
+ return (expedition_bootstrap_.get() != nullptr) || expedition_ready_;
}
/// Start an expedition
void PortDock::start_expedition() {
- assert(!m_expedition_bootstrap);
- m_expedition_bootstrap.reset(new ExpeditionBootstrap(this));
- m_expedition_bootstrap->start();
+ assert(!expedition_bootstrap_);
+ expedition_bootstrap_.reset(new ExpeditionBootstrap(this));
+ expedition_bootstrap_->start();
}
ExpeditionBootstrap* PortDock::expedition_bootstrap() {
- return m_expedition_bootstrap.get();
+ return expedition_bootstrap_.get();
}
void PortDock::expedition_bootstrap_complete(Game& game) {
- m_expedition_ready = true;
+ expedition_ready_ = true;
get_fleet()->update(game);
}
void PortDock::cancel_expedition(Game& game) {
// Reset
- m_expedition_ready = false;
+ expedition_ready_ = false;
- m_expedition_bootstrap->cancel(game);
- m_expedition_bootstrap.reset(nullptr);
+ expedition_bootstrap_->cancel(game);
+ expedition_bootstrap_.reset(nullptr);
}
void PortDock::log_general_info(const EditorGameBase& egbase) {
PlayerImmovable::log_general_info(egbase);
- if (m_warehouse) {
- Coords pos(m_warehouse->get_position());
+ if (warehouse_) {
+ Coords pos(warehouse_->get_position());
molog("PortDock for warehouse %u (at %i,%i) in fleet %u, need_ship: %s, waiting: %" PRIuS "\n",
- m_warehouse->serial(),
+ warehouse_->serial(),
pos.x,
pos.y,
- m_fleet ? m_fleet->serial() : 0,
- m_need_ship ? "true" : "false",
- m_waiting.size());
+ fleet_ ? fleet_->serial() : 0,
+ need_ship_ ? "true" : "false",
+ waiting_.size());
} else {
molog("PortDock without a warehouse in fleet %u, need_ship: %s, waiting: %" PRIuS "\n",
- m_fleet ? m_fleet->serial() : 0,
- m_need_ship ? "true" : "false",
- m_waiting.size());
+ fleet_ ? fleet_->serial() : 0,
+ need_ship_ ? "true" : "false",
+ waiting_.size());
}
- for (ShippingItem& shipping_item : m_waiting) {
+ for (ShippingItem& shipping_item : waiting_) {
molog(" IT %u, destination %u\n",
- shipping_item.m_object.serial(),
- shipping_item.m_destination_dock.serial());
+ shipping_item.object_.serial(),
+ shipping_item.destination_dock_.serial());
}
}
constexpr uint8_t kCurrentPacketVersion = 3;
-PortDock::Loader::Loader() : m_warehouse(0) {
+PortDock::Loader::Loader() : warehouse_(0) {
}
void PortDock::Loader::load(FileRead & fr) {
@@ -481,38 +481,38 @@
PortDock& pd = get<PortDock>();
- m_warehouse = fr.unsigned_32();
+ warehouse_ = fr.unsigned_32();
uint16_t nrdockpoints = fr.unsigned_16();
- pd.m_dockpoints.resize(nrdockpoints);
+ pd.dockpoints_.resize(nrdockpoints);
for (uint16_t i = 0; i < nrdockpoints; ++i) {
- pd.m_dockpoints[i] = read_coords_32(&fr, egbase().map().extent());
- pd.set_position(egbase(), pd.m_dockpoints[i]);
+ pd.dockpoints_[i] = read_coords_32(&fr, egbase().map().extent());
+ pd.set_position(egbase(), pd.dockpoints_[i]);
}
- pd.m_need_ship = fr.unsigned_8();
+ pd.need_ship_ = fr.unsigned_8();
- m_waiting.resize(fr.unsigned_32());
- for (ShippingItem::Loader& shipping_loader : m_waiting) {
+ waiting_.resize(fr.unsigned_32());
+ for (ShippingItem::Loader& shipping_loader : waiting_) {
shipping_loader.load(fr);
}
// All the other expedition specific stuff is saved in the warehouse.
if (fr.unsigned_8()) { // Do we have an expedition?
- pd.m_expedition_bootstrap.reset(new ExpeditionBootstrap(&pd));
+ pd.expedition_bootstrap_.reset(new ExpeditionBootstrap(&pd));
}
- pd.m_expedition_ready = (fr.unsigned_8() == 1) ? true : false;
+ pd.expedition_ready_ = (fr.unsigned_8() == 1) ? true : false;
}
void PortDock::Loader::load_pointers() {
PlayerImmovable::Loader::load_pointers();
PortDock& pd = get<PortDock>();
- pd.m_warehouse = &mol().get<Warehouse>(m_warehouse);
+ pd.warehouse_ = &mol().get<Warehouse>(warehouse_);
- pd.m_waiting.resize(m_waiting.size());
- for (uint32_t i = 0; i < m_waiting.size(); ++i) {
- pd.m_waiting[i] = m_waiting[i].get(mol());
+ pd.waiting_.resize(waiting_.size());
+ for (uint32_t i = 0; i < waiting_.size(); ++i) {
+ pd.waiting_[i] = waiting_[i].get(mol());
}
}
@@ -521,14 +521,14 @@
PortDock& pd = get<PortDock>();
- if (pd.m_warehouse->get_portdock() != &pd) {
+ if (pd.warehouse_->get_portdock() != &pd) {
log("Inconsistent PortDock <> Warehouse link\n");
if (upcast(Game, game, &egbase()))
pd.schedule_destroy(*game);
}
// This shouldn't be necessary, but let's check just in case
- if (!pd.m_fleet)
+ if (!pd.fleet_)
pd.init_fleet(egbase());
}
@@ -558,22 +558,22 @@
PlayerImmovable::save(egbase, mos, fw);
- fw.unsigned_32(mos.get_object_file_index(*m_warehouse));
- fw.unsigned_16(m_dockpoints.size());
- for (const Coords& coords : m_dockpoints) {
+ fw.unsigned_32(mos.get_object_file_index(*warehouse_));
+ fw.unsigned_16(dockpoints_.size());
+ for (const Coords& coords : dockpoints_) {
write_coords_32(&fw, coords);
}
- fw.unsigned_8(m_need_ship);
+ fw.unsigned_8(need_ship_);
- fw.unsigned_32(m_waiting.size());
- for (ShippingItem& shipping_item : m_waiting) {
+ fw.unsigned_32(waiting_.size());
+ for (ShippingItem& shipping_item : waiting_) {
shipping_item.save(egbase, mos, fw);
}
// Expedition specific stuff
- fw.unsigned_8(m_expedition_bootstrap.get() != nullptr ? 1 : 0);
- fw.unsigned_8(m_expedition_ready ? 1 : 0);
+ fw.unsigned_8(expedition_bootstrap_.get() != nullptr ? 1 : 0);
+ fw.unsigned_8(expedition_ready_ ? 1 : 0);
}
} // namespace Widelands
=== modified file 'src/economy/portdock.h'
--- src/economy/portdock.h 2016-01-06 19:11:20 +0000
+++ src/economy/portdock.h 2016-02-07 07:48:48 +0000
@@ -82,9 +82,9 @@
void add_position(Widelands::Coords where);
Warehouse * get_warehouse() const;
- Fleet * get_fleet() const {return m_fleet;}
+ Fleet * get_fleet() const {return fleet_;}
PortDock * get_dock(Flag & flag) const;
- bool get_need_ship() const {return m_need_ship || m_expedition_ready;}
+ bool get_need_ship() const {return need_ship_ || expedition_ready_;}
void set_economy(Economy *) override;
@@ -137,14 +137,14 @@
void _update_shippingitem(Game &, std::vector<ShippingItem>::iterator);
void set_need_ship(Game &, bool need);
- Fleet * m_fleet;
- Warehouse * m_warehouse;
- PositionList m_dockpoints;
- std::vector<ShippingItem> m_waiting;
- bool m_need_ship;
- bool m_expedition_ready;
+ Fleet * fleet_;
+ Warehouse * warehouse_;
+ PositionList dockpoints_;
+ std::vector<ShippingItem> waiting_;
+ bool need_ship_;
+ bool expedition_ready_;
- std::unique_ptr<ExpeditionBootstrap> m_expedition_bootstrap;
+ std::unique_ptr<ExpeditionBootstrap> expedition_bootstrap_;
// saving and loading
protected:
@@ -157,8 +157,8 @@
void load_finish() override;
private:
- uint32_t m_warehouse;
- std::vector<ShippingItem::Loader> m_waiting;
+ uint32_t warehouse_;
+ std::vector<ShippingItem::Loader> waiting_;
};
public:
=== modified file 'src/economy/request.cc'
--- src/economy/request.cc 2015-11-28 22:29:26 +0000
+++ src/economy/request.cc 2016-02-07 07:48:48 +0000
@@ -54,21 +54,21 @@
CallbackFn const cbfn,
WareWorker const w)
:
- m_type (w),
- m_target (_target),
- m_target_building (dynamic_cast<Building *>(&_target)),
- m_target_productionsite (dynamic_cast<ProductionSite *>(&_target)),
- m_target_warehouse (dynamic_cast<Warehouse *>(&_target)),
- m_target_constructionsite (dynamic_cast<ConstructionSite *>(&_target)),
- m_economy (_target.get_economy()),
- m_index (index),
- m_count (1),
- m_callbackfn (cbfn),
- m_required_time (_target.owner().egbase().get_gametime()),
- m_required_interval(0),
- m_last_request_time(m_required_time)
+ type_ (w),
+ target_ (_target),
+ target_building_ (dynamic_cast<Building *>(&_target)),
+ target_productionsite_ (dynamic_cast<ProductionSite *>(&_target)),
+ target_warehouse_ (dynamic_cast<Warehouse *>(&_target)),
+ target_constructionsite_ (dynamic_cast<ConstructionSite *>(&_target)),
+ economy_ (_target.get_economy()),
+ index_ (index),
+ count_ (1),
+ callbackfn_ (cbfn),
+ required_time_ (_target.owner().egbase().get_gametime()),
+ required_interval_(0),
+ last_request_time_(required_time_)
{
- assert(m_type == wwWARE || m_type == wwWORKER);
+ assert(type_ == wwWARE || type_ == wwWORKER);
if (w == wwWARE && !_target.owner().egbase().tribes().ware_exists(index))
throw wexception
("creating ware request with index %u, but the ware for this index doesn't exist",
@@ -77,18 +77,18 @@
throw wexception
("creating worker request with index %u, but the worker for this index doesn't exist",
index);
- if (m_economy)
- m_economy->add_request(*this);
+ if (economy_)
+ economy_->add_request(*this);
}
Request::~Request()
{
// Remove from the economy
- if (is_open() && m_economy)
- m_economy->remove_request(*this);
+ if (is_open() && economy_)
+ economy_->remove_request(*this);
// Cancel all ongoing transfers
- while (m_transfers.size())
+ while (transfers_.size())
cancel_transfer(0);
}
@@ -109,28 +109,28 @@
try {
uint16_t const packet_version = fr.unsigned_16();
if (packet_version == kCurrentPacketVersion) {
- const TribeDescr& tribe = m_target.owner().tribe();
+ const TribeDescr& tribe = target_.owner().tribe();
char const* const type_name = fr.c_string();
DescriptionIndex const wai = tribe.ware_index(type_name);
if (tribe.has_ware(wai)) {
- m_type = wwWARE;
- m_index = wai;
+ type_ = wwWARE;
+ index_ = wai;
} else {
DescriptionIndex const woi = tribe.worker_index(type_name);
if (tribe.has_worker(woi)) {
- m_type = wwWORKER;
- m_index = woi;
+ type_ = wwWORKER;
+ index_ = woi;
} else {
throw wexception("Request::read: unknown type '%s'.\n", type_name);
}
}
- m_count = fr.unsigned_32();
- m_required_time = fr.unsigned_32();
- m_required_interval = fr.unsigned_32();
-
- m_last_request_time = fr.unsigned_32();
-
- assert(m_transfers.empty());
+ count_ = fr.unsigned_32();
+ required_time_ = fr.unsigned_32();
+ required_interval_ = fr.unsigned_32();
+
+ last_request_time_ = fr.unsigned_32();
+
+ assert(transfers_.empty());
uint16_t const nr_transfers = fr.unsigned_16();
for (uint16_t i = 0; i < nr_transfers; ++i)
@@ -140,12 +140,12 @@
if (upcast(Worker, worker, obj)) {
transfer = worker->get_transfer();
- if (m_type != wwWORKER || !worker->descr().can_act_as(m_index)) {
+ if (type_ != wwWORKER || !worker->descr().can_act_as(index_)) {
throw wexception("Request::read: incompatible transfer type");
}
} else if (upcast(WareInstance, ware, obj)) {
transfer = ware->get_transfer();
- if (m_type != wwWARE || ware->descr_index() != m_index) {
+ if (type_ != wwWARE || ware->descr_index() != index_) {
throw wexception("Request::read: incompatible transfer type");
}
} else {
@@ -157,14 +157,14 @@
obj->serial());
} else {
transfer->set_request(this);
- m_transfers.push_back(transfer);
+ transfers_.push_back(transfer);
}
} catch (const WException& e) {
throw wexception("transfer %u: %s", i, e.what());
}
- m_requirements.read (fr, game, mol);
- if (!is_open() && m_economy)
- m_economy->remove_request(*this);
+ requirements_.read (fr, game, mol);
+ if (!is_open() && economy_)
+ economy_->remove_request(*this);
} else {
throw UnhandledVersionError("Request", packet_version, kCurrentPacketVersion);
}
@@ -183,34 +183,34 @@
// Target and economy should be set. Same is true for callback stuff.
- assert(m_type == wwWARE || m_type == wwWORKER);
- if (m_type == wwWARE) {
- assert(game.tribes().ware_exists(m_index));
- fw.c_string(game.tribes().get_ware_descr(m_index)->name());
- } else if (m_type == wwWORKER) {
- assert(game.tribes().worker_exists(m_index));
- fw.c_string(game.tribes().get_worker_descr(m_index)->name());
+ assert(type_ == wwWARE || type_ == wwWORKER);
+ if (type_ == wwWARE) {
+ assert(game.tribes().ware_exists(index_));
+ fw.c_string(game.tribes().get_ware_descr(index_)->name());
+ } else if (type_ == wwWORKER) {
+ assert(game.tribes().worker_exists(index_));
+ fw.c_string(game.tribes().get_worker_descr(index_)->name());
}
- fw.unsigned_32(m_count);
-
- fw.unsigned_32(m_required_time);
- fw.unsigned_32(m_required_interval);
-
- fw.unsigned_32(m_last_request_time);
-
- fw.unsigned_16(m_transfers.size()); // Write number of current transfers.
- for (uint32_t i = 0; i < m_transfers.size(); ++i) {
- Transfer & trans = *m_transfers[i];
- if (trans.m_ware) { // write ware/worker
- assert(mos.is_object_known(*trans.m_ware));
- fw.unsigned_32(mos.get_object_file_index(*trans.m_ware));
- } else if (trans.m_worker) {
- assert(mos.is_object_known(*trans.m_worker));
- fw.unsigned_32(mos.get_object_file_index(*trans.m_worker));
+ fw.unsigned_32(count_);
+
+ fw.unsigned_32(required_time_);
+ fw.unsigned_32(required_interval_);
+
+ fw.unsigned_32(last_request_time_);
+
+ fw.unsigned_16(transfers_.size()); // Write number of current transfers.
+ for (uint32_t i = 0; i < transfers_.size(); ++i) {
+ Transfer & trans = *transfers_[i];
+ if (trans.ware_) { // write ware/worker
+ assert(mos.is_object_known(*trans.ware_));
+ fw.unsigned_32(mos.get_object_file_index(*trans.ware_));
+ } else if (trans.worker_) {
+ assert(mos.is_object_known(*trans.worker_));
+ fw.unsigned_32(mos.get_object_file_index(*trans.worker_));
}
}
- m_requirements.write (fw, game, mos);
+ requirements_.write (fw, game, mos);
}
/**
@@ -223,33 +223,33 @@
/**
* Return the point in time at which we want the ware of the given number to
- * be delivered. nr is in the range [0..m_count[
+ * be delivered. nr is in the range [0..count_[
*/
int32_t Request::get_base_required_time
(EditorGameBase & egbase, uint32_t const nr) const
{
- if (m_count <= nr) {
- if (!(m_count == 1 && nr == 1)) {
+ if (count_ <= nr) {
+ if (!(count_ == 1 && nr == 1)) {
log
("Request::get_base_required_time: WARNING nr = %u but count is %u, "
"which is not allowed according to the comment for this function\n",
- nr, m_count);
+ nr, count_);
}
}
int32_t const curtime = egbase.get_gametime();
- if (!nr || !m_required_interval)
- return m_required_time;
+ if (!nr || !required_interval_)
+ return required_time_;
- if ((curtime - m_required_time) > (m_required_interval * 2)) {
+ if ((curtime - required_time_) > (required_interval_ * 2)) {
if (nr == 1)
- return m_required_time + (curtime - m_required_time) / 2;
+ return required_time_ + (curtime - required_time_) / 2;
assert(2 <= nr);
- return curtime + (nr - 2) * m_required_interval;
+ return curtime + (nr - 2) * required_interval_;
}
- return m_required_time + nr * m_required_interval;
+ return required_time_ + nr * required_interval_;
}
/**
@@ -260,7 +260,7 @@
int32_t Request::get_required_time() const
{
return
- get_base_required_time(m_economy->owner().egbase(), m_transfers.size());
+ get_base_required_time(economy_->owner().egbase(), transfers_.size());
}
//#define MAX_IDLE_PRIORITY 100
@@ -281,17 +281,17 @@
bool is_construction_site = false;
int32_t modifier = DEFAULT_PRIORITY;
- if (m_target_building) {
- modifier = m_target_building->get_priority(get_type(), get_index());
- if (m_target_constructionsite)
+ if (target_building_) {
+ modifier = target_building_->get_priority(get_type(), get_index());
+ if (target_constructionsite_)
is_construction_site = true;
- else if (m_target_warehouse) {
+ else if (target_warehouse_) {
// If there is no expedition at this warehouse, use the default
// warehouse calculation. Otherwise we use the default priority for
// the ware.
if
- (!m_target_warehouse->get_portdock() ||
- !m_target_warehouse->get_portdock()->expedition_bootstrap())
+ (!target_warehouse_->get_portdock() ||
+ !target_warehouse_->get_portdock()->expedition_bootstrap())
{
modifier =
std::max(1, MAX_IDLE_PRIORITY - cost * MAX_IDLE_PRIORITY / PRIORITY_MAX_COST);
@@ -311,7 +311,7 @@
+
std::max
(uint32_t(1),
- ((m_economy->owner().egbase().get_gametime() -
+ ((economy_->owner().egbase().get_gametime() -
(is_construction_site ?
get_required_time() : get_last_request_time()))
*
@@ -331,11 +331,11 @@
{
uint32_t pri = 0;
- if (m_target_building) {
- pri = m_target_building->get_priority(get_type(), get_index());
- if (m_target_constructionsite)
+ if (target_building_) {
+ pri = target_building_->get_priority(get_type(), get_index());
+ if (target_constructionsite_)
return pri + 3;
- else if (m_target_warehouse)
+ else if (target_warehouse_)
return pri - 2;
}
return pri;
@@ -346,12 +346,12 @@
*/
void Request::set_economy(Economy * const e)
{
- if (m_economy != e) {
- if (m_economy && is_open())
- m_economy->remove_request(*this);
- m_economy = e;
- if (m_economy && is_open())
- m_economy-> add_request(*this);
+ if (economy_ != e) {
+ if (economy_ && is_open())
+ economy_->remove_request(*this);
+ economy_ = e;
+ if (economy_ && is_open())
+ economy_-> add_request(*this);
}
}
@@ -362,20 +362,20 @@
{
bool const wasopen = is_open();
- m_count = count;
+ count_ = count;
// Cancel unneeded transfers. This should be more clever about which
// transfers to cancel. Then again, this loop shouldn't execute during
// normal play anyway
- while (m_count < m_transfers.size())
- cancel_transfer(m_transfers.size() - 1);
+ while (count_ < transfers_.size())
+ cancel_transfer(transfers_.size() - 1);
// Update the economy
- if (m_economy) {
+ if (economy_) {
if (wasopen && !is_open())
- m_economy->remove_request(*this);
+ economy_->remove_request(*this);
else if (!wasopen && is_open())
- m_economy->add_request(*this);
+ economy_->add_request(*this);
}
}
@@ -385,7 +385,7 @@
*/
void Request::set_required_time(int32_t const time)
{
- m_required_time = time;
+ required_time_ = time;
}
/**
@@ -393,7 +393,7 @@
*/
void Request::set_required_interval(int32_t const interval)
{
- m_required_interval = interval;
+ required_interval_ = interval;
}
/**
@@ -427,9 +427,9 @@
t = new Transfer(game, *this, ware);
}
- m_transfers.push_back(t);
+ transfers_.push_back(t);
if (!is_open())
- m_economy->remove_request(*this);
+ economy_->remove_request(*this);
}
/**
@@ -439,23 +439,23 @@
*/
void Request::transfer_finish(Game & game, Transfer & t)
{
- Worker * const w = t.m_worker;
-
- if (t.m_ware)
- t.m_ware->destroy(game);
-
- t.m_worker = nullptr;
- t.m_ware = nullptr;
+ Worker * const w = t.worker_;
+
+ if (t.ware_)
+ t.ware_->destroy(game);
+
+ t.worker_ = nullptr;
+ t.ware_ = nullptr;
remove_transfer(find_transfer(t));
set_required_time(get_base_required_time(game, 1));
- --m_count;
+ --count_;
// the callback functions are likely to delete us,
// therefore we musn't access member variables behind this
// point
- (*m_callbackfn)(game, *this, m_index, w, m_target);
+ (*callbackfn_)(game, *this, index_, w, target_);
}
/**
@@ -467,13 +467,13 @@
void Request::transfer_fail(Game &, Transfer & t) {
bool const wasopen = is_open();
- t.m_worker = nullptr;
- t.m_ware = nullptr;
+ t.worker_ = nullptr;
+ t.ware_ = nullptr;
remove_transfer(find_transfer(t));
if (!wasopen)
- m_economy->add_request(*this);
+ economy_->add_request(*this);
}
/// Cancel the transfer with the given index.
@@ -492,9 +492,9 @@
*/
void Request::remove_transfer(uint32_t const idx)
{
- Transfer * const t = m_transfers[idx];
+ Transfer * const t = transfers_[idx];
- m_transfers.erase(m_transfers.begin() + idx);
+ transfers_.erase(transfers_.begin() + idx);
delete t;
}
@@ -506,12 +506,12 @@
uint32_t Request::find_transfer(Transfer & t)
{
TransferList::const_iterator const it =
- std::find(m_transfers.begin(), m_transfers.end(), &t);
+ std::find(transfers_.begin(), transfers_.end(), &t);
- if (it == m_transfers.end())
+ if (it == transfers_.end())
throw wexception("Request::find_transfer(): not found");
- return it - m_transfers.begin();
+ return it - transfers_.begin();
}
}
=== modified file 'src/economy/request.h'
--- src/economy/request.h 2015-11-28 22:29:26 +0000
+++ src/economy/request.h 2016-02-07 07:48:48 +0000
@@ -69,18 +69,18 @@
Request(PlayerImmovable & target, DescriptionIndex, CallbackFn, WareWorker);
~Request();
- PlayerImmovable & target() const {return m_target;}
- DescriptionIndex get_index() const {return m_index;}
- WareWorker get_type() const {return m_type;}
- uint32_t get_count() const {return m_count;}
- uint32_t get_open_count() const {return m_count - m_transfers.size();}
- bool is_open() const {return m_transfers.size() < m_count;}
- Economy * get_economy() const {return m_economy;}
+ PlayerImmovable & target() const {return target_;}
+ DescriptionIndex get_index() const {return index_;}
+ WareWorker get_type() const {return type_;}
+ uint32_t get_count() const {return count_;}
+ uint32_t get_open_count() const {return count_ - transfers_.size();}
+ bool is_open() const {return transfers_.size() < count_;}
+ Economy * get_economy() const {return economy_;}
int32_t get_required_time() const;
- int32_t get_last_request_time() const {return m_last_request_time;}
+ int32_t get_last_request_time() const {return last_request_time_;}
int32_t get_priority(int32_t cost) const;
uint32_t get_transfer_priority() const;
- uint32_t get_num_transfers() const {return m_transfers.size();}
+ uint32_t get_num_transfers() const {return transfers_.size();}
Flag & target_flag() const;
@@ -89,7 +89,7 @@
void set_required_time(int32_t time);
void set_required_interval(int32_t interval);
- void set_last_request_time(int32_t const time) {m_last_request_time = time;}
+ void set_last_request_time(int32_t const time) {last_request_time_ = time;}
void start_transfer(Game &, Supply &);
@@ -101,8 +101,8 @@
void transfer_finish(Game &, Transfer &);
void transfer_fail (Game &, Transfer &);
- void set_requirements (const Requirements & r) {m_requirements = r;}
- const Requirements & get_requirements () const {return m_requirements;}
+ void set_requirements (const Requirements & r) {requirements_ = r;}
+ const Requirements & get_requirements () const {return requirements_;}
private:
int32_t get_base_required_time(EditorGameBase &, uint32_t nr) const;
@@ -114,31 +114,31 @@
using TransferList = std::vector<Transfer *>;
- WareWorker m_type;
+ WareWorker type_;
- PlayerImmovable & m_target; // who requested it?
- // Copies of m_target of various pointer types, to avoid expensive
+ PlayerImmovable & target_; // who requested it?
+ // Copies of target_ of various pointer types, to avoid expensive
// dynamic casting at runtime. Variables with an incompatible type
// are filled with nulls.
- Building * m_target_building;
- ProductionSite * m_target_productionsite;
- Warehouse * m_target_warehouse;
- ConstructionSite * m_target_constructionsite;
-
- Economy * m_economy;
- DescriptionIndex m_index; // the index of the ware descr
- uint32_t m_count; // how many do we need in total
-
- CallbackFn m_callbackfn; // called on request success
+ Building * target_building_;
+ ProductionSite * target_productionsite_;
+ Warehouse * target_warehouse_;
+ ConstructionSite * target_constructionsite_;
+
+ Economy * economy_;
+ DescriptionIndex index_; // the index of the ware descr
+ uint32_t count_; // how many do we need in total
+
+ CallbackFn callbackfn_; // called on request success
// when do we need the first ware (can be in the past)
- int32_t m_required_time;
- int32_t m_required_interval; // time between wares
- int32_t m_last_request_time;
-
- TransferList m_transfers; // maximum size is m_count
-
- Requirements m_requirements;
+ int32_t required_time_;
+ int32_t required_interval_; // time between wares
+ int32_t last_request_time_;
+
+ TransferList transfers_; // maximum size is count_
+
+ Requirements requirements_;
};
}
=== modified file 'src/economy/road.cc'
--- src/economy/road.cc 2015-11-29 09:43:15 +0000
+++ src/economy/road.cc 2016-02-07 07:48:48 +0000
@@ -51,21 +51,21 @@
*/
Road::Road() :
PlayerImmovable (g_road_descr),
- m_busyness (0),
- m_busyness_last_update(0),
- m_type (0),
- m_idle_index(0)
+ busyness_ (0),
+ busyness_last_update_(0),
+ type_ (0),
+ idle_index_(0)
{
- m_flags[0] = m_flags[1] = nullptr;
- m_flagidx[0] = m_flagidx[1] = -1;
+ flags_[0] = flags_[1] = nullptr;
+ flagidx_[0] = flagidx_[1] = -1;
// Initialize the worker slots for the road
// TODO(unknown): make this configurable
CarrierSlot slot;
- m_carrier_slots.push_back(slot);
- m_carrier_slots.push_back(slot);
- m_carrier_slots[0].carrier_type = 1;
- m_carrier_slots[1].carrier_type = 2;
+ carrier_slots_.push_back(slot);
+ carrier_slots_.push_back(slot);
+ carrier_slots_[0].carrier_type = 1;
+ carrier_slots_[1].carrier_type = 2;
}
Road::CarrierSlot::CarrierSlot() :
@@ -80,7 +80,7 @@
*/
Road::~Road()
{
- for (CarrierSlot& slot: m_carrier_slots) {
+ for (CarrierSlot& slot: carrier_slots_) {
delete slot.carrier_request;
}
}
@@ -99,10 +99,10 @@
Player & owner = start.owner();
Road & road = *new Road();
road.set_owner(&owner);
- road.m_type = RoadType::kNormal;
- road.m_flags[FlagStart] = &start;
- road.m_flags[FlagEnd] = &end;
- // m_flagidx is set when attach_road() is called, i.e. in init()
+ road.type_ = RoadType::kNormal;
+ road.flags_[FlagStart] = &start;
+ road.flags_[FlagEnd] = &end;
+ // flagidx_ is set when attach_road() is called, i.e. in init()
road._set_path(egbase, path);
road.init(egbase);
@@ -124,24 +124,24 @@
(const EditorGameBase & egbase) const
{
Map & map = egbase.map();
- Coords curf = map.get_fcoords(m_path.get_start());
+ Coords curf = map.get_fcoords(path_.get_start());
PositionList rv;
- const Path::StepVector::size_type nr_steps = m_path.get_nsteps();
+ const Path::StepVector::size_type nr_steps = path_.get_nsteps();
for (Path::StepVector::size_type steps = 0; steps < nr_steps + 1; ++steps)
{
- if (steps > 0 && steps < m_path.get_nsteps())
+ if (steps > 0 && steps < path_.get_nsteps())
rv.push_back(curf);
- if (steps < m_path.get_nsteps())
- map.get_neighbour(curf, m_path[steps], &curf);
+ if (steps < path_.get_nsteps())
+ map.get_neighbour(curf, path_[steps], &curf);
}
return rv;
}
Flag & Road::base_flag()
{
- return *m_flags[FlagStart];
+ return *flags_[FlagStart];
}
/**
@@ -149,7 +149,7 @@
*/
int32_t Road::get_cost(FlagId fromflag)
{
- return m_cost[fromflag];
+ return cost_[fromflag];
}
/**
@@ -159,14 +159,14 @@
void Road::_set_path(EditorGameBase & egbase, const Path & path)
{
assert(path.get_nsteps() >= 2);
- assert(path.get_start() == m_flags[FlagStart]->get_position());
- assert(path.get_end() == m_flags[FlagEnd]->get_position());
+ assert(path.get_start() == flags_[FlagStart]->get_position());
+ assert(path.get_end() == flags_[FlagEnd]->get_position());
- m_path = path;
- egbase.map().calc_cost(path, &m_cost[FlagStart], &m_cost[FlagEnd]);
+ path_ = path;
+ egbase.map().calc_cost(path, &cost_[FlagStart], &cost_[FlagEnd]);
// Figure out where carriers should idle
- m_idle_index = path.get_nsteps() / 2;
+ idle_index_ = path.get_nsteps() / 2;
}
/**
@@ -175,30 +175,30 @@
void Road::_mark_map(EditorGameBase & egbase)
{
Map & map = egbase.map();
- FCoords curf = map.get_fcoords(m_path.get_start());
+ FCoords curf = map.get_fcoords(path_.get_start());
- const Path::StepVector::size_type nr_steps = m_path.get_nsteps();
+ const Path::StepVector::size_type nr_steps = path_.get_nsteps();
for (Path::StepVector::size_type steps = 0; steps < nr_steps + 1; ++steps)
{
- if (steps > 0 && steps < m_path.get_nsteps())
+ if (steps > 0 && steps < path_.get_nsteps())
set_position(egbase, curf);
// mark the road that leads up to this field
if (steps > 0) {
- const Direction dir = get_reverse_dir(m_path[steps - 1]);
+ const Direction dir = get_reverse_dir(path_[steps - 1]);
Direction const rdir = 2 * (dir - WALK_E);
if (rdir <= 4)
- egbase.set_road(curf, rdir, m_type);
+ egbase.set_road(curf, rdir, type_);
}
// mark the road that leads away from this field
- if (steps < m_path.get_nsteps()) {
- const Direction dir = m_path[steps];
+ if (steps < path_.get_nsteps()) {
+ const Direction dir = path_[steps];
Direction const rdir = 2 * (dir - WALK_E);
if (rdir <= 4)
- egbase.set_road(curf, rdir, m_type);
+ egbase.set_road(curf, rdir, type_);
map.get_neighbour(curf, dir, &curf);
}
@@ -210,17 +210,17 @@
*/
void Road::_unmark_map(EditorGameBase & egbase) {
Map & map = egbase.map();
- FCoords curf(m_path.get_start(), &map[m_path.get_start()]);
+ FCoords curf(path_.get_start(), &map[path_.get_start()]);
- const Path::StepVector::size_type nr_steps = m_path.get_nsteps();
+ const Path::StepVector::size_type nr_steps = path_.get_nsteps();
for (Path::StepVector::size_type steps = 0; steps < nr_steps + 1; ++steps)
{
- if (steps > 0 && steps < m_path.get_nsteps())
+ if (steps > 0 && steps < path_.get_nsteps())
unset_position(egbase, curf);
// mark the road that leads up to this field
if (steps > 0) {
- const Direction dir = get_reverse_dir(m_path[steps - 1]);
+ const Direction dir = get_reverse_dir(path_[steps - 1]);
Direction const rdir = 2 * (dir - WALK_E);
if (rdir <= 4)
@@ -228,8 +228,8 @@
}
// mark the road that leads away from this field
- if (steps < m_path.get_nsteps()) {
- const Direction dir = m_path[steps];
+ if (steps < path_.get_nsteps()) {
+ const Direction dir = path_[steps];
Direction const rdir = 2 * (dir - WALK_E);
if (rdir <= 4)
@@ -247,7 +247,7 @@
{
PlayerImmovable::init(egbase);
- if (2 <= m_path.get_nsteps())
+ if (2 <= path_.get_nsteps())
_link_into_flags(egbase);
}
@@ -259,22 +259,22 @@
* as Map Object, thats why this is moved
*/
void Road::_link_into_flags(EditorGameBase & egbase) {
- assert(m_path.get_nsteps() >= 2);
+ assert(path_.get_nsteps() >= 2);
// Link into the flags (this will also set our economy)
{
- const Direction dir = m_path[0];
- m_flags[FlagStart]->attach_road(dir, this);
- m_flagidx[FlagStart] = dir;
+ const Direction dir = path_[0];
+ flags_[FlagStart]->attach_road(dir, this);
+ flagidx_[FlagStart] = dir;
}
const Direction dir =
- get_reverse_dir(m_path[m_path.get_nsteps() - 1]);
- m_flags[FlagEnd]->attach_road(dir, this);
- m_flagidx[FlagEnd] = dir;
+ get_reverse_dir(path_[path_.get_nsteps() - 1]);
+ flags_[FlagEnd]->attach_road(dir, this);
+ flagidx_[FlagEnd] = dir;
- Economy::check_merge(*m_flags[FlagStart], *m_flags[FlagEnd]);
+ Economy::check_merge(*flags_[FlagStart], *flags_[FlagEnd]);
// Mark Fields
_mark_map(egbase);
@@ -285,7 +285,7 @@
* request a new carrier
*/
if (upcast(Game, game, &egbase)) {
- for (CarrierSlot& slot : m_carrier_slots) {
+ for (CarrierSlot& slot : carrier_slots_) {
if (Carrier * const carrier = slot.carrier.get(*game)) {
// This happens after a road split. Tell the carrier what's going on.
carrier->set_location (this);
@@ -293,7 +293,7 @@
} else if
(!slot.carrier_request &&
(slot.carrier_type == 1 ||
- m_type == RoadType::kBusy)) {
+ type_ == RoadType::kBusy)) {
_request_carrier(slot);
}
}
@@ -306,7 +306,7 @@
void Road::cleanup(EditorGameBase & egbase)
{
- for (CarrierSlot& slot : m_carrier_slots) {
+ for (CarrierSlot& slot : carrier_slots_) {
delete slot.carrier_request;
slot.carrier_request = nullptr;
@@ -318,14 +318,14 @@
_unmark_map(egbase);
// Unlink from flags (also clears the economy)
- m_flags[FlagStart]->detach_road(m_flagidx[FlagStart]);
- m_flags[FlagEnd]->detach_road(m_flagidx[FlagEnd]);
+ flags_[FlagStart]->detach_road(flagidx_[FlagStart]);
+ flags_[FlagEnd]->detach_road(flagidx_[FlagEnd]);
- Economy::check_split(*m_flags[FlagStart], *m_flags[FlagEnd]);
+ Economy::check_split(*flags_[FlagStart], *flags_[FlagEnd]);
if (upcast(Game, game, &egbase)) {
- m_flags[FlagStart]->update_wares(*game, m_flags[FlagEnd]);
- m_flags[FlagEnd]->update_wares(*game, m_flags[FlagStart]);
+ flags_[FlagStart]->update_wares(*game, flags_[FlagEnd]);
+ flags_[FlagEnd]->update_wares(*game, flags_[FlagStart]);
}
PlayerImmovable::cleanup(egbase);
@@ -339,7 +339,7 @@
{
PlayerImmovable::set_economy(e);
- for (CarrierSlot& slot: m_carrier_slots) {
+ for (CarrierSlot& slot: carrier_slots_) {
if (slot.carrier_request) {
slot.carrier_request->set_economy(e);
}
@@ -384,7 +384,7 @@
Road& road = dynamic_cast<Road&>(target);
- for (CarrierSlot& slot : road.m_carrier_slots) {
+ for (CarrierSlot& slot : road.carrier_slots_) {
if (slot.carrier_request == &rq) {
Carrier & carrier = dynamic_cast<Carrier&> (*w);
slot.carrier_request = nullptr;
@@ -414,7 +414,7 @@
{
EditorGameBase & egbase = owner().egbase();
- for (CarrierSlot& slot : m_carrier_slots) {
+ for (CarrierSlot& slot : carrier_slots_) {
Carrier const * carrier = slot.carrier.get(egbase);
if (carrier == &w) {
@@ -436,15 +436,15 @@
assert(slot <= 1);
// Send the worker home if it occupies our slot
- CarrierSlot & s = m_carrier_slots[slot];
+ CarrierSlot & s = carrier_slots_[slot];
delete s.carrier_request;
s.carrier_request = nullptr;
if (Carrier * const current_carrier = s.carrier.get(owner().egbase()))
current_carrier->set_location(nullptr);
- m_carrier_slots[slot].carrier = &c;
- m_carrier_slots[slot].carrier_request = nullptr;
+ carrier_slots_[slot].carrier = &c;
+ carrier_slots_[slot].carrier_request = nullptr;
}
@@ -465,14 +465,14 @@
// TODO(SirVer): This needs to take an EditorGameBase as well.
void Road::postsplit(Game & game, Flag & flag)
{
- Flag & oldend = *m_flags[FlagEnd];
+ Flag & oldend = *flags_[FlagEnd];
// detach from end
- oldend.detach_road(m_flagidx[FlagEnd]);
+ oldend.detach_road(flagidx_[FlagEnd]);
// build our new path and the new road's path
Map & map = game.map();
- CoordPath path(map, m_path);
+ CoordPath path(map, path_);
CoordPath secondpath(path);
int32_t const index = path.get_index(flag.get_position());
@@ -492,12 +492,12 @@
}
// change road size and reattach
- m_flags[FlagEnd] = &flag;
+ flags_[FlagEnd] = &flag;
_set_path(game, path);
- const Direction dir = get_reverse_dir(m_path[m_path.get_nsteps() - 1]);
- m_flags[FlagEnd]->attach_road(dir, this);
- m_flagidx[FlagEnd] = dir;
+ const Direction dir = get_reverse_dir(path_[path_.get_nsteps() - 1]);
+ flags_[FlagEnd]->attach_road(dir, this);
+ flagidx_[FlagEnd] = dir;
// recreate road markings
_mark_map(game);
@@ -505,9 +505,9 @@
// create the new road
Road & newroad = *new Road();
newroad.set_owner(get_owner());
- newroad.m_type = m_type;
- newroad.m_flags[FlagStart] = &flag; // flagidx will be set on init()
- newroad.m_flags[FlagEnd] = &oldend;
+ newroad.type_ = type_;
+ newroad.flags_[FlagStart] = &flag; // flagidx will be set on init()
+ newroad.flags_[FlagEnd] = &oldend;
newroad._set_path(game, secondpath);
// Find workers on this road that need to be reassigned
@@ -543,12 +543,12 @@
* The current worker is not on this road. Search him
* in this road and remove him. Than add him to the new road
*/
- for (CarrierSlot& old_slot : m_carrier_slots) {
+ for (CarrierSlot& old_slot : carrier_slots_) {
Carrier const * const carrier = old_slot.carrier.get(game);
if (carrier == w) {
old_slot.carrier = nullptr;
- for (CarrierSlot& new_slot : newroad.m_carrier_slots) {
+ for (CarrierSlot& new_slot : newroad.carrier_slots_) {
if
(!new_slot.carrier.get(game) &&
!new_slot.carrier_request &&
@@ -579,19 +579,19 @@
// Request a new carrier for this road if necessary. This must be done
// _after_ the new road initializes, otherwise request routing might not
// work correctly
- for (CarrierSlot& slot : m_carrier_slots) {
+ for (CarrierSlot& slot : carrier_slots_) {
if
(!slot.carrier.get(game) &&
!slot.carrier_request &&
(slot.carrier_type == 1 ||
- m_type == RoadType::kBusy)) {
+ type_ == RoadType::kBusy)) {
_request_carrier(slot);
}
}
// Make sure wares waiting on the original endpoint flags are dealt with.
- m_flags[FlagStart]->update_wares(game, &oldend);
- oldend.update_wares(game, m_flags[FlagStart]);
+ flags_[FlagStart]->update_wares(game, &oldend);
+ oldend.update_wares(game, flags_[FlagStart]);
}
/**
@@ -601,28 +601,28 @@
bool Road::notify_ware(Game & game, FlagId const flagid)
{
uint32_t const gametime = game.get_gametime();
- assert(m_busyness_last_update <= gametime);
- uint32_t const tdelta = gametime - m_busyness_last_update;
+ assert(busyness_last_update_ <= gametime);
+ uint32_t const tdelta = gametime - busyness_last_update_;
// Iterate over all carriers and try to find one which takes the ware.
- for (CarrierSlot& slot : m_carrier_slots) {
+ for (CarrierSlot& slot : carrier_slots_) {
if (Carrier * const carrier = slot.carrier.get(game))
if (carrier->notify_ware(game, flagid)) {
// notify_ware returns false if the carrier currently can not take
// the ware. If we get here, the carrier took the ware. So we
// decrement the usage busyness.
if (500 < tdelta) {
- m_busyness_last_update = gametime;
- if (m_busyness) {
- --m_busyness;
+ busyness_last_update_ = gametime;
+ if (busyness_) {
+ --busyness_;
- // If m_busyness drops below a limit, release the donkey.
+ // If busyness_ drops below a limit, release the donkey.
// remember that every time a ware is waiting at the flag
- // m_busyness increase by 10 but every time a ware is immediatly
- // acked by a carrier m_busyness is decreased by 1 only.
+ // busyness_ increase by 10 but every time a ware is immediatly
+ // acked by a carrier busyness_ is decreased by 1 only.
// so the limit is not so easy to reach
- if (m_busyness < 350) {
- Carrier * const second_carrier = m_carrier_slots[1].carrier.get(game);
+ if (busyness_ < 350) {
+ Carrier * const second_carrier = carrier_slots_[1].carrier.get(game);
if (second_carrier && second_carrier->top_state().task == &Carrier::taskRoad) {
second_carrier->send_signal(game, "cancel");
// this signal is not handled in any special way
@@ -630,9 +630,9 @@
// the string "cancel" has been used to make clear
// the final goal we want to achieve
// ie: cancelling current task
- m_carrier_slots[1].carrier = nullptr;
- m_carrier_slots[1].carrier_request = nullptr;
- m_type = RoadType::kNormal;
+ carrier_slots_[1].carrier = nullptr;
+ carrier_slots_[1].carrier_request = nullptr;
+ type_ = RoadType::kNormal;
_mark_map(game);
}
}
@@ -643,14 +643,14 @@
}
// If we get here, no carrier took the ware. So we check if we should
- // increment the usage counter. m_busyness_last_update prevents that the
+ // increment the usage counter. busyness_last_update_ prevents that the
// counter is incremented too often.
if (100 < tdelta) {
- m_busyness_last_update = gametime;
- if (500 < (m_busyness += 10)) {
- m_type = RoadType::kBusy;
+ busyness_last_update_ = gametime;
+ if (500 < (busyness_ += 10)) {
+ type_ = RoadType::kBusy;
_mark_map(game);
- for (CarrierSlot& slot : m_carrier_slots) {
+ for (CarrierSlot& slot : carrier_slots_) {
if
(!slot.carrier.get(game) &&
!slot.carrier_request &&
@@ -666,7 +666,7 @@
void Road::log_general_info(const EditorGameBase & egbase)
{
PlayerImmovable::log_general_info(egbase);
- molog("m_busyness: %i\n", m_busyness);
+ molog("busyness_: %i\n", busyness_);
}
}
=== modified file 'src/economy/road.h'
--- src/economy/road.h 2015-11-28 22:29:26 +0000
+++ src/economy/road.h 2016-02-07 07:48:48 +0000
@@ -85,9 +85,9 @@
(EditorGameBase &,
Flag & start, Flag & end, const Path &);
- Flag & get_flag(FlagId const flag) const {return *m_flags[flag];}
+ Flag & get_flag(FlagId const flag) const {return *flags_[flag];}
- uint8_t get_roadtype() const {return m_type;}
+ uint8_t get_roadtype() const {return type_;}
int32_t get_size () const override;
bool get_passable() const override;
PositionList get_positions(const EditorGameBase &) const override;
@@ -97,8 +97,8 @@
void set_economy(Economy *) override;
int32_t get_cost(FlagId fromflag);
- const Path & get_path() const {return m_path;}
- int32_t get_idle_index() const {return m_idle_index;}
+ const Path & get_path() const {return path_;}
+ int32_t get_idle_index() const {return idle_index_;}
void presplit(Game &, Coords split);
void postsplit(Game &, Flag &);
@@ -132,23 +132,23 @@
/// Counter that is incremented when a ware does not get a carrier for this
/// road immediately and decremented over time.
- uint32_t m_busyness;
-
- /// holds the gametime when m_busyness was last updated
- uint32_t m_busyness_last_update;
-
- uint8_t m_type; ///< RoadType, 2 bits used
- Flag * m_flags [2]; ///< start and end flag
- int32_t m_flagidx[2]; ///< index of this road in the flag's road array
+ uint32_t busyness_;
+
+ /// holds the gametime when busyness_ was last updated
+ uint32_t busyness_last_update_;
+
+ uint8_t type_; ///< RoadType, 2 bits used
+ Flag * flags_ [2]; ///< start and end flag
+ int32_t flagidx_[2]; ///< index of this road in the flag's road array
/// cost for walking this road (0 = from start to end, 1 = from end to start)
- int32_t m_cost [2];
+ int32_t cost_ [2];
- Path m_path; ///< path goes from start to end
- uint32_t m_idle_index; ///< index into path where carriers should idle
+ Path path_; ///< path goes from start to end
+ uint32_t idle_index_; ///< index into path where carriers should idle
using SlotVector = std::vector<CarrierSlot>;
- SlotVector m_carrier_slots;
+ SlotVector carrier_slots_;
};
}
=== modified file 'src/economy/route.cc'
--- src/economy/route.cc 2014-09-20 09:37:47 +0000
+++ src/economy/route.cc 2016-02-07 07:48:48 +0000
@@ -35,7 +35,7 @@
*/
namespace Widelands {
-Route::Route() : m_totalcost(0)
+Route::Route() : totalcost_(0)
{}
/**
@@ -44,8 +44,8 @@
*/
void Route::init(int32_t totalcost)
{
- m_totalcost = totalcost;
- m_route.clear();
+ totalcost_ = totalcost;
+ route_.clear();
}
/**
@@ -56,8 +56,8 @@
Flag & Route::get_flag
(EditorGameBase & egbase, std::vector<Flag *>::size_type const idx)
{
- assert(idx < m_route.size());
- return *m_route[idx].get(egbase);
+ assert(idx < route_.size());
+ return *route_[idx].get(egbase);
}
/**
@@ -65,9 +65,9 @@
*/
void Route::trim_start(int32_t count)
{
- assert(count < static_cast<int32_t>(m_route.size()));
+ assert(count < static_cast<int32_t>(route_.size()));
- m_route.erase(m_route.begin(), m_route.begin() + count);
+ route_.erase(route_.begin(), route_.begin() + count);
}
/**
@@ -75,9 +75,9 @@
*/
void Route::truncate(int32_t const count)
{
- assert(count < static_cast<int32_t>(m_route.size()));
+ assert(count < static_cast<int32_t>(route_.size()));
- m_route.erase(m_route.begin() + count + 1, m_route.end());
+ route_.erase(route_.begin() + count + 1, route_.end());
}
@@ -89,9 +89,9 @@
*/
void Route::load(LoadData & data, FileRead & fr)
{
- m_route.clear();
+ route_.clear();
- m_totalcost = fr.signed_32();
+ totalcost_ = fr.signed_32();
uint32_t nsteps = fr.unsigned_16();
for (uint32_t step = 0; step < nsteps; ++step)
data.flags.push_back(fr.unsigned_32());
@@ -106,7 +106,7 @@
for (uint32_t i = 0; i < data.flags.size(); ++i) {
uint32_t const flag_serial = data.flags.size();
try {
- m_route.push_back(&mol.get<Flag>(flag_serial));
+ route_.push_back(&mol.get<Flag>(flag_serial));
} catch (const WException & e) {
throw wexception("Route flag #%u (%u): %s", i, flag_serial, e.what());
}
@@ -121,10 +121,10 @@
(FileWrite & fw, EditorGameBase & egbase, MapObjectSaver & mos)
{
fw.signed_32(get_totalcost());
- fw.unsigned_16(m_route.size());
+ fw.unsigned_16(route_.size());
for
(std::vector<ObjectPointer>::size_type idx = 0;
- idx < m_route.size();
+ idx < route_.size();
++idx)
{
Flag & flag = get_flag(egbase, idx);
@@ -140,7 +140,7 @@
// we are sure that node is a Flag, since it is the only
// RoutingNode ever used in the path finder (outside tests)
// That's why we can make this cast
- m_route.insert(m_route.begin(), static_cast<Flag *>(node));
+ route_.insert(route_.begin(), static_cast<Flag *>(node));
}
}
=== modified file 'src/economy/route.h'
--- src/economy/route.h 2015-11-29 09:43:15 +0000
+++ src/economy/route.h 2016-02-07 07:48:48 +0000
@@ -46,8 +46,8 @@
void init(int32_t) override;
- int32_t get_totalcost() const {return m_totalcost;}
- int32_t get_nrsteps() const {return m_route.size() - 1;}
+ int32_t get_totalcost() const {return totalcost_;}
+ int32_t get_nrsteps() const {return route_.size() - 1;}
Flag & get_flag(EditorGameBase &, std::vector<Flag *>::size_type);
void trim_start(int32_t count);
@@ -64,8 +64,8 @@
void insert_as_first(RoutingNode * node) override;
private:
- int32_t m_totalcost;
- std::vector<OPtr<Flag> > m_route; ///< includes start and end flags
+ int32_t totalcost_;
+ std::vector<OPtr<Flag> > route_; ///< includes start and end flags
};
}
=== modified file 'src/economy/routeastar.cc'
--- src/economy/routeastar.cc 2015-10-25 15:44:36 +0000
+++ src/economy/routeastar.cc 2016-02-07 07:48:48 +0000
@@ -26,7 +26,7 @@
namespace Widelands {
BaseRouteAStar::BaseRouteAStar(Router & router, WareWorker type) :
- m_type(type),
+ type_(type),
mpf_cycle(router.assign_cycle())
{
}
=== modified file 'src/economy/routeastar.h'
--- src/economy/routeastar.h 2014-11-28 16:40:55 +0000
+++ src/economy/routeastar.h 2016-02-07 07:48:48 +0000
@@ -34,9 +34,9 @@
void routeto(RoutingNode & to, IRoute & route);
protected:
- RoutingNode::Queue m_open;
- WareWorker m_type;
- RoutingNodeNeighbours m_neighbours;
+ RoutingNode::Queue open_;
+ WareWorker type_;
+ RoutingNodeNeighbours neighbours_;
uint32_t mpf_cycle;
};
@@ -82,7 +82,7 @@
RoutingNode * step();
private:
- Estimator m_estimator;
+ Estimator estimator_;
};
/**
@@ -93,7 +93,7 @@
template<typename Est_>
RouteAStar<Est_>::RouteAStar(Router & router, WareWorker type, const Estimator & est) :
BaseRouteAStar(router, type),
- m_estimator(est)
+ estimator_(est)
{
}
@@ -109,33 +109,33 @@
node.mpf_cycle = mpf_cycle;
node.mpf_backlink = backlink;
node.mpf_realcost = cost;
- node.mpf_estimate = m_estimator(node);
- m_open.push(&node);
+ node.mpf_estimate = estimator_(node);
+ open_.push(&node);
} else if (node.mpf_cookie.is_active() && cost <= node.mpf_realcost) {
node.mpf_backlink = backlink;
node.mpf_realcost = cost;
- m_open.decrease_key(&node);
+ open_.decrease_key(&node);
}
}
template<typename Est_>
RoutingNode * RouteAStar<Est_>::step()
{
- if (m_open.empty())
+ if (open_.empty())
return nullptr;
// Keep the neighbours vector around to avoid excessive amounts of memory
// allocations and frees.
// Note that the C++ standard does not state whether clear will reset
// the reserved memory, but most implementations do not.
- m_neighbours.clear();
-
- RoutingNode * current = m_open.top();
- m_open.pop(current);
-
- current->get_neighbours(m_type, m_neighbours);
-
- for (RoutingNodeNeighbour& temp_neighbour : m_neighbours) {
+ neighbours_.clear();
+
+ RoutingNode * current = open_.top();
+ open_.pop(current);
+
+ current->get_neighbours(type_, neighbours_);
+
+ for (RoutingNodeNeighbour& temp_neighbour : neighbours_) {
RoutingNode & neighbour = *temp_neighbour.get_neighbour();
// We have already found the best path
@@ -158,18 +158,18 @@
*/
struct AStarEstimator {
AStarEstimator(ITransportCostCalculator & calc, RoutingNode & dest) :
- m_calc(calc), m_dest(dest.get_position())
+ calc_(calc), dest_(dest.get_position())
{
}
int32_t operator()(RoutingNode & current) const
{
- return m_calc.calc_cost_estimate(current.get_position(), m_dest);
+ return calc_.calc_cost_estimate(current.get_position(), dest_);
}
private:
- ITransportCostCalculator & m_calc;
- Coords m_dest;
+ ITransportCostCalculator & calc_;
+ Coords dest_;
};
/**
=== modified file 'src/economy/router.cc'
--- src/economy/router.cc 2013-07-26 20:19:36 +0000
+++ src/economy/router.cc 2016-02-07 07:48:48 +0000
@@ -33,13 +33,13 @@
/*************************************************************************/
/* Router Implementation */
/*************************************************************************/
-Router::Router(const ResetCycleFn & reset) : m_reset(reset), mpf_cycle(0) {}
+Router::Router(const ResetCycleFn & reset) : reset_(reset), mpf_cycle(0) {}
uint32_t Router::assign_cycle()
{
++mpf_cycle;
if (!mpf_cycle) { // reset all cycle fields
- m_reset();
+ reset_();
++mpf_cycle;
}
=== modified file 'src/economy/router.h'
--- src/economy/router.h 2015-11-28 22:29:26 +0000
+++ src/economy/router.h 2016-02-07 07:48:48 +0000
@@ -49,7 +49,7 @@
uint32_t assign_cycle();
private:
- ResetCycleFn m_reset;
+ ResetCycleFn reset_;
uint32_t mpf_cycle; ///< pathfinding cycle, see Flag::mpf_cycle
};
=== modified file 'src/economy/routing_node.h'
--- src/economy/routing_node.h 2015-11-28 22:29:26 +0000
+++ src/economy/routing_node.h 2016-02-07 07:48:48 +0000
@@ -37,18 +37,18 @@
*/
struct RoutingNodeNeighbour {
RoutingNodeNeighbour(RoutingNode * const f, int32_t const cost) :
- m_nb(f), m_cost(cost)
+ nb_(f), cost_(cost)
{}
RoutingNode * get_neighbour() const {
- return m_nb;
+ return nb_;
}
int32_t get_cost() const {
- return m_cost;
+ return cost_;
}
private:
- RoutingNode * m_nb;
- int32_t m_cost; /// Cost to get from me to the neighbour (Cost for road)
+ RoutingNode * nb_;
+ int32_t cost_; /// Cost to get from me to the neighbour (Cost for road)
};
using RoutingNodeNeighbours = std::vector<RoutingNodeNeighbour>;
=== modified file 'src/economy/shippingitem.cc'
--- src/economy/shippingitem.cc 2015-11-28 22:29:26 +0000
+++ src/economy/shippingitem.cc 2016-02-07 07:48:48 +0000
@@ -31,12 +31,12 @@
namespace Widelands {
ShippingItem::ShippingItem(WareInstance & ware) :
- m_object(&ware)
+ object_(&ware)
{
}
ShippingItem::ShippingItem(Worker & worker) :
- m_object(&worker)
+ object_(&worker)
{
}
@@ -48,7 +48,7 @@
*worker = nullptr;
}
- MapObject* obj = m_object.get(game);
+ MapObject* obj = object_.get(game);
if (!obj) {
return;
}
@@ -113,7 +113,7 @@
PortDock * ShippingItem::get_destination(Game & game)
{
- return m_destination_dock.get(game);
+ return destination_dock_.get(game);
}
void ShippingItem::update_destination(Game & game, PortDock & pd)
@@ -134,7 +134,7 @@
}
}
- m_destination_dock = dynamic_cast<PortDock *>(next);
+ destination_dock_ = dynamic_cast<PortDock *>(next);
}
void ShippingItem::schedule_update(Game & game, int32_t delay)
@@ -156,9 +156,9 @@
*/
void ShippingItem::remove(EditorGameBase & egbase)
{
- if (MapObject * obj = m_object.get(egbase)) {
+ if (MapObject * obj = object_.get(egbase)) {
obj->remove(egbase);
- m_object = nullptr;
+ object_ = nullptr;
}
}
@@ -170,7 +170,7 @@
try {
uint8_t packet_version = fr.unsigned_8();
if (packet_version == kCurrentPacketVersion) {
- m_serial = fr.unsigned_32();
+ serial_ = fr.unsigned_32();
} else {
throw UnhandledVersionError("ShippingItem", packet_version, kCurrentPacketVersion);
}
@@ -182,15 +182,15 @@
ShippingItem ShippingItem::Loader::get(MapObjectLoader & mol)
{
ShippingItem it;
- if (m_serial != 0)
- it.m_object = &mol.get<MapObject>(m_serial);
+ if (serial_ != 0)
+ it.object_ = &mol.get<MapObject>(serial_);
return it;
}
void ShippingItem::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw)
{
fw.unsigned_8(kCurrentPacketVersion);
- fw.unsigned_32(mos.get_object_file_index_or_zero(m_object.get(egbase)));
+ fw.unsigned_32(mos.get_object_file_index_or_zero(object_.get(egbase)));
}
} // namespace Widelands
=== modified file 'src/economy/shippingitem.h'
--- src/economy/shippingitem.h 2015-11-29 09:43:15 +0000
+++ src/economy/shippingitem.h 2016-02-07 07:48:48 +0000
@@ -62,7 +62,7 @@
ShippingItem get(MapObjectLoader & mol);
private:
- uint32_t m_serial;
+ uint32_t serial_;
};
void save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw);
@@ -77,11 +77,11 @@
// Sets the location of this shippingitem, this could be a ship, a portdock or a warehouse.
void set_location(Game&, MapObject* obj);
- // Updates m_destination_dock.
+ // Updates destination_dock_.
void update_destination(Game &, PortDock &);
- ObjectPointer m_object;
- OPtr<PortDock> m_destination_dock;
+ ObjectPointer object_;
+ OPtr<PortDock> destination_dock_;
};
} // namespace Widelands
=== modified file 'src/economy/supply_list.cc'
--- src/economy/supply_list.cc 2014-11-28 16:40:55 +0000
+++ src/economy/supply_list.cc 2016-02-07 07:48:48 +0000
@@ -30,7 +30,7 @@
*/
void SupplyList::add_supply(Supply & supp)
{
- m_supplies.push_back(&supp);
+ supplies_.push_back(&supp);
}
/**
@@ -38,13 +38,13 @@
*/
void SupplyList::remove_supply(Supply & supp)
{
- for (Supplies::iterator item_iter = m_supplies.begin();
- item_iter != m_supplies.end();
+ for (Supplies::iterator item_iter = supplies_.begin();
+ item_iter != supplies_.end();
++item_iter) {
if (*item_iter == &supp) {
- *item_iter = *(m_supplies.end() - 1);
- return m_supplies.pop_back();
+ *item_iter = *(supplies_.end() - 1);
+ return supplies_.pop_back();
}
}
throw wexception("SupplyList::remove: not in list");
@@ -56,8 +56,8 @@
*/
bool SupplyList::have_supplies(Game & game, const Request & req)
{
- for (size_t i = 0; i < m_supplies.size(); ++i)
- if (m_supplies[i]->nr_supplies(game, req))
+ for (size_t i = 0; i < supplies_.size(); ++i)
+ if (supplies_[i]->nr_supplies(game, req))
return true;
return false;
=== modified file 'src/economy/supply_list.h'
--- src/economy/supply_list.h 2014-09-14 11:31:58 +0000
+++ src/economy/supply_list.h 2016-02-07 07:48:48 +0000
@@ -36,15 +36,15 @@
void add_supply(Supply &);
void remove_supply(Supply &);
- size_t get_nrsupplies() const {return m_supplies.size();}
- const Supply & operator[](size_t const idx) const {return *m_supplies[idx];}
- Supply & operator[](size_t const idx) {return *m_supplies[idx];}
+ size_t get_nrsupplies() const {return supplies_.size();}
+ const Supply & operator[](size_t const idx) const {return *supplies_[idx];}
+ Supply & operator[](size_t const idx) {return *supplies_[idx];}
bool have_supplies(Game & game, const Request &);
private:
using Supplies = std::vector<Supply *>;
- Supplies m_supplies;
+ Supplies supplies_;
};
}
=== modified file 'src/economy/trackptr.h'
--- src/economy/trackptr.h 2014-07-05 16:41:51 +0000
+++ src/economy/trackptr.h 2016-02-07 07:48:48 +0000
@@ -42,29 +42,29 @@
friend class BaseTrackPtr;
class Tracker {
- uint32_t m_refcount;
- Trackable * m_ptr;
+ uint32_t refcount_;
+ Trackable * ptr_;
public:
- Tracker(Trackable * const p) : m_refcount(0), m_ptr(p) {}
+ Tracker(Trackable * const p) : refcount_(0), ptr_(p) {}
void addref() {
- ++m_refcount;
- assert(m_refcount > 0);
+ ++refcount_;
+ assert(refcount_ > 0);
}
void deref() {
- assert(m_refcount > 0);
- --m_refcount;
- if (!m_refcount && !m_ptr)
+ assert(refcount_ > 0);
+ --refcount_;
+ if (!refcount_ && !ptr_)
delete this;
}
void clear() {
- m_ptr = nullptr;
- if (!m_refcount)
+ ptr_ = nullptr;
+ if (!refcount_)
delete this;
}
- Trackable * get() {return m_ptr;}
+ Trackable * get() {return ptr_;}
// Putting "private:" here causes a compiler warning, even though we use
// delete this.
@@ -73,11 +73,11 @@
};
public:
- Trackable() {m_tracker = new Tracker(this);}
- virtual ~Trackable() {m_tracker->clear();}
+ Trackable() {tracker_ = new Tracker(this);}
+ virtual ~Trackable() {tracker_->clear();}
private:
- Tracker * m_tracker;
+ Tracker * tracker_;
};
@@ -88,56 +88,56 @@
type-safe interface.
*/
class BaseTrackPtr {
- mutable Trackable::Tracker * m_tracker;
+ mutable Trackable::Tracker * tracker_;
protected:
- BaseTrackPtr() : m_tracker(nullptr) {}
+ BaseTrackPtr() : tracker_(nullptr) {}
~BaseTrackPtr() {
- if (m_tracker)
- m_tracker->deref();
+ if (tracker_)
+ tracker_->deref();
}
BaseTrackPtr(Trackable * const t) {
if (t) {
- m_tracker = t->m_tracker;
- m_tracker->addref();
+ tracker_ = t->tracker_;
+ tracker_->addref();
} else
- m_tracker = nullptr;
+ tracker_ = nullptr;
}
BaseTrackPtr(const BaseTrackPtr & o) {
- m_tracker = o.m_tracker;
- if (m_tracker)
- m_tracker->addref();
+ tracker_ = o.tracker_;
+ if (tracker_)
+ tracker_->addref();
}
void set(const BaseTrackPtr & o) {
- if (m_tracker)
- m_tracker->deref();
+ if (tracker_)
+ tracker_->deref();
- m_tracker = o.m_tracker;
- if (m_tracker)
- m_tracker->addref();
+ tracker_ = o.tracker_;
+ if (tracker_)
+ tracker_->addref();
}
void set(Trackable * const t)
{
- if (m_tracker)
- m_tracker->deref();
+ if (tracker_)
+ tracker_->deref();
if (t) {
- m_tracker = t->m_tracker;
- m_tracker->addref();
+ tracker_ = t->tracker_;
+ tracker_->addref();
} else
- m_tracker = nullptr;
+ tracker_ = nullptr;
}
Trackable * get() const
{
- if (m_tracker) {
- if (Trackable * const t = m_tracker->get())
+ if (tracker_) {
+ if (Trackable * const t = tracker_->get())
return t;
- m_tracker->deref();
- m_tracker = nullptr;
+ tracker_->deref();
+ tracker_ = nullptr;
}
return nullptr;
=== modified file 'src/economy/transfer.cc'
--- src/economy/transfer.cc 2015-11-28 22:29:26 +0000
+++ src/economy/transfer.cc 2016-02-07 07:48:48 +0000
@@ -39,23 +39,23 @@
namespace Widelands {
Transfer::Transfer(Game & game, Request & req, WareInstance & it) :
- m_game(game),
- m_request(&req),
- m_destination(&req.target()),
- m_ware(&it),
- m_worker(nullptr)
+ game_(game),
+ request_(&req),
+ destination_(&req.target()),
+ ware_(&it),
+ worker_(nullptr)
{
- m_ware->set_transfer(game, *this);
+ ware_->set_transfer(game, *this);
}
Transfer::Transfer(Game & game, Request & req, Worker & w) :
- m_game(game),
- m_request(&req),
- m_destination(&req.target()),
- m_ware(nullptr),
- m_worker(&w)
+ game_(game),
+ request_(&req),
+ destination_(&req.target()),
+ ware_(nullptr),
+ worker_(&w)
{
- m_worker->start_task_transfer(game, this);
+ worker_->start_task_transfer(game, this);
}
/**
@@ -63,10 +63,10 @@
* given ware instance and without a request.
*/
Transfer::Transfer(Game & game, WareInstance & w) :
- m_game(game),
- m_request(nullptr),
- m_ware(&w),
- m_worker(nullptr)
+ game_(game),
+ request_(nullptr),
+ ware_(&w),
+ worker_(nullptr)
{
}
@@ -75,10 +75,10 @@
* worker and without a request.
*/
Transfer::Transfer(Game & game, Worker & w) :
- m_game(game),
- m_request(nullptr),
- m_ware(nullptr),
- m_worker(&w)
+ game_(game),
+ request_(nullptr),
+ ware_(nullptr),
+ worker_(&w)
{
}
@@ -87,12 +87,12 @@
*/
Transfer::~Transfer()
{
- if (m_worker) {
- assert(!m_ware);
+ if (worker_) {
+ assert(!ware_);
- m_worker->cancel_task_transfer(m_game);
- } else if (m_ware) {
- m_ware->cancel_transfer(m_game);
+ worker_->cancel_task_transfer(game_);
+ } else if (ware_) {
+ ware_->cancel_transfer(game_);
}
}
@@ -104,18 +104,18 @@
*/
void Transfer::set_request(Request * req)
{
- assert(!m_request);
+ assert(!request_);
assert(req);
- if (&req->target() != m_destination.get(m_game)) {
- if (m_destination.is_set())
+ if (&req->target() != destination_.get(game_)) {
+ if (destination_.is_set())
log
("WARNING: Transfer::set_request req->target (%u) "
"vs. destination (%u) mismatch\n",
- req->target().serial(), m_destination.serial());
- m_destination = &req->target();
+ req->target().serial(), destination_.serial());
+ destination_ = &req->target();
}
- m_request = req;
+ request_ = req;
}
/**
@@ -123,9 +123,9 @@
*/
void Transfer::set_destination(PlayerImmovable & imm)
{
- assert(!m_request);
+ assert(!request_);
- m_destination = &imm;
+ destination_ = &imm;
}
/**
@@ -133,7 +133,7 @@
*/
PlayerImmovable * Transfer::get_destination(Game & g)
{
- return m_destination.get(g);
+ return destination_.get(g);
}
/**
@@ -149,7 +149,7 @@
}
PlayerImmovable * destination =
- m_destination.get(location->get_economy()->owner().egbase());
+ destination_.get(location->get_economy()->owner().egbase());
if (!destination || destination->get_economy() != location->get_economy()) {
tlog("destination disappeared or economy mismatch -> fail\n");
success = false;
@@ -168,30 +168,30 @@
return &locflag == location ? destination : &locflag;
// Brute force: recalculate the best route every time
- if (!locflag.get_economy()->find_route(locflag, destflag, &m_route, m_ware ? wwWARE : wwWORKER)) {
+ if (!locflag.get_economy()->find_route(locflag, destflag, &route_, ware_ ? wwWARE : wwWORKER)) {
tlog("destination appears to have become split from current location -> fail\n");
Economy::check_split(locflag, destflag);
success = false;
return nullptr;
}
- if (m_route.get_nrsteps() >= 1)
+ if (route_.get_nrsteps() >= 1)
if (upcast(Road const, road, location))
- if (&road->get_flag(Road::FlagEnd) == &m_route.get_flag(m_game, 1))
- m_route.trim_start(1);
+ if (&road->get_flag(Road::FlagEnd) == &route_.get_flag(game_, 1))
+ route_.trim_start(1);
- if (m_route.get_nrsteps() >= 1)
+ if (route_.get_nrsteps() >= 1)
if (upcast(Road const, road, destination))
if
(&road->get_flag(Road::FlagEnd)
==
- &m_route.get_flag(m_game, m_route.get_nrsteps() - 1))
- m_route.truncate(m_route.get_nrsteps() - 1);
+ &route_.get_flag(game_, route_.get_nrsteps() - 1))
+ route_.truncate(route_.get_nrsteps() - 1);
// Reroute into PortDocks or the associated warehouse when appropriate
- if (m_route.get_nrsteps() >= 1) {
- Flag & curflag(m_route.get_flag(m_game, 0));
- Flag & nextflag(m_route.get_flag(m_game, 1));
+ if (route_.get_nrsteps() >= 1) {
+ Flag & curflag(route_.get_flag(game_, 0));
+ Flag & nextflag(route_.get_flag(game_, 1));
if (!curflag.get_road(nextflag)) {
upcast(Warehouse, wh, curflag.get_building());
assert(wh);
@@ -203,13 +203,13 @@
return pd->get_dock(nextflag);
if (location == wh)
return pd;
- if (location == &curflag || m_ware)
+ if (location == &curflag || ware_)
return wh;
return &curflag;
}
- if (m_ware && location == &curflag && m_route.get_nrsteps() >= 2) {
- Flag & nextnextflag(m_route.get_flag(m_game, 2));
+ if (ware_ && location == &curflag && route_.get_nrsteps() >= 2) {
+ Flag & nextnextflag(route_.get_flag(game_, 2));
if (!nextflag.get_road(nextnextflag)) {
upcast(Warehouse, wh, nextflag.get_building());
assert(wh);
@@ -221,24 +221,24 @@
// Now decide where we want to go
if (dynamic_cast<Flag const *>(location)) {
- assert(&m_route.get_flag(m_game, 0) == location);
+ assert(&route_.get_flag(game_, 0) == location);
// special rule to get wares into buildings
- if (m_ware && m_route.get_nrsteps() == 1)
+ if (ware_ && route_.get_nrsteps() == 1)
if (dynamic_cast<Building const *>(destination)) {
- assert(&m_route.get_flag(m_game, 1) == &destflag);
+ assert(&route_.get_flag(game_, 1) == &destflag);
return destination;
}
- if (m_route.get_nrsteps() >= 1) {
- return &m_route.get_flag(m_game, 1);
+ if (route_.get_nrsteps() >= 1) {
+ return &route_.get_flag(game_, 1);
}
return destination;
}
- return &m_route.get_flag(m_game, 0);
+ return &route_.get_flag(game_, 0);
}
/**
@@ -248,18 +248,18 @@
*/
void Transfer::has_finished()
{
- if (m_request) {
- m_request->transfer_finish(m_game, *this);
+ if (request_) {
+ request_->transfer_finish(game_, *this);
} else {
- PlayerImmovable * destination = m_destination.get(m_game);
+ PlayerImmovable * destination = destination_.get(game_);
assert(destination);
- if (m_worker) {
- destination->receive_worker(m_game, *m_worker);
- m_worker = nullptr;
+ if (worker_) {
+ destination->receive_worker(game_, *worker_);
+ worker_ = nullptr;
} else {
- destination->receive_ware(m_game, m_ware->descr_index());
- m_ware->destroy(m_game);
- m_ware = nullptr;
+ destination->receive_ware(game_, ware_->descr_index());
+ ware_->destroy(game_);
+ ware_ = nullptr;
}
delete this;
@@ -272,8 +272,8 @@
*/
void Transfer::has_failed()
{
- if (m_request) {
- m_request->transfer_fail(m_game, *this);
+ if (request_) {
+ request_->transfer_fail(game_, *this);
} else {
delete this;
}
@@ -290,12 +290,12 @@
vsnprintf(buffer, sizeof(buffer), fmt, va);
va_end(va);
- if (m_worker) {
+ if (worker_) {
id = 'W';
- serial = m_worker->serial();
- } else if (m_ware) {
+ serial = worker_->serial();
+ } else if (ware_) {
id = 'I';
- serial = m_ware->serial();
+ serial = ware_->serial();
} else {
id = '?';
serial = 0;
@@ -332,13 +332,13 @@
(MapObjectLoader & mol, const Widelands::Transfer::ReadData & rd)
{
if (rd.destination)
- m_destination = &mol.get<PlayerImmovable>(rd.destination);
+ destination_ = &mol.get<PlayerImmovable>(rd.destination);
}
void Transfer::write(MapObjectSaver & mos, FileWrite & fw)
{
fw.unsigned_8(kCurrentPacketVersion);
- fw.unsigned_32(mos.get_object_file_index_or_zero(m_destination.get(m_game)));
+ fw.unsigned_32(mos.get_object_file_index_or_zero(destination_.get(game_)));
// not saving route right now, will be recaculated anyway
}
=== modified file 'src/economy/transfer.h'
--- src/economy/transfer.h 2014-09-10 07:57:29 +0000
+++ src/economy/transfer.h 2016-02-07 07:48:48 +0000
@@ -52,11 +52,11 @@
Transfer(Game &, Worker &);
~Transfer();
- Request * get_request() const {return m_request;}
+ Request * get_request() const {return request_;}
void set_request(Request * req);
void set_destination(PlayerImmovable & imm);
PlayerImmovable * get_destination(Game & g);
- uint32_t get_steps_left() const {return m_route.get_nrsteps();}
+ uint32_t get_steps_left() const {return route_.get_nrsteps();}
/// Called by the controlled ware or worker
PlayerImmovable * get_next_step(PlayerImmovable *, bool & psuccess);
@@ -76,12 +76,12 @@
private:
void tlog(char const * fmt, ...) PRINTF_FORMAT(2, 3);
- Game & m_game;
- Request * m_request;
- OPtr<PlayerImmovable> m_destination;
- WareInstance * m_ware; ///< non-null iff this is transferring a ware
- Worker * m_worker; ///< non-null iff this is transferring a worker
- Route m_route;
+ Game & game_;
+ Request * request_;
+ OPtr<PlayerImmovable> destination_;
+ WareInstance * ware_; ///< non-null iff this is transferring a ware
+ Worker * worker_; ///< non-null iff this is transferring a worker
+ Route route_;
};
}
=== 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 07:48:48 +0000
@@ -65,15 +65,15 @@
Worker & launch_worker(Game &, const Request &) override;
private:
- WareInstance & m_ware;
- Economy * m_economy;
+ WareInstance & ware_;
+ Economy * economy_;
};
/**
* Initialize the Supply and update the economy.
*/
IdleWareSupply::IdleWareSupply(WareInstance & ware) :
- m_ware(ware), m_economy(nullptr)
+ ware_(ware), economy_(nullptr)
{
set_economy(ware.get_economy());
}
@@ -91,11 +91,11 @@
*/
void IdleWareSupply::set_economy(Economy * const e)
{
- if (m_economy != e) {
- if (m_economy)
- m_economy->remove_supply(*this);
- if ((m_economy = e))
- m_economy-> add_supply(*this);
+ if (economy_ != e) {
+ if (economy_)
+ economy_->remove_supply(*this);
+ if ((economy_ = e))
+ economy_-> add_supply(*this);
}
}
@@ -104,7 +104,7 @@
*/
PlayerImmovable * IdleWareSupply::get_position(Game & game)
{
- MapObject * const loc = m_ware.get_location(game);
+ MapObject * const loc = ware_.get_location(game);
if (upcast(PlayerImmovable, playerimmovable, loc))
return playerimmovable;
@@ -129,7 +129,7 @@
SupplyProviders IdleWareSupply::provider_type(Game* game) const
{
- MapObject * const loc = m_ware.get_location(*game);
+ MapObject * const loc = ware_.get_location(*game);
if (is_a(Ship, loc)) {
return SupplyProviders::kShip;
}
@@ -139,20 +139,20 @@
bool IdleWareSupply::has_storage() const
{
- return m_ware.is_moving();
+ return ware_.is_moving();
}
void IdleWareSupply::get_ware_type(WareWorker & type, DescriptionIndex & ware) const
{
type = wwWARE;
- ware = m_ware.descr_index();
+ ware = ware_.descr_index();
}
uint32_t IdleWareSupply::nr_supplies(const Game &, const Request & req) const
{
if
(req.get_type() == wwWARE &&
- req.get_index() == m_ware.descr_index())
+ req.get_index() == ware_.descr_index())
return 1;
return 0;
@@ -165,14 +165,14 @@
if (req.get_type() != wwWARE)
throw wexception
("IdleWareSupply::launch_ware : called for non-ware request");
- if (req.get_index() != m_ware.descr_index())
+ if (req.get_index() != ware_.descr_index())
throw wexception
("IdleWareSupply: ware(%u) (type = %i) requested for %i",
- m_ware.serial(),
- m_ware.descr_index(),
+ ware_.serial(),
+ ware_.descr_index(),
req.get_index());
- return m_ware;
+ return ware_;
}
Worker & IdleWareSupply::launch_worker(Game &, const Request &)
@@ -184,9 +184,9 @@
{
assert(!has_storage());
- Transfer * t = new Transfer(game, m_ware);
+ Transfer * t = new Transfer(game, ware_);
t->set_destination(*wh);
- m_ware.set_transfer(game, *t);
+ ware_.set_transfer(game, *t);
}
@@ -197,17 +197,17 @@
(DescriptionIndex const i, const WareDescr * const ware_descr)
:
MapObject (ware_descr),
-m_economy (nullptr),
-m_descr_index(i),
-m_supply (nullptr),
-m_transfer (nullptr)
+economy_ (nullptr),
+descr_index_(i),
+supply_ (nullptr),
+transfer_ (nullptr)
{}
WareInstance::~WareInstance()
{
- if (m_supply) {
- molog("Ware %u still has supply %p\n", m_descr_index, m_supply);
- delete m_supply;
+ if (supply_) {
+ molog("Ware %u still has supply %p\n", descr_index_, supply_);
+ delete supply_;
}
}
@@ -219,11 +219,11 @@
void WareInstance::cleanup(EditorGameBase & egbase)
{
// Unlink from our current location, if necessary
- if (upcast(Flag, flag, m_location.get(egbase)))
+ if (upcast(Flag, flag, location_.get(egbase)))
flag->remove_ware(egbase, this);
- delete m_supply;
- m_supply = nullptr;
+ delete supply_;
+ supply_ = nullptr;
cancel_moving();
set_location(egbase, nullptr);
@@ -236,18 +236,18 @@
*/
void WareInstance::set_economy(Economy * const e)
{
- if (m_descr_index == INVALID_INDEX || m_economy == e)
+ if (descr_index_ == INVALID_INDEX || economy_ == e)
return;
- if (m_economy)
- m_economy->remove_wares(m_descr_index, 1);
-
- m_economy = e;
- if (m_supply)
- m_supply->set_economy(e);
-
- if (m_economy)
- m_economy->add_wares(m_descr_index, 1);
+ if (economy_)
+ economy_->remove_wares(descr_index_, 1);
+
+ economy_ = e;
+ if (supply_)
+ supply_->set_economy(e);
+
+ if (economy_)
+ economy_->add_wares(descr_index_, 1);
}
/**
@@ -257,12 +257,12 @@
*/
void WareInstance::set_location(EditorGameBase & egbase, MapObject * const location)
{
- MapObject * const oldlocation = m_location.get(egbase);
+ MapObject * const oldlocation = location_.get(egbase);
if (oldlocation == location)
return;
- m_location = location;
+ location_ = location;
if (location) {
Economy * eco = nullptr;
@@ -314,7 +314,7 @@
if (!m_descr) // Upsy, we're not even initialized. Happens on load
return;
- MapObject * const loc = m_location.get(game);
+ MapObject * const loc = location_.get(game);
// Reset our state if we're not on location or outside an economy
if (!get_economy()) {
@@ -331,16 +331,16 @@
}
// Update whether we have a Supply or not
- if (!m_transfer || !m_transfer->get_request()) {
- if (!m_supply)
- m_supply = new IdleWareSupply(*this);
+ if (!transfer_ || !transfer_->get_request()) {
+ if (!supply_)
+ supply_ = new IdleWareSupply(*this);
} else {
- delete m_supply;
- m_supply = nullptr;
+ delete supply_;
+ supply_ = nullptr;
}
// Deal with transfers
- if (m_transfer) {
+ if (transfer_) {
upcast(PlayerImmovable, location, loc);
if (!location) {
@@ -349,17 +349,17 @@
bool success;
PlayerImmovable * const nextstep =
- m_transfer->get_next_step(location, success);
- m_transfer_nextstep = nextstep;
+ transfer_->get_next_step(location, success);
+ transfer_nextstep_ = nextstep;
if (!nextstep) {
if (upcast(Flag, flag, location))
flag->call_carrier(game, *this, nullptr);
- Transfer * const t = m_transfer;
+ Transfer * const t = transfer_;
- m_transfer = nullptr;
- m_transfer_nextstep = nullptr;
+ transfer_ = nullptr;
+ transfer_nextstep_ = nullptr;
if (success) {
t->has_finished();
@@ -395,12 +395,12 @@
*/
void WareInstance::enter_building(Game & game, Building & building)
{
- if (m_transfer) {
- if (m_transfer->get_destination(game) == &building) {
- Transfer * t = m_transfer;
+ if (transfer_) {
+ if (transfer_->get_destination(game) == &building) {
+ Transfer * t = transfer_;
- m_transfer = nullptr;
- m_transfer_nextstep = nullptr;
+ transfer_ = nullptr;
+ transfer_nextstep_ = nullptr;
t->has_finished();
return;
@@ -408,8 +408,8 @@
bool success;
PlayerImmovable * const nextstep =
- m_transfer->get_next_step(&building, success);
- m_transfer_nextstep = nextstep;
+ transfer_->get_next_step(&building, success);
+ transfer_nextstep_ = nextstep;
if (success) {
assert(nextstep);
@@ -440,16 +440,16 @@
building.get_position().y, nextstep->serial(),
nextstep->descr().name().c_str());
} else {
- Transfer * t = m_transfer;
+ Transfer * t = transfer_;
- m_transfer = nullptr;
- m_transfer_nextstep = nullptr;
+ transfer_ = nullptr;
+ transfer_nextstep_ = nullptr;
t->has_failed();
cancel_moving();
if (is_a(Warehouse, &building)) {
- building.receive_ware(game, m_descr_index);
+ building.receive_ware(game, descr_index_);
remove(game);
} else {
update(game);
@@ -458,7 +458,7 @@
}
} else {
// We don't have a transfer, so just enter the building
- building.receive_ware(game, m_descr_index);
+ building.receive_ware(game, descr_index_);
remove(game);
}
}
@@ -471,19 +471,19 @@
*/
void WareInstance::set_transfer(Game & game, Transfer & t)
{
- m_transfer_nextstep = nullptr;
+ transfer_nextstep_ = nullptr;
// Reset current transfer
- if (m_transfer) {
- m_transfer->has_failed();
- m_transfer = nullptr;
+ if (transfer_) {
+ transfer_->has_failed();
+ transfer_ = nullptr;
}
// Set transfer state
- m_transfer = &t;
+ transfer_ = &t;
- delete m_supply;
- m_supply = nullptr;
+ delete supply_;
+ supply_ = nullptr;
// Schedule an update.
// Do not update immediately, because update() could try to reference
@@ -498,8 +498,8 @@
*/
void WareInstance::cancel_transfer(Game & game)
{
- m_transfer = nullptr;
- m_transfer_nextstep = nullptr;
+ transfer_ = nullptr;
+ transfer_nextstep_ = nullptr;
update(game);
}
@@ -509,7 +509,7 @@
*/
bool WareInstance::is_moving() const
{
- return m_transfer;
+ return transfer_;
}
/**
@@ -520,10 +520,10 @@
{
molog("cancel_moving\n");
- if (m_transfer) {
- m_transfer->has_failed();
- m_transfer = nullptr;
- m_transfer_nextstep = nullptr;
+ if (transfer_) {
+ transfer_->has_failed();
+ transfer_ = nullptr;
+ transfer_nextstep_ = nullptr;
}
}
@@ -534,8 +534,8 @@
PlayerImmovable * WareInstance::get_next_move_step(Game & game)
{
return
- m_transfer ?
- dynamic_cast<PlayerImmovable *>(m_transfer_nextstep.get(game)) : nullptr;
+ transfer_ ?
+ dynamic_cast<PlayerImmovable *>(transfer_nextstep_.get(game)) : nullptr;
}
void WareInstance::log_general_info(const EditorGameBase & egbase)
@@ -543,7 +543,7 @@
MapObject::log_general_info(egbase);
molog("Ware: %s\n", descr().name().c_str());
- molog("Location: %u\n", m_location.serial());
+ molog("Location: %u\n", location_.serial());
}
@@ -558,8 +558,8 @@
constexpr uint8_t kCurrentPacketVersion = 2;
WareInstance::Loader::Loader() :
- m_location(0),
- m_transfer_nextstep(0)
+ location_(0),
+ transfer_nextstep_(0)
{
}
@@ -568,12 +568,12 @@
MapObject::Loader::load(fr);
WareInstance & ware = get<WareInstance>();
- m_location = fr.unsigned_32();
- m_transfer_nextstep = fr.unsigned_32();
+ location_ = fr.unsigned_32();
+ transfer_nextstep_ = fr.unsigned_32();
if (fr.unsigned_8()) {
- ware.m_transfer =
+ ware.transfer_ =
new Transfer(dynamic_cast<Game&>(egbase()), ware);
- ware.m_transfer->read(fr, m_transfer);
+ ware.transfer_->read(fr, transfer_);
}
}
@@ -586,12 +586,12 @@
// There is a race condition where a ware may lose its location and be scheduled
// for removal via the update callback, but the game is saved just before the
// removal. This is why we allow a null location on load.
- if (m_location)
- ware.set_location(egbase(), &mol().get<MapObject>(m_location));
- if (m_transfer_nextstep)
- ware.m_transfer_nextstep = &mol().get<MapObject>(m_transfer_nextstep);
- if (ware.m_transfer)
- ware.m_transfer->read_pointers(mol(), m_transfer);
+ if (location_)
+ ware.set_location(egbase(), &mol().get<MapObject>(location_));
+ if (transfer_nextstep_)
+ ware.transfer_nextstep_ = &mol().get<MapObject>(transfer_nextstep_);
+ if (ware.transfer_)
+ ware.transfer_->read_pointers(mol(), transfer_);
}
void WareInstance::Loader::load_finish()
@@ -599,9 +599,9 @@
MapObject::Loader::load_finish();
WareInstance & ware = get<WareInstance>();
- if (!ware.m_transfer || !ware.m_transfer->get_request()) {
- if (!ware.m_supply)
- ware.m_supply = new IdleWareSupply(ware);
+ if (!ware.transfer_ || !ware.transfer_->get_request()) {
+ if (!ware.supply_)
+ ware.supply_ = new IdleWareSupply(ware);
}
}
@@ -615,12 +615,12 @@
MapObject::save(egbase, mos, fw);
- fw.unsigned_32(mos.get_object_file_index_or_zero(m_location.get(egbase)));
+ fw.unsigned_32(mos.get_object_file_index_or_zero(location_.get(egbase)));
fw.unsigned_32
- (mos.get_object_file_index_or_zero(m_transfer_nextstep.get(egbase)));
- if (m_transfer) {
+ (mos.get_object_file_index_or_zero(transfer_nextstep_.get(egbase)));
+ if (transfer_) {
fw.unsigned_8(1);
- m_transfer->write(mos, fw);
+ transfer_->write(mos, fw);
} else {
fw.unsigned_8(0);
}
=== modified file 'src/economy/ware_instance.h'
--- src/economy/ware_instance.h 2015-11-29 09:43:15 +0000
+++ src/economy/ware_instance.h 2016-02-07 07:48:48 +0000
@@ -63,13 +63,13 @@
~WareInstance();
MapObject* get_location(EditorGameBase& egbase) {
- return m_location.get(egbase);
+ return location_.get(egbase);
}
Economy* get_economy() const {
- return m_economy;
+ return economy_;
}
DescriptionIndex descr_index() const {
- return m_descr_index;
+ return descr_index_;
}
void init(EditorGameBase&) override;
@@ -90,19 +90,19 @@
void set_transfer(Game&, Transfer&);
void cancel_transfer(Game&);
Transfer* get_transfer() const {
- return m_transfer;
+ return transfer_;
}
void log_general_info(const EditorGameBase& egbase) override;
private:
- ObjectPointer m_location;
- Economy* m_economy;
- DescriptionIndex m_descr_index;
+ ObjectPointer location_;
+ Economy* economy_;
+ DescriptionIndex descr_index_;
- IdleWareSupply* m_supply;
- Transfer* m_transfer;
- ObjectPointer m_transfer_nextstep; ///< cached PlayerImmovable, can be 0
+ IdleWareSupply* supply_;
+ Transfer* transfer_;
+ ObjectPointer transfer_nextstep_; ///< cached PlayerImmovable, can be 0
// loading and saving stuff
protected:
@@ -114,9 +114,9 @@
void load_finish() override;
private:
- uint32_t m_location;
- uint32_t m_transfer_nextstep;
- Transfer::ReadData m_transfer;
+ uint32_t location_;
+ uint32_t transfer_nextstep_;
+ Transfer::ReadData transfer_;
};
public:
=== modified file 'src/economy/warehousesupply.h'
--- src/economy/warehousesupply.h 2016-01-08 21:00:39 +0000
+++ src/economy/warehousesupply.h 2016-02-07 07:48:48 +0000
@@ -31,7 +31,7 @@
It also manages the list of wares in the warehouse.
*/
struct WarehouseSupply : public Supply {
- WarehouseSupply(Warehouse * const wh) : m_economy(nullptr), m_warehouse(wh) {}
+ WarehouseSupply(Warehouse * const wh) : economy_(nullptr), warehouse_(wh) {}
virtual ~WarehouseSupply();
void set_economy(Economy *);
@@ -39,13 +39,13 @@
void set_nrworkers(DescriptionIndex);
void set_nrwares (DescriptionIndex);
- const WareList & get_wares () const {return m_wares;}
- const WareList & get_workers() const {return m_workers;}
+ const WareList & get_wares () const {return wares_;}
+ const WareList & get_workers() const {return workers_;}
uint32_t stock_wares (DescriptionIndex const i) const {
- return m_wares .stock(i);
+ return wares_ .stock(i);
}
uint32_t stock_workers(DescriptionIndex const i) const {
- return m_workers.stock(i);
+ return workers_.stock(i);
}
void add_wares (DescriptionIndex, uint32_t count);
void remove_wares (DescriptionIndex, uint32_t count);
@@ -65,10 +65,10 @@
Worker & launch_worker(Game &, const Request &) override;
private:
- Economy * m_economy;
- WareList m_wares;
- WareList m_workers; // we use this to keep the soldiers
- Warehouse * m_warehouse;
+ Economy * economy_;
+ WareList wares_;
+ WareList workers_; // we use this to keep the soldiers
+ Warehouse * warehouse_;
};
}
=== modified file 'src/economy/wares_queue.cc'
--- src/economy/wares_queue.cc 2015-11-28 22:29:26 +0000
+++ src/economy/wares_queue.cc 2016-02-07 07:48:48 +0000
@@ -41,17 +41,17 @@
DescriptionIndex const _ware,
uint8_t const _max_size)
:
- m_owner (_owner),
- m_ware (_ware),
- m_max_size (_max_size),
- m_max_fill (_max_size),
- m_filled (0),
- m_consume_interval(0),
- m_request (nullptr),
- m_callback_fn (nullptr),
- m_callback_data (nullptr)
+ owner_ (_owner),
+ ware_ (_ware),
+ max_size_ (_max_size),
+ max_fill_ (_max_size),
+ filled_ (0),
+ consume_interval_(0),
+ request_ (nullptr),
+ callback_fn_ (nullptr),
+ callback_data_ (nullptr)
{
- if (m_ware != INVALID_INDEX)
+ if (ware_ != INVALID_INDEX)
update();
}
@@ -60,18 +60,18 @@
* Clear the queue appropriately.
*/
void WaresQueue::cleanup() {
- assert(m_ware != INVALID_INDEX);
-
- if (m_filled && m_owner.get_economy())
- m_owner.get_economy()->remove_wares(m_ware, m_filled);
-
- m_filled = 0;
- m_max_size = 0;
- m_max_fill = 0;
+ assert(ware_ != INVALID_INDEX);
+
+ if (filled_ && owner_.get_economy())
+ owner_.get_economy()->remove_wares(ware_, filled_);
+
+ filled_ = 0;
+ max_size_ = 0;
+ max_fill_ = 0;
update();
- m_ware = INVALID_INDEX;
+ ware_ = INVALID_INDEX;
}
/**
@@ -79,31 +79,31 @@
* You must call this after every call to set_*()
*/
void WaresQueue::update() {
- assert(m_ware != INVALID_INDEX);
+ assert(ware_ != INVALID_INDEX);
- if (m_filled > m_max_size) {
- if (m_owner.get_economy())
- m_owner.get_economy()->remove_wares(m_ware, m_filled - m_max_size);
- m_filled = m_max_size;
+ if (filled_ > max_size_) {
+ if (owner_.get_economy())
+ owner_.get_economy()->remove_wares(ware_, filled_ - max_size_);
+ filled_ = max_size_;
}
- if (m_filled < m_max_fill)
+ if (filled_ < max_fill_)
{
- if (!m_request)
- m_request =
+ if (!request_)
+ request_ =
new Request
- (m_owner,
- m_ware,
+ (owner_,
+ ware_,
WaresQueue::request_callback,
wwWARE);
- m_request->set_count(m_max_fill - m_filled);
- m_request->set_required_interval(m_consume_interval);
+ request_->set_count(max_fill_ - filled_);
+ request_->set_required_interval(consume_interval_);
}
else
{
- delete m_request;
- m_request = nullptr;
+ delete request_;
+ request_ = nullptr;
}
}
@@ -112,8 +112,8 @@
*/
void WaresQueue::set_callback(CallbackFn * const fn, void * const data)
{
- m_callback_fn = fn;
- m_callback_data = data;
+ callback_fn_ = fn;
+ callback_data_ = data;
}
/**
@@ -134,14 +134,14 @@
dynamic_cast<Building&>(target).waresqueue(ware);
assert(!w); // WaresQueue can't hold workers
- assert(wq.m_filled < wq.m_max_size);
- assert(wq.m_ware == ware);
+ assert(wq.filled_ < wq.max_size_);
+ assert(wq.ware_ == ware);
// Update
- wq.set_filled(wq.m_filled + 1);
+ wq.set_filled(wq.filled_ + 1);
- if (wq.m_callback_fn)
- (*wq.m_callback_fn)(game, &wq, ware, wq.m_callback_data);
+ if (wq.callback_fn_)
+ (*wq.callback_fn_)(game, &wq, ware, wq.callback_data_);
}
/**
@@ -149,10 +149,10 @@
*/
void WaresQueue::remove_from_economy(Economy & e)
{
- if (m_ware != INVALID_INDEX) {
- e.remove_wares(m_ware, m_filled);
- if (m_request)
- m_request->set_economy(nullptr);
+ if (ware_ != INVALID_INDEX) {
+ e.remove_wares(ware_, filled_);
+ if (request_)
+ request_->set_economy(nullptr);
}
}
@@ -161,10 +161,10 @@
*/
void WaresQueue::add_to_economy(Economy & e)
{
- if (m_ware != INVALID_INDEX) {
- e.add_wares(m_ware, m_filled);
- if (m_request)
- m_request->set_economy(&e);
+ if (ware_ != INVALID_INDEX) {
+ e.add_wares(ware_, filled_);
+ if (request_)
+ request_->set_economy(&e);
}
}
@@ -173,14 +173,14 @@
*/
void WaresQueue::set_max_size(const uint32_t size)
{
- uint32_t old_size = m_max_size;
- m_max_size = size;
+ uint32_t old_size = max_size_;
+ max_size_ = size;
// make sure that max fill is reduced as well if the max size is decreased
// because this is very likely what the user wanted to only consume so
// and so many wares in the first place. If it is increased, keep the
// max fill fill as it was
- set_max_fill(std::min(m_max_fill, m_max_fill - (old_size - m_max_size)));
+ set_max_fill(std::min(max_fill_, max_fill_ - (old_size - max_size_)));
update();
}
@@ -194,10 +194,10 @@
*/
void WaresQueue::set_max_fill(uint32_t size)
{
- if (size > m_max_size)
- size = m_max_size;
+ if (size > max_size_)
+ size = max_size_;
- m_max_fill = size;
+ max_fill_ = size;
update();
}
@@ -206,14 +206,14 @@
* Change fill status of the queue.
*/
void WaresQueue::set_filled(const uint32_t filled) {
- if (m_owner.get_economy()) {
- if (filled > m_filled)
- m_owner.get_economy()->add_wares(m_ware, filled - m_filled);
- else if (filled < m_filled)
- m_owner.get_economy()->remove_wares(m_ware, m_filled - filled);
+ if (owner_.get_economy()) {
+ if (filled > filled_)
+ owner_.get_economy()->add_wares(ware_, filled - filled_);
+ else if (filled < filled_)
+ owner_.get_economy()->remove_wares(ware_, filled_ - filled);
}
- m_filled = filled;
+ filled_ = filled;
update();
}
@@ -226,7 +226,7 @@
*/
void WaresQueue::set_consume_interval(const uint32_t time)
{
- m_consume_interval = time;
+ consume_interval_ = time;
update();
}
@@ -243,14 +243,14 @@
// Owner and callback is not saved, but this should be obvious on load.
fw.c_string
- (owner().tribe().get_ware_descr(m_ware)->name().c_str());
- fw.signed_32(m_max_size);
- fw.signed_32(m_max_fill);
- fw.signed_32(m_filled);
- fw.signed_32(m_consume_interval);
- if (m_request) {
+ (owner().tribe().get_ware_descr(ware_)->name().c_str());
+ fw.signed_32(max_size_);
+ fw.signed_32(max_fill_);
+ fw.signed_32(filled_);
+ fw.signed_32(consume_interval_);
+ if (request_) {
fw.unsigned_8(1);
- m_request->write(fw, game, mos);
+ request_->write(fw, game, mos);
} else
fw.unsigned_8(0);
}
@@ -261,26 +261,26 @@
uint16_t const packet_version = fr.unsigned_16();
try {
if (packet_version == kCurrentPacketVersion) {
- delete m_request;
- m_ware = owner().tribe().ware_index(fr.c_string ());
- m_max_size = fr.unsigned_32();
- m_max_fill = fr.signed_32();
- m_filled = fr.unsigned_32();
- m_consume_interval = fr.unsigned_32();
+ delete request_;
+ ware_ = owner().tribe().ware_index(fr.c_string ());
+ max_size_ = fr.unsigned_32();
+ max_fill_ = fr.signed_32();
+ filled_ = fr.unsigned_32();
+ consume_interval_ = fr.unsigned_32();
if (fr.unsigned_8 ()) {
- m_request = // TODO(unknown): Change Request::read
+ request_ = // TODO(unknown): Change Request::read
new Request // to a constructor.
- (m_owner,
+ (owner_,
0,
WaresQueue::request_callback,
wwWORKER);
- m_request->read(fr, game, mol);
+ request_->read(fr, game, mol);
} else
- m_request = nullptr;
+ request_ = nullptr;
// Now Economy stuff. We have to add our filled items to the economy.
- if (m_owner.get_economy())
- add_to_economy(*m_owner.get_economy());
+ if (owner_.get_economy())
+ add_to_economy(*owner_.get_economy());
} else {
throw UnhandledVersionError("WaresQueue", packet_version, kCurrentPacketVersion);
}
=== modified file 'src/economy/wares_queue.h'
--- src/economy/wares_queue.h 2015-11-28 22:29:26 +0000
+++ src/economy/wares_queue.h 2016-02-07 07:48:48 +0000
@@ -45,13 +45,13 @@
WaresQueue(PlayerImmovable &, DescriptionIndex, uint8_t size);
#ifndef NDEBUG
- ~WaresQueue() {assert(m_ware == INVALID_INDEX);}
+ ~WaresQueue() {assert(ware_ == INVALID_INDEX);}
#endif
- DescriptionIndex get_ware() const {return m_ware;}
- uint32_t get_max_fill() const {return m_max_fill;}
- uint32_t get_max_size() const {return m_max_size;}
- uint32_t get_filled() const {return m_filled;}
+ DescriptionIndex get_ware() const {return ware_;}
+ uint32_t get_max_fill() const {return max_fill_;}
+ uint32_t get_max_size() const {return max_size_;}
+ uint32_t get_filled() const {return filled_;}
void cleanup();
@@ -65,7 +65,7 @@
void set_filled (uint32_t);
void set_consume_interval(uint32_t);
- Player & owner() const {return m_owner.owner();}
+ Player & owner() const {return owner_.owner();}
void read (FileRead &, Game &, MapObjectLoader &);
void write(FileWrite &, Game &, MapObjectSaver &);
@@ -75,19 +75,19 @@
(Game &, Request &, DescriptionIndex, Worker *, PlayerImmovable &);
void update();
- PlayerImmovable & m_owner;
- DescriptionIndex m_ware; ///< ware ID
- uint32_t m_max_size; ///< nr of items that fit into the queue maximum
- uint32_t m_max_fill; ///< nr of wares that should be ideally in this queue
- uint32_t m_filled; ///< nr of items that are currently in the queue
+ PlayerImmovable & owner_;
+ DescriptionIndex ware_; ///< ware ID
+ uint32_t max_size_; ///< nr of items that fit into the queue maximum
+ uint32_t max_fill_; ///< nr of wares that should be ideally in this queue
+ uint32_t filled_; ///< nr of items that are currently in the queue
///< time in ms between consumption at full speed
- uint32_t m_consume_interval;
-
- Request * m_request; ///< currently pending request
-
- CallbackFn * m_callback_fn;
- void * m_callback_data;
+ uint32_t consume_interval_;
+
+ Request * request_; ///< currently pending request
+
+ CallbackFn * callback_fn_;
+ void * callback_data_;
};
}
=== modified file 'src/io/streamread.cc'
--- src/io/streamread.cc 2014-09-20 09:37:47 +0000
+++ src/io/streamread.cc 2016-02-07 07:48:48 +0000
@@ -35,7 +35,7 @@
vsnprintf(buffer, sizeof(buffer), fmt, va);
va_end(va);
}
- m_what += buffer;
+ what_ += buffer;
}
/**
=== modified file 'src/logic/game_data_error.cc'
--- src/logic/game_data_error.cc 2015-10-24 15:42:37 +0000
+++ src/logic/game_data_error.cc 2016-02-07 07:48:48 +0000
@@ -37,14 +37,14 @@
vsnprintf(buffer, sizeof(buffer), fmt, va);
va_end(va);
}
- m_what = buffer;
+ what_ = buffer;
}
UnhandledVersionError::UnhandledVersionError(const char* packet_name, int32_t packet_version,
int32_t current_packet_version)
{
- m_what = (boost::format
+ what_ = (boost::format
("\n\nUnhandledVersionError: %s\n\nPacket Name: %s\nSaved Version: %i\nCurrent Version: %i")
% _("This game was saved using an older version of Widelands and cannot be loaded anymore, "
"or it's a new version that can't be handled yet.")
=== modified file 'src/logic/game_data_error.h'
--- src/logic/game_data_error.h 2016-01-28 05:24:34 +0000
+++ src/logic/game_data_error.h 2016-02-07 07:48:48 +0000
@@ -29,7 +29,7 @@
struct GameDataError : public WException {
explicit GameDataError(char const * fmt, ...) PRINTF_FORMAT(2, 3);
- char const * what() const noexcept override {return m_what.c_str();}
+ char const * what() const noexcept override {return what_.c_str();}
protected:
GameDataError() {}
};
@@ -49,7 +49,7 @@
explicit UnhandledVersionError(const char* packet_name, int32_t packet_version,
int32_t current_packet_version);
- char const * what() const noexcept override {return m_what.c_str();}
+ char const * what() const noexcept override {return what_.c_str();}
protected:
UnhandledVersionError() {}
};
=== 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 07:48:48 +0000
@@ -122,9 +122,9 @@
m_fleet->remove_ship(egbase, this);
}
- while (!m_items.empty()) {
- m_items.back().remove(egbase);
- m_items.pop_back();
+ while (!items_.empty()) {
+ items_.back().remove(egbase);
+ items_.pop_back();
}
Notifications::publish(NoteShipMessage(this, NoteShipMessage::Message::kLost));
@@ -637,10 +637,10 @@
if (baim) {
upcast(ConstructionSite, cs, baim);
- for (int i = m_items.size() - 1; i >= 0; --i) {
+ for (int i = items_.size() - 1; i >= 0; --i) {
WareInstance* ware;
Worker* worker;
- m_items.at(i).get(game, &ware, &worker);
+ items_.at(i).get(game, &ware, &worker);
if (ware) {
// no, we don't transfer the wares, we create new ones out of
// air and remove the old ones ;)
@@ -664,8 +664,8 @@
assert(wq.get_max_fill() > cur);
wq.set_filled(cur + 1);
- m_items.at(i).remove(game);
- m_items.resize(i);
+ items_.at(i).remove(game);
+ items_.resize(i);
break;
} else {
assert(worker);
@@ -675,7 +675,7 @@
worker->reset_tasks(game);
PartiallyFinishedBuilding::request_builder_callback(
game, *cs->get_builder_request(), worker->descr().worker_index(), worker, *cs);
- m_items.resize(i);
+ items_.resize(i);
}
}
} else { // it seems that port constructionsite has dissapeared
@@ -689,7 +689,7 @@
send_signal(game, "cancel_expedition");
}
- if (m_items.empty() || !baim) { // we are done, either way
+ if (items_.empty() || !baim) { // we are done, either way
m_ship_state = TRANSPORT; // That's it, expedition finished
// Bring us back into a fleet and a economy.
@@ -698,7 +698,7 @@
// for case that there are any workers left on board
// (applicable when port construction space is kLost)
Worker* worker;
- for (ShippingItem& item : m_items) {
+ for (ShippingItem& item : items_) {
item.get(game, nullptr, &worker);
if (worker) {
worker->reset_tasks(game);
@@ -728,7 +728,7 @@
// we rely that wares really get reassigned our economy.
m_economy = e;
- for (ShippingItem& shipping_item : m_items) {
+ for (ShippingItem& shipping_item : items_) {
shipping_item.set_economy(game, e);
}
}
@@ -740,29 +740,29 @@
*/
void Ship::set_destination(Game& game, PortDock& pd) {
molog("set_destination / sending to portdock %u (carrying %" PRIuS " items)\n",
- pd.serial(), m_items.size());
+ pd.serial(), items_.size());
m_destination = &pd;
send_signal(game, "wakeup");
}
void Ship::add_item(Game& game, const ShippingItem& item) {
- assert(m_items.size() < descr().get_capacity());
+ assert(items_.size() < descr().get_capacity());
- m_items.push_back(item);
- m_items.back().set_location(game, this);
+ items_.push_back(item);
+ items_.back().set_location(game, this);
}
void Ship::withdraw_items(Game& game, PortDock& pd, std::vector<ShippingItem>& items) {
uint32_t dst = 0;
- for (uint32_t src = 0; src < m_items.size(); ++src) {
- PortDock* destination = m_items[src].get_destination(game);
+ for (uint32_t src = 0; src < items_.size(); ++src) {
+ PortDock* destination = items_[src].get_destination(game);
if (!destination || destination == &pd) {
- items.push_back(m_items[src]);
+ items.push_back(items_[src]);
} else {
- m_items[dst++] = m_items[src];
+ items_[dst++] = items_[src];
}
}
- m_items.resize(dst);
+ items_.resize(dst);
}
/**
@@ -846,10 +846,10 @@
set_economy(game, m_expedition->economy.get());
- for (int i = m_items.size() - 1; i >= 0; --i) {
+ for (int i = items_.size() - 1; i >= 0; --i) {
WareInstance* ware;
Worker* worker;
- m_items.at(i).get(game, &ware, &worker);
+ items_.at(i).get(game, &ware, &worker);
if (worker) {
worker->reset_tasks(game);
worker->start_task_idle(game, 0, -1);
@@ -930,7 +930,7 @@
// economy with us and the warehouse will make sure that they are
// getting used.
Worker* worker;
- for (ShippingItem& item : m_items) {
+ for (ShippingItem& item : items_) {
item.get(game, nullptr, &worker);
if (worker) {
worker->reset_tasks(game);
@@ -971,12 +971,12 @@
m_fleet ? m_fleet->serial() : 0,
m_destination.serial(),
m_lastdock.serial(),
- m_items.size());
+ items_.size());
- for (const ShippingItem& shipping_item : m_items) {
+ for (const ShippingItem& shipping_item : items_) {
molog(" IT %u, destination %u\n",
- shipping_item.m_object.serial(),
- shipping_item.m_destination_dock.serial());
+ shipping_item.object_.serial(),
+ shipping_item.destination_dock_.serial());
}
}
@@ -1088,9 +1088,9 @@
if (m_destination)
ship.m_destination = &mol().get<PortDock>(m_destination);
- ship.m_items.resize(m_items.size());
+ ship.items_.resize(m_items.size());
for (uint32_t i = 0; i < m_items.size(); ++i) {
- ship.m_items[i] = m_items[i].get(mol());
+ ship.items_[i] = m_items[i].get(mol());
}
}
@@ -1198,8 +1198,8 @@
fw.unsigned_32(mos.get_object_file_index_or_zero(m_lastdock.get(egbase)));
fw.unsigned_32(mos.get_object_file_index_or_zero(m_destination.get(egbase)));
- fw.unsigned_32(m_items.size());
- for (ShippingItem& shipping_item : m_items) {
+ fw.unsigned_32(items_.size());
+ for (ShippingItem& shipping_item : items_) {
shipping_item.save(egbase, mos, fw);
}
}
=== modified file 'src/logic/map_objects/tribes/ship.h'
--- src/logic/map_objects/tribes/ship.h 2016-01-28 05:24:34 +0000
+++ src/logic/map_objects/tribes/ship.h 2016-02-07 07:48:48 +0000
@@ -114,8 +114,8 @@
void log_general_info(const EditorGameBase &) override;
- uint32_t get_nritems() const {return m_items.size();}
- const ShippingItem & get_item(uint32_t idx) const {return m_items[idx];}
+ uint32_t get_nritems() const {return items_.size();}
+ const ShippingItem & get_item(uint32_t idx) const {return items_[idx];}
void withdraw_items(Game & game, PortDock & pd, std::vector<ShippingItem> & items);
void add_item(Game &, const ShippingItem & item);
@@ -249,7 +249,7 @@
Economy * m_economy;
OPtr<PortDock> m_lastdock;
OPtr<PortDock> m_destination;
- std::vector<ShippingItem> m_items;
+ std::vector<ShippingItem> items_;
uint8_t m_ship_state;
std::string m_shipname;
=== modified file 'src/logic/map_objects/tribes/warehouse.cc'
--- src/logic/map_objects/tribes/warehouse.cc 2016-01-28 05:24:34 +0000
+++ src/logic/map_objects/tribes/warehouse.cc 2016-02-07 07:48:48 +0000
@@ -70,59 +70,59 @@
WarehouseSupply::~WarehouseSupply()
{
- if (m_economy) {
+ if (economy_) {
log
("WarehouseSupply::~WarehouseSupply: Warehouse %u still belongs to "
"an economy",
- m_warehouse->serial());
+ warehouse_->serial());
set_economy(nullptr);
}
// We're removed from the Economy. Therefore, the wares can simply
// be cleared out. The global inventory will be okay.
- m_wares .clear();
- m_workers.clear();
+ wares_ .clear();
+ workers_.clear();
}
/// Inform this supply, how much wares are to be handled
void WarehouseSupply::set_nrwares(DescriptionIndex const i) {
- assert(0 == m_wares.get_nrwareids());
+ assert(0 == wares_.get_nrwareids());
- m_wares.set_nrwares(i);
+ wares_.set_nrwares(i);
}
void WarehouseSupply::set_nrworkers(DescriptionIndex const i) {
- assert(0 == m_workers.get_nrwareids());
+ assert(0 == workers_.get_nrwareids());
- m_workers.set_nrwares(i);
+ workers_.set_nrwares(i);
}
/// Add and remove our wares and the Supply to the economies as necessary.
void WarehouseSupply::set_economy(Economy * const e)
{
- if (e == m_economy)
+ if (e == economy_)
return;
- if (m_economy) {
- m_economy->remove_supply(*this);
- for (DescriptionIndex i = 0; i < m_wares.get_nrwareids(); ++i)
- if (m_wares.stock(i))
- m_economy->remove_wares(i, m_wares.stock(i));
- for (DescriptionIndex i = 0; i < m_workers.get_nrwareids(); ++i)
- if (m_workers.stock(i))
- m_economy->remove_workers(i, m_workers.stock(i));
+ if (economy_) {
+ economy_->remove_supply(*this);
+ for (DescriptionIndex i = 0; i < wares_.get_nrwareids(); ++i)
+ if (wares_.stock(i))
+ economy_->remove_wares(i, wares_.stock(i));
+ for (DescriptionIndex i = 0; i < workers_.get_nrwareids(); ++i)
+ if (workers_.stock(i))
+ economy_->remove_workers(i, workers_.stock(i));
}
- m_economy = e;
+ economy_ = e;
- if (m_economy) {
- for (DescriptionIndex i = 0; i < m_wares.get_nrwareids(); ++i)
- if (m_wares.stock(i))
- m_economy->add_wares(i, m_wares.stock(i));
- for (DescriptionIndex i = 0; i < m_workers.get_nrwareids(); ++i)
- if (m_workers.stock(i))
- m_economy->add_workers(i, m_workers.stock(i));
- m_economy->add_supply(*this);
+ if (economy_) {
+ for (DescriptionIndex i = 0; i < wares_.get_nrwareids(); ++i)
+ if (wares_.stock(i))
+ economy_->add_wares(i, wares_.stock(i));
+ for (DescriptionIndex i = 0; i < workers_.get_nrwareids(); ++i)
+ if (workers_.stock(i))
+ economy_->add_workers(i, workers_.stock(i));
+ economy_->add_supply(*this);
}
}
@@ -133,9 +133,9 @@
if (!count)
return;
- if (m_economy) // No economies in the editor
- m_economy->add_wares(id, count);
- m_wares.add(id, count);
+ if (economy_) // No economies in the editor
+ economy_->add_wares(id, count);
+ wares_.add(id, count);
}
@@ -145,9 +145,9 @@
if (!count)
return;
- m_wares.remove(id, count);
- if (m_economy) // No economies in the editor
- m_economy->remove_wares(id, count);
+ wares_.remove(id, count);
+ if (economy_) // No economies in the editor
+ economy_->remove_wares(id, count);
}
@@ -157,9 +157,9 @@
if (!count)
return;
- if (m_economy) // No economies in the editor
- m_economy->add_workers(id, count);
- m_workers.add(id, count);
+ if (economy_) // No economies in the editor
+ economy_->add_workers(id, count);
+ workers_.add(id, count);
}
@@ -172,13 +172,13 @@
if (!count)
return;
- m_workers.remove(id, count);
- if (m_economy) // No economies in the editor
- m_economy->remove_workers(id, count);
+ workers_.remove(id, count);
+ if (economy_) // No economies in the editor
+ economy_->remove_workers(id, count);
}
/// Return the position of the Supply, i.e. the owning Warehouse.
-PlayerImmovable * WarehouseSupply::get_position(Game &) {return m_warehouse;}
+PlayerImmovable * WarehouseSupply::get_position(Game &) {return warehouse_;}
/// Warehouse supplies are never active.
@@ -206,12 +206,12 @@
{
if (req.get_type() == wwWORKER)
return
- m_warehouse->count_workers
+ warehouse_->count_workers
(game, req.get_index(), req.get_requirements());
// Calculate how many wares can be sent out - it might be that we need them
// ourselves. E.g. for hiring new soldiers.
- int32_t const x = m_wares.stock(req.get_index());
+ int32_t const x = wares_.stock(req.get_index());
// only mark an ware of that type as available, if the priority of the
// request + number of that wares in warehouse is > priority of request
// of *this* warehouse + 1 (+1 is important, as else the ware would directly
@@ -219,7 +219,7 @@
// highered and would have the same value as the original request)
int32_t const y =
x + (req.get_priority(0) / 100)
- - (m_warehouse->get_priority(wwWARE, req.get_index()) / 100) - 1;
+ - (warehouse_->get_priority(wwWARE, req.get_index()) / 100) - 1;
// But the number should never be higher than the number of wares available
if (y > x)
return x;
@@ -231,17 +231,17 @@
WareInstance & WarehouseSupply::launch_ware(Game & game, const Request & req) {
if (req.get_type() != wwWARE)
throw wexception("WarehouseSupply::launch_ware: called for non-ware request");
- if (!m_wares.stock(req.get_index()))
+ if (!wares_.stock(req.get_index()))
throw wexception("WarehouseSupply::launch_ware: called for non-existing ware");
- return m_warehouse->launch_ware(game, req.get_index());
+ return warehouse_->launch_ware(game, req.get_index());
}
/// Launch a ware as worker.
Worker & WarehouseSupply::launch_worker(Game & game, const Request & req)
{
return
- m_warehouse->launch_worker
+ warehouse_->launch_worker
(game, req.get_index(), req.get_requirements());
}
@@ -275,10 +275,10 @@
Building(warehouse_descr),
m_supply(new WarehouseSupply(this)),
m_next_military_act(0),
- m_portdock(nullptr)
+ portdock_(nullptr)
{
m_next_stock_remove_act = 0;
- m_cleanup_in_progress = false;
+ cleanup_in_progress_ = false;
}
@@ -487,7 +487,7 @@
if (descr().get_isport()) {
init_portdock(egbase);
- PortDock* pd = m_portdock;
+ PortDock* pd = portdock_;
// should help diagnose problems with marine
if (!pd->get_fleet()) {
log(" Warning: portdock without a fleet created (%3dx%3d)\n",
@@ -497,7 +497,7 @@
}
//this is default
- m_cleanup_in_progress = false;
+ cleanup_in_progress_ = false;
}
@@ -533,20 +533,20 @@
molog("Found %" PRIuS " fields for the dock\n", dock.size());
- m_portdock = new PortDock(this);
- m_portdock->set_owner(get_owner());
- m_portdock->set_economy(get_economy());
+ portdock_ = new PortDock(this);
+ portdock_->set_owner(get_owner());
+ portdock_->set_economy(get_economy());
for (const Coords& coords : dock) {
- m_portdock->add_position(coords);
+ portdock_->add_position(coords);
}
- m_portdock->init(egbase);
+ portdock_->init(egbase);
if (get_economy() != nullptr)
- m_portdock->set_economy(get_economy());
+ portdock_->set_economy(get_economy());
// this is just to indicate something wrong is going on
//(tiborb)
- PortDock* pd_tmp = m_portdock;
+ PortDock* pd_tmp = portdock_;
if (!pd_tmp->get_fleet()) {
log (" portdock for port at %3dx%3d created but without a fleet!\n",
get_position().x,
@@ -563,14 +563,14 @@
// if the port still exists and we are in game we first try to restore the portdock
void Warehouse::restore_portdock_or_destroy(EditorGameBase& egbase) {
Warehouse::init_portdock(egbase);
- if (!m_portdock) {
+ if (!portdock_) {
log(" Portdock could not be restored, removing the port now (coords: %3dx%3d)\n",
get_position().x,
get_position().y);
Building::destroy(egbase);
} else {
molog ("Message: portdock restored\n");
- PortDock* pd_tmp = m_portdock;
+ PortDock* pd_tmp = portdock_;
if (!pd_tmp->get_fleet()) {
log (" Portdock restored but without a fleet!\n");
}
@@ -583,14 +583,14 @@
// if this is a port, it will remove also portdock.
// But portdock must know that it should not try to recreate itself
- m_cleanup_in_progress = true;
+ cleanup_in_progress_ = true;
- if (egbase.objects().object_still_available(m_portdock)) {
- m_portdock->remove(egbase);
+ if (egbase.objects().object_still_available(portdock_)) {
+ portdock_->remove(egbase);
}
- if (!egbase.objects().object_still_available(m_portdock)) {
- m_portdock = nullptr;
+ if (!egbase.objects().object_still_available(portdock_)) {
+ portdock_ = nullptr;
}
// This will empty the stock and launch all workers including incorporated
@@ -740,8 +740,8 @@
if (old)
old->remove_warehouse(*this);
- if (m_portdock)
- m_portdock->set_economy(e);
+ if (portdock_)
+ portdock_->set_economy(e);
m_supply->set_economy(e);
Building::set_economy(e);
@@ -751,8 +751,8 @@
}
}
- if (m_portdock)
- m_portdock->set_economy(e);
+ if (portdock_)
+ portdock_->set_economy(e);
if (e)
e->add_warehouse(*this);
@@ -1426,10 +1426,10 @@
}
WaresQueue& Warehouse::waresqueue(DescriptionIndex index) {
- assert(m_portdock != nullptr);
- assert(m_portdock->expedition_bootstrap() != nullptr);
+ assert(portdock_ != nullptr);
+ assert(portdock_->expedition_bootstrap() != nullptr);
- return m_portdock->expedition_bootstrap()->waresqueue(index);
+ return portdock_->expedition_bootstrap()->waresqueue(index);
}
/*
@@ -1482,7 +1482,7 @@
Building::log_general_info(egbase);
if (descr().get_isport()){
- PortDock* pd_tmp = m_portdock;
+ PortDock* pd_tmp = portdock_;
if (pd_tmp){
molog("Port dock: %u\n", pd_tmp->serial());
molog("port needs ship: %s\n", (pd_tmp->get_need_ship())?"true":"false");
=== modified file 'src/logic/map_objects/tribes/warehouse.h'
--- src/logic/map_objects/tribes/warehouse.h 2016-01-31 15:31:00 +0000
+++ src/logic/map_objects/tribes/warehouse.h 2016-02-07 07:48:48 +0000
@@ -213,7 +213,7 @@
void set_worker_policy(DescriptionIndex ware, StockPolicy policy);
// Get the portdock if this is a port.
- PortDock * get_portdock() const {return m_portdock;}
+ PortDock * get_portdock() const {return portdock_;}
// Returns the waresqueue of the expedition if this is a port.
// Will throw an exception otherwise.
@@ -271,11 +271,11 @@
std::vector<PlannedWorkers> m_planned_workers;
- PortDock * m_portdock;
+ PortDock * portdock_;
//this is information for portdock,to know whether it should
//try to recreate itself
- bool m_cleanup_in_progress;
+ bool cleanup_in_progress_;
};
=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc 2016-01-18 19:35:25 +0000
+++ src/map_io/map_buildingdata_packet.cc 2016-02-07 07:48:48 +0000
@@ -460,13 +460,13 @@
if (warehouse.descr().get_isport()) {
if (Serial portdock = fr.unsigned_32()) {
- warehouse.m_portdock = &mol.get<PortDock>(portdock);
- warehouse.m_portdock->set_economy(warehouse.get_economy());
+ warehouse.portdock_ = &mol.get<PortDock>(portdock);
+ warehouse.portdock_->set_economy(warehouse.get_economy());
// Expedition specific stuff. This is done in this packet
// because the "new style" loader is not supported and
// doesn't lend itself to request and other stuff.
- if (warehouse.m_portdock->expedition_started()) {
- warehouse.m_portdock->expedition_bootstrap()->load(warehouse, fr, game, mol);
+ if (warehouse.portdock_->expedition_started()) {
+ warehouse.portdock_->expedition_bootstrap()->load(warehouse, fr, game, mol);
}
}
}
@@ -1116,11 +1116,11 @@
fw.unsigned_32(warehouse.m_next_stock_remove_act);
if (warehouse.descr().get_isport()) {
- fw.unsigned_32(mos.get_object_file_index_or_zero(warehouse.m_portdock));
+ fw.unsigned_32(mos.get_object_file_index_or_zero(warehouse.portdock_));
// Expedition specific stuff. See comment in loader.
- if (warehouse.m_portdock->expedition_started()) {
- warehouse.m_portdock->expedition_bootstrap()->save(fw, game, mos);
+ if (warehouse.portdock_->expedition_started()) {
+ warehouse.portdock_->expedition_bootstrap()->save(fw, game, mos);
}
}
}
=== modified file 'src/map_io/map_flagdata_packet.cc'
--- src/map_io/map_flagdata_packet.cc 2015-11-28 22:29:26 +0000
+++ src/map_io/map_flagdata_packet.cc 2016-02-07 07:48:48 +0000
@@ -38,7 +38,7 @@
namespace Widelands {
-constexpr uint16_t kCurrentPacketVersion = 4;
+constexpr uint16_t kCurrentPacketVersion = 5;
void MapFlagdataPacket::read
(FileSystem & fs,
@@ -63,39 +63,33 @@
// Owner is already set, nothing to do from PlayerImmovable.
- flag.m_animstart = fr.unsigned_16();
+ flag.animstart_ = fr.unsigned_16();
{
- FCoords building_position = map.get_fcoords(flag.m_position);
+ FCoords building_position = map.get_fcoords(flag.position_);
map.get_tln(building_position, &building_position);
- flag.m_building =
+ flag.building_ =
dynamic_cast<Building *>
(building_position.field->get_immovable());
}
// Roads are set somewhere else.
-
- // Compatibility stuff: Read 6 bytes of attic stuff
- // that is no longer used (was m_wares_pending)
- for (uint32_t i = 0; i < 6; ++i)
- fr.unsigned_32();
-
- flag.m_ware_capacity = fr.unsigned_32();
+ flag.ware_capacity_ = fr.unsigned_32();
{
uint32_t const wares_filled = fr.unsigned_32();
- flag.m_ware_filled = wares_filled;
+ flag.ware_filled_ = wares_filled;
for (uint32_t i = 0; i < wares_filled; ++i) {
- flag.m_wares[i].pending = fr.unsigned_8();
- flag.m_wares[i].priority = fr.signed_32();
+ flag.wares_[i].pending = fr.unsigned_8();
+ flag.wares_[i].priority = fr.signed_32();
uint32_t const ware_serial = fr.unsigned_32();
try {
- flag.m_wares[i].ware =
+ flag.wares_[i].ware =
&mol.get<WareInstance>(ware_serial);
if (uint32_t const nextstep_serial = fr.unsigned_32()) {
try {
- flag.m_wares[i].nextstep =
+ flag.wares_[i].nextstep =
&mol.get<PlayerImmovable>(nextstep_serial);
} catch (const WException & e) {
throw GameDataError
@@ -103,7 +97,7 @@
nextstep_serial, e.what());
}
} else
- flag.m_wares[i].nextstep = nullptr;
+ flag.wares_[i].nextstep = nullptr;
} catch (const WException & e) {
throw GameDataError
("ware #%u (%u): %s", i, ware_serial, e.what());
@@ -112,7 +106,7 @@
if (uint32_t const always_call_serial = fr.unsigned_32()) {
try {
- flag.m_always_call_for_flag =
+ flag.always_call_for_flag_ =
&mol.get<Flag>(always_call_serial);
} catch (const WException & e) {
throw GameDataError
@@ -120,7 +114,7 @@
always_call_serial, e.what());
}
} else
- flag.m_always_call_for_flag = nullptr;
+ flag.always_call_for_flag_ = nullptr;
// workers waiting
uint16_t const nr_workers = fr.unsigned_16();
@@ -131,7 +125,7 @@
// waitforcapacity task for this flag is in
// Flag::load_finish, which is called after the worker
// (with his stack of tasks) has been fully loaded.
- flag.m_capacity_wait.push_back
+ flag.capacity_wait_.push_back
(&mol.get<Worker>(worker_serial));
} catch (const WException & e) {
throw GameDataError
@@ -141,7 +135,7 @@
// flag jobs
uint16_t const nr_jobs = fr.unsigned_16();
- assert(flag.m_flag_jobs.empty());
+ assert(flag.flag_jobs_.empty());
for (uint16_t i = 0; i < nr_jobs; ++i) {
Flag::FlagJob f;
if (fr.unsigned_8()) {
@@ -157,7 +151,7 @@
f.request = nullptr;
}
f.program = fr.c_string();
- flag.m_flag_jobs.push_back(f);
+ flag.flag_jobs_.push_back(f);
}
mol.mark_object_as_loaded(flag);
@@ -195,33 +189,28 @@
// Owner is already written in the existanz packet.
// Animation is set by creator.
- fw.unsigned_16(flag->m_animstart);
+ fw.unsigned_16(flag->animstart_);
// Roads are not saved, they are set on load.
- // Compatibility stuff: Write 6 bytes of attic stuff that is
- // no longer used (was m_wares_pending)
- for (uint32_t i = 0; i < 6; ++i)
- fw.unsigned_32(0);
-
- fw.unsigned_32(flag->m_ware_capacity);
-
- fw.unsigned_32(flag->m_ware_filled);
-
- for (int32_t i = 0; i < flag->m_ware_filled; ++i) {
- fw.unsigned_8(flag->m_wares[i].pending);
- fw.signed_32(flag->m_wares[i].priority);
- assert(mos.is_object_known(*flag->m_wares[i].ware));
- fw.unsigned_32(mos.get_object_file_index(*flag->m_wares[i].ware));
+ fw.unsigned_32(flag->ware_capacity_);
+
+ fw.unsigned_32(flag->ware_filled_);
+
+ for (int32_t i = 0; i < flag->ware_filled_; ++i) {
+ fw.unsigned_8(flag->wares_[i].pending);
+ fw.signed_32(flag->wares_[i].priority);
+ assert(mos.is_object_known(*flag->wares_[i].ware));
+ fw.unsigned_32(mos.get_object_file_index(*flag->wares_[i].ware));
if
(PlayerImmovable const * const nextstep =
- flag->m_wares[i].nextstep.get(egbase))
+ flag->wares_[i].nextstep.get(egbase))
fw.unsigned_32(mos.get_object_file_index(*nextstep));
else
fw.unsigned_32(0);
}
- if (Flag const * const always_call_for = flag->m_always_call_for_flag)
+ if (Flag const * const always_call_for = flag->always_call_for_flag_)
{
assert(mos.is_object_known(*always_call_for));
fw.unsigned_32(mos.get_object_file_index(*always_call_for));
@@ -230,7 +219,7 @@
// worker waiting for capacity
const Flag::CapacityWaitQueue & capacity_wait =
- flag->m_capacity_wait;
+ flag->capacity_wait_;
fw.unsigned_16(capacity_wait.size());
for (const OPtr<Worker >& temp_worker : capacity_wait) {
Worker const * const obj = temp_worker.get(egbase);
@@ -245,7 +234,7 @@
assert(mos.is_object_known(*obj));
fw.unsigned_32(mos.get_object_file_index(*obj));
}
- const Flag::FlagJobs & flag_jobs = flag->m_flag_jobs;
+ const Flag::FlagJobs & flag_jobs = flag->flag_jobs_;
fw.unsigned_16(flag_jobs.size());
for (const Flag::FlagJob& temp_job : flag_jobs) {
=== modified file 'src/map_io/map_roaddata_packet.cc'
--- src/map_io/map_roaddata_packet.cc 2015-11-28 22:29:26 +0000
+++ src/map_io/map_roaddata_packet.cc 2016-02-07 07:48:48 +0000
@@ -72,13 +72,13 @@
Player & plr = egbase.player(player_index);
road.set_owner(&plr);
- road.m_busyness = fr.unsigned_32();
- road.m_busyness_last_update = fr.unsigned_32();
- road.m_type = fr.unsigned_32();
+ road.busyness_ = fr.unsigned_32();
+ road.busyness_last_update_ = fr.unsigned_32();
+ road.type_ = fr.unsigned_32();
{
uint32_t const flag_0_serial = fr.unsigned_32();
try {
- road.m_flags[0] = &mol.get<Flag>(flag_0_serial);
+ road.flags_[0] = &mol.get<Flag>(flag_0_serial);
} catch (const WException & e) {
throw GameDataError
("flag 0 (%u): %s", flag_0_serial, e.what());
@@ -87,21 +87,21 @@
{
uint32_t const flag_1_serial = fr.unsigned_32();
try {
- road.m_flags[1] = &mol.get<Flag>(flag_1_serial);
+ road.flags_[1] = &mol.get<Flag>(flag_1_serial);
} catch (const WException & e) {
throw GameDataError
("flag 1 (%u): %s", flag_1_serial, e.what());
}
}
- road.m_flagidx[0] = fr.unsigned_32();
- road.m_flagidx[1] = fr.unsigned_32();
+ road.flagidx_[0] = fr.unsigned_32();
+ road.flagidx_[1] = fr.unsigned_32();
- road.m_cost[0] = fr.unsigned_32();
- road.m_cost[1] = fr.unsigned_32();
+ road.cost_[0] = fr.unsigned_32();
+ road.cost_[1] = fr.unsigned_32();
Path::StepVector::size_type const nr_steps = fr.unsigned_16();
if (!nr_steps)
throw GameDataError("nr_steps = 0");
- Path p(road.m_flags[0]->get_position());
+ Path p(road.flags_[0]->get_position());
for (Path::StepVector::size_type i = nr_steps; i; --i)
try {
p.append(egbase.map(), read_direction_8(&fr));
@@ -117,7 +117,7 @@
// overwrite the initialization values.
road._link_into_flags(game);
- road.m_idle_index = fr.unsigned_32();
+ road.idle_index_ = fr.unsigned_32();
uint32_t const count = fr.unsigned_32();
if (!count)
@@ -152,15 +152,15 @@
uint8_t const carrier_type = fr.unsigned_32();
if
- (i < road.m_carrier_slots.size() &&
- road.m_carrier_slots[i].carrier_type == carrier_type)
+ (i < road.carrier_slots_.size() &&
+ road.carrier_slots_[i].carrier_type == carrier_type)
{
- assert(!road.m_carrier_slots[i].carrier.get(egbase));
+ assert(!road.carrier_slots_[i].carrier.get(egbase));
- road.m_carrier_slots[i].carrier = carrier;
+ road.carrier_slots_[i].carrier = carrier;
if (carrier || carrier_request) {
- delete road.m_carrier_slots[i].carrier_request;
- road.m_carrier_slots[i].carrier_request =
+ delete road.carrier_slots_[i].carrier_request;
+ road.carrier_slots_[i].carrier_request =
carrier_request;
}
} else {
@@ -205,35 +205,35 @@
// Theres only the owner
fw.unsigned_8(r->owner().player_number());
- fw.unsigned_32(r->m_busyness);
- fw.unsigned_32(r->m_busyness_last_update);
+ fw.unsigned_32(r->busyness_);
+ fw.unsigned_32(r->busyness_last_update_);
- fw.unsigned_32(r->m_type);
+ fw.unsigned_32(r->type_);
// serial of flags
- assert(mos.is_object_known(*r->m_flags[0]));
- assert(mos.is_object_known(*r->m_flags[1]));
- fw.unsigned_32(mos.get_object_file_index(*r->m_flags[0]));
- fw.unsigned_32(mos.get_object_file_index(*r->m_flags[1]));
-
- fw.unsigned_32(r->m_flagidx[0]);
- fw.unsigned_32(r->m_flagidx[1]);
-
- fw.unsigned_32(r->m_cost[0]);
- fw.unsigned_32(r->m_cost[1]);
-
- const Path & path = r->m_path;
+ assert(mos.is_object_known(*r->flags_[0]));
+ assert(mos.is_object_known(*r->flags_[1]));
+ fw.unsigned_32(mos.get_object_file_index(*r->flags_[0]));
+ fw.unsigned_32(mos.get_object_file_index(*r->flags_[1]));
+
+ fw.unsigned_32(r->flagidx_[0]);
+ fw.unsigned_32(r->flagidx_[1]);
+
+ fw.unsigned_32(r->cost_[0]);
+ fw.unsigned_32(r->cost_[1]);
+
+ const Path & path = r->path_;
const Path::StepVector::size_type nr_steps = path.get_nsteps();
fw.unsigned_16(nr_steps);
for (Path::StepVector::size_type i = 0; i < nr_steps; ++i)
fw.unsigned_8(path[i]);
- fw.unsigned_32(r->m_idle_index); // TODO(unknown): do not save this
-
-
- fw.unsigned_32(r->m_carrier_slots.size());
-
- for (const Road::CarrierSlot& temp_slot : r->m_carrier_slots) {
+ fw.unsigned_32(r->idle_index_); // TODO(unknown): do not save this
+
+
+ fw.unsigned_32(r->carrier_slots_.size());
+
+ for (const Road::CarrierSlot& temp_slot : r->carrier_slots_) {
if
(Carrier const * const carrier =
temp_slot.carrier.get(egbase)) {
=== modified file 'src/wui/transport_draw.cc'
--- src/wui/transport_draw.cc 2016-01-24 20:11:53 +0000
+++ src/wui/transport_draw.cc 2016-02-07 07:48:48 +0000
@@ -42,17 +42,16 @@
const RGBColor& player_color = owner().get_playercolor();
dst.blit_animation(
- pos, owner().tribe().flag_animation(), game.get_gametime() - m_animstart, player_color);
+ pos, owner().tribe().flag_animation(), game.get_gametime() - animstart_, player_color);
- const uint32_t ware_filled = m_ware_filled;
- for (uint32_t i = 0; i < ware_filled; ++i) { // draw wares
+ for (int32_t i = 0; i < ware_filled_; ++i) { // draw wares
Point warepos = pos;
if (i < 8) {
warepos.x += ware_offsets[i].x;
warepos.y += ware_offsets[i].y;
} else
warepos.y -= 6 + (i - 8) * 3;
- dst.blit_animation(warepos, m_wares[i].ware->descr().get_animation("idle"), 0, player_color);
+ dst.blit_animation(warepos, wares_[i].ware->descr().get_animation("idle"), 0, player_color);
}
}
=== modified file 'src/wui/transport_ui.cc'
--- src/wui/transport_ui.cc 2016-01-29 08:37:22 +0000
+++ src/wui/transport_ui.cc 2016-02-07 07:48:48 +0000
@@ -286,8 +286,8 @@
// users can register for change updates. The registry should be
// moved to InteractivePlayer or some other UI component.
void Economy::show_options_window() {
- if (m_optionswindow_registry.window) {
- m_optionswindow_registry.window->move_to_top();
+ if (optionswindow_registry_.window) {
+ optionswindow_registry_.window->move_to_top();
} else {
new EconomyOptionsWindow(dynamic_cast<InteractiveGameBase&>
(*owner().egbase().get_ibase()), *this);
Follow ups