Add AI number detection in server screen
This commit is contained in:
parent
cfd7fa662b
commit
e4515e7454
@ -61,6 +61,7 @@ Server::Server(const XMLNode& server_info) : m_supports_encrytion(true)
|
||||
xml.get("host_id", &m_server_owner);
|
||||
xml.get("max_players", &m_max_players);
|
||||
xml.get("current_players", &m_current_players);
|
||||
xml.get("current_ai", &m_current_ai);
|
||||
xml.get("current_track", &m_current_track);
|
||||
uint32_t ip;
|
||||
xml.get("ip", &ip);
|
||||
@ -198,6 +199,7 @@ Server::Server(unsigned server_id, const core::stringw &name, int max_players,
|
||||
m_official = false;
|
||||
m_game_started = game_started;
|
||||
m_current_track = current_track;
|
||||
m_current_ai = 0;
|
||||
} // server(server_id, ...)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -70,6 +70,8 @@ protected:
|
||||
/** The number of players currently on the server */
|
||||
int m_current_players;
|
||||
|
||||
int m_current_ai;
|
||||
|
||||
/** The public ip address and port of this server. */
|
||||
std::unique_ptr<SocketAddress> m_address;
|
||||
|
||||
@ -210,6 +212,8 @@ public:
|
||||
{ m_reconnect_when_quit_lobby = val; }
|
||||
// ------------------------------------------------------------------------
|
||||
std::string getBookmarkKey() const;
|
||||
// ------------------------------------------------------------------------
|
||||
const int getCurrentAI() const { return m_current_ai; }
|
||||
}; // Server
|
||||
|
||||
class UserDefinedServer : public Server
|
||||
|
@ -230,24 +230,42 @@ void ServerSelection::loadList()
|
||||
switch (m_current_column)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
return c->getLowerCaseName() > d->getLowerCaseName();
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
return c->getServerMode() > d->getServerMode();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
return c->getCurrentPlayers() > d->getCurrentPlayers();
|
||||
{
|
||||
int c_players = c->getCurrentPlayers() - c->getCurrentAI();
|
||||
if (c_players < 0)
|
||||
c_players = 0;
|
||||
int d_players = d->getCurrentPlayers() - d->getCurrentAI();
|
||||
if (d_players < 0)
|
||||
d_players = 0;
|
||||
return c_players > d_players;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
return c->getDifficulty() > d->getDifficulty();
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
return c->getServerOwnerLowerCaseName() >
|
||||
d->getServerOwnerLowerCaseName();
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
return c->getDistance() > d->getDistance();
|
||||
break;
|
||||
}
|
||||
} // switch
|
||||
assert(false);
|
||||
return false;
|
||||
@ -259,7 +277,18 @@ void ServerSelection::loadList()
|
||||
if (t)
|
||||
icon = track_manager->getTrackIndexByIdent(t->getIdent()) + 2;
|
||||
core::stringw num_players;
|
||||
num_players.append(StringUtils::toWString(server->getCurrentPlayers()));
|
||||
int current_players = server->getCurrentPlayers();
|
||||
int current_ai = server->getCurrentAI();
|
||||
current_players -= current_ai;
|
||||
if (current_players < 0)
|
||||
current_players = 0;
|
||||
num_players.append(StringUtils::toWString(current_players));
|
||||
if (current_ai > 0)
|
||||
{
|
||||
num_players.append("(");
|
||||
num_players.append(StringUtils::toWString(current_ai));
|
||||
num_players.append(")");
|
||||
}
|
||||
num_players.append("/");
|
||||
num_players.append(StringUtils::toWString(server->getMaxPlayers()));
|
||||
std::vector<GUIEngine::ListWidget::ListCell> row;
|
||||
|
Loading…
Reference in New Issue
Block a user