Skip to content

Commit

Permalink
Fix #5053 (bool vector -> uint8_t vector) (#5073)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nomagno authored May 5, 2024
1 parent dae5c49 commit e47958f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/race/grand_prix_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
6 changes: 4 additions & 2 deletions src/race/grand_prix_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <irrString.h>
#include <string>
#include <vector>
#include "utils/types.hpp"

using irr::core::stringw;

Expand Down Expand Up @@ -65,7 +66,8 @@ class GrandPrixData
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;
Expand Down Expand Up @@ -137,7 +139,7 @@ class GrandPrixData

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;
Expand Down
4 changes: 3 additions & 1 deletion src/race/race_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -316,7 +317,8 @@ class RaceManager
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;
Expand Down
2 changes: 1 addition & 1 deletion src/states_screens/grand_prix_cutscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e47958f

Please sign in to comment.