Skip to content

Commit

Permalink
remove foreach from thememetrics.h and deal with fallout
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jul 3, 2020
1 parent 25c1147 commit 5ef46a3
Show file tree
Hide file tree
Showing 26 changed files with 66 additions and 90 deletions.
1 change: 1 addition & 0 deletions src/Etterna/Actor/Gameplay/Background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Etterna/FileTypes/XmlFile.h"
#include "Etterna/FileTypes/XmlFileUtil.h"
#include <deque>
#include "Etterna/Models/Misc/Foreach.h"

static ThemeMetric<float> LEFT_EDGE("Background", "LeftEdge");
static ThemeMetric<float> TOP_EDGE("Background", "TopEdge");
Expand Down
24 changes: 10 additions & 14 deletions src/Etterna/Actor/Gameplay/NoteField.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "Etterna/Globals/global.h"
#include "Etterna/Actor/Gameplay/ArrowEffects.h"
#include "Etterna/Models/Misc/CommonMetrics.h"
#include "Etterna/Models/Misc/GameConstantsAndTypes.h"
#include "Etterna/Singletons/GameState.h"
#include "Etterna/Models/NoteData/NoteData.h"
Expand All @@ -16,7 +15,6 @@
#include "Etterna/Models/Songs/Song.h"
#include "Etterna/Models/StepsAndStyles/Style.h"
#include "Etterna/Singletons/ThemeManager.h"
#include <cfloat>

void
FindDisplayedBeats(const PlayerState* pPlayerState,
Expand Down Expand Up @@ -145,10 +143,9 @@ NoteField::CacheAllUsedNoteSkins()
GAMESTATE->GetAllUsedNoteSkins(asSkinsLower);
asSkinsLower.push_back(
m_pPlayerState->m_PlayerOptions.GetStage().m_sNoteSkin);
FOREACH(RString, asSkinsLower, s)
{
NOTESKIN->ValidateNoteSkinName(*s);
s->MakeLower();
for (auto& s : asSkinsLower) {
NOTESKIN->ValidateNoteSkinName(s);
s.MakeLower();
}

for (unsigned i = 0; i < asSkinsLower.size(); ++i) {
Expand All @@ -158,16 +155,15 @@ NoteField::CacheAllUsedNoteSkins()
/* If we're changing note skins in the editor, we can have old note skins
* lying around. Remove them so they don't accumulate. */
set<RString> setNoteSkinsToUnload;
FOREACHM(RString, NoteDisplayCols*, m_NoteDisplays, d)
{
bool unused =
find(asSkinsLower.begin(), asSkinsLower.end(), d->first) ==
asSkinsLower.end();
for (auto& d : m_NoteDisplays) {
bool unused = find(asSkinsLower.begin(), asSkinsLower.end(), d.first) ==
asSkinsLower.end();
if (unused)
setNoteSkinsToUnload.insert(d->first);
setNoteSkinsToUnload.insert(d.first);
}
for (auto& s : setNoteSkinsToUnload) {
UncacheNoteSkin(s);
}
FOREACHS(RString, setNoteSkinsToUnload, s)
UncacheNoteSkin(*s);

RString sCurrentNoteSkinLower =
m_pPlayerState->m_PlayerOptions.GetCurrent().m_sNoteSkin;
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Actor/Gameplay/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "Etterna/Singletons/NoteSkinManager.h"
#include "Etterna/Models/Misc/ThemeMetric.h"
#include "HoldJudgment.h"
#include "Etterna/Models/Misc/Foreach.h"

void
TimingWindowSecondsInit(size_t /*TimingWindow*/ i,
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Actor/Gameplay/PlayerReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "Etterna/Models/Misc/ThemeMetric.h"
#include "RageUtil/Utils/RageUtil.h"
#include "PlayerReplay.h"
#include "Etterna/Models/Misc/Foreach.h"

static ThemeMetric<float> GRAY_ARROWS_Y_STANDARD;
static ThemeMetric<float> GRAY_ARROWS_Y_REVERSE;
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Actor/Menus/OptionsList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "OptionsList.h"
#include "Etterna/Models/Misc/PlayerState.h"
#include "Etterna/Models/Songs/SongUtil.h"
#include "Etterna/Models/Misc/Foreach.h"

#define LINE(sLineName) \
THEME->GetMetric(m_sName, ssprintf("Line%s", (sLineName).c_str()))
Expand Down
11 changes: 3 additions & 8 deletions src/Etterna/Globals/GameLoop.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#include "global.h"
#include "global.h"
#include "GameLoop.h"
#include "Etterna/Singletons/PrefsManager.h"
#include "RageUtil/Graphics/RageDisplay.h"
#include "RageUtil/Sound/RageSoundManager.h"
#include "RageUtil/Graphics/RageTextureManager.h"

#include "arch/ArchHooks/ArchHooks.h"

#include "Etterna/Singletons/GameSoundManager.h"
#include "Etterna/Singletons/ThemeManager.h"
#include "Etterna/Singletons/SongManager.h"
Expand All @@ -17,8 +15,6 @@
#include "Etterna/Singletons/NetworkSyncManager.h"
#include "RageUtil/Misc/RageInput.h"
#include "Etterna/Singletons/ScreenManager.h"
#include "Etterna/Singletons/SongManager.h"
#include "Etterna/Singletons/ThemeManager.h"
#include <chrono>

static auto g_AccurateGameplayTimer = std::chrono::steady_clock::now();
Expand Down Expand Up @@ -85,9 +81,8 @@ ChangeAppPri()
// This can get called before INPUTMAN is constructed.
if (INPUTMAN) {
INPUTMAN->GetDevicesAndDescriptions(vDevices);
FOREACH_CONST(InputDeviceInfo, vDevices, d)
{
if (d->sDesc.find("NTPAD") != string::npos) {
for (auto& d : vDevices) {
if (d.sDesc.find("NTPAD") != std::string::npos) {
LOG->Trace("Using NTPAD. Don't boost priority.");
return false;
}
Expand Down
11 changes: 2 additions & 9 deletions src/Etterna/Models/Misc/DBProfile.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@

#include "Etterna/Globals/global.h"
#include "Profile.h"
#include "RageUtil/Misc/RageLog.h"
#include "RageUtil/Utils/RageUtil.h"
#include "Etterna/Singletons/ProfileManager.h"
#include "Etterna/Models/NoteData/NoteData.h"
#include "DBProfile.h"
#include "RageUtil/File/RageFile.h"
#include "RageUtil/File/RageFileDriverDeflate.h"
#include "Etterna/Singletons/GameState.h"
#include "Etterna/Singletons/GameManager.h"
#include "Etterna/Singletons/LuaManager.h"
#include "Etterna/Models/NoteData/NoteData.h"
#include "RageUtil/File/RageFileManager.h"

#include "Etterna/Singletons/ScoreManager.h"
#include "Etterna/Singletons/CryptManager.h"
#include "Etterna/Models/Songs/Song.h"
#include "Etterna/Singletons/SongManager.h"
#include "Etterna/Models/StepsAndStyles/Steps.h"
#include "sqlite3.h"
#include "RageUtil/File/RageFileManager.h"
#include <SQLiteCpp/SQLiteCpp.h>
#include <SQLiteCpp/VariadicBind.h>
#include "Etterna/Models/Misc/Foreach.h"

const string PROFILE_DB = "profile.db";
const string WRITE_ONLY_PROFILE_DB = "webprofile.db";
Expand Down Expand Up @@ -130,7 +123,7 @@ DBProfile::LoadGeneralData(SQLite::Database* db)
while (userTableQuery.executeStep()) {
const char* key = userTableQuery.getColumn(0);
const char* value = userTableQuery.getColumn(1);
lua_pushstring(L, key); // push key
lua_pushstring(L, key); // push key
lua_pushstring(L, value); // push value
lua_settable(L, -3);
}
Expand Down
11 changes: 5 additions & 6 deletions src/Etterna/Models/Misc/Difficulty.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Etterna/Globals/global.h"
#include "Etterna/Globals/global.h"
#include "Difficulty.h"
#include "GameConstantsAndTypes.h"
#include "Etterna/Singletons/GameState.h"
Expand Down Expand Up @@ -79,18 +79,17 @@ GetCustomDifficulty(StepsType st, Difficulty dc)
// OPTIMIZATION OPPORTUNITY: cache these metrics and cache the splitting
vector<RString> vsNames;
split(NAMES, ",", vsNames);
FOREACH(RString, vsNames, sName)
{
for (auto& sName : vsNames) {
ThemeMetric<StepsType> STEPS_TYPE("CustomDifficulty",
(*sName) + "StepsType");
(sName) + "StepsType");
if (STEPS_TYPE == StepsType_Invalid || st == STEPS_TYPE) // match
{
ThemeMetric<Difficulty> DIFFICULTY("CustomDifficulty",
(*sName) + "Difficulty");
(sName) + "Difficulty");
if (DIFFICULTY == Difficulty_Invalid || dc == DIFFICULTY) // match
{
ThemeMetric<RString> STRING("CustomDifficulty",
(*sName) + "String");
(sName) + "String");
return STRING.GetValue();
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/Etterna/Models/Misc/RoomWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ AutoScreenMessage(SM_RoomInfoDeploy);

RoomWheel::~RoomWheel()
{
FOREACH(WheelItemBaseData*, m_CurWheelItemData, i)
SAFE_DELETE(*i);
for (auto& i : m_CurWheelItemData) {
SAFE_DELETE(i);
}

m_CurWheelItemData.clear();
}

Expand Down
7 changes: 3 additions & 4 deletions src/Etterna/Models/Misc/ThemeMetric.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#ifndef THEME_METRIC_H
#define THEME_METRIC_H

#include "Foreach.h"
#include "Etterna/Singletons/LuaManager.h"
#include "RageUtil/Utils/RageUtil.h"
#include "Etterna/Singletons/ThemeManager.h"
#include <map>

Expand Down Expand Up @@ -283,8 +281,9 @@ class ThemeMetricMap : public IThemeMetric
const vector<RString>& vsValueNames)
{
m_metric.clear();
FOREACH_CONST(RString, vsValueNames, s)
m_metric[*s].Load(sGroup, pfn(*s));
for (auto& s : vsValueNames) {
m_metric[s].Load(sGroup, pfn(s));
}
}
void Read() override
{
Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/Models/Misc/XMLProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
#include "Etterna/Singletons/GameState.h"
#include "Etterna/Singletons/GameManager.h"
#include "Etterna/Singletons/LuaManager.h"
#include "Etterna/Models/NoteData/NoteData.h"
#include "RageUtil/File/RageFileManager.h"

#include "Etterna/Singletons/ScoreManager.h"
#include "Etterna/Singletons/CryptManager.h"
#include "Etterna/Models/Songs/Song.h"
#include "Etterna/Singletons/SongManager.h"
#include "Etterna/Models/StepsAndStyles/Steps.h"
#include "Etterna/Models/Misc/Foreach.h"

using std::string;

Expand Down
3 changes: 1 addition & 2 deletions src/Etterna/Models/NoteLoaders/NotesLoaderSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
#include "Etterna/FileTypes/MsdFile.h"
#include "Etterna/Models/Misc/NoteTypes.h"
#include "NotesLoaderSM.h"
#include "Etterna/Singletons/PrefsManager.h"
#include "RageUtil/File/RageFileManager.h"
#include "RageUtil/Misc/RageLog.h"
#include "RageUtil/Utils/RageUtil.h"
#include "Etterna/Models/Songs/Song.h"
#include "Etterna/Models/StepsAndStyles/Steps.h"
#include "Etterna/Models/NoteData/NoteData.h"
#include "Etterna/Singletons/SongManager.h"
#include "Etterna/Models/StepsAndStyles/Steps.h"
#include "Etterna/Models/Misc/Foreach.h"

// Everything from this line to the creation of sm_parser_helper exists to
// speed up parsing by allowing the use of std::map. All these functions
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Models/NoteLoaders/NotesLoaderSMA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Etterna/Models/Songs/Song.h"
#include "Etterna/Singletons/SongManager.h"
#include "Etterna/Models/StepsAndStyles/Steps.h"
#include "Etterna/Models/Misc/Foreach.h"

void
SMALoader::ProcessMultipliers(TimingData& out,
Expand Down
4 changes: 2 additions & 2 deletions src/Etterna/Models/NoteLoaders/NotesLoaderSSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Etterna/Models/Songs/Song.h"
#include "Etterna/Singletons/SongManager.h"
#include "Etterna/Models/StepsAndStyles/Steps.h"
#include "Etterna/Models/Misc/Foreach.h"

// Everything from this line to the creation of parser_helper exists to
// speed up parsing by allowing the use of std::map. All these functions
Expand Down Expand Up @@ -571,8 +572,7 @@ SetMSDValues(SSC::StepsTagInfo& info)
auto params = (*info.params);
auto size = params.params.size();
// Start from index 1
for (size_t i = 1; i <= size; i++)
{
for (size_t i = 1; i <= size; i++) {
auto m = SSC::msdsplit(params[i]);
o.push_back(
std::vector<float>{ 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f });
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Models/Songs/SongOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Etterna/Singletons/GameState.h"
#include "RageUtil/Utils/RageUtil.h"
#include "SongOptions.h"
#include "Etterna/Models/Misc/Foreach.h"

static const char* AutosyncTypeNames[] = {
"Off",
Expand Down
15 changes: 9 additions & 6 deletions src/Etterna/Screen/Options/ScreenOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include "Etterna/Singletons/PrefsManager.h"
#include "RageUtil/Misc/RageLog.h"
#include "RageUtil/Utils/RageUtil.h"
#include "Etterna/Models/Misc/ScreenDimensions.h"
#include "Etterna/Singletons/ScreenManager.h"
#include "ScreenOptions.h"
#include "Etterna/Singletons/ThemeManager.h"
#include "Etterna/Models/Misc/Foreach.h"

/*
* These navigation types are provided:
Expand Down Expand Up @@ -323,8 +323,9 @@ ScreenOptions::TweenOnScreen()
{
ScreenWithMenuElements::TweenOnScreen();

FOREACH(OptionRow*, m_pRows, p)
(*p)->RunCommands(ROW_ON_COMMAND);
for (auto& p : m_pRows) {
p->RunCommands(ROW_ON_COMMAND);
}

m_frameContainer.SortByDrawOrder();
}
Expand All @@ -334,8 +335,9 @@ ScreenOptions::TweenOffScreen()
{
ScreenWithMenuElements::TweenOffScreen();

FOREACH(OptionRow*, m_pRows, p)
(*p)->RunCommands(ROW_OFF_COMMAND);
for (auto& p : m_pRows) {
p->RunCommands(ROW_OFF_COMMAND);
}
}

ScreenOptions::~ScreenOptions()
Expand Down Expand Up @@ -669,7 +671,8 @@ ScreenOptions::PositionRows(bool bTween)
if (i < first_start)
fPos = -0.5f;
else if (i >= first_end && i < second_start)
fPos = (static_cast<int>(static_cast<int>(NUM_ROWS_SHOWN) / 2)) - 0.5f;
fPos =
(static_cast<int>(static_cast<int>(NUM_ROWS_SHOWN) / 2)) - 0.5f;
else if (i >= second_end)
fPos = ((int)NUM_ROWS_SHOWN) - 0.5f;

Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Screen/Others/ScreenDebugOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Etterna/Globals/StepMania.h"
#include "Etterna/Models/Misc/ThemeMetric.h"
#include "Etterna/FileTypes/XmlToLua.h"
#include "Etterna/Models/Misc/Foreach.h"

static bool g_bIsDisplayed = false;
static bool g_bIsSlow = false;
Expand Down
21 changes: 2 additions & 19 deletions src/Etterna/Screen/Others/ScreenInstallOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,24 @@
#include "RageUtil/File/RageFileManager.h"
#include "Etterna/Singletons/ScreenManager.h"
#include "Etterna/Singletons/CryptManager.h"
#include "Etterna/Models/Misc/Preference.h"
#include "RageUtil/Misc/RageLog.h"
#include "Etterna/Models/Misc/Preference.h"
#include "Etterna/Singletons/LuaManager.h"
#include "RageUtil/File/RageFileManager.h"
#include "RageUtil/Misc/RageLog.h"
#include "ScreenInstallOverlay.h"
#include "Etterna/Singletons/ScreenManager.h"
#include "Etterna/Globals/SpecialFiles.h"
class Song;
#include "Etterna/Singletons/SongManager.h"
#include "Etterna/Singletons/GameState.h"
#include "Etterna/Singletons/GameManager.h"
#include "Etterna/Screen/Others/ScreenSelectMusic.h"
#include "Etterna/Models/NoteWriters/NotesWriterSSC.h"
#include "Etterna/Models/Misc/CommonMetrics.h"
#include "Etterna/Singletons/SongManager.h"
#include "Etterna/Singletons/CommandLineActions.h"
#include "Etterna/Models/Misc/CommonMetrics.h"
#include "Etterna/Singletons/GameManager.h"
#include "Etterna/Singletons/GameState.h"
#include "Etterna/Models/Misc/ScreenDimensions.h"
#include "Etterna/Singletons/SongManager.h"
#include "Etterna/Globals/StepMania.h"
#include "Etterna/Actor/Base/ActorUtil.h"
#include "Etterna/Models/Songs/Song.h"
#include "Etterna/Models/NoteData/NoteData.h"
#include "Etterna/Models/StepsAndStyles/Steps.h"
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
#include <fstream>
#include "Etterna/Singletons/DownloadManager.h"
#include "Etterna/Models/Misc/Foreach.h"

class Song;
const RString TEMP_OS_MOUNT_POINT = "/@temp-os/";

struct FileCopyResult
Expand Down
5 changes: 2 additions & 3 deletions src/Etterna/Screen/Others/ScreenMapControllers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,8 @@ ScreenMapControllers::SanityCheckWrapper()
return true;
}

FOREACH(RString, reasons_not_sane, reason)
{
*reason = THEME->GetString("ScreenMapControllers", *reason);
for (auto& reason : reasons_not_sane) {
reason = THEME->GetString("ScreenMapControllers", reason);
}
RString joined_reasons = join("\n", reasons_not_sane);
joined_reasons = THEME->GetString("ScreenMapControllers", "VitalButtons") +
Expand Down
Loading

0 comments on commit 5ef46a3

Please sign in to comment.