Save GP reverse Type; close #1137

This commit is contained in:
konstin 2014-10-18 20:54:25 +02:00 committed by Deve
parent 035fc599ee
commit f65ad8f84f
5 changed files with 38 additions and 15 deletions

View File

@ -68,6 +68,7 @@ SavedGrandPrix::SavedGrandPrix(unsigned int player_id,
RaceManager::Difficulty difficulty,
int player_karts,
int last_track,
int reverse_type,
const std::vector<RaceManager::KartStatus> &kart_list)
: m_savedgp_group("SavedGP",
"Represents the saved state of a GP"),
@ -75,7 +76,8 @@ SavedGrandPrix::SavedGrandPrix(unsigned int player_id,
m_gp_id(gp_id.c_str(), "gp_id", &m_savedgp_group),
m_difficulty((int)difficulty,"difficulty", &m_savedgp_group),
m_player_karts(player_karts,"player_karts", &m_savedgp_group),
m_next_track(last_track,"last_track", &m_savedgp_group)
m_next_track(last_track,"last_track", &m_savedgp_group),
m_reverse_type(reverse_type,"reverse_type", &m_savedgp_group)
{
for(unsigned int i =0; i < kart_list.size(); i++)
{
@ -94,18 +96,20 @@ SavedGrandPrix::SavedGrandPrix(unsigned int player_id,
SavedGrandPrix::SavedGrandPrix(const XMLNode* node)
: m_savedgp_group("SavedGP",
"Represents the saved state of a GP"),
m_player_id(0, "player_id", &m_savedgp_group),
m_gp_id("-", "gp_id", &m_savedgp_group),
m_difficulty(0,"difficulty", &m_savedgp_group),
m_player_id (0, "player_id", &m_savedgp_group),
m_gp_id ("-", "gp_id", &m_savedgp_group),
m_difficulty (0,"difficulty", &m_savedgp_group),
m_player_karts(0,"player_karts", &m_savedgp_group),
m_next_track(0,"last_track", &m_savedgp_group)
m_next_track (0,"last_track", &m_savedgp_group),
m_reverse_type(0,"reverse_type", &m_savedgp_group)
{
//m_player_group.findYourDataInAChildOf(node);
m_player_id.findYourDataInAnAttributeOf(node);
m_gp_id.findYourDataInAnAttributeOf(node);
m_difficulty.findYourDataInAnAttributeOf(node);
m_player_id. findYourDataInAnAttributeOf(node);
m_gp_id. findYourDataInAnAttributeOf(node);
m_difficulty. findYourDataInAnAttributeOf(node);
m_player_karts.findYourDataInAnAttributeOf(node);
m_next_track.findYourDataInAnAttributeOf(node);
m_next_track. findYourDataInAnAttributeOf(node);
m_reverse_type.findYourDataInAnAttributeOf(node);
std::vector<XMLNode*> karts;
node->getNodes("Kart", karts);

View File

@ -76,6 +76,9 @@ protected:
/** Index of the next to run track. */
IntUserConfigParam m_next_track;
/** GPReverseType of the GP as int */
IntUserConfigParam m_reverse_type;
PtrVector<SavedGPKart> m_karts;
public:
@ -88,6 +91,7 @@ public:
RaceManager::Difficulty difficulty,
int player_karts,
int last_track,
int reverse_type,
const std::vector<RaceManager::KartStatus> &kart_list);
/**
@ -122,6 +126,10 @@ public:
/** Returns the index of the last track finished when this GP was saved. */
int getNextTrack() const { return m_next_track; }
// ------------------------------------------------------------------------
/** Returns the reverse Type. */
int getReverseType() const { return m_reverse_type; }
// ------------------------------------------------------------------------
/** Sets the index of the last track finished. */
void setNextTrack(int next_track) { m_next_track = next_track; }

View File

@ -70,6 +70,7 @@ void GrandPrixData::createRandomGP(const unsigned int number_of_tracks,
m_name = "Random Grand Prix";
m_editable = false;
m_group = GP_NONE;
m_reverse_type = use_reverse;
if(new_tracks)
{
@ -155,6 +156,7 @@ void GrandPrixData::changeTrackNumber(const unsigned int number_of_tracks,
*/
void GrandPrixData::changeReverse(const GrandPrixData::GPReverseType use_reverse)
{
m_reverse_type = use_reverse;
for (unsigned int i = 0; i < m_tracks.size(); i++)
{
if (use_reverse == GP_NO_REVERSE)

View File

@ -94,6 +94,9 @@ public:
GP_DEFAULT_REVERSE = 3
}; // GPReverseType
private:
GPReverseType m_reverse_type;
public:
#if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__)
# pragma warning(disable:4290)
@ -145,22 +148,25 @@ public:
// ------------------------------------------------------------------------
/** @return the (potentially translated) user-visible name of the Grand
* Prix (apply fribidi as needed) */
irr::core::stringw getName() const { return _LTR(m_name.c_str()); }
irr::core::stringw getName() const { return _LTR(m_name.c_str()); }
// ------------------------------------------------------------------------
/** @return the internal indentifier of the Grand Prix (not translated) */
const std::string& getId() const { return m_id; }
const std::string& getId() const { return m_id; }
// ------------------------------------------------------------------------
/** Returns true if this GP is a random GP. */
bool isRandomGP() const { return m_id=="random"; }
bool isRandomGP() const { return m_id=="random"; }
// ------------------------------------------------------------------------
/** Returns the filename of the grand prix xml file. */
const std::string& getFilename() const { return m_filename; }
const std::string& getFilename() const { return m_filename; }
// ------------------------------------------------------------------------
/** Returns the group. */
enum GPGroupType getGroup() const { return m_group; }
enum GPGroupType getGroup() const { return m_group; }
// ------------------------------------------------------------------------
enum GPReverseType getReverseType()
const { return m_reverse_type; }
}; // GrandPrixData
#endif

View File

@ -308,6 +308,8 @@ void RaceManager::startNew(bool from_overworld)
} else {
setNumKarts(m_saved_gp->getTotalKarts());
setupPlayerKartInfo();
m_grand_prix.changeReverse((GrandPrixData::GPReverseType)m_saved_gp->getReverseType());
m_reverse_track = m_grand_prix.getReverse();
}
}
}
@ -519,6 +521,7 @@ void RaceManager::next()
m_difficulty,
(int)m_player_karts.size(),
m_track_number,
m_grand_prix.getReverseType(),
m_kart_status
)
);