Bugfix for 1778264: karts starting off the track (esp.
with about 10 karts in tuxtrack and islandtrack). The number of karts is additionally now limited to 10 (see stk_config.data), the only reason for this is to avoid the same bug report when someone is using more karts than the number of specified start locations. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1261 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
57e93880de
commit
fddfac77d2
@ -6,6 +6,10 @@
|
||||
(music "mods/Boom_boom_boom.mod")
|
||||
(screenshot "sshot-islandtrack.rgb")
|
||||
(topview "topview-islandtrack.rgb")
|
||||
(start-heading 0.0 3.7 9.5 11.5 15.1 17.0 20.2 22.0 26.0 36.0 )
|
||||
(start-x -1.2 1.6 -0.9 2.3 0.0 3.4 1.2 4.2 2.6 6.2 )
|
||||
(start-y -0.5 -1.5 -3.8 -5.0 -7.0 -8.0 -10.4 -10.9 -13.4 -14.1 )
|
||||
|
||||
)
|
||||
|
||||
;; EOF ;;
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
(config
|
||||
|
||||
;; STK parameters
|
||||
;; --------------
|
||||
(max-karts 10 ) ;; maximum number of karts
|
||||
|
||||
;; Attachment related parameters
|
||||
;; -----------------------------
|
||||
(anvil-weight 150.0 ) ;; additional weight an anvil adds to a kart
|
||||
|
@ -13,7 +13,8 @@
|
||||
(sun-ambient 0.3 0.4 0.5 0.0)
|
||||
(sun-diffuse 0.3 0.4 0.5 0.0)
|
||||
(sun-specular 0.8 0.8 1.0 0.0)
|
||||
|
||||
;; The default x start coordinates are a bit too far to the right
|
||||
(start-x 2.0 -1.0 2.0 -1.0 2.0 -1.0 2.0 -1.0 2.0 -1.0 )
|
||||
(music "mods/tuxr.mod")
|
||||
(screenshot "sshot-subseatrack.rgb")
|
||||
(topview "topview-subseatrack.rgb")
|
||||
|
@ -6,6 +6,10 @@
|
||||
(music "mods/tk2.mod")
|
||||
(screenshot "sshot-tuxtrack.rgb")
|
||||
(topview "topview-tuxtrack.rgb")
|
||||
(start-heading -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 -25.0 )
|
||||
(start-x 0.1 -3.3 -1.5 -4.8 -3.0 -6.3 -4.5 -7.8 -6.0 -9.3 )
|
||||
(start-y -2.0 -1.8 -4.6 -4.4 -7.2 -7.0 -9.8 -9.6 -12.4 -12.2 )
|
||||
|
||||
)
|
||||
|
||||
;; EOF ;;
|
||||
|
@ -396,6 +396,10 @@ void Kart::reset()
|
||||
#ifdef BULLET
|
||||
btTransform *trans=new btTransform();
|
||||
trans->setIdentity();
|
||||
// Set heading:
|
||||
trans->setRotation(btQuaternion(btVector3(0.0f, 0.0f, 1.0f),
|
||||
m_reset_pos.hpr[0]*3.1415926f/180.0f));
|
||||
// Set position
|
||||
trans->setOrigin(btVector3(m_reset_pos.xyz[0],
|
||||
m_reset_pos.xyz[1],
|
||||
m_reset_pos.xyz[2]+0.5*m_kart_height));
|
||||
|
10
src/main.cpp
10
src/main.cpp
@ -170,8 +170,14 @@ int handleCmdLine(int argc, char **argv)
|
||||
else if( (!strcmp(argv[i], "--numkarts") || !strcmp(argv[i], "-k")) &&
|
||||
i+1<argc )
|
||||
{
|
||||
race_manager->setNumKarts(user_config->m_karts = atoi(argv[i+1]));
|
||||
fprintf ( stdout, _("You choose to have %s karts.\n"), argv[i+1] ) ;
|
||||
user_config->m_karts = atoi(argv[i+1]);
|
||||
if(user_config->m_karts>stk_config->m_max_karts) {
|
||||
fprintf(stdout, _("Number of karts reset to maximum number %d\n"),
|
||||
stk_config->m_max_karts);
|
||||
user_config->m_karts = stk_config->m_max_karts;
|
||||
}
|
||||
race_manager->setNumKarts(user_config->m_karts );
|
||||
fprintf ( stdout, _("%d karts will be used.\n"), user_config->m_karts);
|
||||
}
|
||||
else if( !strcmp(argv[i], "--list-tracks") || !strcmp(argv[i], "-l") )
|
||||
{
|
||||
|
@ -148,26 +148,26 @@ public:
|
||||
void setPlayerKart(int player, const std::string& kart);
|
||||
void setNumPlayers(int num);
|
||||
void reset();
|
||||
void setGrandPrix(const CupData &cup_) { m_cup = cup_; }
|
||||
void setGrandPrix(const CupData &cup_) { m_cup = cup_; }
|
||||
void setDifficulty(RaceDifficulty diff_) { m_difficulty = diff_; }
|
||||
void setNumLaps(int num) { m_num_laps = num; }
|
||||
void setNumLaps(int num) { m_num_laps = num; }
|
||||
void setTrack(const std::string& track_) { m_track = track_; }
|
||||
void setRaceMode(RaceSetup::RaceMode mode) { m_race_mode = mode; }
|
||||
void setNumKarts(int num) { m_num_karts = num; }
|
||||
int getNumKarts() const { return m_num_karts; }
|
||||
void setNumKarts(int num) { m_num_karts = num; }
|
||||
int getNumKarts() const { return m_num_karts; }
|
||||
int getNumPlayers() const { return (int)m_players.size(); }
|
||||
int getNumLaps() const { return m_num_laps; }
|
||||
int getNumLaps() const { return m_num_laps; }
|
||||
CupData *getGrandPrix() { return &m_cup; }
|
||||
unsigned int getFinishedKarts() const { return m_num_finished_karts; }
|
||||
unsigned int getFinishedPlayers() const { return m_num_finished_players; }
|
||||
unsigned int getFinishedKarts() const { return m_num_finished_karts; }
|
||||
unsigned int getFinishedPlayers() const { return m_num_finished_players; }
|
||||
int getKartScore(int kart ) const { return m_mode->getKartScore(kart); }
|
||||
int getPositionScore(int pos) const { return m_mode->getPositionScore(pos);}
|
||||
std::string getKartName(int kart) const { return m_mode->getKartName(kart); }
|
||||
void addKartScore(int kart, int pos) { m_mode->addKartScore(kart, pos); }
|
||||
void addFinishedKarts(int num) { m_num_finished_karts += num; }
|
||||
void PlayerFinishes() { m_num_finished_players++; }
|
||||
int allPlayerFinished() {return m_num_finished_players==m_players.size();}
|
||||
int raceIsActive() {return m_active_race;}
|
||||
void addFinishedKarts(int num) { m_num_finished_karts += num; }
|
||||
void PlayerFinishes() { m_num_finished_players++; }
|
||||
int allPlayerFinished() {return m_num_finished_players==m_players.size();}
|
||||
int raceIsActive() {return m_active_race; }
|
||||
|
||||
void setMirror() {/*FIXME*/}
|
||||
void setReverse(){/*FIXME*/}
|
||||
|
@ -53,6 +53,8 @@ void STKConfig::load(const std::string filename)
|
||||
exit(-1);
|
||||
}
|
||||
#endif
|
||||
CHECK_NEG(m_max_karts, "max-karts" );
|
||||
|
||||
CHECK_NEG(m_corn_r, "m_corn_r" );
|
||||
CHECK_NEG(m_corn_f, "m_corn_f" );
|
||||
|
||||
@ -139,6 +141,7 @@ void STKConfig::init_defaults()
|
||||
m_maximum_speed = m_brake_force = m_gravity_center_shift = m_suspension_rest =
|
||||
m_max_speed_reverse_ratio = m_explosion_impulse = -99.9f;
|
||||
|
||||
m_max_karts = -100;
|
||||
m_air_res_reduce[0] = 1.0f;
|
||||
} // init_defaults
|
||||
|
||||
@ -165,6 +168,7 @@ void STKConfig::getAllData(const lisp::Lisp* lisp)
|
||||
lisp->get("bomb-time-increase", m_bomb_time_increase );
|
||||
lisp->get("anvil-time", m_anvil_time );
|
||||
lisp->get("explosion-impulse", m_explosion_impulse );
|
||||
lisp->get("max-karts", m_max_karts );
|
||||
|
||||
// Get the default KartProperties
|
||||
// ------------------------------
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
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
|
||||
int m_max_karts; // maximum number of karts
|
||||
|
||||
STKConfig() : KartProperties() {};
|
||||
void init_defaults ();
|
||||
|
@ -370,6 +370,37 @@ void Track::trackToSpatial ( sgVec3 xyz, const int SECTOR ) const
|
||||
sgCopyVec3 ( xyz, m_driveline [ SECTOR ] ) ;
|
||||
} // trackToSpatial
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Track::createHash(ssgEntity* track_branch, unsigned int n) {
|
||||
m_static_ssg = new StaticSSG(track_branch, n);
|
||||
} // createHash
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns the start coordinates for a kart on a given position pos
|
||||
(with 0<=pos).
|
||||
*/
|
||||
void Track::getStartCoords(unsigned int pos, sgCoord* coords) const {
|
||||
// Bug fix/workaround: sometimes the first kart would be too close
|
||||
// to the first driveline point and not to the last one -->
|
||||
// This kart would not get any lap counting done in the first
|
||||
// lap! Therefor -1.5 is subtracted from the y position - which
|
||||
// is a somewhat arbitrary value.
|
||||
coords->xyz[0] = pos<m_start_x.size() ? m_start_x[pos] : ((pos%2==0)?1.5:-1.5f);
|
||||
coords->xyz[1] = pos<m_start_y.size() ? m_start_y[pos] : -1.5f*pos-1.5f;
|
||||
// height must be larger than the actual hight for which hot is computed.
|
||||
coords->xyz[2] = pos<m_start_z.size() ? m_start_z[pos] : 1.0f;
|
||||
|
||||
coords->hpr[0] = pos<m_start_heading.size() ? m_start_heading[pos] : 0.0f;
|
||||
coords->hpr[1] = 0.0f;
|
||||
coords->hpr[2] = 0.0f;
|
||||
|
||||
ssgLeaf *leaf;
|
||||
sgVec4* normal;
|
||||
const float hot = m_static_ssg->hot(coords->xyz, coords->xyz, &leaf, &normal);
|
||||
coords->xyz[2] = hot;
|
||||
|
||||
} // getStartCoords
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Determines if a kart moving from sector OLDSEC to sector NEWSEC
|
||||
* would be taking a shortcut, i.e. if the distance is larger
|
||||
@ -747,25 +778,29 @@ void Track::loadTrack(std::string filename_)
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
|
||||
LISP->get("name", m_name);
|
||||
LISP->get("description", m_description);
|
||||
LISP->getVector("music", m_music_filenames);
|
||||
LISP->get("herring", m_herring_style);
|
||||
LISP->get("screenshot", m_screenshot);
|
||||
LISP->get("topview", m_top_view);
|
||||
LISP->get("sky-color", m_sky_color);
|
||||
LISP->get ("name", m_name);
|
||||
LISP->get ("description", m_description);
|
||||
LISP->getVector("music", m_music_filenames);
|
||||
LISP->get ("herring", m_herring_style);
|
||||
LISP->get ("screenshot", m_screenshot);
|
||||
LISP->get ("topview", m_top_view);
|
||||
LISP->get ("sky-color", m_sky_color);
|
||||
LISP->getVector("start-x", m_start_x);
|
||||
LISP->getVector("start-y", m_start_y);
|
||||
LISP->getVector("start-z", m_start_z);
|
||||
LISP->getVector("start-heading", m_start_heading);
|
||||
|
||||
LISP->get("use-fog", m_use_fog);
|
||||
LISP->get("fog-color", m_fog_color);
|
||||
LISP->get("fog-density", m_fog_density);
|
||||
LISP->get("fog-start", m_fog_start);
|
||||
LISP->get("fog-end", m_fog_end);
|
||||
LISP->get ("use-fog", m_use_fog);
|
||||
LISP->get ("fog-color", m_fog_color);
|
||||
LISP->get ("fog-density", m_fog_density);
|
||||
LISP->get ("fog-start", m_fog_start);
|
||||
LISP->get ("fog-end", m_fog_end);
|
||||
|
||||
LISP->get("sun-position", m_sun_position);
|
||||
LISP->get("sun-ambient", m_ambient_col);
|
||||
LISP->get("sun-specular", m_specular_col);
|
||||
LISP->get("sun-diffuse", m_diffuse_col);
|
||||
LISP->get("m_gravity", m_gravity);
|
||||
LISP->get ("sun-position", m_sun_position);
|
||||
LISP->get ("sun-ambient", m_ambient_col);
|
||||
LISP->get ("sun-specular", m_specular_col);
|
||||
LISP->get ("sun-diffuse", m_diffuse_col);
|
||||
LISP->get ("m_gravity", m_gravity);
|
||||
delete ROOT;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <plib/ssg.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "static_ssg.hpp"
|
||||
|
||||
class Track
|
||||
{
|
||||
@ -43,9 +43,11 @@ private:
|
||||
std::string m_screenshot;
|
||||
std::string m_top_view;
|
||||
std::vector<std::string> m_music_filenames;
|
||||
std::vector<float> m_start_x, m_start_y, m_start_z, m_start_heading;
|
||||
std::string m_herring_style;
|
||||
std::string m_description;
|
||||
std::string m_filename;
|
||||
StaticSSG* m_static_ssg;
|
||||
|
||||
public:
|
||||
enum RoadSide{ RS_DONT_KNOW = -1, RS_LEFT = 0, RS_RIGHT = 1 };
|
||||
@ -168,11 +170,18 @@ public:
|
||||
const float& getFogEnd () const {return m_fog_end; }
|
||||
const sgVec4& getSkyColor () const {return m_sky_color; }
|
||||
const std::string& getDescription () const {return m_description; }
|
||||
const std::string& getTopviewFile () const {return m_top_view; }
|
||||
const std::string& getTopviewFile () const {return m_top_view; }
|
||||
const std::string& getScreenshotFile() const {return m_screenshot; }
|
||||
const std::vector<sgVec3Wrapper>& getDriveline () const {return m_driveline;}
|
||||
const std::vector<SGfloat>& getWidth() const {return m_path_width; }
|
||||
const std::string& getHerringStyle () const {return m_herring_style; }
|
||||
void createHash (ssgEntity* track_branch, unsigned int n);
|
||||
void getStartCoords (unsigned int pos, sgCoord* coords) const;
|
||||
int Collision(sgSphere* s, AllHits *a) const
|
||||
{return m_static_ssg->collision(s,a); }
|
||||
float GetHOT(sgVec3 start, sgVec3 end,
|
||||
ssgLeaf** l, sgVec4** nrm) const
|
||||
{return m_static_ssg->hot(start, end, l, nrm);}
|
||||
void glVtx (sgVec2 v, float x_offset, float y_offset) const
|
||||
{
|
||||
glVertex2f(
|
||||
|
@ -37,7 +37,7 @@ TrackManager::~TrackManager()
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const Track*
|
||||
Track*
|
||||
TrackManager::getTrack(const std::string& ident) const
|
||||
{
|
||||
for(Tracks::const_iterator i = m_tracks.begin(); i != m_tracks.end(); ++i)
|
||||
@ -52,7 +52,7 @@ TrackManager::getTrack(const std::string& ident) const
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const Track*
|
||||
Track*
|
||||
TrackManager::getTrack(size_t id) const
|
||||
{
|
||||
return m_tracks[id];
|
||||
|
@ -38,8 +38,8 @@ public:
|
||||
|
||||
/** get TrackData by the track ident (aka filename without
|
||||
.track) */
|
||||
const Track* getTrack(const std::string& ident) const;
|
||||
const Track* getTrack(size_t id) const;
|
||||
Track* getTrack(const std::string& ident) const;
|
||||
Track* getTrack(size_t id) const;
|
||||
|
||||
size_t getTrackCount() const;
|
||||
|
||||
|
@ -109,36 +109,22 @@ World::World(const RaceSetup& raceSetup_) : m_race_setup(raceSetup_)
|
||||
// karts can be positioned properly on (and not in) the tracks.
|
||||
loadTrack ( ) ;
|
||||
|
||||
m_static_ssg = new StaticSSG(m_track_branch, 1000);
|
||||
m_track->createHash(m_track_branch, 1000);
|
||||
|
||||
int pos = 0;
|
||||
int playerIndex = 0;
|
||||
for (RaceSetup::Karts::iterator i = m_race_setup.m_karts.begin() ;
|
||||
i != m_race_setup.m_karts.end() ; ++i )
|
||||
{
|
||||
// First determine the x/y/z position for the kart
|
||||
sgCoord init_pos = { { 0, 0, 0 }, { 0, 0, 0 } } ;
|
||||
//float hot=0.0;
|
||||
// Bug fix/workaround: sometimes the first kart would be too close
|
||||
// to the first driveline point and not to the last one -->
|
||||
// This kart would not get any lap counting done in the first
|
||||
// lap! Therefor -1.5 is subtracted from the y position - which
|
||||
// is a somewhat arbitrary value.
|
||||
init_pos.xyz[0] = (pos % 2 == 0) ? 1.5f : -1.5f ;
|
||||
init_pos.xyz[1] = -pos * 1.5f -1.5f;
|
||||
init_pos.xyz[2] = 1.0f; // height must be and larger than the actual
|
||||
// hight for which hot is computed.
|
||||
ssgLeaf *leaf;
|
||||
sgVec4* normal;
|
||||
const float hot = GetHOT(init_pos.xyz, init_pos.xyz, &leaf, &normal);
|
||||
init_pos.xyz[2] = hot;
|
||||
sgCoord init_pos;
|
||||
m_track->getStartCoords(pos, &init_pos);
|
||||
|
||||
Kart* newkart;
|
||||
if(user_config->m_profile)
|
||||
{
|
||||
// In profile mode, load only the old kart
|
||||
newkart = new DefaultRobot (kart_properties_manager->getKart("tuxkart"), pos,
|
||||
init_pos);
|
||||
init_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -156,7 +142,7 @@ World::World(const RaceSetup& raceSetup_) : m_race_setup(raceSetup_)
|
||||
else
|
||||
{
|
||||
newkart = loadRobot(kart_properties_manager->getKart(*i), pos,
|
||||
init_pos);
|
||||
init_pos);
|
||||
}
|
||||
} // if !user_config->m_profile
|
||||
if(user_config->m_replay_history)
|
||||
@ -669,7 +655,7 @@ void World::herring_command (sgVec3 *xyz, char htype, int bNeedHeight )
|
||||
// Even if 3d data are given, make sure that the herring is on the ground
|
||||
(*xyz)[2] = getHeight ( m_track_branch, *xyz ) + 0.06f;
|
||||
herringType type=HE_GREEN;
|
||||
if ( htype=='Y' || htype=='y' ) { type = HE_GOLD ;}
|
||||
if ( htype=='Y' || htype=='y' ) { type = HE_GOLD ;}
|
||||
if ( htype=='G' || htype=='g' ) { type = HE_GREEN ;}
|
||||
if ( htype=='R' || htype=='r' ) { type = HE_RED ;}
|
||||
if ( htype=='S' || htype=='s' ) { type = HE_SILVER ;}
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <vector>
|
||||
#include <plib/ssg.h>
|
||||
#include "race_setup.hpp"
|
||||
#include "static_ssg.hpp"
|
||||
#include "track.hpp"
|
||||
#include "player_kart.hpp"
|
||||
#include "physics.hpp"
|
||||
@ -64,7 +63,7 @@ public:
|
||||
|
||||
int m_ready_set_go;
|
||||
|
||||
const Track* m_track;
|
||||
Track* m_track;
|
||||
|
||||
/** debug text that will be overlaid to the screen */
|
||||
std::string m_debug_text[10];
|
||||
@ -72,13 +71,12 @@ public:
|
||||
/** Reference to the track inside the scene */
|
||||
ssgBranch *m_track_branch ;
|
||||
|
||||
|
||||
World(const RaceSetup& raceSetup);
|
||||
virtual ~World();
|
||||
float GetHOT(sgVec3 start, sgVec3 end, ssgLeaf** leaf, sgVec4** nrm)
|
||||
{return m_static_ssg->hot(start, end, leaf, nrm);}
|
||||
int Collision(sgSphere* s, AllHits *a)
|
||||
{return m_static_ssg->collision(s,a); }
|
||||
|
||||
{return m_track->GetHOT(start, end, leaf, nrm);}
|
||||
int Collision(sgSphere* s, AllHits *a) const {return m_track->Collision(s,a); }
|
||||
void draw();
|
||||
void update(float delta);
|
||||
void restartRace();
|
||||
@ -112,7 +110,6 @@ public:
|
||||
void unpause();
|
||||
private:
|
||||
Karts m_kart;
|
||||
StaticSSG* m_static_ssg;
|
||||
float m_finish_delay_start_time;
|
||||
int* m_number_collisions;
|
||||
Physics* m_physics;
|
||||
|
Loading…
x
Reference in New Issue
Block a user