Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit c422067

Browse files
committed
Cleanup
1 parent 3e6bacc commit c422067

File tree

8 files changed

+32
-26
lines changed

8 files changed

+32
-26
lines changed

Entities/Scene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ int Scene::SaveData(std::string pathBase)
10531053
{
10541054
std::snprintf(str, sizeof(str), "T%d", team);
10551055
// Save unseen layer data to disk
1056-
if (m_apUnseenLayer[team]->SaveData(fullPathBase + " US" + str + ".bmp") < 0)
1056+
if (m_apUnseenLayer[team]->SaveData(fullPathBase + " US" + str + ".png") < 0)
10571057
{
10581058
g_ConsoleMan.PrintString("ERROR: Saving unseen layer " + m_apUnseenLayer[team]->GetPresetName() + "\'s data failed!");
10591059
return -1;

Managers/AudioMan.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,15 @@ namespace RTE {
287287
void AudioMan::PlayMusic(const char *filePath, int loops, float volumeOverrideIfNotMuted) {
288288
if (m_AudioEnabled) {
289289
const std::string fullFilePath = g_PresetMan.FullModulePath(filePath);
290-
if (m_IsInMultiplayerMode) { RegisterMusicEvent(-1, MUSIC_PLAY, fullFilePath.c_str(), loops); }
290+
if (m_IsInMultiplayerMode) {
291+
RegisterMusicEvent(-1, NetworkMusicState::MUSIC_PLAY, fullFilePath.c_str(), loops);
292+
}
291293

292294
bool musicIsPlaying;
293295
FMOD_RESULT result = m_MusicChannelGroup->isPlaying(&musicIsPlaying);
294296
if (result == FMOD_OK && musicIsPlaying) {
295297
bool doNotPlayNextStream = true;
296-
FMOD_RESULT result = m_MusicChannelGroup->setUserData(&doNotPlayNextStream);
298+
result = m_MusicChannelGroup->setUserData(&doNotPlayNextStream);
297299
result = (result == FMOD_OK) ? m_MusicChannelGroup->stop() : result;
298300
result = (result == FMOD_OK) ? m_MusicChannelGroup->setUserData(nullptr) : result;
299301
}

Managers/LuaMan.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,9 @@ namespace RTE {
212212
"\n"
213213
// Override "math.random" in the lua state to use RTETools MT19937 implementation. Preserve return types of original to not break all the things.
214214
"math.random = function(lower, upper) if lower ~= nil and upper ~= nil then return SelectRand(lower, upper); elseif lower ~= nil then return SelectRand(1, lower); else return PosRand(); end end"
215-
);
216-
// Override dofile() to be able to account for Data/ or Mods/ subfolder
217-
luaL_dostring(m_MasterState,
218-
"OriginalDoFile = dofile dofile = function(filePath) filePath = PresetMan:FullModulePath(filePath) if filePath ~= '' then return OriginalDoFile(filePath) end end;"
215+
"\n"
216+
// Override "dofile" to be able to account for Data/ or Mods/ directory.
217+
"OriginalDoFile = dofile; dofile = function(filePath) filePath = PresetMan:FullModulePath(filePath); if filePath ~= '' then return OriginalDoFile(filePath); end end;"
219218
);
220219
}
221220

Managers/PresetMan.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333

3434
namespace RTE {
3535

36-
static const std::array<std::string, 10> officialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" };
37-
static const std::array<std::pair<std::string, std::string>, 3> userdataModules = { {
36+
const std::array<std::string, 10> PresetMan::c_OfficialModules = { "Base.rte", "Coalition.rte", "Imperatus.rte", "Techion.rte", "Dummy.rte", "Ronin.rte", "Browncoats.rte", "Uzira.rte", "MuIlaak.rte", "Missions.rte" };
37+
const std::array<std::pair<std::string, std::string>, 3> PresetMan::c_UserdataModules = {{
3838
{c_UserScenesModuleName, "User Scenes"},
3939
{c_UserConquestSavesModuleName, "Conquest Saves"},
4040
{c_UserScriptedSavesModuleName, "Scripted Activity Saves" }
41-
} };
41+
}};
4242

4343
//////////////////////////////////////////////////////////////////////////////////////////
4444
// Method: Clear
@@ -152,7 +152,7 @@ bool PresetMan::LoadAllDataModules() {
152152
FindAndExtractZippedModules();
153153

154154
// Load all the official modules first!
155-
for (const std::string &officialModule : officialModules) {
155+
for (const std::string &officialModule : c_OfficialModules) {
156156
if (!LoadDataModule(officialModule, true, false, LoadingScreen::LoadingSplashProgressReport)) {
157157
return false;
158158
}
@@ -185,7 +185,7 @@ bool PresetMan::LoadAllDataModules() {
185185
}
186186

187187
// Load userdata modules AFTER all other techs etc are loaded; might be referring to stuff in user mods.
188-
for (const auto &[userdataModuleName, userdataModuleFriendlyName] : userdataModules) {
188+
for (const auto &[userdataModuleName, userdataModuleFriendlyName] : c_UserdataModules) {
189189
if (!std::filesystem::exists(System::GetWorkingDirectory() + userdataModuleName)) {
190190
bool scanContentsAndIgnoreMissing = userdataModuleName == c_UserScenesModuleName;
191191
DataModule::CreateOnDiskAsUserdata(userdataModuleName, userdataModuleFriendlyName, scanContentsAndIgnoreMissing, scanContentsAndIgnoreMissing);
@@ -334,16 +334,19 @@ int PresetMan::GetModuleIDFromPath(std::string dataPath)
334334

335335
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
336336

337-
bool PresetMan::IsModuleOfficial(std::string moduleName)
338-
{
339-
return std::find(officialModules.begin(), officialModules.end(), moduleName) != officialModules.end();
337+
bool PresetMan::IsModuleOfficial(std::string moduleName) {
338+
return std::find(c_OfficialModules.begin(), c_OfficialModules.end(), moduleName) != c_OfficialModules.end();
340339
}
341340

342341
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
343342

344-
bool PresetMan::IsModuleUserdata(std::string moduleName) {
345-
auto userdataModuleItr = std::find_if(userdataModules.begin(), userdataModules.end(), [&moduleName](const auto &userdataModulesEntry) { return userdataModulesEntry.first == moduleName; });
346-
return userdataModuleItr != userdataModules.end();
343+
bool PresetMan::IsModuleUserdata(std::string moduleName) const {
344+
auto userdataModuleItr = std::find_if(c_UserdataModules.begin(), c_UserdataModules.end(),
345+
[&moduleName](const auto &userdataModulesEntry) {
346+
return userdataModulesEntry.first == moduleName;
347+
}
348+
);
349+
return userdataModuleItr != c_UserdataModules.end();
347350
}
348351

349352
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Managers/PresetMan.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ class PresetMan : public Singleton<PresetMan> {
177177
/// <param name="moduleName">The name of the module to check, in the form "[moduleName].rte"</param>
178178
/// <returns>True if the module is an official data module, otherwise false.</returns>
179179
bool IsModuleOfficial(std::string moduleName);
180-
180+
181181

182182
/// <summary>
183183
/// Returns whether or not the module is vanilla.
184184
/// </summary>
185185
/// <param name="moduleName">The name of the module to check, in the form "[moduleName].rte"</param>
186186
/// <returns>True if the module is a listed user data module, otherwise false.</returns>
187-
bool IsModuleUserdata(std::string moduleName);
187+
bool IsModuleUserdata(std::string moduleName) const;
188188

189189
/// <summary>
190190
/// Returns the Full path to the module including Data/, Userdata/ or Mods/.
@@ -573,6 +573,9 @@ class PresetMan : public Singleton<PresetMan> {
573573

574574
private:
575575

576+
static const std::array<std::string, 10> c_OfficialModules; // Array storing the names of all the official modules.
577+
static const std::array<std::pair<std::string, std::string>, 3> c_UserdataModules; // Array storing the names of all the userdata modules.
578+
576579
std::array<std::string, 3> m_LastReloadedEntityPresetInfo; //!< Array storing the last reloaded Entity preset info (ClassName, PresetName and DataModule). Used for quick reloading via key combination.
577580
bool m_ReloadEntityPresetCalledThisUpdate; //!< A flag for whether or not ReloadEntityPreset was called this update.
578581

System/Reader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace RTE {
2323
m_OverwriteExisting = false;
2424
m_SkipIncludes = false;
2525
m_CanFail = false;
26-
m_NonMudulePath = false;
26+
m_NonModulePath = false;
2727
}
2828

2929
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -33,7 +33,7 @@ namespace RTE {
3333
return -1;
3434
}
3535

36-
if (m_NonMudulePath) {
36+
if (m_NonModulePath) {
3737
m_FilePath = std::filesystem::path(fileName).generic_string();
3838
m_DataModuleName = "Base.rte";
3939
m_DataModuleID = 0;

System/Reader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace RTE {
2626
/// <param name="progressCallback">A function pointer to a function that will be called and sent a string with information about the progress of this Reader's reading.</param>
2727
/// <param name="failOK">Whether it's ok for the file to not be there, ie we're only trying to open, and if it's not there, then fail silently.</param>
2828
/// <param name="nonModulePath">Whether this Reader is reading from path that is not a DataModule and should just read it as provided.</param>
29-
Reader(const std::string &fileName, bool overwrites = false, const ProgressCallback &progressCallback = nullptr, bool failOK = false, bool nonModulePath = false) { Clear(); m_NonMudulePath = nonModulePath; Create(fileName, overwrites, progressCallback, failOK); }
29+
Reader(const std::string &fileName, bool overwrites = false, const ProgressCallback &progressCallback = nullptr, bool failOK = false, bool nonModulePath = false) { Clear(); m_NonModulePath = nonModulePath; Create(fileName, overwrites, progressCallback, failOK); }
3030

3131
/// <summary>
3232
/// Makes the Reader object ready for use.
@@ -221,7 +221,7 @@ namespace RTE {
221221
bool m_OverwriteExisting; //!< Whether object instances read from this should overwrite any already existing ones with the same names.
222222
bool m_SkipIncludes; //!< Indicates whether reader should skip included files.
223223
bool m_CanFail; //!< Whether it's ok for the Reader to fail reading a file and fail silently instead of aborting.
224-
bool m_NonMudulePath; //!< Whether this Reader is reading from path that is not a DataModule and should just read it as provided.
224+
bool m_NonModulePath; //!< Whether this Reader is reading from path that is not a DataModule and should just read it as provided.
225225

226226
std::stack<int> m_BlockCommentOpenTagLines; //<! Stores lines on which block comment open tags are encountered. Used for error reporting when a file stream ends with an open block comment.
227227

System/System.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ namespace RTE {
5555
/// <returns>Folder name of the mod directory.</returns>
5656
static const std::string & GetModDirectory() { return s_ModDirectory; }
5757

58-
5958
/// <summary>
6059
/// Gets the userdata directory name.
6160
/// </summary>
6261
/// <returns>Folder name of the userdata directory.</returns>
63-
static const std::string &GetUserdataDirectory() { return s_UserdataDirectory; }
62+
static const std::string & GetUserdataDirectory() { return s_UserdataDirectory; }
6463

6564
/// <summary>
6665
/// Gets the extension that determines a directory/file is an RTE module.

0 commit comments

Comments
 (0)