GP start order option to user's config + add option to have players always last

In light of #28, the GP start order option is probably more at home in a user's
configuration. While at it, also add an option to keep the player always last.
This is more of a challenge for the player than just reverse mode since your
direct opponents _will_ be at the forefront while you have to play catch up.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11017 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
wardje 2012-03-25 16:39:32 +00:00
parent 36cd82b0eb
commit a40462594c
5 changed files with 33 additions and 15 deletions

View File

@ -14,9 +14,8 @@
positions for those additional karts. -->
<karts max-number="20"/>
<!-- Scores are the number of points given when the race ends,
order is most-points-first or most-points-last. -->
<grand-prix order = "most-points-first">
<!-- Scores are the number of points given when the race ends. -->
<grand-prix>
<!-- Karts on position 1 and 2 will have 3 more points than the next kart;
a kart on position 3 and 4 will have two more points than the next;
and all remaining karts will have one more point than the next. -->

View File

@ -113,7 +113,6 @@ void STKConfig::load(const std::string &filename)
}
CHECK_NEG(m_max_karts, "<karts max=..." );
CHECK_NEG(m_gp_order, "grand-prix order=..." );
CHECK_NEG(m_parachute_friction, "parachute-friction" );
CHECK_NEG(m_parachute_done_fraction, "parachute-done-fraction" );
CHECK_NEG(m_parachute_time, "parachute-time" );
@ -164,7 +163,6 @@ void STKConfig::init_defaults()
m_penalty_time = m_explosion_impulse_objects = UNDEFINED;
m_bubble_gum_counter = -100;
m_max_karts = -100;
m_gp_order = -100;
m_max_history = -100;
m_max_skidmarks = -100;
m_min_kart_version = -100;
@ -211,10 +209,6 @@ void STKConfig::getAllData(const XMLNode * root)
if(const XMLNode *gp_node = root->getNode("grand-prix"))
{
std::string order;
gp_node->get("order", &order);
m_gp_order = (order=="most-points-first");
for(unsigned int i=0; i<gp_node->getNumNodes(); i++)
{
const XMLNode *pn=gp_node->getNode(i);

View File

@ -85,8 +85,6 @@ public:
float m_music_credit_time; /**<Time the music credits are
displayed. */
int m_max_karts; /**<Maximum number of karts. */
int m_gp_order; /**<Whether grand prix grid is in point
or reverse point order. */
int m_max_history; /**<Maximum number of frames to save in
a history files. */
bool m_smooth_normals; /**< If normals for raycasts for wheels

View File

@ -332,6 +332,20 @@ namespace UserConfigParams
PARAM_PREFIX StringUserConfigParam m_last_used_kart_group
PARAM_DEFAULT( StringUserConfigParam("all", "last_kart_group",
"Last selected kart group") );
// ---- GP start order
PARAM_PREFIX GroupUserConfigParam m_gp_start_order
PARAM_DEFAULT( GroupUserConfigParam("GpStartOrder",
"Order karts start in GP") );
PARAM_PREFIX BoolUserConfigParam m_gp_most_points_first
PARAM_DEFAULT( BoolUserConfigParam(true, "most_points_first",
&m_gp_start_order,
"Starting order from most to least points (true) or other "
"way around (false)") );
PARAM_PREFIX BoolUserConfigParam m_gp_player_last
PARAM_DEFAULT( BoolUserConfigParam(false, "player_last",
&m_gp_start_order,
"Always put the player at the back or not (Bully mode).") );
// ---- Video
PARAM_PREFIX GroupUserConfigParam m_video_group

View File

@ -336,11 +336,24 @@ void RaceManager::startNextRace()
// since it's always the leader.
int offset = (m_minor_mode==MINOR_MODE_FOLLOW_LEADER) ? 1 : 0;
std::sort(m_kart_status.begin()+offset, m_kart_status.end());
//reverse kart order if flagged in stk_config
if (stk_config->m_gp_order)
// Keep players at the end if needed
int player_last_offset = 0;
if (UserConfigParams::m_gp_player_last)
{
std::reverse(m_kart_status.begin()+offset, m_kart_status.end());
// Doing this is enough to keep player karts at
// the end because of the simple reason that they
// are at the end when getting added. Keep them out
// of the later sorting and they will stay there.
player_last_offset = m_player_karts.size();
}
std::sort(m_kart_status.begin()+offset,
m_kart_status.end() - player_last_offset);
// reverse kart order if flagged in user's config
if (UserConfigParams::m_gp_most_points_first)
{
std::reverse(m_kart_status.begin()+offset,
m_kart_status.end() - player_last_offset);
}
} // not first race