Cosmetic changes only.

This commit is contained in:
hiker 2015-11-10 08:08:41 +11:00
parent 36ebe29649
commit 0a23198be1
2 changed files with 138 additions and 129 deletions

View File

@ -28,6 +28,11 @@ namespace Online
{
Server::SortOrder Server::m_sort_order = Server::SO_NAME;
/** Constructor based on XML data received from the stk server.
* \param xml The data for one server as received as part of the
* get-all stk-server request.
* \param is_lan If this is a lan only server.
*/
Server::Server(const XMLNode & xml, bool is_lan)
{
assert(xml.getName() == "server");
@ -51,6 +56,13 @@ namespace Online
} // Server(const XML&)
// ----------------------------------------------------------------------------
/** Manual server creation, based on data received from a LAN server discovery
* (see ServersManager::getLANRefresh).
* \param name Name of the server.
* \param is_lan If this is a lan-only server.
* \param max_players Maximum number of players allowed on this server.
* \param current_players The currently connected number of players.
*/
Server::Server(const core::stringw &name, bool is_lan, int max_players,
int current_players)
{
@ -63,8 +75,7 @@ namespace Online
} // server(name, ...)
// ----------------------------------------------------------------------------
/**
* \brief Filter the add-on with a list of words.
/** \brief Filter the add-on with a list of words.
* \param words A list of words separated by ' '.
* \return true if the add-on contains one of the words, otherwise false.
*/

View File

@ -51,7 +51,9 @@ namespace Online
protected:
/** The server name to be displayed. */
irr::core::stringw m_name;
std::string m_lower_case_name; // Used for comparison
/** Name in lower case for comparisons. */
std::string m_lower_case_name;
uint32_t m_server_id;
uint32_t m_host_id;
@ -71,14 +73,13 @@ namespace Online
/** The sort order to be used in the comparison. */
static SortOrder m_sort_order;
Server() {}
public:
/** Initialises the object from an XML node. */
Server(const XMLNode &xml, bool is_lan);
Server(const core::stringw &name, bool is_lan, int max_players,
int current_players);
bool filterByWords(const irr::core::stringw words) const;
// ------------------------------------------------------------------------
/** Sets the sort order used in the comparison function. It is static, so
* that each instance can access the sort order. */
@ -87,21 +88,18 @@ namespace Online
// ------------------------------------------------------------------------
/** Returns the name of the server. */
const irr::core::stringw& getName() const { return m_name; }
const std::string & getLowerCaseName() const { return m_lower_case_name; }
// ------------------------------------------------------------------------
const float getScore() const { return m_satisfaction_score; }
// ------------------------------------------------------------------------
/** Returns the ID of this server. */
const uint32_t getServerId() const { return m_server_id; }
const uint32_t getHostId() const { return m_host_id; }
const int getMaxPlayers() const { return m_max_players; }
const int getCurrentPlayers() const { return m_current_players; }
// ------------------------------------------------------------------------
bool filterByWords(const irr::core::stringw words) const;
/** Returns the unique host id of this server. */
const uint32_t getHostId() const { return m_host_id; }
// ------------------------------------------------------------------------
/** Returns the maximum number of players allowed on this server. */
const int getMaxPlayers() const { return m_max_players; }
// ------------------------------------------------------------------------
/** Returns the number of currently connected players. */
const int getCurrentPlayers() const { return m_current_players; }
// ------------------------------------------------------------------------
/** Compares two servers according to the sort order currently defined.
* \param a The addon to compare this addon to.
@ -111,14 +109,14 @@ namespace Online
switch (m_sort_order)
{
case SO_SCORE:
return m_satisfaction_score < server.getScore();
return m_satisfaction_score < server.m_satisfaction_score;
break;
case SO_NAME:
// m_id is the lower case name
return m_lower_case_name < server.m_lower_case_name;
break;
case SO_PLAYERS:
return m_current_players < server.getCurrentPlayers();
return m_current_players < server.m_current_players;
break;
} // switch