1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Close #13630: Refactor DATATYPE into strong enum

This commit is contained in:
Tulio Leao
2020-12-23 00:54:01 -03:00
parent b7f70ab20b
commit d6ebdded6b
2 changed files with 15 additions and 15 deletions

View File

@@ -22,7 +22,7 @@ Intent* Intent::putExtra(uint32_t key, uint32_t value)
{
IntentData data = {};
data.intVal.unsignedInt = value;
data.type = IntentData::DT_INT;
data.type = IntentData::DataType::Int;
_Data.insert(std::make_pair(key, data));
@@ -33,7 +33,7 @@ Intent* Intent::putExtra(uint32_t key, void* value)
{
IntentData data = {};
data.pointerVal = value;
data.type = IntentData::DT_POINTER;
data.type = IntentData::DataType::Pointer;
_Data.insert(std::make_pair(key, data));
@@ -44,7 +44,7 @@ Intent* Intent::putExtra(uint32_t key, int32_t value)
{
IntentData data = {};
data.intVal.signedInt = value;
data.type = IntentData::DT_INT;
data.type = IntentData::DataType::Int;
_Data.insert(std::make_pair(key, data));
@@ -55,7 +55,7 @@ Intent* Intent::putExtra(uint32_t key, std::string value)
{
IntentData data = {};
data.stringVal = std::move(value);
data.type = IntentData::DT_STRING;
data.type = IntentData::DataType::String;
_Data.insert(std::make_pair(key, data));
@@ -66,7 +66,7 @@ Intent* Intent::putExtra(uint32_t key, close_callback value)
{
IntentData data = {};
data.closeCallbackVal = value;
data.type = IntentData::DT_CLOSE_CALLBACK;
data.type = IntentData::DataType::CloseCallback;
_Data.insert(std::make_pair(key, data));
@@ -86,7 +86,7 @@ void* Intent::GetPointerExtra(uint32_t key) const
}
auto data = _Data.at(key);
openrct2_assert(data.type == IntentData::DT_POINTER, "Actual type doesn't match requested type");
openrct2_assert(data.type == IntentData::DataType::Pointer, "Actual type doesn't match requested type");
return static_cast<void*>(data.pointerVal);
}
@@ -98,7 +98,7 @@ uint32_t Intent::GetUIntExtra(uint32_t key) const
}
auto data = _Data.at(key);
openrct2_assert(data.type == IntentData::DT_INT, "Actual type doesn't match requested type");
openrct2_assert(data.type == IntentData::DataType::Int, "Actual type doesn't match requested type");
return data.intVal.unsignedInt;
}
@@ -110,7 +110,7 @@ int32_t Intent::GetSIntExtra(uint32_t key) const
}
auto data = _Data.at(key);
openrct2_assert(data.type == IntentData::DT_INT, "Actual type doesn't match requested type");
openrct2_assert(data.type == IntentData::DataType::Int, "Actual type doesn't match requested type");
return data.intVal.signedInt;
}
@@ -122,7 +122,7 @@ std::string Intent::GetStringExtra(uint32_t key) const
}
auto data = _Data.at(key);
openrct2_assert(data.type == IntentData::DT_STRING, "Actual type doesn't match requested type");
openrct2_assert(data.type == IntentData::DataType::String, "Actual type doesn't match requested type");
return data.stringVal;
}
@@ -134,6 +134,6 @@ close_callback Intent::GetCloseCallbackExtra(uint32_t key) const
}
auto data = _Data.at(key);
openrct2_assert(data.type == IntentData::DT_CLOSE_CALLBACK, "Actual type doesn't match requested type");
openrct2_assert(data.type == IntentData::DataType::CloseCallback, "Actual type doesn't match requested type");
return data.closeCallbackVal;
}

View File

@@ -17,12 +17,12 @@
struct IntentData
{
enum DATATYPE
enum class DataType
{
DT_INT,
DT_STRING,
DT_POINTER,
DT_CLOSE_CALLBACK
Int,
String,
Pointer,
CloseCallback
} type;
union