From: <au...@us...> - 2010-02-17 23:35:31
|
Revision: 4756 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4756&view=rev Author: auria Date: 2010-02-17 23:35:25 +0000 (Wed, 17 Feb 2010) Log Message: ----------- Clarified one method by using a enum type instead of simply 'int' Modified Paths: -------------- main/trunk/src/modes/three_strikes_battle.cpp main/trunk/src/modes/three_strikes_battle.hpp main/trunk/src/modes/world.hpp Modified: main/trunk/src/modes/three_strikes_battle.cpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.cpp 2010-02-17 23:32:43 UTC (rev 4755) +++ main/trunk/src/modes/three_strikes_battle.cpp 2010-02-17 23:35:25 UTC (rev 4756) @@ -311,7 +311,7 @@ } // raceResultOrder //----------------------------------------------------------------------------- -bool ThreeStrikesBattle::acceptPowerup(const int type) const +bool ThreeStrikesBattle::acceptPowerup(const PowerupType type) const { // these powerups don't make much sense in battle mode if(type == POWERUP_PARACHUTE || type == POWERUP_ANVIL || Modified: main/trunk/src/modes/three_strikes_battle.hpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.hpp 2010-02-17 23:32:43 UTC (rev 4755) +++ main/trunk/src/modes/three_strikes_battle.hpp 2010-02-17 23:35:25 UTC (rev 4756) @@ -59,7 +59,7 @@ virtual RaceGUI::KartIconDisplayInfo* getKartsDisplayInfo(); virtual bool raceHasLaps(){ return false; } virtual void moveKartAfterRescue(Kart* kart, btRigidBody* body); - virtual bool acceptPowerup(const int type) const; + virtual bool acceptPowerup(const PowerupType type) const; virtual std::string getIdent() const; Modified: main/trunk/src/modes/world.hpp =================================================================== --- main/trunk/src/modes/world.hpp 2010-02-17 23:32:43 UTC (rev 4755) +++ main/trunk/src/modes/world.hpp 2010-02-17 23:35:25 UTC (rev 4756) @@ -205,7 +205,7 @@ /** called when a bonus box is hit, to determine which types of powerups are allowed in each game mode. By default all are accepted, override in child classes to get a different behaviour */ - virtual bool acceptPowerup(const int type) const { return true; } + virtual bool acceptPowerup(const PowerupType type) const { return true; } /** Called by the code that draws the list of karts on the race GUI * to know what needs to be drawn in the current mode This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-03-07 16:52:26
|
Revision: 4953 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4953&view=rev Author: auria Date: 2010-03-07 16:52:20 +0000 (Sun, 07 Mar 2010) Log Message: ----------- Added sanity checks to debug bogus rankings, especially in GPs. Improved Doxygen documentation on the way. Modified Paths: -------------- main/trunk/src/modes/linear_world.cpp main/trunk/src/modes/linear_world.hpp main/trunk/src/modes/world.hpp Modified: main/trunk/src/modes/linear_world.cpp =================================================================== --- main/trunk/src/modes/linear_world.cpp 2010-03-07 02:25:25 UTC (rev 4952) +++ main/trunk/src/modes/linear_world.cpp 2010-03-07 16:52:20 UTC (rev 4953) @@ -119,8 +119,29 @@ // First all kart infos must be updated before the kart position can be // recomputed, since otherwise 'new' (initialised) valued will be compared // with old values. - for(unsigned int i=0; i<kart_amount; i++) + for (unsigned int i=0; i<kart_amount; i++) + { updateRacePosition(m_karts[i], m_kart_info[i]); + } + +#ifdef DEBUG + //FIXME: this could be defined somewhere in a central header so it can be used everywhere +#define assertExpr( ARG1, OP, ARG2 ) if (!(ARG1 OP ARG2)) \ + { \ + std::cerr << "Failed assert " << #ARG1 << #OP << #ARG2 << " @ " << __FILE__ << ":" << __LINE__ \ + << "; values are (" << ARG1 << #OP << ARG2 << ")\n"; \ + assert(false); \ + } + + for (unsigned int i=0; i<kart_amount; i++) + { + for (unsigned int j=i+1; j<kart_amount; j++) + { + assertExpr( m_karts[i]->getPosition(), !=, m_karts[j]->getPosition() ); + } + } +#endif + } // restartRace //----------------------------------------------------------------------------- @@ -409,13 +430,46 @@ // ---------------------------------------------------------------------------- /** Sets up the mapping from kart position to kart index. */ -void LinearWorld::raceResultOrder( int* order ) +void LinearWorld::raceResultOrder( int order[] ) { const unsigned int NUM_KARTS = getNumKarts(); - for(unsigned int i=0; i < NUM_KARTS; i++) + +#ifndef NDEBUG + for (unsigned int i=0; i < NUM_KARTS; i++) { - order[getKart(i)->getPosition()-1] = i; // even for eliminated karts + order[i] = -1; } +#endif + + for (unsigned int i=0; i < NUM_KARTS; i++) + { + const int position = getKart(i)->getPosition()-1; + +#ifndef NDEBUG + // sanity checks + if (order[position] != -1) + { + std::cerr << "== TWO KARTS ARE BEING GIVEN THE SAME POSITION!! ==\n"; + for (unsigned int j=0; j < NUM_KARTS; j++) + { + if (order[j] == -1) + { + std::cout << " No kart is yet set at position " << j << std::endl; + } + else + { + std::cout << " Kart " << order[j] << " is at position " << j << std::endl; + } + } + std::cout << "Kart " << i << " is being given posiiton " << (getKart(i)->getPosition()-1) + << ", but this position is already taken\n"; + assert(false); + } +#endif + + // actually assign the position + order[position] = i; // even for eliminated karts + } } // raceResultOrder //----------------------------------------------------------------------------- @@ -521,7 +575,7 @@ const float my_progression = getDistanceDownTrackForKart(my_id); for ( unsigned int j = 0 ; j < kart_amount ; j++ ) { - if(j == kart->getWorldKartId()) continue; // don't compare a kart with itself + if(j == kart->getWorldKartId()) continue; // don't compare a kart with itself if(m_karts[j]->isEliminated()) continue; // dismiss eliminated karts // Count karts ahead of the current kart, i.e. kart that are already @@ -548,7 +602,9 @@ p++; } } //next kart + kart->setPosition(p); + // Switch on faster music if not already done so, if the // first kart is doing its last lap, and if the estimated // remaining time is less than 30 seconds. Modified: main/trunk/src/modes/linear_world.hpp =================================================================== --- main/trunk/src/modes/linear_world.hpp 2010-03-07 02:25:25 UTC (rev 4952) +++ main/trunk/src/modes/linear_world.hpp 2010-03-07 16:52:20 UTC (rev 4953) @@ -99,7 +99,7 @@ /** Called by the race result GUI at the end of the race to know the final order (fill in the 'order' array) */ - virtual void raceResultOrder( int* order ); + virtual void raceResultOrder( int order[] ); /** Returns true if the kart is on a valid driveline quad. * \param kart_index Index of the kart. */ Modified: main/trunk/src/modes/world.hpp =================================================================== --- main/trunk/src/modes/world.hpp 2010-03-07 02:25:25 UTC (rev 4952) +++ main/trunk/src/modes/world.hpp 2010-03-07 16:52:20 UTC (rev 4953) @@ -241,8 +241,11 @@ virtual void kartHit(const int kart_id) {}; /** Called by the race result GUI at the end of the race to know the final order - (fill in the 'order' array) */ - virtual void raceResultOrder( int* order ) = 0; + * \param[out] order returns the order of karts. order[0] will contain the ID of + * the first kart, order[1] the ID of the second kart, etc... + * Array dimension must be the number of karts. + */ + virtual void raceResultOrder( int order[] ) = 0; }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-03-08 18:39:13
|
Revision: 4959 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4959&view=rev Author: auria Date: 2010-03-08 18:39:05 +0000 (Mon, 08 Mar 2010) Log Message: ----------- Hopefully fixed bug about bogus kart rankings. 1) Made all karts be ranked at the same time, so there's less risk of mismatches 2) Found a precondition inside the sorting method, that was not documented in the doxygen comments, nor enforced with contracts... and sure enough someone somewhere called it without respecting that hidden precondition. Fixed the problem by removing the precondition (the new logic doesn't have the same precondition) Modified Paths: -------------- main/trunk/src/modes/linear_world.cpp main/trunk/src/modes/linear_world.hpp Modified: main/trunk/src/modes/linear_world.cpp =================================================================== --- main/trunk/src/modes/linear_world.cpp 2010-03-08 17:04:05 UTC (rev 4958) +++ main/trunk/src/modes/linear_world.cpp 2010-03-08 18:39:05 UTC (rev 4959) @@ -119,10 +119,7 @@ // First all kart infos must be updated before the kart position can be // recomputed, since otherwise 'new' (initialised) valued will be compared // with old values. - for (unsigned int i=0; i<kart_amount; i++) - { - updateRacePosition(m_karts[i], m_kart_info[i]); - } + updateRacePosition(); #ifdef DEBUG //FIXME: this could be defined somewhere in a central header so it can be used everywhere @@ -194,18 +191,23 @@ // updated their position and laps etc, otherwise inconsistencies // (like two karts at same position) can occur. // --------------------------------------------------------------- - for(unsigned int i=0; i<kart_amount; i++) + + updateRacePosition(); + + for (unsigned int i=0; i<kart_amount; i++) { // ---------- update rank ------ - if(m_karts[i]->hasFinishedRace() || m_karts[i]->isEliminated()) - continue; - updateRacePosition(m_karts[i], m_kart_info[i]); + if (m_karts[i]->hasFinishedRace() || m_karts[i]->isEliminated()) continue; + // During the last lap update the estimated finish time. // This is used to play the faster music, and by the AI - if(m_kart_info[i].m_race_lap == race_manager->getNumLaps()-1) + if (m_kart_info[i].m_race_lap == race_manager->getNumLaps()-1) + { m_kart_info[i].m_estimated_finish = estimateFinishTimeForKart(m_karts[i]); + } checkForWrongDirection(i); } + #ifdef DEBUG // FIXME: Debug output in case that the double position error // occurs again. It can most likely be removed. @@ -563,61 +565,106 @@ } // moveKartAfterRescue //----------------------------------------------------------------------------- -/** Find the position (rank) of 'kart' and update it accordingly +/** Find the position (rank) of every kart */ -void LinearWorld::updateRacePosition ( Kart* kart, KartInfo& kart_info ) +void LinearWorld::updateRacePosition() { - int p = 1 ; + const unsigned int kart_amount = m_karts.size(); - const unsigned int kart_amount = m_karts.size(); - const int my_id = kart->getWorldKartId(); - const int my_laps = getLapForKart(my_id); - const float my_progression = getDistanceDownTrackForKart(my_id); - for ( unsigned int j = 0 ; j < kart_amount ; j++ ) + +#ifdef DEBUG + bool rank_used[kart_amount+1]; + for (unsigned int n=0; n<=kart_amount; n++) rank_used[n] = false; +#endif + + for (unsigned int i=0; i<kart_amount; i++) { - if(j == kart->getWorldKartId()) continue; // don't compare a kart with itself - if(m_karts[j]->isEliminated()) continue; // dismiss eliminated karts + Kart* kart = m_karts[i]; + KartInfo& kart_info = m_kart_info[i]; + + int p = 1 ; - // Count karts ahead of the current kart, i.e. kart that are already - // finished (the current kart k has not yet finished!!), have done more - // laps, or the same number of laps, but a greater distance. - if(m_karts[j]->hasFinishedRace()) { p++; continue; } + const int my_id = kart->getWorldKartId(); + const int my_laps = getLapForKart(my_id); + const float my_progression = getDistanceDownTrackForKart(my_id); + for (unsigned int j = 0 ; j < kart_amount ; j++) + { + if(j == kart->getWorldKartId()) continue; // don't compare a kart with itself + + //if(m_karts[j]->isEliminated()) continue; // dismiss eliminated karts - /* has done more or less lapses */ - assert(j==m_karts[j]->getWorldKartId()); - int other_laps = getLapForKart(j); - if (other_laps != my_laps) + // Count karts ahead of the current kart, i.e. kart that are already finished, + // have done more laps, or the same number of laps, but a greater distance. + if(!kart->hasFinishedRace() && m_karts[j]->hasFinishedRace()) { p++; continue; } + + /* has done more or less lapses */ + assert(j==m_karts[j]->getWorldKartId()); + int other_laps = getLapForKart(j); + if (other_laps != my_laps) + { + if(other_laps > my_laps) p++; // Other kart has more lapses + continue; + } + // Now both karts have the same number of lapses. Test progression. + // A kart is ahead if it's driven further, or driven the same + // distance, but started further to the back. + float other_progression = getDistanceDownTrackForKart(j); + if(other_progression > my_progression || + (other_progression == my_progression && + m_karts[j]->getInitialPosition() > kart->getInitialPosition()) ) + { + p++; + } + } //next kart + +#ifdef DEBUG + if (rank_used[p]) { - if(other_laps > my_laps) p++; // Other kart has more lapses - continue; + std::cerr << "ERROR, same rank used twice!!\n"; + + std::cerr << "Info used to decide ranking :\n"; + for (unsigned int d=0; d<kart_amount; d++) + { + std::cerr << " kart " << m_karts[d]->getIdent() << " has finished(" << m_karts[d]->hasFinishedRace() + << "), is at lap (" << getLapForKart(d) << "), is at distance(" + << getDistanceDownTrackForKart(d) << "), is eliminated(" << m_karts[d]->isEliminated() << ")" << std::endl; + } + + std::cerr << "Used ranks:\n"; + for (unsigned int d=1; d<=kart_amount; d++) + { + std::cerr << " rank " << d << " used : " << rank_used[d] << std::endl; + } + + std::cerr << "Who has each ranking so far :\n"; + for (unsigned int d=0; d<i; d++) + { + std::cerr << " " << m_karts[d]->getIdent() << " has rank " << m_karts[d]->getPosition() << std::endl; + } + + std::cerr << " --> And " << kart->getIdent() << " is being set at rank " << p << std::endl; + assert(false); } - // Now both karts have the same number of lapses. Test progression. - // A kart is ahead if it's driven further, or driven the same - // distance, but started further to the back. - float other_progression = getDistanceDownTrackForKart(j); - if(other_progression > my_progression || - (other_progression == my_progression && - m_karts[j]->getInitialPosition() > kart->getInitialPosition()) ) + rank_used[p] = true; +#endif + + kart->setPosition(p); + + // Switch on faster music if not already done so, if the + // first kart is doing its last lap, and if the estimated + // remaining time is less than 30 seconds. + if(!m_faster_music_active && + kart_info.m_race_lap == race_manager->getNumLaps()-1 && + p==1 && + useFastMusicNearEnd() && + kart_info.m_estimated_finish > 0 && + kart_info.m_estimated_finish - getTime() < 30.0f ) { - p++; + sound_manager->switchToFastMusic(); + m_faster_music_active=true; } - } //next kart + } - kart->setPosition(p); - - // Switch on faster music if not already done so, if the - // first kart is doing its last lap, and if the estimated - // remaining time is less than 30 seconds. - if(!m_faster_music_active && - kart_info.m_race_lap == race_manager->getNumLaps()-1 && - p==1 && - useFastMusicNearEnd() && - kart_info.m_estimated_finish > 0 && - kart_info.m_estimated_finish - getTime() < 30.0f ) - { - sound_manager->switchToFastMusic(); - m_faster_music_active=true; - } } // updateRacePosition //----------------------------------------------------------------------------- Modified: main/trunk/src/modes/linear_world.hpp =================================================================== --- main/trunk/src/modes/linear_world.hpp 2010-03-08 17:04:05 UTC (rev 4958) +++ main/trunk/src/modes/linear_world.hpp 2010-03-08 18:39:05 UTC (rev 4959) @@ -63,11 +63,11 @@ /** Linear races can trigger rescues for one additional reason : shortcuts. - * It may need to do some specific world before calling the generic Kart::forceRescue - */ + * It may need to do some specific world before calling the generic Kart::forceRescue + */ void rescueKartAfterShortcut(Kart* kart, KartInfo& kart_info); void checkForWrongDirection(unsigned int i); - void updateRacePosition(Kart* kart, KartInfo& kart_info ); + void updateRacePosition(); virtual float estimateFinishTimeForKart(Kart* kart); public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-03-27 18:11:17
|
Revision: 5082 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5082&view=rev Author: auria Date: 2010-03-27 18:11:00 +0000 (Sat, 27 Mar 2010) Log Message: ----------- I reproduced wrong kart rank issues again; adding more debug code to better track this bug Modified Paths: -------------- main/trunk/src/modes/linear_world.cpp main/trunk/src/modes/world.cpp Modified: main/trunk/src/modes/linear_world.cpp =================================================================== --- main/trunk/src/modes/linear_world.cpp 2010-03-27 17:32:21 UTC (rev 5081) +++ main/trunk/src/modes/linear_world.cpp 2010-03-27 18:11:00 UTC (rev 5082) @@ -449,6 +449,8 @@ { order[i] = -1; } + + bool positions_ok = true; #endif for (unsigned int i=0; i < NUM_KARTS; i++) @@ -473,13 +475,18 @@ } std::cout << "Kart " << i << " is being given posiiton " << (getKart(i)->getPosition()-1) << ", but this position is already taken\n"; - assert(false); + positions_ok = false; } #endif // actually assign the position order[position] = i; // even for eliminated karts } + +#ifndef NDEBUG + assert(positions_ok); +#endif + } // raceResultOrder //----------------------------------------------------------------------------- Modified: main/trunk/src/modes/world.cpp =================================================================== --- main/trunk/src/modes/world.cpp 2010-03-27 17:32:21 UTC (rev 5081) +++ main/trunk/src/modes/world.cpp 2010-03-27 18:11:00 UTC (rev 5082) @@ -498,7 +498,7 @@ // the kart location data is wrong #ifdef DEBUG - fprintf(stderr, "Error, incorrect kart positions:"); + fprintf(stderr, "Error, incorrect kart positions:\n"); for (unsigned int i=0; i<m_karts.size(); i++ ) { fprintf(stderr, "i=%d position %d\n",i, m_karts[i]->getPosition()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-06-07 03:31:47
|
Revision: 5477 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5477&view=rev Author: hikerstk Date: 2010-06-07 03:31:41 +0000 (Mon, 07 Jun 2010) Log Message: ----------- Added new 'UNDEFINED_PHASE' to catch incorrect pause/unpause sequences (instead of re-using SETUP_PHASE as was done previously). Modified Paths: -------------- main/trunk/src/modes/world_status.cpp main/trunk/src/modes/world_status.hpp Modified: main/trunk/src/modes/world_status.cpp =================================================================== --- main/trunk/src/modes/world_status.cpp 2010-06-07 03:16:02 UTC (rev 5476) +++ main/trunk/src/modes/world_status.cpp 2010-06-07 03:31:41 UTC (rev 5477) @@ -31,8 +31,7 @@ m_time = 0.0f; m_auxiliary_timer = 0.0f; m_phase = SETUP_PHASE; - m_previous_phase = SETUP_PHASE; // initialise it just in case - m_phase = SETUP_PHASE; + m_previous_phase = UNDEFINED_PHASE; // initialise it just in case // FIXME - is it a really good idea to reload and delete the sound every race?? m_prestart_sound = sfx_manager->createSoundSource("prestart"); @@ -47,7 +46,7 @@ m_time = 0.0f; m_auxiliary_timer = 0.0f; m_phase = READY_PHASE; // FIXME - unsure - m_previous_phase = SETUP_PHASE; + m_previous_phase = UNDEFINED_PHASE; } // reset //----------------------------------------------------------------------------- @@ -218,7 +217,7 @@ */ void WorldStatus::pause(Phase phase) { - assert(m_previous_phase==SETUP_PHASE); + assert(m_previous_phase==UNDEFINED_PHASE); m_previous_phase = m_phase; m_phase = phase; } // pause @@ -231,5 +230,5 @@ m_phase = m_previous_phase; // Set m_previous_phase so that we can use an assert // in pause to detect incorrect pause/unpause sequences. - m_previous_phase = SETUP_PHASE; -} + m_previous_phase = UNDEFINED_PHASE; +} // unpause Modified: main/trunk/src/modes/world_status.hpp =================================================================== --- main/trunk/src/modes/world_status.hpp 2010-06-07 03:16:02 UTC (rev 5476) +++ main/trunk/src/modes/world_status.hpp 2010-06-07 03:31:41 UTC (rev 5477) @@ -71,6 +71,8 @@ // Display the in-game menu, but no update of world or anything IN_GAME_MENU_PHASE, + // Undefined, used in asserts to catch incorrect states. + UNDEFINED_PHASE }; protected: SFXBase *m_prestart_sound; @@ -123,11 +125,7 @@ /** Returns the current race time. */ float getTime() const { return m_time; } - /** Returns the value of the auxiliary timer. */ - float getAuxiliaryTimer() const {return m_auxiliary_timer; } - /** - * Call each frame, with the elapsed time as argument. - */ + /** Call each frame, with the elapsed time as argument. */ void update(const float dt); void setTime(const float time); @@ -137,15 +135,11 @@ virtual void enterRaceOverState(); virtual void terminateRace(); - /* - * Will be called to notify your derived class that the clock, - * which is in COUNTDOWN mode, has reached zero. - */ + /** Will be called to notify your derived class that the clock, + * which is in COUNTDOWN mode, has reached zero. */ virtual void countdownReachedZero() {}; - /* - * Called when the race actually starts. - */ + /** Called when the race actually starts. */ virtual void onGo() {}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-07-22 22:50:02
|
Revision: 5704 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5704&view=rev Author: hikerstk Date: 2010-07-22 22:49:56 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Keep the race going (with end race controller) while the race results are shown. Modified Paths: -------------- main/trunk/src/modes/world.cpp main/trunk/src/modes/world_status.cpp Modified: main/trunk/src/modes/world.cpp =================================================================== --- main/trunk/src/modes/world.cpp 2010-07-22 22:33:53 UTC (rev 5703) +++ main/trunk/src/modes/world.cpp 2010-07-22 22:49:56 UTC (rev 5704) @@ -400,8 +400,8 @@ { // Don't update world if a menu is shown or the race is over. if( m_phase == FINISH_PHASE || - m_phase == RESULT_DISPLAY_PHASE || - m_phase == IN_GAME_MENU_PHASE ) return; + m_phase == IN_GAME_MENU_PHASE ) + return; update(dt); if( (!isFinishPhase()) && isRaceOver()) Modified: main/trunk/src/modes/world_status.cpp =================================================================== --- main/trunk/src/modes/world_status.cpp 2010-07-22 22:33:53 UTC (rev 5703) +++ main/trunk/src/modes/world_status.cpp 2010-07-22 22:49:56 UTC (rev 5704) @@ -85,10 +85,11 @@ */ void WorldStatus::enterRaceOverState() { - // Don't + // Don't enter race over if it's already race over if( m_phase == DELAY_FINISH_PHASE || m_phase == RESULT_DISPLAY_PHASE - || m_phase == FINISH_PHASE ) return; + || m_phase == FINISH_PHASE ) + return; m_phase = DELAY_FINISH_PHASE; m_auxiliary_timer = 0.0f; @@ -183,11 +184,17 @@ break; } case RESULT_DISPLAY_PHASE : - if(((RaceOverDialog*)GUIEngine::ModalDialog::getCurrent())->menuIsFinished()) { - m_phase = FINISH_PHASE; + // Wait for the race over GUI/modal dialog to appear + // Previously the in race race over results are shown, + // and getCurrent() returns NULL. + GUIEngine::ModalDialog *m = GUIEngine::ModalDialog::getCurrent(); + if( m && ( (RaceOverDialog*)m)->menuIsFinished() ) + { + m_phase = FINISH_PHASE; + } + break; } - break; case FINISH_PHASE: // Nothing to do here. break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-09-02 13:38:30
|
Revision: 5865 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5865&view=rev Author: hikerstk Date: 2010-09-02 13:38:23 +0000 (Thu, 02 Sep 2010) Log Message: ----------- Moved setting of the position of each kart into setKartPosition, some simplifications to ftl. Modified Paths: -------------- main/trunk/src/modes/follow_the_leader.cpp main/trunk/src/modes/linear_world.cpp main/trunk/src/modes/three_strikes_battle.cpp main/trunk/src/modes/world_with_rank.cpp Modified: main/trunk/src/modes/follow_the_leader.cpp =================================================================== --- main/trunk/src/modes/follow_the_leader.cpp 2010-09-02 13:14:07 UTC (rev 5864) +++ main/trunk/src/modes/follow_the_leader.cpp 2010-09-02 13:38:23 UTC (rev 5865) @@ -76,7 +76,7 @@ { // In case that the kart on position 1 was removed, we have to set // the correct position (which equals the remaining number of karts). - m_karts[kart_number]->setPosition(getCurrentNumKarts()); + setKartPosition(kart_number, getCurrentNumKarts()); removeKart(kart_number); } @@ -148,7 +148,6 @@ int *scores = new int[num_karts]; double *race_time = new double[num_karts]; - World *world = World::getWorld(); // Ignore kart 0, since it was the leader (*order)[0] = -1; @@ -159,9 +158,9 @@ race_time[kart_id] = race_manager->getOverallTime(kart_id); // check this kart is not in front of leader. If it is, give a score of 0 - if( getLapForKart(kart_id) * world->getTrack()->getTrackLength() + if( getLapForKart(kart_id) * getTrack()->getTrackLength() + getDistanceDownTrackForKart(kart_id) - > getLapForKart(0) * world->getTrack()->getTrackLength() + > getLapForKart(0) * getTrack()->getTrackLength() + getDistanceDownTrackForKart(0)) { scores[kart_id] = 0; @@ -189,7 +188,6 @@ for(unsigned int i=1; i<num_karts; i++) { - world->getKart((*order)[i])->setPosition(i); setKartPosition((*order)[i], i); } Modified: main/trunk/src/modes/linear_world.cpp =================================================================== --- main/trunk/src/modes/linear_world.cpp 2010-09-02 13:14:07 UTC (rev 5864) +++ main/trunk/src/modes/linear_world.cpp 2010-09-02 13:38:23 UTC (rev 5865) @@ -689,7 +689,6 @@ rank_changed |= kart->getPosition()!=p; #endif - kart->setPosition(p); setKartPosition(i, p); // Switch on faster music if not already done so, if the // first kart is doing its last lap, and if the estimated Modified: main/trunk/src/modes/three_strikes_battle.cpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.cpp 2010-09-02 13:14:07 UTC (rev 5864) +++ main/trunk/src/modes/three_strikes_battle.cpp 2010-09-02 13:38:23 UTC (rev 5865) @@ -162,7 +162,6 @@ for( unsigned int n = 0; n < NUM_KARTS; ++n ) { - m_karts[ karts_list[n] ]->setPosition( n+1 ); setKartPosition(karts_list[n], n+1); } delete [] karts_list; Modified: main/trunk/src/modes/world_with_rank.cpp =================================================================== --- main/trunk/src/modes/world_with_rank.cpp 2010-09-02 13:14:07 UTC (rev 5864) +++ main/trunk/src/modes/world_with_rank.cpp 2010-09-02 13:38:23 UTC (rev 5865) @@ -31,6 +31,7 @@ unsigned int position) { m_position_index[position-1] = kart_id; + m_karts[kart_id]->setPosition(position); } // setKartPosition // ---------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-11-29 02:34:33
|
Revision: 6753 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6753&view=rev Author: hikerstk Date: 2010-11-29 02:34:25 +0000 (Mon, 29 Nov 2010) Log Message: ----------- Fixed profile world (ProfileWorld::CreateKart was not called anymore since the parameters for that function had changed). Modified Paths: -------------- main/trunk/src/modes/profile_world.cpp main/trunk/src/modes/profile_world.hpp Modified: main/trunk/src/modes/profile_world.cpp =================================================================== --- main/trunk/src/modes/profile_world.cpp 2010-11-29 01:31:44 UTC (rev 6752) +++ main/trunk/src/modes/profile_world.cpp 2010-11-29 02:34:25 UTC (rev 6753) @@ -21,6 +21,7 @@ #include "graphics/camera.hpp" #include "graphics/irr_driver.hpp" +#include "tracks/track.hpp" ProfileWorld::ProfileType ProfileWorld::m_profile_mode=PROFILE_NONE; int ProfileWorld::m_num_laps = 0; @@ -82,14 +83,15 @@ * \param init_pos The start XYZ coordinates. */ Kart *ProfileWorld::createKart(const std::string &kart_ident, int index, - int local_player_id, int global_player_id, - const btTransform &init_pos) + int local_player_id, int global_player_id) { // Ignore the kart identifier specified for this kart, instead load // _only_ the kart specified for the player. This allows to measure // the impact different karts have on performance. const std::string prof_kart_id = race_manager->getKartIdent( race_manager->getNumberOfKarts()-1); + btTransform init_pos = m_track->getStartTransform(index); + Kart *new_kart = new Kart(prof_kart_id, index+1, init_pos); Controller *controller = loadAIController(new_kart); Modified: main/trunk/src/modes/profile_world.hpp =================================================================== --- main/trunk/src/modes/profile_world.hpp 2010-11-29 01:31:44 UTC (rev 6752) +++ main/trunk/src/modes/profile_world.hpp 2010-11-29 02:34:25 UTC (rev 6753) @@ -70,8 +70,7 @@ protected: virtual Kart *createKart(const std::string &kart_ident, int index, - int local_player_id, int global_player_id, - const btTransform &init_pos); + int local_player_id, int global_player_id); public: ProfileWorld(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-11-29 22:02:05
|
Revision: 6782 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6782&view=rev Author: hikerstk Date: 2010-11-29 22:01:59 +0000 (Mon, 29 Nov 2010) Log Message: ----------- Made the 'wrap around' lap counting approach work correctly. Modified Paths: -------------- main/trunk/src/modes/linear_world.cpp main/trunk/src/modes/three_strikes_battle.cpp main/trunk/src/modes/three_strikes_battle.hpp main/trunk/src/modes/world.cpp main/trunk/src/modes/world.hpp Modified: main/trunk/src/modes/linear_world.cpp =================================================================== --- main/trunk/src/modes/linear_world.cpp 2010-11-29 22:01:01 UTC (rev 6781) +++ main/trunk/src/modes/linear_world.cpp 2010-11-29 22:01:59 UTC (rev 6782) @@ -167,11 +167,11 @@ * sectors, which are then used to determine the kart positions. * \param dt Time step size. */ -void LinearWorld::update(float delta) +void LinearWorld::update(float dt) { // run generic parent stuff that applies to all modes. It // especially updates the kart positions. - WorldWithRank::update(delta); + WorldWithRank::update(dt); if (m_last_lap_sfx_playing && m_last_lap_sfx->getStatus() != SFXManager::SFX_PLAYING) { @@ -223,6 +223,7 @@ // (like two karts at same position) can occur. // --------------------------------------------------------------- + WorldWithRank::updateTrack(dt); updateRacePosition(); for (unsigned int i=0; i<kart_amount; i++) Modified: main/trunk/src/modes/three_strikes_battle.cpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.cpp 2010-11-29 22:01:01 UTC (rev 6781) +++ main/trunk/src/modes/three_strikes_battle.cpp 2010-11-29 22:01:59 UTC (rev 6782) @@ -121,6 +121,16 @@ } // getIdent //----------------------------------------------------------------------------- +/** Update the world and the track. + * \param dt Time step size. + */ +void ThreeStrikesBattle::update(float dt) +{ + WorldWithRank::update(dt); + WorldWithRank::updateTrack(dt); +} // update + +//----------------------------------------------------------------------------- void ThreeStrikesBattle::updateKartRanks() { beginSetKartPositions(); Modified: main/trunk/src/modes/three_strikes_battle.hpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.hpp 2010-11-29 22:01:01 UTC (rev 6781) +++ main/trunk/src/modes/three_strikes_battle.hpp 2010-11-29 22:01:59 UTC (rev 6782) @@ -74,7 +74,7 @@ virtual std::string getIdent() const; virtual void kartHit(const int kart_id); - + virtual void update(float dt); void updateKartRanks(); }; // ThreeStrikesBattles Modified: main/trunk/src/modes/world.cpp =================================================================== --- main/trunk/src/modes/world.cpp 2010-11-29 22:01:01 UTC (rev 6781) +++ main/trunk/src/modes/world.cpp 2010-11-29 22:01:59 UTC (rev 6782) @@ -513,25 +513,32 @@ // Update all karts that are not eliminated if(!m_karts[i]->isEliminated()) m_karts[i]->update(dt) ; } - // The order of updates is rather important: if track update would - // be called before kart update, then the check manager (called from - // track update) will be using the old kart position to determine - // e.g. if a kart has crossed a new line. But linear world (from - // which this is called in case of a race) will be using the new - // position of the karts to determine the driveline quad a kart - // is on. So if a kart just arrived at quad 0 (meaning the distance - // along the track goes from close-to-lap-length to close-to-zero), - // the order of karts will be incorrect, since this kart will not - // have started the next lap. While this will only last for one - // frame (since in the next frame the check manager will detect - // the new lap), it causes an incorrect display of icons in the - // icon display for this one frame. - m_track->update(dt); projectile_manager->update(dt); } // update // ---------------------------------------------------------------------------- +/** Only updates the track. The order in which the various parts of STK are + * updated is quite important (i.e. the track can't be updated as part of + * the standard update call): + * the track must be updated after updating the karts (otherwise the + * checklines would be using the previous kart positions to determine + * new laps, but linear world which determines distance along track would + * be using the new kart positions --> the lap counting line will be + * triggered one frame too late, potentially causing strange behaviour of + * the icons. + * Similarly linear world must update the position of all karts after all + * karts have been updated (i.e. World::update() must be called before + * updating the position of the karts). The check manager (which is called + * from Track::update()) needs the updated distance along track, so track + * update has to be called after updating the race position in linear world. + * That's why there is a separate call for trackUpdate here. + */ +void World::updateTrack(float dt) +{ + m_track->update(dt); +} // update Track +// ---------------------------------------------------------------------------- Highscores* World::getHighscores() const { Modified: main/trunk/src/modes/world.hpp =================================================================== --- main/trunk/src/modes/world.hpp 2010-11-29 22:01:01 UTC (rev 6781) +++ main/trunk/src/modes/world.hpp 2010-11-29 22:01:59 UTC (rev 6782) @@ -137,6 +137,7 @@ /** Returns true if the race is over. Must be defined by all modes. */ virtual bool isRaceOver() = 0; virtual void update(float dt); + void updateTrack(float dt); /** Used for AI karts that are still racing when all player kart finished. * Generally it should estimate the arrival time for those karts, but as * a default (useful for battle mode and ftl races) we just use the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2011-01-24 20:33:20
|
Revision: 7529 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7529&view=rev Author: hikerstk Date: 2011-01-24 20:33:14 +0000 (Mon, 24 Jan 2011) Log Message: ----------- Fixed 3164026 - lap not counted in snowmountain: when a kart was rescued it would be set to the last valid sector, and the lap count to the last valid lap count. If the kart triggered a lap count while being off track, the lap count would be decremented, but the lap line is already deactivated, so it would not count again. Since the last valid lap count was stored to solve an old problem (being reset to before the lap line would count the lap again), and this is not necessary anymore, the whole storing of last valid lap was removed. Modified Paths: -------------- main/trunk/src/modes/linear_world.cpp main/trunk/src/modes/linear_world.hpp Modified: main/trunk/src/modes/linear_world.cpp =================================================================== --- main/trunk/src/modes/linear_world.cpp 2011-01-24 20:32:35 UTC (rev 7528) +++ main/trunk/src/modes/linear_world.cpp 2011-01-24 20:33:14 UTC (rev 7529) @@ -60,7 +60,6 @@ KartInfo info; info.m_track_sector = QuadGraph::UNKNOWN_SECTOR; info.m_last_valid_sector = 0; - info.m_last_valid_race_lap = -1; info.m_lap_start_time = 0; m_track->getQuadGraph().findRoadSector(m_karts[n]->getXYZ(), &info.m_track_sector); @@ -202,7 +201,6 @@ if(kart_info.m_on_road) { kart_info.m_last_valid_sector = kart_info.m_track_sector; - kart_info.m_last_valid_race_lap = kart_info.m_race_lap; } else { @@ -241,7 +239,7 @@ } #ifdef DEBUG - // FIXME: Debug output in case that the double position error occurs again. + // Debug output in case that the double position error occurs again. std::vector<int> pos_used; pos_used.resize(kart_amount+1, -99); for(unsigned int i=0; i<kart_amount; i++) @@ -560,10 +558,10 @@ { info.m_track_sector = info.m_last_valid_sector; } - info.m_race_lap = info.m_last_valid_race_lap; - // FIXME - removing 1 here makes it less likely to fall in a rescue loop since the kart - // moves back on each attempt. This is still a weak hack. Also some other code depends - // on 1 being substracted, like 'forceRescue' + + // Removing 1 here makes it less likely to fall in a rescue loop since the + // kart moves back on each attempt. This is still a weak hack. Also some + // other code depends on 1 being substracted, like 'forceRescue' if ( info.m_track_sector > 0 ) info.m_track_sector-- ; info.m_last_valid_sector = info.m_track_sector; if ( info.m_last_valid_sector > 0 ) info.m_last_valid_sector --; Modified: main/trunk/src/modes/linear_world.hpp =================================================================== --- main/trunk/src/modes/linear_world.hpp 2011-01-24 20:32:35 UTC (rev 7528) +++ main/trunk/src/modes/linear_world.hpp 2011-01-24 20:33:14 UTC (rev 7529) @@ -55,7 +55,6 @@ * e.g. UNKNOWN_SECTOR can be negative!*/ int m_last_valid_sector; /* used when rescusing, e.g. for invalid shortcuts */ - int m_last_valid_race_lap; /* when a kart is rescued, we need to give it back the number of lap it had */ Vec3 m_curr_track_coords; /** True if the kart is on top of the road path drawn by the drivelines */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-02-28 16:19:49
|
Revision: 7771 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7771&view=rev Author: auria Date: 2011-02-28 16:19:43 +0000 (Mon, 28 Feb 2011) Log Message: ----------- Only play start and lap fanfares if music is enabled Modified Paths: -------------- main/trunk/src/modes/linear_world.cpp main/trunk/src/modes/world_status.cpp Modified: main/trunk/src/modes/linear_world.cpp =================================================================== --- main/trunk/src/modes/linear_world.cpp 2011-02-28 02:15:01 UTC (rev 7770) +++ main/trunk/src/modes/linear_world.cpp 2011-02-28 16:19:43 UTC (rev 7771) @@ -293,14 +293,22 @@ 3.0f, 40, video::SColor(255, 210, 100, 50), true); if(!m_last_lap_sfx_played && lap_count > 1) { - m_last_lap_sfx->play(); - m_last_lap_sfx_played = true; - m_last_lap_sfx_playing = true; + if (UserConfigParams::m_music) + { + m_last_lap_sfx->play(); + m_last_lap_sfx_played = true; + m_last_lap_sfx_playing = true; - // In case that no music is defined - if(music_manager->getCurrentMusic() && music_manager->getMasterMusicVolume() > 0.2f) + // In case that no music is defined + if(music_manager->getCurrentMusic() && music_manager->getMasterMusicVolume() > 0.2f) + { + music_manager->getCurrentMusic()->setTemporaryVolume(0.2f); + } + } + else { - music_manager->getCurrentMusic()->setTemporaryVolume(0.2f); + m_last_lap_sfx_played = true; + m_last_lap_sfx_playing = false; } } } Modified: main/trunk/src/modes/world_status.cpp =================================================================== --- main/trunk/src/modes/world_status.cpp 2011-02-28 02:15:01 UTC (rev 7770) +++ main/trunk/src/modes/world_status.cpp 2011-02-28 16:19:43 UTC (rev 7771) @@ -126,7 +126,8 @@ case SETUP_PHASE: m_auxiliary_timer = 0.0f; m_phase = TRACK_INTRO_PHASE; - m_track_intro_sound->play(); + if (UserConfigParams::m_music) + m_track_intro_sound->play(); return; case TRACK_INTRO_PHASE: if(m_track_intro_sound->getStatus()==SFXManager::SFX_PLAYING) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-09-10 21:47:30
|
Revision: 9792 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9792&view=rev Author: auria Date: 2011-09-10 21:47:23 +0000 (Sat, 10 Sep 2011) Log Message: ----------- Apply patch by khonkhortisan to lose 4 tires in 3 strikes mode, thanks\! Modified Paths: -------------- main/trunk/src/modes/three_strikes_battle.cpp main/trunk/src/modes/three_strikes_battle.hpp Modified: main/trunk/src/modes/three_strikes_battle.cpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.cpp 2011-09-10 19:33:41 UTC (rev 9791) +++ main/trunk/src/modes/three_strikes_battle.cpp 2011-09-10 21:47:23 UTC (rev 9792) @@ -20,6 +20,8 @@ #include <string> #include <IMeshSceneNode.h> +#include <math.h> + #include "audio/music_manager.hpp" #include "io/file_manager.hpp" #include "states_screens/race_gui_base.hpp" @@ -33,7 +35,7 @@ { WorldStatus::setClockMode(CLOCK_CHRONO); m_use_highscores = false; - m_insert_tire = false; + m_insert_tire = 0; m_tire = irr_driver->getMesh( file_manager->getModelFile("tire.b3d") ); } // ThreeStrikesBattle @@ -145,6 +147,7 @@ if(wheels[2]) wheels[2]->setVisible(false); if(wheels[3]) wheels[3]->setVisible(false); eliminateKart(kart_id, true, false); + m_insert_tire = 4; } const unsigned int NUM_KARTS = getNumKarts(); @@ -182,9 +185,26 @@ // schedule a tire to be thrown away (but can't do it in this callback // because the caller is currently iterating the list of track objects) - m_insert_tire = true; + m_insert_tire++; core::vector3df wheel_pos(m_karts[kart_id]->getKartWidth()*0.5f, 0.0f, 0.0f); m_tire_position = kart_node->getPosition() + wheel_pos; + m_tire_rotation = 0; + if(m_insert_tire > 1) + { + m_tire_position = kart_node->getPosition(); + m_tire_rotation = m_karts[kart_id]->getHeading(); + } + + m_tire_1_offset = m_karts[kart_id]->getKartModel()->getWheelGraphicsPosition(1).toIrrVector(); + m_tire_2_offset = m_karts[kart_id]->getKartModel()->getWheelGraphicsPosition(2).toIrrVector(); + m_tire_3_offset = m_karts[kart_id]->getKartModel()->getWheelGraphicsPosition(3).toIrrVector(); + m_tire_4_offset = m_karts[kart_id]->getKartModel()->getWheelGraphicsPosition(4).toIrrVector(); + m_tire_1_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); + m_tire_2_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); + m_tire_3_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); + m_tire_4_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); + + } // kartHit //----------------------------------------------------------------------------- @@ -204,23 +224,39 @@ WorldWithRank::update(dt); WorldWithRank::updateTrack(dt); + core::vector3df tire_offset; + // insert blown away tire now if was requested - if (m_insert_tire) + while (m_insert_tire > 0) { TrackObjectManager* tom = m_track->getTrackObjectManager(); + if(m_insert_tire == 1) + tire_offset = core::vector3df(0.0f, 0.0f, 0.0f); + if(m_insert_tire == 2) + tire_offset = m_tire_1_offset; + if(m_insert_tire == 3) + tire_offset = m_tire_2_offset; + if(m_insert_tire == 4) + tire_offset = m_tire_3_offset; + if(m_insert_tire == 5) + tire_offset = m_tire_4_offset; + PhysicalObject* obj = tom->insertObject(file_manager->getModelFile("tire.b3d"), PhysicalObject::MP_CYLINDER_Y, 15 /* mass */, 0.5f /* radius */, - core::vector3df(800.0f,0,0) /* rotation */, - m_tire_position, + core::vector3df(800.0f,0,m_tire_rotation / M_PI * 180 + 180) /* rotation */, + m_tire_position + tire_offset, core::vector3df(0.5f, 0.5f, 0.5f) /* scale */); // FIXME: orient the force relative to kart orientation obj->getBody()->applyCentralForce(btVector3(60.0f, 0.0f, 0.0f)); - m_insert_tire = false; + + m_insert_tire--; + if(m_insert_tire == 1) + m_insert_tire = 0; m_tires.push_back(obj); } Modified: main/trunk/src/modes/three_strikes_battle.hpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.hpp 2011-09-10 19:33:41 UTC (rev 9791) +++ main/trunk/src/modes/three_strikes_battle.hpp 2011-09-10 21:47:23 UTC (rev 9792) @@ -47,11 +47,17 @@ irr::scene::IMesh* m_tire; /** for tires that are blown away */ - bool m_insert_tire; + int m_insert_tire; /** for tires that are blown away */ core::vector3df m_tire_position; + core::vector3df m_tire_1_offset; + core::vector3df m_tire_2_offset; + core::vector3df m_tire_3_offset; + core::vector3df m_tire_4_offset; + double m_tire_rotation; + PtrVector<PhysicalObject, REF> m_tires; public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2011-09-13 02:51:40
|
Revision: 9818 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9818&view=rev Author: hikerstk Date: 2011-09-13 02:51:33 +0000 (Tue, 13 Sep 2011) Log Message: ----------- Applied Khonkhortisan's patch for #423: use the actual kart wheel models when losing the final tires. Modified Paths: -------------- main/trunk/src/modes/three_strikes_battle.cpp main/trunk/src/modes/three_strikes_battle.hpp Modified: main/trunk/src/modes/three_strikes_battle.cpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.cpp 2011-09-13 00:03:42 UTC (rev 9817) +++ main/trunk/src/modes/three_strikes_battle.cpp 2011-09-13 02:51:33 UTC (rev 9818) @@ -191,8 +191,8 @@ m_tire_rotation = 0; if(m_insert_tire > 1) { - m_tire_position = kart_node->getPosition(); - m_tire_rotation = m_karts[kart_id]->getHeading(); + m_tire_position = kart_node->getPosition(); + m_tire_rotation = m_karts[kart_id]->getHeading(); } m_tire_1_offset = m_karts[kart_id]->getKartModel()->getWheelGraphicsPosition(1).toIrrVector(); @@ -203,8 +203,14 @@ m_tire_2_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); m_tire_3_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); m_tire_4_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); + m_tire_dir = m_karts[kart_id]->getKartProperties()->getKartDir(); + m_tire_1_radius = m_karts[kart_id]->getKartModel()->getWheelGraphicsRadius(1); + m_tire_2_radius = m_karts[kart_id]->getKartModel()->getWheelGraphicsRadius(2); + m_tire_3_radius = m_karts[kart_id]->getKartModel()->getWheelGraphicsRadius(3); + m_tire_4_radius = m_karts[kart_id]->getKartModel()->getWheelGraphicsRadius(4); + if(m_insert_tire == 5 && m_karts[kart_id]->isWheeless()) + m_insert_tire = 0; - } // kartHit //----------------------------------------------------------------------------- @@ -225,38 +231,69 @@ WorldWithRank::updateTrack(dt); core::vector3df tire_offset; + std::string tire; + float scale = 0.5f; + float radius = 0.5f; + PhysicalObject::bodyTypes tire_model; - // insert blown away tire now if was requested + // insert blown away tire(s) now if was requested while (m_insert_tire > 0) { TrackObjectManager* tom = m_track->getTrackObjectManager(); if(m_insert_tire == 1) + { tire_offset = core::vector3df(0.0f, 0.0f, 0.0f); + tire = file_manager->getModelFile("tire.b3d"); + scale = 0.5f; + radius = 0.5f; + tire_model = PhysicalObject::MP_CYLINDER_Y; + } + if(m_insert_tire != 1) + { + scale = 1.0f; + tire_model = PhysicalObject::MP_CYLINDER_X; + } if(m_insert_tire == 2) + { tire_offset = m_tire_1_offset; + tire = m_tire_dir+"/wheel-rear-left.b3d"; + radius = m_tire_1_radius; + } if(m_insert_tire == 3) + { tire_offset = m_tire_2_offset; + tire = m_tire_dir+"/wheel-front-left.b3d"; + radius = m_tire_2_radius; + } if(m_insert_tire == 4) + { tire_offset = m_tire_3_offset; + tire = m_tire_dir+"/wheel-front-right.b3d"; + radius = m_tire_3_radius; + } if(m_insert_tire == 5) + { tire_offset = m_tire_4_offset; + tire = m_tire_dir+"/wheel-rear-right.b3d"; + radius = m_tire_4_radius; + } PhysicalObject* obj = - tom->insertObject(file_manager->getModelFile("tire.b3d"), - PhysicalObject::MP_CYLINDER_Y, + tom->insertObject(tire, + tire_model, 15 /* mass */, - 0.5f /* radius */, + radius /* radius */, core::vector3df(800.0f,0,m_tire_rotation / M_PI * 180 + 180) /* rotation */, m_tire_position + tire_offset, - core::vector3df(0.5f, 0.5f, 0.5f) /* scale */); + core::vector3df(scale,scale,scale) /* scale */); // FIXME: orient the force relative to kart orientation obj->getBody()->applyCentralForce(btVector3(60.0f, 0.0f, 0.0f)); m_insert_tire--; if(m_insert_tire == 1) - m_insert_tire = 0; + m_insert_tire = 0; m_tires.push_back(obj); } Modified: main/trunk/src/modes/three_strikes_battle.hpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.hpp 2011-09-13 00:03:42 UTC (rev 9817) +++ main/trunk/src/modes/three_strikes_battle.hpp 2011-09-13 02:51:33 UTC (rev 9818) @@ -56,6 +56,11 @@ core::vector3df m_tire_2_offset; core::vector3df m_tire_3_offset; core::vector3df m_tire_4_offset; + std::string m_tire_dir; + float m_tire_1_radius; + float m_tire_2_radius; + float m_tire_3_radius; + float m_tire_4_radius; double m_tire_rotation; PtrVector<PhysicalObject, REF> m_tires; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2011-09-14 23:11:18
|
Revision: 9838 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9838&view=rev Author: hikerstk Date: 2011-09-14 23:11:12 +0000 (Wed, 14 Sep 2011) Log Message: ----------- Uses arrays instead of m_tire_{1,2,3,4}_{radius,offset} scalar variables. Fixed incorrect indices used for tires (used 1-4, should use 0-3). Modified Paths: -------------- main/trunk/src/modes/three_strikes_battle.cpp main/trunk/src/modes/three_strikes_battle.hpp Modified: main/trunk/src/modes/three_strikes_battle.cpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.cpp 2011-09-14 22:48:57 UTC (rev 9837) +++ main/trunk/src/modes/three_strikes_battle.cpp 2011-09-14 23:11:12 UTC (rev 9838) @@ -195,19 +195,16 @@ m_tire_rotation = m_karts[kart_id]->getHeading(); } - m_tire_1_offset = m_karts[kart_id]->getKartModel()->getWheelGraphicsPosition(1).toIrrVector(); - m_tire_2_offset = m_karts[kart_id]->getKartModel()->getWheelGraphicsPosition(2).toIrrVector(); - m_tire_3_offset = m_karts[kart_id]->getKartModel()->getWheelGraphicsPosition(3).toIrrVector(); - m_tire_4_offset = m_karts[kart_id]->getKartModel()->getWheelGraphicsPosition(4).toIrrVector(); - m_tire_1_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); - m_tire_2_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); - m_tire_3_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); - m_tire_4_offset.rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); + for(unsigned int i=0; i<4; i++) + { + m_tire_offsets[i] = m_karts[kart_id]->getKartModel() + ->getWheelGraphicsPosition(i).toIrrVector(); + m_tire_offsets[i].rotateXZBy(-m_tire_rotation / M_PI * 180 + 180); + m_tire_radius[i] = m_karts[kart_id]->getKartModel() + ->getWheelGraphicsRadius(i); + } + m_tire_dir = m_karts[kart_id]->getKartProperties()->getKartDir(); - m_tire_1_radius = m_karts[kart_id]->getKartModel()->getWheelGraphicsRadius(1); - m_tire_2_radius = m_karts[kart_id]->getKartModel()->getWheelGraphicsRadius(2); - m_tire_3_radius = m_karts[kart_id]->getKartModel()->getWheelGraphicsRadius(3); - m_tire_4_radius = m_karts[kart_id]->getKartModel()->getWheelGraphicsRadius(4); if(m_insert_tire == 5 && m_karts[kart_id]->isWheeless()) m_insert_tire = 0; @@ -249,35 +246,17 @@ radius = 0.5f; tire_model = PhysicalObject::MP_CYLINDER_Y; } - if(m_insert_tire != 1) + else { scale = 1.0f; tire_model = PhysicalObject::MP_CYLINDER_X; + radius = m_tire_radius[m_insert_tire-2]; + tire_offset = m_tire_offsets[m_insert_tire-2]; + if (m_insert_tire == 2) tire = m_tire_dir+"/wheel-rear-left.b3d"; + else if(m_insert_tire == 3) tire = m_tire_dir+"/wheel-front-left.b3d"; + else if(m_insert_tire == 4) tire = m_tire_dir+"/wheel-front-right.b3d"; + else if(m_insert_tire == 5) tire = m_tire_dir+"/wheel-rear-right.b3d"; } - if(m_insert_tire == 2) - { - tire_offset = m_tire_1_offset; - tire = m_tire_dir+"/wheel-rear-left.b3d"; - radius = m_tire_1_radius; - } - if(m_insert_tire == 3) - { - tire_offset = m_tire_2_offset; - tire = m_tire_dir+"/wheel-front-left.b3d"; - radius = m_tire_2_radius; - } - if(m_insert_tire == 4) - { - tire_offset = m_tire_3_offset; - tire = m_tire_dir+"/wheel-front-right.b3d"; - radius = m_tire_3_radius; - } - if(m_insert_tire == 5) - { - tire_offset = m_tire_4_offset; - tire = m_tire_dir+"/wheel-rear-right.b3d"; - radius = m_tire_4_radius; - } PhysicalObject* obj = tom->insertObject(tire, Modified: main/trunk/src/modes/three_strikes_battle.hpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.hpp 2011-09-14 22:48:57 UTC (rev 9837) +++ main/trunk/src/modes/three_strikes_battle.hpp 2011-09-14 23:11:12 UTC (rev 9838) @@ -52,15 +52,10 @@ /** for tires that are blown away */ core::vector3df m_tire_position; - core::vector3df m_tire_1_offset; - core::vector3df m_tire_2_offset; - core::vector3df m_tire_3_offset; - core::vector3df m_tire_4_offset; + core::vector3df m_tire_offsets[4]; + + float m_tire_radius[4]; std::string m_tire_dir; - float m_tire_1_radius; - float m_tire_2_radius; - float m_tire_3_radius; - float m_tire_4_radius; double m_tire_rotation; PtrVector<PhysicalObject, REF> m_tires; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ter...@us...> - 2011-12-04 15:11:05
|
Revision: 10335 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10335&view=rev Author: termina1 Date: 2011-12-04 15:10:59 +0000 (Sun, 04 Dec 2011) Log Message: ----------- Fix for ticket 450: use a largest accumulated distance to separate kart respawns in 3sb Modified Paths: -------------- main/trunk/src/modes/three_strikes_battle.cpp main/trunk/src/modes/three_strikes_battle.hpp Modified: main/trunk/src/modes/three_strikes_battle.cpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.cpp 2011-12-04 14:21:10 UTC (rev 10334) +++ main/trunk/src/modes/three_strikes_battle.cpp 2011-12-04 15:10:59 UTC (rev 10335) @@ -20,7 +20,6 @@ #include <string> #include <IMeshSceneNode.h> - #include "audio/music_manager.hpp" #include "io/file_manager.hpp" #include "states_screens/race_gui_base.hpp" @@ -478,29 +477,49 @@ const int start_spots_amount = world->getTrack()->getNumberOfStartPositions(); assert(start_spots_amount > 0); - float smallest_distance_found = -1; - int closest_id_found = -1; + float largest_accumulated_distance_found = -1; + int furthest_id_found = -1; const float kart_x = kart->getXYZ().getX(); const float kart_z = kart->getXYZ().getZ(); - + for(int n=0; n<start_spots_amount; n++) { // no need for the overhead to compute exact distance with sqrt(), // so using the 'manhattan' heuristic which will do fine enough. const btTransform &s = world->getTrack()->getStartTransform(n); const Vec3 &v=s.getOrigin(); - const float dist_n= fabs(kart_x - v.getX()) + - fabs(kart_z - v.getZ()); - if(dist_n < smallest_distance_found || closest_id_found == -1) + float accumulatedDistance = .0f; + bool spawnPointClear = true; + + for(unsigned int k=0; k<getCurrentNumKarts(); k++) { - closest_id_found = n; - smallest_distance_found = dist_n; + const Kart *currentKart = World::getWorld()->getKart(k); + const float currentKart_x = currentKart->getXYZ().getX(); + const float currentKartk_z = currentKart->getXYZ().getZ(); + + if(kart_x!=currentKart_x && kart_z !=currentKartk_z) + { + float absDistance = fabs(currentKart_x - v.getX()) + + fabs(currentKartk_z - v.getZ()); + if(absDistance < CLEAR_SPAWN_RANGE) + { + spawnPointClear = false; + break; + } + accumulatedDistance += absDistance; + } } + + if(largest_accumulated_distance_found < accumulatedDistance && spawnPointClear) + { + furthest_id_found = n; + largest_accumulated_distance_found = accumulatedDistance; + } } - assert(closest_id_found != -1); - const btTransform &s = world->getTrack()->getStartTransform(closest_id_found); + assert(furthest_id_found != -1); + const btTransform &s = world->getTrack()->getStartTransform(furthest_id_found); const Vec3 &xyz = s.getOrigin(); kart->setXYZ(xyz); kart->setRotation(s.getRotation()); Modified: main/trunk/src/modes/three_strikes_battle.hpp =================================================================== --- main/trunk/src/modes/three_strikes_battle.hpp 2011-12-04 14:21:10 UTC (rev 10334) +++ main/trunk/src/modes/three_strikes_battle.hpp 2011-12-04 15:10:59 UTC (rev 10335) @@ -25,6 +25,8 @@ #include "modes/world_with_rank.hpp" #include "states_screens/race_gui_base.hpp" +#define CLEAR_SPAWN_RANGE 5 + class PhysicalObject; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-12-20 20:08:25
|
Revision: 10459 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=10459&view=rev Author: auria Date: 2011-12-20 20:08:19 +0000 (Tue, 20 Dec 2011) Log Message: ----------- Make overworld GUI cleaner by removing timer and rank Modified Paths: -------------- main/trunk/src/modes/overworld.cpp main/trunk/src/modes/overworld.hpp main/trunk/src/modes/world.hpp Modified: main/trunk/src/modes/overworld.cpp =================================================================== --- main/trunk/src/modes/overworld.cpp 2011-12-20 20:07:08 UTC (rev 10458) +++ main/trunk/src/modes/overworld.cpp 2011-12-20 20:08:19 UTC (rev 10459) @@ -31,6 +31,7 @@ void OverWorld::init() { LinearWorld::init(); + m_display_rank = false; } // init //----------------------------------------------------------------------------- Modified: main/trunk/src/modes/overworld.hpp =================================================================== --- main/trunk/src/modes/overworld.hpp 2011-12-20 20:07:08 UTC (rev 10458) +++ main/trunk/src/modes/overworld.hpp 2011-12-20 20:08:19 UTC (rev 10459) @@ -52,9 +52,13 @@ // ------------------------------------------------------------------------ /** The overworld is not a race per se so it's never over */ virtual bool isRaceOver() { return false; } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------ + /** Implement base class method */ virtual const std::string& getIdent() const { return IDENT_OVERWORLD; } + // ------------------------------------------------------------------------ + /** Override base class method */ + virtual bool shouldDrawTimer() const { return false; } }; #endif Modified: main/trunk/src/modes/world.hpp =================================================================== --- main/trunk/src/modes/world.hpp 2011-12-20 20:07:08 UTC (rev 10458) +++ main/trunk/src/modes/world.hpp 2011-12-20 20:08:19 UTC (rev 10459) @@ -252,7 +252,7 @@ // ------------------------------------------------------------------------ /** The code that draws the timer should call this first to know * whether the game mode wants a timer drawn. */ - bool shouldDrawTimer() const { return isRacePhase() && + virtual bool shouldDrawTimer() const { return isRacePhase() && getClockMode() != CLOCK_NONE; } // ------------------------------------------------------------------------ /** \return whether this world can generate/have highscores */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2012-04-23 23:41:57
|
Revision: 11145 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11145&view=rev Author: auria Date: 2012-04-23 23:41:51 +0000 (Mon, 23 Apr 2012) Log Message: ----------- Fixed returning reference to temporary Modified Paths: -------------- main/trunk/src/modes/overworld.cpp main/trunk/src/modes/overworld.hpp Modified: main/trunk/src/modes/overworld.cpp =================================================================== --- main/trunk/src/modes/overworld.cpp 2012-04-23 20:35:27 UTC (rev 11144) +++ main/trunk/src/modes/overworld.cpp 2012-04-23 23:41:51 UTC (rev 11145) @@ -193,7 +193,7 @@ //----------------------------------------------------------------------------- -const btTransform& OverWorld::getClosestStartPoint(float currentKart_x, float currentKart_z) +btTransform OverWorld::getClosestStartPoint(float currentKart_x, float currentKart_z) { // find closest point to drop kart on World *world = World::getWorld(); Modified: main/trunk/src/modes/overworld.hpp =================================================================== --- main/trunk/src/modes/overworld.hpp 2012-04-23 20:35:27 UTC (rev 11144) +++ main/trunk/src/modes/overworld.hpp 2012-04-23 23:41:51 UTC (rev 11145) @@ -42,7 +42,7 @@ void moveKartAfterRescue(AbstractKart* kart, float angle); - const btTransform& getClosestStartPoint(float currentKart_x, float currentKart_z); + btTransform getClosestStartPoint(float currentKart_x, float currentKart_z); public: OverWorld(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mbj...@us...> - 2012-05-07 00:51:18
|
Revision: 11191 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11191&view=rev Author: mbjornstk Date: 2012-05-07 00:51:12 +0000 (Mon, 07 May 2012) Log Message: ----------- Set property to make sure EOLs are not mangled in future. Property Changed: ---------------- main/trunk/src/modes/demo_world.cpp main/trunk/src/modes/demo_world.hpp Property changes on: main/trunk/src/modes/demo_world.cpp ___________________________________________________________________ Added: svn:eol-style + native Property changes on: main/trunk/src/modes/demo_world.hpp ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2012-05-09 23:05:31
|
Revision: 11218 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11218&view=rev Author: hikerstk Date: 2012-05-09 23:05:25 +0000 (Wed, 09 May 2012) Log Message: ----------- Removed unnecessary settings of a demo mode in ProfileWorld. Modified Paths: -------------- main/trunk/src/modes/profile_world.cpp main/trunk/src/modes/profile_world.hpp Modified: main/trunk/src/modes/profile_world.cpp =================================================================== --- main/trunk/src/modes/profile_world.cpp 2012-05-09 22:57:51 UTC (rev 11217) +++ main/trunk/src/modes/profile_world.cpp 2012-05-09 23:05:25 UTC (rev 11218) @@ -79,17 +79,6 @@ } // setProfileModeLaps //----------------------------------------------------------------------------- -/** Activates Demo mode. In this mode all karts are controlled by an AI, but - * at the end no stats are printed, and the game isn't exited. - * \param laps The number of laps. - */ -void ProfileWorld::setProfileModeDemo(int laps) -{ - m_profile_mode = PROFILE_DEMO; - m_num_laps = laps; -} // setProfileModeDemo - -//----------------------------------------------------------------------------- /** Creates a kart, having a certain position, starting location, and local * and global player id (if applicable). * \param kart_ident Identifier of the kart to create. @@ -132,8 +121,7 @@ if(m_profile_mode==PROFILE_TIME) return getTime()>m_time; - if(m_profile_mode == PROFILE_LAPS || - m_profile_mode == PROFILE_DEMO) + if(m_profile_mode == PROFILE_LAPS ) { // Now it must be laps based profiling: return race_manager->getFinishedKarts()==getNumKarts(); @@ -149,7 +137,6 @@ void ProfileWorld::update(float dt) { StandardRace::update(dt); - if(m_profile_mode==PROFILE_DEMO) return; m_frame_count++; video::IVideoDriver *driver = irr_driver->getVideoDriver(); @@ -196,9 +183,6 @@ m_karts[i]->finishedRace(estimateFinishTimeForKart(m_karts[i])); } - // Do nothing more in demo mode - esp. don't abort ;) - if(m_profile_mode == PROFILE_DEMO) return; - // Print framerate statistics float runtime = (irr_driver->getRealTime()-m_start_time)*0.001f; printf("Number of frames: %d time %f, Average FPS: %f\n", Modified: main/trunk/src/modes/profile_world.hpp =================================================================== --- main/trunk/src/modes/profile_world.hpp 2012-05-09 22:57:51 UTC (rev 11217) +++ main/trunk/src/modes/profile_world.hpp 2012-05-09 23:05:25 UTC (rev 11218) @@ -31,8 +31,7 @@ { private: /** Profiling modes. */ - enum ProfileType {PROFILE_NONE, PROFILE_TIME, PROFILE_LAPS, - PROFILE_DEMO}; + enum ProfileType {PROFILE_NONE, PROFILE_TIME, PROFILE_LAPS}; /** If profiling is done, and if so, which mode. */ static ProfileType m_profile_mode; @@ -88,7 +87,6 @@ static void setProfileModeTime(float time); static void setProfileModeLaps(int laps); - static void setProfileModeDemo(int laps); // ------------------------------------------------------------------------ /** Returns true if profile mode was selected. */ static bool isProfileMode() {return m_profile_mode!=PROFILE_NONE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2012-05-10 12:57:57
|
Revision: 11225 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11225&view=rev Author: hikerstk Date: 2012-05-10 12:57:45 +0000 (Thu, 10 May 2012) Log Message: ----------- Made m_phase and m_auxiliary_timer private, and added setPhase. Removed usage of auxiliary timer in overworld (instead set phase to race_phase) - as a result there is no mpre 'Go!' being displayed (which I think is actually better for the overworld). Modified Paths: -------------- main/trunk/src/modes/overworld.cpp main/trunk/src/modes/profile_world.cpp main/trunk/src/modes/standard_race.cpp main/trunk/src/modes/world.cpp main/trunk/src/modes/world_status.hpp Modified: main/trunk/src/modes/overworld.cpp =================================================================== --- main/trunk/src/modes/overworld.cpp 2012-05-10 01:20:50 UTC (rev 11224) +++ main/trunk/src/modes/overworld.cpp 2012-05-10 12:57:45 UTC (rev 11225) @@ -112,12 +112,11 @@ // Skip annoying waiting without a purpose // Make sure to do all things that would normally happen in the // update() method of the base classes. - if (m_phase < GO_PHASE) + if (getPhase()< GO_PHASE) { - m_phase = GO_PHASE; - // Go message disappears at 3, music starts at 2.5 - m_auxiliary_timer = 2.0f; - // Normally done in WorldStatus::update(), SET_PHASE + setPhase(RACE_PHASE); + // Normally done in WorldStatus::update(), during phase SET_PHASE, + // so we have to start music 'manually', since we skip all phases. World::getWorld()->getTrack()->startMusic(); } LinearWorld::update(dt); Modified: main/trunk/src/modes/profile_world.cpp =================================================================== --- main/trunk/src/modes/profile_world.cpp 2012-05-10 01:20:50 UTC (rev 11224) +++ main/trunk/src/modes/profile_world.cpp 2012-05-10 12:57:45 UTC (rev 11225) @@ -43,7 +43,7 @@ // based profiling) - in case of time based profiling, the number of // laps is set to 99999. race_manager->setNumLaps(m_num_laps); - m_phase = RACE_PHASE; + setPhase(RACE_PHASE); m_frame_count = 0; m_start_time = irr_driver->getRealTime(); m_num_triangles = 0; Modified: main/trunk/src/modes/standard_race.cpp =================================================================== --- main/trunk/src/modes/standard_race.cpp 2012-05-10 01:20:50 UTC (rev 11224) +++ main/trunk/src/modes/standard_race.cpp 2012-05-10 12:57:45 UTC (rev 11225) @@ -130,6 +130,6 @@ ); } // Finish the active players endSetKartPositions(); - m_phase = RESULT_DISPLAY_PHASE; + setPhase(RESULT_DISPLAY_PHASE); terminateRace(); } // endRaceEarly Modified: main/trunk/src/modes/world.cpp =================================================================== --- main/trunk/src/modes/world.cpp 2012-05-10 01:20:50 UTC (rev 11224) +++ main/trunk/src/modes/world.cpp 2012-05-10 12:57:45 UTC (rev 11225) @@ -607,8 +607,8 @@ } // Don't update world if a menu is shown or the race is over. - if( m_phase == FINISH_PHASE || - m_phase == IN_GAME_MENU_PHASE ) + if( getPhase() == FINISH_PHASE || + getPhase() == IN_GAME_MENU_PHASE ) return; update(dt); Modified: main/trunk/src/modes/world_status.hpp =================================================================== --- main/trunk/src/modes/world_status.hpp 2012-05-10 01:20:50 UTC (rev 11224) +++ main/trunk/src/modes/world_status.hpp 2012-05-10 12:57:45 UTC (rev 11225) @@ -91,7 +91,8 @@ */ float m_time; ClockType m_clock_mode; - + +private: Phase m_phase; /** @@ -110,43 +111,53 @@ virtual ~WorldStatus(); void reset(); + void update(const float dt); + void setTime(const float time); + virtual void pause(Phase phase); + virtual void unpause(); + virtual void enterRaceOverState(); + virtual void terminateRace(); + // ------------------------------------------------------------------------ // Note: GO_PHASE is both: start phase and race phase bool isStartPhase() const { return m_phase<GO_PHASE; } + // ------------------------------------------------------------------------ bool isRacePhase() const { return m_phase>=GO_PHASE && m_phase<FINISH_PHASE; } + // ------------------------------------------------------------------------ /** While the race menu is being displayed, m_phase is limbo, and * m_previous_phase is finish. So we have to test this case, too. */ bool isFinishPhase() const { return m_phase==FINISH_PHASE || (m_phase==IN_GAME_MENU_PHASE && m_previous_phase==FINISH_PHASE);} + // ------------------------------------------------------------------------ + /** Returns the current race phase. */ const Phase getPhase() const { return m_phase; } + // ------------------------------------------------------------------------ + /** Sets the current race phase. Canbe used to e.g. avoid the count down + * etc. */ + void setPhase(Phase phase) { m_phase = phase; } + + // ------------------------------------------------------------------------ /** Call to specify what kind of clock you want. The second argument * can be used to specify the initial time value (especially useful * for countdowns). */ void setClockMode(const ClockType mode, const float initial_time=0.0f); + // ------------------------------------------------------------------------ /** Returns the current clock mode. */ int getClockMode() const { return m_clock_mode; } + // ------------------------------------------------------------------------ /** Returns the current race time. */ float getTime() const { return m_time; } - - /** Call each frame, with the elapsed time as argument. */ - void update(const float dt); - void setTime(const float time); - - virtual void pause(Phase phase); - virtual void unpause(); - virtual void enterRaceOverState(); - virtual void terminateRace(); - // ------------------------------------------------------------------------ /** Will be called to notify your derived class that the clock, * which is in COUNTDOWN mode, has reached zero. */ virtual void countdownReachedZero() {}; + // ------------------------------------------------------------------------ /** Called when the race actually starts. */ virtual void onGo() {}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2012-05-14 00:20:07
|
Revision: 11232 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11232&view=rev Author: auria Date: 2012-05-14 00:20:00 +0000 (Mon, 14 May 2012) Log Message: ----------- Use the new OVERRIDE macro in a couple more places Modified Paths: -------------- main/trunk/src/modes/demo_world.hpp main/trunk/src/modes/follow_the_leader.hpp main/trunk/src/modes/linear_world.hpp main/trunk/src/modes/overworld.hpp main/trunk/src/modes/standard_race.hpp main/trunk/src/modes/world.hpp main/trunk/src/modes/world_status.hpp Modified: main/trunk/src/modes/demo_world.hpp =================================================================== --- main/trunk/src/modes/demo_world.hpp 2012-05-14 00:04:26 UTC (rev 11231) +++ main/trunk/src/modes/demo_world.hpp 2012-05-14 00:20:00 UTC (rev 11232) @@ -54,12 +54,13 @@ DemoWorld(); virtual ~DemoWorld(); /** Returns identifier for this world. */ - virtual std::string getInternalCode() const {return "DEMO"; } - virtual void update(float dt) {ProfileWorld::update(dt);}; - virtual bool isRaceOver(); - virtual void enterRaceOverState(); - static bool updateIdleTimeAndStartDemo(float dt) ; + virtual std::string getInternalCode() const OVERRIDE { return "DEMO"; } + virtual void update(float dt) OVERRIDE {ProfileWorld::update(dt);}; + virtual bool isRaceOver() OVERRIDE; + virtual void enterRaceOverState() OVERRIDE; // ------------------------------------------------------------------------ + static bool updateIdleTimeAndStartDemo(float dt); + // ------------------------------------------------------------------------ /** Sets the number of laps to use in demo mode. m_num_laps is from * ProfileWorld. */ static void setNumLaps(unsigned int num_laps) { m_num_laps = num_laps; } Modified: main/trunk/src/modes/follow_the_leader.hpp =================================================================== --- main/trunk/src/modes/follow_the_leader.hpp 2012-05-14 00:04:26 UTC (rev 11231) +++ main/trunk/src/modes/follow_the_leader.hpp 2012-05-14 00:20:00 UTC (rev 11232) @@ -35,17 +35,17 @@ virtual ~FollowTheLeaderRace(); // clock events - virtual void countdownReachedZero(); + virtual void countdownReachedZero() OVERRIDE; // overriding World methods - virtual void restartRace(); - virtual const std::string& getIdent() const; - float getClockStartTime(); - virtual bool useFastMusicNearEnd() const { return false; } - virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo(); + virtual void restartRace() OVERRIDE; + virtual const std::string& getIdent() const OVERRIDE; + virtual float getClockStartTime(); + virtual bool useFastMusicNearEnd() const OVERRIDE { return false; } + virtual RaceGUIBase::KartIconDisplayInfo* getKartsDisplayInfo() OVERRIDE; - virtual bool isRaceOver(); - virtual bool raceHasLaps(){ return false; } + virtual bool isRaceOver() OVERRIDE; + virtual bool raceHasLaps() OVERRIDE { return false; } }; // FollowTheLeader Modified: main/trunk/src/modes/linear_world.hpp =================================================================== --- main/trunk/src/modes/linear_world.hpp 2012-05-14 00:04:26 UTC (rev 11231) +++ main/trunk/src/modes/linear_world.hpp 2012-05-14 00:20:00 UTC (rev 11232) @@ -105,17 +105,17 @@ void rescueKartAfterShortcut(AbstractKart* kart, KartInfo& kart_info); virtual void checkForWrongDirection(unsigned int i); void updateRacePosition(); - virtual float estimateFinishTimeForKart(AbstractKart* kart); + virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE; public: LinearWorld(); /** call just after instanciating. can't be moved to the contructor as child classes must be instanciated, otherwise polymorphism will fail and the results will be incorrect */ - virtual void init(); + virtual void init() OVERRIDE; virtual ~LinearWorld(); - virtual void update(float delta); + virtual void update(float delta) OVERRIDE; int getSectorForKart(const AbstractKart *kart) const; float getDistanceDownTrackForKart(const int kart_id) const; float getDistanceToCenterForKart(const int kart_id) const; @@ -124,20 +124,20 @@ float getTimeAtLapForKart(const int kart_id) const; virtual RaceGUIBase::KartIconDisplayInfo* - getKartsDisplayInfo(); - virtual void moveKartAfterRescue(AbstractKart* kart); - virtual void restartRace(); - virtual void newLap(unsigned int kart_index); + getKartsDisplayInfo() OVERRIDE; + virtual void moveKartAfterRescue(AbstractKart* kart) OVERRIDE; + virtual void restartRace() OVERRIDE; + virtual void newLap(unsigned int kart_index) OVERRIDE; // ------------------------------------------------------------------------ /** Returns if this race mode has laps. */ - virtual bool raceHasLaps(){ return true; } + virtual bool raceHasLaps() OVERRIDE { return true; } // ------------------------------------------------------------------------ /** Returns if this race mode has bonus items. */ - virtual bool haveBonusBoxes(){ return true; } + virtual bool haveBonusBoxes() OVERRIDE { return true; } // ------------------------------------------------------------------------ /** Override settings from base class */ - virtual bool useChecklineRequirements() const { return true; } + virtual bool useChecklineRequirements() const OVERRIDE { return true; } // ------------------------------------------------------------------------ /** Returns true if the kart is on a valid driveline quad. * \param kart_index Index of the kart. */ Modified: main/trunk/src/modes/overworld.hpp =================================================================== --- main/trunk/src/modes/overworld.hpp 2012-05-14 00:04:26 UTC (rev 11231) +++ main/trunk/src/modes/overworld.hpp 2012-05-14 00:20:00 UTC (rev 11232) @@ -50,40 +50,40 @@ /** call just after instanciating. can't be moved to the contructor as child classes must be instanciated, otherwise polymorphism will fail and the results will be incorrect */ - virtual void init(); + virtual void init() OVERRIDE; virtual ~OverWorld(); static void enterOverWorld(); - virtual void update(float delta); + virtual void update(float delta) OVERRIDE; // ------------------------------------------------------------------------ /** Returns if this race mode has laps. */ - virtual bool raceHasLaps(){ return false; } + virtual bool raceHasLaps() OVERRIDE { return false; } // ------------------------------------------------------------------------ - virtual void checkForWrongDirection(unsigned int i); + virtual void checkForWrongDirection(unsigned int i) OVERRIDE; // ------------------------------------------------------------------------ /** The overworld is not a race per se so it's never over */ - virtual bool isRaceOver() { return false; } + virtual bool isRaceOver() OVERRIDE { return false; } // ------------------------------------------------------------------------ /** Implement base class method */ virtual const std::string& - getIdent() const { return IDENT_OVERWORLD; } + getIdent() const OVERRIDE { return IDENT_OVERWORLD; } // ------------------------------------------------------------------------ /** Override base class method */ - virtual bool shouldDrawTimer() const { return false; } + virtual bool shouldDrawTimer() const OVERRIDE { return false; } // ------------------------------------------------------------------------ /** Override base class method */ - virtual void onFirePressed(Controller* who); + virtual void onFirePressed(Controller* who) OVERRIDE; // ------------------------------------------------------------------------ /** Override settings from base class */ - virtual bool useChecklineRequirements() const { return false; } + virtual bool useChecklineRequirements() const OVERRIDE { return false; } // ------------------------------------------------------------------------ void scheduleReturnToGarage() { m_return_to_garage = true; } // ------------------------------------------------------------------------ - virtual void moveKartAfterRescue(AbstractKart* kart); + virtual void moveKartAfterRescue(AbstractKart* kart) OVERRIDE; // ------------------------------------------------------------------------ - virtual void onMouseClick(int x, int y); + virtual void onMouseClick(int x, int y) OVERRIDE; }; #endif Modified: main/trunk/src/modes/standard_race.hpp =================================================================== --- main/trunk/src/modes/standard_race.hpp 2012-05-14 00:04:26 UTC (rev 11231) +++ main/trunk/src/modes/standard_race.hpp 2012-05-14 00:20:00 UTC (rev 11232) @@ -36,11 +36,11 @@ virtual ~StandardRace() {}; // overriding World methods - virtual void getDefaultCollectibles(int *collectible_type, int *amount); - virtual bool haveBonusBoxes(); - virtual const std::string& getIdent() const; + virtual void getDefaultCollectibles(int *collectible_type, int *amount) OVERRIDE; + virtual bool haveBonusBoxes() OVERRIDE; + virtual const std::string& getIdent() const OVERRIDE; - virtual void endRaceEarly(); + virtual void endRaceEarly() OVERRIDE; }; #endif Modified: main/trunk/src/modes/world.hpp =================================================================== --- main/trunk/src/modes/world.hpp 2012-05-14 00:04:26 UTC (rev 11231) +++ main/trunk/src/modes/world.hpp 2012-05-14 00:20:00 UTC (rev 11232) @@ -155,7 +155,7 @@ * around at the end of a race, and other criteria (number of lives, * race position) will be used to determine the final order. */ - virtual float estimateFinishTimeForKart(AbstractKart* kart) + virtual float estimateFinishTimeForKart(AbstractKart* kart) {return getTime(); } @@ -203,17 +203,17 @@ // Virtual functions // ================= virtual void init(); - virtual void terminateRace(); - virtual void restartRace(); - virtual void pause(Phase phase); - virtual void unpause(); + virtual void terminateRace() OVERRIDE; + virtual void restartRace(); + virtual void pause(Phase phase) OVERRIDE; + virtual void unpause() OVERRIDE; virtual void getDefaultCollectibles(int *collectible_type, int *amount ); virtual void endRaceEarly() { return; } // ------------------------------------------------------------------------ /** Called to determine whether this race mode uses bonus boxes. */ - virtual bool haveBonusBoxes(){ return true; } + virtual bool haveBonusBoxes() { return true; } // ------------------------------------------------------------------------ /** Returns if this mode should use fast music (if available). */ virtual bool useFastMusicNearEnd() const { return true; } @@ -270,8 +270,8 @@ // ------------------------------------------------------------------------ /** The code that draws the timer should call this first to know * whether the game mode wants a timer drawn. */ - virtual bool shouldDrawTimer() const { return isRacePhase() && - getClockMode() != CLOCK_NONE; } + virtual bool shouldDrawTimer() const + { return isRacePhase() && getClockMode() != CLOCK_NONE; } // ------------------------------------------------------------------------ /** \return whether this world can generate/have highscores */ bool useHighScores() const { return m_use_highscores; } Modified: main/trunk/src/modes/world_status.hpp =================================================================== --- main/trunk/src/modes/world_status.hpp 2012-05-14 00:04:26 UTC (rev 11231) +++ main/trunk/src/modes/world_status.hpp 2012-05-14 00:20:00 UTC (rev 11232) @@ -18,6 +18,8 @@ #ifndef HEADER_WORLD_STATUS_HPP #define HEADER_WORLD_STATUS_HPP +#include "utils/cpp2011.h" + class SFXBase; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2012-07-15 04:09:07
|
Revision: 11392 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11392&view=rev Author: wardje Date: 2012-07-15 04:09:00 +0000 (Sun, 15 Jul 2012) Log Message: ----------- Fix #664 After DemoWorld finishes/gets aborted, the static variable in ProfileWorld would still be set to profiling, indicating that profiling still had to be done. This caused troubles with trying to race after the demo had run at least once. Any started race would be seen as profiling. Simply deactivating profiling when ProfileWorld gets destroyed does the trick. Modified Paths: -------------- main/trunk/src/modes/profile_world.cpp main/trunk/src/modes/profile_world.hpp Modified: main/trunk/src/modes/profile_world.cpp =================================================================== --- main/trunk/src/modes/profile_world.cpp 2012-07-14 20:01:13 UTC (rev 11391) +++ main/trunk/src/modes/profile_world.cpp 2012-07-15 04:09:00 UTC (rev 11392) @@ -56,6 +56,16 @@ } // ProfileWorld //----------------------------------------------------------------------------- +/** Sets profile mode off again. + * Needed because demo mode's closing allows the player to continue playing + * STK. If we didn't set it off, profile mode would stay activated. + */ +ProfileWorld::~ProfileWorld() +{ + m_profile_mode = PROFILE_NONE; +} + +//----------------------------------------------------------------------------- /** Enables profiling for a certain amount of time. It also sets the * number of laps to a high number (so that the lap count will not finish * a race before the time is over). Modified: main/trunk/src/modes/profile_world.hpp =================================================================== --- main/trunk/src/modes/profile_world.hpp 2012-07-14 20:01:13 UTC (rev 11391) +++ main/trunk/src/modes/profile_world.hpp 2012-07-15 04:09:00 UTC (rev 11392) @@ -78,7 +78,7 @@ public: ProfileWorld(); - virtual ~ProfileWorld() {}; + virtual ~ProfileWorld(); /** Returns identifier for this world. */ virtual std::string getInternalCode() const {return "PROFILE"; } virtual void update(float dt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2012-08-13 00:25:36
|
Revision: 11503 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11503&view=rev Author: auria Date: 2012-08-13 00:25:30 +0000 (Mon, 13 Aug 2012) Log Message: ----------- Pressing escape cancels both parts of the cutscene Modified Paths: -------------- main/trunk/src/modes/cutscene_world.cpp main/trunk/src/modes/cutscene_world.hpp main/trunk/src/modes/world.cpp Modified: main/trunk/src/modes/cutscene_world.cpp =================================================================== --- main/trunk/src/modes/cutscene_world.cpp 2012-08-13 00:23:18 UTC (rev 11502) +++ main/trunk/src/modes/cutscene_world.cpp 2012-08-13 00:25:30 UTC (rev 11503) @@ -43,6 +43,7 @@ */ CutsceneWorld::CutsceneWorld() : World() { + m_aborted = false; WorldStatus::setClockMode(CLOCK_NONE); m_use_highscores = false; m_play_racestart_sounds = false; @@ -264,7 +265,7 @@ } } - if (partId == -1 || partId == (int)m_parts.size() - 1) + if (m_aborted || partId == -1 || partId == (int)m_parts.size() - 1) { race_manager->exitRace(); StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); Modified: main/trunk/src/modes/cutscene_world.hpp =================================================================== --- main/trunk/src/modes/cutscene_world.hpp 2012-08-13 00:23:18 UTC (rev 11502) +++ main/trunk/src/modes/cutscene_world.hpp 2012-08-13 00:25:30 UTC (rev 11503) @@ -42,10 +42,12 @@ std::map<float, std::vector<TrackObject*> > m_sounds_to_stop; float m_duration; + bool m_aborted; void abortCutscene() { if (m_time < m_duration - 2.0f) m_duration = m_time + 2.0f; + m_aborted = true; } std::vector<std::string> m_parts; Modified: main/trunk/src/modes/world.cpp =================================================================== --- main/trunk/src/modes/world.cpp 2012-08-13 00:23:18 UTC (rev 11502) +++ main/trunk/src/modes/world.cpp 2012-08-13 00:25:30 UTC (rev 11503) @@ -246,8 +246,8 @@ // For now: instead of random switching, use each // robot in turns: switch(m_random.get(NUM_ROBOTS)) #undef USE_PRESENT_AI -#undef USE_SKIDDING_AI -#define USE_ALL_AIS +#define USE_SKIDDING_AI +#undef USE_ALL_AIS #ifdef USE_PRESENT_AI int turn = 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2012-10-01 00:11:53
|
Revision: 11652 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11652&view=rev Author: auria Date: 2012-10-01 00:11:47 +0000 (Mon, 01 Oct 2012) Log Message: ----------- Fix bug Modified Paths: -------------- main/trunk/src/modes/cutscene_world.cpp main/trunk/src/modes/cutscene_world.hpp Modified: main/trunk/src/modes/cutscene_world.cpp =================================================================== --- main/trunk/src/modes/cutscene_world.cpp 2012-09-30 23:32:00 UTC (rev 11651) +++ main/trunk/src/modes/cutscene_world.cpp 2012-10-01 00:11:47 UTC (rev 11652) @@ -177,7 +177,7 @@ /** Update the world and the track. * \param dt Time step size. */ -void CutsceneWorld::update(double dt) +void CutsceneWorld::update(float dt) { /* { Modified: main/trunk/src/modes/cutscene_world.hpp =================================================================== --- main/trunk/src/modes/cutscene_world.hpp 2012-09-30 23:32:00 UTC (rev 11651) +++ main/trunk/src/modes/cutscene_world.hpp 2012-10-01 00:11:47 UTC (rev 11652) @@ -85,7 +85,7 @@ virtual const std::string& getIdent() const OVERRIDE; virtual void kartHit(const int kart_id) OVERRIDE; - virtual void update(double dt) OVERRIDE; + virtual void update(float dt) OVERRIDE; virtual void createRaceGUI() OVERRIDE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2012-10-14 22:23:14
|
Revision: 11683 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=11683&view=rev Author: hikerstk Date: 2012-10-14 22:23:07 +0000 (Sun, 14 Oct 2012) Log Message: ----------- Added files missing in previous commit. Modified Paths: -------------- main/trunk/src/modes/linear_world.cpp main/trunk/src/modes/linear_world.hpp main/trunk/src/modes/world_with_rank.cpp Modified: main/trunk/src/modes/linear_world.cpp =================================================================== --- main/trunk/src/modes/linear_world.cpp 2012-10-14 20:59:51 UTC (rev 11682) +++ main/trunk/src/modes/linear_world.cpp 2012-10-14 22:23:07 UTC (rev 11683) @@ -160,6 +160,13 @@ if(kart->getKartAnimation()) continue; kart_info.getSector()->update(kart->getXYZ()); + if(kart_info.m_race_lap>=0) + kart_info.m_overall_distance = kart_info.m_race_lap + * m_track->getTrackLength() + + getDistanceDownTrackForKart(kart->getWorldKartId()); + else + kart_info.m_overall_distance = 0; + } // for n // Update all positions. This must be done after _all_ karts have @@ -239,7 +246,10 @@ { assert(kart->getWorldKartId()==kart_index); kart_info.m_time_at_last_lap=getTime(); - kart_info.m_race_lap++ ; + kart_info.m_race_lap++; + m_kart_info[kart_index].m_overall_distance = + m_kart_info[kart_index].m_race_lap * m_track->getTrackLength() + + getDistanceDownTrackForKart(kart->getWorldKartId()); } // Last lap message (kart_index's assert in previous block already) if (raceHasLaps() && kart_info.m_race_lap+1 == lap_count) @@ -511,21 +521,17 @@ float LinearWorld::estimateFinishTimeForKart(AbstractKart* kart) { const KartInfo &kart_info = m_kart_info[kart->getWorldKartId()]; - float distance_covered = kart_info.m_race_lap * m_track->getTrackLength() - + getDistanceDownTrackForKart(kart->getWorldKartId()); - // In case that a kart is rescued behind start line, or ... - if(distance_covered<0) distance_covered =1.0f; float full_distance = race_manager->getNumLaps() * m_track->getTrackLength(); if(full_distance == 0) full_distance = 1; // For 0 lap races avoid warning below #ifdef DEBUG - if(full_distance < distance_covered) + if(full_distance < kart_info.m_overall_distance) { printf("WARNING: full distance < distance covered for kart '%s':\n", kart->getIdent().c_str()); - printf("%f < %f\n", full_distance, distance_covered); + printf("%f < %f\n", full_distance, kart_info.m_overall_distance); } #endif // Avoid potential problems (floating point issues, coding bug?) if a @@ -533,13 +539,14 @@ // Return the current time plus initial position to spread arrival // times a bit. This code should generally not be used at all, it's // just here to avoid invalid finishing times. - if(full_distance < distance_covered) + if(full_distance < kart_info.m_overall_distance) return getTime() + kart->getInitialPosition(); // Finish time is the time needed for the whole race with // the computed average speed computed. - const float average_speed = distance_covered/getTime(); - return getTime() + (full_distance - distance_covered) / average_speed; + const float average_speed = kart_info.m_overall_distance/getTime(); + return getTime() + (full_distance - kart_info.m_overall_distance) + / average_speed; } // estimateFinishTimeForKart @@ -629,53 +636,28 @@ int p = 1 ; - const int my_id = kart->getWorldKartId(); - const int my_laps = getLapForKart(my_id); - const float my_progression = getDistanceDownTrackForKart(my_id); + const int my_id = kart->getWorldKartId(); + const float my_distance = m_kart_info[my_id].m_overall_distance; + // Count karts ahead of the current kart, i.e. kart that are - // already finished, have done more laps, or the same number of laps, - // but a greater distance. + // already finished or have covered a larger overall distance. for (unsigned int j = 0 ; j < kart_amount ; j++) { - // don't compare a kart with itself - if(j == kart->getWorldKartId()) continue; - // dismiss eliminated karts - if(m_karts[j]->isEliminated()) continue; + // don't compare a kart with itself and ignore eliminated karts + if(j == my_id || m_karts[j]->isEliminated()) + continue; - if(!kart->hasFinishedRace() && m_karts[j]->hasFinishedRace()) + // If the other kart has: + // - finished the race, or is ahead, or has the same distance + // but started earlier, it is ahead --> increase position + if(!kart->hasFinishedRace() && m_karts[j]->hasFinishedRace() || + m_kart_info[j].m_overall_distance > my_distance || + (m_kart_info[j].m_overall_distance == my_distance && + m_karts[j]->getInitialPosition()<kart->getInitialPosition() ) ) { p++; - continue; } - /* has done more or less lapses */ - assert(j==m_karts[j]->getWorldKartId()); - int other_laps = getLapForKart(j); - if (other_laps != my_laps) - { - if(other_laps > my_laps) - { - p++; // Other kart has more lapses - } - continue; - } - // Now both karts have the same number of lapses. Test progression. - // A kart is ahead if it's driven further, or driven the same - // distance, but started further to the back. - float other_progression = getDistanceDownTrackForKart(j); - if(other_progression > my_progression || - (other_progression == my_progression && - m_karts[j]->getInitialPosition() > kart->getInitialPosition()) ) - { - p++; -#if _DEBUG_PRINTS_LIKE_MAD_ - std::cout << " " << p << " : " << m_karts[j]->getIdent() - << " because he has is further within the track" - "(my progression is " - << my_progression << ", his progression is " - << other_progression << ")\n"; -#endif - } } //next kart #ifndef DEBUG @@ -693,7 +675,7 @@ << " has finished(" << m_karts[d]->hasFinishedRace() << "), is at lap (" << getLapForKart(d) << "), is at distance(" - << getDistanceDownTrackForKart(d) + << m_kart_info[d].m_overall_distance << "), is eliminated(" << m_karts[d]->isEliminated() << ")" << std::endl; } @@ -737,53 +719,58 @@ std::cout << "Counting laps at "<<getTime()<<" seconds.\n"; for (unsigned int i=0; i<kart_amount; i++) { - Kart* kart = m_karts[i]; + AbstractKart* kart = m_karts[i]; + std::cout << "counting karts ahead of " << kart->getIdent() + << " (laps " << m_kart_info[i].m_race_lap + << ", progress " << m_kart_info[i].m_overall_distance + << " finished " << kart->hasFinishedRace() + << " eliminated " << kart->isEliminated() + << " initial position "<< kart->getInitialPosition() + << ").\n"; + // Karts that are either eliminated or have finished the + // race already have their (final) position assigned. If + // these karts would get their rank updated, it could happen + // that a kart that finished first will be overtaken after + // crossing the finishing line and become second! if(kart->isEliminated() || kart->hasFinishedRace()) continue; KartInfo& kart_info = m_kart_info[i]; int p = 1 ; - const int my_id = kart->getWorldKartId(); - const int my_laps = getLapForKart(my_id); - const float my_progression = getDistanceDownTrackForKart(my_id); - std::cout << "counting karts ahead of " << kart->getIdent() - << " (laps "<<m_kart_info[i].m_race_lap<<", progress " - << my_progression<<").\n"; + const int my_id = kart->getWorldKartId(); + const float my_distance = m_kart_info[my_id].m_overall_distance; + for (unsigned int j = 0 ; j < kart_amount ; j++) { - // don't compare a kart with itself - if(j == kart->getWorldKartId()) continue; + if(j == my_id) continue; + if(m_karts[j]->isEliminated()) + { + std::cout << " " << p << " : " << m_karts[j]->getIdent() + << " because it is eliminated.\n"; + continue; + } if(!kart->hasFinishedRace() && m_karts[j]->hasFinishedRace()) { p++; std::cout << " " << p << " : " << m_karts[j]->getIdent() - << " because he has finished.\n"; + << " because it has finished the race.\n"; continue; } - int other_laps = getLapForKart(j); - if (other_laps != my_laps) + if(m_kart_info[j].m_overall_distance > my_distance) { - if(other_laps > my_laps) - { - p++; // Other kart has more lapses - std::cout << " " << p << " : " - << m_karts[j]->getIdent() - << " because he has more laps than me.\n"; - } + p++; + std::cout << " " << p << " : " << m_karts[j]->getIdent() + << " because it is ahead " + << m_kart_info[j].m_overall_distance <<".\n"; continue; } - float other_progression = getDistanceDownTrackForKart(j); - if(other_progression > my_progression || - (other_progression == my_progression && - m_karts[j]->getInitialPosition() - > kart->getInitialPosition()) ) + if(m_kart_info[j].m_overall_distance == my_distance && + m_karts[j]->getInitialPosition()<kart->getInitialPosition() ) { p++; std::cout << " " << p << " : " << m_karts[j]->getIdent() - << " because he is further within the track" - "(my progression is " - << my_progression << ", his progression is " - << other_progression << ")\n"; + << " has same distance, but started ahead " + << m_karts[j]->getInitialPosition()<<".\n"; } - } //next kart + } // next kart j } // for i<kart_amount std::cout << "-------------------------------------------\n"; } // if rank_changed Modified: main/trunk/src/modes/linear_world.hpp =================================================================== --- main/trunk/src/modes/linear_world.hpp 2012-10-14 20:59:51 UTC (rev 11682) +++ main/trunk/src/modes/linear_world.hpp 2012-10-14 22:23:07 UTC (rev 11683) @@ -65,6 +65,10 @@ /** During last lap only: estimated finishing time! */ float m_estimated_finish; + /** How far the kart has travelled (this is (number-of-laps-1) times + * track-length plus distance-along-track). */ + float m_overall_distance; + /** Stores the current graph node and track coordinates etc. */ TrackSector m_current_sector; @@ -78,8 +82,9 @@ m_lap_start_time = 0; m_time_at_last_lap = 99999.9f; m_estimated_finish = -1.0f; + m_overall_distance = 0.0f; m_current_sector.reset(); - } + } // reset // -------------------------------------------------------------------- /** Returns a pointer to the current node object. */ TrackSector *getSector() {return &m_current_sector; } @@ -141,23 +146,36 @@ // ------------------------------------------------------------------------ /** Returns true if the kart is on a valid driveline quad. * \param kart_index Index of the kart. */ - bool isOnRoad(unsigned int kart_index) const - { return m_kart_info[kart_index].getSector()->isOnRoad(); } + bool isOnRoad(unsigned int kart_index) const + { + return m_kart_info[kart_index].getSector()->isOnRoad(); + } // isOnRoad // ------------------------------------------------------------------------ - int getKartLap(unsigned int kart_index) const - { - if (kart_index < m_kart_info.size()) - return m_kart_info[kart_index].m_race_lap; - else - return -1; - } + /** Returns the number of laps a kart has completed. + * \param kart_index World index of the kart. */ + int getKartLap(unsigned int kart_index) const + { + assert(kart_index < m_kart_info.size()); + return m_kart_info[kart_index].m_race_lap; + } // getkartLap + // ------------------------------------------------------------------------ + /** Returns the track_sector object for the specified kart. + * \param kart_index World index of the kart. */ TrackSector& getTrackSector(unsigned int kart_index) - { - return m_kart_info[kart_index].m_current_sector; - } + { + return m_kart_info[kart_index].m_current_sector; + } // getTrackSector + // ------------------------------------------------------------------------ + /** Returns how far the kart has driven so far (i.e. + * number-of-laps-finished times track-length plus distance-on-track. + * \param kart_index World kart id of the kart. */ + float getOverallDistance(unsigned int kart_index) const + { + return m_kart_info[kart_index].m_overall_distance; + } // getOverallDistance }; // LinearWorld #endif Modified: main/trunk/src/modes/world_with_rank.cpp =================================================================== --- main/trunk/src/modes/world_with_rank.cpp 2012-10-14 20:59:51 UTC (rev 11682) +++ main/trunk/src/modes/world_with_rank.cpp 2012-10-14 22:23:07 UTC (rev 11683) @@ -88,7 +88,8 @@ { if (!m_position_used[j]) { - std::cout << " No kart is yet set at position " << j << std::endl; + std::cout << " No kart is yet set at position " << j+1 + << std::endl; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |