Commit f3fc8473 authored by bank's avatar bank

Use fixed buffer size var when allocating return buffer from console.

Conflicts:
	Engine/source/T3D/missionArea.cpp
	Engine/source/gui/editor/guiDebugger.cpp
parent d0a64026
......@@ -457,8 +457,9 @@ ConsoleMethod( AIClient, getAimLocation, const char *, 2, 2, "ai.getAimLocation(
AIClient *ai = static_cast<AIClient *>( object );
Point3F aimPoint = ai->getAimLocation();
char *returnBuffer = Con::getReturnBuffer( 256 );
dSprintf( returnBuffer, 256, "%f %f %f", aimPoint.x, aimPoint.y, aimPoint.z );
static const U32 bufSize = 256;
char *returnBuffer = Con::getReturnBuffer( bufSize );
dSprintf( returnBuffer, bufSize, "%f %f %f", aimPoint.x, aimPoint.y, aimPoint.z );
return returnBuffer;
}
......@@ -470,8 +471,9 @@ ConsoleMethod( AIClient, getMoveDestination, const char *, 2, 2, "ai.getMoveDest
AIClient *ai = static_cast<AIClient *>( object );
Point3F movePoint = ai->getMoveDestination();
char *returnBuffer = Con::getReturnBuffer( 256 );
dSprintf( returnBuffer, 256, "%f %f %f", movePoint.x, movePoint.y, movePoint.z );
static const U32 bufSize = 256;
char *returnBuffer = Con::getReturnBuffer( bufSize );
dSprintf( returnBuffer, bufSize, "%f %f %f", movePoint.x, movePoint.y, movePoint.z );
return returnBuffer;
}
......@@ -522,8 +524,9 @@ ConsoleMethod( AIClient, getLocation, const char *, 2, 2, "ai.getLocation();" )
AIClient *ai = static_cast<AIClient *>( object );
Point3F locPoint = ai->getLocation();
char *returnBuffer = Con::getReturnBuffer( 256 );
dSprintf( returnBuffer, 256, "%f %f %f", locPoint.x, locPoint.y, locPoint.z );
static const U32 bufSize = 256;
char *returnBuffer = Con::getReturnBuffer( bufSize );
dSprintf( returnBuffer, bufSize, "%f %f %f", locPoint.x, locPoint.y, locPoint.z );
return returnBuffer;
}
......
......@@ -145,9 +145,10 @@ ConsoleFunction(containerFindFirst, const char*, 6, 6, "(int mask, Point3F point
//return the first element
sgServerQueryIndex = 0;
char *buff = Con::getReturnBuffer(100);
static const U32 bufSize = 100;
char *buff = Con::getReturnBuffer(bufSize);
if (sgServerQueryList.mList.size())
dSprintf(buff, 100, "%d", sgServerQueryList.mList[sgServerQueryIndex++]->getId());
dSprintf(buff, bufSize, "%d", sgServerQueryList.mList[sgServerQueryIndex++]->getId());
else
buff[0] = '\0';
......@@ -162,9 +163,10 @@ ConsoleFunction( containerFindNext, const char*, 1, 1, "()"
"@ingroup Game")
{
//return the next element
char *buff = Con::getReturnBuffer(100);
static const U32 bufSize = 100;
char *buff = Con::getReturnBuffer(bufSize);
if (sgServerQueryIndex < sgServerQueryList.mList.size())
dSprintf(buff, 100, "%d", sgServerQueryList.mList[sgServerQueryIndex++]->getId());
dSprintf(buff, bufSize, "%d", sgServerQueryList.mList[sgServerQueryIndex++]->getId());
else
buff[0] = '\0';
......
......@@ -1241,9 +1241,10 @@ DefineEngineMethod( Item, getLastStickyPos, const char*, (),,
"@note Server side only.\n"
)
{
char* ret = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* ret = Con::getReturnBuffer(bufSize);
if (object->isServerObject())
dSprintf(ret, 255, "%g %g %g",
dSprintf(ret, bufSize, "%g %g %g",
object->mStickyCollisionPos.x,
object->mStickyCollisionPos.y,
object->mStickyCollisionPos.z);
......@@ -1263,9 +1264,10 @@ DefineEngineMethod( Item, getLastStickyNormal, const char *, (),,
"@note Server side only.\n"
)
{
char* ret = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* ret = Con::getReturnBuffer(bufSize);
if (object->isServerObject())
dSprintf(ret, 255, "%g %g %g",
dSprintf(ret, bufSize, "%g %g %g",
object->mStickyCollisionNormal.x,
object->mStickyCollisionNormal.y,
object->mStickyCollisionNormal.z);
......
......@@ -176,10 +176,11 @@ DefineEngineFunction(getMissionAreaServerObject, MissionArea*, (),,
DefineEngineMethod( MissionArea, getArea, const char *, (),,
"Returns 4 fields: starting x, starting y, extents x, extents y.\n")
{
char* returnBuffer = Con::getReturnBuffer(48);
static const U32 bufSize = 48;
char* returnBuffer = Con::getReturnBuffer(bufSize);
RectI area = object->getArea();
dSprintf(returnBuffer, 48, "%d %d %d %d", area.point.x, area.point.y, area.extent.x, area.extent.y);
dSprintf(returnBuffer, bufSize, "%d %d %d %d", area.point.x, area.point.y, area.extent.x, area.extent.y);
return(returnBuffer);
}
......
......@@ -304,8 +304,9 @@ ConsoleType( WayPointTeam, TypeWayPointTeam, WayPointTeam )
ConsoleGetType( TypeWayPointTeam )
{
char * buf = Con::getReturnBuffer(32);
dSprintf(buf, 32, "%d", ((WayPointTeam*)dptr)->mTeamId);
static const U32 bufSize = 32;
char * buf = Con::getReturnBuffer(bufSize);
dSprintf(buf, bufSize, "%d", ((WayPointTeam*)dptr)->mTeamId);
return(buf);
}
......
......@@ -6510,8 +6510,9 @@ DefineEngineMethod( Player, getDamageLocation, const char*, ( Point3F pos ),,
object->getDamageLocation(pos, buffer1, buffer2);
char *buff = Con::getReturnBuffer(128);
dSprintf(buff, 128, "%s %s", buffer1, buffer2);
static const U32 bufSize = 128;
char *buff = Con::getReturnBuffer(bufSize);
dSprintf(buff, bufSize, "%s %s", buffer1, buffer2);
return buff;
}
......
......@@ -259,8 +259,9 @@ ConsoleGetType( TypeTriggerPolyhedron )
AssertFatal(currVec == 3, "Internal error: Bad trigger polyhedron");
// Build output string.
char* retBuf = Con::getReturnBuffer(1024);
dSprintf(retBuf, 1023, "%7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f",
static const U32 bufSize = 1024;
char* retBuf = Con::getReturnBuffer(bufSize);
dSprintf(retBuf, bufSize, "%7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f %7.7f",
origin.x, origin.y, origin.z,
vecs[0].x, vecs[0].y, vecs[0].z,
vecs[2].x, vecs[2].y, vecs[2].z,
......
......@@ -382,10 +382,11 @@ ConsoleFunction( buildTaggedString, const char*, 2, 11, "(string format, ...)"
if (*indexPtr == StringTagPrefixByte)
indexPtr++;
const char *fmtString = gNetStringTable->lookupString(dAtoi(indexPtr));
char *strBuffer = Con::getReturnBuffer(512);
static const U32 bufSize = 512;
char *strBuffer = Con::getReturnBuffer(bufSize);
const char *fmtStrPtr = fmtString;
char *strBufPtr = strBuffer;
S32 strMaxLength = 511;
S32 strMaxLength = bufSize - 1;
if (!fmtString)
goto done;
......
......@@ -468,9 +468,10 @@ ConsoleFunction(testJavaScriptBridge, const char *, 4, 4, "testBridge(arg1, arg2
if (dStrcmp(jret,"42"))
failed = 3;
char *ret = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char *ret = Con::getReturnBuffer(bufSize);
dSprintf(ret, 256, "%i", failed);
dSprintf(ret, bufSize, "%i", failed);
return ret;
}
......
......@@ -1313,8 +1313,9 @@ const char *getFormattedData(S32 type, const char *data, const EnumTable *tbl, B
Con::setData(type, variable, 0, 1, &data, tbl, flag);
const char* formattedVal = Con::getData(type, variable, 0, tbl, flag);
char* returnBuffer = Con::getReturnBuffer(2048);
dSprintf(returnBuffer, 2048, "%s\0", formattedVal );
static const U32 bufSize = 2048;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%s\0", formattedVal );
cbt->deleteNativeVariable(variable);
......
......@@ -75,7 +75,8 @@ DefineConsoleFunction( strformat, const char*, ( const char* format, const char*
"@ingroup Strings\n"
"@see http://en.wikipedia.org/wiki/Printf" )
{
char* pBuffer = Con::getReturnBuffer(64);
static const U32 bufSize = 64;
char* pBuffer = Con::getReturnBuffer(bufSize);
const char *pch = format;
pBuffer[0] = '\0';
......@@ -99,7 +100,7 @@ DefineConsoleFunction( strformat, const char*, ( const char* format, const char*
case 'u':
case 'x':
case 'X':
dSprintf( pBuffer, 64, format, dAtoi( value ) );
dSprintf( pBuffer, bufSize, format, dAtoi( value ) );
break;
case 'e':
......@@ -107,7 +108,7 @@ DefineConsoleFunction( strformat, const char*, ( const char* format, const char*
case 'f':
case 'g':
case 'G':
dSprintf( pBuffer, 64, format, dAtof( value ) );
dSprintf( pBuffer, bufSize, format, dAtof( value ) );
break;
default:
......
......@@ -289,8 +289,9 @@ ImplementConsoleTypeCasters( TypeS8, S8 )
ConsoleGetType( TypeS8 )
{
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%d", *((U8 *) dptr) );
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%d", *((U8 *) dptr) );
return returnBuffer;
}
......@@ -310,8 +311,9 @@ ImplementConsoleTypeCasters(TypeS32, S32)
ConsoleGetType( TypeS32 )
{
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%d", *((S32 *) dptr) );
static const U32 bufSize = 512;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%d", *((S32 *) dptr) );
return returnBuffer;
}
......@@ -389,8 +391,9 @@ ImplementConsoleTypeCasters(TypeF32, F32)
ConsoleGetType( TypeF32 )
{
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%g", *((F32 *) dptr) );
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%g", *((F32 *) dptr) );
return returnBuffer;
}
ConsoleSetType( TypeF32 )
......@@ -487,8 +490,9 @@ ImplementConsoleTypeCasters( TypeBoolVector, Vector< bool > )
ConsoleGetType( TypeBoolVector )
{
Vector<bool> *vec = (Vector<bool>*)dptr;
char* returnBuffer = Con::getReturnBuffer(1024);
S32 maxReturn = 1024;
static const U32 bufSize = 1024;
char* returnBuffer = Con::getReturnBuffer(bufSize);
S32 maxReturn = bufSize;
returnBuffer[0] = '\0';
S32 returnLeng = 0;
for (Vector<bool>::iterator itr = vec->begin(); itr < vec->end(); itr++)
......@@ -579,8 +583,9 @@ ConsoleGetType( TypeColorF )
return colorName;
// Format as color components.
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%g %g %g %g", color->red, color->green, color->blue, color->alpha);
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%g %g %g %g", color->red, color->green, color->blue, color->alpha);
return(returnBuffer);
}
......@@ -651,8 +656,9 @@ ConsoleGetType( TypeColorI )
return colorName;
// Format as color components.
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%d %d %d %d", color->red, color->green, color->blue, color->alpha);
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%d %d %d %d", color->red, color->green, color->blue, color->alpha);
return returnBuffer;
}
......@@ -723,8 +729,9 @@ ConsoleSetType( TypeSimObjectName )
ConsoleGetType( TypeSimObjectName )
{
SimObject **obj = (SimObject**)dptr;
char* returnBuffer = Con::getReturnBuffer(128);
dSprintf(returnBuffer, 128, "%s", *obj && (*obj)->getName() ? (*obj)->getName() : "");
static const U32 bufSize = 128;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%s", *obj && (*obj)->getName() ? (*obj)->getName() : "");
return returnBuffer;
}
......@@ -791,8 +798,9 @@ ConsoleType( int, TypeTerrainMaterialIndex, S32 )
ConsoleGetType( TypeTerrainMaterialIndex )
{
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%d", *((S32 *) dptr) );
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%d", *((S32 *) dptr) );
return returnBuffer;
}
......@@ -853,8 +861,9 @@ ConsoleType( RectF, TypeRectUV, RectF )
ConsoleGetType( TypeRectUV )
{
RectF *rect = (RectF *) dptr;
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%g %g %g %g", rect->point.x, rect->point.y,
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%g %g %g %g", rect->point.x, rect->point.y,
rect->extent.x, rect->extent.y);
return returnBuffer;
}
......
......@@ -211,8 +211,9 @@ class BitfieldConsoleBaseType : public ConsoleBaseType
virtual const char* getData( void* dptr, const EnumTable*, BitSet32 )
{
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "0x%08x", *((S32 *) dptr) );
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "0x%08x", *((S32 *) dptr) );
return returnBuffer;
}
virtual void setData( void* dptr, S32 argc, const char** argv, const EnumTable*, BitSet32 )
......
......@@ -695,8 +695,9 @@ DefineEngineFunction(makeFullPath, String, ( const char* path, const char* cwd )
"@return String containing non-relative directory of path\n"
"@ingroup FileSystem")
{
char *buf = Con::getReturnBuffer(512);
Platform::makeFullPathName(path, buf, 512, dStrlen(cwd) > 1 ? cwd : NULL);
static const U32 bufSize = 512;
char *buf = Con::getReturnBuffer(buf);
Platform::makeFullPathName(path, buf, bufSize, dStrlen(cwd) > 1 ? cwd : NULL);
return buf;
}
......@@ -721,8 +722,9 @@ DefineEngineFunction(pathConcat, String, ( const char* path, const char* file),,
"@return String containing concatenated file name and path\n"
"@ingroup FileSystem")
{
char *buf = Con::getReturnBuffer(1024);
Platform::makeFullPathName(file, buf, 1024, path);
static const U32 bufSize = 1024;
char *buf = Con::getReturnBuffer(buf);
Platform::makeFullPathName(file, buf, bufSize, path);
return buf;
}
......
......@@ -344,8 +344,9 @@ ConsoleFunction(expandFilename, const char*, 2, 2, "(string filename)"
"@ingroup FileSystem")
{
TORQUE_UNUSED(argc);
char* ret = Con::getReturnBuffer( 1024 );
Con::expandScriptFilename(ret, 1024, argv[1]);
static const U32 bufSize = 1024;
char* ret = Con::getReturnBuffer( bufSize );
Con::expandScriptFilename(ret, bufSize, argv[1]);
return ret;
}
......@@ -355,8 +356,9 @@ ConsoleFunction(expandOldFilename, const char*, 2, 2, "(string filename)"
"@ingroup FileSystem")
{
TORQUE_UNUSED(argc);
char* ret = Con::getReturnBuffer( 1024 );
Con::expandOldScriptFilename(ret, 1024, argv[1]);
static const U32 bufSize = 1024;
char* ret = Con::getReturnBuffer( bufSize );
Con::expandOldScriptFilename(ret, bufSize, argv[1]);
return ret;
}
......@@ -368,8 +370,9 @@ ConsoleToolFunction(collapseFilename, const char*, 2, 2, "(string filename)"
"@internal Editor use only")
{
TORQUE_UNUSED(argc);
char* ret = Con::getReturnBuffer( 1024 );
Con::collapseScriptFilename(ret, 1024, argv[1]);
static const U32 bufSize = 1024;
char* ret = Con::getReturnBuffer( bufSize );
Con::collapseScriptFilename(ret, bufSize, argv[1]);
return ret;
}
......
......@@ -2680,11 +2680,12 @@ DefineConsoleMethod( SimObject, getDynamicField, const char*, ( S32 index ),,
++itr;
}
char* buffer = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* buffer = Con::getReturnBuffer(bufSize);
if (*itr)
{
SimFieldDictionary::Entry* entry = *itr;
dSprintf(buffer, 256, "%s\t%s", entry->slotName, entry->value);
dSprintf(buffer, bufSize, "%s\t%s", entry->slotName, entry->value);
return buffer;
}
......
......@@ -343,8 +343,9 @@ DefineEngineMethod( FileObject, peekLine, const char*, (),,
"@return String containing the line of data that was just peeked\n")
{
char *line = Con::getReturnBuffer( 512 );
object->peekLine( (U8*)line, 512 );
static const U32 bufSize = 512;
char *line = Con::getReturnBuffer( bufSize );
object->peekLine( (U8*)line, bufSize );
return line;
}
......
......@@ -113,8 +113,9 @@ const char * StreamObject::readLine()
if(mStream == NULL)
return NULL;
char *buffer = Con::getReturnBuffer(256);
mStream->readLine((U8 *)buffer, 256);
static const U32 bufSize = 256;
char *buffer = Con::getReturnBuffer(bufSize);
mStream->readLine((U8 *)buffer, bufSize);
return buffer;
}
......
......@@ -1223,9 +1223,10 @@ ConsoleMethod( GuiMeshRoadEditorCtrl, setNodeDepth, void, 3, 3, "" )
ConsoleMethod( GuiMeshRoadEditorCtrl, getNodePosition, const char*, 2, 2, "" )
{
char* returnBuffer = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, 256, "%f %f %f",
dSprintf(returnBuffer, bufSize, "%f %f %f",
object->getNodePosition().x, object->getNodePosition().y, object->getNodePosition().z);
return returnBuffer;
......@@ -1249,9 +1250,10 @@ ConsoleMethod( GuiMeshRoadEditorCtrl, setNodePosition, void, 3, 3, "" )
ConsoleMethod( GuiMeshRoadEditorCtrl, getNodeNormal, const char*, 2, 2, "" )
{
char* returnBuffer = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, 256, "%f %f %f",
dSprintf(returnBuffer, bufSize, "%f %f %f",
object->getNodeNormal().x, object->getNodeNormal().y, object->getNodeNormal().z);
return returnBuffer;
......
......@@ -1430,9 +1430,10 @@ ConsoleMethod( GuiRiverEditorCtrl, setNodeDepth, void, 3, 3, "" )
ConsoleMethod( GuiRiverEditorCtrl, getNodePosition, const char*, 2, 2, "" )
{
char* returnBuffer = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, 256, "%f %f %f",
dSprintf(returnBuffer, bufSize, "%f %f %f",
object->getNodePosition().x, object->getNodePosition().y, object->getNodePosition().z);
return returnBuffer;
......@@ -1456,9 +1457,10 @@ ConsoleMethod( GuiRiverEditorCtrl, setNodePosition, void, 3, 3, "" )
ConsoleMethod( GuiRiverEditorCtrl, getNodeNormal, const char*, 2, 2, "" )
{
char* returnBuffer = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, 256, "%f %f %f",
dSprintf(returnBuffer, bufSize, "%f %f %f",
object->getNodeNormal().x, object->getNodeNormal().y, object->getNodeNormal().z);
return returnBuffer;
......
......@@ -1064,9 +1064,10 @@ ConsoleMethod( GuiRoadEditorCtrl, setNodeWidth, void, 3, 3, "" )
ConsoleMethod( GuiRoadEditorCtrl, getNodePosition, const char*, 2, 2, "" )
{
char* returnBuffer = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, 256, "%f %f %f",
dSprintf(returnBuffer, bufSize, "%f %f %f",
object->getNodePosition().x, object->getNodePosition().y, object->getNodePosition().z);
return returnBuffer;
......
......@@ -64,13 +64,14 @@ ScriptMethod( Forest, forestRayCast, const char*, 4, 4, "( Point3F start, Point3
dSscanf(argv[2], "%g %g %g", &start.x, &start.y, &start.z);
dSscanf(argv[3], "%g %g %g", &end.x, &end.y, &end.z);
char *returnBuffer = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char *returnBuffer = Con::getReturnBuffer(bufSize);
returnBuffer[0] = '0';
returnBuffer[1] = '\0';
ForestRayInfo rinfo;
if ( object->castRayI( start, end, &rinfo ) )
dSprintf( returnBuffer, 256, "%d %d %g", rinfo.item->getData()->getId(), rinfo.key, rinfo.t );
dSprintf( returnBuffer, bufSize, "%d %d %g", rinfo.item->getData()->getId(), rinfo.key, rinfo.t );
return returnBuffer;
}
......
......@@ -528,10 +528,11 @@ void GuiColorPickerCtrl::setScriptValue(const char *value)
ConsoleMethod(GuiColorPickerCtrl, getSelectorPos, const char*, 2, 2, "Gets the current position of the selector")
{
char *temp = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char *temp = Con::getReturnBuffer(bufSize);
Point2I pos;
pos = object->getSelectorPos();
dSprintf(temp,256,"%d %d",pos.x, pos.y);
dSprintf(temp,bufSize,"%d %d",pos.x, pos.y);
return temp;
}
......
......@@ -169,17 +169,18 @@ DefineEngineMethod( GuiDirectoryFileListCtrl, getSelectedFiles, const char*, (),
return StringTable->insert( "" );
// Get an adequate buffer
char itemBuffer[256];
dMemset( itemBuffer, 0, 256 );
static const U32 itemBufSize = 256;
char itemBuffer[itemBufSize];
char* returnBuffer = Con::getReturnBuffer( ItemVector.size() * 64 );
dMemset( returnBuffer, 0, ItemVector.size() * 64 );
static const U32 bufSize = ItemVector.size() * 64;
char* returnBuffer = Con::getReturnBuffer( bufSize );
dMemset( returnBuffer, 0, bufSize );
// Fetch the first entry
StringTableEntry itemText = object->getItemText( ItemVector[0] );
if( !itemText )
return StringTable->lookup("");
dSprintf( returnBuffer, ItemVector.size() * 64, "%s", itemText );
dSprintf( returnBuffer, bufSize, "%s", itemText );
// If only one entry, return it.
if( ItemVector.size() == 1 )
......@@ -192,8 +193,8 @@ DefineEngineMethod( GuiDirectoryFileListCtrl, getSelectedFiles, const char*, (),
if( !itemText )
continue;
dMemset( itemBuffer, 0, 256 );
dSprintf( itemBuffer, 256, " %s", itemText );
dMemset( itemBuffer, 0, itemBufSize );
dSprintf( itemBuffer, itemBufSize, " %s", itemText );
dStrcat( returnBuffer, itemBuffer );
}
......
......@@ -89,8 +89,9 @@ bool GuiGradientSwatchCtrl::onWake()
if ( !Parent::onWake() )
return false;
char* altCommand = Con::getReturnBuffer(512);
dSprintf( altCommand, 512, "%s(%i.color, \"%i.setColor\");", mColorFunction, getId(), getId() );
static const U32 bufSize = 512;
char* altCommand = Con::getReturnBuffer(bufSize);
dSprintf( altCommand, bufSize, "%s(%i.color, \"%i.setColor\");", mColorFunction, getId(), getId() );
setField( "altCommand", altCommand );
return true;
......@@ -616,10 +617,11 @@ ConsoleMethod(GuiGradientCtrl, getColor, const char*, 3, 3, "Get color value")
{
if ( idx >= 0 && idx < object->mColorRange.size() )
{
char* rColor = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* rColor = Con::getReturnBuffer(bufSize);
rColor[0] = 0;
dSprintf(rColor, 256, "%f %f %f %f",
dSprintf(rColor, bufSize, "%f %f %f %f",
object->mColorRange[idx].swatch->getColor().red,
object->mColorRange[idx].swatch->getColor().green,
object->mColorRange[idx].swatch->getColor().blue,
......@@ -632,10 +634,11 @@ ConsoleMethod(GuiGradientCtrl, getColor, const char*, 3, 3, "Get color value")
{
if ( idx >= 0 && idx < object->mAlphaRange.size() )
{
char* rColor = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* rColor = Con::getReturnBuffer(bufSize);
rColor[0] = 0;
dSprintf(rColor, 256, "%f %f %f %f",
dSprintf(rColor, bufSize, "%f %f %f %f",
object->mAlphaRange[idx].swatch->getColor().red,
object->mAlphaRange[idx].swatch->getColor().green,
object->mAlphaRange[idx].swatch->getColor().blue,
......
......@@ -450,8 +450,9 @@ DefineEngineMethod( GuiListBoxCtrl, getSelectedItems, const char*, (),,
if( selItems.empty() )
return StringTable->lookup("-1");
UTF8 *retBuffer = Con::getReturnBuffer( selItems.size() * 4 );
dMemset( retBuffer, 0, selItems.size() * 4 );
static const U32 bufSize = selItems.size() * 4;
UTF8 *retBuffer = Con::getReturnBuffer( bufSize );
dMemset( retBuffer, 0, bufSize );
Vector<S32>::iterator i = selItems.begin();
for( ; i != selItems.end(); i++ )
{
......
......@@ -579,8 +579,9 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, getColorById, const char*, 3, 3,
ColorI color;
object->getColoredBox(color, dAtoi(argv[2]));
char *strBuffer = Con::getReturnBuffer(512);
dSprintf(strBuffer, 512, "%d %d %d %d", color.red, color.green, color.blue, color.alpha);
static const U32 bufSize = 512;
char *strBuffer = Con::getReturnBuffer(bufSize);
dSprintf(strBuffer, bufSize, "%d %d %d %d", color.red, color.green, color.blue, color.alpha);
return strBuffer;
}
......
......@@ -5061,8 +5061,9 @@ ConsoleMethod(GuiTreeViewCtrl, getSelectedObject, S32, 2, 3, "( int index=0 ) -
ConsoleMethod(GuiTreeViewCtrl, getSelectedObjectList, const char*, 2, 2,
"Returns a space sperated list of all selected object ids.")
{
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 = object->getSelectedItems();
for(S32 i = 0; i < selectedItems.size(); i++)
......@@ -5077,7 +5078,7 @@ ConsoleMethod(GuiTreeViewCtrl, getSelectedObjectList, const char*, 2, 2,
//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)
{
......@@ -5126,8 +5127,9 @@ ConsoleMethod(GuiTreeViewCtrl, getTextToRoot, const char*,4,4,"(TreeItemId item,
ConsoleMethod(GuiTreeViewCtrl, getSelectedItemList,const char*, 2,2,"returns a space seperated list of mulitple item ids")
{
char* buff = Con::getReturnBuffer(1024);
dSprintf(buff,1024,"");
static const U32 bufSize = 1024;
char* buff = Con::getReturnBuffer(bufSize);
dSprintf(buff,bufSize,"");
const Vector< S32 >& selected = object->getSelected();
for(S32 i = 0; i < selected.size(); i++)
......@@ -5138,7 +5140,7 @@ ConsoleMethod(GuiTreeViewCtrl, getSelectedItemList,const char*, 2,2,"returns a s
//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)
{
......
......@@ -719,8 +719,9 @@ ImplementConsoleTypeCasters( TypeRectSpacingI, RectSpacingI )
ConsoleGetType( TypeRectSpacingI )
{
RectSpacingI *rect = (RectSpacingI *) dptr;