diff --git a/CMakeLists.txt b/CMakeLists.txt index d869d010..ceb04e4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,6 +172,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core # Set the plugin as the startup project set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}) +target_compile_options(Spelunky2 PRIVATE /W4) + # Copy the plugin to the x64dbg plugins folder if(CMAKE_GENERATOR STREQUAL "Ninja") # dodgy solution for VS Community having different path to the binary diff --git a/include/Data/CharacterDB.h b/include/Data/CharacterDB.h index c78cd5f8..d6c21a72 100644 --- a/include/Data/CharacterDB.h +++ b/include/Data/CharacterDB.h @@ -35,6 +35,6 @@ namespace S2Plugin CharacterDB(const CharacterDB&) = delete; CharacterDB& operator=(const CharacterDB&) = delete; - friend class Spelunky2; + friend struct Spelunky2; }; } // namespace S2Plugin diff --git a/include/Data/EntityDB.h b/include/Data/EntityDB.h index 09d0ba04..cec5ceab 100644 --- a/include/Data/EntityDB.h +++ b/include/Data/EntityDB.h @@ -16,6 +16,6 @@ namespace S2Plugin private: uintptr_t ptr{0}; - friend class Spelunky2; + friend struct Spelunky2; }; } // namespace S2Plugin diff --git a/include/Data/Logger.h b/include/Data/Logger.h index 0347d7bf..9507d949 100644 --- a/include/Data/Logger.h +++ b/include/Data/Logger.h @@ -11,7 +11,7 @@ namespace S2Plugin { - struct ItemModelLoggerFields; + class ItemModelLoggerFields; enum class MemoryFieldType; struct LoggerField diff --git a/include/Data/ParticleDB.h b/include/Data/ParticleDB.h index 482ddcb3..fd00b590 100644 --- a/include/Data/ParticleDB.h +++ b/include/Data/ParticleDB.h @@ -16,6 +16,6 @@ namespace S2Plugin private: uintptr_t ptr{0}; - friend class Spelunky2; + friend struct Spelunky2; }; } // namespace S2Plugin diff --git a/include/Data/StringsTable.h b/include/Data/StringsTable.h index 50897541..11d208a9 100644 --- a/include/Data/StringsTable.h +++ b/include/Data/StringsTable.h @@ -35,6 +35,6 @@ namespace S2Plugin size_t size{0}; // Use the model as cache QStandardItemModel cache; - friend class Spelunky2; + friend struct Spelunky2; }; } // namespace S2Plugin diff --git a/include/Data/TextureDB.h b/include/Data/TextureDB.h index 47f480b4..1144a899 100644 --- a/include/Data/TextureDB.h +++ b/include/Data/TextureDB.h @@ -58,6 +58,6 @@ namespace S2Plugin TextureDB(const TextureDB&) = delete; TextureDB& operator=(const TextureDB&) = delete; - friend class Spelunky2; + friend struct Spelunky2; }; } // namespace S2Plugin diff --git a/include/Data/VirtualTableLookup.h b/include/Data/VirtualTableLookup.h index d642a0a3..5322be37 100644 --- a/include/Data/VirtualTableLookup.h +++ b/include/Data/VirtualTableLookup.h @@ -29,7 +29,7 @@ namespace S2Plugin { return mOffsetToTableEntries.at(tableOffset); } - std::unordered_set tableOffsetForFunctionAddress(size_t functionAddress) const; + std::unordered_set tableOffsetForFunctionAddress(size_t functionAddress) const; VirtualTableEntry findPrecedingEntryWithSymbols(size_t tableOffset) const; size_t tableAddressForEntry(const VirtualTableEntry& entry) const; @@ -50,7 +50,7 @@ namespace S2Plugin } private: - std::unordered_map mOffsetToTableEntries; + std::unordered_map mOffsetToTableEntries; uintptr_t mTableStartAddress{0}; VirtualTableLookup() = default; @@ -58,6 +58,6 @@ namespace S2Plugin VirtualTableLookup(const VirtualTableLookup&) = delete; VirtualTableLookup& operator=(const VirtualTableLookup&) = delete; - friend class Spelunky2; + friend struct Spelunky2; }; } // namespace S2Plugin diff --git a/include/QtHelpers/DialogEditState.h b/include/QtHelpers/DialogEditState.h index b65b65b3..992fc36e 100644 --- a/include/QtHelpers/DialogEditState.h +++ b/include/QtHelpers/DialogEditState.h @@ -7,8 +7,8 @@ namespace S2Plugin { enum class MemoryFieldType; - struct ItemModelStates; - struct SortFilterProxyModelStates; + class ItemModelStates; + class SortFilterProxyModelStates; class DialogEditState : public QDialog { diff --git a/include/QtHelpers/ItemModelGatherVirtualData.h b/include/QtHelpers/ItemModelGatherVirtualData.h index 67d5706e..dd5f1a57 100644 --- a/include/QtHelpers/ItemModelGatherVirtualData.h +++ b/include/QtHelpers/ItemModelGatherVirtualData.h @@ -2,11 +2,11 @@ #include #include +#include +#include namespace S2Plugin { - struct ViewToolbar; - static const uint8_t gsColGatherID = 0; static const uint8_t gsColGatherName = 1; static const uint8_t gsColGatherVirtualTableOffset = 2; @@ -37,7 +37,7 @@ namespace S2Plugin Q_OBJECT public: - ItemModelGatherVirtualData(ViewToolbar* toolbar, QObject* parent = nullptr); + ItemModelGatherVirtualData(QObject* parent = nullptr); Qt::ItemFlags flags(const QModelIndex& index) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; @@ -57,7 +57,6 @@ namespace S2Plugin bool isEntryCompleted(size_t index) const; private: - ViewToolbar* mToolbar; std::vector mEntries; void parseJSON(); @@ -68,13 +67,12 @@ namespace S2Plugin Q_OBJECT public: - SortFilterProxyModelGatherVirtualData(ViewToolbar* toolbar, QObject* parent = nullptr); + SortFilterProxyModelGatherVirtualData(QObject* parent = nullptr); bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override; void setHideCompleted(bool b); private: - ViewToolbar* mToolbar; bool mHideCompleted = false; }; diff --git a/include/QtHelpers/ItemModelVirtualFunctions.h b/include/QtHelpers/ItemModelVirtualFunctions.h index b8a396f5..31748d8e 100644 --- a/include/QtHelpers/ItemModelVirtualFunctions.h +++ b/include/QtHelpers/ItemModelVirtualFunctions.h @@ -7,7 +7,7 @@ namespace S2Plugin { - struct ViewToolbar; + class ViewToolbar; static const uint8_t gsColFunctionIndex = 0; static const uint8_t gsColFunctionTableAddress = 1; diff --git a/include/QtHelpers/ItemModelVirtualTable.h b/include/QtHelpers/ItemModelVirtualTable.h index 70bcef82..8b08b493 100644 --- a/include/QtHelpers/ItemModelVirtualTable.h +++ b/include/QtHelpers/ItemModelVirtualTable.h @@ -6,7 +6,7 @@ namespace S2Plugin { - struct ViewToolbar; + class ViewToolbar; static const uint8_t gsColTableOffset = 0; static const uint8_t gsColCodeAddress = 1; @@ -28,7 +28,7 @@ namespace S2Plugin QModelIndex parent(const QModelIndex& index) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - void detectEntities(ViewToolbar* toolbar); + void detectEntities(); private: uintptr_t mLayer0Offset; diff --git a/include/QtHelpers/TreeViewMemoryFields.h b/include/QtHelpers/TreeViewMemoryFields.h index a2ad03db..071bd60f 100644 --- a/include/QtHelpers/TreeViewMemoryFields.h +++ b/include/QtHelpers/TreeViewMemoryFields.h @@ -11,7 +11,7 @@ namespace S2Plugin { - struct ViewToolbar; + class ViewToolbar; struct MemoryField; class StyledItemDelegateHTML; diff --git a/include/QtHelpers/WidgetSpelunkyLevel.h b/include/QtHelpers/WidgetSpelunkyLevel.h index 3105f597..fd62a5ed 100644 --- a/include/QtHelpers/WidgetSpelunkyLevel.h +++ b/include/QtHelpers/WidgetSpelunkyLevel.h @@ -27,8 +27,8 @@ namespace S2Plugin void paintEvent(QPaintEvent* event) override; private: - size_t mEntitiesOffset; - uint32_t mEntitiesCount; + size_t mEntitiesOffset{0}; + uint32_t mEntitiesCount{0}; std::unordered_map mEntityMasksToPaint; std::unordered_map mEntityIDsToPaint; diff --git a/include/QtHelpers/WidgetSpelunkyRooms.h b/include/QtHelpers/WidgetSpelunkyRooms.h index a48492a8..5008c71e 100644 --- a/include/QtHelpers/WidgetSpelunkyRooms.h +++ b/include/QtHelpers/WidgetSpelunkyRooms.h @@ -5,7 +5,7 @@ namespace S2Plugin { - struct ViewToolbar; + class ViewToolbar; struct ToolTipRect; class WidgetSpelunkyRooms : public QWidget @@ -29,7 +29,7 @@ namespace S2Plugin QString mFieldName; ViewToolbar* mToolbar; bool mIsMetaData = false; - size_t mOffset; + size_t mOffset{0}; QFont mFont; QSize mTextAdvance; uint8_t mSpaceAdvance; diff --git a/include/Views/ViewCharacterDB.h b/include/Views/ViewCharacterDB.h index c7208740..fb8ddb76 100644 --- a/include/Views/ViewCharacterDB.h +++ b/include/Views/ViewCharacterDB.h @@ -16,8 +16,8 @@ namespace S2Plugin { - struct TreeViewMemoryFields; - struct ViewToolbar; + class TreeViewMemoryFields; + class ViewToolbar; class ViewCharacterDB : public QWidget { diff --git a/include/Views/ViewEntities.h b/include/Views/ViewEntities.h index acee7c2b..06d588f0 100644 --- a/include/Views/ViewEntities.h +++ b/include/Views/ViewEntities.h @@ -9,8 +9,8 @@ namespace S2Plugin { - struct ViewToolbar; - struct TreeViewMemoryFields; + class ViewToolbar; + class TreeViewMemoryFields; enum class MASK : uint32_t { diff --git a/include/Views/ViewEntity.h b/include/Views/ViewEntity.h index ec449aca..73418c96 100644 --- a/include/Views/ViewEntity.h +++ b/include/Views/ViewEntity.h @@ -15,12 +15,11 @@ namespace S2Plugin { - struct ViewToolbar; - struct Entity; - struct TreeViewMemoryFields; - struct WidgetMemoryView; - struct CPPSyntaxHighlighter; - struct WidgetSpelunkyLevel; + class ViewToolbar; + class TreeViewMemoryFields; + class WidgetMemoryView; + class CPPSyntaxHighlighter; + class WidgetSpelunkyLevel; class ViewEntity : public QWidget { diff --git a/include/Views/ViewEntityDB.h b/include/Views/ViewEntityDB.h index 0378d366..513e08ab 100644 --- a/include/Views/ViewEntityDB.h +++ b/include/Views/ViewEntityDB.h @@ -16,8 +16,8 @@ namespace S2Plugin { - struct ViewToolbar; - struct TreeViewMemoryFields; + class ViewToolbar; + class TreeViewMemoryFields; class ViewEntityDB : public QWidget { diff --git a/include/Views/ViewGameManager.h b/include/Views/ViewGameManager.h index 0a5db2cc..cbc704cb 100644 --- a/include/Views/ViewGameManager.h +++ b/include/Views/ViewGameManager.h @@ -11,8 +11,8 @@ namespace S2Plugin { - struct ViewToolbar; - struct TreeViewMemoryFields; + class ViewToolbar; + class TreeViewMemoryFields; class ViewGameManager : public QWidget { diff --git a/include/Views/ViewJournalPage.h b/include/Views/ViewJournalPage.h index 3dd28a3b..da2a59fe 100644 --- a/include/Views/ViewJournalPage.h +++ b/include/Views/ViewJournalPage.h @@ -13,9 +13,9 @@ namespace S2Plugin { - struct ViewToolbar; - struct TreeViewMemoryFields; - struct JournalPage; + class ViewToolbar; + class TreeViewMemoryFields; + class JournalPage; class ViewJournalPage : public QWidget { diff --git a/include/Views/ViewLevelGen.h b/include/Views/ViewLevelGen.h index aacf1d20..07eab463 100644 --- a/include/Views/ViewLevelGen.h +++ b/include/Views/ViewLevelGen.h @@ -13,9 +13,9 @@ namespace S2Plugin { - struct ViewToolbar; - struct TreeViewMemoryFields; - struct WidgetSpelunkyRooms; + class ViewToolbar; + class TreeViewMemoryFields; + class WidgetSpelunkyRooms; class ViewLevelGen : public QWidget { diff --git a/include/Views/ViewLogger.h b/include/Views/ViewLogger.h index b7e36371..8dff3e1c 100644 --- a/include/Views/ViewLogger.h +++ b/include/Views/ViewLogger.h @@ -11,11 +11,11 @@ namespace S2Plugin { class Logger; - struct TableViewLogger; - struct ItemModelLoggerFields; - struct WidgetSampling; - struct ItemModelLoggerSamples; - struct WidgetSamplesPlot; + class TableViewLogger; + class ItemModelLoggerFields; + class WidgetSampling; + class ItemModelLoggerSamples; + class WidgetSamplesPlot; class ViewLogger : public QWidget { diff --git a/include/Views/ViewOnline.h b/include/Views/ViewOnline.h index d501b415..9a1275c7 100644 --- a/include/Views/ViewOnline.h +++ b/include/Views/ViewOnline.h @@ -11,8 +11,8 @@ namespace S2Plugin { - struct ViewToolbar; - struct TreeViewMemoryFields; + class ViewToolbar; + class TreeViewMemoryFields; class ViewOnline : public QWidget { diff --git a/include/Views/ViewParticleDB.h b/include/Views/ViewParticleDB.h index 46b75d9e..badab7f3 100644 --- a/include/Views/ViewParticleDB.h +++ b/include/Views/ViewParticleDB.h @@ -16,8 +16,8 @@ namespace S2Plugin { - struct ViewToolbar; - struct TreeViewMemoryFields; + class ViewToolbar; + class TreeViewMemoryFields; class ViewParticleDB : public QWidget { diff --git a/include/Views/ViewSaveGame.h b/include/Views/ViewSaveGame.h index 55328028..62036595 100644 --- a/include/Views/ViewSaveGame.h +++ b/include/Views/ViewSaveGame.h @@ -11,8 +11,8 @@ namespace S2Plugin { - struct ViewToolbar; - struct TreeViewMemoryFields; + class ViewToolbar; + class TreeViewMemoryFields; class ViewSaveGame : public QWidget { diff --git a/include/Views/ViewState.h b/include/Views/ViewState.h index a8ff4cf0..3cc7886f 100644 --- a/include/Views/ViewState.h +++ b/include/Views/ViewState.h @@ -11,8 +11,8 @@ namespace S2Plugin { - struct ViewToolbar; - struct TreeViewMemoryFields; + class ViewToolbar; + class TreeViewMemoryFields; class ViewState : public QWidget { diff --git a/include/Views/ViewStdMap.h b/include/Views/ViewStdMap.h index 75392052..a2d2c142 100644 --- a/include/Views/ViewStdMap.h +++ b/include/Views/ViewStdMap.h @@ -10,9 +10,8 @@ namespace S2Plugin { - struct MemoryField; - struct ViewToolbar; - struct TreeViewMemoryFields; + class ViewToolbar; + class TreeViewMemoryFields; class ViewStdMap : public QWidget { diff --git a/include/Views/ViewStdVector.h b/include/Views/ViewStdVector.h index 2a46f7e0..b18a1cbb 100644 --- a/include/Views/ViewStdVector.h +++ b/include/Views/ViewStdVector.h @@ -9,9 +9,8 @@ namespace S2Plugin { - struct ViewToolbar; - struct MemoryField; - struct TreeViewMemoryFields; + class ViewToolbar; + class TreeViewMemoryFields; class ViewStdVector : public QWidget { diff --git a/include/Views/ViewTextureDB.h b/include/Views/ViewTextureDB.h index 37735ff5..120f6784 100644 --- a/include/Views/ViewTextureDB.h +++ b/include/Views/ViewTextureDB.h @@ -16,8 +16,8 @@ namespace S2Plugin { - struct ViewToolbar; - struct TreeViewMemoryFields; + class ViewToolbar; + class TreeViewMemoryFields; class ViewTextureDB : public QWidget { diff --git a/include/Views/ViewThreads.h b/include/Views/ViewThreads.h index dedefddd..96c36fb5 100644 --- a/include/Views/ViewThreads.h +++ b/include/Views/ViewThreads.h @@ -8,8 +8,8 @@ namespace S2Plugin { - struct ViewToolbar; - struct StyledItemDelegateHTML; + class ViewToolbar; + class StyledItemDelegateHTML; class ViewThreads : public QWidget { diff --git a/include/Views/ViewVirtualFunctions.h b/include/Views/ViewVirtualFunctions.h index 983752bd..66052483 100644 --- a/include/Views/ViewVirtualFunctions.h +++ b/include/Views/ViewVirtualFunctions.h @@ -1,5 +1,6 @@ #pragma once +#include "QtHelpers/StyledItemDelegateHTML.h" #include #include #include @@ -7,10 +8,9 @@ namespace S2Plugin { - struct ViewToolbar; - struct StyledItemDelegateHTML; - struct ItemModelVirtualFunctions; - struct SortFilterProxyModelVirtualFunctions; + class ViewToolbar; + class ItemModelVirtualFunctions; + class SortFilterProxyModelVirtualFunctions; class ViewVirtualFunctions : public QWidget { @@ -37,7 +37,7 @@ namespace S2Plugin QLineEdit* mJumpToLineEdit; QTableView* mFunctionsTable; - std::unique_ptr mHTMLDelegate; + StyledItemDelegateHTML mHTMLDelegate; std::unique_ptr mModel; std::unique_ptr mSortFilterProxy; diff --git a/include/Views/ViewVirtualTable.h b/include/Views/ViewVirtualTable.h index d4bfcc6c..8016051b 100644 --- a/include/Views/ViewVirtualTable.h +++ b/include/Views/ViewVirtualTable.h @@ -9,18 +9,17 @@ namespace S2Plugin { - struct ViewToolbar; - struct ItemModelVirtualTable; - struct SortFilterProxyModelVirtualTable; - struct StyledItemDelegateHTML; - struct ItemModelGatherVirtualData; - struct SortFilterProxyModelGatherVirtualData; + class ItemModelVirtualTable; + class SortFilterProxyModelVirtualTable; + class StyledItemDelegateHTML; + class ItemModelGatherVirtualData; + class SortFilterProxyModelGatherVirtualData; class ViewVirtualTable : public QWidget { Q_OBJECT public: - ViewVirtualTable(ViewToolbar* toolbar, QWidget* parent = nullptr); + ViewVirtualTable(QWidget* parent = nullptr); void showLookupAddress(size_t address); void updateGatherProgress(); @@ -46,7 +45,6 @@ namespace S2Plugin void showGatherHideCompletedCheckBoxStateChanged(int state); private: - ViewToolbar* mToolbar; QVBoxLayout* mMainLayout; QTabWidget* mMainTabWidget; diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 5052472a..baebfaff 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -651,7 +651,7 @@ const std::vector>& S2Plugin::Configuration::ref auto it = mRefs.find(fieldName); if (it == mRefs.end()) { - dprintf("unknown ref requested in Configuration::refTitlesOfField() (%s)\n", fieldName); + dprintf("unknown ref requested in Configuration::refTitlesOfField() (%s)\n", fieldName.c_str()); static std::vector> empty; return empty; } @@ -762,7 +762,7 @@ int S2Plugin::Configuration::getAlingment(const std::string& typeName) const { if (itr->second > sizeof(uintptr_t)) { - dprintf("wrong alignment provided (%d) for struct (%s), allowed range: 0-8\n", itr->second, itr->first); + dprintf("wrong alignment provided (%d) for struct (%s), allowed range: 0-8\n", itr->second, itr->first.c_str()); return sizeof(uintptr_t); } return itr->second; @@ -796,7 +796,7 @@ size_t S2Plugin::Configuration::getTypeSize(const std::string& typeName, bool en } return new_size; } - dprintf("could not determinate size for (%s)\n", typeName); + dprintf("could not determinate size for (%s)\n", typeName.c_str()); return 0; } diff --git a/src/Data/CPPGenerator.cpp b/src/Data/CPPGenerator.cpp index 90cd9340..37fb10db 100644 --- a/src/Data/CPPGenerator.cpp +++ b/src/Data/CPPGenerator.cpp @@ -46,7 +46,7 @@ void S2Plugin::CPPGenerator::generate(const std::string& typeName, CPPSyntaxHigh QString qClassName = QString("\\b" + QRegularExpression::escape(QString::fromStdString(className)) + "\\b"); highlighter->addRule(qClassName, HighlightColor::Type); - auto skipCounter = 1; + // auto skipCounter = 1; mGeneratedTypes.insert(typeName); mSS << "class " << className; if (!parentClassName.empty()) diff --git a/src/Data/VirtualTableLookup.cpp b/src/Data/VirtualTableLookup.cpp index a96015a9..51b4ed13 100644 --- a/src/Data/VirtualTableLookup.cpp +++ b/src/Data/VirtualTableLookup.cpp @@ -1,8 +1,8 @@ #include "Data/VirtualTableLookup.h" -std::unordered_set S2Plugin::VirtualTableLookup::tableOffsetForFunctionAddress(size_t functionAddress) const +std::unordered_set S2Plugin::VirtualTableLookup::tableOffsetForFunctionAddress(size_t functionAddress) const { - std::unordered_set offsets; + std::unordered_set offsets; for (const auto& [tableOffset, tableEntry] : mOffsetToTableEntries) { if (tableEntry.value == functionAddress) diff --git a/src/QtHelpers/ItemModelGatherVirtualData.cpp b/src/QtHelpers/ItemModelGatherVirtualData.cpp index f6958333..faaf422e 100644 --- a/src/QtHelpers/ItemModelGatherVirtualData.cpp +++ b/src/QtHelpers/ItemModelGatherVirtualData.cpp @@ -1,10 +1,6 @@ #include "QtHelpers/ItemModelGatherVirtualData.h" #include "Configuration.h" -#include "Data/EntityDB.h" -#include "Data/State.h" -#include "Data/VirtualTableLookup.h" #include "Spelunky2.h" -#include "Views/ViewToolbar.h" #include "pluginmain.h" #include #include @@ -25,7 +21,7 @@ enum VIRT_FUNC : uint32_t MOVABLE_DAMAGE = 48, }; -S2Plugin::ItemModelGatherVirtualData::ItemModelGatherVirtualData(ViewToolbar* toolbar, QObject* parent) : QAbstractItemModel(parent), mToolbar(toolbar) +S2Plugin::ItemModelGatherVirtualData::ItemModelGatherVirtualData(QObject* parent) : QAbstractItemModel(parent) { parseJSON(); } @@ -232,7 +228,7 @@ void S2Plugin::ItemModelGatherVirtualData::gatherExtraObjects() for (const auto& logicName : logics) { auto logicAddress = Script::Memory::ReadQword(Script::Memory::ReadQword(firstLogicPtr + counter)); - auto tableOffset = 0; + size_t tableOffset = 0; if (logicAddress != 0) { tableOffset = (logicAddress - vtl.tableStartAddress()) / sizeof(size_t); @@ -274,7 +270,7 @@ void S2Plugin::ItemModelGatherVirtualData::gatherExtraObjects() { auto offset = config->offsetForField(config->typeFields(MemoryFieldType::GameManager), screenName, spel2->get_GameManagerPtr()); auto screenAddress = Script::Memory::ReadQword(Script::Memory::ReadQword(offset)); - auto tableOffset = 0; + size_t tableOffset = 0; if (screenAddress != 0) { tableOffset = (screenAddress - vtl.tableStartAddress()) / sizeof(size_t); @@ -327,7 +323,7 @@ void S2Plugin::ItemModelGatherVirtualData::gatherExtraObjects() for (const auto& screenName : screens_state) { auto screenAddress = Script::Memory::ReadQword(Script::Memory::ReadQword(config->offsetForField(config->typeFields(MemoryFieldType::State), screenName, spel2->get_StatePtr()))); - auto tableOffset = 0; + size_t tableOffset = 0; if (screenAddress != 0) { tableOffset = (screenAddress - vtl.tableStartAddress()) / sizeof(size_t); @@ -366,7 +362,7 @@ void S2Plugin::ItemModelGatherVirtualData::gatherExtraObjects() for (const auto& questName : quests) { auto questAddress = Script::Memory::ReadQword(Script::Memory::ReadQword(config->offsetForField(config->typeFields(MemoryFieldType::State), "quests." + questName, spel2->get_StatePtr()))); - auto tableOffset = 0; + size_t tableOffset = 0; if (questAddress != 0) { tableOffset = (questAddress - vtl.tableStartAddress()) / sizeof(size_t); @@ -616,7 +612,7 @@ void S2Plugin::ItemModelGatherVirtualData::gatherAvailableVirtuals() endResetModel(); } -S2Plugin::SortFilterProxyModelGatherVirtualData::SortFilterProxyModelGatherVirtualData(ViewToolbar* toolbar, QObject* parent) : QSortFilterProxyModel(parent), mToolbar(toolbar) {} +S2Plugin::SortFilterProxyModelGatherVirtualData::SortFilterProxyModelGatherVirtualData(QObject* parent) : QSortFilterProxyModel(parent) {} bool S2Plugin::SortFilterProxyModelGatherVirtualData::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const { diff --git a/src/QtHelpers/ItemModelVirtualTable.cpp b/src/QtHelpers/ItemModelVirtualTable.cpp index 17dd8974..11507d8f 100644 --- a/src/QtHelpers/ItemModelVirtualTable.cpp +++ b/src/QtHelpers/ItemModelVirtualTable.cpp @@ -91,7 +91,7 @@ QVariant S2Plugin::ItemModelVirtualTable::headerData(int section, Qt::Orientatio return QVariant(); } -void S2Plugin::ItemModelVirtualTable::detectEntities(ViewToolbar* toolbar) +void S2Plugin::ItemModelVirtualTable::detectEntities() { auto processEntities = [&](size_t layerEntities, uint32_t count) { @@ -102,7 +102,7 @@ void S2Plugin::ItemModelVirtualTable::detectEntities(ViewToolbar* toolbar) auto entity = Script::Memory::ReadQword(entityPtr); auto entityVTableOffset = Script::Memory::ReadQword(entity); - auto entityUid = Script::Memory::ReadDword(entity + 56); + // auto entityUid = Script::Memory::ReadDword(entity + 56); auto entityName = Configuration::get()->getEntityName(entity); Spelunky2::get()->get_VirtualTableLookup().setSymbolNameForOffsetAddress(entityVTableOffset, entityName); } diff --git a/src/QtHelpers/SortFilterProxyModelStringsTable.cpp b/src/QtHelpers/SortFilterProxyModelStringsTable.cpp index 251f30c9..670a6733 100644 --- a/src/QtHelpers/SortFilterProxyModelStringsTable.cpp +++ b/src/QtHelpers/SortFilterProxyModelStringsTable.cpp @@ -18,17 +18,16 @@ bool S2Plugin::SortFilterProxyModelStringsTable::filterAcceptsRow(int sourceRow, } bool isNumeric = false; - auto enteredID = mFilterString.toUInt(&isNumeric); + auto enteredID = mFilterString.toInt(&isNumeric); if (isNumeric) { return enteredID == sourceRow; } else { - auto& str = model->data(model->index(sourceRow, gsColStringValue), Qt::DisplayRole).toString(); + auto str = model->data(model->index(sourceRow, gsColStringValue), Qt::DisplayRole).toString(); return str.contains(mFilterString, Qt::CaseInsensitive); } - return false; } void S2Plugin::SortFilterProxyModelStringsTable::setFilterString(const QString& f) diff --git a/src/QtHelpers/TableViewLogger.cpp b/src/QtHelpers/TableViewLogger.cpp index 7ba02753..6114526b 100644 --- a/src/QtHelpers/TableViewLogger.cpp +++ b/src/QtHelpers/TableViewLogger.cpp @@ -51,9 +51,9 @@ void S2Plugin::TableViewLogger::dropEvent(QDropEvent* event) auto fieldsModel = qobject_cast(model()); - auto data = event->mimeData()->data("spelunky/memoryfield"); + auto dropData = event->mimeData()->data("spelunky/memoryfield"); auto codec = QTextCodec::codecForName("UTF-8"); - auto str = codec->toUnicode(data); + auto str = codec->toUnicode(dropData); auto j = nlohmann::json::parse(str.toStdString()); diff --git a/src/QtHelpers/TreeViewMemoryFields.cpp b/src/QtHelpers/TreeViewMemoryFields.cpp index 91f23707..11de3066 100644 --- a/src/QtHelpers/TreeViewMemoryFields.cpp +++ b/src/QtHelpers/TreeViewMemoryFields.cpp @@ -579,13 +579,13 @@ void S2Plugin::TreeViewMemoryFields::updateRow(int row, std::optional { std::stringstream ss; uint8_t counter = 0; - for (int x = size - 1; x >= 0; --x) + for (uint8_t x = size - 1;; --x) { if (counter % 4 == 0) { ss << (x + 1) << ": "; } - if ((value & (1 << x)) == (1 << x)) + if ((value & (1u << x)) == (1u << x)) { ss << "Y "; } @@ -594,6 +594,8 @@ void S2Plugin::TreeViewMemoryFields::updateRow(int row, std::optional ss << "N "; } counter++; + if (x == 0) + break; } return ss; }; @@ -924,7 +926,7 @@ void S2Plugin::TreeViewMemoryFields::updateRow(int row, std::optional }; auto flagIndex = itemField->data(gsRoleFlagIndex).toUInt(); - auto mask = (1 << (flagIndex - 1)); + uint mask = (1 << (flagIndex - 1)); auto flagRef = qvariant_cast(itemField->parent()->data(gsRoleRefName)); auto flagName = Configuration::get()->flagTitle(flagRef, flagIndex); @@ -2365,8 +2367,8 @@ void S2Plugin::TreeViewMemoryFields::dragMoveEvent(QDragMoveEvent* event) void S2Plugin::TreeViewMemoryFields::dropEvent(QDropEvent* event) { - auto data = event->mimeData()->data("spelunky/entityoffset"); - emit entityOffsetDropped(data.toULongLong()); + auto dropData = event->mimeData()->data("spelunky/entityoffset"); + emit entityOffsetDropped(dropData.toULongLong()); event->acceptProposedAction(); } diff --git a/src/QtHelpers/WidgetSamplesPlot.cpp b/src/QtHelpers/WidgetSamplesPlot.cpp index 99dce46a..9a35ae57 100644 --- a/src/QtHelpers/WidgetSamplesPlot.cpp +++ b/src/QtHelpers/WidgetSamplesPlot.cpp @@ -35,8 +35,8 @@ void S2Plugin::WidgetSamplesPlot::paintEvent(QPaintEvent* event) auto [lowerBound, upperBound] = mLogger->sampleBounds(field); const auto& samples = mLogger->samplesForField(field.uuid); - size_t x = 0; - uint16_t mappedY; + int x = 0; + uint16_t mappedY = 0; uint16_t prevX = 0, prevY = 0; bool first = true; for (const auto& sample : samples) @@ -129,8 +129,8 @@ void S2Plugin::WidgetSamplesPlot::paintEvent(QPaintEvent* event) painter.setPen(Qt::cyan); painter.drawLine(mCurrentMousePos.x(), 0, mCurrentMousePos.x(), paintBounds.height()); - int64_t sampleIndex = mCurrentMousePos.x() - gsPlotMargin; - if (sampleIndex >= 0 && sampleIndex < mLogger->sampleCount()) + int64_t sampleIndex = static_cast(mCurrentMousePos.x()) - gsPlotMargin; + if (sampleIndex >= 0 && sampleIndex < static_cast(mLogger->sampleCount())) { auto scrollArea = qobject_cast(parent()->parent()); auto drawOnLeftSide = (scrollArea->mapFromGlobal(QCursor::pos()).x() > (scrollArea->width() / 2)); diff --git a/src/QtHelpers/WidgetSpelunkyLevel.cpp b/src/QtHelpers/WidgetSpelunkyLevel.cpp index 2c5e3e37..f02aa7c6 100644 --- a/src/QtHelpers/WidgetSpelunkyLevel.cpp +++ b/src/QtHelpers/WidgetSpelunkyLevel.cpp @@ -34,7 +34,7 @@ void S2Plugin::WidgetSpelunkyLevel::paintEvent(QPaintEvent* event) auto entityUID = Script::Memory::ReadDword(entity + 56); auto entityType = Script::Memory::ReadDword(entityDB + 20); auto entityMask = Script::Memory::ReadDword(entityDB + 24); - auto entityOverlay = Script::Memory::ReadQword(entity + 16); + // auto entityOverlay = Script::Memory::ReadQword(entity + 16); auto foundInIDs = (mEntityIDsToPaint.count(entityType) == 1); auto foundInUIDs = (mEntityUIDsToPaint.count(entityUID) == 1); diff --git a/src/QtHelpers/WidgetSpelunkyRooms.cpp b/src/QtHelpers/WidgetSpelunkyRooms.cpp index 76dfc186..6f3120e4 100644 --- a/src/QtHelpers/WidgetSpelunkyRooms.cpp +++ b/src/QtHelpers/WidgetSpelunkyRooms.cpp @@ -33,13 +33,13 @@ void S2Plugin::WidgetSpelunkyRooms::paintEvent(QPaintEvent* event) QPainter painter(this); painter.setRenderHint(QPainter::HighQualityAntialiasing, true); painter.setFont(mFont); - - auto rect = QRectF(QPointF(0, 0), sizeHint()); - rect.adjust(0, 0, -0.5, -0.5); - painter.setBrush(Qt::white); - painter.setPen(QPen(Qt::darkGray, 1)); - painter.drawRect(rect); - + { + auto rect = QRectF(QPointF(0, 0), sizeHint()); + rect.adjust(0, 0, -0.5, -0.5); + painter.setBrush(Qt::white); + painter.setPen(QPen(Qt::darkGray, 1)); + painter.drawRect(rect); + } mToolTipRects.clear(); painter.setBrush(Qt::black); uint32_t x = gsMarginHor; @@ -53,7 +53,6 @@ void S2Plugin::WidgetSpelunkyRooms::paintEvent(QPaintEvent* event) auto buffer = std::array(); Script::Memory::Read(mOffset, buffer.data(), bufferSize, nullptr); - uint32_t index = 0; for (auto counter = 0; counter < bufferSize; ++counter) { if (mIsMetaData) @@ -62,8 +61,7 @@ void S2Plugin::WidgetSpelunkyRooms::paintEvent(QPaintEvent* event) { painter.setPen(QPen(Qt::white, 1)); painter.setBrush(Qt::black); - auto rect = QRect(x, y - mTextAdvance.height() + 5, mTextAdvance.width(), mTextAdvance.height() - 2); - painter.drawRect(rect); + painter.drawRect(QRect(x, y - mTextAdvance.height() + 5, mTextAdvance.width(), mTextAdvance.height() - 2)); } else { diff --git a/src/Views/ViewEntities.cpp b/src/Views/ViewEntities.cpp index f700c4a3..6944191e 100644 --- a/src/Views/ViewEntities.cpp +++ b/src/Views/ViewEntities.cpp @@ -103,7 +103,7 @@ void S2Plugin::ViewEntities::refreshEntities() mMainTreeView->clear(); bool isUIDlookupSuccess = false; - uint enteredUID; + uint enteredUID = 0; if (!mFilterLineEdit->text().isEmpty()) { enteredUID = mFilterLineEdit->text().toUInt(&isUIDlookupSuccess, 0); @@ -145,7 +145,7 @@ void S2Plugin::ViewEntities::refreshEntities() auto ent_list = Script::Memory::ReadQword(layer0 + 0x8); auto uid_list = Script::Memory::ReadQword(layer0 + 0x10); bool found_uid = false; - for (int idx = 0; idx < layer0Count; ++idx) + for (uint idx = 0; idx < layer0Count; ++idx) { auto uid = Script::Memory::ReadDword(uid_list + idx * sizeof(uint32_t)); if (enteredUID == uid) @@ -159,7 +159,7 @@ void S2Plugin::ViewEntities::refreshEntities() uid_list = Script::Memory::ReadQword(layer1 + 0x10); if (found_uid == false) { - for (int idx = 0; idx < layer1Count; ++idx) + for (uint idx = 0; idx < layer1Count; ++idx) { auto uid = Script::Memory::ReadDword(uid_list + idx * sizeof(uint32_t)); if (enteredUID == uid) diff --git a/src/Views/ViewEntityDB.cpp b/src/Views/ViewEntityDB.cpp index 7233175c..b05ca60d 100644 --- a/src/Views/ViewEntityDB.cpp +++ b/src/Views/ViewEntityDB.cpp @@ -230,7 +230,7 @@ void S2Plugin::ViewEntityDB::populateComparisonTableWidget() auto& entityList = Configuration::get()->entityList(); size_t row = 0; - for (auto x = 1; x <= entityList.highestID(); ++x) + for (uint x = 1; x <= entityList.highestID(); ++x) { if (!entityList.isValidID(x)) { diff --git a/src/Views/ViewStdMap.cpp b/src/Views/ViewStdMap.cpp index d7b1bc92..f8f54936 100644 --- a/src/Views/ViewStdMap.cpp +++ b/src/Views/ViewStdMap.cpp @@ -163,7 +163,7 @@ void S2Plugin::ViewStdMap::refreshMapContents() parent_field.name = "obj_" + std::to_string(x); parent = mMainTreeView->addMemoryField(parent_field, parent_field.name, 0, 0); - auto key_StandardItem = mMainTreeView->addMemoryField(key_field, key_field.name, _cur.key_ptr(), 0, parent); + mMainTreeView->addMemoryField(key_field, key_field.name, _cur.key_ptr(), 0, parent); if (mMapValueTypeSize == 0) // StdSet continue; diff --git a/src/Views/ViewTextureDB.cpp b/src/Views/ViewTextureDB.cpp index d0f63a20..736efa35 100644 --- a/src/Views/ViewTextureDB.cpp +++ b/src/Views/ViewTextureDB.cpp @@ -231,15 +231,15 @@ void S2Plugin::ViewTextureDB::populateComparisonTableWidget() auto& textureDB = Spelunky2::get()->get_TextureDB(); size_t row = 0; - for (auto& [textureID, data] : textureDB.textures()) + for (auto& [textureID, textureData] : textureDB.textures()) { auto item0 = new QTableWidgetItem(QString::asprintf("%03d", textureID)); item0->setTextAlignment(Qt::AlignCenter); mCompareTableWidget->setItem(row, 0, item0); - auto name = QString("Texture %1 (%2)").arg(textureID).arg(QString::fromStdString(data.first)); + auto name = QString("Texture %1 (%2)").arg(textureID).arg(QString::fromStdString(textureData.first)); mCompareTableWidget->setItem(row, 1, new QTableWidgetItem(QString("%1").arg(name))); - auto [caption, value] = DB::valueForField(comboboxData, data.second); + auto [caption, value] = DB::valueForField(comboboxData, textureData.second); auto item = new TableWidgetItemNumeric(caption); item->setData(Qt::UserRole, value); mCompareTableWidget->setItem(row, 2, item); @@ -259,9 +259,9 @@ void S2Plugin::ViewTextureDB::populateComparisonTreeWidget() std::unordered_map rootValues; std::unordered_map> groupedValues; // valueString -> set - for (auto& [textureID, data] : textureDB.textures()) + for (auto& [textureID, textureData] : textureDB.textures()) { - auto [caption, value] = DB::valueForField(comboboxData, data.second); + auto [caption, value] = DB::valueForField(comboboxData, textureData.second); auto captionStr = caption.toStdString(); rootValues[captionStr] = value; diff --git a/src/Views/ViewToolbar.cpp b/src/Views/ViewToolbar.cpp index b6b6ae93..0c270c7f 100644 --- a/src/Views/ViewToolbar.cpp +++ b/src/Views/ViewToolbar.cpp @@ -1,12 +1,5 @@ #include "Views/ViewToolbar.h" #include "Configuration.h" -#include "Data/CharacterDB.h" -#include "Data/EntityDB.h" -#include "Data/ParticleDB.h" -#include "Data/State.h" -#include "Data/StringsTable.h" -#include "Data/TextureDB.h" -#include "Data/VirtualTableLookup.h" #include "Spelunky2.h" #include "Views/ViewCharacterDB.h" #include "Views/ViewEntities.h" diff --git a/src/Views/ViewVirtualFunctions.cpp b/src/Views/ViewVirtualFunctions.cpp index f4736dc9..155d2b8d 100644 --- a/src/Views/ViewVirtualFunctions.cpp +++ b/src/Views/ViewVirtualFunctions.cpp @@ -39,8 +39,7 @@ void S2Plugin::ViewVirtualFunctions::initializeUI() mTopLayout->addWidget(jumpBtn); mTopLayout->addStretch(); - mHTMLDelegate = std::make_unique(); - mHTMLDelegate->setCenterVertically(true); + mHTMLDelegate.setCenterVertically(true); mFunctionsTable = new QTableView(this); mSortFilterProxy->setSourceModel(mModel.get()); @@ -48,7 +47,7 @@ void S2Plugin::ViewVirtualFunctions::initializeUI() mFunctionsTable->setAlternatingRowColors(true); mFunctionsTable->setSelectionBehavior(QAbstractItemView::SelectRows); mFunctionsTable->horizontalHeader()->setStretchLastSection(true); - mFunctionsTable->setItemDelegate(mHTMLDelegate.get()); + mFunctionsTable->setItemDelegate(&mHTMLDelegate); mFunctionsTable->setColumnWidth(gsColFunctionIndex, 50); mFunctionsTable->setColumnWidth(gsColFunctionTableAddress, 130); mFunctionsTable->setColumnWidth(gsColFunctionFunctionAddress, 130); diff --git a/src/Views/ViewVirtualTable.cpp b/src/Views/ViewVirtualTable.cpp index b106664d..4bd7b982 100644 --- a/src/Views/ViewVirtualTable.cpp +++ b/src/Views/ViewVirtualTable.cpp @@ -17,13 +17,13 @@ #include #include -S2Plugin::ViewVirtualTable::ViewVirtualTable(ViewToolbar* toolbar, QWidget* parent) : QWidget(parent), mToolbar(toolbar) +S2Plugin::ViewVirtualTable::ViewVirtualTable(QWidget* parent) : QWidget(parent) { mHTMLDelegate = std::make_unique(); mModel = std::make_unique(this); mSortFilterProxy = std::make_unique(this); - mGatherModel = std::make_unique(toolbar, this); - mGatherSortFilterProxy = std::make_unique(toolbar, this); + mGatherModel = std::make_unique(this); + mGatherSortFilterProxy = std::make_unique(this); mGatherSortFilterProxy->sort(gsColGatherID); initializeUI(); @@ -248,7 +248,7 @@ void S2Plugin::ViewVirtualTable::tableEntryClicked(const QModelIndex& index) void S2Plugin::ViewVirtualTable::detectEntities() { - mModel->detectEntities(mToolbar); + mModel->detectEntities(); } void S2Plugin::ViewVirtualTable::showImportedSymbolsCheckBoxStateChanged(int state)