Definitions for GP points is now independent of the maximum number of karts.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6021 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e778c2547f
commit
92d18a7a25
@ -16,8 +16,15 @@
|
||||
|
||||
<!-- Scores are the number of points given when the race ends,
|
||||
order is most-points-first or most-points-last. -->
|
||||
<grand-prix scores="10 8 6 5 4 3 2 1"
|
||||
order = "most-points-first"/>
|
||||
<grand-prix order = "most-points-first">
|
||||
<!-- 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. -->
|
||||
<points from="1" to="2" points="3"/>
|
||||
<points from="3" to="4" points="2"/>
|
||||
<points from="5" points="1"/>
|
||||
</grand-prix>
|
||||
|
||||
<!-- Time in follow-the-leader after which karts are removed.
|
||||
The last values applies for all remaining karts. -->
|
||||
<follow-the-leader intervals="30 20 10"/>
|
||||
|
@ -72,7 +72,7 @@ void STKConfig::load(const std::string &filename)
|
||||
strA,filename.c_str());exit(-1); \
|
||||
}
|
||||
|
||||
if(m_scores.size()==0 || (int)m_scores.size()!=m_max_karts)
|
||||
if(m_score_increase.size()==0 || (int)m_score_increase.size()!=m_max_karts)
|
||||
{
|
||||
fprintf(stderr,"Not or not enough scores defined in stk_config");
|
||||
exit(-1);
|
||||
@ -152,7 +152,7 @@ void STKConfig::init_defaults()
|
||||
m_max_track_version = -100;
|
||||
m_title_music = NULL;
|
||||
m_enable_networking = true;
|
||||
m_scores.clear();
|
||||
m_score_increase.clear();
|
||||
m_leader_intervals.clear();
|
||||
m_switch_items.clear();
|
||||
} // init_defaults
|
||||
@ -182,10 +182,30 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
|
||||
if(const XMLNode *gp_node = root->getNode("grand-prix"))
|
||||
{
|
||||
gp_node->get("scores", &m_scores);
|
||||
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);
|
||||
int from=-1;
|
||||
pn->get("from", &from);
|
||||
int to=-1;
|
||||
pn->get("to", &to);
|
||||
if(to<0) to=m_max_karts;
|
||||
int points=-1;
|
||||
pn->get("points", &points);
|
||||
if(points<0 || from<0 || from>to||m_score_increase.size()!=from-1)
|
||||
{
|
||||
fprintf(stderr, "Incorrect GP point specification:\n");
|
||||
fprintf(stderr, "from: %d to: %d points: %d\n",
|
||||
from, to, points);
|
||||
exit(-1);
|
||||
}
|
||||
for(int j=from; j<=to; j++)
|
||||
m_score_increase.push_back(points);
|
||||
}
|
||||
}
|
||||
|
||||
if(const XMLNode *leader_node= root->getNode("follow-the-leader"))
|
||||
@ -285,3 +305,23 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
|
||||
} // getAllData
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Defines the points for each position for a race with a given number
|
||||
* of karts.
|
||||
* \param all_scores A vector which will be resized to take num_karts
|
||||
* elements and which on return contains the number of points
|
||||
* for each position.
|
||||
* \param num_karts Number of karts.
|
||||
*/
|
||||
void STKConfig::getAllScores(std::vector<int> *all_scores, int num_karts)
|
||||
{
|
||||
assert(num_karts <= m_max_karts);
|
||||
all_scores->resize(num_karts);
|
||||
(*all_scores)[num_karts-1] = 1; // last position gets one point
|
||||
|
||||
// Must be signed, in case that num_karts==1
|
||||
for(int i=num_karts-2; i>=0; i--)
|
||||
{
|
||||
(*all_scores)[i] = (*all_scores)[i+1] + m_score_increase[i];
|
||||
}
|
||||
} // getAllScores
|
||||
|
@ -95,8 +95,10 @@ public:
|
||||
m_leader_intervals; /**<Interval in follow the leader till
|
||||
last kart is reomved. */
|
||||
std::vector<int> m_switch_items; /**< How to switch items. */
|
||||
std::vector<int>
|
||||
m_scores; /**<Scores depending on position. */
|
||||
/** The number of points a kart on position X has more than the
|
||||
* next kart. From this the actual number of points for each
|
||||
* position is computed. */
|
||||
std::vector<int> m_score_increase;
|
||||
|
||||
MusicInformation
|
||||
*m_title_music; /**<Filename of the title music to play.*/
|
||||
@ -111,6 +113,7 @@ public:
|
||||
getDefaultKartProperties() const {return m_kart_properties; }
|
||||
const std::string &getMainMenuPicture(int n);
|
||||
const std::string &getBackgroundPicture(int n);
|
||||
void getAllScores(std::vector<int> *all_scores, int num_karts);
|
||||
}
|
||||
; // STKConfig
|
||||
|
||||
|
@ -52,7 +52,6 @@ RaceManager::RaceManager()
|
||||
m_major_mode = MAJOR_MODE_SINGLE;
|
||||
m_minor_mode = MINOR_MODE_NORMAL_RACE;
|
||||
m_track_number = 0;
|
||||
m_score_for_position = stk_config->m_scores;
|
||||
m_coin_target = 0;
|
||||
setTrack("jungle");
|
||||
setNumLocalPlayers(0);
|
||||
@ -245,6 +244,7 @@ void RaceManager::startNew()
|
||||
*/
|
||||
void RaceManager::startNextRace()
|
||||
{
|
||||
stk_config->getAllScores(&m_score_for_position, m_num_karts);
|
||||
IrrlichtDevice* device = irr_driver->getDevice();
|
||||
GUIEngine::renderLoading();
|
||||
device->getVideoDriver()->endScene();
|
||||
|
@ -506,10 +506,10 @@ void RaceResultGUI::renderGlobal(float dt)
|
||||
break;
|
||||
case RR_INCREASE_POINTS:
|
||||
ri->m_current_displayed_points +=
|
||||
dt*stk_config->m_scores[0]/m_time_for_points;
|
||||
dt*race_manager->getPositionScore(1)/m_time_for_points;
|
||||
if(ri->m_current_displayed_points>ri->m_new_overall_points)
|
||||
ri->m_current_displayed_points = (float)ri->m_new_overall_points;
|
||||
ri->m_new_points -= dt*stk_config->m_scores[0]/m_time_for_points;
|
||||
ri->m_new_points -= dt*race_manager->getPositionScore(1)/m_time_for_points;
|
||||
if(ri->m_new_points<0)
|
||||
ri->m_new_points = 0;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user