Skip to content

Commit c66de92

Browse files
committed
Add legacy support for .cwmods
1 parent 5bdabd7 commit c66de92

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

CubeModLoader/main.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ using namespace std;
2121

2222
GLOBAL void* base; // Module base
2323
GLOBAL vector <DLL*> modDLLs; // Every mod we've loaded
24+
GLOBAL vector <DLL*> legacyDLLs; // cwmods
2425
GLOBAL HMODULE hSelf; // A handle to ourself, to prevent being unloaded
2526
GLOBAL void** initterm_eReference; // A pointer-pointer to a function which is run extremely soon after starting, or after being unpacked
2627
GETTER_VAR(void*, initterm_e); // A pointer to that function
@@ -148,7 +149,21 @@ extern "C" void StartMods() {
148149
for (DLL* dll: modDLLs) {
149150
dll->mod->Initialize();
150151
}
151-
152+
153+
// Load legacy cwmods. Don't use this.
154+
hFind = FindFirstFile("Mods\\*.cwmod", &data);
155+
if (hFind != INVALID_HANDLE_VALUE) {
156+
do {
157+
// We should be loaded into the application's address space, so we can just LoadLibraryA
158+
DLL* dll = new DLL(string("Mods\\") + data.cFileName);
159+
dll->Load();
160+
printf("Loaded %s\n", dll->fileName.c_str());
161+
legacyDLLs.push_back(dll);
162+
} while (FindNextFile(hFind, &data));
163+
FindClose(hFind);
164+
}
165+
166+
152167
if (hSelf) PrintLoadedMods();
153168
return;
154169
}
@@ -209,6 +224,13 @@ void PrintLoadedMods() {
209224
if (modDLLs.size() == 0) {
210225
mods += "<No mods>\n";
211226
}
227+
if (legacyDLLs.size() != 0) {
228+
mods += "\nLegacy mods loaded:\n";
229+
for (DLL* dll : legacyDLLs) {
230+
mods += dll->fileName;
231+
mods += "\n";
232+
}
233+
}
212234
Popup("Loaded Mods", mods.c_str());
213235
}
214236

0 commit comments

Comments
 (0)