widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #06189
[Merge] lp:~widelands-dev/widelands/bug-1395278-logic1 into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1395278-logic1 into lp:widelands.
Commit message:
Started refactoring member variable names in src/logic.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1395278 in widelands: "Consolidate naming of member variables"
https://bugs.launchpad.net/widelands/+bug/1395278
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1395278-logic1/+merge/286178
This is already quite big, so I have split the logic dir up into 3 branches - this is the first one.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1395278-logic1 into lp:widelands.
=== modified file 'src/game_io/game_cmd_queue_packet.cc'
--- src/game_io/game_cmd_queue_packet.cc 2015-11-29 10:10:29 +0000
+++ src/game_io/game_cmd_queue_packet.cc 2016-02-16 14:25:27 +0000
@@ -44,7 +44,7 @@
// nothing to be done for m_game
// Next serial
- cmdq.nextserial = fr.unsigned_32();
+ cmdq.nextserial_ = fr.unsigned_32();
// Erase all currently pending commands in the queue
cmdq.flush();
@@ -65,8 +65,8 @@
item.cmd = &cmd;
- cmdq.m_cmds[cmd.duetime() % kCommandQueueBucketSize].push(item);
- ++ cmdq.m_ncmds;
+ cmdq.cmds_[cmd.duetime() % kCommandQueueBucketSize].push(item);
+ ++ cmdq.ncmds_;
}
} else {
throw UnhandledVersionError("GameCmdQueuePacket", packet_version, kCurrentPacketVersion);
@@ -89,7 +89,7 @@
// nothing to be done for m_game
// Next serial
- fw.unsigned_32(cmdq.nextserial);
+ fw.unsigned_32(cmdq.nextserial_);
// Write all commands
@@ -97,9 +97,9 @@
uint32_t time = game.get_gametime();
size_t nhandled = 0;
- while (nhandled < cmdq.m_ncmds) {
+ while (nhandled < cmdq.ncmds_) {
// Make a copy, so we can pop stuff
- std::priority_queue<CmdQueue::CmdItem> p = cmdq.m_cmds[time % kCommandQueueBucketSize];
+ std::priority_queue<CmdQueue::CmdItem> p = cmdq.cmds_[time % kCommandQueueBucketSize];
while (!p.empty()) {
const CmdQueue::CmdItem & it = p.top();
=== modified file 'src/logic/cmd_luacoroutine.cc'
--- src/logic/cmd_luacoroutine.cc 2016-01-28 05:24:34 +0000
+++ src/logic/cmd_luacoroutine.cc 2016-02-16 14:25:27 +0000
@@ -34,14 +34,14 @@
void CmdLuaCoroutine::execute (Game & game) {
try {
- int rv = m_cr->resume();
- const uint32_t sleeptime = m_cr->pop_uint32();
+ int rv = cr_->resume();
+ const uint32_t sleeptime = cr_->pop_uint32();
if (rv == LuaCoroutine::YIELDED) {
- game.enqueue_command(new Widelands::CmdLuaCoroutine(sleeptime, m_cr));
- m_cr = nullptr; // Remove our ownership so we don't delete.
+ game.enqueue_command(new Widelands::CmdLuaCoroutine(sleeptime, cr_));
+ cr_ = nullptr; // Remove our ownership so we don't delete.
} else if (rv == LuaCoroutine::DONE) {
- delete m_cr;
- m_cr = nullptr;
+ delete cr_;
+ cr_ = nullptr;
}
} catch (LuaError & e) {
log("Error in Lua Coroutine\n");
@@ -75,7 +75,7 @@
upcast(LuaGameInterface, lgi, &egbase.lua());
assert(lgi); // If this is not true, this is not a game.
- m_cr = lgi->read_coroutine(fr);
+ cr_ = lgi->read_coroutine(fr);
} else {
throw UnhandledVersionError("CmdLuaCoroutine", packet_version, kCurrentPacketVersion);
}
@@ -94,7 +94,7 @@
upcast(LuaGameInterface, lgi, &egbase.lua());
assert(lgi); // If this is not true, this is not a game.
- lgi->write_coroutine(fw, m_cr);
+ lgi->write_coroutine(fw, cr_);
}
}
=== modified file 'src/logic/cmd_luacoroutine.h'
--- src/logic/cmd_luacoroutine.h 2016-02-09 16:29:48 +0000
+++ src/logic/cmd_luacoroutine.h 2016-02-16 14:25:27 +0000
@@ -28,12 +28,12 @@
namespace Widelands {
struct CmdLuaCoroutine : public GameLogicCommand {
- CmdLuaCoroutine() : GameLogicCommand(0), m_cr(nullptr) {} // For savegame loading
+ CmdLuaCoroutine() : GameLogicCommand(0), cr_(nullptr) {} // For savegame loading
CmdLuaCoroutine(uint32_t const init_duetime, LuaCoroutine * const cr) :
- GameLogicCommand(init_duetime), m_cr(cr) {}
+ GameLogicCommand(init_duetime), cr_(cr) {}
~CmdLuaCoroutine() {
- delete m_cr;
+ delete cr_;
}
// Write these commands to a file (for savegames)
@@ -45,7 +45,7 @@
void execute(Game &) override;
private:
- LuaCoroutine * m_cr;
+ LuaCoroutine * cr_;
};
}
=== modified file 'src/logic/cmd_queue.cc'
--- src/logic/cmd_queue.cc 2015-12-04 18:27:36 +0000
+++ src/logic/cmd_queue.cc 2016-02-16 14:25:27 +0000
@@ -37,10 +37,10 @@
// class Cmd_Queue
//
CmdQueue::CmdQueue(Game & game) :
- m_game(game),
- nextserial(0),
- m_ncmds(0),
- m_cmds(kCommandQueueBucketSize, std::priority_queue<CmdItem>()) {}
+ game_(game),
+ nextserial_(0),
+ ncmds_(0),
+ cmds_(kCommandQueueBucketSize, std::priority_queue<CmdItem>()) {}
CmdQueue::~CmdQueue()
{
@@ -55,18 +55,18 @@
// Note: Order of destruction of Items is not guaranteed
void CmdQueue::flush() {
uint32_t cbucket = 0;
- while (m_ncmds && cbucket < kCommandQueueBucketSize) {
- std::priority_queue<CmdItem> & current_cmds = m_cmds[cbucket];
+ while (ncmds_ && cbucket < kCommandQueueBucketSize) {
+ std::priority_queue<CmdItem> & current_cmds = cmds_[cbucket];
while (!current_cmds.empty()) {
Command * cmd = current_cmds.top().cmd;
current_cmds.pop();
delete cmd;
- --m_ncmds;
+ --ncmds_;
}
++ cbucket;
}
- assert(m_ncmds == 0);
+ assert(ncmds_ == 0);
}
/*
@@ -84,7 +84,7 @@
ci.serial = plcmd->cmdserial();
} else if (dynamic_cast<GameLogicCommand *>(cmd)) {
ci.category = cat_gamelogic;
- ci.serial = nextserial++;
+ ci.serial = nextserial_++;
} else {
// the order of non-gamelogic commands matters only with respect to
// gamelogic commands; the order of non-gamelogic commands wrt other
@@ -94,15 +94,15 @@
ci.serial = 0;
}
- m_cmds[cmd->duetime() % kCommandQueueBucketSize].push(ci);
- ++ m_ncmds;
+ cmds_[cmd->duetime() % kCommandQueueBucketSize].push(ci);
+ ++ ncmds_;
}
void CmdQueue::run_queue(int32_t const interval, uint32_t & game_time_var) {
uint32_t const final = game_time_var + interval;
while (game_time_var < final) {
- std::priority_queue<CmdItem> & current_cmds = m_cmds[game_time_var % kCommandQueueBucketSize];
+ std::priority_queue<CmdItem> & current_cmds = cmds_[game_time_var % kCommandQueueBucketSize];
while (!current_cmds.empty()) {
Command & c = *current_cmds.top().cmd;
@@ -110,18 +110,18 @@
break;
current_cmds.pop();
- -- m_ncmds;
+ -- ncmds_;
assert(game_time_var == c.duetime());
if (dynamic_cast<GameLogicCommand *>(&c)) {
- StreamWrite & ss = m_game.syncstream();
+ StreamWrite & ss = game_.syncstream();
static uint8_t const tag[] = {0xde, 0xad, 0x00};
ss.data(tag, 3); // provide an easy-to-find pattern as debugging aid
ss.unsigned_32(c.duetime());
ss.unsigned_32(static_cast<uint32_t>(c.id()));
}
- c.execute (m_game);
+ c.execute (game_);
delete &c;
}
=== modified file 'src/logic/cmd_queue.h'
--- src/logic/cmd_queue.h 2016-02-09 16:29:48 +0000
+++ src/logic/cmd_queue.h 2016-02-16 14:25:27 +0000
@@ -70,17 +70,17 @@
* the same for all parallel simulation.
*/
struct Command {
- Command (const uint32_t init_duetime) : m_duetime(init_duetime) {}
+ Command (const uint32_t init_duetime) : duetime_(init_duetime) {}
virtual ~Command ();
virtual void execute (Game &) = 0;
virtual QueueCommandTypes id() const = 0;
- uint32_t duetime() const {return m_duetime;}
- void set_duetime(uint32_t const t) {m_duetime = t;}
+ uint32_t duetime() const {return duetime_;}
+ void set_duetime(uint32_t const t) {duetime_ = t;}
private:
- uint32_t m_duetime;
+ uint32_t duetime_;
};
@@ -148,11 +148,11 @@
void flush(); // delete all commands in the queue now
private:
- Game & m_game;
- uint32_t nextserial;
- uint32_t m_ncmds;
+ Game& game_;
+ uint32_t nextserial_;
+ uint32_t ncmds_;
using CommandsContainer = std::vector<std::priority_queue<CmdItem>>;
- CommandsContainer m_cmds;
+ CommandsContainer cmds_;
};
}
=== modified file 'src/logic/field.h'
--- src/logic/field.h 2016-01-24 11:11:54 +0000
+++ src/logic/field.h 2016-02-16 14:25:27 +0000
@@ -82,53 +82,6 @@
struct ResourceAmounts {ResourceAmount d : 4, r : 4;};
static_assert(sizeof(ResourceAmounts) == 1, "assert(sizeof(ResourceAmounts) == 1) failed.");
-private:
- /**
- * A field can be selected in one of 2 selections. This allows the user to
- * use selection tools to select a set of fields and then perform a command
- * on those fields.
- *
- * Selections can be edited with some operations. A selection can be
- * 1. inverted,
- * 2. unioned with the other selection,
- * 3. intersected with the other selection or
- * 4. differenced with the other selection.
- *
- * Each field can be owned by a player.
- * The 2 highest bits are selected_a and selected_b.
- * The next highest bit is the border bit.
- * The low bits are the player number of the owner.
- */
- using OwnerInfoAndSelectionsType = PlayerNumber;
- static const uint8_t Border_Bit =
- std::numeric_limits<OwnerInfoAndSelectionsType>::digits - 1;
- static const OwnerInfoAndSelectionsType Border_Bitmask = 1 << Border_Bit;
- static const OwnerInfoAndSelectionsType Player_Number_Bitmask =
- Border_Bitmask - 1;
- static const OwnerInfoAndSelectionsType Owner_Info_Bitmask =
- Player_Number_Bitmask + Border_Bitmask;
- static_assert(MAX_PLAYERS <= Player_Number_Bitmask, "Bitmask is too big.");
-
- // Data Members
- /** linked list, \sa Bob::m_linknext*/
- Bob * bobs;
- BaseImmovable * immovable;
-
- uint8_t caps : 7;
- uint8_t roads : 6;
-
- Height height;
- int8_t brightness;
-
- OwnerInfoAndSelectionsType owner_info_and_selections;
-
- DescriptionIndex m_resources; ///< Resource type on this field, if any
- uint8_t m_initial_res_amount; ///< Initial amount of m_resources
- uint8_t m_res_amount; ///< Current amount of m_resources
-
- Terrains terrains;
-
-public:
Height get_height() const {return height;}
NodeCaps nodecaps() const {return static_cast<NodeCaps>(caps);}
uint16_t get_caps() const {return caps;}
@@ -203,10 +156,10 @@
// Resources can be set through Map::set_resources()
// TODO(unknown): This should return DescriptionIndex
- uint8_t get_resources() const {return m_resources;}
- uint8_t get_resources_amount() const {return m_res_amount;}
+ uint8_t get_resources() const {return resources;}
+ uint8_t get_resources_amount() const {return res_amount;}
// TODO(unknown): This should return uint8_t
- int32_t get_initial_res_amount() const {return m_initial_res_amount;}
+ int32_t get_initial_res_amount() const {return initial_res_amount;}
/// \note you must reset this field's + neighbor's brightness when you
/// change the height. Map::change_height does this. This function is not
@@ -217,6 +170,52 @@
static_cast<int8_t>(h) < 0 ? 0 :
MAX_FIELD_HEIGHT < h ? MAX_FIELD_HEIGHT : h;
}
+
+private:
+ /**
+ * A field can be selected in one of 2 selections. This allows the user to
+ * use selection tools to select a set of fields and then perform a command
+ * on those fields.
+ *
+ * Selections can be edited with some operations. A selection can be
+ * 1. inverted,
+ * 2. unioned with the other selection,
+ * 3. intersected with the other selection or
+ * 4. differenced with the other selection.
+ *
+ * Each field can be owned by a player.
+ * The 2 highest bits are selected_a and selected_b.
+ * The next highest bit is the border bit.
+ * The low bits are the player number of the owner.
+ */
+ using OwnerInfoAndSelectionsType = PlayerNumber;
+ static const uint8_t Border_Bit =
+ std::numeric_limits<OwnerInfoAndSelectionsType>::digits - 1;
+ static const OwnerInfoAndSelectionsType Border_Bitmask = 1 << Border_Bit;
+ static const OwnerInfoAndSelectionsType Player_Number_Bitmask =
+ Border_Bitmask - 1;
+ static const OwnerInfoAndSelectionsType Owner_Info_Bitmask =
+ Player_Number_Bitmask + Border_Bitmask;
+ static_assert(MAX_PLAYERS <= Player_Number_Bitmask, "Bitmask is too big.");
+
+ // Data Members
+ /** linked list, \sa Bob::linknext_ */
+ Bob * bobs;
+ BaseImmovable * immovable;
+
+ uint8_t caps : 7;
+ uint8_t roads : 6;
+
+ Height height;
+ int8_t brightness;
+
+ OwnerInfoAndSelectionsType owner_info_and_selections;
+
+ DescriptionIndex resources; ///< Resource type on this field, if any
+ uint8_t initial_res_amount; ///< Initial amount of resources
+ uint8_t res_amount; ///< Current amount of resources
+
+ Terrains terrains;
};
#pragma pack(pop)
=== modified file 'src/logic/findbob.cc'
--- src/logic/findbob.cc 2015-11-28 22:29:26 +0000
+++ src/logic/findbob.cc 2016-02-16 14:25:27 +0000
@@ -27,7 +27,7 @@
bool FindBobAttribute::accept(Bob * const bob) const
{
- return bob->has_attribute(m_attrib);
+ return bob->has_attribute(attrib);
}
bool FindBobEnemySoldier::accept(Bob * const imm) const
=== modified file 'src/logic/findbob.h'
--- src/logic/findbob.h 2016-02-09 16:29:48 +0000
+++ src/logic/findbob.h 2016-02-16 14:25:27 +0000
@@ -27,11 +27,11 @@
class Player;
struct FindBobAttribute : public FindBob {
- FindBobAttribute(uint32_t const attrib) : m_attrib(attrib) {}
+ FindBobAttribute(uint32_t const init_attrib) : attrib(init_attrib) {}
bool accept(Bob *) const override;
- uint32_t m_attrib;
+ uint32_t attrib;
virtual ~FindBobAttribute() {} // make gcc shut up
};
=== modified file 'src/logic/findimmovable.cc'
--- src/logic/findimmovable.cc 2015-11-28 22:29:26 +0000
+++ src/logic/findimmovable.cc 2016-02-16 14:25:27 +0000
@@ -39,15 +39,15 @@
bool FindImmovableSize ::accept(const BaseImmovable & imm) const {
int32_t const size = imm.get_size();
- return m_min <= size && size <= m_max;
+ return min <= size && size <= max;
}
bool FindImmovableType ::accept(const BaseImmovable & imm) const {
- return m_type == imm.descr().type();
+ return type == imm.descr().type();
}
bool FindImmovableAttribute ::accept(const BaseImmovable & imm) const {
- return imm.has_attribute(m_attrib);
+ return imm.has_attribute(attrib);
}
bool FindImmovablePlayerImmovable ::accept(const BaseImmovable & imm) const {
@@ -75,7 +75,7 @@
bool FindFlagOf::accept(const BaseImmovable & baseimm) const {
if (upcast(const Flag, flag, &baseimm)) {
if (Building * building = flag->get_building()) {
- if (finder_.accept(*building))
+ if (finder.accept(*building))
return true;
}
}
=== modified file 'src/logic/findimmovable.h'
--- src/logic/findimmovable.h 2016-02-09 16:29:48 +0000
+++ src/logic/findimmovable.h 2016-02-16 14:25:27 +0000
@@ -84,30 +84,30 @@
// FindImmovable functor
struct FindImmovableSize {
- FindImmovableSize(int32_t const min, int32_t const max)
- : m_min(min), m_max(max)
+ FindImmovableSize(int32_t const init_min, int32_t const init_max)
+ : min(init_min), max(init_max)
{}
bool accept(const BaseImmovable &) const;
private:
- int32_t m_min, m_max;
+ int32_t min, max;
};
struct FindImmovableType {
- FindImmovableType(MapObjectType const type) : m_type(type) {}
+ FindImmovableType(MapObjectType const init_type) : type(init_type) {}
bool accept(const BaseImmovable &) const;
private:
- MapObjectType m_type;
+ MapObjectType type;
};
struct FindImmovableAttribute {
- FindImmovableAttribute(uint32_t const attrib) : m_attrib(attrib) {}
+ FindImmovableAttribute(uint32_t const init_attrib) : attrib(init_attrib) {}
bool accept(const BaseImmovable &) const;
private:
- int32_t m_attrib;
+ int32_t attrib;
};
struct FindImmovablePlayerImmovable {
FindImmovablePlayerImmovable() {}
@@ -134,11 +134,11 @@
const ImmovableDescr & descr;
};
struct FindFlagOf {
- FindFlagOf(const FindImmovable & finder) : finder_(finder) {}
+ FindFlagOf(const FindImmovable & init_finder) : finder(init_finder) {}
bool accept(const BaseImmovable &) const;
- const FindImmovable finder_;
+ const FindImmovable finder;
};
=== modified file 'src/logic/findnode.cc'
--- src/logic/findnode.cc 2016-02-09 16:29:48 +0000
+++ src/logic/findnode.cc 2016-02-16 14:25:27 +0000
@@ -33,11 +33,11 @@
void FindNodeAnd::add(const FindNode & findfield, bool const negate)
{
- m_subfunctors.push_back(Subfunctor(findfield, negate));
+ subfunctors.push_back(Subfunctor(findfield, negate));
}
bool FindNodeAnd::accept(const Map & map, const FCoords & coord) const {
- for (const Subfunctor& subfunctor : m_subfunctors) {
+ for (const Subfunctor& subfunctor : subfunctors) {
if (subfunctor.findfield.accept(map, coord) == subfunctor.negate) {
return false;
}
@@ -49,10 +49,10 @@
bool FindNodeCaps::accept(const Map &, const FCoords & coord) const {
NodeCaps nodecaps = coord.field->nodecaps();
- if ((nodecaps & BUILDCAPS_SIZEMASK) < (m_mincaps & BUILDCAPS_SIZEMASK))
+ if ((nodecaps & BUILDCAPS_SIZEMASK) < (mincaps & BUILDCAPS_SIZEMASK))
return false;
- if ((m_mincaps & ~BUILDCAPS_SIZEMASK) & ~(nodecaps & ~BUILDCAPS_SIZEMASK))
+ if ((mincaps & ~BUILDCAPS_SIZEMASK) & ~(nodecaps & ~BUILDCAPS_SIZEMASK))
return false;
return true;
@@ -64,7 +64,7 @@
return false;
NodeCaps const nodecaps = coord.field->nodecaps();
- switch (m_size) {
+ switch (size) {
case sizeBuild:
return
nodecaps & (BUILDCAPS_SIZEMASK | BUILDCAPS_FLAG | BUILDCAPS_MINE);
@@ -91,10 +91,10 @@
size = imm->get_size();
switch (size) {
- case BaseImmovable::NONE: return m_sizes & sizeNone;
- case BaseImmovable::SMALL: return m_sizes & sizeSmall;
- case BaseImmovable::MEDIUM: return m_sizes & sizeMedium;
- case BaseImmovable::BIG: return m_sizes & sizeBig;
+ case BaseImmovable::NONE: return sizes & sizeNone;
+ case BaseImmovable::SMALL: return sizes & sizeSmall;
+ case BaseImmovable::MEDIUM: return sizes & sizeMedium;
+ case BaseImmovable::BIG: return sizes & sizeBig;
default:
throw wexception("FindNodeImmovableSize: bad size = %i", size);
}
@@ -105,14 +105,14 @@
(const Map &, const FCoords & coord) const
{
if (BaseImmovable * const imm = coord.field->get_immovable())
- return imm->has_attribute(m_attribute);
+ return imm->has_attribute(attribute);
return false;
}
bool FindNodeResource::accept(const Map &, const FCoords & coord) const {
return
- m_resource == coord.field->get_resources() &&
+ resource == coord.field->get_resources() &&
coord.field->get_resources_amount();
}
@@ -122,7 +122,7 @@
{
// Accept a tile that is full only if a neighbor also matches resource and
// is not full.
- if (m_resource != coord.field->get_resources()) {
+ if (resource != coord.field->get_resources()) {
return false;
}
if (coord.field->get_resources_amount() < coord.field->get_initial_res_amount()) {
@@ -131,7 +131,7 @@
for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) {
const FCoords neighb = map.get_neighbour(coord, dir);
if
- (m_resource == neighb.field->get_resources()
+ (resource == neighb.field->get_resources()
&&
neighb.field->get_resources_amount() < neighb.field->get_initial_res_amount())
{
=== modified file 'src/logic/findnode.h'
--- src/logic/findnode.h 2016-02-09 16:29:48 +0000
+++ src/logic/findnode.h 2016-02-16 14:25:27 +0000
@@ -84,12 +84,12 @@
};
struct FindNodeCaps {
- FindNodeCaps(uint8_t mincaps) : m_mincaps(mincaps) {}
+ FindNodeCaps(uint8_t init_mincaps) : mincaps(init_mincaps) {}
bool accept(const Map &, const FCoords &) const;
private:
- uint8_t m_mincaps;
+ uint8_t mincaps;
};
/// Accepts a node if it is accepted by all subfunctors.
@@ -108,7 +108,7 @@
Subfunctor(const FindNode &, bool init_negate);
};
- std::vector<Subfunctor> m_subfunctors;
+ std::vector<Subfunctor> subfunctors;
};
/// Accepts a node based on what can be built there.
@@ -123,12 +123,12 @@
sizePort, // can build a port on this field
};
- FindNodeSize(Size size) : m_size(size) {}
+ FindNodeSize(Size init_size) : size(init_size) {}
bool accept(const Map &, const FCoords &) const;
private:
- Size m_size;
+ Size size;
};
/// Accepts a node based on the size of the immovable there (if any).
@@ -140,44 +140,44 @@
sizeBig = 1 << 3
};
- FindNodeImmovableSize(uint32_t sizes) : m_sizes(sizes) {}
+ FindNodeImmovableSize(uint32_t init_sizes) : sizes(init_sizes) {}
bool accept(const Map &, const FCoords &) const;
private:
- uint32_t m_sizes;
+ uint32_t sizes;
};
/// Accepts a node if it has an immovable with a given attribute.
struct FindNodeImmovableAttribute {
- FindNodeImmovableAttribute(uint32_t attrib) : m_attribute(attrib) {}
+ FindNodeImmovableAttribute(uint32_t attrib) : attribute(attrib) {}
bool accept(const Map &, const FCoords &) const;
private:
- uint32_t m_attribute;
+ uint32_t attribute;
};
/// Accepts a node if it has at least one of the given resource.
struct FindNodeResource {
- FindNodeResource(uint8_t res) : m_resource(res) {}
+ FindNodeResource(uint8_t res) : resource(res) {}
bool accept(const Map &, const FCoords &) const;
private:
- uint8_t m_resource;
+ uint8_t resource;
};
/// Accepts a node if it has the given resource type and remaining capacity.
struct FindNodeResourceBreedable {
- FindNodeResourceBreedable(uint8_t res) : m_resource(res) {}
+ FindNodeResourceBreedable(uint8_t res) : resource(res) {}
bool accept(const Map &, const FCoords &) const;
private:
- uint8_t m_resource;
+ uint8_t resource;
};
/// Accepts a node if it is a shore node in the sense that it is walkable
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2016-02-07 07:16:24 +0000
+++ src/logic/game.cc 2016-02-16 14:25:27 +0000
@@ -74,15 +74,15 @@
//#define SYNC_DEBUG
Game::SyncWrapper::~SyncWrapper() {
- if (m_dump != nullptr) {
- if (!m_syncstreamsave)
- g_fs->fs_unlink(m_dumpfname);
+ if (dump_ != nullptr) {
+ if (!syncstreamsave_)
+ g_fs->fs_unlink(dumpfname_);
}
}
void Game::SyncWrapper::start_dump(const std::string & fname) {
- m_dumpfname = fname + ".wss";
- m_dump.reset(g_fs->open_stream_write(m_dumpfname));
+ dumpfname_ = fname + ".wss";
+ dump_.reset(g_fs->open_stream_write(dumpfname_));
}
static const unsigned long long MINIMUM_DISK_SPACE = 256 * 1024 * 1024;
@@ -96,39 +96,39 @@
log("\n");
#endif
- if (m_dump != nullptr && static_cast<int32_t>(m_counter - m_next_diskspacecheck) >= 0) {
- m_next_diskspacecheck = m_counter + 16 * 1024 * 1024;
+ if (dump_ != nullptr && static_cast<int32_t>(counter_ - next_diskspacecheck_) >= 0) {
+ next_diskspacecheck_ = counter_ + 16 * 1024 * 1024;
if (g_fs->disk_space() < MINIMUM_DISK_SPACE) {
log("Stop writing to syncstream file: disk is getting full.\n");
- m_dump.reset();
+ dump_.reset();
}
}
- if (m_dump != nullptr) {
+ if (dump_ != nullptr) {
try {
- m_dump->data(sync_data, size);
+ dump_->data(sync_data, size);
} catch (const WException &) {
- log("Writing to syncstream file %s failed. Stop synctream dump.\n", m_dumpfname.c_str());
- m_dump.reset();
+ log("Writing to syncstream file %s failed. Stop synctream dump.\n", dumpfname_.c_str());
+ dump_.reset();
}
}
- m_target.data(sync_data, size);
- m_counter += size;
+ target_.data(sync_data, size);
+ counter_ += size;
}
Game::Game() :
EditorGameBase(new LuaGameInterface(this)),
- m_syncwrapper (*this, m_synchash),
- m_ctrl (nullptr),
- m_writereplay (true),
- m_writesyncstream (false),
- m_state (gs_notrunning),
- m_cmdqueue (*this),
+ syncwrapper_ (*this, synchash_),
+ ctrl_ (nullptr),
+ writereplay_ (true),
+ writesyncstream_ (false),
+ state_ (gs_notrunning),
+ cmdqueue_ (*this),
/** TRANSLATORS: Win condition for this game has not been set. */
- m_win_condition_displayname(_("Not set"))
+ win_condition_displayname_(_("Not set"))
{
}
@@ -138,9 +138,9 @@
void Game::sync_reset() {
- m_syncwrapper.m_counter = 0;
+ syncwrapper_.counter_ = 0;
- m_synchash.Reset();
+ synchash_.Reset();
log("[sync] Reset\n");
}
@@ -166,12 +166,12 @@
void Game::set_game_controller(GameController * const ctrl)
{
- m_ctrl = ctrl;
+ ctrl_ = ctrl;
}
GameController * Game::game_controller()
{
- return m_ctrl;
+ return ctrl_;
}
void Game::set_write_replay(bool const wr)
@@ -180,16 +180,16 @@
// this is to ensure we do not crash because of diskspace
// still this is only possibe to go from true->false
// still probally should not do this with an assert but with better checks
- assert(m_state == gs_notrunning || !wr);
+ assert(state_ == gs_notrunning || !wr);
- m_writereplay = wr;
+ writereplay_ = wr;
}
void Game::set_write_syncstream(bool const wr)
{
- assert(m_state == gs_notrunning);
+ assert(state_ == gs_notrunning);
- m_writesyncstream = wr;
+ writesyncstream_ = wr;
}
@@ -199,7 +199,7 @@
*/
void Game::save_syncstream(bool const save)
{
- m_syncwrapper.m_syncstreamsave = save;
+ syncwrapper_.syncstreamsave_ = save;
}
@@ -235,7 +235,7 @@
map().get_scenario_player_name (p));
get_player(p)->set_ai(map().get_scenario_player_ai(p));
}
- m_win_condition_displayname = _("Scenario");
+ win_condition_displayname_ = _("Scenario");
set_ibase
(new InteractivePlayer
@@ -248,12 +248,12 @@
set_game_controller(new SinglePlayerGameController(*this, true, 1));
try {
bool const result = run(&loader_ui, NewSPScenario, script_to_run, false, "single_player");
- delete m_ctrl;
- m_ctrl = nullptr;
+ delete ctrl_;
+ ctrl_ = nullptr;
return result;
} catch (...) {
- delete m_ctrl;
- m_ctrl = nullptr;
+ delete ctrl_;
+ ctrl_ = nullptr;
throw;
}
}
@@ -331,11 +331,11 @@
if (!settings.scenario) {
std::unique_ptr<LuaTable> table(lua().run_script(settings.win_condition_script));
table->do_not_warn_about_unaccessed_keys();
- m_win_condition_displayname = table->get_string("name");
+ win_condition_displayname_ = table->get_string("name");
std::unique_ptr<LuaCoroutine> cr = table->get_coroutine("func");
enqueue_command(new CmdLuaCoroutine(get_gametime() + 100, cr.release()));
} else {
- m_win_condition_displayname = _("Scenario");
+ win_condition_displayname_ = _("Scenario");
}
}
@@ -360,7 +360,7 @@
GameLoader gl(settings.mapfilename, *this);
Widelands::GamePreloadPacket gpdp;
gl.preload_game(gpdp);
- m_win_condition_displayname = gpdp.get_win_condition();
+ win_condition_displayname_ = gpdp.get_win_condition();
std::string background(gpdp.get_background());
loader_ui->set_background(background);
loader_ui->step(_("Loading..."));
@@ -389,7 +389,7 @@
Widelands::GamePreloadPacket gpdp;
gl.preload_game(gpdp);
std::string background(gpdp.get_background());
- m_win_condition_displayname = gpdp.get_win_condition();
+ win_condition_displayname_ = gpdp.get_win_condition();
loader_ui.set_background(background);
player_nr = gpdp.get_player_nr();
set_ibase
@@ -406,12 +406,12 @@
set_game_controller(new SinglePlayerGameController(*this, true, player_nr));
try {
bool const result = run(&loader_ui, Loaded, script_to_run, false, "single_player");
- delete m_ctrl;
- m_ctrl = nullptr;
+ delete ctrl_;
+ ctrl_ = nullptr;
return result;
} catch (...) {
- delete m_ctrl;
- m_ctrl = nullptr;
+ delete ctrl_;
+ ctrl_ = nullptr;
throw;
}
}
@@ -453,7 +453,7 @@
{
assert(loader_ui != nullptr);
- m_replay = replay;
+ replay_ = replay;
postload();
if (start_game_type != Loaded) {
@@ -516,21 +516,21 @@
enqueue_command(new CmdLuaScript(get_gametime() + 1, script_to_run));
}
- if (m_writereplay || m_writesyncstream) {
+ if (writereplay_ || writesyncstream_) {
// Derive a replay filename from the current time
const std::string fname = (boost::format("%s/%s_%s%s") % REPLAY_DIR % timestring() %
prefix_for_replays % REPLAY_SUFFIX).str();
- if (m_writereplay) {
+ if (writereplay_) {
log("Starting replay writer\n");
- assert(!m_replaywriter);
- m_replaywriter.reset(new ReplayWriter(*this, fname));
+ assert(!replaywriter_);
+ replaywriter_.reset(new ReplayWriter(*this, fname));
log("Replay writer has started\n");
}
- if (m_writesyncstream)
- m_syncwrapper.start_dump(fname);
+ if (writesyncstream_)
+ syncwrapper_.start_dump(fname);
}
sync_reset();
@@ -546,11 +546,11 @@
g_sound_handler.change_music("ingame", 1000, 0);
- m_state = gs_running;
+ state_ = gs_running;
get_ibase()->run<UI::Panel::Returncodes>();
- m_state = gs_ending;
+ state_ = gs_ending;
g_sound_handler.change_music("menu", 1000, 0);
@@ -558,7 +558,7 @@
delete get_ibase();
set_ibase(nullptr);
- m_state = gs_notrunning;
+ state_ = gs_notrunning;
return true;
}
@@ -572,19 +572,19 @@
*/
void Game::think()
{
- assert(m_ctrl);
-
- m_ctrl->think();
-
- if (m_state == gs_running) {
+ assert(ctrl_);
+
+ ctrl_->think();
+
+ if (state_ == gs_running) {
// TODO(sirver): This is not good. Here, it depends on the speed of the
// computer and the fps if and when the game is saved - this is very bad
// for scenarios and even worse for the regression suite (which relies on
// the timings of savings.
- cmdqueue().run_queue(m_ctrl->get_frametime(), get_gametime_pointer());
+ cmdqueue().run_queue(ctrl_->get_frametime(), get_gametime_pointer());
// check if autosave is needed
- m_savehandler.think(*this);
+ savehandler_.think(*this);
}
}
@@ -596,14 +596,14 @@
// Note that this needs fixes in the editor.
void Game::cleanup_for_load()
{
- m_state = gs_notrunning;
+ state_ = gs_notrunning;
EditorGameBase::cleanup_for_load();
cmdqueue().flush();
// Statistics
- m_general_stats.clear();
+ general_stats_.clear();
}
@@ -619,7 +619,7 @@
*/
StreamWrite & Game::syncstream()
{
- return m_syncwrapper;
+ return syncwrapper_;
}
@@ -632,7 +632,7 @@
*/
Md5Checksum Game::get_sync_hash() const
{
- MD5Checksum<StreamWrite> copy(m_synchash);
+ MD5Checksum<StreamWrite> copy(synchash_);
copy.finish_checksum();
return copy.get_checksum();
@@ -660,7 +660,7 @@
*/
void Game::send_player_command (PlayerCommand & pc)
{
- m_ctrl->send_player_command(pc);
+ ctrl_->send_player_command(pc);
}
@@ -674,9 +674,9 @@
*/
void Game::enqueue_command (Command * const cmd)
{
- if (m_writereplay && m_replaywriter) {
+ if (writereplay_ && replaywriter_) {
if (upcast(PlayerCommand, plcmd, cmd)) {
- m_replaywriter->send_player_command(plcmd);
+ replaywriter_->send_player_command(plcmd);
}
}
cmdqueue().enqueue(cmd);
@@ -983,25 +983,25 @@
}
// Now, push this on the general statistics
- m_general_stats.resize(map().get_nrplayers());
+ general_stats_.resize(map().get_nrplayers());
for (uint32_t i = 0; i < map().get_nrplayers(); ++i) {
- m_general_stats[i].land_size .push_back(land_size [i]);
- m_general_stats[i].nr_buildings .push_back(nr_buildings [i]);
- m_general_stats[i].nr_casualties .push_back(nr_casualties [i]);
- m_general_stats[i].nr_kills .push_back(nr_kills [i]);
- m_general_stats[i].nr_msites_lost .push_back
+ general_stats_[i].land_size .push_back(land_size [i]);
+ general_stats_[i].nr_buildings .push_back(nr_buildings [i]);
+ general_stats_[i].nr_casualties .push_back(nr_casualties [i]);
+ general_stats_[i].nr_kills .push_back(nr_kills [i]);
+ general_stats_[i].nr_msites_lost .push_back
(nr_msites_lost [i]);
- m_general_stats[i].nr_msites_defeated .push_back
+ general_stats_[i].nr_msites_defeated .push_back
(nr_msites_defeated [i]);
- m_general_stats[i].nr_civil_blds_lost .push_back
+ general_stats_[i].nr_civil_blds_lost .push_back
(nr_civil_blds_lost [i]);
- m_general_stats[i].nr_civil_blds_defeated.push_back
+ general_stats_[i].nr_civil_blds_defeated.push_back
(nr_civil_blds_defeated[i]);
- m_general_stats[i].miltary_strength.push_back(miltary_strength[i]);
- m_general_stats[i].nr_workers .push_back(nr_workers [i]);
- m_general_stats[i].nr_wares .push_back(nr_wares [i]);
- m_general_stats[i].productivity .push_back(productivity [i]);
- m_general_stats[i].custom_statistic.push_back(custom_statistic[i]);
+ general_stats_[i].miltary_strength.push_back(miltary_strength[i]);
+ general_stats_[i].nr_workers .push_back(nr_workers [i]);
+ general_stats_[i].nr_wares .push_back(nr_wares [i]);
+ general_stats_[i].productivity .push_back(productivity [i]);
+ general_stats_[i].custom_statistic.push_back(custom_statistic[i]);
}
@@ -1024,40 +1024,40 @@
// Read general statistics
uint32_t entries = fr.unsigned_16();
const PlayerNumber nr_players = map().get_nrplayers();
- m_general_stats.resize(nr_players);
+ general_stats_.resize(nr_players);
iterate_players_existing_novar(p, nr_players, *this) {
- m_general_stats[p - 1].land_size .resize(entries);
- m_general_stats[p - 1].nr_workers .resize(entries);
- m_general_stats[p - 1].nr_buildings .resize(entries);
- m_general_stats[p - 1].nr_wares .resize(entries);
- m_general_stats[p - 1].productivity .resize(entries);
- m_general_stats[p - 1].nr_casualties .resize(entries);
- m_general_stats[p - 1].nr_kills .resize(entries);
- m_general_stats[p - 1].nr_msites_lost .resize(entries);
- m_general_stats[p - 1].nr_msites_defeated .resize(entries);
- m_general_stats[p - 1].nr_civil_blds_lost .resize(entries);
- m_general_stats[p - 1].nr_civil_blds_defeated.resize(entries);
- m_general_stats[p - 1].miltary_strength.resize(entries);
- m_general_stats[p - 1].custom_statistic.resize(entries);
+ general_stats_[p - 1].land_size .resize(entries);
+ general_stats_[p - 1].nr_workers .resize(entries);
+ general_stats_[p - 1].nr_buildings .resize(entries);
+ general_stats_[p - 1].nr_wares .resize(entries);
+ general_stats_[p - 1].productivity .resize(entries);
+ general_stats_[p - 1].nr_casualties .resize(entries);
+ general_stats_[p - 1].nr_kills .resize(entries);
+ general_stats_[p - 1].nr_msites_lost .resize(entries);
+ general_stats_[p - 1].nr_msites_defeated .resize(entries);
+ general_stats_[p - 1].nr_civil_blds_lost .resize(entries);
+ general_stats_[p - 1].nr_civil_blds_defeated.resize(entries);
+ general_stats_[p - 1].miltary_strength.resize(entries);
+ general_stats_[p - 1].custom_statistic.resize(entries);
}
iterate_players_existing_novar(p, nr_players, *this)
- for (uint32_t j = 0; j < m_general_stats[p - 1].land_size.size(); ++j)
+ for (uint32_t j = 0; j < general_stats_[p - 1].land_size.size(); ++j)
{
- m_general_stats[p - 1].land_size [j] = fr.unsigned_32();
- m_general_stats[p - 1].nr_workers [j] = fr.unsigned_32();
- m_general_stats[p - 1].nr_buildings [j] = fr.unsigned_32();
- m_general_stats[p - 1].nr_wares [j] = fr.unsigned_32();
- m_general_stats[p - 1].productivity [j] = fr.unsigned_32();
- m_general_stats[p - 1].nr_casualties [j] = fr.unsigned_32();
- m_general_stats[p - 1].nr_kills [j] = fr.unsigned_32();
- m_general_stats[p - 1].nr_msites_lost [j] = fr.unsigned_32();
- m_general_stats[p - 1].nr_msites_defeated [j] = fr.unsigned_32();
- m_general_stats[p - 1].nr_civil_blds_lost [j] = fr.unsigned_32();
- m_general_stats[p - 1].nr_civil_blds_defeated[j] = fr.unsigned_32();
- m_general_stats[p - 1].miltary_strength[j] = fr.unsigned_32();
- m_general_stats[p - 1].custom_statistic[j] = fr.unsigned_32();
+ general_stats_[p - 1].land_size [j] = fr.unsigned_32();
+ general_stats_[p - 1].nr_workers [j] = fr.unsigned_32();
+ general_stats_[p - 1].nr_buildings [j] = fr.unsigned_32();
+ general_stats_[p - 1].nr_wares [j] = fr.unsigned_32();
+ general_stats_[p - 1].productivity [j] = fr.unsigned_32();
+ general_stats_[p - 1].nr_casualties [j] = fr.unsigned_32();
+ general_stats_[p - 1].nr_kills [j] = fr.unsigned_32();
+ general_stats_[p - 1].nr_msites_lost [j] = fr.unsigned_32();
+ general_stats_[p - 1].nr_msites_defeated [j] = fr.unsigned_32();
+ general_stats_[p - 1].nr_civil_blds_lost [j] = fr.unsigned_32();
+ general_stats_[p - 1].nr_civil_blds_defeated[j] = fr.unsigned_32();
+ general_stats_[p - 1].miltary_strength[j] = fr.unsigned_32();
+ general_stats_[p - 1].custom_statistic[j] = fr.unsigned_32();
}
}
@@ -1075,8 +1075,8 @@
const PlayerNumber nr_players = map().get_nrplayers();
iterate_players_existing_novar(p, nr_players, *this)
- if (!m_general_stats.empty()) {
- entries = m_general_stats[p - 1].land_size.size();
+ if (!general_stats_.empty()) {
+ entries = general_stats_[p - 1].land_size.size();
break;
}
@@ -1084,19 +1084,19 @@
iterate_players_existing_novar(p, nr_players, *this)
for (uint32_t j = 0; j < entries; ++j) {
- fw.unsigned_32(m_general_stats[p - 1].land_size [j]);
- fw.unsigned_32(m_general_stats[p - 1].nr_workers [j]);
- fw.unsigned_32(m_general_stats[p - 1].nr_buildings [j]);
- fw.unsigned_32(m_general_stats[p - 1].nr_wares [j]);
- fw.unsigned_32(m_general_stats[p - 1].productivity [j]);
- fw.unsigned_32(m_general_stats[p - 1].nr_casualties [j]);
- fw.unsigned_32(m_general_stats[p - 1].nr_kills [j]);
- fw.unsigned_32(m_general_stats[p - 1].nr_msites_lost [j]);
- fw.unsigned_32(m_general_stats[p - 1].nr_msites_defeated [j]);
- fw.unsigned_32(m_general_stats[p - 1].nr_civil_blds_lost [j]);
- fw.unsigned_32(m_general_stats[p - 1].nr_civil_blds_defeated[j]);
- fw.unsigned_32(m_general_stats[p - 1].miltary_strength[j]);
- fw.unsigned_32(m_general_stats[p - 1].custom_statistic[j]);
+ fw.unsigned_32(general_stats_[p - 1].land_size [j]);
+ fw.unsigned_32(general_stats_[p - 1].nr_workers [j]);
+ fw.unsigned_32(general_stats_[p - 1].nr_buildings [j]);
+ fw.unsigned_32(general_stats_[p - 1].nr_wares [j]);
+ fw.unsigned_32(general_stats_[p - 1].productivity [j]);
+ fw.unsigned_32(general_stats_[p - 1].nr_casualties [j]);
+ fw.unsigned_32(general_stats_[p - 1].nr_kills [j]);
+ fw.unsigned_32(general_stats_[p - 1].nr_msites_lost [j]);
+ fw.unsigned_32(general_stats_[p - 1].nr_msites_defeated [j]);
+ fw.unsigned_32(general_stats_[p - 1].nr_civil_blds_lost [j]);
+ fw.unsigned_32(general_stats_[p - 1].nr_civil_blds_defeated[j]);
+ fw.unsigned_32(general_stats_[p - 1].miltary_strength[j]);
+ fw.unsigned_32(general_stats_[p - 1].custom_statistic[j]);
}
}
=== modified file 'src/logic/game.h'
--- src/logic/game.h 2016-02-08 06:12:18 +0000
+++ src/logic/game.h 2016-02-16 14:25:27 +0000
@@ -135,22 +135,22 @@
void think() override;
ReplayWriter* get_replaywriter() {
- return m_replaywriter.get();
+ return replaywriter_.get();
}
/**
* \return \c true if the game is completely loaded and running (or paused)
* or \c false otherwise.
*/
- bool is_loaded() {return m_state == gs_running;}
+ bool is_loaded() {return state_ == gs_running;}
void cleanup_for_load() override;
// in-game logic
- const CmdQueue & cmdqueue() const {return m_cmdqueue;}
- CmdQueue & cmdqueue() {return m_cmdqueue;}
- const RNG & rng () const {return m_rng;}
- RNG & rng () {return m_rng;}
+ const CmdQueue & cmdqueue() const {return cmdqueue_;}
+ CmdQueue & cmdqueue() {return cmdqueue_;}
+ const RNG & rng () const {return rng_;}
+ RNG & rng () {return rng_;}
uint32_t logic_rand();
@@ -198,11 +198,11 @@
InteractivePlayer * get_ipl();
- SaveHandler & save_handler() {return m_savehandler;}
+ SaveHandler & save_handler() {return savehandler_;}
// Statistics
const GeneralStatsVector & get_general_statistics() const {
- return m_general_stats;
+ return general_stats_;
}
void read_statistics(FileRead &);
@@ -210,22 +210,22 @@
void sample_statistics();
- const std::string & get_win_condition_displayname() {return m_win_condition_displayname;}
+ const std::string & get_win_condition_displayname() {return win_condition_displayname_;}
- bool is_replay() const {return m_replay;}
+ bool is_replay() const {return replay_;}
private:
void sync_reset();
- MD5Checksum<StreamWrite> m_synchash;
+ MD5Checksum<StreamWrite> synchash_;
struct SyncWrapper : public StreamWrite {
SyncWrapper(Game & game, StreamWrite & target) :
- m_game (game),
- m_target (target),
- m_counter (0),
- m_next_diskspacecheck(0),
- m_syncstreamsave(false)
+ game_ (game),
+ target_ (target),
+ counter_ (0),
+ next_diskspacecheck_(0),
+ syncstreamsave_(false)
{}
~SyncWrapper();
@@ -233,50 +233,50 @@
/// Start dumping the entire syncstream into a file.
///
/// Note that this file is deleted at the end of the game, unless
- /// \ref m_syncstreamsave has been set.
+ /// \ref syncstreamsave_ has been set.
void start_dump(const std::string & fname);
void data(void const * data, size_t size) override;
- void flush() override {m_target.flush();}
+ void flush() override {target_.flush();}
public:
- Game & m_game;
- StreamWrite & m_target;
- uint32_t m_counter;
- uint32_t m_next_diskspacecheck;
- std::unique_ptr<StreamWrite> m_dump;
- std::string m_dumpfname;
- bool m_syncstreamsave;
- } m_syncwrapper;
+ Game & game_;
+ StreamWrite & target_;
+ uint32_t counter_;
+ uint32_t next_diskspacecheck_;
+ std::unique_ptr<StreamWrite> dump_;
+ std::string dumpfname_;
+ bool syncstreamsave_;
+ } syncwrapper_;
- GameController * m_ctrl;
+ GameController * ctrl_;
/// Whether a replay writer should be created.
/// Defaults to \c true, and should only be set to \c false for playing back
/// replays.
- bool m_writereplay;
+ bool writereplay_;
/// Whether a syncsteam file should be created.
/// Defaults to \c false, and can be set to true for network games. The file
- /// is written only if \ref m_writereplay is true too.
- bool m_writesyncstream;
-
- int32_t m_state;
-
- RNG m_rng;
-
- CmdQueue m_cmdqueue;
-
- SaveHandler m_savehandler;
-
- std::unique_ptr<ReplayWriter> m_replaywriter;
-
- GeneralStatsVector m_general_stats;
+ /// is written only if \ref writereplay_ is true too.
+ bool writesyncstream_;
+
+ int32_t state_;
+
+ RNG rng_;
+
+ CmdQueue cmdqueue_;
+
+ SaveHandler savehandler_;
+
+ std::unique_ptr<ReplayWriter> replaywriter_;
+
+ GeneralStatsVector general_stats_;
/// For save games and statistics generation
- std::string m_win_condition_displayname;
- bool m_replay;
+ std::string win_condition_displayname_;
+ bool replay_;
};
inline Coords Game::random_location(Coords location, uint8_t radius) {
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2016-02-14 14:09:29 +0000
+++ src/logic/map.cc 2016-02-16 14:25:27 +0000
@@ -67,11 +67,11 @@
*/
Map::Map() :
-m_nrplayers (0),
-m_scenario_types (NO_SCENARIO),
-m_width (0),
-m_height (0),
-m_pathfieldmgr (new PathfieldManager)
+nrplayers_ (0),
+scenario_types_ (NO_SCENARIO),
+width_ (0),
+height_ (0),
+pathfieldmgr_ (new PathfieldManager)
{
}
@@ -109,11 +109,11 @@
*/
void Map::recalc_for_field_area(const World& world, const Area<FCoords> area) {
assert(0 <= area.x);
- assert(area.x < m_width);
+ assert(area.x < width_);
assert(0 <= area.y);
- assert(area.y < m_height);
- assert(m_fields.get() <= area.field);
- assert (area.field < m_fields.get() + max_index());
+ assert(area.y < height_);
+ assert(fields_.get() <= area.field);
+ assert (area.field < fields_.get() + max_index());
{ // First pass.
MapRegion<Area<FCoords> > mr(*this, area);
@@ -146,8 +146,8 @@
// brightness and building caps
FCoords f;
- for (int16_t y = 0; y < m_height; ++y)
- for (int16_t x = 0; x < m_width; ++x) {
+ for (int16_t y = 0; y < height_; ++y)
+ for (int16_t x = 0; x < width_; ++x) {
f = get_fcoords(Coords(x, y));
uint32_t radius = 0;
check_neighbour_heights(f, radius);
@@ -156,16 +156,16 @@
recalc_nodecaps_pass1 (world, f);
}
- for (int16_t y = 0; y < m_height; ++y)
- for (int16_t x = 0; x < m_width; ++x) {
+ for (int16_t y = 0; y < height_; ++y)
+ for (int16_t x = 0; x < width_; ++x) {
f = get_fcoords(Coords(x, y));
recalc_nodecaps_pass2(world, f);
}
}
void Map::recalc_default_resources(const World& world) {
- for (int16_t y = 0; y < m_height; ++y)
- for (int16_t x = 0; x < m_width; ++x) {
+ for (int16_t y = 0; y < height_; ++y)
+ for (int16_t x = 0; x < width_; ++x) {
FCoords f, f1;
f = get_fcoords(Coords(x, y));
// only on unset nodes
@@ -265,24 +265,24 @@
===============
*/
void Map::cleanup() {
- m_nrplayers = 0;
- m_width = m_height = 0;
-
- m_fields.reset();
-
- m_starting_pos.clear();
- m_scenario_tribes.clear();
- m_scenario_names.clear();
- m_scenario_ais.clear();
- m_scenario_closeables.clear();
-
- m_tags.clear();
- m_hint = std::string();
- m_background = std::string();
+ nrplayers_ = 0;
+ width_ = height_ = 0;
+
+ fields_.reset();
+
+ starting_pos_.clear();
+ scenario_tribes_.clear();
+ scenario_names_.clear();
+ scenario_ais_.clear();
+ scenario_closeables_.clear();
+
+ tags_.clear();
+ hint_ = std::string();
+ background_ = std::string();
objectives_.clear();
- m_port_spaces.clear();
+ port_spaces_.clear();
// TODO(meitis): should be done here ... but WidelandsMapLoader::preload_map calls
// this cleanup AFTER assigning filesystem_ in WidelandsMapLoader::WidelandsMapLoader
@@ -320,8 +320,8 @@
Field::Terrains default_terrains;
default_terrains.d = default_terrain;
default_terrains.r = default_terrain;
- for (int16_t y = 0; y < m_height; ++y) {
- for (int16_t x = 0; x < m_width; ++x) {
+ for (int16_t y = 0; y < height_; ++y) {
+ for (int16_t x = 0; x < width_; ++x) {
auto f = get_fcoords(Coords(x, y));
f.field->set_height(10);
f.field->set_terrains(default_terrains);
@@ -337,39 +337,39 @@
void Map::set_origin(Coords const new_origin) {
assert(0 <= new_origin.x);
- assert (new_origin.x < m_width);
+ assert (new_origin.x < width_);
assert(0 <= new_origin.y);
- assert (new_origin.y < m_height);
+ assert (new_origin.y < height_);
for (uint8_t i = get_nrplayers(); i;) {
- m_starting_pos[--i].reorigin(new_origin, extent());
+ starting_pos_[--i].reorigin(new_origin, extent());
}
- std::unique_ptr<Field[]> new_field_order(new Field[m_width * m_height]);
- memset(new_field_order.get(), 0, sizeof(Field) * m_width * m_height);
+ std::unique_ptr<Field[]> new_field_order(new Field[width_ * height_]);
+ memset(new_field_order.get(), 0, sizeof(Field) * width_ * height_);
// Rearrange The fields
// NOTE because of the triangle design, we have to take special care about cases
// NOTE where y is changed by an odd number
bool yisodd = (new_origin.y % 2) != 0;
- for (FCoords c(Coords(0, 0)); c.y < m_height; ++c.y) {
+ for (FCoords c(Coords(0, 0)); c.y < height_; ++c.y) {
bool cyisodd = (c.y % 2) != 0;
- for (c.x = 0; c.x < m_width; ++c.x) {
+ for (c.x = 0; c.x < width_; ++c.x) {
Coords temp;
if (yisodd && cyisodd)
temp = Coords(c.x + new_origin.x + 1, c.y + new_origin.y);
else
temp = Coords(c.x + new_origin.x, c.y + new_origin.y);
normalize_coords(temp);
- new_field_order[get_index(c, m_width)] = operator[](temp);
+ new_field_order[get_index(c, width_)] = operator[](temp);
}
}
// Now that we restructured the fields, we just overwrite the old order
- m_fields.reset(new_field_order.release());
+ fields_.reset(new_field_order.release());
// Inform immovables and bobs about their new coordinates.
- for (FCoords c(Coords(0, 0), m_fields.get()); c.y < m_height; ++c.y)
- for (c.x = 0; c.x < m_width; ++c.x, ++c.field) {
+ for (FCoords c(Coords(0, 0), fields_.get()); c.y < height_; ++c.y)
+ for (c.x = 0; c.x < width_; ++c.x, ++c.field) {
assert(c.field == &operator[] (c));
if (upcast(Immovable, immovable, c.field->get_immovable()))
immovable->position_ = c;
@@ -386,7 +386,7 @@
// Take care about port spaces
PortSpacesSet new_port_spaces;
- for (PortSpacesSet::iterator it = m_port_spaces.begin(); it != m_port_spaces.end(); ++it) {
+ for (PortSpacesSet::iterator it = port_spaces_.begin(); it != port_spaces_.end(); ++it) {
Coords temp;
if (yisodd && ((it->y % 2) == 0))
temp = Coords(it->x - new_origin.x - 1, it->y - new_origin.y);
@@ -396,7 +396,7 @@
log("(%i,%i) -> (%i,%i)\n", it->x, it->y, temp.x, temp.y);
new_port_spaces.insert(temp);
}
- m_port_spaces = new_port_spaces;
+ port_spaces_ = new_port_spaces;
}
@@ -409,15 +409,15 @@
*/
void Map::set_size(const uint32_t w, const uint32_t h)
{
- assert(!m_fields);
-
- m_width = w;
- m_height = h;
-
- m_fields.reset(new Field[w * h]);
- memset(m_fields.get(), 0, sizeof(Field) * w * h);
-
- m_pathfieldmgr->set_size(w * h);
+ assert(!fields_);
+
+ width_ = w;
+ height_ = h;
+
+ fields_.reset(new Field[w * h]);
+ memset(fields_.get(), 0, sizeof(Field) * w * h);
+
+ pathfieldmgr_->set_size(w * h);
}
/*
@@ -425,34 +425,34 @@
*/
const std::string & Map::get_scenario_player_tribe(const PlayerNumber p) const
{
- assert(m_scenario_tribes.size() == get_nrplayers());
+ assert(scenario_tribes_.size() == get_nrplayers());
assert(p);
assert(p <= get_nrplayers());
- return m_scenario_tribes[p - 1];
+ return scenario_tribes_[p - 1];
}
const std::string & Map::get_scenario_player_name(const PlayerNumber p) const
{
- assert(m_scenario_names.size() == get_nrplayers());
+ assert(scenario_names_.size() == get_nrplayers());
assert(p);
assert(p <= get_nrplayers());
- return m_scenario_names[p - 1];
+ return scenario_names_[p - 1];
}
const std::string & Map::get_scenario_player_ai(const PlayerNumber p) const
{
- assert(m_scenario_ais.size() == get_nrplayers());
+ assert(scenario_ais_.size() == get_nrplayers());
assert(p);
assert(p <= get_nrplayers());
- return m_scenario_ais[p - 1];
+ return scenario_ais_[p - 1];
}
bool Map::get_scenario_player_closeable(const PlayerNumber p) const
{
- assert(m_scenario_closeables.size() == get_nrplayers());
+ assert(scenario_closeables_.size() == get_nrplayers());
assert(p);
assert(p <= get_nrplayers());
- return m_scenario_closeables[p - 1];
+ return scenario_closeables_[p - 1];
}
void Map::swap_filesystem(std::unique_ptr<FileSystem>& fs)
@@ -468,32 +468,32 @@
{
assert(p);
assert(p <= get_nrplayers());
- m_scenario_tribes.resize(get_nrplayers());
- m_scenario_tribes[p - 1] = tribename;
+ scenario_tribes_.resize(get_nrplayers());
+ scenario_tribes_[p - 1] = tribename;
}
void Map::set_scenario_player_name(PlayerNumber const p, const std::string & playername)
{
assert(p);
assert(p <= get_nrplayers());
- m_scenario_names.resize(get_nrplayers());
- m_scenario_names[p - 1] = playername;
+ scenario_names_.resize(get_nrplayers());
+ scenario_names_[p - 1] = playername;
}
void Map::set_scenario_player_ai(PlayerNumber const p, const std::string & ainame)
{
assert(p);
assert(p <= get_nrplayers());
- m_scenario_ais.resize(get_nrplayers());
- m_scenario_ais[p - 1] = ainame;
+ scenario_ais_.resize(get_nrplayers());
+ scenario_ais_[p - 1] = ainame;
}
void Map::set_scenario_player_closeable(PlayerNumber const p, bool closeable)
{
assert(p);
assert(p <= get_nrplayers());
- m_scenario_closeables.resize(get_nrplayers());
- m_scenario_closeables[p - 1] = closeable;
+ scenario_closeables_.resize(get_nrplayers());
+ scenario_closeables_[p - 1] = closeable;
}
/*
@@ -504,18 +504,18 @@
*/
void Map::set_nrplayers(PlayerNumber const nrplayers) {
if (!nrplayers) {
- m_nrplayers = 0;
+ nrplayers_ = 0;
return;
}
- m_starting_pos.resize(nrplayers, Coords(-1, -1));
- m_scenario_tribes.resize(nrplayers);
- m_scenario_ais.resize(nrplayers);
- m_scenario_closeables.resize(nrplayers);
- m_scenario_names.resize(nrplayers);
- m_scenario_tribes.resize(nrplayers);
+ starting_pos_.resize(nrplayers, Coords(-1, -1));
+ scenario_tribes_.resize(nrplayers);
+ scenario_ais_.resize(nrplayers);
+ scenario_closeables_.resize(nrplayers);
+ scenario_names_.resize(nrplayers);
+ scenario_tribes_.resize(nrplayers);
- m_nrplayers = nrplayers; // in case the number players got less
+ nrplayers_ = nrplayers; // in case the number players got less
}
/*
@@ -526,50 +526,50 @@
void Map::set_starting_pos(PlayerNumber const plnum, Coords const c)
{
assert(1 <= plnum && plnum <= get_nrplayers());
- m_starting_pos[plnum - 1] = c;
+ starting_pos_[plnum - 1] = c;
}
void Map::set_filename(const std::string& filename)
{
- m_filename = filename;
+ filename_ = filename;
}
void Map::set_author(const std::string& author)
{
- m_author = author;
+ author_ = author;
}
void Map::set_name(const std::string& name)
{
- m_name = name;
+ name_ = name;
}
void Map::set_description(const std::string& description)
{
- m_description = description;
+ description_ = description;
}
void Map::set_hint(const std::string& hint)
{
- m_hint = hint;
+ hint_ = hint;
}
void Map::set_background(const std::string& image_path)
{
if (image_path.empty())
- m_background.clear();
+ background_.clear();
else
- m_background = image_path;
+ background_ = image_path;
}
void Map::add_tag(const std::string& tag) {
- m_tags.insert(tag);
+ tags_.insert(tag);
}
void Map::delete_tag(const std::string& tag) {
if (has_tag(tag)) {
- m_tags.erase(m_tags.find(tag));
+ tags_.erase(tags_.find(tag));
}
}
@@ -600,7 +600,7 @@
(Area<FCoords> const area, const CheckStep & checkstep, functorT & functor)
{
std::vector<Coords> queue;
- boost::shared_ptr<Pathfields> pathfields = m_pathfieldmgr->allocate();
+ boost::shared_ptr<Pathfields> pathfields = pathfieldmgr_->allocate();
queue.push_back(area);
@@ -608,7 +608,7 @@
// Pop the last ware from the queue
FCoords const cur = get_fcoords(*queue.rbegin());
queue.pop_back();
- Pathfield & curpf = pathfields->fields[cur.field - m_fields.get()];
+ Pathfield & curpf = pathfields->fields[cur.field - fields_.get()];
// handle this node
functor(*this, cur);
@@ -621,7 +621,7 @@
get_neighbour(cur, dir, &neighb);
if // node not already handled?
- (pathfields->fields[neighb.field - m_fields.get()].cycle
+ (pathfields->fields[neighb.field - fields_.get()].cycle
!=
pathfields->cycle
&&
@@ -1372,15 +1372,15 @@
/// \returns true, if Coordinates are in port space list
bool Map::is_port_space(const Coords& c) const {
- return m_port_spaces.count(c);
+ return port_spaces_.count(c);
}
/// Set or unset a space as port space
void Map::set_port_space(Coords c, bool allowed) {
if (allowed) {
- m_port_spaces.insert(c);
+ port_spaces_.insert(c);
} else {
- m_port_spaces.erase(c);
+ port_spaces_.erase(c);
}
}
@@ -1395,14 +1395,14 @@
// do we fly up or down?
dy = b.y - a.y;
- if (dy > static_cast<int32_t>(m_height >> 1)) // wrap-around!
- dy -= m_height;
- else if (dy < -static_cast<int32_t>(m_height >> 1))
- dy += m_height;
+ if (dy > static_cast<int32_t>(height_ >> 1)) // wrap-around!
+ dy -= height_;
+ else if (dy < -static_cast<int32_t>(height_ >> 1))
+ dy += height_;
dist = abs(dy);
- if (static_cast<int16_t>(dist) >= m_width)
+ if (static_cast<int16_t>(dist) >= width_)
// no need to worry about x movement at all
return dist;
@@ -1418,22 +1418,22 @@
// Allow for wrap-around
// Yes, the second is an else if; see the above if (dist >= m_width)
if (lx < 0)
- lx += m_width;
- else if (rx >= static_cast<int32_t>(m_width))
- rx -= m_width;
+ lx += width_;
+ else if (rx >= static_cast<int32_t>(width_))
+ rx -= width_;
// Normal, non-wrapping case
if (lx <= rx)
{
if (b.x < lx) {
int32_t dx1 = lx - b.x;
- int32_t dx2 = b.x - (rx - m_width);
+ int32_t dx2 = b.x - (rx - width_);
dist += std::min(dx1, dx2);
}
else if (b.x > rx)
{
int32_t dx1 = b.x - rx;
- int32_t dx2 = (lx + m_width) - b.x;
+ int32_t dx2 = (lx + width_) - b.x;
dist += std::min(dx1, dx2);
}
}
@@ -1705,9 +1705,9 @@
upper_cost_limit = persist * calc_cost_estimate(start, end);
// Actual pathfinding
- boost::shared_ptr<Pathfields> pathfields = m_pathfieldmgr->allocate();
+ boost::shared_ptr<Pathfields> pathfields = pathfieldmgr_->allocate();
Pathfield::Queue Open;
- Pathfield * curpf = &pathfields->fields[start.field - m_fields.get()];
+ Pathfield * curpf = &pathfields->fields[start.field - fields_.get()];
curpf->cycle = pathfields->cycle;
curpf->real_cost = 0;
curpf->estim_cost = calc_cost_lowerbound(start, end);
@@ -1721,7 +1721,7 @@
curpf = Open.top();
Open.pop(curpf);
- cur.field = m_fields.get() + (curpf - pathfields->fields.get());
+ cur.field = fields_.get() + (curpf - pathfields->fields.get());
get_coords(*cur.field, cur);
if (upper_cost_limit && curpf->real_cost > upper_cost_limit)
@@ -1742,7 +1742,7 @@
int32_t cost;
get_neighbour(cur, *direction, &neighb);
- Pathfield & neighbpf = pathfields->fields[neighb.field - m_fields.get()];
+ Pathfield & neighbpf = pathfields->fields[neighb.field - fields_.get()];
// Is the field Closed already?
if
@@ -1800,7 +1800,7 @@
// Reverse logic! (WALK_NW needs to find the SE neighbour)
get_neighbour(cur, get_reverse_dir(curpf->backlink), &cur);
- curpf = &pathfields->fields[cur.field - m_fields.get()];
+ curpf = &pathfields->fields[cur.field - fields_.get()];
}
return result;
@@ -1852,7 +1852,7 @@
}
Notifications::publish(
- NoteFieldTerrainChanged{c, static_cast<MapIndex>(c.field - &m_fields[0])});
+ NoteFieldTerrainChanged{c, static_cast<MapIndex>(c.field - &fields_[0])});
// Changing the terrain can affect ports, which can be up to 3 fields away.
constexpr int kPotentiallyAffectedNeighbors = 3;
@@ -1895,7 +1895,7 @@
void Map::ensure_resource_consistency(const World& world)
{
for (MapIndex i = 0; i < max_index(); ++i) {
- auto fcords = get_fcoords(m_fields[i]);
+ auto fcords = get_fcoords(fields_[i]);
if (!is_resource_valid(world, fcords, fcords.field->get_resources())) {
clear_resources(fcords);
}
@@ -1910,24 +1910,24 @@
amount = 0;
}
const auto note = NoteFieldResourceChanged{
- c, c.field->m_resources, c.field->m_initial_res_amount, c.field->m_res_amount,
+ c, c.field->resources, c.field->initial_res_amount, c.field->res_amount,
};
- c.field->m_resources = resource_type;
- c.field->m_initial_res_amount = amount;
- c.field->m_res_amount = amount;
+ c.field->resources = resource_type;
+ c.field->initial_res_amount = amount;
+ c.field->res_amount = amount;
Notifications::publish(note);
}
void Map::set_resources(const FCoords& c, uint8_t amount) {
// You cannot change the amount of resources on a field without resources.
- if (c.field->m_resources == Widelands::kNoResource) {
+ if (c.field->resources == Widelands::kNoResource) {
return;
}
const auto note = NoteFieldResourceChanged{
- c, c.field->m_resources, c.field->m_initial_res_amount, c.field->m_res_amount,
+ c, c.field->resources, c.field->initial_res_amount, c.field->res_amount,
};
- c.field->m_res_amount = amount;
+ c.field->res_amount = amount;
Notifications::publish(note);
}
@@ -1937,8 +1937,8 @@
uint32_t Map::set_height(const World& world, const FCoords fc, uint8_t const new_value) {
assert(new_value <= MAX_FIELD_HEIGHT);
- assert(m_fields.get() <= fc.field);
- assert (fc.field < m_fields.get() + max_index());
+ assert(fields_.get() <= fc.field);
+ assert (fc.field < fields_.get() + max_index());
fc.field->height = new_value;
uint32_t radius = 2;
check_neighbour_heights(fc, radius);
@@ -2032,8 +2032,8 @@
*/
void Map::check_neighbour_heights(FCoords coords, uint32_t & area)
{
- assert(m_fields.get() <= coords.field);
- assert (coords.field < m_fields.get() + max_index());
+ assert(fields_.get() <= coords.field);
+ assert (coords.field < fields_.get() + max_index());
int32_t height = coords.field->get_height();
bool check[] = {false, false, false, false, false, false};
=== modified file 'src/logic/map.h'
--- src/logic/map.h 2016-02-14 14:09:29 +0000
+++ src/logic/map.h 2016-02-16 14:25:27 +0000
@@ -204,7 +204,7 @@
void set_starting_pos(PlayerNumber, Coords);
Coords get_starting_pos(PlayerNumber const p) const {
assert(1 <= p && p <= get_nrplayers());
- return m_starting_pos[p - 1];
+ return starting_pos_[p - 1];
}
void set_filename (const std::string& filename);
@@ -215,7 +215,7 @@
void set_background (const std::string& image_path);
void add_tag (const std::string& tag);
void delete_tag (const std::string& tag);
- void set_scenario_types(ScenarioTypes t) {m_scenario_types = t;}
+ void set_scenario_types(ScenarioTypes t) {scenario_types_ = t;}
// Allows access to the filesystem of the map to access auxiliary files.
// This can be nullptr if this file is new.
@@ -224,25 +224,25 @@
void swap_filesystem(std::unique_ptr<FileSystem>& fs);
// informational functions
- const std::string& get_filename() const {return m_filename;}
- const std::string& get_author() const {return m_author;}
- const std::string& get_name() const {return m_name;}
- const std::string& get_description() const {return m_description;}
- const std::string& get_hint() const {return m_hint;}
- const std::string& get_background() const {return m_background;}
+ const std::string& get_filename() const {return filename_;}
+ const std::string& get_author() const {return author_;}
+ const std::string& get_name() const {return name_;}
+ const std::string& get_description() const {return description_;}
+ const std::string& get_hint() const {return hint_;}
+ const std::string& get_background() const {return background_;}
using Tags = std::set<std::string>;
- const Tags & get_tags() const {return m_tags;}
- void clear_tags() {m_tags.clear();}
- bool has_tag(const std::string& s) const {return m_tags.count(s);}
-
- const std::vector<SuggestedTeamLineup>& get_suggested_teams() const {return m_suggested_teams;}
-
- PlayerNumber get_nrplayers() const {return m_nrplayers;}
- ScenarioTypes scenario_types() const {return m_scenario_types;}
- Extent extent() const {return Extent(m_width, m_height);}
- int16_t get_width () const {return m_width;}
- int16_t get_height () const {return m_height;}
+ const Tags & get_tags() const {return tags_;}
+ void clear_tags() {tags_.clear();}
+ bool has_tag(const std::string& s) const {return tags_.count(s);}
+
+ const std::vector<SuggestedTeamLineup>& get_suggested_teams() const {return suggested_teams_;}
+
+ PlayerNumber get_nrplayers() const {return nrplayers_;}
+ ScenarioTypes scenario_types() const {return scenario_types_;}
+ Extent extent() const {return Extent(width_, height_);}
+ int16_t get_width () const {return width_;}
+ int16_t get_height () const {return height_;}
// The next few functions are only valid when the map is loaded as a
// scenario.
@@ -294,7 +294,7 @@
// Field logic
static MapIndex get_index(const Coords &, int16_t width);
- MapIndex max_index() const {return m_width * m_height;}
+ MapIndex max_index() const {return width_ * height_;}
Field & operator[](MapIndex) const;
Field & operator[](const Coords &) const;
FCoords get_fcoords(const Coords &) const;
@@ -430,7 +430,7 @@
/// Port space specific functions
bool is_port_space(const Coords& c) const;
void set_port_space(Coords c, bool allowed);
- const PortSpacesSet& get_port_spaces() const {return m_port_spaces;}
+ const PortSpacesSet& get_port_spaces() const {return port_spaces_;}
std::vector<Coords> find_portdock(const Widelands::Coords& c) const;
bool allows_seafaring();
bool has_artifacts(const World& world);
@@ -442,34 +442,34 @@
void recalc_border(FCoords);
/// # of players this map supports (!= Game's number of players!)
- PlayerNumber m_nrplayers;
- ScenarioTypes m_scenario_types; // whether the map is playable as scenario
-
- int16_t m_width;
- int16_t m_height;
- std::string m_filename;
- std::string m_author;
- std::string m_name;
- std::string m_description;
- std::string m_hint;
- std::string m_background;
- Tags m_tags;
- std::vector<SuggestedTeamLineup> m_suggested_teams;
-
- std::vector<Coords> m_starting_pos; // players' starting positions
-
- std::unique_ptr<Field[]> m_fields;
-
- std::unique_ptr<PathfieldManager> m_pathfieldmgr;
- std::vector<std::string> m_scenario_tribes;
- std::vector<std::string> m_scenario_names;
- std::vector<std::string> m_scenario_ais;
- std::vector<bool> m_scenario_closeables;
+ PlayerNumber nrplayers_;
+ ScenarioTypes scenario_types_; // whether the map is playable as scenario
+
+ int16_t width_;
+ int16_t height_;
+ std::string filename_;
+ std::string author_;
+ std::string name_;
+ std::string description_;
+ std::string hint_;
+ std::string background_;
+ Tags tags_;
+ std::vector<SuggestedTeamLineup> suggested_teams_;
+
+ std::vector<Coords> starting_pos_; // players' starting positions
+
+ std::unique_ptr<Field[]> fields_;
+
+ std::unique_ptr<PathfieldManager> pathfieldmgr_;
+ std::vector<std::string> scenario_tribes_;
+ std::vector<std::string> scenario_names_;
+ std::vector<std::string> scenario_ais_;
+ std::vector<bool> scenario_closeables_;
// The map file as a filesystem.
std::unique_ptr<FileSystem> filesystem_;
- PortSpacesSet m_port_spaces;
+ PortSpacesSet port_spaces_;
Objectives objectives_;
void recalc_brightness(FCoords);
@@ -490,7 +490,7 @@
void find_reachable(Area<FCoords>, const CheckStep &, functorT &);
template<typename functorT> void find(const Area<FCoords>, functorT &) const;
- MapVersion m_map_version;
+ MapVersion map_version_;
};
@@ -510,9 +510,9 @@
return c.y * width + c.x;
}
-inline Field & Map::operator[](MapIndex const i) const {return m_fields[i];}
+inline Field & Map::operator[](MapIndex const i) const {return fields_[i];}
inline Field & Map::operator[](const Coords & c) const {
- return operator[](get_index(c, m_width));
+ return operator[](get_index(c, width_));
}
inline FCoords Map::get_fcoords(const Coords & c) const
@@ -522,10 +522,10 @@
inline void Map::normalize_coords(Coords & c) const
{
- while (c.x < 0) c.x += m_width;
- while (c.x >= m_width) c.x -= m_width;
- while (c.y < 0) c.y += m_height;
- while (c.y >= m_height) c.y -= m_height;
+ while (c.x < 0) c.x += width_;
+ while (c.x >= width_) c.x -= width_;
+ while (c.y < 0) c.y += height_;
+ while (c.y >= height_) c.y -= height_;
}
@@ -533,8 +533,8 @@
* Calculate the field coordates from the pointer
*/
inline FCoords Map::get_fcoords(Field & f) const {
- const int32_t i = &f - m_fields.get();
- return FCoords(Coords(i % m_width, i / m_width), &f);
+ const int32_t i = &f - fields_.get();
+ return FCoords(Coords(i % width_, i / width_), &f);
}
inline void Map::get_coords(Field & f, Coords & c) const {c = get_fcoords(f);}
@@ -550,138 +550,138 @@
inline void Map::get_ln(const Coords & f, Coords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
o->y = f.y;
- o->x = (f.x ? f.x : m_width) - 1;
+ o->x = (f.x ? f.x : width_) - 1;
assert(0 <= o->x);
assert(0 <= o->y);
- assert(o->x < m_width);
- assert(o->y < m_height);
+ assert(o->x < width_);
+ assert(o->y < height_);
}
inline void Map::get_ln(const FCoords & f, FCoords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert (f.field < m_fields.get() + max_index());
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert (f.field < fields_.get() + max_index());
o->y = f.y;
o->x = f.x - 1;
o->field = f.field - 1;
if (o->x == -1) {
- o->x = m_width - 1;
- o->field += m_width;
+ o->x = width_ - 1;
+ o->field += width_;
}
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
- assert(m_fields.get() <= o->field);
- assert(o->field < m_fields.get() + max_index());
+ assert(o->y < height_);
+ assert(fields_.get() <= o->field);
+ assert(o->field < fields_.get() + max_index());
}
inline Coords Map::l_n(const Coords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
Coords result(f.x - 1, f.y);
if (result.x == -1)
- result.x = m_width - 1;
+ result.x = width_ - 1;
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
+ assert(result.y < height_);
return result;
}
inline FCoords Map::l_n(const FCoords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert(f.field < m_fields.get() + max_index());
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert(f.field < fields_.get() + max_index());
FCoords result(Coords(f.x - 1, f.y), f.field - 1);
if (result.x == -1) {
- result.x = m_width - 1;
- result.field += m_width;
+ result.x = width_ - 1;
+ result.field += width_;
}
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
- assert(m_fields.get() <= result.field);
- assert(result.field < m_fields.get() + max_index());
+ assert(result.y < height_);
+ assert(fields_.get() <= result.field);
+ assert(result.field < fields_.get() + max_index());
return result;
}
inline void Map::get_rn(const Coords & f, Coords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
o->y = f.y;
o->x = f.x + 1;
- if (o->x == m_width)
+ if (o->x == width_)
o->x = 0;
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
+ assert(o->y < height_);
}
inline void Map::get_rn(const FCoords & f, FCoords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert (f.field < m_fields.get() + max_index());
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert (f.field < fields_.get() + max_index());
o->y = f.y;
o->x = f.x + 1;
o->field = f.field + 1;
- if (o->x == m_width) {o->x = 0; o->field -= m_width;}
+ if (o->x == width_) {o->x = 0; o->field -= width_;}
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
- assert(m_fields.get() <= o->field);
- assert(o->field < m_fields.get() + max_index());
+ assert(o->y < height_);
+ assert(fields_.get() <= o->field);
+ assert(o->field < fields_.get() + max_index());
}
inline Coords Map::r_n(const Coords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
Coords result(f.x + 1, f.y);
- if (result.x == m_width)
+ if (result.x == width_)
result.x = 0;
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
+ assert(result.y < height_);
return result;
}
inline FCoords Map::r_n(const FCoords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert(f.field < m_fields.get() + max_index());
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert(f.field < fields_.get() + max_index());
FCoords result(Coords(f.x + 1, f.y), f.field + 1);
- if (result.x == m_width) {result.x = 0; result.field -= m_width;}
+ if (result.x == width_) {result.x = 0; result.field -= width_;}
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
- assert(m_fields.get() <= result.field);
- assert(result.field < m_fields.get() + max_index());
+ assert(result.y < height_);
+ assert(fields_.get() <= result.field);
+ assert(result.field < fields_.get() + max_index());
return result;
}
@@ -689,97 +689,97 @@
inline void Map::get_tln(const Coords & f, Coords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
o->y = f.y - 1;
o->x = f.x;
if (o->y & 1) {
if (o->y == -1)
- o->y = m_height - 1;
- o->x = (o->x ? o->x : m_width) - 1;
+ o->y = height_ - 1;
+ o->x = (o->x ? o->x : width_) - 1;
}
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
+ assert(o->y < height_);
}
inline void Map::get_tln(const FCoords & f, FCoords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert(f.field < m_fields.get() + max_index());
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert(f.field < fields_.get() + max_index());
o->y = f.y - 1;
o->x = f.x;
- o->field = f.field - m_width;
+ o->field = f.field - width_;
if (o->y & 1) {
if (o->y == -1) {
- o->y = m_height - 1;
+ o->y = height_ - 1;
o->field += max_index();
}
--o->x;
--o->field;
if (o->x == -1) {
- o->x = m_width - 1;
- o->field += m_width;
+ o->x = width_ - 1;
+ o->field += width_;
}
}
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
- assert(m_fields.get() <= o->field);
- assert(o->field < m_fields.get() + max_index());
+ assert(o->y < height_);
+ assert(fields_.get() <= o->field);
+ assert(o->field < fields_.get() + max_index());
}
inline Coords Map::tl_n(const Coords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
Coords result(f.x, f.y - 1);
if (result.y & 1) {
if (result.y == -1)
- result.y = m_height - 1;
+ result.y = height_ - 1;
--result.x;
if (result.x == -1)
- result.x = m_width - 1;
+ result.x = width_ - 1;
}
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
+ assert(result.y < height_);
return result;
}
inline FCoords Map::tl_n(const FCoords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert(f.field < m_fields.get() + max_index());
- FCoords result(Coords(f.x, f.y - 1), f.field - m_width);
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert(f.field < fields_.get() + max_index());
+ FCoords result(Coords(f.x, f.y - 1), f.field - width_);
if (result.y & 1) {
if (result.y == -1) {
- result.y = m_height - 1;
+ result.y = height_ - 1;
result.field += max_index();
}
--result.x;
--result.field;
if (result.x == -1) {
- result.x = m_width - 1;
- result.field += m_width;
+ result.x = width_ - 1;
+ result.field += width_;
}
}
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
- assert(m_fields.get() <= result.field);
- assert(result.field < m_fields.get() + max_index());
+ assert(result.y < height_);
+ assert(fields_.get() <= result.field);
+ assert(result.field < fields_.get() + max_index());
return result;
}
@@ -787,97 +787,97 @@
inline void Map::get_trn(const Coords & f, Coords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
o->x = f.x;
if (f.y & 1) {
++o->x;
- if (o->x == m_width)
+ if (o->x == width_)
o->x = 0;
}
- o->y = (f.y ? f.y : m_height) - 1;
+ o->y = (f.y ? f.y : height_) - 1;
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
+ assert(o->y < height_);
}
inline void Map::get_trn(const FCoords & f, FCoords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert(f.field < m_fields.get() + max_index());
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert(f.field < fields_.get() + max_index());
o->x = f.x;
- o->field = f.field - m_width;
+ o->field = f.field - width_;
if (f.y & 1) {
++o->x;
++o->field;
- if (o->x == m_width) {
+ if (o->x == width_) {
o->x = 0;
- o->field -= m_width;
+ o->field -= width_;
}
}
o->y = f.y - 1;
if (o->y == -1) {
- o->y = m_height - 1;
+ o->y = height_ - 1;
o->field += max_index();
}
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
- assert(m_fields.get() <= o->field);
- assert(o->field < m_fields.get() + max_index());
+ assert(o->y < height_);
+ assert(fields_.get() <= o->field);
+ assert(o->field < fields_.get() + max_index());
}
inline Coords Map::tr_n(const Coords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
Coords result(f.x, f.y - 1);
if (f.y & 1) {
++result.x;
- if (result.x == m_width)
+ if (result.x == width_)
result.x = 0;
}
if (result.y == -1)
- result.y = m_height - 1;
+ result.y = height_ - 1;
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
+ assert(result.y < height_);
return result;
}
inline FCoords Map::tr_n(const FCoords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert(f.field < m_fields.get() + max_index());
- FCoords result(Coords(f.x, f.y - 1), f.field - m_width);
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert(f.field < fields_.get() + max_index());
+ FCoords result(Coords(f.x, f.y - 1), f.field - width_);
if (f.y & 1) {
++result.x;
++result.field;
- if (result.x == m_width) {
+ if (result.x == width_) {
result.x = 0;
- result.field -= m_width;
+ result.field -= width_;
}
}
if (result.y == -1) {
- result.y = m_height - 1;
+ result.y = height_ - 1;
result.field += max_index();
}
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
- assert(m_fields.get() <= result.field);
- assert(result.field < m_fields.get() + max_index());
+ assert(result.y < height_);
+ assert(fields_.get() <= result.field);
+ assert(result.field < fields_.get() + max_index());
return result;
}
@@ -885,33 +885,33 @@
inline void Map::get_bln(const Coords & f, Coords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
o->y = f.y + 1;
o->x = f.x;
- if (o->y == m_height)
+ if (o->y == height_)
o->y = 0;
if (o->y & 1)
- o->x = (o->x ? o->x : m_width) - 1;
+ o->x = (o->x ? o->x : width_) - 1;
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
+ assert(o->y < height_);
}
inline void Map::get_bln(const FCoords & f, FCoords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert(f.field < m_fields.get() + max_index());
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert(f.field < fields_.get() + max_index());
o->y = f.y + 1;
o->x = f.x;
- o->field = f.field + m_width;
- if (o->y == m_height) {
+ o->field = f.field + width_;
+ if (o->y == height_) {
o->y = 0;
o->field -= max_index();
}
@@ -919,45 +919,45 @@
--o->x;
--o->field;
if (o->x == -1) {
- o->x = m_width - 1;
- o->field += m_width;
+ o->x = width_ - 1;
+ o->field += width_;
}
}
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
- assert(m_fields.get() <= o->field);
- assert(o->field < m_fields.get() + max_index());
+ assert(o->y < height_);
+ assert(fields_.get() <= o->field);
+ assert(o->field < fields_.get() + max_index());
}
inline Coords Map::bl_n(const Coords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
Coords result(f.x, f.y + 1);
- if (result.y == m_height)
+ if (result.y == height_)
result.y = 0;
if (result.y & 1) {
--result.x;
if (result.x == -1)
- result.x = m_width - 1;
+ result.x = width_ - 1;
}
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
+ assert(result.y < height_);
return result;
}
inline FCoords Map::bl_n(const FCoords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert(f.field < m_fields.get() + max_index());
- FCoords result(Coords(f.x, f.y + 1), f.field + m_width);
- if (result.y == m_height) {
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert(f.field < fields_.get() + max_index());
+ FCoords result(Coords(f.x, f.y + 1), f.field + width_);
+ if (result.y == height_) {
result.y = 0;
result.field -= max_index();
}
@@ -965,16 +965,16 @@
--result.x;
--result.field;
if (result.x == -1) {
- result.x = m_width - 1;
- result.field += m_width;
+ result.x = width_ - 1;
+ result.field += width_;
}
}
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
- assert(m_fields.get() <= result.field);
- assert(result.field < m_fields.get() + max_index());
+ assert(result.y < height_);
+ assert(fields_.get() <= result.field);
+ assert(result.field < fields_.get() + max_index());
return result;
}
@@ -982,99 +982,99 @@
inline void Map::get_brn(const Coords & f, Coords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
o->x = f.x;
if (f.y & 1) {
++o->x;
- if (o->x == m_width)
+ if (o->x == width_)
o->x = 0;
}
o->y = f.y + 1;
- if (o->y == m_height)
+ if (o->y == height_)
o->y = 0;
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
+ assert(o->y < height_);
}
inline void Map::get_brn(const FCoords & f, FCoords * const o) const
{
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert(f.field < m_fields.get() + max_index());
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert(f.field < fields_.get() + max_index());
o->x = f.x;
- o->field = f.field + m_width;
+ o->field = f.field + width_;
if (f.y & 1) {
++o->x;
++o->field;
- if (o->x == m_width) {
+ if (o->x == width_) {
o->x = 0;
- o->field -= m_width;
+ o->field -= width_;
}
}
o->y = f.y + 1;
- if (o->y == m_height) {
+ if (o->y == height_) {
o->y = 0;
o->field -= max_index();
}
assert(0 <= o->x);
- assert(o->x < m_width);
+ assert(o->x < width_);
assert(0 <= o->y);
- assert(o->y < m_height);
- assert(m_fields.get() <= o->field);
- assert(o->field < m_fields.get() + max_index());
+ assert(o->y < height_);
+ assert(fields_.get() <= o->field);
+ assert(o->field < fields_.get() + max_index());
}
inline Coords Map::br_n(const Coords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
+ assert(f.y < height_);
Coords result(f.x, f.y + 1);
if (f.y & 1) {
++result.x;
- if (result.x == m_width)
+ if (result.x == width_)
result.x = 0;
}
- if (result.y == m_height)
+ if (result.y == height_)
result.y = 0;
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
+ assert(result.y < height_);
return result;
}
inline FCoords Map::br_n(const FCoords & f) const {
assert(0 <= f.x);
- assert(f.x < m_width);
+ assert(f.x < width_);
assert(0 <= f.y);
- assert(f.y < m_height);
- assert(m_fields.get() <= f.field);
- assert(f.field < m_fields.get() + max_index());
- FCoords result(Coords(f.x, f.y + 1), f.field + m_width);
+ assert(f.y < height_);
+ assert(fields_.get() <= f.field);
+ assert(f.field < fields_.get() + max_index());
+ FCoords result(Coords(f.x, f.y + 1), f.field + width_);
if (f.y & 1) {
++result.x;
++result.field;
- if (result.x == m_width) {
+ if (result.x == width_) {
result.x = 0;
- result.field -= m_width;
+ result.field -= width_;
}
}
- if (result.y == m_height) {
+ if (result.y == height_) {
result.y = 0;
result.field -= max_index();
}
assert(0 <= result.x);
- assert(result.x < m_width);
+ assert(result.x < width_);
assert(0 <= result.y);
- assert(result.y < m_height);
- assert(m_fields.get() <= result.field);
- assert(result.field < m_fields.get() + max_index());
+ assert(result.y < height_);
+ assert(fields_.get() <= result.field);
+ assert(result.field < fields_.get() + max_index());
return result;
}
=== modified file 'src/logic/map_objects/tribes/ship.cc'
--- src/logic/map_objects/tribes/ship.cc 2016-02-11 06:50:56 +0000
+++ src/logic/map_objects/tribes/ship.cc 2016-02-16 14:25:27 +0000
@@ -109,9 +109,9 @@
i18n::Textdomain td("tribes");
// Read the sailing animations
- add_directional_animation(&m_sail_anims, "sail");
+ add_directional_animation(&sail_anims_, "sail");
- m_capacity = table.has_key("capacity") ? table.get_int("capacity") : 20;
+ capacity_ = table.has_key("capacity") ? table.get_int("capacity") : 20;
}
uint32_t ShipDescr::movecaps() const {
@@ -123,7 +123,7 @@
}
Ship::Ship(const ShipDescr& gdescr)
- : Bob(gdescr), m_window(nullptr), m_fleet(nullptr), m_economy(nullptr), m_ship_state(TRANSPORT) {
+ : Bob(gdescr), window_(nullptr), fleet_(nullptr), economy_(nullptr), ship_state_(TRANSPORT) {
}
Ship::~Ship() {
@@ -131,15 +131,15 @@
}
PortDock* Ship::get_destination(EditorGameBase& egbase) const {
- return m_destination.get(egbase);
+ return destination_.get(egbase);
}
PortDock* Ship::get_lastdock(EditorGameBase& egbase) const {
- return m_lastdock.get(egbase);
+ return lastdock_.get(egbase);
}
Fleet* Ship::get_fleet() const {
- return m_fleet;
+ return fleet_;
}
void Ship::init_auto_task(Game& game) {
@@ -153,8 +153,8 @@
assert(get_owner());
// Assigning a ship name
- m_shipname = get_owner()->pick_shipname();
- molog("New ship: %s\n", m_shipname.c_str());
+ shipname_ = get_owner()->pick_shipname();
+ molog("New ship: %s\n", shipname_.c_str());
}
/**
@@ -171,8 +171,8 @@
}
void Ship::cleanup(EditorGameBase& egbase) {
- if (m_fleet) {
- m_fleet->remove_ship(egbase, this);
+ if (fleet_) {
+ fleet_->remove_ship(egbase, this);
}
while (!items_.empty()) {
@@ -189,7 +189,7 @@
* This function is to be called only by @ref Fleet.
*/
void Ship::set_fleet(Fleet* fleet) {
- m_fleet = fleet;
+ fleet_ = fleet;
}
void Ship::wakeup_neighbours(Game& game) {
@@ -237,7 +237,7 @@
signal_handled();
} else if (signal == "cancel_expedition") {
pop_task(game);
- PortDock* dst = m_fleet->get_arbitrary_dock();
+ PortDock* dst = fleet_->get_arbitrary_dock();
// TODO(sirver): What happens if there is no port anymore?
if (dst) {
start_task_movetodock(game, *dst);
@@ -252,7 +252,7 @@
}
}
- switch (m_ship_state) {
+ switch (ship_state_) {
case TRANSPORT:
if (ship_update_transport(game, state))
return;
@@ -266,7 +266,7 @@
break;
case SINK_REQUEST:
if (descr().is_animation_known("sinking")) {
- m_ship_state = SINK_ANIMATION;
+ ship_state_ = SINK_ANIMATION;
start_task_idle(game, descr().get_animation("sinking"), 3000);
return;
}
@@ -297,8 +297,8 @@
FCoords position = map.get_fcoords(get_position());
if (position.field->get_immovable() == dst) {
molog("ship_update: Arrived at dock %u\n", dst->serial());
- m_lastdock = dst;
- m_destination = nullptr;
+ lastdock_ = dst;
+ destination_ = nullptr;
dst->ship_arrived(game, *this);
start_task_idle(game, descr().main_animation(), 250);
return true;
@@ -306,12 +306,12 @@
molog("ship_update: Go to dock %u\n", dst->serial());
- PortDock* lastdock = m_lastdock.get(game);
+ PortDock* lastdock = lastdock_.get(game);
if (lastdock && lastdock != dst) {
molog("ship_update: Have lastdock %u\n", lastdock->serial());
Path path;
- if (m_fleet->get_path(*lastdock, *dst, path)) {
+ if (fleet_->get_path(*lastdock, *dst, path)) {
uint32_t closest_idx = std::numeric_limits<uint32_t>::max();
uint32_t closest_dist = std::numeric_limits<uint32_t>::max();
Coords closest_target(Coords::null());
@@ -354,7 +354,7 @@
}
}
- m_lastdock = nullptr;
+ lastdock_ = nullptr;
}
start_task_movetodock(game, *dst);
@@ -365,16 +365,16 @@
void Ship::ship_update_expedition(Game& game, Bob::State&) {
Map& map = game.map();
- assert(m_expedition);
+ assert(expedition_);
// Update the knowledge of the surrounding fields
FCoords position = get_position();
for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) {
- m_expedition->swimable[dir - 1] =
+ expedition_->swimable[dir - 1] =
map.get_neighbour(position, dir).field->nodecaps() & MOVECAPS_SWIM;
}
- if (m_ship_state == EXP_SCOUTING) {
+ if (ship_state_ == EXP_SCOUTING) {
// Check surrounding fields for port buildspaces
std::vector<Coords> temp_port_buildspaces;
MapRegion<Area<Coords>> mr(map, Area<Coords>(position, descr().vision_range()));
@@ -398,9 +398,9 @@
}
// Check if the ship knows this port space already from its last check
- if (std::find(m_expedition->seen_port_buildspaces.begin(),
- m_expedition->seen_port_buildspaces.end(),
- mr.location()) != m_expedition->seen_port_buildspaces.end()) {
+ if (std::find(expedition_->seen_port_buildspaces.begin(),
+ expedition_->seen_port_buildspaces.end(),
+ mr.location()) != expedition_->seen_port_buildspaces.end()) {
temp_port_buildspaces.push_back(mr.location());
} else {
new_port_space = true;
@@ -409,7 +409,7 @@
} while (mr.advance(map));
if (new_port_space) {
- m_ship_state = EXP_FOUNDPORTSPACE;
+ ship_state_ = EXP_FOUNDPORTSPACE;
send_message(
game,
_("Port Space"),
@@ -417,7 +417,7 @@
_("An expedition ship found a new port build space."),
"images/wui/editor/fsel_editor_set_port_space.png");
}
- m_expedition->seen_port_buildspaces = temp_port_buildspaces;
+ expedition_->seen_port_buildspaces = temp_port_buildspaces;
if (new_port_space) {
Notifications::publish(
NoteShipMessage(this, NoteShipMessage::Message::kWaitingForCommand));
@@ -438,7 +438,7 @@
// If we are waiting for the next transport job, check if we should move away from ships and
// shores
- switch (m_ship_state) {
+ switch (ship_state_) {
case TRANSPORT: {
FCoords position = get_position();
Map& map = game.map();
@@ -514,22 +514,22 @@
}
case EXP_SCOUTING: {
- if (m_expedition->island_exploration) { // Exploration of the island
+ if (expedition_->island_exploration) { // Exploration of the island
if (exp_close_to_coast()) {
- if (m_expedition->scouting_direction == WalkingDir::IDLE) {
+ if (expedition_->scouting_direction == WalkingDir::IDLE) {
// Make sure we know the location of the coast and use it as initial direction we
// come from
- m_expedition->scouting_direction = WALK_SE;
- for (uint8_t secure = 0; exp_dir_swimable(m_expedition->scouting_direction); ++secure) {
+ expedition_->scouting_direction = WALK_SE;
+ for (uint8_t secure = 0; exp_dir_swimable(expedition_->scouting_direction); ++secure) {
assert(secure < 6);
- m_expedition->scouting_direction = get_cw_neighbour(m_expedition->scouting_direction);
+ expedition_->scouting_direction = get_cw_neighbour(expedition_->scouting_direction);
}
- m_expedition->scouting_direction = get_backward_dir(m_expedition->scouting_direction);
+ expedition_->scouting_direction = get_backward_dir(expedition_->scouting_direction);
// Save the position - this is where we start
- m_expedition->exploration_start = get_position();
+ expedition_->exploration_start = get_position();
} else {
// Check whether the island was completely surrounded
- if (get_position() == m_expedition->exploration_start) {
+ if (get_position() == expedition_->exploration_start) {
send_message(
game,
/** TRANSLATORS: A ship has circumnavigated an island and is waiting for orders */
@@ -537,7 +537,7 @@
_("Island Circumnavigated"),
_("An expedition ship sailed around its island without any events."),
"images/wui/ship/ship_explore_island_cw.png");
- m_ship_state = EXP_WAITING;
+ ship_state_ = EXP_WAITING;
Notifications::publish(
NoteShipMessage(this, NoteShipMessage::Message::kWaitingForCommand));
@@ -548,18 +548,18 @@
// The ship is supposed to follow the coast as close as possible, therefore the check
// for
// a swimable field begins at the neighbour field of the direction we came from.
- m_expedition->scouting_direction = get_backward_dir(m_expedition->scouting_direction);
- if (m_expedition->island_explore_direction == IslandExploreDirection::kClockwise) {
+ expedition_->scouting_direction = get_backward_dir(expedition_->scouting_direction);
+ if (expedition_->island_explore_direction == IslandExploreDirection::kClockwise) {
do {
- m_expedition->scouting_direction = get_ccw_neighbour(m_expedition->scouting_direction);
- } while (!exp_dir_swimable(m_expedition->scouting_direction));
+ expedition_->scouting_direction = get_ccw_neighbour(expedition_->scouting_direction);
+ } while (!exp_dir_swimable(expedition_->scouting_direction));
} else {
do {
- m_expedition->scouting_direction = get_cw_neighbour(m_expedition->scouting_direction);
- } while (!exp_dir_swimable(m_expedition->scouting_direction));
+ expedition_->scouting_direction = get_cw_neighbour(expedition_->scouting_direction);
+ } while (!exp_dir_swimable(expedition_->scouting_direction));
}
state.ivar1 = 1;
- return start_task_move(game, m_expedition->scouting_direction, descr().get_sail_anims(), false);
+ return start_task_move(game, expedition_->scouting_direction, descr().get_sail_anims(), false);
} else {
// The ship got the command to scout around an island, but is not close to any island
// Most likely the command was send as the ship was on an exploration and just leaving
@@ -580,18 +580,18 @@
}
// if we are here, it seems something really strange happend.
log("WARNING: ship was not able to start exploration. Entering WAIT mode.");
- m_ship_state = EXP_WAITING;
+ ship_state_ = EXP_WAITING;
return start_task_idle(game, descr().main_animation(), 1500);
}
} else { // scouting towards a specific direction
- if (exp_dir_swimable(m_expedition->scouting_direction)) {
+ if (exp_dir_swimable(expedition_->scouting_direction)) {
// the scouting direction is still free to move
state.ivar1 = 1;
- start_task_move(game, m_expedition->scouting_direction, descr().get_sail_anims(), false);
+ start_task_move(game, expedition_->scouting_direction, descr().get_sail_anims(), false);
return;
}
// coast reached
- m_ship_state = EXP_WAITING;
+ ship_state_ = EXP_WAITING;
start_task_idle(game, descr().main_animation(), 1500);
// Send a message to the player, that a new coast was reached
send_message(
@@ -609,8 +609,8 @@
}
}
case EXP_COLONIZING: {
- assert(!m_expedition->seen_port_buildspaces.empty());
- BaseImmovable* baim = game.map()[m_expedition->seen_port_buildspaces.front()].get_immovable();
+ assert(!expedition_->seen_port_buildspaces.empty());
+ BaseImmovable* baim = game.map()[expedition_->seen_port_buildspaces.front()].get_immovable();
if (baim) {
upcast(ConstructionSite, cs, baim);
@@ -667,7 +667,7 @@
}
if (items_.empty() || !baim) { // we are done, either way
- m_ship_state = TRANSPORT; // That's it, expedition finished
+ ship_state_ = TRANSPORT; // That's it, expedition finished
// Bring us back into a fleet and a economy.
init_fleet(game);
@@ -683,7 +683,7 @@
}
}
- m_expedition.reset(nullptr);
+ expedition_.reset(nullptr);
if (upcast(InteractiveGameBase, igb, game.get_ibase()))
refresh_window(*igb);
@@ -704,7 +704,7 @@
// Do not check here that the economy actually changed, because on loading
// we rely that wares really get reassigned our economy.
- m_economy = e;
+ economy_ = e;
for (ShippingItem& shipping_item : items_) {
shipping_item.set_economy(game, e);
}
@@ -718,7 +718,7 @@
void Ship::set_destination(Game& game, PortDock& pd) {
molog("set_destination / sending to portdock %u (carrying %" PRIuS " items)\n",
pd.serial(), items_.size());
- m_destination = &pd;
+ destination_ = &pd;
send_signal(game, "wakeup");
}
@@ -806,22 +806,22 @@
/// Prepare everything for the coming exploration
void Ship::start_task_expedition(Game& game) {
// Now we are waiting
- m_ship_state = EXP_WAITING;
+ ship_state_ = EXP_WAITING;
// Initialize a new, yet empty expedition
- m_expedition.reset(new Expedition());
- m_expedition->seen_port_buildspaces.clear();
- m_expedition->island_exploration = false;
- m_expedition->scouting_direction = WalkingDir::IDLE;
- m_expedition->exploration_start = Coords(0, 0);
- m_expedition->island_explore_direction = IslandExploreDirection::kClockwise;
- m_expedition->economy.reset(new Economy(*get_owner()));
+ expedition_.reset(new Expedition());
+ expedition_->seen_port_buildspaces.clear();
+ expedition_->island_exploration = false;
+ expedition_->scouting_direction = WalkingDir::IDLE;
+ expedition_->exploration_start = Coords(0, 0);
+ expedition_->island_explore_direction = IslandExploreDirection::kClockwise;
+ expedition_->economy.reset(new Economy(*get_owner()));
// We are no longer in any other economy, but instead are an economy of our
// own.
- m_fleet->remove_ship(game, this);
- assert(m_fleet == nullptr);
+ fleet_->remove_ship(game, this);
+ assert(fleet_ == nullptr);
- set_economy(game, m_expedition->economy.get());
+ set_economy(game, expedition_->economy.get());
for (int i = items_.size() - 1; i >= 0; --i) {
WareInstance* ware;
@@ -849,15 +849,15 @@
/// Initializes / changes the direction of scouting to @arg direction
/// @note only called via player command
void Ship::exp_scouting_direction(Game&, WalkingDir scouting_direction) {
- assert(m_expedition);
- m_ship_state = EXP_SCOUTING;
- m_expedition->scouting_direction = scouting_direction;
- m_expedition->island_exploration = false;
+ assert(expedition_);
+ ship_state_ = EXP_SCOUTING;
+ expedition_->scouting_direction = scouting_direction;
+ expedition_->island_exploration = false;
}
WalkingDir Ship::get_scouting_direction() {
- if (m_expedition && m_ship_state == EXP_SCOUTING && !m_expedition->island_exploration) {
- return m_expedition->scouting_direction;
+ if (expedition_ && ship_state_ == EXP_SCOUTING && !expedition_->island_exploration) {
+ return expedition_->scouting_direction;
}
return WalkingDir::IDLE;
}
@@ -865,25 +865,25 @@
/// Initializes the construction of a port at @arg c
/// @note only called via player command
void Ship::exp_construct_port(Game&, const Coords& c) {
- assert(m_expedition);
+ assert(expedition_);
DescriptionIndex port_idx = get_owner()->tribe().port();
get_owner()->force_csite(c, port_idx);
- m_ship_state = EXP_COLONIZING;
+ ship_state_ = EXP_COLONIZING;
}
/// Initializes / changes the direction the island exploration in @arg island_explore_direction direction
/// @note only called via player command
void Ship::exp_explore_island(Game&, IslandExploreDirection island_explore_direction) {
- assert(m_expedition);
- m_ship_state = EXP_SCOUTING;
- m_expedition->island_explore_direction = island_explore_direction;
- m_expedition->scouting_direction = WalkingDir::IDLE;
- m_expedition->island_exploration = true;
+ assert(expedition_);
+ ship_state_ = EXP_SCOUTING;
+ expedition_->island_explore_direction = island_explore_direction;
+ expedition_->scouting_direction = WalkingDir::IDLE;
+ expedition_->island_exploration = true;
}
IslandExploreDirection Ship::get_island_explore_direction() {
- if (m_expedition && m_ship_state == EXP_SCOUTING && m_expedition->island_exploration) {
- return m_expedition->island_explore_direction;
+ if (expedition_ && ship_state_ == EXP_SCOUTING && expedition_->island_exploration) {
+ return expedition_->island_explore_direction;
}
return IslandExploreDirection::kNotSet;
}
@@ -895,7 +895,7 @@
// Running colonization has the highest priority before cancelation
// + cancelation only works if an expedition is actually running
- if ((m_ship_state == EXP_COLONIZING) || !state_is_expedition())
+ if ((ship_state_ == EXP_COLONIZING) || !state_is_expedition())
return;
send_signal(game, "cancel_expedition");
@@ -914,15 +914,15 @@
worker->start_task_shipping(game, nullptr);
}
}
- m_ship_state = TRANSPORT;
+ ship_state_ = TRANSPORT;
// Bring us back into a fleet and a economy.
set_economy(game, nullptr);
init_fleet(game);
- assert(get_economy() && get_economy() != m_expedition->economy.get());
+ assert(get_economy() && get_economy() != expedition_->economy.get());
// Delete the expedition and the economy it created.
- m_expedition.reset(nullptr);
+ expedition_.reset(nullptr);
// And finally update our ship window
if (upcast(InteractiveGameBase, igb, game.get_ibase()))
@@ -935,7 +935,7 @@
// Running colonization has the highest priority + a sink request is only valid once
if (!state_is_sinkable())
return;
- m_ship_state = SINK_REQUEST;
+ ship_state_ = SINK_REQUEST;
// Make sure the ship is active and close possible open windows
ship_wakeup(game);
close_window();
@@ -945,9 +945,9 @@
Bob::log_general_info(egbase);
molog("Fleet: %u, destination: %u, lastdock: %u, carrying: %" PRIuS "\n",
- m_fleet ? m_fleet->serial() : 0,
- m_destination.serial(),
- m_lastdock.serial(),
+ fleet_ ? fleet_->serial() : 0,
+ destination_.serial(),
+ lastdock_.serial(),
items_.size());
for (const ShippingItem& shipping_item : items_) {
@@ -1005,7 +1005,7 @@
constexpr uint8_t kCurrentPacketVersion = 6;
-Ship::Loader::Loader() : m_lastdock(0), m_destination(0) {
+Ship::Loader::Loader() : lastdock_(0), destination_(0) {
}
const Bob::Task* Ship::Loader::get_task(const std::string& name) {
@@ -1019,38 +1019,38 @@
Bob::Loader::load(fr);
// The state the ship is in
- m_ship_state = fr.unsigned_8();
+ ship_state_ = fr.unsigned_8();
// Expedition specific data
- if (m_ship_state == EXP_SCOUTING || m_ship_state == EXP_WAITING ||
- m_ship_state == EXP_FOUNDPORTSPACE || m_ship_state == EXP_COLONIZING) {
- m_expedition.reset(new Expedition());
+ if (ship_state_ == EXP_SCOUTING || ship_state_ == EXP_WAITING ||
+ ship_state_ == EXP_FOUNDPORTSPACE || ship_state_ == EXP_COLONIZING) {
+ expedition_.reset(new Expedition());
// Currently seen port build spaces
- m_expedition->seen_port_buildspaces.clear();
+ expedition_->seen_port_buildspaces.clear();
uint8_t numofports = fr.unsigned_8();
for (uint8_t i = 0; i < numofports; ++i)
- m_expedition->seen_port_buildspaces.push_back(read_coords_32(&fr));
+ expedition_->seen_port_buildspaces.push_back(read_coords_32(&fr));
// Swimability of the directions
for (uint8_t i = 0; i < LAST_DIRECTION; ++i)
- m_expedition->swimable[i] = (fr.unsigned_8() == 1);
+ expedition_->swimable[i] = (fr.unsigned_8() == 1);
// whether scouting or exploring
- m_expedition->island_exploration = fr.unsigned_8() == 1;
+ expedition_->island_exploration = fr.unsigned_8() == 1;
// current direction
- m_expedition->scouting_direction = static_cast<WalkingDir>(fr.unsigned_8());
+ expedition_->scouting_direction = static_cast<WalkingDir>(fr.unsigned_8());
// Start coordinates of an island exploration
- m_expedition->exploration_start = read_coords_32(&fr);
+ expedition_->exploration_start = read_coords_32(&fr);
// Whether the exploration is done clockwise or counter clockwise
- m_expedition->island_explore_direction = static_cast<IslandExploreDirection>(fr.unsigned_8());
+ expedition_->island_explore_direction = static_cast<IslandExploreDirection>(fr.unsigned_8());
} else {
- m_ship_state = TRANSPORT;
+ ship_state_ = TRANSPORT;
}
- m_shipname = fr.c_string();
- m_lastdock = fr.unsigned_32();
- m_destination = fr.unsigned_32();
+ shipname_ = fr.c_string();
+ lastdock_ = fr.unsigned_32();
+ destination_ = fr.unsigned_32();
- m_items.resize(fr.unsigned_32());
- for (ShippingItem::Loader& item_loader : m_items) {
+ items_.resize(fr.unsigned_32());
+ for (ShippingItem::Loader& item_loader : items_) {
item_loader.load(fr);
}
}
@@ -1060,14 +1060,14 @@
Ship& ship = get<Ship>();
- if (m_lastdock)
- ship.m_lastdock = &mol().get<PortDock>(m_lastdock);
- if (m_destination)
- ship.m_destination = &mol().get<PortDock>(m_destination);
+ if (lastdock_)
+ ship.lastdock_ = &mol().get<PortDock>(lastdock_);
+ if (destination_)
+ ship.destination_ = &mol().get<PortDock>(destination_);
- ship.items_.resize(m_items.size());
- for (uint32_t i = 0; i < m_items.size(); ++i) {
- ship.items_[i] = m_items[i].get(mol());
+ ship.items_.resize(items_.size());
+ for (uint32_t i = 0; i < items_.size(); ++i) {
+ ship.items_[i] = items_[i].get(mol());
}
}
@@ -1077,18 +1077,18 @@
Ship& ship = get<Ship>();
// restore the state the ship is in
- ship.m_ship_state = m_ship_state;
+ ship.ship_state_ = ship_state_;
// restore the ship id and name
- ship.m_shipname = m_shipname;
+ ship.shipname_ = shipname_;
// if the ship is on an expedition, restore the expedition specific data
- if (m_expedition) {
- ship.m_expedition.swap(m_expedition);
- ship.m_expedition->economy.reset(new Economy(*ship.get_owner()));
- ship.m_economy = ship.m_expedition->economy.get();
+ if (expedition_) {
+ ship.expedition_.swap(expedition_);
+ ship.expedition_->economy.reset(new Economy(*ship.get_owner()));
+ ship.economy_ = ship.expedition_->economy.get();
} else
- assert(m_ship_state == TRANSPORT);
+ assert(ship_state_ == TRANSPORT);
// Workers load code set their economy to the economy of their location
// (which is a PlayerImmovable), that means that workers on ships do not get
@@ -1096,7 +1096,7 @@
// economy of all workers we're transporting so that they are in the correct
// economy. Also, we might are on an expedition which means that we just now
// created the economy of this ship and must inform all wares.
- ship.set_economy(dynamic_cast<Game&>(egbase()), ship.m_economy);
+ ship.set_economy(dynamic_cast<Game&>(egbase()), ship.economy_);
}
MapObject::Loader* Ship::load(EditorGameBase& egbase, MapObjectLoader& mol, FileRead& fr) {
@@ -1146,31 +1146,31 @@
Bob::save(egbase, mos, fw);
// state the ship is in
- fw.unsigned_8(m_ship_state);
+ fw.unsigned_8(ship_state_);
// expedition specific data
if (state_is_expedition()) {
// currently seen port buildspaces
- fw.unsigned_8(m_expedition->seen_port_buildspaces.size());
- for (const Coords& coords : m_expedition->seen_port_buildspaces) {
+ fw.unsigned_8(expedition_->seen_port_buildspaces.size());
+ for (const Coords& coords : expedition_->seen_port_buildspaces) {
write_coords_32(&fw, coords);
}
// swimability of the directions
for (uint8_t i = 0; i < LAST_DIRECTION; ++i)
- fw.unsigned_8(m_expedition->swimable[i] ? 1 : 0);
+ fw.unsigned_8(expedition_->swimable[i] ? 1 : 0);
// whether scouting or exploring
- fw.unsigned_8(m_expedition->island_exploration ? 1 : 0);
+ fw.unsigned_8(expedition_->island_exploration ? 1 : 0);
// current direction
- fw.unsigned_8(static_cast<uint8_t>(m_expedition->scouting_direction));
+ fw.unsigned_8(static_cast<uint8_t>(expedition_->scouting_direction));
// Start coordinates of an island exploration
- write_coords_32(&fw, m_expedition->exploration_start);
+ write_coords_32(&fw, expedition_->exploration_start);
// Whether the exploration is done clockwise or counter clockwise
- fw.unsigned_8(static_cast<uint8_t>(m_expedition->island_explore_direction));
+ fw.unsigned_8(static_cast<uint8_t>(expedition_->island_explore_direction));
}
- fw.string(m_shipname);
- 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.string(shipname_);
+ fw.unsigned_32(mos.get_object_file_index_or_zero(lastdock_.get(egbase)));
+ fw.unsigned_32(mos.get_object_file_index_or_zero(destination_.get(egbase)));
fw.unsigned_32(items_.size());
for (ShippingItem& shipping_item : items_) {
=== modified file 'src/logic/map_objects/tribes/ship.h'
--- src/logic/map_objects/tribes/ship.h 2016-02-08 20:45:24 +0000
+++ src/logic/map_objects/tribes/ship.h 2016-02-16 14:25:27 +0000
@@ -65,13 +65,13 @@
Bob & create_object() const override;
uint32_t movecaps() const override;
- const DirAnimations & get_sail_anims() const {return m_sail_anims;}
+ const DirAnimations & get_sail_anims() const {return sail_anims_;}
- uint32_t get_capacity() const {return m_capacity;}
+ uint32_t get_capacity() const {return capacity_;}
private:
- DirAnimations m_sail_anims;
- uint32_t m_capacity;
+ DirAnimations sail_anims_;
+ uint32_t capacity_;
DISALLOW_COPY_AND_ASSIGN(ShipDescr);
};
@@ -97,7 +97,7 @@
// the last visited was removed.
PortDock* get_lastdock(EditorGameBase& egbase) const;
- Economy * get_economy() const {return m_economy;}
+ Economy * get_economy() const {return economy_;}
void set_economy(Game &, Economy * e);
void set_destination(Game &, PortDock &);
@@ -151,54 +151,54 @@
};
/// \returns the current state the ship is in
- uint8_t get_ship_state() {return m_ship_state;}
+ uint8_t get_ship_state() {return ship_state_;}
/// \returns the current name of ship
- const std::string & get_shipname() {return m_shipname;}
+ const std::string & get_shipname() {return shipname_;}
/// \returns whether the ship is currently on an expedition
bool state_is_expedition() {
return
- (m_ship_state == EXP_SCOUTING
- ||
- m_ship_state == EXP_WAITING
- ||
- m_ship_state == EXP_FOUNDPORTSPACE
- ||
- m_ship_state == EXP_COLONIZING);
+ (ship_state_ == EXP_SCOUTING
+ ||
+ ship_state_ == EXP_WAITING
+ ||
+ ship_state_ == EXP_FOUNDPORTSPACE
+ ||
+ ship_state_ == EXP_COLONIZING);
}
/// \returns whether the ship is in transport mode
- bool state_is_transport() {return (m_ship_state == TRANSPORT);}
+ bool state_is_transport() {return (ship_state_ == TRANSPORT);}
/// \returns whether a sink request for the ship is currently valid
bool state_is_sinkable() {
return
- (m_ship_state != SINK_REQUEST
- &&
- m_ship_state != SINK_ANIMATION
- &&
- m_ship_state != EXP_COLONIZING);
+ (ship_state_ != SINK_REQUEST
+ &&
+ ship_state_ != SINK_ANIMATION
+ &&
+ ship_state_ != EXP_COLONIZING);
}
/// \returns (in expedition mode only!) whether the next field in direction \arg dir is swimable
bool exp_dir_swimable(Direction dir) {
- if (!m_expedition)
+ if (!expedition_)
return false;
- return m_expedition->swimable[dir - 1];
+ return expedition_->swimable[dir - 1];
}
/// \returns whether the expedition ship is close to the coast
bool exp_close_to_coast() {
- if (!m_expedition)
+ if (!expedition_)
return false;
for (uint8_t dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir)
- if (!m_expedition->swimable[dir - 1])
+ if (!expedition_->swimable[dir - 1])
return true;
return false;
}
/// \returns (in expedition mode only!) the list of currently seen port build spaces
const std::vector<Coords>& exp_port_spaces() {
- return m_expedition->seen_port_buildspaces;
+ return expedition_->seen_port_buildspaces;
}
void exp_scouting_direction(Game &, WalkingDir);
@@ -241,15 +241,15 @@
const std::string& description,
const std::string& picture);
- UI::Window * m_window;
+ UI::Window * window_;
- Fleet * m_fleet;
- Economy * m_economy;
- OPtr<PortDock> m_lastdock;
- OPtr<PortDock> m_destination;
+ Fleet * fleet_;
+ Economy * economy_;
+ OPtr<PortDock> lastdock_;
+ OPtr<PortDock> destination_;
std::vector<ShippingItem> items_;
- uint8_t m_ship_state;
- std::string m_shipname;
+ uint8_t ship_state_;
+ std::string shipname_;
struct Expedition {
std::vector<Coords> seen_port_buildspaces;
@@ -260,7 +260,7 @@
IslandExploreDirection island_explore_direction;
std::unique_ptr<Economy> economy;
};
- std::unique_ptr<Expedition> m_expedition;
+ std::unique_ptr<Expedition> expedition_;
// saving and loading
protected:
@@ -274,12 +274,12 @@
void load_finish() override;
private:
- uint32_t m_lastdock;
- uint32_t m_destination;
- uint8_t m_ship_state;
- std::string m_shipname;
- std::unique_ptr<Expedition> m_expedition;
- std::vector<ShippingItem::Loader> m_items;
+ uint32_t lastdock_;
+ uint32_t destination_;
+ uint8_t ship_state_;
+ std::string shipname_;
+ std::unique_ptr<Expedition> expedition_;
+ std::vector<ShippingItem::Loader> items_;
};
public:
=== modified file 'src/logic/map_objects/tribes/soldier.cc'
--- src/logic/map_objects/tribes/soldier.cc 2016-02-09 16:29:48 +0000
+++ src/logic/map_objects/tribes/soldier.cc 2016-02-16 14:25:27 +0000
@@ -68,90 +68,90 @@
{
add_attribute(MapObject::Attribute::SOLDIER);
- m_base_hp = table.get_int("hp");
+ base_hp_ = table.get_int("hp");
// Parse attack
std::unique_ptr<LuaTable> items_table = table.get_table("attack");
- m_min_attack = items_table->get_int("minimum");
- m_max_attack = items_table->get_int("maximum");
- if (m_min_attack > m_max_attack) {
- throw GameDataError("Minimum attack %d is greater than maximum attack %d.", m_min_attack, m_max_attack);
+ min_attack_ = items_table->get_int("minimum");
+ max_attack_ = items_table->get_int("maximum");
+ if (min_attack_ > max_attack_) {
+ throw GameDataError("Minimum attack %d is greater than maximum attack %d.", min_attack_, max_attack_);
}
// Parse defend
- m_defense = table.get_int("defense");
+ defense_ = table.get_int("defense");
// Parse evade
- m_evade = table.get_int("evade");
+ evade_ = table.get_int("evade");
// Parse increases per level
- m_hp_incr = table.get_int("hp_incr_per_level");
- m_attack_incr = table.get_int("attack_incr_per_level");
- m_defense_incr = table.get_int("defense_incr_per_level");
- m_evade_incr = table.get_int("evade_incr_per_level");
+ hp_incr_ = table.get_int("hp_incr_per_level");
+ attack_incr_ = table.get_int("attack_incr_per_level");
+ defense_incr_ = table.get_int("defense_incr_per_level");
+ evade_incr_ = table.get_int("evade_incr_per_level");
// Parse max levels
- m_max_hp_level = table.get_int("max_hp_level");
- m_max_attack_level = table.get_int("max_attack_level");
- m_max_defense_level = table.get_int("max_defense_level");
- m_max_evade_level = table.get_int("max_evade_level");
+ max_hp_level_ = table.get_int("max_hp_level");
+ max_attack_level_ = table.get_int("max_attack_level");
+ max_defense_level_ = table.get_int("max_defense_level");
+ max_evade_level_ = table.get_int("max_evade_level");
// Load the filenames
- m_hp_pics_fn .resize(m_max_hp_level + 1);
- m_attack_pics_fn .resize(m_max_attack_level + 1);
- m_defense_pics_fn.resize(m_max_defense_level + 1);
- m_evade_pics_fn .resize(m_max_evade_level + 1);
+ hp_pics_fn_ .resize(max_hp_level_ + 1);
+ attack_pics_fn_ .resize(max_attack_level_ + 1);
+ defense_pics_fn_.resize(max_defense_level_ + 1);
+ evade_pics_fn_ .resize(max_evade_level_ + 1);
- for (uint32_t i = 0; i <= m_max_hp_level; ++i) {
- m_hp_pics_fn[i] = table.get_string((boost::format("hp_level_%u_pic") % i).str());
- }
- for (uint32_t i = 0; i <= m_max_attack_level; ++i) {
- m_attack_pics_fn[i] = table.get_string((boost::format("attack_level_%u_pic") % i).str());
- }
- for (uint32_t i = 0; i <= m_max_defense_level; ++i) {
- m_defense_pics_fn[i] = table.get_string((boost::format("defense_level_%u_pic") % i).str());
- }
- for (uint32_t i = 0; i <= m_max_evade_level; ++i) {
- m_evade_pics_fn[i] = table.get_string((boost::format("evade_level_%u_pic") % i).str());
+ for (uint32_t i = 0; i <= max_hp_level_; ++i) {
+ hp_pics_fn_[i] = table.get_string((boost::format("hp_level_%u_pic") % i).str());
+ }
+ for (uint32_t i = 0; i <= max_attack_level_; ++i) {
+ attack_pics_fn_[i] = table.get_string((boost::format("attack_level_%u_pic") % i).str());
+ }
+ for (uint32_t i = 0; i <= max_defense_level_; ++i) {
+ defense_pics_fn_[i] = table.get_string((boost::format("defense_level_%u_pic") % i).str());
+ }
+ for (uint32_t i = 0; i <= max_evade_level_; ++i) {
+ evade_pics_fn_[i] = table.get_string((boost::format("evade_level_%u_pic") % i).str());
}
// Battle animations
// attack_success_*-> soldier is attacking and hit his opponent
- add_battle_animation(table.get_table("attack_success_w"), &m_attack_success_w_name);
- add_battle_animation(table.get_table("attack_success_e"), &m_attack_success_e_name);
+ add_battle_animation(table.get_table("attack_success_w"), &attack_success_w_name_);
+ add_battle_animation(table.get_table("attack_success_e"), &attack_success_e_name_);
// attack_failure_*-> soldier is attacking and miss hit, defender evades
- add_battle_animation(table.get_table("attack_failure_w"), &m_attack_failure_w_name);
- add_battle_animation(table.get_table("attack_failure_e"), &m_attack_failure_e_name);
+ add_battle_animation(table.get_table("attack_failure_w"), &attack_failure_w_name_);
+ add_battle_animation(table.get_table("attack_failure_e"), &attack_failure_e_name_);
// evade_success_* -> soldier is defending and opponent misses
- add_battle_animation(table.get_table("evade_success_w"), &m_evade_success_w_name);
- add_battle_animation(table.get_table("evade_success_e"), &m_evade_success_e_name);
+ add_battle_animation(table.get_table("evade_success_w"), &evade_success_w_name_);
+ add_battle_animation(table.get_table("evade_success_e"), &evade_success_e_name_);
// evade_failure_* -> soldier is defending and opponent hits
- add_battle_animation(table.get_table("evade_failure_w"), &m_evade_failure_w_name);
- add_battle_animation(table.get_table("evade_failure_e"), &m_evade_failure_e_name);
+ add_battle_animation(table.get_table("evade_failure_w"), &evade_failure_w_name_);
+ add_battle_animation(table.get_table("evade_failure_e"), &evade_failure_e_name_);
// die_* -> soldier is dying
- add_battle_animation(table.get_table("die_w"), &m_die_w_name);
- add_battle_animation(table.get_table("die_e"), &m_die_e_name);
+ add_battle_animation(table.get_table("die_w"), &die_w_name_);
+ add_battle_animation(table.get_table("die_e"), &die_e_name_);
// Load Graphics
- m_hp_pics .resize(m_max_hp_level + 1);
- m_attack_pics .resize(m_max_attack_level + 1);
- m_defense_pics.resize(m_max_defense_level + 1);
- m_evade_pics .resize(m_max_evade_level + 1);
- for (uint32_t i = 0; i <= m_max_hp_level; ++i)
- m_hp_pics[i] = g_gr->images().get(m_hp_pics_fn[i]);
- for (uint32_t i = 0; i <= m_max_attack_level; ++i)
- m_attack_pics[i] =
- g_gr->images().get(m_attack_pics_fn[i]);
- for (uint32_t i = 0; i <= m_max_defense_level; ++i)
- m_defense_pics[i] =
- g_gr->images().get(m_defense_pics_fn[i]);
- for (uint32_t i = 0; i <= m_max_evade_level; ++i)
- m_evade_pics[i] =
- g_gr->images().get(m_evade_pics_fn[i]);
+ hp_pics_ .resize(max_hp_level_ + 1);
+ attack_pics_ .resize(max_attack_level_ + 1);
+ defense_pics_.resize(max_defense_level_ + 1);
+ evade_pics_ .resize(max_evade_level_ + 1);
+ for (uint32_t i = 0; i <= max_hp_level_; ++i)
+ hp_pics_[i] = g_gr->images().get(hp_pics_fn_[i]);
+ for (uint32_t i = 0; i <= max_attack_level_; ++i)
+ attack_pics_[i] =
+ g_gr->images().get(attack_pics_fn_[i]);
+ for (uint32_t i = 0; i <= max_defense_level_; ++i)
+ defense_pics_[i] =
+ g_gr->images().get(defense_pics_fn_[i]);
+ for (uint32_t i = 0; i <= max_evade_level_; ++i)
+ evade_pics_[i] =
+ g_gr->images().get(evade_pics_fn_[i]);
}
/**
@@ -163,62 +163,62 @@
std::string run = animation_name;
if (strcmp(animation_name, "attack_success_w") == 0) {
- assert(!m_attack_success_w_name.empty());
- uint32_t i = game.logic_rand() % m_attack_success_w_name.size();
- run = m_attack_success_w_name[i];
+ assert(!attack_success_w_name_.empty());
+ uint32_t i = game.logic_rand() % attack_success_w_name_.size();
+ run = attack_success_w_name_[i];
}
if (strcmp(animation_name, "attack_success_e") == 0) {
- assert(!m_attack_success_e_name.empty());
- uint32_t i = game.logic_rand() % m_attack_success_e_name.size();
- run = m_attack_success_e_name[i];
+ assert(!attack_success_e_name_.empty());
+ uint32_t i = game.logic_rand() % attack_success_e_name_.size();
+ run = attack_success_e_name_[i];
}
if (strcmp(animation_name, "attack_failure_w") == 0) {
- assert(!m_attack_failure_w_name.empty());
- uint32_t i = game.logic_rand() % m_attack_failure_w_name.size();
- run = m_attack_failure_w_name[i];
+ assert(!attack_failure_w_name_.empty());
+ uint32_t i = game.logic_rand() % attack_failure_w_name_.size();
+ run = attack_failure_w_name_[i];
}
if (strcmp(animation_name, "attack_failure_e") == 0) {
- assert(!m_attack_failure_e_name.empty());
- uint32_t i = game.logic_rand() % m_attack_failure_e_name.size();
- run = m_attack_failure_e_name[i];
+ assert(!attack_failure_e_name_.empty());
+ uint32_t i = game.logic_rand() % attack_failure_e_name_.size();
+ run = attack_failure_e_name_[i];
}
if (strcmp(animation_name, "evade_success_w") == 0) {
- assert(!m_evade_success_w_name.empty());
- uint32_t i = game.logic_rand() % m_evade_success_w_name.size();
- run = m_evade_success_w_name[i];
+ assert(!evade_success_w_name_.empty());
+ uint32_t i = game.logic_rand() % evade_success_w_name_.size();
+ run = evade_success_w_name_[i];
}
if (strcmp(animation_name, "evade_success_e") == 0) {
- assert(!m_evade_success_e_name.empty());
- uint32_t i = game.logic_rand() % m_evade_success_e_name.size();
- run = m_evade_success_e_name[i];
+ assert(!evade_success_e_name_.empty());
+ uint32_t i = game.logic_rand() % evade_success_e_name_.size();
+ run = evade_success_e_name_[i];
}
if (strcmp(animation_name, "evade_failure_w") == 0) {
- assert(!m_evade_failure_w_name.empty());
- uint32_t i = game.logic_rand() % m_evade_failure_w_name.size();
- run = m_evade_failure_w_name[i];
+ assert(!evade_failure_w_name_.empty());
+ uint32_t i = game.logic_rand() % evade_failure_w_name_.size();
+ run = evade_failure_w_name_[i];
}
if (strcmp(animation_name, "evade_failure_e") == 0) {
- assert(!m_evade_failure_e_name.empty());
- uint32_t i = game.logic_rand() % m_evade_failure_e_name.size();
- run = m_evade_failure_e_name[i];
+ assert(!evade_failure_e_name_.empty());
+ uint32_t i = game.logic_rand() % evade_failure_e_name_.size();
+ run = evade_failure_e_name_[i];
}
if (strcmp(animation_name, "die_w") == 0) {
- assert(!m_die_w_name.empty());
- uint32_t i = game.logic_rand() % m_die_w_name.size();
- run = m_die_w_name[i];
+ assert(!die_w_name_.empty());
+ uint32_t i = game.logic_rand() % die_w_name_.size();
+ run = die_w_name_[i];
}
if (strcmp(animation_name, "die_e") == 0) {
- assert(!m_die_e_name.empty());
- uint32_t i = game.logic_rand() % m_die_e_name.size();
- run = m_die_e_name[i];
+ assert(!die_e_name_.empty());
+ uint32_t i = game.logic_rand() % die_e_name_.size();
+ run = die_e_name_[i];
}
if (!is_animation_known(run)) {
log("Missing animation '%s' for soldier %s. Reverting to idle.\n", run.c_str(), name().c_str());
@@ -252,32 +252,32 @@
/// all done through init
Soldier::Soldier(const SoldierDescr & soldier_descr) : Worker(soldier_descr)
{
- m_battle = nullptr;
- m_hp_level = 0;
- m_attack_level = 0;
- m_defense_level = 0;
- m_evade_level = 0;
-
- m_hp_current = get_max_hitpoints();
-
- m_combat_walking = CD_NONE;
- m_combat_walkstart = 0;
- m_combat_walkend = 0;
+ battle_ = nullptr;
+ hp_level_ = 0;
+ attack_level_ = 0;
+ defense_level_ = 0;
+ evade_level_ = 0;
+
+ hp_current_ = get_max_hitpoints();
+
+ combat_walking_ = CD_NONE;
+ combat_walkstart_ = 0;
+ combat_walkend_ = 0;
}
void Soldier::init(EditorGameBase & egbase)
{
- m_hp_level = 0;
- m_attack_level = 0;
- m_defense_level = 0;
- m_evade_level = 0;
-
- m_hp_current = get_max_hitpoints();
-
- m_combat_walking = CD_NONE;
- m_combat_walkstart = 0;
- m_combat_walkend = 0;
+ hp_level_ = 0;
+ attack_level_ = 0;
+ defense_level_ = 0;
+ evade_level_ = 0;
+
+ hp_current_ = get_max_hitpoints();
+
+ combat_walking_ = CD_NONE;
+ combat_walkstart_ = 0;
+ combat_walkend_ = 0;
Worker::init(egbase);
}
@@ -307,43 +307,43 @@
set_evade_level(evade);
}
void Soldier::set_hp_level(const uint32_t hp) {
- assert(m_hp_level <= hp);
+ assert(hp_level_ <= hp);
assert (hp <= descr().get_max_hp_level());
uint32_t oldmax = get_max_hitpoints();
- m_hp_level = hp;
+ hp_level_ = hp;
uint32_t newmax = get_max_hitpoints();
- m_hp_current = m_hp_current * newmax / oldmax;
+ hp_current_ = hp_current_ * newmax / oldmax;
}
void Soldier::set_attack_level(const uint32_t attack) {
- assert(m_attack_level <= attack);
+ assert(attack_level_ <= attack);
assert (attack <= descr().get_max_attack_level());
- m_attack_level = attack;
+ attack_level_ = attack;
}
void Soldier::set_defense_level(const uint32_t defense) {
- assert(m_defense_level <= defense);
+ assert(defense_level_ <= defense);
assert (defense <= descr().get_max_defense_level());
- m_defense_level = defense;
+ defense_level_ = defense;
}
void Soldier::set_evade_level(const uint32_t evade) {
- assert(m_evade_level <= evade);
+ assert(evade_level_ <= evade);
assert (evade <= descr().get_max_evade_level());
- m_evade_level = evade;
+ evade_level_ = evade;
}
uint32_t Soldier::get_level(TrainingAttribute const at) const {
switch (at) {
- case atrHP: return m_hp_level;
- case atrAttack: return m_attack_level;
- case atrDefense: return m_defense_level;
- case atrEvade: return m_evade_level;
+ case atrHP: return hp_level_;
+ case atrAttack: return attack_level_;
+ case atrDefense: return defense_level_;
+ case atrEvade: return evade_level_;
case atrTotal:
- return m_hp_level + m_attack_level + m_defense_level + m_evade_level;
+ return hp_level_ + attack_level_ + defense_level_ + evade_level_;
}
NEVER_HERE();
}
@@ -352,12 +352,12 @@
int32_t Soldier::get_training_attribute(uint32_t const attr) const
{
switch (attr) {
- case atrHP: return m_hp_level;
- case atrAttack: return m_attack_level;
- case atrDefense: return m_defense_level;
- case atrEvade: return m_evade_level;
+ case atrHP: return hp_level_;
+ case atrAttack: return attack_level_;
+ case atrDefense: return defense_level_;
+ case atrEvade: return evade_level_;
case atrTotal:
- return m_hp_level + m_attack_level + m_defense_level + m_evade_level;
+ return hp_level_ + attack_level_ + defense_level_ + evade_level_;
default:
return Worker::get_training_attribute(attr);
}
@@ -365,45 +365,45 @@
uint32_t Soldier::get_max_hitpoints() const
{
- return descr().get_base_hp() + m_hp_level * descr().get_hp_incr_per_level();
+ return descr().get_base_hp() + hp_level_ * descr().get_hp_incr_per_level();
}
uint32_t Soldier::get_min_attack() const
{
return
descr().get_base_min_attack() +
- m_attack_level * descr().get_attack_incr_per_level();
+ attack_level_ * descr().get_attack_incr_per_level();
}
uint32_t Soldier::get_max_attack() const
{
return
descr().get_base_max_attack() +
- m_attack_level * descr().get_attack_incr_per_level();
+ attack_level_ * descr().get_attack_incr_per_level();
}
uint32_t Soldier::get_defense() const
{
return
descr().get_base_defense() +
- m_defense_level * descr().get_defense_incr_per_level();
+ defense_level_ * descr().get_defense_incr_per_level();
}
uint32_t Soldier::get_evade() const
{
return
descr().get_base_evade() +
- m_evade_level * descr().get_evade_incr_per_level();
+ evade_level_ * descr().get_evade_incr_per_level();
}
// Unsignedness ensures that we can only heal, not hurt through this method.
void Soldier::heal (const uint32_t hp) {
molog
- ("[soldier] healing (%d+)%d/%d\n", hp, m_hp_current, get_max_hitpoints());
+ ("[soldier] healing (%d+)%d/%d\n", hp, hp_current_, get_max_hitpoints());
assert(hp);
- assert(m_hp_current < get_max_hitpoints());
- m_hp_current += std::min(hp, get_max_hitpoints() - m_hp_current);
- assert(m_hp_current <= get_max_hitpoints());
+ assert(hp_current_ < get_max_hitpoints());
+ hp_current_ += std::min(hp, get_max_hitpoints() - hp_current_);
+ assert(hp_current_ <= get_max_hitpoints());
}
/**
@@ -411,15 +411,15 @@
*/
void Soldier::damage (const uint32_t value)
{
- assert (m_hp_current > 0);
+ assert (hp_current_ > 0);
molog
("[soldier] damage %d(-%d)/%d\n",
- m_hp_current, value, get_max_hitpoints());
- if (m_hp_current < value)
- m_hp_current = 0;
+ hp_current_, value, get_max_hitpoints());
+ if (hp_current_ < value)
+ hp_current_ = 0;
else
- m_hp_current -= value;
+ hp_current_ -= value;
}
/// Calculates the actual position to draw on from the base node position.
@@ -430,14 +430,14 @@
Point Soldier::calc_drawpos
(const EditorGameBase & game, const Point pos) const
{
- if (m_combat_walking == CD_NONE) {
+ if (combat_walking_ == CD_NONE) {
return Bob::calc_drawpos(game, pos);
}
bool moving = false;
Point spos = pos, epos = pos;
- switch (m_combat_walking) {
+ switch (combat_walking_) {
case CD_WALK_W:
moving = true;
epos.x -= TRIANGLE_WIDTH / 4;
@@ -469,11 +469,11 @@
if (moving) {
float f =
- static_cast<float>(game.get_gametime() - m_combat_walkstart)
+ static_cast<float>(game.get_gametime() - combat_walkstart_)
/
- (m_combat_walkend - m_combat_walkstart);
- assert(m_combat_walkstart <= game.get_gametime());
- assert(m_combat_walkstart < m_combat_walkend);
+ (combat_walkend_ - combat_walkstart_);
+ assert(combat_walkstart_ <= game.get_gametime());
+ assert(combat_walkstart_ < combat_walkend_);
if (f < 0)
f = 0;
@@ -542,7 +542,7 @@
dst.draw_rect(energy_outer, HP_FRAMECOLOR);
assert(get_max_hitpoints());
- uint32_t health_width = 2 * (w - 1) * m_hp_current / get_max_hitpoints();
+ uint32_t health_width = 2 * (w - 1) * hp_current_ / get_max_hitpoints();
Rect energy_inner(Point(pt.x - w + 1, pt.y + 1), health_width, 3);
Rect energy_complement
(energy_inner.origin() + Point(health_width, 0), 2 * (w - 1) - health_width, 3);
@@ -597,7 +597,7 @@
void Soldier::pop_task_or_fight(Game& game) {
- if (m_battle)
+ if (battle_)
start_task_battle(game);
else
pop_task(game);
@@ -644,7 +644,7 @@
Battle * Soldier::get_battle()
{
- return m_battle;
+ return battle_;
}
@@ -657,16 +657,16 @@
*/
bool Soldier::can_be_challenged()
{
- if (m_hp_current < 1) { //< Soldier is dead!
+ if (hp_current_ < 1) { //< Soldier is dead!
return false;
}
if (!is_on_battlefield()) {
return false;
}
- if (!m_battle) {
+ if (!battle_) {
return true;
}
- return !m_battle->locked(dynamic_cast<Game&>(owner().egbase()));
+ return !battle_->locked(dynamic_cast<Game&>(owner().egbase()));
}
/**
@@ -676,8 +676,8 @@
*/
void Soldier::set_battle(Game & game, Battle * const battle)
{
- if (m_battle != battle) {
- m_battle = battle;
+ if (battle_ != battle) {
+ battle_ = battle;
send_signal(game, "battle");
}
}
@@ -884,7 +884,7 @@
}
}
- if (m_battle)
+ if (battle_)
return start_task_battle(game);
if (signal == "blocked") {
@@ -987,8 +987,8 @@
void Soldier::attack_pop(Game & game, State &)
{
- if (m_battle)
- m_battle->cancel(game, *this);
+ if (battle_)
+ battle_->cancel(game, *this);
}
/**
@@ -1102,7 +1102,7 @@
Flag & baseflag = location->base_flag();
- if (m_battle)
+ if (battle_)
return start_task_battle(game);
if (signal == "blocked")
@@ -1123,7 +1123,7 @@
state.ivar2 = 1;
assert(state.ivar2 == 1);
- if (m_battle)
+ if (battle_)
return start_task_battle(game);
// Check if any attacker is waiting us to fight
@@ -1268,8 +1268,8 @@
void Soldier::defense_pop(Game & game, State &)
{
- if (m_battle)
- m_battle->cancel(game, *this);
+ if (battle_)
+ battle_->cancel(game, *this);
}
@@ -1303,9 +1303,9 @@
Map & map = game.map();
int32_t const tdelta = (map.calc_cost(get_position(), mapdir)) / 2;
molog("[move_in_battle] dir: (%d) tdelta: (%d)\n", dir, tdelta);
- m_combat_walking = dir;
- m_combat_walkstart = game.get_gametime();
- m_combat_walkend = m_combat_walkstart + tdelta;
+ combat_walking_ = dir;
+ combat_walkstart_ = game.get_gametime();
+ combat_walkend_ = combat_walkstart_ + tdelta;
push_task(game, taskMoveInBattle);
State & state = top_state();
@@ -1316,28 +1316,28 @@
void Soldier::move_in_battle_update(Game & game, State &)
{
- if (game.get_gametime() >= m_combat_walkend) {
- switch (m_combat_walking) {
+ if (game.get_gametime() >= combat_walkend_) {
+ switch (combat_walking_) {
case CD_NONE:
break;
case CD_WALK_W:
- m_combat_walking = CD_COMBAT_W;
+ combat_walking_ = CD_COMBAT_W;
break;
case CD_WALK_E:
- m_combat_walking = CD_COMBAT_E;
+ combat_walking_ = CD_COMBAT_E;
break;
case CD_RETURN_W:
case CD_RETURN_E:
case CD_COMBAT_W:
case CD_COMBAT_E:
- m_combat_walking = CD_NONE;
+ combat_walking_ = CD_NONE;
break;
}
return pop_task(game);
} else
// Only end the task once we've actually completed the step
// Ignore signals until then
- return schedule_act(game, m_combat_walkend - game.get_gametime());
+ return schedule_act(game, combat_walkend_ - game.get_gametime());
}
/**
@@ -1366,8 +1366,8 @@
void Soldier::start_task_battle(Game& game)
{
- assert(m_battle);
- m_combat_walking = CD_NONE;
+ assert(battle_);
+ combat_walking_ = CD_NONE;
push_task(game, taskBattle);
}
@@ -1394,21 +1394,21 @@
}
}
- if (!m_battle) {
- if (m_combat_walking == CD_COMBAT_W) {
+ if (!battle_) {
+ if (combat_walking_ == CD_COMBAT_W) {
return start_task_move_in_battle(game, CD_RETURN_W);
}
- if (m_combat_walking == CD_COMBAT_E) {
+ if (combat_walking_ == CD_COMBAT_E) {
return start_task_move_in_battle(game, CD_RETURN_E);
}
- assert(m_combat_walking == CD_NONE);
+ assert(combat_walking_ == CD_NONE);
molog("[battle] is over\n");
send_space_signals(game);
return pop_task(game);
}
Map & map = game.map();
- Soldier & opponent = *m_battle->opponent(*this);
+ Soldier & opponent = *battle_->opponent(*this);
if (opponent.get_position() != get_position()) {
if (is_a(Building, map[get_position()].get_immovable()))
{
@@ -1427,20 +1427,20 @@
}
if (stay_home()) {
- if (this == m_battle->first()) {
+ if (this == battle_->first()) {
molog("[battle] stay_home, so reverse roles\n");
- new Battle(game, *m_battle->second(), *m_battle->first());
+ new Battle(game, *battle_->second(), *battle_->first());
return skip_act(); // we will get a signal via set_battle()
} else {
- if (m_combat_walking != CD_COMBAT_E) {
+ if (combat_walking_ != CD_COMBAT_E) {
opponent.send_signal(game, "wakeup");
return start_task_move_in_battle(game, CD_WALK_E);
}
}
} else {
- if (opponent.stay_home() && (this == m_battle->second())) {
+ if (opponent.stay_home() && (this == battle_->second())) {
// Wait until correct roles are assigned
- new Battle(game, *m_battle->second(), *m_battle->first());
+ new Battle(game, *battle_->second(), *battle_->first());
return schedule_act(game, 10);
}
@@ -1452,7 +1452,7 @@
uint32_t const dist = map.calc_distance(get_position(), dest);
- if (dist >= 2 || this == m_battle->first()) {
+ if (dist >= 2 || this == battle_->first()) {
// Only make small steps at a time, so we can adjust to the
// opponent's change of position.
if
@@ -1521,7 +1521,7 @@
}
} else {
assert(opponent.get_position() == get_position());
- assert(m_battle == opponent.get_battle());
+ assert(battle_ == opponent.get_battle());
if (opponent.is_walking()) {
molog
@@ -1531,14 +1531,14 @@
return start_task_idle(game, descr().get_animation("idle"), 5000);
}
- if (m_battle->first()->serial() == serial()) {
- if (m_combat_walking != CD_COMBAT_W) {
+ if (battle_->first()->serial() == serial()) {
+ if (combat_walking_ != CD_COMBAT_W) {
molog("[battle]: Moving west\n");
opponent.send_signal(game, "wakeup");
return start_task_move_in_battle(game, CD_WALK_W);
}
} else {
- if (m_combat_walking != CD_COMBAT_E) {
+ if (combat_walking_ != CD_COMBAT_E) {
molog("[battle]: Moving east\n");
opponent.send_signal(game, "wakeup");
return start_task_move_in_battle(game, CD_WALK_E);
@@ -1547,13 +1547,13 @@
}
}
- m_battle->get_battle_work(game, *this);
+ battle_->get_battle_work(game, *this);
}
void Soldier::battle_pop(Game & game, State &)
{
- if (m_battle)
- m_battle->cancel(game, *this);
+ if (battle_)
+ battle_->cancel(game, *this);
}
@@ -1576,7 +1576,7 @@
start_task_idle
(game,
descr().get_animation
- (m_combat_walking == CD_COMBAT_W ? "die_w" : "die_e"),
+ (combat_walking_ == CD_COMBAT_W ? "die_w" : "die_e"),
1000);
}
@@ -1673,7 +1673,7 @@
if (soldier->get_battle()) {
foundbattle = true;
- if (m_battle && m_battle->opponent(*this) == soldier)
+ if (battle_ && battle_->opponent(*this) == soldier)
foundopponent = true;
}
}
@@ -1750,18 +1750,18 @@
molog("[Soldier]\n");
molog
("Levels: %d/%d/%d/%d\n",
- m_hp_level, m_attack_level, m_defense_level, m_evade_level);
- molog ("HitPoints: %d/%d\n", m_hp_current, get_max_hitpoints());
+ hp_level_, attack_level_, defense_level_, evade_level_);
+ molog ("HitPoints: %d/%d\n", hp_current_, get_max_hitpoints());
molog ("Attack : %d-%d\n", get_min_attack(), get_max_attack());
molog ("Defense : %d%%\n", get_defense());
molog ("Evade: %d%%\n", get_evade());
- molog ("CombatWalkingDir: %i\n", m_combat_walking);
- molog ("CombatWalkingStart: %i\n", m_combat_walkstart);
- molog ("CombatWalkEnd: %i\n", m_combat_walkend);
- molog ("HasBattle: %s\n", m_battle ? "yes" : "no");
- if (m_battle) {
- molog("BattleSerial: %u\n", m_battle->serial());
- molog("Opponent: %u\n", m_battle->opponent(*this)->serial());
+ molog ("CombatWalkingDir: %i\n", combat_walking_);
+ molog ("CombatWalkingStart: %i\n", combat_walkstart_);
+ molog ("CombatWalkEnd: %i\n", combat_walkend_);
+ molog ("HasBattle: %s\n", battle_ ? "yes" : "no");
+ if (battle_) {
+ molog("BattleSerial: %u\n", battle_->serial());
+ molog("Opponent: %u\n", battle_->opponent(*this)->serial());
}
}
@@ -1776,7 +1776,7 @@
constexpr uint8_t kCurrentPacketVersion = 2;
Soldier::Loader::Loader() :
- m_battle(0)
+ battle_(0)
{
}
@@ -1789,27 +1789,27 @@
if (packet_version == kCurrentPacketVersion) {
Soldier & soldier = get<Soldier>();
- soldier.m_hp_current = fr.unsigned_32();
+ soldier.hp_current_ = fr.unsigned_32();
- soldier.m_hp_level =
+ soldier.hp_level_ =
std::min(fr.unsigned_32(), soldier.descr().get_max_hp_level());
- soldier.m_attack_level =
+ soldier.attack_level_ =
std::min(fr.unsigned_32(), soldier.descr().get_max_attack_level());
- soldier.m_defense_level =
+ soldier.defense_level_ =
std::min(fr.unsigned_32(), soldier.descr().get_max_defense_level());
- soldier.m_evade_level =
+ soldier.evade_level_ =
std::min(fr.unsigned_32(), soldier.descr().get_max_evade_level());
- if (soldier.m_hp_current > soldier.get_max_hitpoints())
- soldier.m_hp_current = soldier.get_max_hitpoints();
+ if (soldier.hp_current_ > soldier.get_max_hitpoints())
+ soldier.hp_current_ = soldier.get_max_hitpoints();
- soldier.m_combat_walking = static_cast<CombatWalkingDir>(fr.unsigned_8());
- if (soldier.m_combat_walking != CD_NONE) {
- soldier.m_combat_walkstart = fr.unsigned_32();
- soldier.m_combat_walkend = fr.unsigned_32();
+ soldier.combat_walking_ = static_cast<CombatWalkingDir>(fr.unsigned_8());
+ if (soldier.combat_walking_ != CD_NONE) {
+ soldier.combat_walkstart_ = fr.unsigned_32();
+ soldier.combat_walkend_ = fr.unsigned_32();
}
- m_battle = fr.unsigned_32();
+ battle_ = fr.unsigned_32();
} else {
throw UnhandledVersionError("Soldier", packet_version, kCurrentPacketVersion);
}
@@ -1824,8 +1824,8 @@
Soldier & soldier = get<Soldier>();
- if (m_battle)
- soldier.m_battle = &mol().get<Battle>(m_battle);
+ if (battle_)
+ soldier.battle_ = &mol().get<Battle>(battle_);
}
const Bob::Task * Soldier::Loader::get_task(const std::string & name)
@@ -1849,19 +1849,19 @@
Worker::do_save(egbase, mos, fw);
fw.unsigned_8(kCurrentPacketVersion);
- fw.unsigned_32(m_hp_current);
- fw.unsigned_32(m_hp_level);
- fw.unsigned_32(m_attack_level);
- fw.unsigned_32(m_defense_level);
- fw.unsigned_32(m_evade_level);
+ fw.unsigned_32(hp_current_);
+ fw.unsigned_32(hp_level_);
+ fw.unsigned_32(attack_level_);
+ fw.unsigned_32(defense_level_);
+ fw.unsigned_32(evade_level_);
- fw.unsigned_8(m_combat_walking);
- if (m_combat_walking != CD_NONE) {
- fw.unsigned_32(m_combat_walkstart);
- fw.unsigned_32(m_combat_walkend);
+ fw.unsigned_8(combat_walking_);
+ if (combat_walking_ != CD_NONE) {
+ fw.unsigned_32(combat_walkstart_);
+ fw.unsigned_32(combat_walkend_);
}
- fw.unsigned_32(mos.get_object_file_index_or_zero(m_battle));
+ fw.unsigned_32(mos.get_object_file_index_or_zero(battle_));
}
}
=== modified file 'src/logic/map_objects/tribes/soldier.h'
--- src/logic/map_objects/tribes/soldier.h 2016-01-31 15:31:00 +0000
+++ src/logic/map_objects/tribes/soldier.h 2016-02-16 14:25:27 +0000
@@ -47,33 +47,33 @@
const LuaTable& t, const EditorGameBase& egbase);
~SoldierDescr() override {}
- uint32_t get_max_hp_level () const {return m_max_hp_level;}
- uint32_t get_max_attack_level () const {return m_max_attack_level;}
- uint32_t get_max_defense_level () const {return m_max_defense_level;}
- uint32_t get_max_evade_level () const {return m_max_evade_level;}
-
- uint32_t get_base_hp () const {return m_base_hp;}
- uint32_t get_base_min_attack() const {return m_min_attack;}
- uint32_t get_base_max_attack() const {return m_max_attack;}
- uint32_t get_base_defense () const {return m_defense;}
- uint32_t get_base_evade () const {return m_evade;}
-
- uint32_t get_hp_incr_per_level () const {return m_hp_incr;}
- uint32_t get_attack_incr_per_level () const {return m_attack_incr;}
- uint32_t get_defense_incr_per_level() const {return m_defense_incr;}
- uint32_t get_evade_incr_per_level () const {return m_evade_incr;}
+ uint32_t get_max_hp_level () const {return max_hp_level_;}
+ uint32_t get_max_attack_level () const {return max_attack_level_;}
+ uint32_t get_max_defense_level () const {return max_defense_level_;}
+ uint32_t get_max_evade_level () const {return max_evade_level_;}
+
+ uint32_t get_base_hp () const {return base_hp_;}
+ uint32_t get_base_min_attack() const {return min_attack_;}
+ uint32_t get_base_max_attack() const {return max_attack_;}
+ uint32_t get_base_defense () const {return defense_;}
+ uint32_t get_base_evade () const {return evade_;}
+
+ uint32_t get_hp_incr_per_level () const {return hp_incr_;}
+ uint32_t get_attack_incr_per_level () const {return attack_incr_;}
+ uint32_t get_defense_incr_per_level() const {return defense_incr_;}
+ uint32_t get_evade_incr_per_level () const {return evade_incr_;}
const Image* get_hp_level_pic (uint32_t const level) const {
- assert(level <= m_max_hp_level); return m_hp_pics [level];
+ assert(level <= max_hp_level_); return hp_pics_ [level];
}
const Image* get_attack_level_pic (uint32_t const level) const {
- assert(level <= m_max_attack_level); return m_attack_pics [level];
+ assert(level <= max_attack_level_); return attack_pics_ [level];
}
const Image* get_defense_level_pic(uint32_t const level) const {
- assert(level <= m_max_defense_level); return m_defense_pics[level];
+ assert(level <= max_defense_level_); return defense_pics_[level];
}
const Image* get_evade_level_pic (uint32_t const level) const {
- assert(level <= m_max_evade_level); return m_evade_pics [level];
+ assert(level <= max_evade_level_); return evade_pics_ [level];
}
uint32_t get_rand_anim(Game & game, const char * const name) const;
@@ -82,46 +82,46 @@
Bob & create_object() const override;
// start values
- uint32_t m_base_hp;
- uint32_t m_min_attack;
- uint32_t m_max_attack;
- uint32_t m_defense;
- uint32_t m_evade;
+ uint32_t base_hp_;
+ uint32_t min_attack_;
+ uint32_t max_attack_;
+ uint32_t defense_;
+ uint32_t evade_;
// per level increases
- uint32_t m_hp_incr;
- uint32_t m_attack_incr;
- uint32_t m_defense_incr;
- uint32_t m_evade_incr;
+ uint32_t hp_incr_;
+ uint32_t attack_incr_;
+ uint32_t defense_incr_;
+ uint32_t evade_incr_;
// max levels
- uint32_t m_max_hp_level;
- uint32_t m_max_attack_level;
- uint32_t m_max_defense_level;
- uint32_t m_max_evade_level;
+ uint32_t max_hp_level_;
+ uint32_t max_attack_level_;
+ uint32_t max_defense_level_;
+ uint32_t max_evade_level_;
// level pictures
- std::vector<const Image* > m_hp_pics;
- std::vector<const Image* > m_attack_pics;
- std::vector<const Image* > m_evade_pics;
- std::vector<const Image* > m_defense_pics;
- std::vector<std::string> m_hp_pics_fn;
- std::vector<std::string> m_attack_pics_fn;
- std::vector<std::string> m_evade_pics_fn;
- std::vector<std::string> m_defense_pics_fn;
+ std::vector<const Image* > hp_pics_;
+ std::vector<const Image* > attack_pics_;
+ std::vector<const Image* > evade_pics_;
+ std::vector<const Image* > defense_pics_;
+ std::vector<std::string> hp_pics_fn_;
+ std::vector<std::string> attack_pics_fn_;
+ std::vector<std::string> evade_pics_fn_;
+ std::vector<std::string> defense_pics_fn_;
// animation names
- std::vector<std::string> m_attack_success_w_name;
- std::vector<std::string> m_attack_failure_w_name;
- std::vector<std::string> m_evade_success_w_name;
- std::vector<std::string> m_evade_failure_w_name;
- std::vector<std::string> m_die_w_name;
+ std::vector<std::string> attack_success_w_name_;
+ std::vector<std::string> attack_failure_w_name_;
+ std::vector<std::string> evade_success_w_name_;
+ std::vector<std::string> evade_failure_w_name_;
+ std::vector<std::string> die_w_name_;
- std::vector<std::string> m_attack_success_e_name;
- std::vector<std::string> m_attack_failure_e_name;
- std::vector<std::string> m_evade_success_e_name;
- std::vector<std::string> m_evade_failure_e_name;
- std::vector<std::string> m_die_e_name;
+ std::vector<std::string> attack_success_e_name_;
+ std::vector<std::string> attack_failure_e_name_;
+ std::vector<std::string> evade_success_e_name_;
+ std::vector<std::string> evade_failure_e_name_;
+ std::vector<std::string> die_e_name_;
private:
// Reads list of animation names from the table and pushes them into result.
@@ -171,11 +171,11 @@
void set_defense_level(uint32_t);
void set_evade_level (uint32_t);
uint32_t get_level (TrainingAttribute) const;
- uint32_t get_hp_level () const {return m_hp_level;}
- uint32_t get_attack_level () const {return m_attack_level;}
- uint32_t get_defense_level() const {return m_defense_level;}
- uint32_t get_evade_level () const {return m_evade_level;}
- uint32_t get_total_level () const {return m_hp_level + m_attack_level + m_defense_level + m_evade_level;}
+ uint32_t get_hp_level () const {return hp_level_;}
+ uint32_t get_attack_level () const {return attack_level_;}
+ uint32_t get_defense_level() const {return defense_level_;}
+ uint32_t get_evade_level () const {return evade_level_;}
+ uint32_t get_total_level () const {return hp_level_ + attack_level_ + defense_level_ + evade_level_;}
/// Automatically select a task.
void init_auto_task(Game &) override;
@@ -188,7 +188,7 @@
(const TribeDescr &, uint32_t & w, uint32_t & h);
void draw_info_icon(RenderTarget &, Point, bool anchor_below) const;
- uint32_t get_current_hitpoints() const {return m_hp_current;}
+ uint32_t get_current_hitpoints() const {return hp_current_;}
uint32_t get_max_hitpoints() const;
uint32_t get_min_attack() const;
uint32_t get_max_attack() const;
@@ -196,16 +196,16 @@
uint32_t get_evade() const;
const Image* get_hp_level_pic () const {
- return descr().get_hp_level_pic (m_hp_level);
+ return descr().get_hp_level_pic (hp_level_);
}
const Image* get_attack_level_pic () const {
- return descr().get_attack_level_pic (m_attack_level);
+ return descr().get_attack_level_pic (attack_level_);
}
const Image* get_defense_level_pic() const {
- return descr().get_defense_level_pic(m_defense_level);
+ return descr().get_defense_level_pic(defense_level_);
}
const Image* get_evade_level_pic () const {
- return descr().get_evade_level_pic (m_evade_level);
+ return descr().get_evade_level_pic (evade_level_);
}
int32_t get_training_attribute(uint32_t attr) const override;
@@ -262,27 +262,27 @@
bool is_evict_allowed() override;
private:
- uint32_t m_hp_current;
- uint32_t m_hp_level;
- uint32_t m_attack_level;
- uint32_t m_defense_level;
- uint32_t m_evade_level;
+ uint32_t hp_current_;
+ uint32_t hp_level_;
+ uint32_t attack_level_;
+ uint32_t defense_level_;
+ uint32_t evade_level_;
/// This is used to replicate walk for soldiers but only just before and
/// just after figthing in a battle, to draw soldier at proper position.
- /// Maybe Bob.m_walking could be used, but then that variable should be
+ /// Maybe Bob.walking_ could be used, but then that variable should be
/// protected instead of private, and some type of rework needed to allow
/// the new states. I thought that it is cleaner to have this variable
/// separate.
- CombatWalkingDir m_combat_walking;
- uint32_t m_combat_walkstart;
- uint32_t m_combat_walkend;
+ CombatWalkingDir combat_walking_;
+ uint32_t combat_walkstart_;
+ uint32_t combat_walkend_;
/**
* If the soldier is involved in a challenge, it is assigned a battle
* object.
*/
- Battle * m_battle;
+ Battle * battle_;
static constexpr uint8_t kSoldierHpBarWidth = 13;
@@ -302,7 +302,7 @@
const Task * get_task(const std::string & name) override;
private:
- uint32_t m_battle;
+ uint32_t battle_;
};
Loader * create_loader() override;
=== modified file 'src/logic/mapastar.h'
--- src/logic/mapastar.h 2014-07-05 16:41:51 +0000
+++ src/logic/mapastar.h 2016-02-16 14:25:27 +0000
@@ -29,7 +29,7 @@
struct MapAStarBase {
MapAStarBase(Map & m) :
map(m),
- pathfields(m.m_pathfieldmgr->allocate())
+ pathfields(m.pathfieldmgr_->allocate())
{
}
=== modified file 'src/map_io/map_elemental_packet.cc'
--- src/map_io/map_elemental_packet.cc 2016-02-10 20:39:02 +0000
+++ src/map_io/map_elemental_packet.cc 2016-02-16 14:25:27 +0000
@@ -41,8 +41,8 @@
try {
int32_t const packet_version = s.get_int("packet_version");
if (packet_version == kCurrentPacketVersion) {
- map->m_width = s.get_int ("map_w");
- map->m_height = s.get_int ("map_h");
+ map->width_ = s.get_int ("map_w");
+ map->height_ = s.get_int ("map_h");
map->set_nrplayers (s.get_int ("nr_players"));
map->set_name (s.get_string("name"));
map->set_author (s.get_string("author"));
@@ -64,7 +64,7 @@
}
// Get suggested teams
- map->m_suggested_teams.clear();
+ map->suggested_teams_.clear();
uint16_t team_section_id = 0;
std::string teamsection_key = (boost::format("teams%02i") % team_section_id).str();
@@ -97,7 +97,7 @@
team_string = teamsection->get_string(team_key.c_str(), "");
}
- map->m_suggested_teams.push_back(lineup);
+ map->suggested_teams_.push_back(lineup);
// Increase teamsection
++team_section_id;
=== modified file 'src/map_io/map_version_packet.cc'
--- src/map_io/map_version_packet.cc 2015-10-24 15:42:37 +0000
+++ src/map_io/map_version_packet.cc 2016-02-16 14:25:27 +0000
@@ -44,8 +44,8 @@
try {prof.read("version", nullptr, fs);} catch (...)
{
Map & map = egbase.map();
- map.m_map_version.m_map_version_timestamp = 0;
- map.m_map_version.m_map_creator_version = "unknown";
+ map.map_version_.m_map_version_timestamp = 0;
+ map.map_version_.m_map_creator_version = "unknown";
return;
}
@@ -60,13 +60,13 @@
|| (packet_version > kCurrentPacketVersion && forward_compatibility <= kCurrentPacketVersion))
{
Map & map = egbase.map();
- map.m_map_version.m_map_source_url = globv.get_safe_string("map_source_url");
- map.m_map_version.m_map_source_release = globv.get_safe_string("map_release");
- map.m_map_version.m_map_creator_version = globv.get_safe_string("map_creator_version");
- map.m_map_version.m_map_version_major = globv.get_safe_int("map_version_major");
- map.m_map_version.m_map_version_minor = globv.get_safe_int("map_version_minor");
+ map.map_version_.m_map_source_url = globv.get_safe_string("map_source_url");
+ map.map_version_.m_map_source_release = globv.get_safe_string("map_release");
+ map.map_version_.m_map_creator_version = globv.get_safe_string("map_creator_version");
+ map.map_version_.m_map_version_major = globv.get_safe_int("map_version_major");
+ map.map_version_.m_map_version_minor = globv.get_safe_int("map_version_minor");
uint32_t ts = static_cast<uint32_t>(globv.get_safe_int("map_version_timestamp"));
- map.m_map_version.m_map_version_timestamp = ts;
+ map.map_version_.m_map_version_timestamp = ts;
} else {
throw UnhandledVersionError("MapVersionPacket", packet_version, kCurrentPacketVersion);
}
@@ -116,11 +116,11 @@
// There seems to be a get_safe_natural method, but not corresponding setter.
Map & map = egbase.map();
- globs.set_string("map_source_url", map.m_map_version.m_map_source_url);
- globs.set_string("map_release", map.m_map_version.m_map_source_release);
- globs.set_string("map_creator_version", map.m_map_version.m_map_creator_version);
- globs.set_int("map_version_major", map.m_map_version.m_map_version_major);
- globs.set_int("map_version_minor", 1 + map.m_map_version.m_map_version_minor);
+ globs.set_string("map_source_url", map.map_version_.m_map_source_url);
+ globs.set_string("map_release", map.map_version_.m_map_source_release);
+ globs.set_string("map_creator_version", map.map_version_.m_map_creator_version);
+ globs.set_int("map_version_major", map.map_version_.m_map_version_major);
+ globs.set_int("map_version_minor", 1 + map.map_version_.m_map_version_minor);
globs.set_int("map_version_timestamp", static_cast<uint32_t>(time(nullptr)));
globs.set_int("packet_version", kCurrentPacketVersion);
globs.set_int("packet_compatibility", kCurrentPacketVersion);
=== modified file 'src/map_io/s2map.cc'
--- src/map_io/s2map.cc 2016-02-10 20:55:54 +0000
+++ src/map_io/s2map.cc 2016-02-16 14:25:27 +0000
@@ -396,8 +396,8 @@
#endif
// don't really set size, but make the structures valid
- m_map.m_width = header.w;
- m_map.m_height = header.h;
+ m_map.width_ = header.w;
+ m_map.height_ = header.h;
m_map.set_author(header.author);
m_map.set_name(header.name);
@@ -419,10 +419,10 @@
fr.open(*g_fs, m_filename.c_str());
load_s2mf_header(fr);
- m_map.set_size(m_map.m_width, m_map.m_height);
+ m_map.set_size(m_map.width_, m_map.height_);
// The header must already have been processed.
- assert(m_map.m_fields.get());
+ assert(m_map.fields_.get());
int16_t const mapwidth = m_map.get_width ();
int16_t const mapheight = m_map.get_height();
assert(mapwidth > 0 && mapheight > 0);
@@ -433,7 +433,7 @@
if (!section)
throw wexception("Section 1 (Heights) not found");
- Widelands::Field * f = m_map.m_fields.get();
+ Widelands::Field * f = m_map.fields_.get();
pc = section.get();
for (int16_t y = 0; y < mapheight; ++y)
for (int16_t x = 0; x < mapwidth; ++x, ++f, ++pc)
@@ -450,7 +450,7 @@
const Widelands::World& world = egbase.world();
TerrainConverter terrain_converter(world, *lookup_table);
- f = m_map.m_fields.get();
+ f = m_map.fields_.get();
pc = section.get();
for (int16_t y = 0; y < mapheight; ++y)
for (int16_t x = 0; x < mapwidth; ++x, ++f, ++pc) {
@@ -466,7 +466,7 @@
if (!section)
throw wexception("Section 3 (Terrain 2) not found");
- f = m_map.m_fields.get();
+ f = m_map.fields_.get();
pc = section.get();
for (int16_t y = 0; y < mapheight; ++y)
for (int16_t x = 0; x < mapwidth; ++x, ++f, ++pc) {
=== modified file 'src/map_io/widelands_map_loader.cc'
--- src/map_io/widelands_map_loader.cc 2016-02-14 14:09:29 +0000
+++ src/map_io/widelands_map_loader.cc 2016-02-16 14:25:27 +0000
@@ -116,7 +116,7 @@
bool is_game = load_type == MapLoader::LoadType::kGame;
preload_map(!is_game);
- m_map.set_size(m_map.m_width, m_map.m_height);
+ m_map.set_size(m_map.width_, m_map.height_);
m_mol.reset(new MapObjectLoader());
// MANDATORY PACKETS
=== modified file 'src/wui/shipwindow.cc'
--- src/wui/shipwindow.cc 2016-02-07 21:44:44 +0000
+++ src/wui/shipwindow.cc 2016-02-16 14:25:27 +0000
@@ -92,9 +92,9 @@
m_igbase(igb),
m_ship(ship)
{
- assert(!m_ship.m_window);
+ assert(!m_ship.window_);
assert(m_ship.get_owner());
- m_ship.m_window = this;
+ m_ship.window_ = this;
UI::Box * vbox = new UI::Box(this, 0, 0, UI::Box::Vertical);
@@ -204,8 +204,8 @@
ShipWindow::~ShipWindow()
{
- assert(m_ship.m_window == this);
- m_ship.m_window = nullptr;
+ assert(m_ship.window_ == this);
+ m_ship.window_ = nullptr;
}
void ShipWindow::think()
@@ -349,18 +349,18 @@
void Ship::show_window(InteractiveGameBase & igb, bool avoid_fastclick)
{
// No window, if ship is sinking
- if (m_ship_state == SINK_REQUEST || m_ship_state == SINK_ANIMATION)
+ if (ship_state_ == SINK_REQUEST || ship_state_ == SINK_ANIMATION)
return;
- if (m_window) {
- if (m_window->is_minimal())
- m_window->restore();
- m_window->move_to_top();
+ if (window_) {
+ if (window_->is_minimal())
+ window_->restore();
+ window_->move_to_top();
} else {
const std::string& title = get_shipname();
new ShipWindow(igb, *this, title);
if (!avoid_fastclick)
- m_window->warp_mouse_to_fastclick_panel();
+ window_->warp_mouse_to_fastclick_panel();
}
}
@@ -369,9 +369,9 @@
*/
void Ship::close_window()
{
- if (m_window) {
- delete m_window;
- m_window = nullptr;
+ if (window_) {
+ delete window_;
+ window_ = nullptr;
}
}
@@ -380,14 +380,14 @@
*/
void Ship::refresh_window(InteractiveGameBase & igb) {
// Only do something if there is actually a window
- if (m_window) {
- Point window_position = m_window->get_pos();
+ if (window_) {
+ Point window_position = window_->get_pos();
close_window();
show_window(igb, true);
// show window could theoretically fail if refresh_window was called at the very same moment
// as the ship begins to sink
- if (m_window)
- m_window->set_pos(window_position);
+ if (window_)
+ window_->set_pos(window_position);
}
}
Follow ups