some buxfixes + implementation of the max player count

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@14127 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hilnius 2013-09-21 20:56:39 +00:00
parent 241a7f63e1
commit a637ce6e36
7 changed files with 16 additions and 34 deletions

View File

@ -1422,6 +1422,9 @@ int main(int argc, char *argv[] )
// load the network manager // load the network manager
// If the server has been created (--server option), this will do nothing (just a warning): // If the server has been created (--server option), this will do nothing (just a warning):
NetworkManager::getInstance<ClientNetworkManager>(); NetworkManager::getInstance<ClientNetworkManager>();
if (NetworkManager::getInstance()->isServer())
ServerNetworkManager::getInstance()->setMaxPlayers(
UserConfigParams::m_server_max_players);
NetworkManager::getInstance()->run(); NetworkManager::getInstance()->run();
if (NetworkManager::getInstance()->isServer()) if (NetworkManager::getInstance()->isServer())
{ {

View File

@ -320,11 +320,11 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
{ {
if (data[0] != 1 || data[2] != 4) if (data[0] != 1 || data[2] != 4)
Log::error("ClientLobbyRoomProtocol", "Bad format in players list."); Log::error("ClientLobbyRoomProtocol", "Bad format in players list.");
uint8_t race_id = data[1]; uint8_t race_id = data[1];
uint32_t global_id = data.gui32(3); uint32_t global_id = data.gui32(3);
Online::Profile* new_user = new Online::Profile(global_id, ""); Online::Profile* new_user = new Online::Profile(global_id, "");
NetworkPlayerProfile* profile2 = new NetworkPlayerProfile(); NetworkPlayerProfile* profile2 = new NetworkPlayerProfile();
profile2->race_id = race_id; profile2->race_id = race_id;
profile2->user_profile = new_user; profile2->user_profile = new_user;

View File

@ -334,7 +334,8 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
uint32_t player_id = 0; uint32_t player_id = 0;
player_id = data.getUInt32(1); player_id = data.getUInt32(1);
// can we add the player ? // can we add the player ?
if (m_setup->getPlayerCount() < 16) // accept player if (m_setup->getPlayerCount() <
ServerNetworkManager::getInstance()->getMaxPlayers()) //accept
{ {
// add the player to the game setup // add the player to the game setup
m_next_id = m_setup->getPlayerCount(); m_next_id = m_setup->getPlayerCount();

View File

@ -44,19 +44,6 @@ void TrackVote::voteLaps(int laps)
track_info.laps = laps; track_info.laps = laps;
has_voted_laps = true; has_voted_laps = true;
} }
//-----------------------------------------------------------------------------
int GPRaceInfo::getMajorMode()
{
return RaceManager::MAJOR_MODE_GRAND_PRIX;
}
//-----------------------------------------------------------------------------
int SingleRaceInfo::getMajorMode()
{
return RaceManager::MAJOR_MODE_SINGLE;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -147,23 +134,9 @@ void RaceConfig::computeNextTrack()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
const TrackInfo* RaceConfig::getNextTrack() const const TrackInfo* RaceConfig::getNextTrackInfo() const
{ {
return m_track.track; return &m_track;
}
//-----------------------------------------------------------------------------
bool RaceConfig::getReverse() const
{
return m_track.track;
}
//-----------------------------------------------------------------------------
bool RaceConfig::getLapCount() const
{
return m_track.track;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -41,7 +41,7 @@ class RaceConfig
void computeNextTrack(); void computeNextTrack();
const TrackInfo* getNextTrack() const; const TrackInfo* getNextTrackInfo() const;
bool getReverse() const; bool getReverse() const;
bool getLapCount() const; bool getLapCount() const;

View File

@ -36,6 +36,9 @@ class ServerNetworkManager : public NetworkManager
virtual void run(); virtual void run();
void setMaxPlayers(uint8_t count) { m_max_players = count; }
uint8_t getMaxPlayers() {return m_max_players;}
void kickAllPlayers(); void kickAllPlayers();
virtual void sendPacket(const NetworkString& data, bool reliable = true); virtual void sendPacket(const NetworkString& data, bool reliable = true);
@ -47,6 +50,7 @@ class ServerNetworkManager : public NetworkManager
virtual ~ServerNetworkManager(); virtual ~ServerNetworkManager();
pthread_t* m_thread_keyboard; pthread_t* m_thread_keyboard;
uint8_t m_max_players;
}; };

View File

@ -170,7 +170,8 @@ void STKHost::stopListening()
if(m_listening_thread) if(m_listening_thread)
{ {
pthread_mutex_unlock(&m_exit_mutex); // will stop the update function on its next update pthread_mutex_unlock(&m_exit_mutex); // will stop the update function on its next update
pthread_join(*m_listening_thread, NULL); // wait the thread to end } pthread_join(*m_listening_thread, NULL); // wait the thread to end
}
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------