Minor correction to patch from konstin.

This commit is contained in:
hiker 2014-04-30 10:35:06 +10:00
parent ca08ee9d86
commit 3487f70740
3 changed files with 15 additions and 10 deletions

View File

@ -226,16 +226,16 @@ bool GrandPrixData::checkConsistency(bool log_error) const
* is unlocked). It also prevents people from using the grand prix editor as
* a way to play tracks that still haven't been unlocked
*/
bool GrandPrixData::isTrackAvailable(const std::string &id, bool includeLocked)
const
bool GrandPrixData::isTrackAvailable(const std::string &id,
bool includeLocked ) const
{
if (includeLocked)
return true;
else if (id == "fortmagma")
return !PlayerManager::getCurrentPlayer()->isLocked("fortmagma");
else
return (!m_editable
|| !PlayerManager::get()->getCurrentPlayer()->isLocked(id));
return (!m_editable ||
!PlayerManager::get()->getCurrentPlayer()->isLocked(id));
}
// ----------------------------------------------------------------------------
@ -243,9 +243,10 @@ std::vector<std::string> GrandPrixData::getTrackNames(bool includeLocked) const
{
std::vector<std::string> names;
for (unsigned int i = 0; i < m_tracks.size(); i++)
{
if(isTrackAvailable(m_tracks[i], includeLocked))
names.push_back(m_tracks[i]);
}
return names;
}
@ -289,7 +290,7 @@ unsigned int GrandPrixData::getNumberOfTracks(bool includeLocked) const
// ----------------------------------------------------------------------------
irr::core::stringw GrandPrixData::getTrackName(const unsigned int track) const
{
assert(0 <= track && track < getNumberOfTracks(true));
assert(track < getNumberOfTracks(true));
Track* t = track_manager->getTrack(m_tracks[track]);
assert(t != NULL);
return t->getName();

View File

@ -69,9 +69,9 @@ private:
bool isTrackAvailable(const std::string &id, bool includeLocked) const;
public:
#if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__)
#pragma warning(disable:4290)
#endif
#if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__)
# pragma warning(disable:4290)
#endif
/** Load the GrandPrixData from the given filename */
GrandPrixData(const std::string& filename);
/** Needed for simple creation of an instance of GrandPrixData */

View File

@ -19,8 +19,8 @@
#include "race/grand_prix_manager.hpp"
#include "config/user_config.hpp"
#include "race/grand_prix_data.hpp"
#include "io/file_manager.hpp"
#include "race/grand_prix_data.hpp"
#include "utils/string_utils.hpp"
#include <algorithm>
@ -140,7 +140,9 @@ GrandPrixManager::GrandPrixManager()
GrandPrixManager::~GrandPrixManager()
{
for(unsigned int i=0; i<m_gp_data.size(); i++)
{
delete m_gp_data[i];
}
}
// ----------------------------------------------------------------------------
@ -153,8 +155,10 @@ GrandPrixData* GrandPrixManager::getGrandPrix(const std::string& s) const
GrandPrixData* GrandPrixManager::editGrandPrix(const std::string& s) const
{
for(unsigned int i=0; i<m_gp_data.size(); i++)
{
if(m_gp_data[i]->getId() == s)
return m_gp_data[i];
} // for i in m_gp_data
return NULL;
}