Use std::optional instead of sentinel values for absent data

This commit is contained in:
2026-07-20 20:27:20 +02:00
parent 1cdafb7bcd
commit 9622fa4345
32 changed files with 228 additions and 209 deletions

View File

@@ -47,7 +47,7 @@ public:
struct CellInfo
{
bool buildable;
int moduleIndex; // -1 if empty
std::optional<int> moduleIndex; // nullopt if empty
};
private:
@@ -69,7 +69,12 @@ private:
std::vector<PlacedModule> m_placedModules;
std::vector<std::vector<CellInfo>> m_grid;
int m_activeModuleIndex; // -1 = remove mode, -2 = no selection
// The module to place, as an index into config modules; nullopt when no
// module is selected for placement. m_removeMode is a separate mode in which
// clicking a cell removes the module there (mutually exclusive with a
// selected module).
std::optional<int> m_activeModuleIndex;
bool m_removeMode = false;
Rotation m_currentRotation;
std::vector<QPushButton*> m_moduleButtons;