Added "switch" functionality to plugin SIMU message handler.

This commit is contained in:
Jason Watkins
2015-05-01 14:48:33 -07:00
parent 7b462b5f78
commit 1ee3f85b23

View File

@@ -496,28 +496,51 @@ namespace XPC
void MessageHandlers::HandleSimu(Message& msg) void MessageHandlers::HandleSimu(Message& msg)
{ {
// Update log // Update log
#if LOG_VERBOSITY > 0 #if LOG_VERBOSITY > 1
Log::FormatLine("[SIMU] Message Received (Conn %i)", connection.id); Log::FormatLine("[SIMU] Message Received (Conn %i)", connection.id);
#endif #endif
const unsigned char* buffer = msg.GetBuffer(); char v = msg.GetBuffer()[5];
if (v < 0 || v > 2)
// Set DREF
int value[20];
for (int i = 0; i < 20; ++i)
{ {
value[i] = buffer[5]; #if LOG_VERBOSITY > 0
Log::FormatLine("[SIMU] ERROR: Invalid argument: %i", v);
return;
#endif
} }
DataManager::Set(DREF::Pause, value, 20);
int value[20];
#if LOG_VERBOSITY > 2 if (v == 2)
if (buffer[5] == 0)
{ {
Log::FormatLine("[SIMU] Simulation Resumed (Conn %i)", connection.id); DataManager::GetIntArray(DREF::Pause, value, 20);
for (int i = 0; i < 20; ++i)
{
value[i] = value[i] ? 0 : 1;
}
} }
else else
{ {
Log::FormatLine("[SIMU] Simulation Paused (Conn %i)", connection.id); for (int i = 0; i < 20; ++i)
{
value[i] = v;
}
}
// Set DREF
DataManager::Set(DREF::Pause, value, 20);
#if LOG_VERBOSITY > 2
switch (v)
{
case 0:
Log::WriteLine("[SIMU] Simulation Resumed");
break;
case 1:
Log::WriteLine("[SIMU] Simulation Paused");
break;
case 2:
Log::WriteLine("[SIMU] Simulation switched.");
break;
} }
#endif #endif
} }