Show android robot icon for bots in lobby

This commit is contained in:
Benau 2019-10-09 15:28:09 +08:00
parent 2a40606be7
commit 396e55a39d
7 changed files with 17 additions and 4 deletions

View File

@ -47,6 +47,8 @@ blue_flag.png, heart.png and red_flag.png by Benau, released under CC-BY-SA 4
lap_flag.png, modified by Alayan, original by Alina Oleynik from The Noun Project, under CC-BY 3.0
Android robot.png is licensed under the terms of the Creative Commons Attribution license
====
Glass Skin by Auria, under CC-BY-SA 3+

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -185,7 +185,7 @@ void LinearWorld::update(int ticks)
if (npp)
{
auto peer = npp->getPeer();
if (peer && peer->getUserVersion() == "AI")
if (peer && peer->isAIPeer())
has_ai = true;
else if (!getKart(i)->hasFinishedRace())
all_players_finished = false;

View File

@ -421,7 +421,7 @@ void ClientLobby::update(int ticks)
auto& p = NetworkConfig::get()->getNetworkPlayers()[i];
PlayerProfile* player = std::get<1>(p);
core::stringw name = player->getName();
if (lan_ai)
if (NetworkConfig::get()->isNetworkAITester())
{
// I18N: Shown in lobby to indicate it's a bot in LAN game
name = _("Bot");
@ -787,9 +787,12 @@ void ClientLobby::updatePlayerList(Event* event)
bool is_spectator = ((boolean_combine >> 1) & 1) == 1;
bool is_peer_server_owner = ((boolean_combine >> 2) & 1) == 1;
bool ready = ((boolean_combine >> 3) & 1) == 1;
bool ai = ((boolean_combine >> 4) & 1) == 1;
// icon to be used, see NetworkingLobby::loadedFromFile
lp.m_icon_id = is_peer_server_owner ? 0 :
lp.m_online_id != 0 /*if online account*/ ? 1 : 2;
if (ai)
lp.m_icon_id = 6;
if (waiting && !is_peer_waiting_for_game)
lp.m_icon_id = 3;
if (is_spectator)

View File

@ -2961,7 +2961,8 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
PerPlayerDifficulty per_player_difficulty =
(PerPlayerDifficulty)data.getUInt8();
auto player = std::make_shared<NetworkPlayerProfile>
(peer, i == 0 && !online_name.empty() ? online_name : name,
(peer, i == 0 && !online_name.empty() && !peer->isAIPeer() ?
online_name : name,
peer->getHostId(), default_kart_color, i == 0 ? online_id : 0,
per_player_difficulty, (uint8_t)i, KART_TEAM_NONE,
country_code);
@ -3156,6 +3157,8 @@ void ServerLobby::updatePlayerList(bool update_when_reset_server)
m_peers_ready.find(p) != m_peers_ready.end() &&
m_peers_ready.at(p))
boolean_combine |= (1 << 3);
if (p && p->isAIPeer())
boolean_combine |= (1 << 4);
pl->addUInt8(boolean_combine);
pl->addUInt8(profile->getPerPlayerDifficulty());
if (ServerConfig::m_team_choosing &&
@ -3201,7 +3204,7 @@ void ServerLobby::updateServerOwner()
for (auto peer: peers)
{
// Only 127.0.0.1 can be server owner in case of graphics-client-server
if (peer->isValidated() && peer->getUserVersion() != "AI" &&
if (peer->isValidated() && !peer->isAIPeer() &&
(NetworkConfig::get()->getServerIdFile().empty() ||
peer->getAddress().getIP() == 0x7f000001))
{

View File

@ -248,6 +248,8 @@ public:
// ------------------------------------------------------------------------
const std::set<std::string>& getClientCapabilities() const
{ return m_client_capabilities; }
// ------------------------------------------------------------------------
bool isAIPeer() const { return m_user_version == "AI"; }
}; // STKPeer
#endif // STK_PEER_HPP

View File

@ -133,12 +133,15 @@ void NetworkingLobby::loadedFromFile()
(file_manager->getAsset(FileManager::GUI_ICON, "main_options.png"));
m_spectate_texture = irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON, "screen_other.png"));
video::ITexture* icon_6 = irr_driver->getTexture
(file_manager->getAsset(FileManager::GUI_ICON, "android/robot.png"));
m_icon_bank->addTextureAsSprite(icon_1);
m_icon_bank->addTextureAsSprite(icon_2);
m_icon_bank->addTextureAsSprite(icon_3);
m_icon_bank->addTextureAsSprite(icon_4);
m_icon_bank->addTextureAsSprite(icon_5);
m_icon_bank->addTextureAsSprite(m_spectate_texture);
m_icon_bank->addTextureAsSprite(icon_6);
m_icon_bank->setScale((float)GUIEngine::getFontHeight() / 96.0f);
} // loadedFromFile