Add a user config option to randomize the player position at the start (#4627)
This commit is contained in:
parent
d0f4c8ffee
commit
95de01a8fb
@ -486,6 +486,9 @@ namespace UserConfigParams
|
||||
PARAM_PREFIX BoolUserConfigParam m_addon_tux_online
|
||||
PARAM_DEFAULT( BoolUserConfigParam(false, "addon-tux-online",
|
||||
&m_race_setup_group, "Always show online addon karts as tux when live join is on.") );
|
||||
PARAM_PREFIX BoolUserConfigParam m_random_player_pos
|
||||
PARAM_DEFAULT( BoolUserConfigParam(false, "random-player-pos",
|
||||
&m_race_setup_group, "Randomize the position of the players at the start of a race. Doesn't apply to story mode.") );
|
||||
|
||||
// ---- Wiimote data
|
||||
PARAM_PREFIX GroupUserConfigParam m_wiimote_group
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
@ -490,6 +491,20 @@ void RaceManager::startNew(bool from_overworld)
|
||||
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;
|
||||
if (m_major_mode == MAJOR_MODE_GRAND_PRIX)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user