Skip to content

Commit

Permalink
Fixed bad string compares and simdictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
Winterleaf committed Nov 5, 2014
1 parent acb192e commit 9907c45
Show file tree
Hide file tree
Showing 30 changed files with 169 additions and 202 deletions.
27 changes: 6 additions & 21 deletions Engine/source/T3D/aiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,29 +456,19 @@ DefineConsoleMethod( AIClient, setMoveDestination, void, (Point3F v), , "ai.setM
/**
* Returns the point the AI is aiming at
*/
DefineConsoleMethod( AIClient, getAimLocation, const char *, (),, "ai.getAimLocation();" )
DefineConsoleMethod( AIClient, getAimLocation, Point3F, (),, "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 );
return returnBuffer;
return ai->getAimLocation();
}
/**
* Returns the point the AI is set to move to
*/
DefineConsoleMethod( AIClient, getMoveDestination, const char *, (),, "ai.getMoveDestination();" )
DefineConsoleMethod( AIClient, getMoveDestination, Point3F, (),, "ai.getMoveDestination();" )
{
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 );
return returnBuffer;
return ai->getMoveDestination();
}
/**
Expand Down Expand Up @@ -527,15 +517,10 @@ DefineConsoleMethod( AIClient, move, void, (),, "ai.move();" )
/**
* Gets the AI's location in the world
*/
DefineConsoleMethod( AIClient, getLocation, const char *, (),, "ai.getLocation();" )
DefineConsoleMethod( AIClient, getLocation, Point3F, (),, "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 );
return returnBuffer;
return ai->getLocation();
}
/**
Expand Down
2 changes: 1 addition & 1 deletion Engine/source/T3D/gameBase/gameProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ClientProcessList* ClientProcessList::smClientProcessList = NULL;
ServerProcessList* ServerProcessList::smServerProcessList = NULL;
static U32 gNetOrderNextId = 0;

DefineConsoleFunction( dumpProcessList, void, ( bool allow ), ,
DefineConsoleFunction( dumpProcessList, void, ( ), ,
"Dumps all ProcessObjects in ServerProcessList and ClientProcessList to the console." )
{
Con::printf( "client process list:" );
Expand Down
2 changes: 1 addition & 1 deletion Engine/source/T3D/lightBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ DefineConsoleMethod( LightBase, playAnimation, void, (const char * anim), (""),
"existing one is played."
"@hide")
{
if ( anim == "" )
if ( dStrcmp(anim,"" )==0)
{
object->playAnimation();
return;
Expand Down
43 changes: 43 additions & 0 deletions Engine/source/T3D/missionMarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ ConsoleDocClass( WayPoint,
"@ingroup enviroMisc\n"
);

WayPointTeam::WayPointTeam()
{
mTeamId = 0;
mWayPoint = 0;
}

WayPoint::WayPoint()
{
mName = StringTable->insert("");
Expand All @@ -246,6 +252,7 @@ bool WayPoint::onAdd()
Sim::getWayPointSet()->addObject(this);
else
{
mTeam.mWayPoint = this;
setMaskBits(UpdateNameMask|UpdateTeamMask);
}

Expand All @@ -265,6 +272,8 @@ U32 WayPoint::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
U32 retMask = Parent::packUpdate(con, mask, stream);
if(stream->writeFlag(mask & UpdateNameMask))
stream->writeString(mName);
if(stream->writeFlag(mask & UpdateTeamMask))
stream->write(mTeam.mTeamId);
if(stream->writeFlag(mask & UpdateHiddenMask))
stream->writeFlag(isHidden());
return(retMask);
Expand All @@ -275,17 +284,51 @@ void WayPoint::unpackUpdate(NetConnection * con, BitStream * stream)
Parent::unpackUpdate(con, stream);
if(stream->readFlag())
mName = stream->readSTString(true);
if(stream->readFlag())
stream->read(&mTeam.mTeamId);
if(stream->readFlag())
setHidden(stream->readFlag());
}

//-----------------------------------------------------------------------------
// TypeWayPointTeam
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// TypeWayPointTeam
//-----------------------------------------------------------------------------

IMPLEMENT_STRUCT( WayPointTeam, WayPointTeam,, "" )
END_IMPLEMENT_STRUCT;

//FIXME: this should work but does not; need to check the stripping down to base types within TYPE
//ConsoleType( WayPointTeam, TypeWayPointTeam, WayPointTeam* )
ConsoleType( WayPointTeam, TypeWayPointTeam, WayPointTeam )

ConsoleGetType( TypeWayPointTeam )
{
static const U32 bufSize = 32;
char * buf = Con::getReturnBuffer(bufSize);
dSprintf(buf, bufSize, "%d", ((WayPointTeam*)dptr)->mTeamId);
return(buf);
}

ConsoleSetType( TypeWayPointTeam )
{
WayPointTeam * pTeam = (WayPointTeam*)dptr;
pTeam->mTeamId = dAtoi(argv[0]);

if(pTeam->mWayPoint && pTeam->mWayPoint->isServerObject())
pTeam->mWayPoint->setMaskBits(WayPoint::UpdateTeamMask);
}

void WayPoint::initPersistFields()
{
addGroup("Misc");
addField("markerName", TypeCaseString, Offset(mName, WayPoint), "Unique name representing this waypoint");
addField("team", TypeWayPointTeam, Offset(mTeam, WayPoint), "Unique numerical ID assigned to this waypoint, or set of waypoints");
endGroup("Misc");

Parent::initPersistFields();
}

Expand Down
12 changes: 12 additions & 0 deletions Engine/source/T3D/missionMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ class MissionMarker : public ShapeBase
// Class: WayPoint
//------------------------------------------------------------------------------
class WayPoint;
class WayPointTeam
{
public:
WayPointTeam();

S32 mTeamId;
WayPoint * mWayPoint;
};

DECLARE_STRUCT( WayPointTeam );
DefineConsoleType( TypeWayPointTeam, WayPointTeam * );

class WayPoint : public MissionMarker
{
Expand Down Expand Up @@ -121,6 +132,7 @@ class WayPoint : public MissionMarker

// field data
StringTableEntry mName;
WayPointTeam mTeam;

static void initPersistFields();

Expand Down
42 changes: 8 additions & 34 deletions Engine/source/gui/controls/guiTreeViewCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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)
{
Expand All @@ -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)")
Expand Down
19 changes: 1 addition & 18 deletions Engine/source/gui/core/guiControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) );
//}
}
//-----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 9907c45

Please sign in to comment.