some more static analyzer suggestions

This commit is contained in:
DarthArgus
2016-07-25 22:11:10 -07:00
parent 88888e4091
commit 814cf4f731
16 changed files with 3350 additions and 3456 deletions
@@ -30,7 +30,7 @@ namespace DataLintNamespace
typedef stdvector<std::string>::fwd StringList;
typedef std::pair<std::string, std::pair<DataLint::AssetType, StringList> > WarningPair;
typedef stdvector<WarningPair>::fwd WarningList;
typedef bool (*AssetFunction)(char const *);
typedef bool(*AssetFunction)(char const *);
bool ms_installed = false;
DataLint::AssetType m_currentAssetType = DataLint::AT_invalid;
@@ -80,7 +80,7 @@ void DataLint::install()
m_warningList = new WarningList();
m_warningList->reserve(4096);
m_assetStack = new StringList ();
m_assetStack = new StringList();
m_assetList = new StringPairList();
m_assetList->reserve(4096);
@@ -116,10 +116,10 @@ void DataLint::report()
// Server/client
FILE *assetErrorFileAll = fopen(dataLintErrorsAll.c_str(), "wt");
FILE *assetErrorFileAllFatal = fopen(dataLintErrorsAllFatal.c_str(), "wt");
FILE *assetErrorFileAllWarning = fopen(dataLintErrorsAllWarning.c_str(), "wt");
FILE *assetErrorFileObjectTemplate = fopen(dataLintErrorsAllObjectTemplate.c_str(), "wt");
FILE *assetErrorFileAll = fopen(dataLintErrorsAll.c_str(), "wt");
FILE *assetErrorFileAllFatal = fopen(dataLintErrorsAllFatal.c_str(), "wt");
FILE *assetErrorFileAllWarning = fopen(dataLintErrorsAllWarning.c_str(), "wt");
FILE *assetErrorFileObjectTemplate = fopen(dataLintErrorsAllObjectTemplate.c_str(), "wt");
// Client only
@@ -137,17 +137,17 @@ void DataLint::report()
if (m_mode == M_client)
{
assetErrorFileAppearance = fopen("DataLint_Errors_Appearance.txt", "wt");
assetErrorFileAppearance = fopen("DataLint_Errors_Appearance.txt", "wt");
assetErrorFileArrangementDescriptor = fopen("DataLint_Errors_ArrangementDescriptor.txt", "wt");
assetErrorFileLocalizedStringTable = fopen("DataLint_Errors_LocalizedStringTable.txt", "wt");
assetErrorFilePortalProperty = fopen("DataLint_Errors_PortalProperty.txt", "wt");
assetErrorFileShaderTemplate = fopen("DataLint_Errors_ShaderTemplate.txt", "wt");
assetErrorFileSkyBox = fopen("DataLint_Errors_SkyBox.txt", "wt");
assetErrorFileSlotDescriptor = fopen("DataLint_Errors_SlotDescriptor.txt", "wt");
assetErrorFileSoundTemplate = fopen("DataLint_Errors_SoundTemplate.txt", "wt");
assetErrorFileTerrain = fopen("DataLint_Errors_Terrain.txt", "wt");
assetErrorFileTexture = fopen("DataLint_Errors_Texture.txt", "wt");
assetErrorFileTextureRenderer = fopen("DataLint_Errors_TextureRenderer.txt", "wt");
assetErrorFileLocalizedStringTable = fopen("DataLint_Errors_LocalizedStringTable.txt", "wt");
assetErrorFilePortalProperty = fopen("DataLint_Errors_PortalProperty.txt", "wt");
assetErrorFileShaderTemplate = fopen("DataLint_Errors_ShaderTemplate.txt", "wt");
assetErrorFileSkyBox = fopen("DataLint_Errors_SkyBox.txt", "wt");
assetErrorFileSlotDescriptor = fopen("DataLint_Errors_SlotDescriptor.txt", "wt");
assetErrorFileSoundTemplate = fopen("DataLint_Errors_SoundTemplate.txt", "wt");
assetErrorFileTerrain = fopen("DataLint_Errors_Terrain.txt", "wt");
assetErrorFileTexture = fopen("DataLint_Errors_Texture.txt", "wt");
assetErrorFileTextureRenderer = fopen("DataLint_Errors_TextureRenderer.txt", "wt");
}
// Might want to think of a better way to keep track of the number of errors for each specific asset type.
@@ -205,104 +205,104 @@ void DataLint::report()
switch (warningListIter->second.first)
{
case AT_appearance:
{
if (m_mode == M_client)
{
writeError(assetErrorFileAppearance, *warningListIter, totalErrorCountAppearance);
}
}
break;
case AT_arrangementDescriptor:
{
if (m_mode == M_client)
{
writeError(assetErrorFileArrangementDescriptor, *warningListIter, totalErrorCountArrangementDescriptor);
}
}
break;
case AT_localizedStringTable:
{
if (m_mode == M_client)
{
writeError(assetErrorFileLocalizedStringTable, *warningListIter, totalErrorCountLocalizedStringTable);
}
}
break;
case AT_objectTemplate:
{
writeError(assetErrorFileObjectTemplate, *warningListIter, totalErrorCountObjectTemplate);
}
break;
case AT_portalProperty:
{
if (m_mode == M_client)
{
writeError(assetErrorFilePortalProperty, *warningListIter, totalErrorCountPortalProperty);
}
}
break;
case AT_shaderTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileShaderTemplate, *warningListIter, totalErrorCountShaderTemplate);
}
}
break;
case AT_skyBox:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSkyBox, *warningListIter, totalErrorCountSkyBox);
}
}
break;
case AT_slotDescriptor:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSlotDescriptor, *warningListIter, totalErrorCountSlotDescriptor);
}
}
break;
case AT_soundTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSoundTemplate, *warningListIter, totalErrorCountSoundTemplate);
}
}
break;
case AT_terrain:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTerrain, *warningListIter, totalErrorCountTerrain);
}
}
break;
case AT_texture:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTexture, *warningListIter, totalErrorCountTexture);
}
}
break;
case AT_textureRendererTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTextureRenderer, *warningListIter, totalErrorCountTextureRenderer);
}
}
break;
default:
{
DEBUG_REPORT_LOG_PRINT(true, ("DataLint::remove() - Unsupported asset type: %s", warningListIter->first.c_str()));
}
break;
case AT_appearance:
{
if (m_mode == M_client)
{
writeError(assetErrorFileAppearance, *warningListIter, totalErrorCountAppearance);
}
}
break;
case AT_arrangementDescriptor:
{
if (m_mode == M_client)
{
writeError(assetErrorFileArrangementDescriptor, *warningListIter, totalErrorCountArrangementDescriptor);
}
}
break;
case AT_localizedStringTable:
{
if (m_mode == M_client)
{
writeError(assetErrorFileLocalizedStringTable, *warningListIter, totalErrorCountLocalizedStringTable);
}
}
break;
case AT_objectTemplate:
{
writeError(assetErrorFileObjectTemplate, *warningListIter, totalErrorCountObjectTemplate);
}
break;
case AT_portalProperty:
{
if (m_mode == M_client)
{
writeError(assetErrorFilePortalProperty, *warningListIter, totalErrorCountPortalProperty);
}
}
break;
case AT_shaderTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileShaderTemplate, *warningListIter, totalErrorCountShaderTemplate);
}
}
break;
case AT_skyBox:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSkyBox, *warningListIter, totalErrorCountSkyBox);
}
}
break;
case AT_slotDescriptor:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSlotDescriptor, *warningListIter, totalErrorCountSlotDescriptor);
}
}
break;
case AT_soundTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileSoundTemplate, *warningListIter, totalErrorCountSoundTemplate);
}
}
break;
case AT_terrain:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTerrain, *warningListIter, totalErrorCountTerrain);
}
}
break;
case AT_texture:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTexture, *warningListIter, totalErrorCountTexture);
}
}
break;
case AT_textureRendererTemplate:
{
if (m_mode == M_client)
{
writeError(assetErrorFileTextureRenderer, *warningListIter, totalErrorCountTextureRenderer);
}
}
break;
default:
{
DEBUG_REPORT_LOG_PRINT(true, ("DataLint::remove() - Unsupported asset type: %s", warningListIter->first.c_str()));
}
break;
}
// Write the error to the master error file
@@ -483,13 +483,13 @@ std::string DataLintNamespace::formatErrorMessage(WarningPair &warningPair, int
}
}
sprintf(formatedError, "%3d Error: %s\n", currentErrorCount, assetError);
snprintf(formatedError, 4096, "%3d Error: %s\n", currentErrorCount, assetError);
result += formatedError;
}
if (lineOfCode)
{
sprintf(formatedError, " Line of Code: %s\n", lineOfCode);
snprintf(formatedError, 4096, " Line of Code: %s\n", lineOfCode);
result += formatedError;
}
@@ -499,10 +499,10 @@ std::string DataLintNamespace::formatErrorMessage(WarningPair &warningPair, int
{
std::string stackString(*stringListIter);
sprintf(text, " Loaded From: %s\n", stackString.c_str());
snprintf(text, 4096, " Loaded From: %s\n", stackString.c_str());
fixUpSlashes(text);
sprintf(formatedError, "%s", text);
snprintf(formatedError, 4096, "%s", text);
result += formatedError;
}
@@ -731,17 +731,17 @@ bool DataLintNamespace::isAnUnSupportedAsset(char const *text)
bool const textureRendererTemplateAsset = isATextureRendererTemplateAsset(text);
bool const result = !(appearanceAsset ||
arrangementDescriptorAsset ||
localizedStringAsset ||
objectTemplateAsset ||
portalPropertyAsset ||
shaderTemplateAsset ||
skyBoxAsset ||
slotDescriptorAsset ||
soundAsset ||
terrainAsset ||
textureAsset ||
textureRendererTemplateAsset);
arrangementDescriptorAsset ||
localizedStringAsset ||
objectTemplateAsset ||
portalPropertyAsset ||
shaderTemplateAsset ||
skyBoxAsset ||
slotDescriptorAsset ||
soundAsset ||
terrainAsset ||
textureAsset ||
textureRendererTemplateAsset);
return result;
}
@@ -777,75 +777,75 @@ DataLint::StringPairList DataLint::getList(AssetType const assetType)
{
switch (assetType)
{
case AT_appearance:
{
return DataLintNamespace::getList(8192, isAnAppearanceAsset);
}
break;
case AT_arrangementDescriptor:
{
return DataLintNamespace::getList(1024, isAnArrangementDescriptorAsset);
}
break;
case AT_localizedStringTable:
{
return DataLintNamespace::getList(1024, isALocalizedStringAsset);
}
break;
case AT_objectTemplate:
{
return DataLintNamespace::getList(8192, isAnObjectTemplateAsset);
}
break;
case AT_portalProperty:
{
return DataLintNamespace::getList(512, isAPortalProprtyAsset);
}
break;
case AT_shaderTemplate:
{
return DataLintNamespace::getList(4096, isAShaderTemplateAsset);
}
break;
case AT_skyBox:
{
return DataLintNamespace::getList(256, isASkyBoxAsset);
}
break;
case AT_slotDescriptor:
{
return DataLintNamespace::getList(1024, isASlotDescriptorAsset);
}
break;
case AT_soundTemplate:
{
return DataLintNamespace::getList(4096, isASoundAsset);
}
break;
case AT_terrain:
{
return DataLintNamespace::getList(32, isATerrainAsset);
}
break;
case AT_texture:
{
return DataLintNamespace::getList(8192, isATextureAsset);
}
break;
case AT_textureRendererTemplate:
{
return DataLintNamespace::getList(512, isATextureRendererTemplateAsset);
}
break;
case AT_unSupported:
{
return DataLintNamespace::getList(4096, isAnUnSupportedAsset);
}
break;
default:
{
DEBUG_FATAL(true, ("DataLint::getList() - Unknown list type."));
}
case AT_appearance:
{
return DataLintNamespace::getList(8192, isAnAppearanceAsset);
}
break;
case AT_arrangementDescriptor:
{
return DataLintNamespace::getList(1024, isAnArrangementDescriptorAsset);
}
break;
case AT_localizedStringTable:
{
return DataLintNamespace::getList(1024, isALocalizedStringAsset);
}
break;
case AT_objectTemplate:
{
return DataLintNamespace::getList(8192, isAnObjectTemplateAsset);
}
break;
case AT_portalProperty:
{
return DataLintNamespace::getList(512, isAPortalProprtyAsset);
}
break;
case AT_shaderTemplate:
{
return DataLintNamespace::getList(4096, isAShaderTemplateAsset);
}
break;
case AT_skyBox:
{
return DataLintNamespace::getList(256, isASkyBoxAsset);
}
break;
case AT_slotDescriptor:
{
return DataLintNamespace::getList(1024, isASlotDescriptorAsset);
}
break;
case AT_soundTemplate:
{
return DataLintNamespace::getList(4096, isASoundAsset);
}
break;
case AT_terrain:
{
return DataLintNamespace::getList(32, isATerrainAsset);
}
break;
case AT_texture:
{
return DataLintNamespace::getList(8192, isATextureAsset);
}
break;
case AT_textureRendererTemplate:
{
return DataLintNamespace::getList(512, isATextureRendererTemplateAsset);
}
break;
case AT_unSupported:
{
return DataLintNamespace::getList(4096, isAnUnSupportedAsset);
}
break;
default:
{
DEBUG_FATAL(true, ("DataLint::getList() - Unknown list type."));
}
}
return StringPairList();
@@ -904,4 +904,4 @@ void DataLint::setServerMode()
m_mode = M_server;
}
// ============================================================================
// ============================================================================
@@ -29,9 +29,9 @@ uint32 RemoteDebugServer::ms_inputTarget;
// ======================================================================
RemoteDebug::Channel::Channel(const std::string& name, Channel *parent)
: m_name(nullptr),
m_parent(parent)
RemoteDebug::Channel::Channel(const std::string& name, Channel *parent)
: m_name(nullptr),
m_parent(parent)
{
m_name = new std::string(name);
m_children = new NodeList;
@@ -42,7 +42,7 @@ RemoteDebug::Channel::Channel(const std::string& name, Channel *parent)
RemoteDebug::Channel::~Channel()
{
m_parent = nullptr;
if(m_name)
if (m_name)
{
delete m_name;
m_name = nullptr;
@@ -71,33 +71,32 @@ const std::string& RemoteDebug::Channel::name()
// ======================================================================
RemoteDebug::Variable::Variable(const std::string& name, void *memLoc, VARIABLE_TYPES type)
: m_memLoc(memLoc),
m_name(nullptr),
m_type(type)
: m_memLoc(memLoc),
m_name(nullptr),
m_type(type)
{
m_name = new std::string(name);
int32 i = 0;
float f = 0.0;
char s = '\0';
int32 b = 0;
switch(m_type)
switch (m_type)
{
case INT:
m_value.intValue = i;
break;
case INT:
m_value.intValue = i;
break;
case FLOAT:
m_value.floatValue = f;
break;
case FLOAT:
m_value.floatValue = f;
break;
case CSTRING:
m_value.stringValue = &s;
break;
case CSTRING:
m_value.stringValue = nullptr;
break;
case BOOL:
m_value.boolValue = b;
break;
case BOOL:
m_value.boolValue = b;
break;
}
}
@@ -105,10 +104,10 @@ RemoteDebug::Variable::Variable(const std::string& name, void *memLoc, VARIABLE_
RemoteDebug::Variable::~Variable()
{
if(m_type == CSTRING)
if (m_type == CSTRING)
delete m_value.stringValue;
if(m_name)
if (m_name)
{
delete m_name;
m_name = nullptr;
@@ -119,23 +118,23 @@ RemoteDebug::Variable::~Variable()
void RemoteDebug::Variable::setValue(VARIABLEVALUE v)
{
switch(m_type)
switch (m_type)
{
case INT:
m_value.intValue = v.intValue;
break;
case INT:
m_value.intValue = v.intValue;
break;
case FLOAT:
m_value.floatValue = v.floatValue;
break;
case FLOAT:
m_value.floatValue = v.floatValue;
break;
case CSTRING:
m_value.stringValue = v.stringValue;
break;
case CSTRING:
m_value.stringValue = v.stringValue;
break;
case BOOL:
m_value.boolValue = v.boolValue;
break;
case BOOL:
m_value.boolValue = v.boolValue;
break;
}
}
@@ -143,27 +142,27 @@ void RemoteDebug::Variable::setValue(VARIABLEVALUE v)
void RemoteDebug::Variable::setValue(void *memLoc)
{
if(memLoc)
if (memLoc)
{
switch(m_type)
switch (m_type)
{
case INT:
memcpy(&m_value.intValue, memLoc, sizeof(int32));
break;
case INT:
memcpy(&m_value.intValue, memLoc, sizeof(int32));
break;
case FLOAT:
memcpy(&m_value.floatValue, memLoc, sizeof(float));
break;
case FLOAT:
memcpy(&m_value.floatValue, memLoc, sizeof(float));
break;
case CSTRING:
delete[] m_value.stringValue;
m_value.stringValue = new char[strlen(static_cast<char *>(memLoc))];
strcpy(m_value.stringValue, const_cast<const char *>(static_cast<char *>(memLoc)));
break;
case CSTRING:
delete[] m_value.stringValue;
m_value.stringValue = new char[strlen(static_cast<char *>(memLoc))];
strcpy(m_value.stringValue, const_cast<const char *>(static_cast<char *>(memLoc)));
break;
case BOOL:
memcpy(&m_value.boolValue, memLoc, sizeof(int32));
break;
case BOOL:
memcpy(&m_value.boolValue, memLoc, sizeof(int32));
break;
}
}
}
@@ -193,8 +192,8 @@ void RemoteDebug::Variable::setType(VARIABLE_TYPES type)
void RemoteDebug::Variable::pushValue()
{
if (m_memLoc)
switch (m_type)
{
switch (m_type)
{
case BOOL:
case INT:
memcpy(m_memLoc, &m_value, sizeof(int32));
@@ -207,7 +206,7 @@ void RemoteDebug::Variable::pushValue()
case FLOAT:
memcpy(m_memLoc, &m_value, sizeof(float));
break;
}
}
}
// ----------------------------------------------------------------------
@@ -219,24 +218,24 @@ RemoteDebug::VARIABLE_TYPES RemoteDebug::Variable::type()
// ======================================================================
void RemoteDebugClient::install(RemoveFunction rf, OpenFunction of,
CloseFunction cf, SendFunction sf,
IsReadyFunction irf, NewStreamFunction ncf,
StreamMessageFunction cmf, NewVariableFunction nvf,
VariableValueFunction vvf, VariableTypeFunction vtf,
BeginFrameFunction bff, EndFrameFunction eff,
NewStaticViewFunction nsvf, LineFunction lf)
void RemoteDebugClient::install(RemoveFunction rf, OpenFunction of,
CloseFunction cf, SendFunction sf,
IsReadyFunction irf, NewStreamFunction ncf,
StreamMessageFunction cmf, NewVariableFunction nvf,
VariableValueFunction vvf, VariableTypeFunction vtf,
BeginFrameFunction bff, EndFrameFunction eff,
NewStaticViewFunction nsvf, LineFunction lf)
{
RemoteDebug::install(rf, of, cf, sf, irf);
ms_newStreamFunction = ncf;
ms_streamMessageFunction = cmf;
ms_newVariableFunction = nvf;
ms_variableValueFunction = vvf;
ms_variableTypeFunction = vtf;
ms_beginFrameFunction = bff;
ms_endFrameFunction = eff;
ms_newStaticViewFunction = nsvf;
ms_lineFunction = lf;
ms_newStreamFunction = ncf;
ms_streamMessageFunction = cmf;
ms_newVariableFunction = nvf;
ms_variableValueFunction = vvf;
ms_variableTypeFunction = vtf;
ms_beginFrameFunction = bff;
ms_endFrameFunction = eff;
ms_newStaticViewFunction = nsvf;
ms_lineFunction = lf;
}
// ----------------------------------------------------------------------
@@ -256,7 +255,7 @@ void RemoteDebugClient::receive(const unsigned char * const message, const uint3
//convert to a const char[] for conveinence
const char * const charMessage = reinterpret_cast<const char * const>(message);
//these values are known based on the packet protocol (see RemoteDebug.h for more info
const int sizeOfMessageType = 1;
const int sizeOfMessageType = 1;
const int sizeOfChannelNumber = 4;
const int sizeOfSizeofPayload = 4;
//this value is filled in from the packet
@@ -264,7 +263,7 @@ void RemoteDebugClient::receive(const unsigned char * const message, const uint3
//this value if filled in from the packet
uint32 sizeOfPayload = 0;
//get the message type
//get the message type
RemoteDebug::MESSAGE_TYPE type = static_cast<RemoteDebug::MESSAGE_TYPE>(charMessage[0]);
//grab the channelNumber
@@ -272,12 +271,12 @@ void RemoteDebugClient::receive(const unsigned char * const message, const uint3
//build the payload if needed
if (type == RemoteDebug::STREAM ||
type == RemoteDebug::STATIC_LINE ||
type == RemoteDebug::NEW_STATIC ||
type == RemoteDebug::NEW_STREAM ||
type == RemoteDebug::VARIABLE_TYPE ||
type == RemoteDebug::VARIABLE_VALUE ||
type == RemoteDebug::NEW_VARIABLE)
type == RemoteDebug::STATIC_LINE ||
type == RemoteDebug::NEW_STATIC ||
type == RemoteDebug::NEW_STREAM ||
type == RemoteDebug::VARIABLE_TYPE ||
type == RemoteDebug::VARIABLE_VALUE ||
type == RemoteDebug::NEW_VARIABLE)
{
memcpy(&sizeOfPayload, charMessage + sizeOfMessageType + sizeOfChannelNumber, sizeOfSizeofPayload);
memcpy(ms_buffer, charMessage + sizeOfMessageType + sizeOfChannelNumber + sizeOfSizeofPayload, sizeOfPayload);
@@ -287,81 +286,81 @@ void RemoteDebugClient::receive(const unsigned char * const message, const uint3
int32 t;
VARIABLE_TYPES varType;
switch(type)
switch (type)
{
case RemoteDebug::STREAM:
//see if we're redefining an already existing stream
if(ms_streamMessageFunction)
ms_streamMessageFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::STREAM:
//see if we're redefining an already existing stream
if (ms_streamMessageFunction)
ms_streamMessageFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::NEW_STREAM:
if (channelNumber < ms_nextStream)
return;
registerStream(ms_buffer);
if (ms_newStreamFunction)
ms_newStreamFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::NEW_STREAM:
if (channelNumber < ms_nextStream)
return;
registerStream(ms_buffer);
if (ms_newStreamFunction)
ms_newStreamFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::NEW_VARIABLE:
if (channelNumber < ms_nextVariable)
return;
//do not send value back to server (hence the "false")
registerVariable(ms_buffer, nullptr, BOOL, false);
if (ms_newVariableFunction)
ms_newVariableFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::NEW_VARIABLE:
if (channelNumber < ms_nextVariable)
return;
//do not send value back to server (hence the "false")
registerVariable(ms_buffer, nullptr, BOOL, false);
if (ms_newVariableFunction)
ms_newVariableFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::VARIABLE_TYPE:
t = atoi(ms_buffer);
varType = static_cast<VARIABLE_TYPES>(t);
(*ms_variableValues)[channelNumber]->setType(varType);
if(ms_variableTypeFunction)
ms_variableTypeFunction(channelNumber, varType);
break;
case RemoteDebug::VARIABLE_VALUE:
(*ms_variableValues)[channelNumber]->setValue(ms_buffer);
if(ms_variableValueFunction)
ms_variableValueFunction(channelNumber, ms_buffer);
break;
case RemoteDebug::VARIABLE_TYPE:
t = atoi(ms_buffer);
varType = static_cast<VARIABLE_TYPES>(t);
(*ms_variableValues)[channelNumber]->setType(varType);
if (ms_variableTypeFunction)
ms_variableTypeFunction(channelNumber, varType);
break;
case RemoteDebug::NEW_STATIC:
if (channelNumber < ms_nextStaticView)
return;
registerStaticView(ms_buffer);
if (ms_newStaticViewFunction)
ms_newStaticViewFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::VARIABLE_VALUE:
(*ms_variableValues)[channelNumber]->setValue(ms_buffer);
if (ms_variableValueFunction)
ms_variableValueFunction(channelNumber, ms_buffer);
break;
case RemoteDebug::STATIC_LINE:
if (ms_lineFunction)
ms_lineFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::NEW_STATIC:
if (channelNumber < ms_nextStaticView)
return;
registerStaticView(ms_buffer);
if (ms_newStaticViewFunction)
ms_newStaticViewFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::STATIC_BEGIN_FRAME:
if (ms_beginFrameFunction)
ms_beginFrameFunction(channelNumber);
break;
case RemoteDebug::STATIC_LINE:
if (ms_lineFunction)
ms_lineFunction(channelNumber, const_cast<const char*>(ms_buffer));
break;
case RemoteDebug::STATIC_END_FRAME:
if (ms_endFrameFunction)
ms_endFrameFunction(channelNumber);
break;
case RemoteDebug::STATIC_BEGIN_FRAME:
if (ms_beginFrameFunction)
ms_beginFrameFunction(channelNumber);
break;
case RemoteDebug::STREAM_SQUELCH:
case RemoteDebug::STREAM_UNSQUELCH:
case RemoteDebug::STATIC_SQUELCH:
case RemoteDebug::STATIC_UNSQUELCH:
case RemoteDebug::STATIC_INPUT_TARGET:
case RemoteDebug::STATIC_UP:
case RemoteDebug::STATIC_DOWN:
case RemoteDebug::STATIC_LEFT:
case RemoteDebug::STATIC_RIGHT:
case RemoteDebug::STATIC_ENTER:
case RemoteDebug::REQUEST_ALL_CHANNELS:
default:
break;
case RemoteDebug::STATIC_END_FRAME:
if (ms_endFrameFunction)
ms_endFrameFunction(channelNumber);
break;
case RemoteDebug::STREAM_SQUELCH:
case RemoteDebug::STREAM_UNSQUELCH:
case RemoteDebug::STATIC_SQUELCH:
case RemoteDebug::STATIC_UNSQUELCH:
case RemoteDebug::STATIC_INPUT_TARGET:
case RemoteDebug::STATIC_UP:
case RemoteDebug::STATIC_DOWN:
case RemoteDebug::STATIC_LEFT:
case RemoteDebug::STATIC_RIGHT:
case RemoteDebug::STATIC_ENTER:
case RemoteDebug::REQUEST_ALL_CHANNELS:
default:
break;
}
}
@@ -373,9 +372,9 @@ void RemoteDebugClient::receive(const unsigned char * const message, const uint3
void RemoteDebugClient::close()
{
DEBUG_FATAL(!ms_installed, ("remoteDebug not installed"));
//don't need to do anything if we're already closed
if(!ms_opened)
if (!ms_opened)
return;
if (ms_closeFunction)
@@ -402,9 +401,9 @@ void RemoteDebugClient::close()
ms_squelchedStream->clear();
ms_squelchedStatic->clear();
ms_nextStream = 0;
ms_nextStream = 0;
ms_nextStaticView = 0;
ms_nextVariable = 0;
ms_nextVariable = 0;
}
// ----------------------------------------------------------------------
@@ -419,9 +418,9 @@ void RemoteDebugClient::isReady()
// ======================================================================
void RemoteDebugServer::install(RemoveFunction rmf, OpenFunction of ,
CloseFunction cf , SendFunction sf,
IsReadyFunction irf)
void RemoteDebugServer::install(RemoveFunction rmf, OpenFunction of,
CloseFunction cf, SendFunction sf,
IsReadyFunction irf)
{
RemoteDebug::install(rmf, of, cf, sf, irf);
ms_inputTarget = 0;
@@ -452,7 +451,7 @@ void RemoteDebugServer::receive(const unsigned char * const message, const uint3
//convert to a const char[] for conveinence
const char * const charMessage = reinterpret_cast<const char * const>(message);
//these values are known based on the packet protocol (see RemoteDebug.h for more info
const int sizeOfMessageType = 1;
const int sizeOfMessageType = 1;
const int sizeOfChannelNumber = 4;
const int sizeOfSizeofPayload = 4;
//this value is filled in from the packet
@@ -460,7 +459,7 @@ void RemoteDebugServer::receive(const unsigned char * const message, const uint3
//this value if filled in from the packet
uint32 sizeOfPayload = 0;
//get the message type
//get the message type
RemoteDebug::MESSAGE_TYPE type = static_cast<RemoteDebug::MESSAGE_TYPE>(charMessage[0]);
//grab the channelNumber
@@ -468,92 +467,92 @@ void RemoteDebugServer::receive(const unsigned char * const message, const uint3
//build the payload if needed
if (type == RemoteDebug::STREAM ||
type == RemoteDebug::NEW_STREAM ||
type == RemoteDebug::VARIABLE_TYPE ||
type == RemoteDebug::VARIABLE_VALUE ||
type == RemoteDebug::NEW_VARIABLE)
type == RemoteDebug::NEW_STREAM ||
type == RemoteDebug::VARIABLE_TYPE ||
type == RemoteDebug::VARIABLE_VALUE ||
type == RemoteDebug::NEW_VARIABLE)
{
memcpy(&sizeOfPayload, charMessage + sizeOfMessageType + sizeOfChannelNumber, sizeOfSizeofPayload);
memcpy(ms_buffer, charMessage + sizeOfMessageType + sizeOfChannelNumber + sizeOfSizeofPayload, sizeOfPayload);
}
Variable* v = nullptr;
switch(type)
switch (type)
{
case STREAM:
case NEW_STREAM:
case VARIABLE_TYPE:
case NEW_VARIABLE:
break;
case STREAM:
case NEW_STREAM:
case VARIABLE_TYPE:
case NEW_VARIABLE:
break;
case STREAM_SQUELCH:
(*ms_squelchedStream)[channelNumber] = true;
break;
case STREAM_SQUELCH:
(*ms_squelchedStream)[channelNumber] = true;
break;
case STREAM_UNSQUELCH:
(*ms_squelchedStream)[channelNumber] = false;
break;
case STREAM_UNSQUELCH:
(*ms_squelchedStream)[channelNumber] = false;
break;
case VARIABLE_VALUE:
//set the new value into the variable on the server side
v = (*ms_variableValues)[channelNumber];
if(!v)
{
DEBUG_FATAL(true, ("message on undefined variable"));
return; //lint !e527 unreachable code
}
v->setValue(ms_buffer);
//put that new value back into the game object
v->pushValue();
break;
case VARIABLE_VALUE:
//set the new value into the variable on the server side
v = (*ms_variableValues)[channelNumber];
if (!v)
{
DEBUG_FATAL(true, ("message on undefined variable"));
return; //lint !e527 unreachable code
}
v->setValue(ms_buffer);
//put that new value back into the game object
v->pushValue();
break;
case STATIC_SQUELCH:
(*ms_squelchedStatic)[channelNumber] = true;
break;
case STATIC_SQUELCH:
(*ms_squelchedStatic)[channelNumber] = true;
break;
case STATIC_UNSQUELCH:
(*ms_squelchedStatic)[channelNumber] = false;
break;
case STATIC_UNSQUELCH:
(*ms_squelchedStatic)[channelNumber] = false;
break;
case REQUEST_ALL_CHANNELS:
sendAllChannels();
break;
case REQUEST_ALL_CHANNELS:
sendAllChannels();
break;
case STATIC_INPUT_TARGET:
ms_inputTarget = channelNumber;
break;
case STATIC_INPUT_TARGET:
ms_inputTarget = channelNumber;
break;
case STATIC_UP:
if ((*ms_upFunctionMap)[ms_inputTarget] != nullptr)
(*ms_upFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_UP:
if ((*ms_upFunctionMap)[ms_inputTarget] != nullptr)
(*ms_upFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_DOWN:
if ((*ms_downFunctionMap)[ms_inputTarget] != nullptr)
(*ms_downFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_DOWN:
if ((*ms_downFunctionMap)[ms_inputTarget] != nullptr)
(*ms_downFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_LEFT:
if ((*ms_leftFunctionMap)[ms_inputTarget] != nullptr)
(*ms_leftFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_LEFT:
if ((*ms_leftFunctionMap)[ms_inputTarget] != nullptr)
(*ms_leftFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_RIGHT:
if ((*ms_rightFunctionMap)[ms_inputTarget] != nullptr)
(*ms_rightFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_RIGHT:
if ((*ms_rightFunctionMap)[ms_inputTarget] != nullptr)
(*ms_rightFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_ENTER:
if ((*ms_enterFunctionMap)[ms_inputTarget] != nullptr)
(*ms_enterFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case STATIC_ENTER:
if ((*ms_enterFunctionMap)[ms_inputTarget] != nullptr)
(*ms_enterFunctionMap)[ms_inputTarget](); //lint !e10, !e522 ("expecting a function" and "expected void assignment)
break;
case NEW_STATIC:
case STATIC_BEGIN_FRAME:
case STATIC_END_FRAME:
case STATIC_LINE:
default:
break;
case NEW_STATIC:
case STATIC_BEGIN_FRAME:
case STATIC_END_FRAME:
case STATIC_LINE:
default:
break;
}
}
@@ -565,7 +564,7 @@ void RemoteDebugServer::receive(const unsigned char * const message, const uint3
void RemoteDebugServer::close()
{
DEBUG_FATAL(!ms_installed, ("remoteDebug not installed"));
if (ms_closeFunction)
ms_closeFunction();
ms_opened = false;
@@ -575,16 +574,16 @@ void RemoteDebugServer::close()
void RemoteDebugServer::sendAllChannels()
{
for(StreamMap::iterator it = ms_streams->begin(); it != ms_streams->end(); ++it)
for (StreamMap::iterator it = ms_streams->begin(); it != ms_streams->end(); ++it)
send(NEW_STREAM, it->second->name().c_str());
for(VariableMap::iterator itr = ms_variables->begin(); itr != ms_variables->end(); ++itr)
for (VariableMap::iterator itr = ms_variables->begin(); itr != ms_variables->end(); ++itr)
{
send(NEW_VARIABLE, itr->second->name().c_str());
send(VARIABLE_TYPE, itr->second->name().c_str());
send(VARIABLE_VALUE, itr->second->name().c_str());
}
for(StaticViewMap::iterator iter = ms_staticViews->begin(); iter != ms_staticViews->end(); ++iter)
for (StaticViewMap::iterator iter = ms_staticViews->begin(); iter != ms_staticViews->end(); ++iter)
send(NEW_STATIC, iter->second->name().c_str());
}
// ======================================================================
// ======================================================================