Automatically trigger computing the track data (based on votes)

once the game starts.
This commit is contained in:
hiker
2015-12-03 17:56:16 +11:00
parent 26155933f0
commit af3f72ae84
4 changed files with 18 additions and 14 deletions

View File

@@ -88,16 +88,6 @@ void* NetworkConsole::mainLoop(void* data)
assert(protocol);
protocol->startSelection();
}
else if (str == "compute_race"&& NetworkConfig::get()->isServer())
{
GameSetup* setup = STKHost::get()->getGameSetup();
setup->getRaceConfig()->computeRaceMode();
}
else if (str == "compute_track" && NetworkConfig::get()->isServer())
{
GameSetup* setup = STKHost::get()->getGameSetup();
setup->getRaceConfig()->computeNextTrack();
}
else if (str == "select" && NetworkConfig::get()->isclient())
{
std::string str2;

View File

@@ -208,7 +208,7 @@ void StartGameProtocol::update()
{
// now the synchronization protocol exists.
Log::info("StartGameProtocol", "Starting the race loading.");
race_manager->startSingleRace("jungle", 1, false);
m_game_setup->getRaceConfig()->setRaceData();
World::getWorld()->setNetworkWorld(true);
m_state = LOADING;
}

View File

@@ -428,6 +428,18 @@ void RaceConfig::computeNextTrack()
}
} // computeNextTrack
//-----------------------------------------------------------------------------
/** Computes the selected setting (based on the users' vote) and sets them
* in the race manager.
*/
void RaceConfig::setRaceData()
{
computeRaceMode();
computeNextTrack();
race_manager->startSingleRace(m_tracks[0].track, m_tracks[0].laps,
m_tracks[0].reversed);
} // setRaceData
//-----------------------------------------------------------------------------
const TrackInfo* RaceConfig::getNextTrackInfo() const
{

View File

@@ -93,7 +93,10 @@ class RaceVote
// ============================================================================
class RaceConfig
{
public:
private:
void computeRaceMode();
void computeNextTrack();
public:
RaceConfig();
void setMaxPlayerCount(uint8_t count);
@@ -107,8 +110,7 @@ class RaceConfig
void setPlayerLapsVote(uint8_t player_id, uint8_t lap_count,
uint8_t track_nb = 0);
void computeRaceMode();
void computeNextTrack();
void setRaceData();
const TrackInfo* getNextTrackInfo() const;
bool getReverse() const;