Properly removed 'too-far-away-from-track' - shortcut detection.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1563 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
7501c01cf3
commit
c34f0aa55a
@ -22,10 +22,6 @@
|
||||
(anvil-time 2.0 ) ;; time an anvil is active
|
||||
(zipper-time 5.0 ) ;; time a zipper is active
|
||||
(zipper-force 800.0 ) ;; additional zipper force
|
||||
(shortcut-road-distance 9999.0 ) ;; max. distance from side of road to be still
|
||||
;; considered on the road (otherwise shortcut)
|
||||
;; usually 5 is a good value, but for the math class
|
||||
;; we have to use at least 21(!!)
|
||||
(shortcut-skipped-segments 5 ) ;; skipping more than this number of segments
|
||||
;; is considered to be a shortcut
|
||||
(explosion-impulse 10000.0 ) ;; explosion impulse on not directly hit karts
|
||||
|
61
src/kart.cpp
61
src/kart.cpp
@ -357,9 +357,7 @@ void Kart::reset()
|
||||
m_race_lap = -1;
|
||||
m_lap_start_time = -1.0f;
|
||||
m_time_at_last_lap = 99999.9f;
|
||||
m_shortcut_count = 0;
|
||||
m_shortcut_sector = Track::UNKNOWN_SECTOR;
|
||||
m_shortcut_type = SC_NONE;
|
||||
m_race_position = 9;
|
||||
m_finished_race = false;
|
||||
m_finish_time = 0.0f;
|
||||
@ -430,10 +428,7 @@ void Kart::reset()
|
||||
void Kart::doLapCounting ()
|
||||
{
|
||||
bool newLap = m_last_track_coords[1] > 300.0f && m_curr_track_coords[1] < 20.0f;
|
||||
if ( newLap &&
|
||||
(world->m_race_setup.m_difficulty==RD_EASY ||
|
||||
world->m_race_setup.m_difficulty==RD_MEDIUM && m_shortcut_count<2 ||
|
||||
world->m_race_setup.m_difficulty==RD_HARD && m_shortcut_count<1 ) )
|
||||
if ( newLap )
|
||||
{
|
||||
// Only increase the lap counter and set the new time if the
|
||||
// kart hasn't already finished the race (otherwise the race_gui
|
||||
@ -444,7 +439,7 @@ void Kart::doLapCounting ()
|
||||
m_race_lap++ ;
|
||||
}
|
||||
|
||||
m_shortcut_count = 0;
|
||||
m_is_shortcut = false;
|
||||
// Only do timings if original time was set properly. Driving backwards
|
||||
// over the start line will cause the lap start time to be set to -1.
|
||||
if(m_lap_start_time>=0.0)
|
||||
@ -483,17 +478,6 @@ void Kart::doLapCounting ()
|
||||
}
|
||||
m_lap_start_time = world->getTime();
|
||||
}
|
||||
else if ( newLap )
|
||||
{
|
||||
// Might happen if the option menu is called
|
||||
RaceGUI* m=(RaceGUI*)menu_manager->getRaceMenu();
|
||||
if(m)
|
||||
{
|
||||
m->addMessage(_("Lap not counted"), this, 2.0f, 60);
|
||||
m->addMessage(_("(shortcut taken)"), this, 2.0f, 60);
|
||||
}
|
||||
m_shortcut_count = 0;
|
||||
}
|
||||
else if ( m_curr_track_coords[1] > 300.0f && m_last_track_coords[1] < 20.0f)
|
||||
{
|
||||
m_race_lap-- ;
|
||||
@ -675,18 +659,11 @@ void Kart::update (float dt)
|
||||
world->m_track->findRoadSector(m_curr_pos.xyz, &m_track_sector);
|
||||
|
||||
// Check if the kart is taking a shortcut (if it's not already doing one):
|
||||
if(m_shortcut_type!=SC_SKIPPED_SECTOR && !m_rescue)
|
||||
if(!m_is_shortcut && !m_rescue)
|
||||
{
|
||||
if(world->m_track->isShortcut(prev_sector, m_track_sector))
|
||||
{
|
||||
// Skipped sectors are more severe then getting outside the
|
||||
// road, so count this as two. But if the kart is already
|
||||
// outside the track, only one is added (since the outside
|
||||
// track shortcut already added 1).
|
||||
|
||||
// This gets subtracted again when doing the rescue
|
||||
m_shortcut_count+= m_shortcut_type==SC_NONE ? 2 : 1;
|
||||
m_shortcut_type = SC_SKIPPED_SECTOR;
|
||||
m_is_shortcut = true;
|
||||
if(isPlayerKart())
|
||||
{
|
||||
forceRescue(); // bring karts back to where they left the track.
|
||||
@ -701,7 +678,7 @@ void Kart::update (float dt)
|
||||
{ // The kart is already doing a skipped sector --> reset
|
||||
// the flag, since from now on (it's on a new sector) it's
|
||||
// not a shortcut anymore.
|
||||
m_shortcut_type=SC_NONE;
|
||||
m_is_shortcut=false;
|
||||
}
|
||||
|
||||
if (m_track_sector == Track::UNKNOWN_SECTOR && !m_rescue)
|
||||
@ -722,29 +699,7 @@ void Kart::update (float dt)
|
||||
int sector = world->m_track->spatialToTrack( m_curr_track_coords,
|
||||
m_curr_pos.xyz,
|
||||
m_track_sector );
|
||||
// If the kart is more thanm_max_road_distance away from the border of
|
||||
// the track, the kart is considered taking a shortcut (but not on level
|
||||
// easy, and not while being rescued)
|
||||
|
||||
if(world->m_race_setup.m_difficulty != RD_EASY &&
|
||||
!m_rescue &&
|
||||
m_shortcut_type != SC_SKIPPED_SECTOR &&
|
||||
fabsf(m_curr_track_coords[0])-stk_config->m_max_road_distance
|
||||
> m_curr_track_coords[2] )
|
||||
{
|
||||
m_shortcut_sector = sector;
|
||||
// Increase the error count the first time this happens
|
||||
if(m_shortcut_type==SC_NONE)
|
||||
m_shortcut_count++;
|
||||
m_shortcut_type = SC_OUTSIDE_TRACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Kart was taking a shortcut before, but it finished. So increase the
|
||||
// overall shortcut count.
|
||||
if(m_shortcut_type == SC_OUTSIDE_TRACK)
|
||||
m_shortcut_type = SC_NONE;
|
||||
}
|
||||
doLapCounting () ;
|
||||
processSkidMarks();
|
||||
} // update
|
||||
@ -943,17 +898,15 @@ float Kart::NormalizedLateralForce(float alpha, float corner) const
|
||||
} // NormalizedLateralForce
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Kart::forceRescue()
|
||||
void Kart::forceRescue(bool is_shortcut)
|
||||
{
|
||||
m_rescue=true;
|
||||
// If rescue is triggered while doing a shortcut, reset the kart to the
|
||||
// segment where the shortcut started!! And then reset the shortcut
|
||||
// flag, so that this shortcut is not counted!
|
||||
if(m_shortcut_type!=SC_NONE)
|
||||
if(is_shortcut)
|
||||
{
|
||||
m_track_sector = m_shortcut_sector;
|
||||
m_shortcut_count-= m_shortcut_type==SC_OUTSIDE_TRACK ? 1 : 2;
|
||||
m_shortcut_type = SC_NONE;
|
||||
}
|
||||
} // forceRescue
|
||||
//-----------------------------------------------------------------------------
|
||||
|
10
src/kart.hpp
10
src/kart.hpp
@ -91,12 +91,9 @@ protected:
|
||||
float m_lap_start_time; // Time at start of a new lap
|
||||
float m_kart_length; // length of kart
|
||||
char m_fastest_lap_message[255];
|
||||
int m_shortcut_count; // counts number of times a shortcut is used
|
||||
|
||||
bool m_is_shortcut; // true if the kart is taking a shortcut
|
||||
int m_shortcut_sector; // segment on which the shortcut was started
|
||||
enum {SC_NONE, // no shortcut
|
||||
SC_SKIPPED_SECTOR, // skipped too many sectors
|
||||
SC_OUTSIDE_TRACK} // too far away from tracj
|
||||
m_shortcut_type ; // what kind of shortcut was detected
|
||||
|
||||
// physics parameters, storing it saves time
|
||||
btRaycastVehicle::btVehicleTuning *m_tuning;
|
||||
@ -167,7 +164,6 @@ public:
|
||||
int getPosition () const { return m_race_position ; }
|
||||
void setFinishingState(float time);
|
||||
float getFinishTime () const { return m_finish_time; }
|
||||
bool isTakingShortcut () const { return m_shortcut_type!=SC_NONE;}
|
||||
bool raceIsFinished () const { return m_finished_race; }
|
||||
void endRescue ();
|
||||
float estimateFinishTime ();
|
||||
@ -233,7 +229,7 @@ public:
|
||||
bool isRescue () const {return m_rescue;}
|
||||
void resetBrakes ();
|
||||
void adjustSpeedWeight(float f);
|
||||
void forceRescue ();
|
||||
void forceRescue (bool is_rescue=false);
|
||||
void handleExplosion (const sgVec3& pos, bool direct_hit);
|
||||
const std::string& getName () const {return m_kart_properties->getName();}
|
||||
virtual int isPlayerKart () const {return 0; }
|
||||
|
@ -125,12 +125,6 @@ void Loader::addSearchPath(const std::string& PATH)
|
||||
m_search_path.push_back(PATH);
|
||||
} // addSearchPath
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Loader::addSearchPath(const char* PATH)
|
||||
{
|
||||
m_search_path.push_back(std::string(PATH));
|
||||
} // addSearchPath
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Loader::initConfigDir()
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
const;
|
||||
|
||||
void addSearchPath(const std::string& path);
|
||||
void addSearchPath(const char* path);
|
||||
void addSearchPath(const char* path) {addSearchPath(std::string(path)); }
|
||||
void initConfigDir();
|
||||
ssgEntity *load(const std::string& filename, CallbackType t, bool optimise=true);
|
||||
void setCallbackType(CallbackType t) {m_current_callback_type=t;}
|
||||
|
@ -240,14 +240,5 @@ void PlayerKart::addMessages()
|
||||
} // if angle is too big
|
||||
} // if difficulty easy
|
||||
|
||||
// 2) Check if a shortcut is currently be taken
|
||||
// --------------------------------------------
|
||||
|
||||
if(world->m_race_setup.m_difficulty != RD_EASY &&
|
||||
m_shortcut_type == SC_OUTSIDE_TRACK)
|
||||
{
|
||||
m->addMessage(_("Invalid short-cut!"), this, -1.0f, 60);
|
||||
}
|
||||
|
||||
} // addMessages
|
||||
/* EOF */
|
||||
|
@ -107,7 +107,6 @@ void STKConfig::load(const std::string filename)
|
||||
CHECK_NEG(m_anvil_time, "anvil-time" );
|
||||
CHECK_NEG(m_zipper_time, "zipper-time" );
|
||||
CHECK_NEG(m_zipper_force, "zipper-force" );
|
||||
CHECK_NEG(m_max_road_distance, "shortcut-road-distance" );
|
||||
CHECK_NEG(m_shortcut_segments, "shortcut-skipped-segments" );
|
||||
CHECK_NEG(m_suspension_rest, "suspension-rest" );
|
||||
CHECK_NEG(m_jump_velocity, "jump-velocity" );
|
||||
@ -131,8 +130,7 @@ void STKConfig::init_defaults()
|
||||
m_wheelie_max_speed_ratio = m_wheelie_pitch_rate = m_wheelie_restore_rate =
|
||||
m_wheelie_speed_boost = m_air_res_reduce[2] = m_air_res_reduce[1] =
|
||||
m_parachute_time = m_bomb_time = m_bomb_time_increase= m_anvil_time =
|
||||
m_zipper_time = m_zipper_force =
|
||||
m_parachute_time_other = m_max_road_distance = m_shortcut_segments =
|
||||
m_zipper_time = m_zipper_force = m_parachute_time_other = m_shortcut_segments =
|
||||
//bullet physics data
|
||||
m_suspension_stiffness = m_wheel_damping_relaxation = m_wheel_damping_compression =
|
||||
m_friction_slip = m_roll_influence = m_wheel_radius = m_wheel_width =
|
||||
@ -155,7 +153,6 @@ void STKConfig::getAllData(const lisp::Lisp* lisp)
|
||||
// Get the values which are not part of the default KartProperties
|
||||
// ---------------------------------------------------------------
|
||||
lisp->get("anvil-weight", m_anvil_weight );
|
||||
lisp->get("shortcut-road-distance", m_max_road_distance );
|
||||
lisp->get("shortcut-skipped-segments", m_shortcut_segments );
|
||||
lisp->get("anvil-speed-factor", m_anvil_speed_factor );
|
||||
lisp->get("parachute-friction", m_parachute_friction );
|
||||
|
@ -38,7 +38,6 @@ public:
|
||||
float m_anvil_time; // time an anvil is active
|
||||
float m_zipper_time; // duration a zipper is active
|
||||
float m_zipper_force; // additional force added to the acceleration
|
||||
float m_max_road_distance; // max distance from road to be still ON road
|
||||
float m_shortcut_segments; // skipping more than this number of segments is
|
||||
// considered to be a shortcut
|
||||
float m_explosion_impulse; // impulse affecting each non-hit kart
|
||||
|
Loading…
Reference in New Issue
Block a user