summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2PluginLoader.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-07-01 02:43:29 +0100
committerAsh Wolf <ninji@wuffs.org>2023-07-01 02:43:29 +0100
commit5c6a48b2ff362a70416a6a00fda7d06e0f276f2d (patch)
tree62cf542c68d91aa6f7a4e3bfa9eddca4ab352970 /src/T2DLL/T2PluginLoader.cpp
parentc0c336500955a23e344651e5412c9d9d441ef4ee (diff)
downloadt2win-5c6a48b2ff362a70416a6a00fda7d06e0f276f2d.tar.gz
t2win-5c6a48b2ff362a70416a6a00fda7d06e0f276f2d.zip
i am in hell
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2PluginLoader.cpp79
1 files changed, 40 insertions, 39 deletions
diff --git a/src/T2DLL/T2PluginLoader.cpp b/src/T2DLL/T2PluginLoader.cpp
index 57867ed..9018012 100644
--- a/src/T2DLL/T2PluginLoader.cpp
+++ b/src/T2DLL/T2PluginLoader.cpp
@@ -1,5 +1,6 @@
#include "CT2App.h"
#include "GlobalFunc.h"
+#include "T2DLL.h"
#include "T2PluginLoader.h"
#include "T2PluginSpecifier.h"
@@ -22,17 +23,17 @@ void T2PluginLoader::InitFileList() {
strcat(dirBuf, "Plugins\\");
char *dirBufEnd = &dirBuf[strlen(dirBuf)];
- CString dbPath = GetTowerDirectory() + "plugins\\Database";
- BOOL errorFlag = false;
+ CString databasePath = GetTowerDirectory() + "plugins\\Database";
+ BOOL fail = false;
CFile file;
- if (file.Open(dbPath, CFile::modeRead)) {
+ if (file.Open(databasePath, CFile::modeRead)) {
CArchive archive(&file, CArchive::load);
- DWORD count = mList.GetCount();
- archive >> count;
+ DWORD countDatabase = mList.GetCount();
+ archive >> countDatabase;
- for (unsigned int i = 0; i < count; i++) {
+ for (unsigned int index = 0; index < countDatabase; index++) {
T2PluginSpecifier *spec = new T2PluginSpecifier;
spec->Read(archive);
mList.AddTail(spec);
@@ -43,39 +44,39 @@ void T2PluginLoader::InitFileList() {
// check that the database is up-to-date
CFileStatus status;
- int count2 = 0;
+ int numSpec = 0;
- POSITION p = mList.GetHeadPosition();
- while (p) {
- T2PluginSpecifier *spec = (T2PluginSpecifier *) mList.GetNext(p);
+ POSITION pos = mList.GetHeadPosition();
+ while (pos) {
+ T2PluginSpecifier *spec = (T2PluginSpecifier *) mList.GetNext(pos);
if (CFile::GetStatus(spec->mPath, status)) {
if (status.m_mtime == spec->mTime)
- count2++;
+ numSpec++;
}
}
- if (count2 != mList.GetCount())
- errorFlag = true;
+ if (numSpec != mList.GetCount())
+ fail = true;
- count2 = 0;
+ numSpec = 0;
strcpy(dirBufEnd, "*.t2p");
- WIN32_FIND_DATA findData;
- HANDLE findHandle = FindFirstFile(dirBuf, &findData);
- BOOL findOK = (findHandle != INVALID_HANDLE_VALUE);
- while (findOK) {
- findOK = FindNextFile(findHandle, &findData);
- count2++;
+ WIN32_FIND_DATA findInfo;
+ HANDLE handle = FindFirstFile(dirBuf, &findInfo);
+ BOOL find = (handle != INVALID_HANDLE_VALUE);
+ while (find) {
+ find = FindNextFile(handle, &findInfo);
+ numSpec++;
}
- FindClose(findHandle);
+ FindClose(handle);
- if (count2 != mList.GetCount())
- errorFlag = true;
+ if (numSpec != mList.GetCount())
+ fail = true;
} else {
- errorFlag = true;
+ fail = true;
}
- if (errorFlag) {
+ if (fail) {
// update the DB
AfxSetResourceHandle(gT2App->m_hInstance);
@@ -83,19 +84,19 @@ void T2PluginLoader::InitFileList() {
dialog->Create(1000);
gT2App->app_vfB4();
- POSITION p = mList.GetHeadPosition();
- while (p) {
- T2PluginSpecifier *spec = (T2PluginSpecifier *) mList.GetNext(p);
+ POSITION pos = mList.GetHeadPosition();
+ while (pos) {
+ T2PluginSpecifier *spec = (T2PluginSpecifier *) mList.GetNext(pos);
delete spec;
}
mList.RemoveAll();
strcpy(dirBufEnd, "*.t2p");
- WIN32_FIND_DATA findData;
- HANDLE findHandle = FindFirstFile(dirBuf, &findData);
- BOOL findOK = (findHandle != INVALID_HANDLE_VALUE);
- while (findOK) {
- strcpy(dirBufEnd, findData.cFileName);
+ WIN32_FIND_DATA findInfo;
+ HANDLE handle = FindFirstFile(dirBuf, &findInfo);
+ BOOL find = (handle != INVALID_HANDLE_VALUE);
+ while (find) {
+ strcpy(dirBufEnd, findInfo.cFileName);
T2PluginSpecifier *spec = new T2PluginSpecifier;
spec->Initialize(NULL, dirBuf);
@@ -103,19 +104,19 @@ void T2PluginLoader::InitFileList() {
spec->mIsLoaded = false;
mList.AddTail(spec);
- findOK = FindNextFile(findHandle, &findData);
+ find = FindNextFile(handle, &findInfo);
}
- FindClose(findHandle);
+ FindClose(handle);
- if (file.Open(dbPath, CFile::modeWrite | CFile::modeCreate)) {
+ if (file.Open(databasePath, CFile::modeWrite | CFile::modeCreate)) {
CArchive archive(&file, CArchive::store);
DWORD count = mList.GetCount();
archive << count;
- p = mList.GetHeadPosition();
- while (p) {
- T2PluginSpecifier *spec = (T2PluginSpecifier *) mList.GetNext(p);
+ pos = mList.GetHeadPosition();
+ while (pos) {
+ T2PluginSpecifier *spec = (T2PluginSpecifier *) mList.GetNext(pos);
spec->Write(archive);
}