Merge lp:~widelands-dev/widelands/bug-1395278-logic3 into lp:widelands

Proposed by Klaus Halfmann
Status: Merged
Merged at revision: 7866
Proposed branch: lp:~widelands-dev/widelands/bug-1395278-logic3
Merge into: lp:widelands
Diff against target: 1743 lines (+444/-444)
26 files modified
src/game_io/game_cmd_queue_packet.cc (+2/-2)
src/game_io/game_loader.cc (+15/-15)
src/game_io/game_loader.h (+1/-1)
src/game_io/game_saver.cc (+9/-9)
src/game_io/game_saver.h (+1/-1)
src/logic/game.cc (+2/-2)
src/logic/map.cc (+33/-33)
src/logic/map_objects/tribes/ship.cc (+3/-3)
src/logic/map_objects/tribes/soldier.cc (+4/-4)
src/logic/map_revision.cc (+4/-4)
src/logic/map_revision.h (+6/-6)
src/logic/mapastar.h (+14/-14)
src/logic/mapdifferenceregion.cc (+19/-19)
src/logic/mapdifferenceregion.h (+9/-9)
src/logic/mapfringeregion.cc (+28/-28)
src/logic/mapfringeregion.h (+13/-13)
src/logic/maphollowregion.cc (+35/-35)
src/logic/maphollowregion.h (+8/-8)
src/logic/mapregion.h (+21/-21)
src/logic/maptriangleregion.cc (+142/-142)
src/logic/maptriangleregion.h (+33/-33)
src/logic/message_queue.h (+22/-22)
src/logic/path.cc (+1/-1)
src/logic/player.cc (+2/-2)
src/logic/replay.cc (+4/-4)
src/map_io/map_version_packet.cc (+13/-13)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1395278-logic3
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+287827@code.launchpad.net

Commit message

Refactored remaining member variable names in src/logic.

Description of the change

Did a code review, found pure renaming only,
will continue to play the game from the last review (bug-1395278-logic2) now.

To post a comment you must log in.
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Played perhas 30 Minutes had no
issues except an annyoing attacking AI :-)

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for the review :)

This can go in once Travis comes through.

Revision history for this message
GunChleoc (gunchleoc) wrote :

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/game_io/game_cmd_queue_packet.cc'
--- src/game_io/game_cmd_queue_packet.cc 2016-02-15 23:26:42 +0000
+++ src/game_io/game_cmd_queue_packet.cc 2016-03-02 18:10:45 +0000
@@ -41,7 +41,7 @@
41 if (packet_version == kCurrentPacketVersion) {41 if (packet_version == kCurrentPacketVersion) {
42 CmdQueue & cmdq = game.cmdqueue();42 CmdQueue & cmdq = game.cmdqueue();
4343
44 // nothing to be done for m_game44 // nothing to be done for game_
4545
46 // Next serial46 // Next serial
47 cmdq.nextserial_ = fr.unsigned_32();47 cmdq.nextserial_ = fr.unsigned_32();
@@ -86,7 +86,7 @@
8686
87 const CmdQueue & cmdq = game.cmdqueue();87 const CmdQueue & cmdq = game.cmdqueue();
8888
89 // nothing to be done for m_game89 // nothing to be done for game_
9090
91 // Next serial91 // Next serial
92 fw.unsigned_32(cmdq.nextserial_);92 fw.unsigned_32(cmdq.nextserial_);
9393
=== modified file 'src/game_io/game_loader.cc'
--- src/game_io/game_loader.cc 2016-01-20 20:12:00 +0000
+++ src/game_io/game_loader.cc 2016-03-02 18:10:45 +0000
@@ -40,7 +40,7 @@
40namespace Widelands {40namespace Widelands {
4141
42GameLoader::GameLoader(const std::string & path, Game & game) :42GameLoader::GameLoader(const std::string & path, Game & game) :
43 m_fs(*g_fs->make_sub_file_system(path)), m_game(game)43 m_fs(*g_fs->make_sub_file_system(path)), game_(game)
44{}44{}
4545
4646
@@ -53,7 +53,7 @@
53 */53 */
54int32_t GameLoader::preload_game(GamePreloadPacket & mp) {54int32_t GameLoader::preload_game(GamePreloadPacket & mp) {
55 // Load elemental data block55 // Load elemental data block
56 mp.read(m_fs, m_game, nullptr);56 mp.read(m_fs, game_, nullptr);
5757
58 return 0;58 return 0;
59}59}
@@ -65,43 +65,43 @@
65 ScopedTimer timer("GameLoader::load() took %ums");65 ScopedTimer timer("GameLoader::load() took %ums");
6666
67 log("Game: Reading Preload Data ... ");67 log("Game: Reading Preload Data ... ");
68 {GamePreloadPacket p; p.read(m_fs, m_game);}68 {GamePreloadPacket p; p.read(m_fs, game_);}
69 log("took %ums\n", timer.ms_since_last_query());69 log("took %ums\n", timer.ms_since_last_query());
7070
71 log("Game: Reading Game Class Data ... ");71 log("Game: Reading Game Class Data ... ");
72 {GameClassPacket p; p.read(m_fs, m_game);}72 {GameClassPacket p; p.read(m_fs, game_);}
73 log("took %ums\n", timer.ms_since_last_query());73 log("took %ums\n", timer.ms_since_last_query());
7474
75 log("Game: Reading Map Data ... ");75 log("Game: Reading Map Data ... ");
76 GameMapPacket M; M.read(m_fs, m_game);76 GameMapPacket M; M.read(m_fs, game_);
77 log("Game: Reading Map Data took %ums\n", timer.ms_since_last_query());77 log("Game: Reading Map Data took %ums\n", timer.ms_since_last_query());
7878
79 log("Game: Reading Player Info ... ");79 log("Game: Reading Player Info ... ");
80 {GamePlayerInfoPacket p; p.read(m_fs, m_game);}80 {GamePlayerInfoPacket p; p.read(m_fs, game_);}
81 log("Game: Reading Player Info took %ums\n", timer.ms_since_last_query());81 log("Game: Reading Player Info took %ums\n", timer.ms_since_last_query());
8282
83 log("Game: Calling read_complete()\n");83 log("Game: Calling read_complete()\n");
84 M.read_complete(m_game);84 M.read_complete(game_);
85 log("Game: read_complete took: %ums\n", timer.ms_since_last_query());85 log("Game: read_complete took: %ums\n", timer.ms_since_last_query());
8686
87 MapObjectLoader * const mol = M.get_map_object_loader();87 MapObjectLoader * const mol = M.get_map_object_loader();
8888
89 log("Game: Reading Player Economies Info ... ");89 log("Game: Reading Player Economies Info ... ");
90 {GamePlayerEconomiesPacket p; p.read(m_fs, m_game, mol);}90 {GamePlayerEconomiesPacket p; p.read(m_fs, game_, mol);}
91 log("took %ums\n", timer.ms_since_last_query());91 log("took %ums\n", timer.ms_since_last_query());
9292
93 log("Game: Reading ai persistent data ... ");93 log("Game: Reading ai persistent data ... ");
94 {GamePlayerAiPersistentPacket p; p.read(m_fs, m_game, mol);}94 {GamePlayerAiPersistentPacket p; p.read(m_fs, game_, mol);}
95 log("took %ums\n", timer.ms_since_last_query());95 log("took %ums\n", timer.ms_since_last_query());
9696
97 log("Game: Reading Command Queue Data ... ");97 log("Game: Reading Command Queue Data ... ");
98 {GameCmdQueuePacket p; p.read(m_fs, m_game, mol);}98 {GameCmdQueuePacket p; p.read(m_fs, game_, mol);}
99 log("took %ums\n", timer.ms_since_last_query());99 log("took %ums\n", timer.ms_since_last_query());
100100
101 // This must be after the command queue has been read.101 // This must be after the command queue has been read.
102 log("Game: Parsing messages ... ");102 log("Game: Parsing messages ... ");
103 PlayerNumber const nr_players = m_game.map().get_nrplayers();103 PlayerNumber const nr_players = game_.map().get_nrplayers();
104 iterate_players_existing_const(p, nr_players, m_game, player) {104 iterate_players_existing_const(p, nr_players, game_, player) {
105 const MessageQueue & messages = player->messages();105 const MessageQueue & messages = player->messages();
106 for (std::pair<MessageId, Message *> temp_message : messages) {106 for (std::pair<MessageId, Message *> temp_message : messages) {
107 Message* m = temp_message.second;107 Message* m = temp_message.second;
@@ -109,7 +109,7 @@
109109
110 // Renew MapObject connections110 // Renew MapObject connections
111 if (m->serial() > 0) {111 if (m->serial() > 0) {
112 MapObject* mo = m_game.objects().get_object(m->serial());112 MapObject* mo = game_.objects().get_object(m->serial());
113 mo->removed.connect113 mo->removed.connect
114 (boost::bind(&Player::message_object_removed, player, m_id));114 (boost::bind(&Player::message_object_removed, player, m_id));
115 }115 }
@@ -118,14 +118,14 @@
118 log("took %ums\n", timer.ms_since_last_query());118 log("took %ums\n", timer.ms_since_last_query());
119119
120 // For compatibility hacks only120 // For compatibility hacks only
121 mol->load_finish_game(m_game);121 mol->load_finish_game(game_);
122122
123 // Only read and use interactive player data, if we load a singleplayer game.123 // Only read and use interactive player data, if we load a singleplayer game.
124 // In multiplayer games every client needs to create a new interactive124 // In multiplayer games every client needs to create a new interactive
125 // player.125 // player.
126 if (!multiplayer) {126 if (!multiplayer) {
127 log("Game: Reading Interactive Player Data ... ");127 log("Game: Reading Interactive Player Data ... ");
128 {GameInteractivePlayerPacket p; p.read(m_fs, m_game, mol);}128 {GameInteractivePlayerPacket p; p.read(m_fs, game_, mol);}
129 log("took %ums\n", timer.ms_since_last_query());129 log("took %ums\n", timer.ms_since_last_query());
130 }130 }
131131
132132
=== modified file 'src/game_io/game_loader.h'
--- src/game_io/game_loader.h 2014-09-10 07:57:29 +0000
+++ src/game_io/game_loader.h 2016-03-02 18:10:45 +0000
@@ -44,7 +44,7 @@
4444
45private:45private:
46 FileSystem & m_fs;46 FileSystem & m_fs;
47 Game & m_game;47 Game & game_;
48};48};
4949
50}50}
5151
=== modified file 'src/game_io/game_saver.cc'
--- src/game_io/game_saver.cc 2016-01-20 20:12:00 +0000
+++ src/game_io/game_saver.cc 2016-03-02 18:10:45 +0000
@@ -34,7 +34,7 @@
3434
35namespace Widelands {35namespace Widelands {
3636
37GameSaver::GameSaver(FileSystem & fs, Game & game) : m_fs(fs), m_game(game) {37GameSaver::GameSaver(FileSystem & fs, Game & game) : m_fs(fs), game_(game) {
38}38}
3939
4040
@@ -47,37 +47,37 @@
47 m_fs.ensure_directory_exists("binary");47 m_fs.ensure_directory_exists("binary");
4848
49 log("Game: Writing Preload Data ... ");49 log("Game: Writing Preload Data ... ");
50 {GamePreloadPacket p; p.write(m_fs, m_game, nullptr);}50 {GamePreloadPacket p; p.write(m_fs, game_, nullptr);}
51 log("took %ums\n", timer.ms_since_last_query());51 log("took %ums\n", timer.ms_since_last_query());
5252
53 log("Game: Writing Game Class Data ... ");53 log("Game: Writing Game Class Data ... ");
54 {GameClassPacket p; p.write(m_fs, m_game, nullptr);}54 {GameClassPacket p; p.write(m_fs, game_, nullptr);}
55 log("took %ums\n", timer.ms_since_last_query());55 log("took %ums\n", timer.ms_since_last_query());
5656
57 log("Game: Writing Player Info ... ");57 log("Game: Writing Player Info ... ");
58 {GamePlayerInfoPacket p; p.write(m_fs, m_game, nullptr);}58 {GamePlayerInfoPacket p; p.write(m_fs, game_, nullptr);}
59 log("took %ums\n", timer.ms_since_last_query());59 log("took %ums\n", timer.ms_since_last_query());
6060
61 log("Game: Writing Map Data!\n");61 log("Game: Writing Map Data!\n");
62 GameMapPacket M; M.write(m_fs, m_game, nullptr);62 GameMapPacket M; M.write(m_fs, game_, nullptr);
63 log("Game: Writing Map Data took %ums\n", timer.ms_since_last_query());63 log("Game: Writing Map Data took %ums\n", timer.ms_since_last_query());
6464
65 MapObjectSaver * const mos = M.get_map_object_saver();65 MapObjectSaver * const mos = M.get_map_object_saver();
6666
67 log("Game: Writing Player Economies Info ... ");67 log("Game: Writing Player Economies Info ... ");
68 {GamePlayerEconomiesPacket p; p.write(m_fs, m_game, mos);}68 {GamePlayerEconomiesPacket p; p.write(m_fs, game_, mos);}
69 log("took %ums\n", timer.ms_since_last_query());69 log("took %ums\n", timer.ms_since_last_query());
7070
71 log("Game: Writing ai persistent data ... ");71 log("Game: Writing ai persistent data ... ");
72 {GamePlayerAiPersistentPacket p; p.write(m_fs, m_game, mos);}72 {GamePlayerAiPersistentPacket p; p.write(m_fs, game_, mos);}
73 log("took %ums\n", timer.ms_since_last_query());73 log("took %ums\n", timer.ms_since_last_query());
7474
75 log("Game: Writing Command Queue Data ... ");75 log("Game: Writing Command Queue Data ... ");
76 {GameCmdQueuePacket p; p.write(m_fs, m_game, mos);}76 {GameCmdQueuePacket p; p.write(m_fs, game_, mos);}
77 log("took %ums\n", timer.ms_since_last_query());77 log("took %ums\n", timer.ms_since_last_query());
7878
79 log("Game: Writing Interactive Player Data ... ");79 log("Game: Writing Interactive Player Data ... ");
80 {GameInteractivePlayerPacket p; p.write(m_fs, m_game, mos);}80 {GameInteractivePlayerPacket p; p.write(m_fs, game_, mos);}
81 log("took %ums\n", timer.ms_since_last_query());81 log("took %ums\n", timer.ms_since_last_query());
82}82}
8383
8484
=== modified file 'src/game_io/game_saver.h'
--- src/game_io/game_saver.h 2014-09-10 07:57:29 +0000
+++ src/game_io/game_saver.h 2016-03-02 18:10:45 +0000
@@ -44,7 +44,7 @@
4444
45private:45private:
46 FileSystem & m_fs;46 FileSystem & m_fs;
47 Game & m_game;47 Game & game_;
48};48};
4949
50}50}
5151
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2016-02-21 18:02:23 +0000
+++ src/logic/game.cc 2016-03-02 18:10:45 +0000
@@ -89,8 +89,8 @@
8989
90void Game::SyncWrapper::data(void const * const sync_data, size_t const size) {90void Game::SyncWrapper::data(void const * const sync_data, size_t const size) {
91#ifdef SYNC_DEBUG91#ifdef SYNC_DEBUG
92 uint32_t time = m_game.get_gametime();92 uint32_t time = game_.get_gametime();
93 log("[sync:%08u t=%6u]", m_counter, time);93 log("[sync:%08u t=%6u]", counter_, time);
94 for (size_t i = 0; i < size; ++i)94 for (size_t i = 0; i < size; ++i)
95 log(" %02x", (static_cast<uint8_t const *>(sync_data))[i]);95 log(" %02x", (static_cast<uint8_t const *>(sync_data))[i]);
96 log("\n");96 log("\n");
9797
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2016-03-02 10:04:54 +0000
+++ src/logic/map.cc 2016-03-02 18:10:45 +0000
@@ -664,7 +664,7 @@
664*/664*/
665struct FindBobsCallback {665struct FindBobsCallback {
666 FindBobsCallback(std::vector<Bob *> * const list, const FindBob & functor)666 FindBobsCallback(std::vector<Bob *> * const list, const FindBob & functor)
667 : m_list(list), m_functor(functor), m_found(0) {}667 : list_(list), functor_(functor), found_(0) {}
668668
669 void operator()(const Map &, const FCoords cur) {669 void operator()(const Map &, const FCoords cur) {
670 for670 for
@@ -673,22 +673,22 @@
673 bob = bob->get_next_bob())673 bob = bob->get_next_bob())
674 {674 {
675 if675 if
676 (m_list &&676 (list_ &&
677 std::find(m_list->begin(), m_list->end(), bob) != m_list->end())677 std::find(list_->begin(), list_->end(), bob) != list_->end())
678 continue;678 continue;
679679
680 if (m_functor.accept(bob)) {680 if (functor_.accept(bob)) {
681 if (m_list)681 if (list_)
682 m_list->push_back(bob);682 list_->push_back(bob);
683683
684 ++m_found;684 ++found_;
685 }685 }
686 }686 }
687 }687 }
688688
689 std::vector<Bob *> * m_list;689 std::vector<Bob*>* list_;
690 const FindBob & m_functor;690 const FindBob& functor_;
691 uint32_t m_found;691 uint32_t found_;
692};692};
693693
694694
@@ -711,7 +711,7 @@
711711
712 find(area, cb);712 find(area, cb);
713713
714 return cb.m_found;714 return cb.found_;
715}715}
716716
717717
@@ -737,7 +737,7 @@
737737
738 find_reachable(area, checkstep, cb);738 find_reachable(area, checkstep, cb);
739739
740 return cb.m_found;740 return cb.found_;
741}741}
742742
743743
@@ -751,7 +751,7 @@
751struct FindImmovablesCallback {751struct FindImmovablesCallback {
752 FindImmovablesCallback752 FindImmovablesCallback
753 (std::vector<ImmovableFound> * const list, const FindImmovable & functor)753 (std::vector<ImmovableFound> * const list, const FindImmovable & functor)
754 : m_list(list), m_functor(functor), m_found(0) {}754 : list_(list), functor_(functor), found_(0) {}
755755
756 void operator()(const Map &, const FCoords cur) {756 void operator()(const Map &, const FCoords cur) {
757 BaseImmovable * const imm = cur.field->get_immovable();757 BaseImmovable * const imm = cur.field->get_immovable();
@@ -759,21 +759,21 @@
759 if (!imm)759 if (!imm)
760 return;760 return;
761761
762 if (m_functor.accept(*imm)) {762 if (functor_.accept(*imm)) {
763 if (m_list) {763 if (list_) {
764 ImmovableFound imf;764 ImmovableFound imf;
765 imf.object = imm;765 imf.object = imm;
766 imf.coords = cur;766 imf.coords = cur;
767 m_list->push_back(imf);767 list_->push_back(imf);
768 }768 }
769769
770 ++m_found;770 ++found_;
771 }771 }
772 }772 }
773773
774 std::vector<ImmovableFound> * m_list;774 std::vector<ImmovableFound>* list_;
775 const FindImmovable & m_functor;775 const FindImmovable& functor_;
776 uint32_t m_found;776 uint32_t found_;
777};777};
778778
779779
@@ -794,7 +794,7 @@
794794
795 find(area, cb);795 find(area, cb);
796796
797 return cb.m_found;797 return cb.found_;
798}798}
799799
800800
@@ -818,7 +818,7 @@
818818
819 find_reachable(area, checkstep, cb);819 find_reachable(area, checkstep, cb);
820820
821 return cb.m_found;821 return cb.found_;
822}822}
823823
824824
@@ -862,20 +862,20 @@
862struct FindNodesCallback {862struct FindNodesCallback {
863 FindNodesCallback863 FindNodesCallback
864 (std::vector<Coords> * const list, const FindNode & functor)864 (std::vector<Coords> * const list, const FindNode & functor)
865 : m_list(list), m_functor(functor), m_found(0) {}865 : list_(list), functor_(functor), found_(0) {}
866866
867 void operator()(const Map & map, const FCoords cur) {867 void operator()(const Map & map, const FCoords cur) {
868 if (m_functor.accept(map, cur)) {868 if (functor_.accept(map, cur)) {
869 if (m_list)869 if (list_)
870 m_list->push_back(cur);870 list_->push_back(cur);
871871
872 ++m_found;872 ++found_;
873 }873 }
874 }874 }
875875
876 std::vector<Coords> * m_list;876 std::vector<Coords>* list_;
877 const FindNode & m_functor;877 const FindNode & functor_;
878 uint32_t m_found;878 uint32_t found_;
879};879};
880880
881881
@@ -897,7 +897,7 @@
897897
898 find(area, cb);898 find(area, cb);
899899
900 return cb.m_found;900 return cb.found_;
901}901}
902902
903903
@@ -920,7 +920,7 @@
920920
921 find_reachable(area, checkstep, cb);921 find_reachable(area, checkstep, cb);
922922
923 return cb.m_found;923 return cb.found_;
924}924}
925925
926926
@@ -1424,7 +1424,7 @@
1424 rx = lx + dist;1424 rx = lx + dist;
14251425
1426 // Allow for wrap-around1426 // Allow for wrap-around
1427 // Yes, the second is an else if; see the above if (dist >= m_width)1427 // Yes, the second is an else if; see the above if (dist >= width_)
1428 if (lx < 0)1428 if (lx < 0)
1429 lx += width_;1429 lx += width_;
1430 else if (rx >= static_cast<int32_t>(width_))1430 else if (rx >= static_cast<int32_t>(width_))
14311431
=== modified file 'src/logic/map_objects/tribes/ship.cc'
--- src/logic/map_objects/tribes/ship.cc 2016-02-21 18:02:23 +0000
+++ src/logic/map_objects/tribes/ship.cc 2016-03-02 18:10:45 +0000
@@ -748,9 +748,9 @@
748uint32_t Ship::calculate_sea_route(Game& game, PortDock& pd, Path* finalpath) {748uint32_t Ship::calculate_sea_route(Game& game, PortDock& pd, Path* finalpath) {
749 Map& map = game.map();749 Map& map = game.map();
750 StepEvalAStar se(pd.get_warehouse()->get_position());750 StepEvalAStar se(pd.get_warehouse()->get_position());
751 se.m_swim = true;751 se.swim_ = true;
752 se.m_conservative = false;752 se.conservative_ = false;
753 se.m_estimator_bias = -5 * map.calc_cost(0);753 se.estimator_bias_ = -5 * map.calc_cost(0);
754754
755 MapAStar<StepEvalAStar> astar(map, se);755 MapAStar<StepEvalAStar> astar(map, se);
756756
757757
=== modified file 'src/logic/map_objects/tribes/soldier.cc'
--- src/logic/map_objects/tribes/soldier.cc 2016-02-16 13:15:29 +0000
+++ src/logic/map_objects/tribes/soldier.cc 2016-03-02 18:10:45 +0000
@@ -425,7 +425,7 @@
425/// Calculates the actual position to draw on from the base node position.425/// Calculates the actual position to draw on from the base node position.
426/// This function takes battling into account.426/// This function takes battling into account.
427///427///
428/// pos is the location, in pixels, of the node m_position (height is already428/// pos is the location, in pixels, of the node position_ (height is already
429/// taken into account).429/// taken into account).
430Point Soldier::calc_drawpos430Point Soldier::calc_drawpos
431 (const EditorGameBase & game, const Point pos) const431 (const EditorGameBase & game, const Point pos) const
@@ -695,13 +695,13 @@
695}695}
696696
697struct FindNodeOwned {697struct FindNodeOwned {
698 FindNodeOwned(PlayerNumber owner) : m_owner(owner)698 FindNodeOwned(PlayerNumber owner) : owner_(owner)
699 {}699 {}
700 bool accept(const Map&, const FCoords& coords) const {700 bool accept(const Map&, const FCoords& coords) const {
701 return (coords.field->get_owned_by() == m_owner);701 return (coords.field->get_owned_by() == owner_);
702 }702 }
703private:703private:
704 PlayerNumber m_owner;704 PlayerNumber owner_;
705};705};
706706
707/**707/**
708708
=== modified file 'src/logic/map_revision.cc'
--- src/logic/map_revision.cc 2014-02-22 18:04:02 +0000
+++ src/logic/map_revision.cc 2016-03-02 18:10:45 +0000
@@ -25,11 +25,11 @@
2525
2626
27MapVersion::MapVersion() :27MapVersion::MapVersion() :
28m_map_version_major(0),28map_version_major_(0),
29m_map_version_minor(0)29map_version_minor_(0)
30{30{
31 m_map_creator_version = build_id();31 map_creator_version_ = build_id();
32 m_map_version_timestamp = static_cast<uint32_t>(time(nullptr));32 map_version_timestamp_ = static_cast<uint32_t>(time(nullptr));
33}33}
3434
35}35}
3636
=== modified file 'src/logic/map_revision.h'
--- src/logic/map_revision.h 2014-07-05 16:41:51 +0000
+++ src/logic/map_revision.h 2016-03-02 18:10:45 +0000
@@ -34,12 +34,12 @@
3434
35struct MapVersion {35struct MapVersion {
3636
37 std::string m_map_source_url;37 std::string map_source_url_;
38 std::string m_map_source_release;38 std::string map_source_release_;
39 std::string m_map_creator_version;39 std::string map_creator_version_;
40 int32_t m_map_version_major;40 int32_t map_version_major_;
41 int32_t m_map_version_minor;41 int32_t map_version_minor_;
42 uint32_t m_map_version_timestamp;42 uint32_t map_version_timestamp_;
4343
44 MapVersion();44 MapVersion();
4545
4646
=== modified file 'src/logic/mapastar.h'
--- src/logic/mapastar.h 2016-02-15 23:26:42 +0000
+++ src/logic/mapastar.h 2016-03-02 18:10:45 +0000
@@ -53,37 +53,37 @@
5353
54struct StepEvalAStar {54struct StepEvalAStar {
55 StepEvalAStar(Coords target) :55 StepEvalAStar(Coords target) :
56 m_target(target),56 target_(target),
57 m_estimator_bias(0),57 estimator_bias_(0),
58 m_conservative(true),58 conservative_(true),
59 m_swim(false)59 swim_(false)
60 {60 {
61 }61 }
6262
63 int32_t estimate(Map & map, FCoords pos) const63 int32_t estimate(Map & map, FCoords pos) const
64 {64 {
65 int32_t est = m_estimator_bias;65 int32_t est = estimator_bias_;
66 if (m_conservative)66 if (conservative_)
67 est += map.calc_cost_lowerbound(pos, m_target);67 est += map.calc_cost_lowerbound(pos, target_);
68 else68 else
69 est += map.calc_cost_estimate(pos, m_target);69 est += map.calc_cost_estimate(pos, target_);
70 return est;70 return est;
71 }71 }
7272
73 int32_t stepcost(Map & map, FCoords from, int32_t /* fromcost */, WalkingDir dir, FCoords to) const73 int32_t stepcost(Map & map, FCoords from, int32_t /* fromcost */, WalkingDir dir, FCoords to) const
74 {74 {
75 if75 if
76 ((m_swim && !(to.field->nodecaps() & MOVECAPS_SWIM)) ||76 ((swim_ && !(to.field->nodecaps() & MOVECAPS_SWIM)) ||
77 (!m_swim && !(to.field->nodecaps() & MOVECAPS_WALK)))77 (!swim_ && !(to.field->nodecaps() & MOVECAPS_WALK)))
78 return -1;78 return -1;
7979
80 return map.calc_cost(from, dir);80 return map.calc_cost(from, dir);
81 }81 }
8282
83 Coords m_target;83 Coords target_;
84 int32_t m_estimator_bias;84 int32_t estimator_bias_;
85 bool m_conservative;85 bool conservative_;
86 bool m_swim;86 bool swim_;
87};87};
8888
8989
9090
=== modified file 'src/logic/mapdifferenceregion.cc'
--- src/logic/mapdifferenceregion.cc 2016-01-18 19:35:25 +0000
+++ src/logic/mapdifferenceregion.cc 2016-03-02 18:10:45 +0000
@@ -25,17 +25,17 @@
2525
26template <> bool MapDifferenceRegion<Area<FCoords> >::advance(const Map & map)26template <> bool MapDifferenceRegion<Area<FCoords> >::advance(const Map & map)
27{27{
28 assert(1 <= m_direction);28 assert(1 <= direction_);
29 assert (m_direction <= 6);29 assert (direction_ <= 6);
30 if (m_remaining_in_edge) {30 if (remaining_in_edge_) {
31 map.get_neighbour(m_area, m_direction, &m_area);31 map.get_neighbour(area_, direction_, &area_);
32 --m_remaining_in_edge;32 --remaining_in_edge_;
33 return true;33 return true;
34 } else {34 } else {
35 if (!m_passed_corner) {35 if (!passed_corner_) {
36 m_passed_corner = true;36 passed_corner_ = true;
37 --m_direction; if (!m_direction) m_direction = 6;37 --direction_; if (!direction_) direction_ = 6;
38 m_remaining_in_edge = m_area.radius;38 remaining_in_edge_ = area_.radius;
39 return advance(map);39 return advance(map);
40 }40 }
41 }41 }
@@ -45,16 +45,16 @@
45template <>45template <>
46void MapDifferenceRegion<Area<FCoords> >::move_to_other_side(const Map & map)46void MapDifferenceRegion<Area<FCoords> >::move_to_other_side(const Map & map)
47{47{
48 assert(1 <= m_direction);48 assert(1 <= direction_);
49 assert (m_direction <= 6);49 assert (direction_ <= 6);
50 assert(m_passed_corner);50 assert(passed_corner_);
51 --m_direction; if (!m_direction) m_direction = 6;51 --direction_; if (!direction_) direction_ = 6;
52 Area<FCoords>::RadiusType steps_left = m_area.radius + 1;52 Area<FCoords>::RadiusType steps_left = area_.radius + 1;
53 switch (m_direction) {53 switch (direction_) {
54#define DIRECTION_CASE(dir, neighbour_function) \54#define DIRECTION_CASE(dir, neighbour_function) \
55 case dir: \55 case dir: \
56 for (; steps_left; --steps_left) \56 for (; steps_left; --steps_left) \
57 map.neighbour_function(m_area, &m_area); \57 map.neighbour_function(area_, &area_); \
58 break; \58 break; \
5959
60 DIRECTION_CASE(WALK_NW, get_tln);60 DIRECTION_CASE(WALK_NW, get_tln);
@@ -66,9 +66,9 @@
66 default:66 default:
67 NEVER_HERE();67 NEVER_HERE();
68 }68 }
69 --m_direction; if (!m_direction) m_direction = 6;69 --direction_; if (!direction_) direction_ = 6;
70 m_remaining_in_edge = m_area.radius;70 remaining_in_edge_ = area_.radius;
71 m_passed_corner = false;71 passed_corner_ = false;
72}72}
7373
74}74}
7575
=== modified file 'src/logic/mapdifferenceregion.h'
--- src/logic/mapdifferenceregion.h 2014-09-10 08:55:04 +0000
+++ src/logic/mapdifferenceregion.h 2016-03-02 18:10:45 +0000
@@ -40,7 +40,7 @@
40template <typename AreaType = Area<> > struct MapDifferenceRegion {40template <typename AreaType = Area<> > struct MapDifferenceRegion {
41 MapDifferenceRegion41 MapDifferenceRegion
42 (const Map & map, AreaType area, Direction direction)42 (const Map & map, AreaType area, Direction direction)
43 : m_area(area), m_remaining_in_edge(area.radius), m_passed_corner(false)43 : area_(area), remaining_in_edge_(area.radius), passed_corner_(false)
44 {44 {
45 assert(1 <= direction);45 assert(1 <= direction);
46 assert (direction <= 6);46 assert (direction <= 6);
@@ -50,7 +50,7 @@
50#define DIRECTION_CASE(dir, neighbour_function) \50#define DIRECTION_CASE(dir, neighbour_function) \
51 case dir: \51 case dir: \
52 for (; area.radius; --area.radius) \52 for (; area.radius; --area.radius) \
53 map.neighbour_function(m_area, &m_area); \53 map.neighbour_function(area_, &area_); \
54 break; \54 break; \
5555
56 DIRECTION_CASE(WALK_NW, get_tln);56 DIRECTION_CASE(WALK_NW, get_tln);
@@ -63,10 +63,10 @@
63 }63 }
64 --direction; if (!direction) direction = 6;64 --direction; if (!direction) direction = 6;
65 --direction; if (!direction) direction = 6;65 --direction; if (!direction) direction = 6;
66 m_direction = direction;66 direction_ = direction;
67 }67 }
6868
69 typename AreaType::CoordsType & location() const {return m_area;}69 typename AreaType::CoordsType & location() const {return area_;}
7070
71 /**71 /**
72 * Moves on to the next location. The return value indicates whether the new72 * Moves on to the next location. The return value indicates whether the new
@@ -80,12 +80,12 @@
8080
81 void move_to_other_side(const Map & map);81 void move_to_other_side(const Map & map);
8282
83 typename AreaType::RadiusType radius() const {return m_area.radius;}83 typename AreaType::RadiusType radius() const {return area_.radius;}
84private:84private:
85 AreaType m_area;85 AreaType area_;
86 typename AreaType::RadiusType m_remaining_in_edge;86 typename AreaType::RadiusType remaining_in_edge_;
87 bool m_passed_corner;87 bool passed_corner_;
88 Direction m_direction;88 Direction direction_;
89};89};
9090
91}91}
9292
=== modified file 'src/logic/mapfringeregion.cc'
--- src/logic/mapfringeregion.cc 2016-01-18 19:35:25 +0000
+++ src/logic/mapfringeregion.cc 2016-03-02 18:10:45 +0000
@@ -25,56 +25,56 @@
2525
26template <>26template <>
27bool MapFringeRegion<Area<FCoords> >::advance(const Map & map) {27bool MapFringeRegion<Area<FCoords> >::advance(const Map & map) {
28 switch (m_phase) {28 switch (phase_) {
29 case 0:29 case 0:
30 if (m_area.radius) {30 if (area_.radius) {
31 m_remaining_in_phase = m_area.radius;31 remaining_in_phase_ = area_.radius;
32 m_phase = 6;32 phase_ = 6;
33 }33 }
34 else34 else
35 return false;35 return false;
36 /* no break */36 /* no break */
37 case 1: map.get_trn(m_area, &m_area); break;37 case 1: map.get_trn(area_, &area_); break;
38 case 2: map.get_tln(m_area, &m_area); break;38 case 2: map.get_tln(area_, &area_); break;
39 case 3: map. get_ln(m_area, &m_area); break;39 case 3: map. get_ln(area_, &area_); break;
40 case 4: map.get_bln(m_area, &m_area); break;40 case 4: map.get_bln(area_, &area_); break;
41 case 5: map.get_brn(m_area, &m_area); break;41 case 5: map.get_brn(area_, &area_); break;
42 case 6: map. get_rn(m_area, &m_area); break;42 case 6: map. get_rn(area_, &area_); break;
43 default:43 default:
44 NEVER_HERE();44 NEVER_HERE();
45 }45 }
46 if (--m_remaining_in_phase == 0) {46 if (--remaining_in_phase_ == 0) {
47 m_remaining_in_phase = m_area.radius;47 remaining_in_phase_ = area_.radius;
48 --m_phase;48 --phase_;
49 }49 }
50 return m_phase;50 return phase_;
51}51}
5252
53template <>53template <>
54bool MapFringeRegion<Area<> >::advance(const Map & map) {54bool MapFringeRegion<Area<> >::advance(const Map & map) {
55 switch (m_phase) {55 switch (phase_) {
56 case 0:56 case 0:
57 if (m_area.radius) {57 if (area_.radius) {
58 m_remaining_in_phase = m_area.radius;58 remaining_in_phase_ = area_.radius;
59 m_phase = 6;59 phase_ = 6;
60 }60 }
61 else61 else
62 return false;62 return false;
63 /* no break */63 /* no break */
64 case 1: map.get_trn(m_area, &m_area); break;64 case 1: map.get_trn(area_, &area_); break;
65 case 2: map.get_tln(m_area, &m_area); break;65 case 2: map.get_tln(area_, &area_); break;
66 case 3: map. get_ln(m_area, &m_area); break;66 case 3: map. get_ln(area_, &area_); break;
67 case 4: map.get_bln(m_area, &m_area); break;67 case 4: map.get_bln(area_, &area_); break;
68 case 5: map.get_brn(m_area, &m_area); break;68 case 5: map.get_brn(area_, &area_); break;
69 case 6: map. get_rn(m_area, &m_area); break;69 case 6: map. get_rn(area_, &area_); break;
70 default:70 default:
71 NEVER_HERE();71 NEVER_HERE();
72 }72 }
73 if (--m_remaining_in_phase == 0) {73 if (--remaining_in_phase_ == 0) {
74 m_remaining_in_phase = m_area.radius;74 remaining_in_phase_ = area_.radius;
75 --m_phase;75 --phase_;
76 }76 }
77 return m_phase;77 return phase_;
78}78}
7979
80}80}
8181
=== modified file 'src/logic/mapfringeregion.h'
--- src/logic/mapfringeregion.h 2014-09-10 08:55:04 +0000
+++ src/logic/mapfringeregion.h 2016-03-02 18:10:45 +0000
@@ -34,16 +34,16 @@
34 */34 */
35template <typename AreaType = Area<> > struct MapFringeRegion {35template <typename AreaType = Area<> > struct MapFringeRegion {
36 MapFringeRegion(const Map & map, AreaType area) :36 MapFringeRegion(const Map & map, AreaType area) :
37 m_area (area),37 area_ (area),
38 m_remaining_in_phase(area.radius),38 remaining_in_phase_(area.radius),
39 m_phase (area.radius ? 6 : 0)39 phase_ (area.radius ? 6 : 0)
40 {40 {
41 for (typename AreaType::RadiusType r = area.radius; r; --r)41 for (typename AreaType::RadiusType r = area.radius; r; --r)
42 map.get_tln(m_area, &m_area);42 map.get_tln(area_, &area_);
43 }43 }
4444
4545
46 const typename AreaType::CoordsType & location() const {return m_area;}46 const typename AreaType::CoordsType & location() const {return area_;}
4747
48 /**48 /**
49 * Moves on to the next location. The return value indicates whether the new49 * Moves on to the next location. The return value indicates whether the new
@@ -64,17 +64,17 @@
64 * the region ready to iterate over the next layer of nodes.64 * the region ready to iterate over the next layer of nodes.
65 */65 */
66 void extend(const Map & map) {66 void extend(const Map & map) {
67 map.get_tln(m_area, &m_area);67 map.get_tln(area_, &area_);
68 ++m_area.radius;68 ++area_.radius;
69 m_remaining_in_phase = m_area.radius;69 remaining_in_phase_ = area_.radius;
70 m_phase = 6;70 phase_ = 6;
71 }71 }
7272
73 typename AreaType::RadiusType radius() const {return m_area.radius;}73 typename AreaType::RadiusType radius() const {return area_.radius;}
74private:74private:
75 AreaType m_area;75 AreaType area_;
76 typename AreaType::RadiusType m_remaining_in_phase;76 typename AreaType::RadiusType remaining_in_phase_;
77 uint8_t m_phase;77 uint8_t phase_;
78};78};
7979
80}80}
8181
=== modified file 'src/logic/maphollowregion.cc'
--- src/logic/maphollowregion.cc 2014-07-20 07:45:17 +0000
+++ src/logic/maphollowregion.cc 2016-03-02 18:10:45 +0000
@@ -24,63 +24,63 @@
24template <> MapHollowRegion<Area<> >::MapHollowRegion24template <> MapHollowRegion<Area<> >::MapHollowRegion
25 (const Map & map, HollowArea<Area<> > const hollow_area)25 (const Map & map, HollowArea<Area<> > const hollow_area)
26:26:
27m_hollow_area (hollow_area),27hollow_area_ (hollow_area),
28m_phase (Top),28phase_ (Top),
29m_delta_radius(hollow_area.radius - hollow_area.hole_radius),29delta_radius_(hollow_area.radius - hollow_area.hole_radius),
30m_row (0),30row_ (0),
31m_rowwidth (hollow_area.radius + 1),31rowwidth_ (hollow_area.radius + 1),
32m_rowpos (0),32rowpos_ (0),
33m_left (hollow_area)33left_ (hollow_area)
34{34{
35 assert(hollow_area.hole_radius < hollow_area.radius);35 assert(hollow_area.hole_radius < hollow_area.radius);
36 for (uint16_t r = hollow_area.radius; r; --r)36 for (uint16_t r = hollow_area.radius; r; --r)
37 map.get_tln(m_hollow_area, &m_hollow_area);37 map.get_tln(hollow_area_, &hollow_area_);
38 m_left = m_hollow_area;38 left_ = hollow_area_;
39}39}
4040
41template <> bool MapHollowRegion<Area<> >::advance(const Map & map) {41template <> bool MapHollowRegion<Area<> >::advance(const Map & map) {
42 if (m_phase == None)42 if (phase_ == None)
43 return false;43 return false;
44 ++m_rowpos;44 ++rowpos_;
45 if (m_rowpos < m_rowwidth) {45 if (rowpos_ < rowwidth_) {
46 map.get_rn(m_hollow_area, &m_hollow_area);46 map.get_rn(hollow_area_, &hollow_area_);
47 if ((m_phase & (Upper|Lower)) && m_rowpos == m_delta_radius) {47 if ((phase_ & (Upper|Lower)) && rowpos_ == delta_radius_) {
48 // Jump over the hole.48 // Jump over the hole.
49 const uint32_t holewidth = m_rowwidth - 2 * m_delta_radius;49 const uint32_t holewidth = rowwidth_ - 2 * delta_radius_;
50 for (uint32_t i = 0; i < holewidth; ++i)50 for (uint32_t i = 0; i < holewidth; ++i)
51 map.get_rn(m_hollow_area, &m_hollow_area);51 map.get_rn(hollow_area_, &hollow_area_);
52 m_rowpos += holewidth;52 rowpos_ += holewidth;
53 }53 }
54 } else {54 } else {
55 ++m_row;55 ++row_;
56 if (m_phase == Top && m_row == m_delta_radius)56 if (phase_ == Top && row_ == delta_radius_)
57 m_phase = Upper;57 phase_ = Upper;
5858
59 // If we completed the widest, center line, switch into lower mode59 // If we completed the widest, center line, switch into lower mode
60 // There are m_radius+1 lines in the upper "half", because the upper60 // There are radius_+1 lines in the upper "half", because the upper
61 // half includes the center line.61 // half includes the center line.
62 else if (m_phase == Upper && m_row > m_hollow_area.radius) {62 else if (phase_ == Upper && row_ > hollow_area_.radius) {
63 m_row = 1;63 row_ = 1;
64 m_phase = Lower;64 phase_ = Lower;
65 }65 }
6666
67 if (m_phase & (Top|Upper)) {67 if (phase_ & (Top|Upper)) {
68 map.get_bln(m_left, &m_hollow_area);68 map.get_bln(left_, &hollow_area_);
69 ++m_rowwidth;69 ++rowwidth_;
70 } else {70 } else {
7171
72 if (m_row > m_hollow_area.radius) {72 if (row_ > hollow_area_.radius) {
73 m_phase = None;73 phase_ = None;
74 return true; // early out74 return true; // early out
75 } else if (m_phase == Lower && m_row > m_hollow_area.hole_radius)75 } else if (phase_ == Lower && row_ > hollow_area_.hole_radius)
76 m_phase = Bottom;76 phase_ = Bottom;
7777
78 map.get_brn(m_left, &m_hollow_area);78 map.get_brn(left_, &hollow_area_);
79 --m_rowwidth;79 --rowwidth_;
80 }80 }
8181
82 m_left = m_hollow_area;82 left_ = hollow_area_;
83 m_rowpos = 0;83 rowpos_ = 0;
84 }84 }
8585
86 return true;86 return true;
8787
=== modified file 'src/logic/maphollowregion.h'
--- src/logic/maphollowregion.h 2014-09-10 08:55:04 +0000
+++ src/logic/maphollowregion.h 2016-03-02 18:10:45 +0000
@@ -35,7 +35,7 @@
35 MapHollowRegion(const Map & map, const HollowArea<AreaType> hollow_area);35 MapHollowRegion(const Map & map, const HollowArea<AreaType> hollow_area);
3636
37 const typename AreaType::CoordsType& location() const {37 const typename AreaType::CoordsType& location() const {
38 return m_hollow_area;38 return hollow_area_;
39 }39 }
4040
41 /**41 /**
@@ -64,13 +64,13 @@
64 Bottom = 8, // below the hole64 Bottom = 8, // below the hole
65 };65 };
6666
67 HollowArea<AreaType> m_hollow_area;67 HollowArea<AreaType> hollow_area_;
68 Phase m_phase;68 Phase phase_;
69 const uint32_t m_delta_radius;69 const uint32_t delta_radius_;
70 uint32_t m_row; // # of rows completed in this phase70 uint32_t row_; // # of rows completed in this phase
71 uint32_t m_rowwidth; // # of fields to return per row71 uint32_t rowwidth_; // # of fields to return per row
72 uint32_t m_rowpos; // # of fields we have returned in this row72 uint32_t rowpos_; // # of fields we have returned in this row
73 typename AreaType::CoordsType m_left; // left-most node of current row73 typename AreaType::CoordsType left_; // left-most node of current row
74};74};
7575
76}76}
7777
=== modified file 'src/logic/mapregion.h'
--- src/logic/mapregion.h 2014-09-10 08:55:04 +0000
+++ src/logic/mapregion.h 2016-03-02 18:10:45 +0000
@@ -31,17 +31,17 @@
31 */31 */
32template <typename AreaType = Area<> > struct MapRegion {32template <typename AreaType = Area<> > struct MapRegion {
33 MapRegion(const Map & map, AreaType area) :33 MapRegion(const Map & map, AreaType area) :
34 m_area (area),34 area_ (area),
35 m_rowwidth (area.radius + 1),35 rowwidth_ (area.radius + 1),
36 m_remaining_in_row(m_rowwidth),36 remaining_in_row_(rowwidth_),
37 m_remaining_rows (m_rowwidth + area.radius)37 remaining_rows_ (rowwidth_ + area.radius)
38 {38 {
39 for (typename AreaType::RadiusType r = area.radius; r; --r)39 for (typename AreaType::RadiusType r = area.radius; r; --r)
40 map.get_tln(m_area, &m_area);40 map.get_tln(area_, &area_);
41 m_left = m_area;41 left_ = area_;
42 }42 }
4343
44 const typename AreaType::CoordsType & location() const {return m_area;}44 const typename AreaType::CoordsType & location() const {return area_;}
4545
46 /// Moves on to the next location. The return value indicates whether the46 /// Moves on to the next location. The return value indicates whether the
47 /// new location has not yet been reached during this iteration. Note that47 /// new location has not yet been reached during this iteration. Note that
@@ -50,25 +50,25 @@
50 /// while advance keeps returning true. When finally advance returns false,50 /// while advance keeps returning true. When finally advance returns false,
51 /// it means that the iteration is done.51 /// it means that the iteration is done.
52 bool advance(const Map & map) {52 bool advance(const Map & map) {
53 if (--m_remaining_in_row)53 if (--remaining_in_row_)
54 map.get_rn(m_area, &m_area);54 map.get_rn(area_, &area_);
55 else if (m_area.radius < --m_remaining_rows) {55 else if (area_.radius < --remaining_rows_) {
56 map.get_bln(m_left, &m_area); m_left = m_area;56 map.get_bln(left_, &area_); left_ = area_;
57 m_remaining_in_row = ++m_rowwidth;57 remaining_in_row_ = ++rowwidth_;
58 } else if (m_remaining_rows) {58 } else if (remaining_rows_) {
59 map.get_brn(m_left, &m_area); m_left = m_area;59 map.get_brn(left_, &area_); left_ = area_;
60 m_remaining_in_row = --m_rowwidth;60 remaining_in_row_ = --rowwidth_;
61 } else return false;61 } else return false;
62 return true;62 return true;
63 }63 }
6464
65 typename AreaType::RadiusType radius() const {return m_area.radius;}65 typename AreaType::RadiusType radius() const {return area_.radius;}
66private:66private:
67 AreaType m_area;67 AreaType area_;
68 typename AreaType::CoordsType m_left;68 typename AreaType::CoordsType left_;
69 typename AreaType::RadiusType m_rowwidth;69 typename AreaType::RadiusType rowwidth_;
70 typename AreaType::RadiusType m_remaining_in_row;70 typename AreaType::RadiusType remaining_in_row_;
71 typename AreaType::RadiusType m_remaining_rows;71 typename AreaType::RadiusType remaining_rows_;
72};72};
7373
74}74}
7575
=== modified file 'src/logic/maptriangleregion.cc'
--- src/logic/maptriangleregion.cc 2016-01-17 08:29:59 +0000
+++ src/logic/maptriangleregion.cc 2016-03-02 18:10:45 +0000
@@ -23,175 +23,175 @@
2323
24template <> MapTriangleRegion<>::MapTriangleRegion24template <> MapTriangleRegion<>::MapTriangleRegion
25 (const Map & map, Area<TCoords<> > area)25 (const Map & map, Area<TCoords<> > area)
26: m_radius_is_odd(area.radius & 1)26: radius_is_odd_(area.radius & 1)
27{27{
28 assert(area.t == TCoords<>::R || area.t == TCoords<>::D);28 assert(area.t == TCoords<>::R || area.t == TCoords<>::D);
29 const uint16_t radius_plus_1 = area.radius + 1;29 const uint16_t radius_plus_1 = area.radius + 1;
30 const uint16_t half_radius_rounded_down = area.radius / 2;30 const uint16_t half_radius_rounded_down = area.radius / 2;
31 m_row_length = radius_plus_1;31 row_length_ = radius_plus_1;
32 for (uint32_t i = half_radius_rounded_down; i; --i) map.get_tln(area, &area);32 for (uint32_t i = half_radius_rounded_down; i; --i) map.get_tln(area, &area);
33 if (area.t == TCoords<>::R) {33 if (area.t == TCoords<>::R) {
34 m_left = area;34 left_ = area;
35 if (area.radius) {35 if (area.radius) {
36 m_remaining_rows_in_upper_phase = half_radius_rounded_down + 1;36 remaining_rows_in_upper_phase_ = half_radius_rounded_down + 1;
37 m_remaining_rows_in_lower_phase = (area.radius - 1) / 2;37 remaining_rows_in_lower_phase_ = (area.radius - 1) / 2;
38 if (m_radius_is_odd) {38 if (radius_is_odd_) {
39 map.get_trn(area, &area);39 map.get_trn(area, &area);
40 m_phase = Top;40 phase_ = Top;
41 m_row_length = area.radius + 2;41 row_length_ = area.radius + 2;
42 m_remaining_in_row = radius_plus_1 / 2;42 remaining_in_row_ = radius_plus_1 / 2;
43 area.t = TCoords<>::D;43 area.t = TCoords<>::D;
44 } else {44 } else {
45 m_phase = Upper;45 phase_ = Upper;
46 m_remaining_in_row = m_row_length = radius_plus_1;46 remaining_in_row_ = row_length_ = radius_plus_1;
47 area.t = TCoords<>::R;47 area.t = TCoords<>::R;
48 }48 }
49 } else {49 } else {
50 assert(area.radius == 0);50 assert(area.radius == 0);
51 m_phase = Bottom;51 phase_ = Bottom;
52 m_remaining_in_row = 0;52 remaining_in_row_ = 0;
53 area.t = TCoords<>::R;53 area.t = TCoords<>::R;
54 }54 }
55 } else {55 } else {
56 m_remaining_rows_in_upper_phase = radius_plus_1 / 2;56 remaining_rows_in_upper_phase_ = radius_plus_1 / 2;
57 m_remaining_rows_in_lower_phase = half_radius_rounded_down;57 remaining_rows_in_lower_phase_ = half_radius_rounded_down;
58 if (m_radius_is_odd) {58 if (radius_is_odd_) {
59 map.get_ln(area, &area);59 map.get_ln(area, &area);
60 m_left = area;60 left_ = area;
61 m_phase = Upper;61 phase_ = Upper;
62 m_remaining_in_row = m_row_length = area.radius + 2;62 remaining_in_row_ = row_length_ = area.radius + 2;
63 area.t = TCoords<>::R;63 area.t = TCoords<>::R;
64 } else {64 } else {
65 map.get_bln(area, &m_left);65 map.get_bln(area, &left_);
66 m_phase = Top;66 phase_ = Top;
67 m_row_length = area.radius + 3;67 row_length_ = area.radius + 3;
68 m_remaining_in_row = half_radius_rounded_down + (0 < area.radius);68 remaining_in_row_ = half_radius_rounded_down + (0 < area.radius);
69 area.t = TCoords<>::D;69 area.t = TCoords<>::D;
70 }70 }
71 }71 }
72 m_location = area;72 location_ = area;
73}73}
7474
7575
76template <> bool MapTriangleRegion<>::advance(const Map & map) {76template <> bool MapTriangleRegion<>::advance(const Map & map) {
77 assert(m_remaining_in_row < 10000); // Catch wrapping (integer underflow)77 assert(remaining_in_row_ < 10000); // Catch wrapping (integer underflow)
78 if (m_remaining_in_row == 0)78 if (remaining_in_row_ == 0)
79 return false;79 return false;
80 --m_remaining_in_row;80 --remaining_in_row_;
81 switch (m_phase) {81 switch (phase_) {
82 case Top:82 case Top:
83 if (m_remaining_in_row)83 if (remaining_in_row_)
84 map.get_rn(m_location, &m_location);84 map.get_rn(location_, &location_);
85 else if (m_remaining_rows_in_upper_phase) {85 else if (remaining_rows_in_upper_phase_) {
86 m_phase = Upper;86 phase_ = Upper;
87 m_remaining_in_row = m_row_length;87 remaining_in_row_ = row_length_;
88 assert(m_remaining_in_row);88 assert(remaining_in_row_);
89 m_location = TCoords<>(m_left, m_location.t);89 location_ = TCoords<>(left_, location_.t);
90 }90 }
91 break;91 break;
92 case Upper:92 case Upper:
93 if (m_remaining_in_row) {93 if (remaining_in_row_) {
94 if (m_location.t == TCoords<>::D)94 if (location_.t == TCoords<>::D)
95 m_location.t = TCoords<>::R;95 location_.t = TCoords<>::R;
96 else96 else
97 m_location = TCoords<>(map.r_n(m_location), TCoords<>::D);97 location_ = TCoords<>(map.r_n(location_), TCoords<>::D);
98 } else {98 } else {
99 if (--m_remaining_rows_in_upper_phase) {99 if (--remaining_rows_in_upper_phase_) {
100 m_row_length += 2;100 row_length_ += 2;
101 m_left = map.bl_n(m_left);101 left_ = map.bl_n(left_);
102 } else {102 } else {
103 if (m_remaining_rows_in_lower_phase) {103 if (remaining_rows_in_lower_phase_) {
104 m_phase = Lower;104 phase_ = Lower;
105 assert(m_row_length >= 2);105 assert(row_length_ >= 2);
106 m_row_length -= 2;106 row_length_ -= 2;
107 } else if (m_location.t == TCoords<>::R) {107 } else if (location_.t == TCoords<>::R) {
108 m_phase = Bottom;108 phase_ = Bottom;
109 m_row_length /= 2;109 row_length_ /= 2;
110 } else return false;110 } else return false;
111 m_left = map.br_n(m_left);111 left_ = map.br_n(left_);
112 }112 }
113 m_remaining_in_row = m_row_length;113 remaining_in_row_ = row_length_;
114 m_location = TCoords<>(m_left, m_location.t);114 location_ = TCoords<>(left_, location_.t);
115 }115 }
116 break;116 break;
117 case Lower:117 case Lower:
118 if (m_remaining_in_row) {118 if (remaining_in_row_) {
119 if (m_location.t == TCoords<>::D)119 if (location_.t == TCoords<>::D)
120 m_location.t = TCoords<>::R;120 location_.t = TCoords<>::R;
121 else121 else
122 m_location = TCoords<>(map.r_n(m_location), TCoords<>::D);122 location_ = TCoords<>(map.r_n(location_), TCoords<>::D);
123 } else {123 } else {
124 if (--m_remaining_rows_in_lower_phase) {124 if (--remaining_rows_in_lower_phase_) {
125 assert(m_row_length >= 2);125 assert(row_length_ >= 2);
126 m_remaining_in_row = m_row_length -= 2;126 remaining_in_row_ = row_length_ -= 2;
127 m_left = map.br_n(m_left);127 left_ = map.br_n(left_);
128 }128 }
129 else if (m_location.t == TCoords<>::R) {129 else if (location_.t == TCoords<>::R) {
130 m_phase = Bottom;130 phase_ = Bottom;
131 m_remaining_in_row = m_row_length / 2;131 remaining_in_row_ = row_length_ / 2;
132 m_left = map.br_n(m_left);132 left_ = map.br_n(left_);
133 }133 }
134 m_location = TCoords<>(m_left, m_location.t);134 location_ = TCoords<>(left_, location_.t);
135 }135 }
136 break;136 break;
137 case Bottom:137 case Bottom:
138 if (m_remaining_in_row)138 if (remaining_in_row_)
139 map.get_rn(m_location, &m_location);139 map.get_rn(location_, &location_);
140 break;140 break;
141 }141 }
142 assert(m_remaining_in_row < 10000); // Catch wrapping (integer underflow)142 assert(remaining_in_row_ < 10000); // Catch wrapping (integer underflow)
143 return true;143 return true;
144}144}
145145
146146
147template <> MapTriangleRegion<TCoords<FCoords> >::MapTriangleRegion147template <> MapTriangleRegion<TCoords<FCoords> >::MapTriangleRegion
148 (const Map & map, Area<TCoords<FCoords> > area)148 (const Map & map, Area<TCoords<FCoords> > area)
149: m_radius_is_odd(area.radius & 1)149: radius_is_odd_(area.radius & 1)
150{150{
151 assert(area.t == TCoords<FCoords>::R || area.t == TCoords<FCoords>::D);151 assert(area.t == TCoords<FCoords>::R || area.t == TCoords<FCoords>::D);
152 const uint16_t radius_plus_1 = area.radius + 1;152 const uint16_t radius_plus_1 = area.radius + 1;
153 const uint16_t half_radius_rounded_down = area.radius / 2;153 const uint16_t half_radius_rounded_down = area.radius / 2;
154 m_row_length = radius_plus_1;154 row_length_ = radius_plus_1;
155 for (uint32_t i = half_radius_rounded_down; i; --i) map.get_tln(area, &area);155 for (uint32_t i = half_radius_rounded_down; i; --i) map.get_tln(area, &area);
156 if (area.t == TCoords<FCoords>::R) {156 if (area.t == TCoords<FCoords>::R) {
157 m_left = area;157 left_ = area;
158 if (area.radius) {158 if (area.radius) {
159 m_remaining_rows_in_upper_phase = half_radius_rounded_down + 1;159 remaining_rows_in_upper_phase_ = half_radius_rounded_down + 1;
160 m_remaining_rows_in_lower_phase = (area.radius - 1) / 2;160 remaining_rows_in_lower_phase_ = (area.radius - 1) / 2;
161 if (m_radius_is_odd) {161 if (radius_is_odd_) {
162 map.get_trn(area, &area);162 map.get_trn(area, &area);
163 m_phase = Top;163 phase_ = Top;
164 m_row_length = area.radius + 2;164 row_length_ = area.radius + 2;
165 m_remaining_in_row = radius_plus_1 / 2;165 remaining_in_row_ = radius_plus_1 / 2;
166 area.t = TCoords<FCoords>::D;166 area.t = TCoords<FCoords>::D;
167 } else {167 } else {
168 m_phase = Upper;168 phase_ = Upper;
169 m_remaining_in_row = m_row_length = radius_plus_1;169 remaining_in_row_ = row_length_ = radius_plus_1;
170 area.t = TCoords<FCoords>::R;170 area.t = TCoords<FCoords>::R;
171 }171 }
172 } else {172 } else {
173 m_phase = Bottom;173 phase_ = Bottom;
174 m_remaining_in_row = 0;174 remaining_in_row_ = 0;
175 area.t = TCoords<FCoords>::R;175 area.t = TCoords<FCoords>::R;
176 }176 }
177 } else {177 } else {
178 m_remaining_rows_in_upper_phase = radius_plus_1 / 2;178 remaining_rows_in_upper_phase_ = radius_plus_1 / 2;
179 m_remaining_rows_in_lower_phase = half_radius_rounded_down;179 remaining_rows_in_lower_phase_ = half_radius_rounded_down;
180 if (m_radius_is_odd) {180 if (radius_is_odd_) {
181 map.get_ln(area, &area);181 map.get_ln(area, &area);
182 m_left = area;182 left_ = area;
183 m_phase = Upper;183 phase_ = Upper;
184 m_remaining_in_row = m_row_length = area.radius + 2;184 remaining_in_row_ = row_length_ = area.radius + 2;
185 area.t = TCoords<FCoords>::R;185 area.t = TCoords<FCoords>::R;
186 } else {186 } else {
187 map.get_bln(area, &m_left);187 map.get_bln(area, &left_);
188 m_phase = Top;188 phase_ = Top;
189 m_row_length = area.radius + 3;189 row_length_ = area.radius + 3;
190 m_remaining_in_row = half_radius_rounded_down + (0 < area.radius);190 remaining_in_row_ = half_radius_rounded_down + (0 < area.radius);
191 area.t = TCoords<FCoords>::D;191 area.t = TCoords<FCoords>::D;
192 }192 }
193 }193 }
194 m_location = area;194 location_ = area;
195}195}
196196
197197
@@ -199,75 +199,75 @@
199template <>199template <>
200bool MapTriangleRegion<TCoords<FCoords> >::advance(const Map & map)200bool MapTriangleRegion<TCoords<FCoords> >::advance(const Map & map)
201{201{
202 assert(m_remaining_in_row < 10000); // Catch wrapping (integer underflow)202 assert(remaining_in_row_ < 10000); // Catch wrapping (integer underflow)
203 if (m_remaining_in_row == 0)203 if (remaining_in_row_ == 0)
204 return false;204 return false;
205 --m_remaining_in_row;205 --remaining_in_row_;
206 switch (m_phase) {206 switch (phase_) {
207 case Top:207 case Top:
208 if (m_remaining_in_row)208 if (remaining_in_row_)
209 map.get_rn(m_location, &m_location);209 map.get_rn(location_, &location_);
210 else if (m_remaining_rows_in_upper_phase) {210 else if (remaining_rows_in_upper_phase_) {
211 m_phase = Upper;211 phase_ = Upper;
212 m_remaining_in_row = m_row_length;212 remaining_in_row_ = row_length_;
213 assert(m_remaining_in_row);213 assert(remaining_in_row_);
214 m_location = TCoords<FCoords>(m_left, m_location.t);214 location_ = TCoords<FCoords>(left_, location_.t);
215 }215 }
216 break;216 break;
217 case Upper:217 case Upper:
218 if (m_remaining_in_row) {218 if (remaining_in_row_) {
219 if (m_location.t == TCoords<FCoords>::D)219 if (location_.t == TCoords<FCoords>::D)
220 m_location.t = TCoords<FCoords>::R;220 location_.t = TCoords<FCoords>::R;
221 else221 else
222 m_location =222 location_ =
223 TCoords<FCoords>(map.r_n(m_location), TCoords<FCoords>::D);223 TCoords<FCoords>(map.r_n(location_), TCoords<FCoords>::D);
224 } else {224 } else {
225 if (--m_remaining_rows_in_upper_phase) {225 if (--remaining_rows_in_upper_phase_) {
226 m_row_length += 2;226 row_length_ += 2;
227 m_left = map.bl_n(m_left);227 left_ = map.bl_n(left_);
228 } else {228 } else {
229 if (m_remaining_rows_in_lower_phase) {229 if (remaining_rows_in_lower_phase_) {
230 m_phase = Lower;230 phase_ = Lower;
231 assert(m_row_length >= 2);231 assert(row_length_ >= 2);
232 m_row_length -= 2;232 row_length_ -= 2;
233 } else if (m_location.t == TCoords<FCoords>::R) {233 } else if (location_.t == TCoords<FCoords>::R) {
234 m_phase = Bottom;234 phase_ = Bottom;
235 m_row_length /= 2;235 row_length_ /= 2;
236 } else236 } else
237 return false;237 return false;
238 m_left = map.br_n(m_left);238 left_ = map.br_n(left_);
239 }239 }
240 m_remaining_in_row = m_row_length;240 remaining_in_row_ = row_length_;
241 m_location = TCoords<FCoords>(m_left, m_location.t);241 location_ = TCoords<FCoords>(left_, location_.t);
242 }242 }
243 break;243 break;
244 case Lower:244 case Lower:
245 if (m_remaining_in_row) {245 if (remaining_in_row_) {
246 if (m_location.t == TCoords<FCoords>::D)246 if (location_.t == TCoords<FCoords>::D)
247 m_location.t = TCoords<FCoords>::R;247 location_.t = TCoords<FCoords>::R;
248 else248 else
249 m_location =249 location_ =
250 TCoords<FCoords>(map.r_n(m_location), TCoords<FCoords>::D);250 TCoords<FCoords>(map.r_n(location_), TCoords<FCoords>::D);
251 } else {251 } else {
252 if (--m_remaining_rows_in_lower_phase) {252 if (--remaining_rows_in_lower_phase_) {
253 assert(m_row_length >= 2);253 assert(row_length_ >= 2);
254 m_remaining_in_row = m_row_length -= 2;254 remaining_in_row_ = row_length_ -= 2;
255 m_left = map.br_n(m_left);255 left_ = map.br_n(left_);
256 }256 }
257 else if (m_location.t == TCoords<FCoords>::R) {257 else if (location_.t == TCoords<FCoords>::R) {
258 m_phase = Bottom;258 phase_ = Bottom;
259 m_remaining_in_row = m_row_length / 2;259 remaining_in_row_ = row_length_ / 2;
260 m_left = map.br_n(m_left);260 left_ = map.br_n(left_);
261 }261 }
262 m_location = TCoords<FCoords>(m_left, m_location.t);262 location_ = TCoords<FCoords>(left_, location_.t);
263 }263 }
264 break;264 break;
265 case Bottom:265 case Bottom:
266 if (m_remaining_in_row)266 if (remaining_in_row_)
267 map.get_rn(m_location, &m_location);267 map.get_rn(location_, &location_);
268 break;268 break;
269 }269 }
270 assert(m_remaining_in_row < 10000); // Catch wrapping (integer underflow)270 assert(remaining_in_row_ < 10000); // Catch wrapping (integer underflow)
271 return true;271 return true;
272}272}
273273
274274
=== modified file 'src/logic/maptriangleregion.h'
--- src/logic/maptriangleregion.h 2014-09-10 08:55:04 +0000
+++ src/logic/maptriangleregion.h 2016-03-02 18:10:45 +0000
@@ -65,60 +65,60 @@
65};65};
66template <> struct MapTriangleRegion<FCoords> {66template <> struct MapTriangleRegion<FCoords> {
67 MapTriangleRegion(const Map & map, const Area<FCoords> area) :67 MapTriangleRegion(const Map & map, const Area<FCoords> area) :
68 m_area(TCoords<FCoords>(area, TCoords<FCoords>::D), area.radius + 1),68 area_(TCoords<FCoords>(area, TCoords<FCoords>::D), area.radius + 1),
69 m_rowwidth (m_area.radius * 2 + 1),69 rowwidth_ (area_.radius * 2 + 1),
70 m_remaining_in_row(m_rowwidth),70 remaining_in_row_(rowwidth_),
71 m_remaining_rows (m_area.radius * 2)71 remaining_rows_ (area_.radius * 2)
72 {72 {
73 for (uint8_t r = m_area.radius; r; --r) map.get_tln(m_area, &m_area);73 for (uint8_t r = area_.radius; r; --r) map.get_tln(area_, &area_);
74 m_left = m_area;74 left_ = area_;
75 }75 }
7676
77 const TCoords<FCoords> & location() const {return m_area;}77 const TCoords<FCoords> & location() const {return area_;}
7878
79 bool advance(const Map & map) {79 bool advance(const Map & map) {
80 if (--m_remaining_in_row) {80 if (--remaining_in_row_) {
81 if (m_area.t == TCoords<FCoords>::D)81 if (area_.t == TCoords<FCoords>::D)
82 m_area.t = TCoords<FCoords>::R;82 area_.t = TCoords<FCoords>::R;
83 else {83 else {
84 m_area.t = TCoords<FCoords>::D;84 area_.t = TCoords<FCoords>::D;
85 map.get_rn(m_area, &m_area);85 map.get_rn(area_, &area_);
86 }86 }
87 } else if (m_area.radius < --m_remaining_rows) {87 } else if (area_.radius < --remaining_rows_) {
88 map.get_bln(m_left, &m_area); m_left = m_area;88 map.get_bln(left_, &area_); left_ = area_;
89 m_area.t = TCoords<FCoords>::D;89 area_.t = TCoords<FCoords>::D;
90 m_remaining_in_row = m_rowwidth += 2;90 remaining_in_row_ = rowwidth_ += 2;
91 } else if (m_remaining_rows) {91 } else if (remaining_rows_) {
92 map.get_brn(m_left, &m_area); m_left = m_area;92 map.get_brn(left_, &area_); left_ = area_;
93 m_area.t = TCoords<FCoords>::D;93 area_.t = TCoords<FCoords>::D;
94 m_remaining_in_row = m_rowwidth -= 2;94 remaining_in_row_ = rowwidth_ -= 2;
95 } else return false;95 } else return false;
96 return true;96 return true;
97 }97 }
9898
99private:99private:
100 Area<TCoords<FCoords> > m_area;100 Area<TCoords<FCoords> > area_;
101 FCoords m_left;101 FCoords left_;
102 uint16_t m_rowwidth;102 uint16_t rowwidth_;
103 uint16_t m_remaining_in_row;103 uint16_t remaining_in_row_;
104 uint16_t m_remaining_rows;104 uint16_t remaining_rows_;
105};105};
106template <typename CoordsType> struct MapTriangleRegion<TCoords<CoordsType> >106template <typename CoordsType> struct MapTriangleRegion<TCoords<CoordsType> >
107{107{
108 MapTriangleRegion(const Map &, Area<TCoords<CoordsType>, uint16_t>);108 MapTriangleRegion(const Map &, Area<TCoords<CoordsType>, uint16_t>);
109109
110 const TCoords<CoordsType> & location() const {return m_location;}110 const TCoords<CoordsType> & location() const {return location_;}
111111
112 bool advance(const Map &);112 bool advance(const Map &);
113113
114private:114private:
115 const bool m_radius_is_odd;115 const bool radius_is_odd_;
116 enum {Top, Upper, Lower, Bottom} m_phase;116 enum {Top, Upper, Lower, Bottom} phase_;
117 uint16_t m_remaining_rows_in_upper_phase;117 uint16_t remaining_rows_in_upper_phase_;
118 uint16_t m_remaining_rows_in_lower_phase;118 uint16_t remaining_rows_in_lower_phase_;
119 uint16_t m_row_length, m_remaining_in_row;119 uint16_t row_length_, remaining_in_row_;
120 CoordsType m_left;120 CoordsType left_;
121 TCoords<CoordsType> m_location;121 TCoords<CoordsType> location_;
122};122};
123123
124}124}
125125
=== modified file 'src/logic/message_queue.h'
--- src/logic/message_queue.h 2014-09-30 07:55:22 +0000
+++ src/logic/message_queue.h 2016-03-02 18:10:45 +0000
@@ -33,9 +33,9 @@
33 friend class MapPlayersMessagesPacket;33 friend class MapPlayersMessagesPacket;
3434
35 MessageQueue() {35 MessageQueue() {
36 m_counts[static_cast<int>(Message::Status::kNew)] = 0; // C++0x:36 counts_[static_cast<int>(Message::Status::kNew)] = 0; // C++0x:
37 m_counts[static_cast<int>(Message::Status::kRead)] = 0; // C++0x:37 counts_[static_cast<int>(Message::Status::kRead)] = 0; // C++0x:
38 m_counts[static_cast<int>(Message::Status::kArchived)] = 0; // C++0x:38 counts_[static_cast<int>(Message::Status::kArchived)] = 0; // C++0x:
39 } // C++0x:39 } // C++0x:
4040
41 ~MessageQueue() {41 ~MessageQueue() {
@@ -68,7 +68,7 @@
68 uint32_t nr_messages(Message::Status const status) const {68 uint32_t nr_messages(Message::Status const status) const {
69 assert_counts();69 assert_counts();
70 assert(static_cast<int>(status) < 3);70 assert(static_cast<int>(status) < 3);
71 return m_counts[static_cast<int>(status)];71 return counts_[static_cast<int>(status)];
72 }72 }
7373
74 /// Adds the message. Takes ownership of the message. Assumes that it has74 /// Adds the message. Takes ownership of the message. Assumes that it has
@@ -82,12 +82,12 @@
82 MessageId add_message(Message & message) {82 MessageId add_message(Message & message) {
83 assert_counts();83 assert_counts();
84 assert(static_cast<int>(message.status()) < 3);84 assert(static_cast<int>(message.status()) < 3);
85 ++m_counts[static_cast<int>(message.status())];85 ++counts_[static_cast<int>(message.status())];
86 insert86 insert
87 (std::map<MessageId, Message *>::end(),87 (std::map<MessageId, Message *>::end(),
88 std::pair<MessageId, Message *>(++m_current_message_id, &message));88 std::pair<MessageId, Message *>(++current_message_id_, &message));
89 assert_counts();89 assert_counts();
90 return m_current_message_id;90 return current_message_id_;
91 }91 }
9292
93 /// Sets the status of the message with the given id, if it exists.93 /// Sets the status of the message with the given id, if it exists.
@@ -98,9 +98,9 @@
98 if (it != end()) {98 if (it != end()) {
99 Message & message = *it->second;99 Message & message = *it->second;
100 assert(static_cast<int>(it->second->status()) < 3);100 assert(static_cast<int>(it->second->status()) < 3);
101 assert(m_counts[static_cast<int>(message.status())]);101 assert(counts_[static_cast<int>(message.status())]);
102 --m_counts[static_cast<int>(message.status())];102 --counts_[static_cast<int>(message.status())];
103 ++m_counts[static_cast<int>(message.set_status(status))];103 ++counts_[static_cast<int>(message.set_status(status))];
104 }104 }
105 assert_counts();105 assert_counts();
106 }106 }
@@ -118,14 +118,14 @@
118 }118 }
119 Message & message = *it->second;119 Message & message = *it->second;
120 assert(static_cast<int>(message.status()) < 3);120 assert(static_cast<int>(message.status()) < 3);
121 assert(m_counts[static_cast<int>(message.status())]);121 assert(counts_[static_cast<int>(message.status())]);
122 --m_counts[static_cast<int>(message.status())];122 --counts_[static_cast<int>(message.status())];
123 delete &message;123 delete &message;
124 erase(it);124 erase(it);
125 assert_counts();125 assert_counts();
126 }126 }
127127
128 MessageId current_message_id() const {return m_current_message_id;}128 MessageId current_message_id() const {return current_message_id_;}
129129
130 /// \returns whether all messages with id 1, 2, 3, ..., current_message_id130 /// \returns whether all messages with id 1, 2, 3, ..., current_message_id
131 /// exist. This should be the case when messages have been loaded from a map131 /// exist. This should be the case when messages have been loaded from a map
@@ -142,28 +142,28 @@
142 /// it.142 /// it.
143 void clear() {143 void clear() {
144 assert_counts();144 assert_counts();
145 m_current_message_id = MessageId::null();145 current_message_id_ = MessageId::null();
146 m_counts[static_cast<int>(Message::Status::kNew)] = 0;146 counts_[static_cast<int>(Message::Status::kNew)] = 0;
147 m_counts[static_cast<int>(Message::Status::kRead)] = 0;147 counts_[static_cast<int>(Message::Status::kRead)] = 0;
148 m_counts[static_cast<int>(Message::Status::kArchived)] = 0;148 counts_[static_cast<int>(Message::Status::kArchived)] = 0;
149 std::map<MessageId, Message *>::clear();149 std::map<MessageId, Message *>::clear();
150 assert_counts();150 assert_counts();
151 }151 }
152152
153 /// The id of the most recently added message, or null if none has been153 /// The id of the most recently added message, or null if none has been
154 /// added yet.154 /// added yet.
155 MessageId m_current_message_id;155 MessageId current_message_id_;
156156
157 /// Number of messages with each status (new, read, deleted).157 /// Number of messages with each status (new, read, deleted).
158 /// Indexed by Message::Status.158 /// Indexed by Message::Status.
159 uint32_t m_counts[3];159 uint32_t counts_[3];
160160
161 void assert_counts() const {161 void assert_counts() const {
162 assert162 assert
163 (size() ==163 (size() ==
164 m_counts[static_cast<int>(Message::Status::kNew)] +164 counts_[static_cast<int>(Message::Status::kNew)] +
165 m_counts[static_cast<int>(Message::Status::kRead)] +165 counts_[static_cast<int>(Message::Status::kRead)] +
166 m_counts[static_cast<int>(Message::Status::kArchived)]);166 counts_[static_cast<int>(Message::Status::kArchived)]);
167 }167 }
168168
169 DISALLOW_COPY_AND_ASSIGN(MessageQueue);169 DISALLOW_COPY_AND_ASSIGN(MessageQueue);
170170
=== modified file 'src/logic/path.cc'
--- src/logic/path.cc 2016-02-16 10:27:23 +0000
+++ src/logic/path.cc 2016-03-02 18:10:45 +0000
@@ -70,7 +70,7 @@
70 fw.unsigned_8(kCurrentPacketVersion);70 fw.unsigned_8(kCurrentPacketVersion);
71 write_coords_32(&fw, start_);71 write_coords_32(&fw, start_);
7272
73 // Careful: steps are stored in the reverse order in m_path73 // Careful: steps are stored in the reverse order in path_
74 // However, we save them in the forward order, to make loading easier74 // However, we save them in the forward order, to make loading easier
75 fw.unsigned_32(path_.size());75 fw.unsigned_32(path_.size());
76 for (uint32_t i = path_.size(); i > 0; --i)76 for (uint32_t i = path_.size(); i > 0; --i)
7777
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2016-02-21 20:02:09 +0000
+++ src/logic/player.cc 2016-03-02 18:10:45 +0000
@@ -367,7 +367,7 @@
367 return add_message(game, m);367 return add_message(game, m);
368}368}
369369
370void Player::message_object_removed(MessageId m_id) const370void Player::message_object_removed(MessageId message_id) const
371{371{
372 // Send delete command372 // Send delete command
373 upcast(Game, game, &egbase_);373 upcast(Game, game, &egbase_);
@@ -377,7 +377,7 @@
377377
378 game->cmdqueue().enqueue378 game->cmdqueue().enqueue
379 (new CmdDeleteMessage379 (new CmdDeleteMessage
380 (game->get_gametime(), player_number_, m_id));380 (game->get_gametime(), player_number_, message_id));
381}381}
382382
383383
384384
=== modified file 'src/logic/replay.cc'
--- src/logic/replay.cc 2016-02-16 13:18:59 +0000
+++ src/logic/replay.cc 2016-03-02 18:10:45 +0000
@@ -49,7 +49,7 @@
49class CmdReplaySyncRead : public Command {49class CmdReplaySyncRead : public Command {
50public:50public:
51 CmdReplaySyncRead(const uint32_t init_duetime, const Md5Checksum & hash)51 CmdReplaySyncRead(const uint32_t init_duetime, const Md5Checksum & hash)
52 : Command(init_duetime), m_hash(hash)52 : Command(init_duetime), hash_(hash)
53 {}53 {}
5454
55 QueueCommandTypes id() const override {return QueueCommandTypes::kReplaySyncRead;}55 QueueCommandTypes id() const override {return QueueCommandTypes::kReplaySyncRead;}
@@ -58,12 +58,12 @@
58 {58 {
59 const Md5Checksum myhash = game.get_sync_hash();59 const Md5Checksum myhash = game.get_sync_hash();
6060
61 if (m_hash != myhash) {61 if (hash_ != myhash) {
62 log62 log
63 ("REPLAY: Lost synchronization at time %u\n"63 ("REPLAY: Lost synchronization at time %u\n"
64 "I have: %s\n"64 "I have: %s\n"
65 "Replay has: %s\n",65 "Replay has: %s\n",
66 duetime(), myhash.str().c_str(), m_hash.str().c_str());66 duetime(), myhash.str().c_str(), hash_.str().c_str());
6767
68 // In case syncstream logging is on, save it for analysis68 // In case syncstream logging is on, save it for analysis
69 game.save_syncstream(true);69 game.save_syncstream(true);
@@ -74,7 +74,7 @@
74 }74 }
7575
76private:76private:
77 Md5Checksum m_hash;77 Md5Checksum hash_;
78};78};
7979
8080
8181
=== modified file 'src/map_io/map_version_packet.cc'
--- src/map_io/map_version_packet.cc 2016-02-15 23:26:42 +0000
+++ src/map_io/map_version_packet.cc 2016-03-02 18:10:45 +0000
@@ -44,8 +44,8 @@
44 try {prof.read("version", nullptr, fs);} catch (...)44 try {prof.read("version", nullptr, fs);} catch (...)
45 {45 {
46 Map & map = egbase.map();46 Map & map = egbase.map();
47 map.map_version_.m_map_version_timestamp = 0;47 map.map_version_.map_version_timestamp_ = 0;
48 map.map_version_.m_map_creator_version = "unknown";48 map.map_version_.map_creator_version_ = "unknown";
49 return;49 return;
50 }50 }
5151
@@ -60,13 +60,13 @@
60 || (packet_version > kCurrentPacketVersion && forward_compatibility <= kCurrentPacketVersion))60 || (packet_version > kCurrentPacketVersion && forward_compatibility <= kCurrentPacketVersion))
61 {61 {
62 Map & map = egbase.map();62 Map & map = egbase.map();
63 map.map_version_.m_map_source_url = globv.get_safe_string("map_source_url");63 map.map_version_.map_source_url_ = globv.get_safe_string("map_source_url");
64 map.map_version_.m_map_source_release = globv.get_safe_string("map_release");64 map.map_version_.map_source_release_ = globv.get_safe_string("map_release");
65 map.map_version_.m_map_creator_version = globv.get_safe_string("map_creator_version");65 map.map_version_.map_creator_version_ = globv.get_safe_string("map_creator_version");
66 map.map_version_.m_map_version_major = globv.get_safe_int("map_version_major");66 map.map_version_.map_version_major_ = globv.get_safe_int("map_version_major");
67 map.map_version_.m_map_version_minor = globv.get_safe_int("map_version_minor");67 map.map_version_.map_version_minor_ = globv.get_safe_int("map_version_minor");
68 uint32_t ts = static_cast<uint32_t>(globv.get_safe_int("map_version_timestamp"));68 uint32_t ts = static_cast<uint32_t>(globv.get_safe_int("map_version_timestamp"));
69 map.map_version_.m_map_version_timestamp = ts;69 map.map_version_.map_version_timestamp_ = ts;
70 } else {70 } else {
71 throw UnhandledVersionError("MapVersionPacket", packet_version, kCurrentPacketVersion);71 throw UnhandledVersionError("MapVersionPacket", packet_version, kCurrentPacketVersion);
72 }72 }
@@ -116,11 +116,11 @@
116 // There seems to be a get_safe_natural method, but not corresponding setter.116 // There seems to be a get_safe_natural method, but not corresponding setter.
117117
118 Map & map = egbase.map();118 Map & map = egbase.map();
119 globs.set_string("map_source_url", map.map_version_.m_map_source_url);119 globs.set_string("map_source_url", map.map_version_.map_source_url_);
120 globs.set_string("map_release", map.map_version_.m_map_source_release);120 globs.set_string("map_release", map.map_version_.map_source_release_);
121 globs.set_string("map_creator_version", map.map_version_.m_map_creator_version);121 globs.set_string("map_creator_version", map.map_version_.map_creator_version_);
122 globs.set_int("map_version_major", map.map_version_.m_map_version_major);122 globs.set_int("map_version_major", map.map_version_.map_version_major_);
123 globs.set_int("map_version_minor", 1 + map.map_version_.m_map_version_minor);123 globs.set_int("map_version_minor", 1 + map.map_version_.map_version_minor_);
124 globs.set_int("map_version_timestamp", static_cast<uint32_t>(time(nullptr)));124 globs.set_int("map_version_timestamp", static_cast<uint32_t>(time(nullptr)));
125 globs.set_int("packet_version", kCurrentPacketVersion);125 globs.set_int("packet_version", kCurrentPacketVersion);
126 globs.set_int("packet_compatibility", kCurrentPacketVersion);126 globs.set_int("packet_compatibility", kCurrentPacketVersion);

Subscribers

People subscribed via source and target branches

to status/vote changes: