Skip to content

Commit

Permalink
add /W4 flag and fix some mistakes revealed by it
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed Mar 4, 2024
1 parent b78b8f3 commit b40dbd1
Show file tree
Hide file tree
Showing 51 changed files with 130 additions and 148 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/Data/CharacterDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ namespace S2Plugin
CharacterDB(const CharacterDB&) = delete;
CharacterDB& operator=(const CharacterDB&) = delete;

friend class Spelunky2;
friend struct Spelunky2;
};
} // namespace S2Plugin
2 changes: 1 addition & 1 deletion include/Data/EntityDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ namespace S2Plugin
private:
uintptr_t ptr{0};

friend class Spelunky2;
friend struct Spelunky2;
};
} // namespace S2Plugin
2 changes: 1 addition & 1 deletion include/Data/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace S2Plugin
{
struct ItemModelLoggerFields;
class ItemModelLoggerFields;
enum class MemoryFieldType;

struct LoggerField
Expand Down
2 changes: 1 addition & 1 deletion include/Data/ParticleDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ namespace S2Plugin
private:
uintptr_t ptr{0};

friend class Spelunky2;
friend struct Spelunky2;
};
} // namespace S2Plugin
2 changes: 1 addition & 1 deletion include/Data/StringsTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion include/Data/TextureDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ namespace S2Plugin
TextureDB(const TextureDB&) = delete;
TextureDB& operator=(const TextureDB&) = delete;

friend class Spelunky2;
friend struct Spelunky2;
};
} // namespace S2Plugin
6 changes: 3 additions & 3 deletions include/Data/VirtualTableLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace S2Plugin
{
return mOffsetToTableEntries.at(tableOffset);
}
std::unordered_set<uint32_t> tableOffsetForFunctionAddress(size_t functionAddress) const;
std::unordered_set<size_t> tableOffsetForFunctionAddress(size_t functionAddress) const;
VirtualTableEntry findPrecedingEntryWithSymbols(size_t tableOffset) const;
size_t tableAddressForEntry(const VirtualTableEntry& entry) const;

Expand All @@ -50,14 +50,14 @@ namespace S2Plugin
}

private:
std::unordered_map<uint32_t, VirtualTableEntry> mOffsetToTableEntries;
std::unordered_map<size_t, VirtualTableEntry> mOffsetToTableEntries;
uintptr_t mTableStartAddress{0};

VirtualTableLookup() = default;
~VirtualTableLookup(){};
VirtualTableLookup(const VirtualTableLookup&) = delete;
VirtualTableLookup& operator=(const VirtualTableLookup&) = delete;

friend class Spelunky2;
friend struct Spelunky2;
};
} // namespace S2Plugin
4 changes: 2 additions & 2 deletions include/QtHelpers/DialogEditState.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
namespace S2Plugin
{
enum class MemoryFieldType;
struct ItemModelStates;
struct SortFilterProxyModelStates;
class ItemModelStates;
class SortFilterProxyModelStates;

class DialogEditState : public QDialog
{
Expand Down
10 changes: 4 additions & 6 deletions include/QtHelpers/ItemModelGatherVirtualData.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include <QAbstractItemModel>
#include <QSortFilterProxyModel>
#include <cstdint>
#include <string>

namespace S2Plugin
{
struct ViewToolbar;

static const uint8_t gsColGatherID = 0;
static const uint8_t gsColGatherName = 1;
static const uint8_t gsColGatherVirtualTableOffset = 2;
Expand Down Expand Up @@ -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;
Expand All @@ -57,7 +57,6 @@ namespace S2Plugin
bool isEntryCompleted(size_t index) const;

private:
ViewToolbar* mToolbar;
std::vector<GatheredDataEntry> mEntries;

void parseJSON();
Expand All @@ -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;
};

Expand Down
2 changes: 1 addition & 1 deletion include/QtHelpers/ItemModelVirtualFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace S2Plugin
{
struct ViewToolbar;
class ViewToolbar;

static const uint8_t gsColFunctionIndex = 0;
static const uint8_t gsColFunctionTableAddress = 1;
Expand Down
4 changes: 2 additions & 2 deletions include/QtHelpers/ItemModelVirtualTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace S2Plugin
{
struct ViewToolbar;
class ViewToolbar;

static const uint8_t gsColTableOffset = 0;
static const uint8_t gsColCodeAddress = 1;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/QtHelpers/TreeViewMemoryFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace S2Plugin
{
struct ViewToolbar;
class ViewToolbar;
struct MemoryField;
class StyledItemDelegateHTML;

Expand Down
4 changes: 2 additions & 2 deletions include/QtHelpers/WidgetSpelunkyLevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t, QColor> mEntityMasksToPaint;
std::unordered_map<uint32_t, QColor> mEntityIDsToPaint;
Expand Down
4 changes: 2 additions & 2 deletions include/QtHelpers/WidgetSpelunkyRooms.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace S2Plugin
{
struct ViewToolbar;
class ViewToolbar;
struct ToolTipRect;

class WidgetSpelunkyRooms : public QWidget
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewCharacterDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

namespace S2Plugin
{
struct TreeViewMemoryFields;
struct ViewToolbar;
class TreeViewMemoryFields;
class ViewToolbar;

class ViewCharacterDB : public QWidget
{
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewEntities.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace S2Plugin
{
struct ViewToolbar;
struct TreeViewMemoryFields;
class ViewToolbar;
class TreeViewMemoryFields;

enum class MASK : uint32_t
{
Expand Down
11 changes: 5 additions & 6 deletions include/Views/ViewEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewEntityDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

namespace S2Plugin
{
struct ViewToolbar;
struct TreeViewMemoryFields;
class ViewToolbar;
class TreeViewMemoryFields;

class ViewEntityDB : public QWidget
{
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewGameManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace S2Plugin
{
struct ViewToolbar;
struct TreeViewMemoryFields;
class ViewToolbar;
class TreeViewMemoryFields;

class ViewGameManager : public QWidget
{
Expand Down
6 changes: 3 additions & 3 deletions include/Views/ViewJournalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace S2Plugin
{
struct ViewToolbar;
struct TreeViewMemoryFields;
struct JournalPage;
class ViewToolbar;
class TreeViewMemoryFields;
class JournalPage;

class ViewJournalPage : public QWidget
{
Expand Down
6 changes: 3 additions & 3 deletions include/Views/ViewLevelGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace S2Plugin
{
struct ViewToolbar;
struct TreeViewMemoryFields;
struct WidgetSpelunkyRooms;
class ViewToolbar;
class TreeViewMemoryFields;
class WidgetSpelunkyRooms;

class ViewLevelGen : public QWidget
{
Expand Down
10 changes: 5 additions & 5 deletions include/Views/ViewLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewOnline.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace S2Plugin
{
struct ViewToolbar;
struct TreeViewMemoryFields;
class ViewToolbar;
class TreeViewMemoryFields;

class ViewOnline : public QWidget
{
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewParticleDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

namespace S2Plugin
{
struct ViewToolbar;
struct TreeViewMemoryFields;
class ViewToolbar;
class TreeViewMemoryFields;

class ViewParticleDB : public QWidget
{
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewSaveGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace S2Plugin
{
struct ViewToolbar;
struct TreeViewMemoryFields;
class ViewToolbar;
class TreeViewMemoryFields;

class ViewSaveGame : public QWidget
{
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewState.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace S2Plugin
{
struct ViewToolbar;
struct TreeViewMemoryFields;
class ViewToolbar;
class TreeViewMemoryFields;

class ViewState : public QWidget
{
Expand Down
5 changes: 2 additions & 3 deletions include/Views/ViewStdMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

namespace S2Plugin
{
struct MemoryField;
struct ViewToolbar;
struct TreeViewMemoryFields;
class ViewToolbar;
class TreeViewMemoryFields;

class ViewStdMap : public QWidget
{
Expand Down
5 changes: 2 additions & 3 deletions include/Views/ViewStdVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

namespace S2Plugin
{
struct ViewToolbar;
struct MemoryField;
struct TreeViewMemoryFields;
class ViewToolbar;
class TreeViewMemoryFields;

class ViewStdVector : public QWidget
{
Expand Down
4 changes: 2 additions & 2 deletions include/Views/ViewTextureDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

namespace S2Plugin
{
struct ViewToolbar;
struct TreeViewMemoryFields;
class ViewToolbar;
class TreeViewMemoryFields;

class ViewTextureDB : public QWidget
{
Expand Down
Loading

0 comments on commit b40dbd1

Please sign in to comment.