Fix #5053 (bool vector -> uint8_t vector) (#5073)

This commit is contained in:
Nomagno 2024-05-05 23:21:31 +02:00 committed by GitHub
parent dae5c49fcc
commit e47958f2d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 6 deletions

View File

@ -476,9 +476,9 @@ std::vector<int> GrandPrixData::getLaps(bool include_locked) const
* \param include_locked If data for locked tracks should be included or not.
* \return A copy of alist with the reverse status for each track.
*/
std::vector<bool> GrandPrixData::getReverse(bool include_locked) const
std::vector<uint8_t> GrandPrixData::getReverse(bool include_locked) const
{
std::vector<bool> reverse;
std::vector<uint8_t> reverse;
for (unsigned int i = 0; i< m_tracks.size(); i++)
if(isTrackAvailable(m_tracks[i], include_locked))
reverse.push_back(m_reversed[i]);

View File

@ -23,6 +23,7 @@
#include <irrString.h>
#include <string>
#include <vector>
#include "utils/types.hpp"
using irr::core::stringw;
@ -65,7 +66,8 @@ private:
std::vector<int> m_laps;
/** Whether the track in question should be done in reverse mode */
std::vector<bool> m_reversed;
// This is uint8_t instead of bool because of GitHub issue #5053
std::vector<uint8_t> m_reversed;
/** Wether the user can edit this grand prix or not */
bool m_editable;
@ -137,7 +139,7 @@ public:
bool checkConsistency(bool log_error=true) const;
std::vector<int> getLaps(const bool includeLocked=false) const;
std::vector<bool> getReverse(const bool includeLocked=false) const;
std::vector<uint8_t> getReverse(const bool includeLocked=false) const;
bool isEditable() const;
const std::string& getTrackId(const unsigned int track) const;
irr::core::stringw getTrackName(const unsigned int track) const;

View File

@ -34,6 +34,7 @@
#include "network/remote_kart_info.hpp"
#include "race/grand_prix_data.hpp"
#include "utils/vec3.hpp"
#include "utils/types.hpp"
class AbstractKart;
class NetworkString;
@ -316,7 +317,8 @@ private:
std::vector<int> m_num_laps;
/** Whether a track should be reversed */
std::vector<bool> m_reverse_track;
// This is uint8_t instead of bool because of GitHub issue #5053
std::vector<uint8_t> m_reverse_track;
/** The list of default AI karts to use. This is from the command line. */
std::vector<std::string> m_default_ai_list;

View File

@ -53,7 +53,7 @@ void GrandPrixCutscene::setNewGPWithName(const irr::core::stringw& name)
const GrandPrixData current_gp = RaceManager::get()->getGrandPrix();
std::vector<std::string> tracks = current_gp.getTrackNames();
std::vector<int> laps = current_gp.getLaps();
std::vector<bool> reverse = current_gp.getReverse();
std::vector<uint8_t> reverse = current_gp.getReverse();
for (unsigned int i = 0; i < laps.size(); i++)
gp->addTrack(track_manager->getTrack(tracks[i]), laps[i], reverse[i]);
gp->writeToFile();