Fixed bad string compares and simdictionary

This commit is contained in:
Vincent Gee 2014-11-04 19:51:13 -05:00
parent acb192e2a5
commit 9907c4592e
30 changed files with 169 additions and 202 deletions

View file

@ -5053,11 +5053,13 @@ DefineConsoleMethod(GuiTreeViewCtrl, getSelectedObject, S32, ( S32 index ), (0),
const char* GuiTreeViewCtrl::getSelectedObjectList()
{
char* buff = Con::getReturnBuffer(1024);
dSprintf(buff,1024,"");
static const U32 bufSize = 1024;
char* buff = Con::getReturnBuffer(bufSize);
dSprintf(buff,bufSize,"");
const Vector< GuiTreeViewCtrl::Item* > selectedItems = this->getSelectedItems();
for(int i = 0; i < selectedItems.size(); i++)
for(S32 i = 0; i < selectedItems.size(); i++)
{
GuiTreeViewCtrl::Item *item = selectedItems[i];
@ -5069,7 +5071,7 @@ const char* GuiTreeViewCtrl::getSelectedObjectList()
//the start of the buffer where we want to write
char* buffPart = buff+len;
//the size of the remaining buffer (-1 cause dStrlen doesn't count the \0)
S32 size = 1024-len-1;
S32 size = bufSize-len-1;
//write it:
if(size < 1)
{
@ -5085,37 +5087,9 @@ const char* GuiTreeViewCtrl::getSelectedObjectList()
}
DefineConsoleMethod(GuiTreeViewCtrl, getSelectedObjectList, const char*, (), ,
"Returns a space sperated list of all selected object ids.")
"Returns a space seperated list of all selected object ids.")
{
char* buff = Con::getReturnBuffer(1024);
dSprintf(buff,1024,"");
const Vector< GuiTreeViewCtrl::Item* > selectedItems = object->getSelectedItems();
for(int i = 0; i < selectedItems.size(); i++)
{
GuiTreeViewCtrl::Item *item = selectedItems[i];
if ( item->isInspectorData() && item->getObject() )
{
S32 id = item->getObject()->getId();
//get the current length of the buffer
U32 len = dStrlen(buff);
//the start of the buffer where we want to write
char* buffPart = buff+len;
//the size of the remaining buffer (-1 cause dStrlen doesn't count the \0)
S32 size = 1024-len-1;
//write it:
if(size < 1)
{
Con::errorf("GuiTreeViewCtrl::getSelectedItemList - Not enough room to return our object list");
return buff;
}
dSprintf(buffPart,size,"%d ", id);
}
}
return buff;
return object->getSelectedObjectList();
}
DefineConsoleMethod(GuiTreeViewCtrl, moveItemUp, void, (S32 index), , "(TreeItemId item)")

View file

@ -2810,28 +2810,11 @@ static ConsoleDocFragment _sGuiControlSetExtent2(
"void setExtent( Point2I p );" ); // The definition string.
//ConsoleMethod( GuiControl, setExtent, void, 3, 4,
DefineConsoleMethod( GuiControl, setExtent, void, ( Point2F ext ), ,
DefineConsoleMethod( GuiControl, setExtent, void, ( Point2I ext ), ,
" Set the width and height of the control.\n\n"
"@hide" )
{
//if ( argc == 3 )
//if ( pOrX != "" && y == "" )
//{
// // We scan for floats because its possible that math
// // done on the extent can result in fractional values.
// Point2F ext;
// //if ( dSscanf( argv[2], "%g %g", &ext.x, &ext.y ) == 2 )
// if ( dSscanf( pOrX, "%g %g", &ext.x, &ext.y ) == 2 )
object->setExtent( (S32)ext.x, (S32)ext.y );
// else
// Con::errorf( "GuiControl::setExtent, not enough parameters!" );
//}
////else if ( argc == 4 )
//else if ( pOrX != "" && y != "" )
//{
// //object->setExtent( dAtoi(argv[2]), dAtoi(argv[3]) );
// object->setExtent( dAtoi(pOrX), dAtoi(y) );
//}
}
//-----------------------------------------------------------------------------

View file

@ -1052,25 +1052,17 @@ DefineConsoleMethod(GuiParticleGraphCtrl, clearAllGraphs, void, (), , "()"
object->clearAllGraphs();
}
DefineConsoleMethod(GuiParticleGraphCtrl, addPlotPoint, const char*, (S32 plotID, F32 x, F32 y, bool setAdded), (true), "(int plotID, float x, float y, bool setAdded = true;)"
DefineConsoleMethod(GuiParticleGraphCtrl, addPlotPoint, S32, (S32 plotID, F32 x, F32 y, bool setAdded), (true), "(int plotID, float x, float y, bool setAdded = true;)"
"Add a data point to the given plot."
"@return")
{
S32 pointAdded = 0;
char *retBuffer = Con::getReturnBuffer(32);
if(plotID > object->MaxPlots)
{
Con::errorf("Invalid plotID.");
dSprintf(retBuffer, 32, "%d", -2);
return retBuffer;
return -2;
}
pointAdded = object->addPlotPoint( plotID, Point2F(x, y), setAdded);
dSprintf(retBuffer, 32, "%d", pointAdded);
return retBuffer;
return object->addPlotPoint( plotID, Point2F(x, y), setAdded);
}
DefineConsoleMethod(GuiParticleGraphCtrl, insertPlotPoint, void, (S32 plotID, S32 i, F32 x, F32 y), , "(int plotID, int i, float x, float y)\n"
@ -1088,7 +1080,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, insertPlotPoint, void, (S32 plotID, S3
object->insertPlotPoint( plotID, i, Point2F(x, y));
}
DefineConsoleMethod(GuiParticleGraphCtrl, changePlotPoint, const char*, (S32 plotID, S32 i, F32 x, F32 y), , "(int plotID, int i, float x, float y)"
DefineConsoleMethod(GuiParticleGraphCtrl, changePlotPoint, S32, (S32 plotID, S32 i, F32 x, F32 y), , "(int plotID, int i, float x, float y)"
"Change a data point to the given plot and plot position.\n"
"@param plotID The plot you want to access\n"
"@param i The data point.\n"
@ -1098,40 +1090,26 @@ DefineConsoleMethod(GuiParticleGraphCtrl, changePlotPoint, const char*, (S32 plo
if(plotID > object->MaxPlots)
{
Con::errorf("Invalid plotID.");
char *retBuffer = Con::getReturnBuffer(64);
const S32 index = -1;
dSprintf(retBuffer, 64, "%d", index);
return retBuffer;
return -1;
}
char *retBuffer = Con::getReturnBuffer(64);
const S32 index = object->changePlotPoint( plotID, i, Point2F(x, y));
dSprintf(retBuffer, 64, "%d", index);
return retBuffer;
return object->changePlotPoint( plotID, i, Point2F(x, y));
}
DefineConsoleMethod(GuiParticleGraphCtrl, getSelectedPlot, const char*, (), , "() "
DefineConsoleMethod(GuiParticleGraphCtrl, getSelectedPlot, S32, (), , "() "
"Gets the selected Plot (a.k.a. graph).\n"
"@return The plot's ID.")
{
char *retBuffer = Con::getReturnBuffer(32);
const S32 plot = object->getSelectedPlot();
dSprintf(retBuffer, 32, "%d", plot);
return retBuffer;
return object->getSelectedPlot();
}
DefineConsoleMethod(GuiParticleGraphCtrl, getSelectedPoint, const char*, (), , "()"
DefineConsoleMethod(GuiParticleGraphCtrl, getSelectedPoint, S32, (), , "()"
"Gets the selected Point on the Plot (a.k.a. graph)."
"@return The last selected point ID")
{
char *retBuffer = Con::getReturnBuffer(32);
const S32 point = object->getSelectedPoint();
dSprintf(retBuffer, 32, "%d", point);
return retBuffer;
return object->getSelectedPoint();
}
DefineConsoleMethod(GuiParticleGraphCtrl, isExistingPoint, const char*, (S32 plotID, S32 samples), , "(int plotID, int samples)"
DefineConsoleMethod(GuiParticleGraphCtrl, isExistingPoint, bool, (S32 plotID, S32 samples), , "(int plotID, int samples)"
"@return Returns true or false whether or not the point in the plot passed is an existing point.")
{
@ -1143,14 +1121,10 @@ DefineConsoleMethod(GuiParticleGraphCtrl, isExistingPoint, const char*, (S32 plo
{
Con::errorf("Invalid sample.");
}
char *retBuffer = Con::getReturnBuffer(32);
const bool isPoint = object->isExistingPoint(plotID, samples);
dSprintf(retBuffer, 32, "%d", isPoint);
return retBuffer;
return object->isExistingPoint(plotID, samples);
}
DefineConsoleMethod(GuiParticleGraphCtrl, getPlotPoint, const char*, (S32 plotID, S32 samples), , "(int plotID, int samples)"
DefineConsoleMethod(GuiParticleGraphCtrl, getPlotPoint, Point2F, (S32 plotID, S32 samples), , "(int plotID, int samples)"
"Get a data point from the plot specified, samples from the start of the graph."
"@return The data point ID")
{
@ -1164,13 +1138,11 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getPlotPoint, const char*, (S32 plotID
Con::errorf("Invalid sample.");
}
char *retBuffer = Con::getReturnBuffer(64);
const Point2F &pos = object->getPlotPoint(plotID, samples);
dSprintf(retBuffer, 64, "%f %f", pos.x, pos.y);
return retBuffer;
return object->getPlotPoint(plotID, samples);
}
DefineConsoleMethod(GuiParticleGraphCtrl, getPlotIndex, const char*, (S32 plotID, F32 x, F32 y), , "(int plotID, float x, float y)\n"
DefineConsoleMethod(GuiParticleGraphCtrl, getPlotIndex, S32, (S32 plotID, F32 x, F32 y), , "(int plotID, float x, float y)\n"
"Gets the index of the point passed on the plotID passed (graph ID).\n"
"@param plotID The plot you wish to check.\n"
"@param x,y The coordinates of the point to get.\n"
@ -1181,14 +1153,10 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getPlotIndex, const char*, (S32 plotID
{
Con::errorf("Invalid plotID.");
}
char *retBuffer = Con::getReturnBuffer(32);
const S32 &index = object->getPlotIndex(plotID, x, y);
dSprintf(retBuffer, 32, "%d", index);
return retBuffer;
return object->getPlotIndex(plotID, x, y);
}
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphColor, const char*, (S32 plotID), , "(int plotID)"
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphColor, ColorF, (S32 plotID), , "(int plotID)"
"Get the color of the graph passed."
"@return Returns the color of the graph as a string of RGB values formatted as \"R G B\"")
{
@ -1197,14 +1165,12 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getGraphColor, const char*, (S32 plotI
{
Con::errorf("Invalid plotID.");
}
char *retBuffer = Con::getReturnBuffer(64);
const ColorF &color = object->getGraphColor(plotID);
dSprintf(retBuffer, 64, "%f %f %f", color.red, color.green, color.blue);
return retBuffer;
return object->getGraphColor(plotID);
}
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMin, const char*, (S32 plotID), , "(int plotID) "
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMin, Point2F, (S32 plotID), , "(int plotID) "
"Get the minimum values of the graph ranges.\n"
"@return Returns the minimum of the range formatted as \"x-min y-min\"")
{
@ -1213,14 +1179,10 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMin, const char*, (S32 plotID)
{
Con::errorf("Invalid plotID.");
}
char *retBuffer = Con::getReturnBuffer(64);
const Point2F graphMin = object->getGraphMin(plotID);
dSprintf(retBuffer, 64, "%f %f", graphMin.x, graphMin.y);
return retBuffer;
return object->getGraphMin(plotID);
}
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMax, const char*, (S32 plotID), , "(int plotID) "
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMax, Point2F, (S32 plotID), , "(int plotID) "
"Get the maximum values of the graph ranges.\n"
"@return Returns the maximum of the range formatted as \"x-max y-max\"")
{
@ -1229,11 +1191,8 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMax, const char*, (S32 plotID)
{
Con::errorf("Invalid plotID.");
}
char *retBuffer = Con::getReturnBuffer(64);
const Point2F graphMax = object->getGraphMax(plotID);
dSprintf(retBuffer, 64, "%f %f", graphMax.x, graphMax.y);
return retBuffer;
return object->getGraphMax(plotID);
}
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphName, const char*, (S32 plotID), , "(int plotID) "

View file

@ -20,8 +20,6 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "console/console.h"
#include "console/consoleTypes.h"
#include "gfx/bitmap/gBitmap.h"

View file

@ -818,15 +818,17 @@ DefineConsoleMethod( GuiDecalEditorCtrl, getDecalCount, S32, (), , "getDecalCoun
DefineConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, ( U32 id ), , "getDecalTransform()" )
{
DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id];
if( decalInstance == NULL )
return "";
char* returnBuffer = Con::getReturnBuffer(256);
returnBuffer[0] = 0;
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
if ( decalInstance )
{
dSprintf(returnBuffer, 256, "%f %f %f %f %f %f %f",
dSprintf(returnBuffer, bufSize, "%f %f %f %f %f %f %f",
decalInstance->mPosition.x, decalInstance->mPosition.y, decalInstance->mPosition.z,
decalInstance->mTangent.x, decalInstance->mTangent.y, decalInstance->mTangent.z,
decalInstance->mSize);

View file

@ -97,7 +97,7 @@ void GuiMissionAreaEditorCtrl::setSelectedMissionArea( MissionArea *missionArea
DefineConsoleMethod( GuiMissionAreaEditorCtrl, setSelectedMissionArea, void, (const char * missionAreaName), (""), "" )
{
if ( missionAreaName == "" )
if ( dStrcmp( missionAreaName, "" )==0 )
object->setSelectedMissionArea(NULL);
else
{