Use std::optional instead of sentinel values for absent data
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user