Fix random player position in FTL
This commit is contained in:
parent
6f7c8c3dd8
commit
39f7e6441a
@ -491,20 +491,6 @@ void RaceManager::startNew(bool from_overworld)
|
|||||||
init_gp_rank ++;
|
init_gp_rank ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool random_pos_available = !NetworkConfig::get()->isNetworking() &&
|
|
||||||
(RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_NORMAL_RACE
|
|
||||||
|| RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL
|
|
||||||
|| RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER);
|
|
||||||
|
|
||||||
if (UserConfigParams::m_random_player_pos)
|
|
||||||
{
|
|
||||||
if (random_pos_available)
|
|
||||||
{
|
|
||||||
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
|
|
||||||
std::shuffle(m_kart_status.begin(), m_kart_status.end(), std::default_random_engine(seed));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_track_number = 0;
|
m_track_number = 0;
|
||||||
if (m_major_mode == MAJOR_MODE_GRAND_PRIX)
|
if (m_major_mode == MAJOR_MODE_GRAND_PRIX)
|
||||||
{
|
{
|
||||||
@ -565,15 +551,14 @@ void RaceManager::startNextRace()
|
|||||||
|
|
||||||
m_num_finished_karts = 0;
|
m_num_finished_karts = 0;
|
||||||
m_num_finished_players = 0;
|
m_num_finished_players = 0;
|
||||||
|
// In follow the leader mode do not change the first kart,
|
||||||
|
// since it's always the leader.
|
||||||
|
int offset = (m_minor_mode==MINOR_MODE_FOLLOW_LEADER) ? 1 : 0;
|
||||||
|
|
||||||
// if subsequent race, sort kart status structure
|
// if subsequent race, sort kart status structure
|
||||||
// ==============================================
|
// ==============================================
|
||||||
if (m_track_number > 0)
|
if (m_track_number > 0)
|
||||||
{
|
{
|
||||||
// In follow the leader mode do not change the first kart,
|
|
||||||
// since it's always the leader.
|
|
||||||
int offset = (m_minor_mode==MINOR_MODE_FOLLOW_LEADER) ? 1 : 0;
|
|
||||||
|
|
||||||
// Keep players at the end if needed
|
// Keep players at the end if needed
|
||||||
int player_last_offset = 0;
|
int player_last_offset = 0;
|
||||||
if (UserConfigParams::m_gp_player_last)
|
if (UserConfigParams::m_gp_player_last)
|
||||||
@ -594,6 +579,23 @@ void RaceManager::startNextRace()
|
|||||||
m_kart_status.end() - player_last_offset);
|
m_kart_status.end() - player_last_offset);
|
||||||
}
|
}
|
||||||
} // not first race
|
} // not first race
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const bool random_pos_available = !NetworkConfig::get()->isNetworking() &&
|
||||||
|
(RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_NORMAL_RACE
|
||||||
|
|| RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_TIME_TRIAL
|
||||||
|
|| RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER);
|
||||||
|
|
||||||
|
if (UserConfigParams::m_random_player_pos)
|
||||||
|
{
|
||||||
|
if (random_pos_available)
|
||||||
|
{
|
||||||
|
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
|
||||||
|
std::shuffle(m_kart_status.begin() + offset, m_kart_status.end(),
|
||||||
|
std::default_random_engine(seed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set boosted AI status for AI karts
|
// set boosted AI status for AI karts
|
||||||
int boosted_ai_count = std::min<int>((int)m_ai_kart_list.size(),
|
int boosted_ai_count = std::min<int>((int)m_ai_kart_list.size(),
|
||||||
|
Loading…
Reference in New Issue
Block a user