This commit is contained in:
Alayan 2018-10-02 13:25:30 +02:00 committed by auriamg
parent a32834e518
commit 3427d21939
26 changed files with 56 additions and 36 deletions

View File

@ -51,7 +51,7 @@
<poweruplover goal="10"/>
</achievement>
<achievement id="8" check-type="all-at-least" reset-type="never"
name="Beyond Luck" description="Win 5 single races in a row against at least 3 AIs.">
name="Beyond Luck" description="Win 5 single races in a row against at least 3 AIs. Beware, restarting a race count as a loss.">
<wins goal="5"/>
</achievement>
<achievement id="9" check-type="all-at-least" reset-type="race"
@ -66,7 +66,7 @@
<swatter goal="5"/>
</achievement>
<achievement id="12" check-type="all-at-least" reset-type="never"
name="Unstoppable" description="Win 10 single races in a row in Expert or SuperTux against at least 5 AIs.">
name="Unstoppable" description="Win 10 single races in a row in Expert or SuperTux against at least 5 AIs. Beware, restarting a race count as a loss.">
<wins goal="10"/>
</achievement>
</achievements>

View File

@ -273,6 +273,13 @@ void AchievementsStatus::onRaceEnd(bool aborted)
}
m_variables[ACHIEVE_POWERUP_USED_1RACE].counter = 0;
// Prevent restart from being abused to get consecutive wins achievement
if (aborted)
{
m_variables[ACHIEVE_CONS_WON_RACES].counter = 0;
m_variables[ACHIEVE_CONS_WON_RACES_HARD].counter = 0;
}
} // onRaceEnd
// ----------------------------------------------------------------------------

View File

@ -189,6 +189,16 @@ public:
->resetDataVar(achievement_data_id);
} // resetAchievementData
// ------------------------------------------------------------------------
/** Reset achievements which have to be done in one race
* \param restart - if the race has been restarted
*/
static void onRaceEnd(bool restart)
{
getCurrentAchievementsStatus()
->onRaceEnd(restart);
} // resetAchievementData
// ------------------------------------------------------------------------
}; // PlayerManager
#endif

View File

@ -106,9 +106,9 @@ void CaptureTheFlag::init()
} // init
// ----------------------------------------------------------------------------
void CaptureTheFlag::reset()
void CaptureTheFlag::reset(bool restart)
{
FreeForAll::reset();
FreeForAll::reset(restart);
m_red_trans = m_orig_red_trans;
m_blue_trans = m_orig_blue_trans;
m_red_return_ticks = m_blue_return_ticks = m_red_scores =

View File

@ -73,7 +73,7 @@ public:
// ------------------------------------------------------------------------
virtual void init() OVERRIDE;
// ------------------------------------------------------------------------
virtual void reset() OVERRIDE;
virtual void reset(bool restart=false) OVERRIDE;
// ------------------------------------------------------------------------
virtual void update(int ticks) OVERRIDE;
// ------------------------------------------------------------------------

View File

@ -172,9 +172,9 @@ CutsceneWorld::~CutsceneWorld()
{
} // ~CutsceneWorld
//-----------------------------------------------------------------------------
void CutsceneWorld::reset()
void CutsceneWorld::reset(bool restart)
{
World::reset();
World::reset(restart);
m_phase = RACE_PHASE;
}
//-----------------------------------------------------------------------------

View File

@ -65,7 +65,7 @@ public:
virtual void init() OVERRIDE;
virtual void reset() OVERRIDE;
virtual void reset(bool restart=false) OVERRIDE;
// clock events
virtual bool isRaceOver() OVERRIDE;

View File

@ -212,11 +212,11 @@ bool EasterEggHunt::isRaceOver()
} // isRaceOver
//-----------------------------------------------------------------------------
/** Called then a battle is restarted.
/** Called when an egg hunt is restarted.
*/
void EasterEggHunt::reset()
void EasterEggHunt::reset(bool restart)
{
LinearWorld::reset();
LinearWorld::reset(restart);
for(unsigned int i=0; i<m_eggs_collected.size(); i++)
m_eggs_collected[i] = 0;

View File

@ -56,7 +56,7 @@ public:
virtual bool isRaceOver() OVERRIDE;
// overriding World methods
virtual void reset() OVERRIDE;
virtual void reset(bool restart=false) OVERRIDE;
virtual bool raceHasLaps() OVERRIDE { return false; }

View File

@ -75,9 +75,9 @@ FollowTheLeaderRace::~FollowTheLeaderRace()
//-----------------------------------------------------------------------------
/** Called just before a race is started.
*/
void FollowTheLeaderRace::reset()
void FollowTheLeaderRace::reset(bool restart)
{
LinearWorld::reset();
LinearWorld::reset(restart);
m_last_eliminated_time = 0.0f;
m_leader_intervals.clear();
m_leader_intervals = stk_config->m_leader_intervals;

View File

@ -46,7 +46,7 @@ public:
virtual int getScoreForPosition(int p) OVERRIDE;
// overriding World methods
virtual void reset() OVERRIDE;
virtual void reset(bool restart=false) OVERRIDE;
virtual const std::string& getIdent() const OVERRIDE;
virtual const btTransform &getStartTransform(int index) OVERRIDE;
virtual void getKartsDisplayInfo(

View File

@ -58,9 +58,9 @@ void FreeForAll::init()
// ----------------------------------------------------------------------------
/** Called when a battle is restarted.
*/
void FreeForAll::reset()
void FreeForAll::reset(bool restart)
{
WorldWithRank::reset();
WorldWithRank::reset(restart);
if (race_manager->hasTimeTarget())
{
WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN,

View File

@ -46,7 +46,7 @@ public:
// ------------------------------------------------------------------------
virtual bool isRaceOver() OVERRIDE;
// ------------------------------------------------------------------------
virtual void reset() OVERRIDE;
virtual void reset(bool restart=false) OVERRIDE;
// ------------------------------------------------------------------------
virtual void getKartsDisplayInfo(
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;

View File

@ -91,9 +91,9 @@ LinearWorld::~LinearWorld()
* structures that keep track of position and distance long track of
* all karts.
*/
void LinearWorld::reset()
void LinearWorld::reset(bool restart)
{
WorldWithRank::reset();
WorldWithRank::reset(restart);
m_finish_timeout = std::numeric_limits<float>::max();
m_last_lap_sfx_played = false;
m_last_lap_sfx_playing = false;

View File

@ -153,7 +153,7 @@ public:
virtual unsigned int getNumberOfRescuePositions() const OVERRIDE;
virtual unsigned int getRescuePositionIndex(AbstractKart *kart) OVERRIDE;
virtual btTransform getRescueTransform(unsigned int index) const OVERRIDE;
virtual void reset() OVERRIDE;
virtual void reset(bool restart=false) OVERRIDE;
virtual void newLap(unsigned int kart_index) OVERRIDE;
// ------------------------------------------------------------------------

View File

@ -129,9 +129,9 @@ void SoccerWorld::init()
//-----------------------------------------------------------------------------
/** Called when a soccer game is restarted.
*/
void SoccerWorld::reset()
void SoccerWorld::reset(bool restart)
{
WorldWithRank::reset();
WorldWithRank::reset(restart);
if (race_manager->hasTimeTarget())
{
WorldStatus::setClockMode(WorldStatus::CLOCK_COUNTDOWN,

View File

@ -312,7 +312,7 @@ public:
virtual void terminateRace() OVERRIDE;
// overriding World methods
virtual void reset() OVERRIDE;
virtual void reset(bool restart=false) OVERRIDE;
virtual unsigned int getRescuePositionIndex(AbstractKart *kart) OVERRIDE;
virtual btTransform getRescueTransform(unsigned int rescue_pos) const

View File

@ -91,9 +91,9 @@ ThreeStrikesBattle::~ThreeStrikesBattle()
//-----------------------------------------------------------------------------
/** Called when a battle is restarted.
*/
void ThreeStrikesBattle::reset()
void ThreeStrikesBattle::reset(bool restart)
{
WorldWithRank::reset();
WorldWithRank::reset(restart);
float next_spawn_time =
race_manager->getDifficulty() == RaceManager::DIFFICULTY_BEST ? 40.0f :

View File

@ -102,7 +102,7 @@ public:
virtual void terminateRace() OVERRIDE;
// ------------------------------------------------------------------------
// overriding World methods
virtual void reset() OVERRIDE;
virtual void reset(bool restart=false) OVERRIDE;
// ------------------------------------------------------------------------
virtual void getKartsDisplayInfo(
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;

View File

@ -266,7 +266,7 @@ void World::init()
* calling init() when starting a race for the first time, or after
* restarting a race, in which case no init() is called.
*/
void World::reset()
void World::reset(bool restart)
{
RewindManager::get()->reset();
@ -283,7 +283,7 @@ void World::reset()
m_schedule_pause = false;
m_schedule_unpause = false;
WorldStatus::reset();
WorldStatus::reset(restart);
m_faster_music_active = false;
m_eliminated_karts = 0;
m_eliminated_players = 0;
@ -292,6 +292,8 @@ void World::reset()
for ( KartList::iterator i = m_karts.begin(); i != m_karts.end() ; ++i )
{
(*i)->reset();
if (restart && (*i)->getController()->canGetAchievements())
PlayerManager::onRaceEnd(true /* previous race aborted */);
}
Camera::resetAllCameras();

View File

@ -256,7 +256,7 @@ public:
virtual void init();
virtual void updateGraphics(float dt);
virtual void terminateRace() OVERRIDE;
virtual void reset() OVERRIDE;
virtual void reset(bool restart=false) OVERRIDE;
virtual void pause(Phase phase) OVERRIDE;
virtual void unpause() OVERRIDE;
virtual void getDefaultCollectibles(int *collectible_type,

View File

@ -59,7 +59,7 @@ WorldStatus::WorldStatus()
//-----------------------------------------------------------------------------
/** Resets all status information, used when starting a new race.
*/
void WorldStatus::reset()
void WorldStatus::reset(bool restart)
{
m_time = 0.0f;
m_time_ticks = 0;

View File

@ -138,7 +138,7 @@ public:
WorldStatus();
virtual ~WorldStatus();
virtual void reset();
virtual void reset(bool restart);
virtual void updateTime(int ticks);
virtual void update(int ticks);
void startReadySetGo();

View File

@ -63,9 +63,9 @@ void WorldWithRank::init()
} // init
//-----------------------------------------------------------------------------
void WorldWithRank::reset()
void WorldWithRank::reset(bool restart)
{
World::reset();
World::reset(restart);
for (unsigned int i = 0; i < m_kart_track_sector.size(); i++)
{
getTrackSector(i)->reset();

View File

@ -74,7 +74,7 @@ public:
classes must be instanciated, otherwise polymorphism will fail and the
results will be incorrect */
virtual void init() OVERRIDE;
virtual void reset() OVERRIDE;
virtual void reset(bool restart=false) OVERRIDE;
bool displayRank() const { return m_display_rank; }

View File

@ -21,6 +21,7 @@
#include <iostream>
#include <algorithm>
#include "achievements/achievements_status.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "config/saved_grand_prix.hpp"
@ -919,7 +920,7 @@ void RaceManager::rerunRace()
m_kart_status[i].m_score = m_kart_status[i].m_last_score;
m_kart_status[i].m_overall_time -= m_kart_status[i].m_last_time;
}
World::getWorld()->reset();
World::getWorld()->reset(true /* restart */);
} // rerunRace
//-----------------------------------------------------------------------------