From: <geo...@us...> - 2014-02-14 07:03:41
|
Revision: 6897 http://sourceforge.net/p/freeorion/code/6897 Author: geoffthemedio Date: 2014-02-14 07:03:36 +0000 (Fri, 14 Feb 2014) Log Message: ----------- Added player status tracking to client app. Modified Paths: -------------- trunk/FreeOrion/client/ClientApp.cpp trunk/FreeOrion/client/ClientApp.h trunk/FreeOrion/client/human/HumanClientFSM.cpp Modified: trunk/FreeOrion/client/ClientApp.cpp =================================================================== --- trunk/FreeOrion/client/ClientApp.cpp 2014-02-14 05:19:34 UTC (rev 6896) +++ trunk/FreeOrion/client/ClientApp.cpp 2014-02-14 07:03:36 UTC (rev 6897) @@ -2,7 +2,6 @@ #include "../combat/CombatOrder.h" #include "../util/Logger.h" -#include "../util/MultiplayerCommon.h" #include "../util/Serialize.h" #include "../universe/UniverseObject.h" #include "../universe/System.h" @@ -104,6 +103,18 @@ std::map<int, PlayerInfo>& ClientApp::Players() { return m_player_info; } +const std::map<int, Message::PlayerStatus>& ClientApp::PlayerStatus() const +{ return m_player_status; } + +std::map<int, Message::PlayerStatus>& ClientApp::PlayerStatus() +{ return m_player_status; } + +void ClientApp::SetPlayerStatus(int player_id, Message::PlayerStatus status) { + if (player_id != Networking::INVALID_PLAYER_ID) + return; + m_player_status[player_id] = status; +} + void ClientApp::StartTurn() { m_networking.SendMessage(TurnOrdersMessage(m_networking.PlayerID(), m_orders)); m_orders.Reset(); Modified: trunk/FreeOrion/client/ClientApp.h =================================================================== --- trunk/FreeOrion/client/ClientApp.h 2014-02-14 05:19:34 UTC (rev 6896) +++ trunk/FreeOrion/client/ClientApp.h 2014-02-14 07:03:36 UTC (rev 6897) @@ -27,9 +27,11 @@ int EmpireID() const; ///< returns the empire ID of this client int CurrentTurn() const; ///< returns the current game turn - int EmpirePlayerID(int empire_id) const; ///< returns the player ID for the player playing the empire with ID \a empire_id + int EmpirePlayerID(int empire_id) const;///< returns the player ID for the player playing the empire with ID \a empire_id - const std::map<int, PlayerInfo>& Players() const; ///< returns the map, indexed by player ID, of PlayerInfo structs containing info about players in the game + const std::map<int, PlayerInfo>&Players() const; ///< returns the map, indexed by player ID, of PlayerInfo structs containing info about players in the game + const std::map<int, Message::PlayerStatus>& + PlayerStatus() const; ///< returns the map, indexed by player ID, of the latest known PlayerStatus for each player in the game const Universe& GetUniverse() const; ///< returns client's local copy of Universe const GalaxySetupData& GetGalaxySetupData() const; ///< returns the settings used in creating the current Universe @@ -58,10 +60,13 @@ CombatOrderSet& CombatOrders(); ///< returns CombatOrder set for this client's player ClientNetworking& Networking(); ///< returns the networking object for this client's player std::map<int, PlayerInfo>& Players(); ///< returns the map, indexed by player ID, of PlayerInfo structs containing info about players in the game + std::map<int, Message::PlayerStatus>& + PlayerStatus(); ///< returns the map, indexed by player ID, of the latest known PlayerStatus for each player in the game void SetEmpireID(int id); ///< sets the empire ID of this client void SetCurrentTurn(int turn); ///< sets the current game turn void SetSinglePlayerGame(bool sp = true); ///< sets whether the current game is single player (sp = true) or multiplayer (sp = false) + void SetPlayerStatus(int player_id, Message::PlayerStatus status); /** returns a universe object ID which can be used for new objects created by the client. Can return INVALID_OBJECT_ID if an ID cannot be created. */ @@ -87,7 +92,9 @@ ClientNetworking m_networking; int m_empire_id; int m_current_turn; - std::map<int, PlayerInfo> m_player_info; ///< indexed by player id, contains info about all players in the game + std::map<int, PlayerInfo> m_player_info; ///< indexed by player id, contains info about all players in the game + std::map<int, Message::PlayerStatus> + m_player_status; ///< indexed by player id, the last known PlayerStatus for each player private: const ClientApp& operator=(const ClientApp&); // disabled Modified: trunk/FreeOrion/client/human/HumanClientFSM.cpp =================================================================== --- trunk/FreeOrion/client/human/HumanClientFSM.cpp 2014-02-14 05:19:34 UTC (rev 6896) +++ trunk/FreeOrion/client/human/HumanClientFSM.cpp 2014-02-14 07:03:36 UTC (rev 6897) @@ -367,6 +367,7 @@ Message::PlayerStatus status; ExtractMessageData(msg.m_message, about_player_id, status); + Client().SetPlayerStatus(about_player_id, status); Client().GetClientUI()->GetMessageWnd()->HandlePlayerStatusUpdate(status, about_player_id); Client().GetClientUI()->GetPlayerListWnd()->HandlePlayerStatusUpdate(status, about_player_id); // TODO: tell the map wnd or something else as well? @@ -522,6 +523,7 @@ bool single_player_game = false; int empire_id = ALL_EMPIRES; int current_turn = INVALID_GAME_TURN; + Client().PlayerStatus().clear(); ExtractMessageData(msg.m_message, single_player_game, empire_id, current_turn, Empires(), GetUniverse(), @@ -580,6 +582,7 @@ if (TRACE_EXECUTION) Logger().debugStream() << "(HumanClientFSM) PlayingGame.TurnUpdate"; int current_turn = INVALID_GAME_TURN; + Client().PlayerStatus().clear(); try { ExtractMessageData(msg.m_message, Client().EmpireID(), current_turn, |