Handle first-team assignment better when joining in the middle of game
This commit is contained in:
parent
1f1734e5a7
commit
4c534dc28c
@ -1618,7 +1618,7 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned player_count = data.getUInt8();
|
unsigned player_count = data.getUInt8();
|
||||||
auto red_blue = m_game_setup->getPlayerTeamInfo();
|
auto red_blue = STKHost::get()->getAllPlayersTeamInfo();
|
||||||
for (unsigned i = 0; i < player_count; i++)
|
for (unsigned i = 0; i < player_count; i++)
|
||||||
{
|
{
|
||||||
core::stringw name;
|
core::stringw name;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "network/game_setup.hpp"
|
#include "network/game_setup.hpp"
|
||||||
#include "network/network_config.hpp"
|
#include "network/network_config.hpp"
|
||||||
#include "network/network_console.hpp"
|
#include "network/network_console.hpp"
|
||||||
|
#include "network/network_player_profile.hpp"
|
||||||
#include "network/network_string.hpp"
|
#include "network/network_string.hpp"
|
||||||
#include "network/network_timer_synchronizer.hpp"
|
#include "network/network_timer_synchronizer.hpp"
|
||||||
#include "network/protocols/connect_to_peer.hpp"
|
#include "network/protocols/connect_to_peer.hpp"
|
||||||
@ -1248,3 +1249,20 @@ void STKHost::initClientNetwork(ENetEvent& event, Network* new_network)
|
|||||||
if (pm && !pm->isExiting())
|
if (pm && !pm->isExiting())
|
||||||
pm->propagateEvent(new Event(&event, stk_peer));
|
pm->propagateEvent(new Event(&event, stk_peer));
|
||||||
} // replaceNetwork
|
} // replaceNetwork
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
std::pair<int, int> STKHost::getAllPlayersTeamInfo() const
|
||||||
|
{
|
||||||
|
int red_count = 0;
|
||||||
|
int blue_count = 0;
|
||||||
|
auto pp = getAllPlayerProfiles();
|
||||||
|
for (auto& player : pp)
|
||||||
|
{
|
||||||
|
if (player->getTeam() == KART_TEAM_RED)
|
||||||
|
red_count++;
|
||||||
|
else if (player->getTeam() == KART_TEAM_BLUE)
|
||||||
|
blue_count++;
|
||||||
|
}
|
||||||
|
return std::make_pair(red_count, blue_count);
|
||||||
|
|
||||||
|
} // getAllPlayersTeamInfo
|
||||||
|
@ -337,6 +337,9 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setNetworkTimer(uint64_t ticks)
|
void setNetworkTimer(uint64_t ticks)
|
||||||
{ m_network_timer.store(StkTime::getRealTimeMs() - ticks); }
|
{ m_network_timer.store(StkTime::getRealTimeMs() - ticks); }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
std::pair<int, int> getAllPlayersTeamInfo() const;
|
||||||
|
|
||||||
}; // class STKHost
|
}; // class STKHost
|
||||||
|
|
||||||
#endif // STK_HOST_HPP
|
#endif // STK_HOST_HPP
|
||||||
|
Loading…
Reference in New Issue
Block a user