[MapRotation] C++20 things

This commit is contained in:
Diavolo 2022-06-11 11:55:12 +02:00
parent 88f82d297f
commit 2c54bd7d0d
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
2 changed files with 7 additions and 7 deletions

View File

@ -21,24 +21,24 @@ namespace Components
std::random_device rd;
std::mt19937 gen(rd());
std::shuffle(this->rotationEntries.begin(), this->rotationEntries.end(), gen);
std::ranges::shuffle(this->rotationEntries_, gen);
}
void MapRotation::RotationData::addEntry(const std::string& key, const std::string& value)
{
this->rotationEntries.emplace_back(std::make_pair(key, value));
this->rotationEntries_.emplace_back(std::make_pair(key, value));
}
std::size_t MapRotation::RotationData::getEntriesSize() const
{
return this->rotationEntries.size();
return this->rotationEntries_.size();
}
MapRotation::RotationData::rotationEntry& MapRotation::RotationData::getNextEntry()
{
const auto index = this->index_;
this->index_ = (this->index_ + 1) % this->rotationEntries.size(); // Point index_ to the next entry
return this->rotationEntries.at(index);
++this->index_ %= this->rotationEntries_.size(); // Point index_ to the next entry
return this->rotationEntries_.at(index);
}
void MapRotation::RotationData::parse(const std::string& data)
@ -132,7 +132,7 @@ namespace Components
void MapRotation::ApplyMapRotation()
{
//Continue to apply gamemode until a map is found
// Continue to apply gamemode until a map is found
auto foundMap = false;
std::size_t i = 0;

View File

@ -32,7 +32,7 @@ namespace Components
void parse(const std::string& data);
private:
std::vector<rotationEntry> rotationEntries;
std::vector<rotationEntry> rotationEntries_;
std::size_t index_;
};