From 6371efb4c1be01dbb2ca0efb03aa3bbb555ff333 Mon Sep 17 00:00:00 2001 From: auria Date: Mon, 29 Sep 2008 15:14:14 +0000 Subject: [PATCH] fixed lap counting and invalid shortcut detection false positives when resetting race git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2308 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- .../Xcode/STK_XCode.xcodeproj/project.pbxproj | 4 ++ src/modes/follow_the_leader.cpp | 2 +- src/modes/linear_world.cpp | 39 +++++++++++++++++++ src/modes/linear_world.hpp | 1 + src/modes/standard_race.cpp | 2 +- 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj b/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj index 9f476a60e..5fbfbacf4 100644 --- a/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj +++ b/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 95065F6A0E9127B800B2C509 /* race_result_message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95065F690E9127B700B2C509 /* race_result_message.cpp */; }; 9519653D0E8C592F001BB888 /* linear_world.hpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9519653B0E8C592F001BB888 /* linear_world.hpp */; }; 9519653E0E8C592F001BB888 /* linear_world.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9519653C0E8C592F001BB888 /* linear_world.cpp */; }; 95F0F25A0E85C054005F6693 /* callbacks.c in Sources */ = {isa = PBXBuildFile; fileRef = 95923F8B0E808EDC00388BDC /* callbacks.c */; }; @@ -257,6 +258,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 95065F690E9127B700B2C509 /* race_result_message.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = race_result_message.cpp; sourceTree = ""; }; 9519653B0E8C592F001BB888 /* linear_world.hpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; name = linear_world.hpp; path = modes/linear_world.hpp; sourceTree = ""; }; 9519653C0E8C592F001BB888 /* linear_world.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = linear_world.cpp; path = modes/linear_world.cpp; sourceTree = ""; }; 956F3FAB0E85BE0E006F93B0 /* random_generator.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = random_generator.cpp; sourceTree = ""; }; @@ -1625,6 +1627,7 @@ 9592416F0E808EE200388BDC /* network */ = { isa = PBXGroup; children = ( + 95065F690E9127B700B2C509 /* race_result_message.cpp */, 959241700E808EE200388BDC /* character_confirm_message.hpp */, 959241710E808EE200388BDC /* character_info_message.hpp */, 959241720E808EE200388BDC /* character_selected_message.hpp */, @@ -2331,6 +2334,7 @@ 95F0F36F0E85C6A6005F6693 /* clock.cpp in Sources */, 95F0F3840E85C76B005F6693 /* world.cpp in Sources */, 9519653E0E8C592F001BB888 /* linear_world.cpp in Sources */, + 95065F6A0E9127B800B2C509 /* race_result_message.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/modes/follow_the_leader.cpp b/src/modes/follow_the_leader.cpp index 32fb6ea95..11a6bc192 100644 --- a/src/modes/follow_the_leader.cpp +++ b/src/modes/follow_the_leader.cpp @@ -119,7 +119,7 @@ void FollowTheLeaderRace::update(float delta) //----------------------------------------------------------------------------- void FollowTheLeaderRace::restartRace() { - World::restartRace(); + LinearWorld::restartRace(); m_leader_intervals = stk_config->m_leader_intervals; } //----------------------------------------------------------------------------- diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index 9fe3e5794..d65744d87 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -72,6 +72,45 @@ LinearWorld::LinearWorld() : World() }// next kart } //----------------------------------------------------------------------------- +void LinearWorld::restartRace() +{ + World::restartRace(); + + const unsigned int kart_amount = m_kart.size(); + for(unsigned int n=0; nfindRoadSector(m_kart[n]->getXYZ(), &info.m_track_sector); + + //If m_track_sector == UNKNOWN_SECTOR, then the kart is not on top of + //the road, so we have to use another function to find the sector. + if (info.m_track_sector == Track::UNKNOWN_SECTOR ) + { + info.m_on_road = false; + info.m_track_sector = + RaceManager::getTrack()->findOutOfRoadSector(m_kart[n]->getXYZ(), + Track::RS_DONT_KNOW, + Track::UNKNOWN_SECTOR ); + } + else + { + info.m_on_road = true; + } + + RaceManager::getTrack()->spatialToTrack(info.m_curr_track_coords, + m_kart[n]->getXYZ(), + info.m_track_sector ); + + info.m_race_lap = -1; + info.m_lap_start_time = -1.0f; + info.m_time_at_last_lap = 99999.9f; + + }// next kart +} +//----------------------------------------------------------------------------- void LinearWorld::update(float delta) { // store previous kart locations diff --git a/src/modes/linear_world.hpp b/src/modes/linear_world.hpp index 122517e4e..9597bf92b 100644 --- a/src/modes/linear_world.hpp +++ b/src/modes/linear_world.hpp @@ -81,6 +81,7 @@ public: virtual void moveKartAfterRescue(Kart* kart, btRigidBody* body); virtual void terminateRace(); + virtual void restartRace(); float estimateFinishTimeForKart (Kart* kart, KartInfo& kart_info); void updateRacePosition ( Kart* kart, KartInfo& kart_info ); diff --git a/src/modes/standard_race.cpp b/src/modes/standard_race.cpp index d5f4a05dd..d7f85c8b0 100644 --- a/src/modes/standard_race.cpp +++ b/src/modes/standard_race.cpp @@ -64,7 +64,7 @@ void StandardRace::onTerminate() //----------------------------------------------------------------------------- void StandardRace::restartRace() { - World::restartRace(); + LinearWorld::restartRace(); } //----------------------------------------------------------------------------- void StandardRace::update(float delta)