Skip to content

Commit ca30a46

Browse files
committed
Don't care about official module count - container is unsorted, just check the module's type
1 parent 3c375a5 commit ca30a46

File tree

6 files changed

+6
-30
lines changed

6 files changed

+6
-30
lines changed

Lua/LuaBindingsManagers.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ namespace RTE {
112112
.def("GetModuleID", &ModuleMan::GetModuleID)
113113
.def("GetModuleIDFromPath", &ModuleMan::GetModuleIDFromPath)
114114
.def("GetTotalModuleCount", &ModuleMan::GetTotalModuleCount)
115-
.def("GetOfficialModuleCount", &ModuleMan::GetOfficialModuleCount)
116115
.def("IsModuleOfficial", &ModuleMan::IsModuleOfficial)
117116
.def("IsModuleUserdata", &ModuleMan::IsModuleUserdata)
118117
.def("GetFullModulePath", &ModuleMan::GetFullModulePath);

Managers/ModuleMan.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ namespace RTE {
2323

2424
void ModuleMan::Clear() {
2525
m_LoadedDataModules.clear();
26-
m_OfficialModuleCount = 0;
27-
2826
m_DisabledMods.clear();
2927
}
3028

@@ -262,11 +260,8 @@ namespace RTE {
262260
if (std::regex_match(directoryEntryPath, std::regex(".*\.rte"))) {
263261
std::string moduleName = directoryEntryPath.substr(directoryEntryPath.find_last_of('/') + 1, std::string::npos);
264262
if (!g_ModuleMan.IsModDisabled(moduleName) && !IsModuleOfficial(moduleName) && !IsModuleUserdata(moduleName)) {
265-
int moduleID = GetModuleID(moduleName);
266263
// NOTE: LoadDataModule can return false (especially since it may try to load already loaded modules, which is okay) and shouldn't cause stop, so we can ignore its return value here.
267-
if (moduleID < 0 || moduleID >= GetOfficialModuleCount()) {
268-
LoadDataModule(moduleName, false, false, LoadingScreen::LoadingSplashProgressReport);
269-
}
264+
LoadDataModule(moduleName, DataModule::DataModuleType::Unofficial, LoadingScreen::LoadingSplashProgressReport);
270265
}
271266
}
272267
}

Managers/ModuleMan.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ namespace RTE {
3838
/// <param name="moduleName">Name of the module to load.</param>
3939
void SetSingleModuleToLoad(const std::string_view &moduleName) { m_SingleModuleToLoad = moduleName; }
4040

41-
/// <summary>
42-
/// Gets the total number of OFFICIAL modules loaded so far.
43-
/// </summary>
44-
/// <returns>The number of official modules loaded so far.</returns>
45-
size_t GetOfficialModuleCount() const { return m_OfficialModuleCount; }
46-
4741
/// <summary>
4842
/// Gets the total number of modules loaded so far, official or not.
4943
/// </summary>
@@ -194,12 +188,6 @@ namespace RTE {
194188
static const std::array<std::string, 10> c_OfficialModules; //!< Array storing the names of all the official modules.
195189
static const std::array<std::pair<std::string, std::string>, 3> c_UserdataModules; //!< Array storing the names of all the userdata modules.
196190

197-
198-
/// <summary>
199-
/// How many modules are 'official' and shipped with the game, and guaranteed to not have name conflicts among them.
200-
/// All official modules are in the beginning of the m_TypeMap, so this count shows how many into that vector they represent
201-
/// </summary>
202-
int m_OfficialModuleCount;
203191
std::unordered_map<int, DataModule *> m_LoadedDataModules; //!< Map of all loaded DataModules by their ID. Owned by this.
204192

205193
std::string m_SingleModuleToLoad; //!< Name of the single module to load after the official modules.

Managers/PresetMan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ namespace RTE {
462462
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
463463

464464
bool PresetMan::AddMaterialMapping(uint8_t fromID, uint8_t toID, int whichModule) const {
465-
RTEAssert(whichModule >= g_ModuleMan.GetOfficialModuleCount() && whichModule < g_ModuleMan.GetTotalModuleCount(), "Tried to make a material mapping in an official or out-of-bounds DataModule!");
465+
//RTEAssert(whichModule >= g_ModuleMan.GetOfficialModuleCount() && whichModule < g_ModuleMan.GetTotalModuleCount(), "Tried to make a material mapping in an official or out-of-bounds DataModule!");
466466

467467
return g_ModuleMan.GetLoadedDataModules()[whichModule]->AddMaterialMapping(fromID, toID);
468468
}

Menus/ModManagerGUI.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,9 @@ namespace RTE {
5656
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5757

5858
void ModManagerGUI::PopulateKnownModsList() {
59-
for (int i = 0; i < g_ModuleMan.GetTotalModuleCount(); ++i) {
60-
if (i >= g_ModuleMan.GetOfficialModuleCount() && i < g_ModuleMan.GetTotalModuleCount()) {
61-
if (const DataModule *dataModule = g_ModuleMan.GetDataModule(i); dataModule && !dataModule->IsUserdata()) {
62-
ModRecord modRecord = { dataModule->GetFileName(), dataModule->GetFriendlyName(), dataModule->GetDescription(), g_ModuleMan.IsModDisabled(dataModule->GetFileName()) };
63-
m_KnownMods.emplace_back(modRecord);
64-
}
59+
for (const auto &[moduleID, dataModule] : g_ModuleMan.GetLoadedDataModules()) {
60+
if (!dataModule->IsOfficial() && !dataModule->IsUserdata()) {
61+
m_KnownMods.emplace_back(dataModule->GetFileName(), dataModule->GetFriendlyName(), dataModule->GetDescription(), g_ModuleMan.IsModDisabled(dataModule->GetFileName()));
6562
}
6663
}
6764
// Add missing data from disabled mods settings

Menus/ObjectPickerGUI.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,7 @@ namespace RTE {
383383
}
384384
}
385385
} else {
386-
for (int moduleID = 0; moduleID < g_ModuleMan.GetOfficialModuleCount() && moduleID < m_ModuleSpaceID; ++moduleID) {
387-
g_PresetMan.GetAllOfGroup(moduleList.at(moduleID), groupListItem->m_Name, m_ShowType, moduleID);
388-
}
389-
g_PresetMan.GetAllOfGroup(moduleList.at(m_ModuleSpaceID), groupListItem->m_Name, m_ShowType, m_ModuleSpaceID);
386+
g_PresetMan.GetAllOfGroupInModuleSpace(moduleList.at(m_ModuleSpaceID), groupListItem->m_Name, m_ShowType, m_ModuleSpaceID);
390387
}
391388
}
392389

0 commit comments

Comments
 (0)