Open
Description
- Allocates a new string on every call.
- Uses if condition instead of switch case. Unclear if the compiler will make it nice.
AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
{
#define CHECK_IF(x) if (t == x) { return #x; }
AsciiString commandName = "UnknownMessage";
if (t >= GameMessage::MSG_COUNT)
{
commandName = "Invalid command";
}
CHECK_IF(MSG_INVALID)
CHECK_IF(MSG_FRAME_TICK)
CHECK_IF(MSG_RAW_MOUSE_BEGIN)
CHECK_IF(MSG_RAW_MOUSE_POSITION)
CHECK_IF(MSG_RAW_MOUSE_LEFT_BUTTON_DOWN)
CHECK_IF(MSG_RAW_MOUSE_LEFT_DOUBLE_CLICK)
CHECK_IF(MSG_RAW_MOUSE_LEFT_BUTTON_UP)
CHECK_IF(MSG_RAW_MOUSE_LEFT_CLICK)
CHECK_IF(MSG_RAW_MOUSE_LEFT_DRAG)
...
// hundreds more