Replaced a ton of ConsoleMethods with the DefineConsoleMethod Macro.

This commit is contained in:
Vincent Gee 2014-11-03 22:42:51 -05:00
parent 378a933894
commit acb192e2a5
133 changed files with 1716 additions and 2087 deletions

View file

@ -28,6 +28,7 @@
#include "T3D/player.h"
#include "T3D/gameBase/moveManager.h"
#include "console/consoleInternal.h"
#include "console/engineAPI.h"
IMPLEMENT_CONOBJECT( AIClient );
@ -52,6 +53,8 @@ ConsoleDocClass( AIClient,
"@ingroup Networking\n"
);
IMPLEMENT_CALLBACK(AIClient, onConnect, void, (const char* idString), (idString),"");
/**
* Constructor
*/
@ -415,15 +418,17 @@ void AIClient::onAdd( const char *nameSpace ) {
/**
* Sets the move speed for an AI object
*/
ConsoleMethod( AIClient, setMoveSpeed, void, 3, 3, "ai.setMoveSpeed( float );" ) {
DefineConsoleMethod( AIClient, setMoveSpeed, void, (F32 speed), , "ai.setMoveSpeed( float );" )
{
AIClient *ai = static_cast<AIClient *>( object );
ai->setMoveSpeed( dAtof( argv[2] ) );
ai->setMoveSpeed( speed );
}
/**
* Stops all AI movement, halt!
*/
ConsoleMethod( AIClient, stop, void, 2, 2, "ai.stop();" ) {
DefineConsoleMethod( AIClient, stop, void, (),, "ai.stop();" )
{
AIClient *ai = static_cast<AIClient *>( object );
ai->setMoveMode( AIClient::ModeStop );
}
@ -431,10 +436,9 @@ ConsoleMethod( AIClient, stop, void, 2, 2, "ai.stop();" ) {
/**
* Tells the AI to aim at the location provided
*/
ConsoleMethod( AIClient, setAimLocation, void, 3, 3, "ai.setAimLocation( x y z );" ) {
DefineConsoleMethod( AIClient, setAimLocation, void, (Point3F v), , "ai.setAimLocation( x y z );" )
{
AIClient *ai = static_cast<AIClient *>( object );
Point3F v( 0.0f,0.0f,0.0f );
dSscanf( argv[2], "%f %f %f", &v.x, &v.y, &v.z );
ai->setAimLocation( v );
}
@ -442,10 +446,9 @@ ConsoleMethod( AIClient, setAimLocation, void, 3, 3, "ai.setAimLocation( x y z )
/**
* Tells the AI to move to the location provided
*/
ConsoleMethod( AIClient, setMoveDestination, void, 3, 3, "ai.setMoveDestination( x y z );" ) {
DefineConsoleMethod( AIClient, setMoveDestination, void, (Point3F v), , "ai.setMoveDestination( x y z );" )
{
AIClient *ai = static_cast<AIClient *>( object );
Point3F v( 0.0f, 0.0f, 0.0f );
dSscanf( argv[2], "%f %f", &v.x, &v.y );
ai->setMoveDestination( v );
}
@ -453,13 +456,13 @@ ConsoleMethod( AIClient, setMoveDestination, void, 3, 3, "ai.setMoveDestination(
/**
* Returns the point the AI is aiming at
*/
ConsoleMethod( AIClient, getAimLocation, const char *, 2, 2, "ai.getAimLocation();" ) {
DefineConsoleMethod( AIClient, getAimLocation, const char *, (),, "ai.getAimLocation();" )
{
AIClient *ai = static_cast<AIClient *>( object );
Point3F aimPoint = ai->getAimLocation();
static const U32 bufSize = 256;
char *returnBuffer = Con::getReturnBuffer( bufSize );
dSprintf( returnBuffer, bufSize, "%f %f %f", aimPoint.x, aimPoint.y, aimPoint.z );
char *returnBuffer = Con::getReturnBuffer( 256 );
dSprintf( returnBuffer, 256, "%f %f %f", aimPoint.x, aimPoint.y, aimPoint.z );
return returnBuffer;
}
@ -467,13 +470,13 @@ ConsoleMethod( AIClient, getAimLocation, const char *, 2, 2, "ai.getAimLocation(
/**
* Returns the point the AI is set to move to
*/
ConsoleMethod( AIClient, getMoveDestination, const char *, 2, 2, "ai.getMoveDestination();" ) {
DefineConsoleMethod( AIClient, getMoveDestination, const char *, (),, "ai.getMoveDestination();" )
{
AIClient *ai = static_cast<AIClient *>( object );
Point3F movePoint = ai->getMoveDestination();
static const U32 bufSize = 256;
char *returnBuffer = Con::getReturnBuffer( bufSize );
dSprintf( returnBuffer, bufSize, "%f %f %f", movePoint.x, movePoint.y, movePoint.z );
char *returnBuffer = Con::getReturnBuffer( 256 );
dSprintf( returnBuffer, 256, "%f %f %f", movePoint.x, movePoint.y, movePoint.z );
return returnBuffer;
}
@ -481,12 +484,13 @@ ConsoleMethod( AIClient, getMoveDestination, const char *, 2, 2, "ai.getMoveDest
/**
* Sets the bots target object
*/
ConsoleMethod( AIClient, setTargetObject, void, 3, 3, "ai.setTargetObject( obj );" ) {
DefineConsoleMethod( AIClient, setTargetObject, void, (const char * objName), , "ai.setTargetObject( obj );" )
{
AIClient *ai = static_cast<AIClient *>( object );
// Find the target
ShapeBase *targetObject;
if( Sim::findObject( argv[2], targetObject ) )
if( Sim::findObject( objName, targetObject ) )
ai->setTargetObject( targetObject );
else
ai->setTargetObject( NULL );
@ -495,7 +499,8 @@ ConsoleMethod( AIClient, setTargetObject, void, 3, 3, "ai.setTargetObject( obj )
/**
* Gets the object the AI is targeting
*/
ConsoleMethod( AIClient, getTargetObject, S32, 2, 2, "ai.getTargetObject();" ) {
DefineConsoleMethod( AIClient, getTargetObject, S32, (),, "ai.getTargetObject();" )
{
AIClient *ai = static_cast<AIClient *>( object );
return ai->getTargetObject();
@ -504,7 +509,8 @@ ConsoleMethod( AIClient, getTargetObject, S32, 2, 2, "ai.getTargetObject();" ) {
/**
* Tells the bot the mission is cycling
*/
ConsoleMethod( AIClient, missionCycleCleanup, void, 2, 2, "ai.missionCycleCleanup();" ) {
DefineConsoleMethod( AIClient, missionCycleCleanup, void, (),, "ai.missionCycleCleanup();" )
{
AIClient *ai = static_cast<AIClient*>( object );
ai->missionCycleCleanup();
}
@ -512,7 +518,8 @@ ConsoleMethod( AIClient, missionCycleCleanup, void, 2, 2, "ai.missionCycleCleanu
/**
* Sets the AI to run mode
*/
ConsoleMethod( AIClient, move, void, 2, 2, "ai.move();" ) {
DefineConsoleMethod( AIClient, move, void, (),, "ai.move();" )
{
AIClient *ai = static_cast<AIClient *>( object );
ai->setMoveMode( AIClient::ModeMove );
}
@ -520,13 +527,13 @@ ConsoleMethod( AIClient, move, void, 2, 2, "ai.move();" ) {
/**
* Gets the AI's location in the world
*/
ConsoleMethod( AIClient, getLocation, const char *, 2, 2, "ai.getLocation();" ) {
DefineConsoleMethod( AIClient, getLocation, const char *, (),, "ai.getLocation();" )
{
AIClient *ai = static_cast<AIClient *>( object );
Point3F locPoint = ai->getLocation();
static const U32 bufSize = 256;
char *returnBuffer = Con::getReturnBuffer( bufSize );
dSprintf( returnBuffer, bufSize, "%f %f %f", locPoint.x, locPoint.y, locPoint.z );
char *returnBuffer = Con::getReturnBuffer( 256 );
dSprintf( returnBuffer, 256, "%f %f %f", locPoint.x, locPoint.y, locPoint.z );
return returnBuffer;
}
@ -534,7 +541,8 @@ ConsoleMethod( AIClient, getLocation, const char *, 2, 2, "ai.getLocation();" )
/**
* Adds an AI Player to the game
*/
ConsoleFunction( aiAddPlayer, S32 , 2, 3, "aiAddPlayer( 'playerName'[, 'AIClassType'] );" ) {
DefineConsoleFunction( aiAddPlayer, S32, (const char * name, const char * ns), (""), "'playerName'[, 'AIClassType'] );")
{
// Create the player
AIClient *aiPlayer = new AIClient();
aiPlayer->registerObject();
@ -548,18 +556,13 @@ ConsoleFunction( aiAddPlayer, S32 , 2, 3, "aiAddPlayer( 'playerName'[, 'AIClassT
SimGroup *g = Sim::getClientGroup();
g->addObject( aiPlayer );
char *name = new char[ dStrlen( argv[1] ) + 1];
char *ns = new char[ dStrlen( argv[2] ) + 1];
dStrcpy( name, argv[1] );
dStrcpy( ns, argv[2] );
// Execute the connect console function, this is the same
// onConnect function invoked for normal client connections
Con::executef( aiPlayer, "onConnect", name );
aiPlayer->onConnect_callback( name );
// Now execute the onAdd command and feed it the namespace
if( argc > 2 )
if( ns != "" )
aiPlayer->onAdd( ns );
else
aiPlayer->onAdd( "AIClient" );
@ -571,7 +574,8 @@ ConsoleFunction( aiAddPlayer, S32 , 2, 3, "aiAddPlayer( 'playerName'[, 'AIClassT
/**
* Tells the AI to move forward 100 units...TEST FXN
*/
ConsoleMethod( AIClient, moveForward, void, 2, 2, "ai.moveForward();" ) {
DefineConsoleMethod( AIClient, moveForward, void, (),, "ai.moveForward();" )
{
AIClient *ai = static_cast<AIClient *>( object );
ShapeBase *player = dynamic_cast<ShapeBase*>(ai->getControlObject());

View file

@ -70,6 +70,8 @@ class AIClient : public AIConnection {
DECLARE_CONOBJECT( AIClient );
DECLARE_CALLBACK( void, onConnect, (const char* idString) );
enum {
ModeStop = 0,
ModeMove,

View file

@ -21,6 +21,7 @@
//-----------------------------------------------------------------------------
#include "T3D/aiConnection.h"
#include "console/engineAPI.h"
IMPLEMENT_CONOBJECT( AIConnection );
@ -159,7 +160,7 @@ ConsoleFunction(aiConnect, S32 , 2, 20, "(...)"
//-----------------------------------------------------------------------------
ConsoleMethod(AIConnection,setMove,void,4, 4,"(string field, float value)"
DefineConsoleMethod(AIConnection, setMove, void, (const char * field, F32 value), ,"(string field, float value)"
"Set a field on the current move.\n\n"
"@param field One of {'x','y','z','yaw','pitch','roll'}\n"
"@param value Value to set field to.")
@ -167,59 +168,59 @@ ConsoleMethod(AIConnection,setMove,void,4, 4,"(string field, float value)"
Move move = object->getMove();
// Ok, a little slow for now, but this is just an example..
if (!dStricmp(argv[2],"x"))
move.x = mClampF(dAtof(argv[3]),-1,1);
if (!dStricmp(field,"x"))
move.x = mClampF(value,-1,1);
else
if (!dStricmp(argv[2],"y"))
move.y = mClampF(dAtof(argv[3]),-1,1);
if (!dStricmp(field,"y"))
move.y = mClampF(value,-1,1);
else
if (!dStricmp(argv[2],"z"))
move.z = mClampF(dAtof(argv[3]),-1,1);
if (!dStricmp(field,"z"))
move.z = mClampF(value,-1,1);
else
if (!dStricmp(argv[2],"yaw"))
move.yaw = moveClamp(dAtof(argv[3]));
if (!dStricmp(field,"yaw"))
move.yaw = moveClamp(value);
else
if (!dStricmp(argv[2],"pitch"))
move.pitch = moveClamp(dAtof(argv[3]));
if (!dStricmp(field,"pitch"))
move.pitch = moveClamp(value);
else
if (!dStricmp(argv[2],"roll"))
move.roll = moveClamp(dAtof(argv[3]));
if (!dStricmp(field,"roll"))
move.roll = moveClamp(value);
//
object->setMove(&move);
}
ConsoleMethod(AIConnection,getMove,F32,3, 3,"(string field)"
DefineConsoleMethod(AIConnection,getMove,F32, (const char * field), ,"(string field)"
"Get the given field of a move.\n\n"
"@param field One of {'x','y','z','yaw','pitch','roll'}\n"
"@returns The requested field on the current move.")
{
const Move& move = object->getMove();
if (!dStricmp(argv[2],"x"))
if (!dStricmp(field,"x"))
return move.x;
if (!dStricmp(argv[2],"y"))
if (!dStricmp(field,"y"))
return move.y;
if (!dStricmp(argv[2],"z"))
if (!dStricmp(field,"z"))
return move.z;
if (!dStricmp(argv[2],"yaw"))
if (!dStricmp(field,"yaw"))
return move.yaw;
if (!dStricmp(argv[2],"pitch"))
if (!dStricmp(field,"pitch"))
return move.pitch;
if (!dStricmp(argv[2],"roll"))
if (!dStricmp(field,"roll"))
return move.roll;
return 0;
}
ConsoleMethod(AIConnection,setFreeLook,void,3, 3,"(bool isFreeLook)"
DefineConsoleMethod(AIConnection,setFreeLook,void,(bool isFreeLook), ,"(bool isFreeLook)"
"Enable/disable freelook on the current move.")
{
Move move = object->getMove();
move.freeLook = dAtob(argv[2]);
move.freeLook = isFreeLook;
object->setMove(&move);
}
ConsoleMethod(AIConnection,getFreeLook,bool,2, 2,"getFreeLook()"
DefineConsoleMethod(AIConnection, getFreeLook, bool, (), ,"getFreeLook()"
"Is freelook on for the current move?")
{
return object->getMove().freeLook;
@ -228,21 +229,20 @@ ConsoleMethod(AIConnection,getFreeLook,bool,2, 2,"getFreeLook()"
//-----------------------------------------------------------------------------
ConsoleMethod(AIConnection,setTrigger,void,4, 4,"(int trigger, bool set)"
DefineConsoleMethod(AIConnection,setTrigger,void, (S32 idx, bool set), ,"(int trigger, bool set)"
"Set a trigger.")
{
S32 idx = dAtoi(argv[2]);
if (idx >= 0 && idx < MaxTriggerKeys) {
if (idx >= 0 && idx < MaxTriggerKeys)
{
Move move = object->getMove();
move.trigger[idx] = dAtob(argv[3]);
move.trigger[idx] = set;
object->setMove(&move);
}
}
ConsoleMethod(AIConnection,getTrigger,bool,4, 4,"(int trigger)"
DefineConsoleMethod(AIConnection,getTrigger,bool, (S32 idx), ,"(int trigger)"
"Is the given trigger set?")
{
S32 idx = dAtoi(argv[2]);
if (idx >= 0 && idx < MaxTriggerKeys)
return object->getMove().trigger[idx];
return false;
@ -251,7 +251,7 @@ ConsoleMethod(AIConnection,getTrigger,bool,4, 4,"(int trigger)"
//-----------------------------------------------------------------------------
ConsoleMethod(AIConnection,getAddress,const char*,2, 2,"")
DefineConsoleMethod(AIConnection,getAddress,const char*,(), ,"")
{
// Override the netConnection method to return to indicate
// this is an ai connection.

View file

@ -575,23 +575,21 @@ ConsoleDocFragment _setAimObject(
"AIPlayer",
"void setAimObject(GameBase targetObject, Point3F offset);"
);
ConsoleMethod( AIPlayer, setAimObject, void, 3, 4, "( GameBase obj, [Point3F offset] )"
DefineConsoleMethod( AIPlayer, setAimObject, void, ( const char * objName, Point3F offset ), (Point3F::Zero), "( GameBase obj, [Point3F offset] )"
"Sets the bot's target object. Optionally set an offset from target location."
"@hide")
{
Point3F off( 0.0f, 0.0f, 0.0f );
// Find the target
GameBase *targetObject;
if( Sim::findObject( argv[2], targetObject ) )
if( Sim::findObject( objName, targetObject ) )
{
if (argc == 4)
dSscanf( argv[3], "%g %g %g", &off.x, &off.y, &off.z );
object->setAimObject( targetObject, off );
object->setAimObject( targetObject, offset );
}
else
object->setAimObject( 0, off );
object->setAimObject( 0, offset );
}
DefineEngineMethod( AIPlayer, getAimObject, S32, (),,

View file

@ -1860,7 +1860,7 @@ DefineEngineMethod( Camera, setOffset, void, (Point3F offset), ,
//-----------------------------------------------------------------------------
DefineEngineMethod( Camera, setOrbitMode, void, (GameBase* orbitObject, TransformF orbitPoint, F32 minDistance, F32 maxDistance,
F32 initDistance, bool ownClientObj, Point3F offset, bool locked), (false, Point3F(0.0f, 0.0f, 0.0f), false),
F32 initDistance, bool ownClientObj, Point3F offset, bool locked), (false, Point3F::Zero, false),
"Set the camera to orbit around the given object, or if none is given, around the given point.\n\n"
"@param orbitObject The object to orbit around. If no object is given (0 or blank string is passed in) use the orbitPoint instead\n"
"@param orbitPoint The point to orbit around when no object is given. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform().\n"
@ -1883,7 +1883,7 @@ DefineEngineMethod( Camera, setOrbitMode, void, (GameBase* orbitObject, Transfor
DefineEngineMethod( Camera, setOrbitObject, bool, (GameBase* orbitObject, VectorF rotation, F32 minDistance,
F32 maxDistance, F32 initDistance, bool ownClientObject, Point3F offset, bool locked),
(false, Point3F(0.0f, 0.0f, 0.0f), false),
(false, Point3F::Zero, false),
"Set the camera to orbit around a given object.\n\n"
"@param orbitObject The object to orbit around.\n"
"@param rotation The initial camera rotation about the object in radians in the form of \"x y z\".\n"
@ -1911,7 +1911,7 @@ DefineEngineMethod( Camera, setOrbitObject, bool, (GameBase* orbitObject, Vector
DefineEngineMethod( Camera, setOrbitPoint, void, (TransformF orbitPoint, F32 minDistance, F32 maxDistance, F32 initDistance,
Point3F offset, bool locked),
(Point3F(0.0f, 0.0f, 0.0f), false),
(Point3F::Zero, false),
"Set the camera to orbit around a given point.\n\n"
"@param orbitPoint The point to orbit around. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform().\n"
"@param minDistance The minimum distance allowed to the orbit object or point.\n"
@ -1929,7 +1929,7 @@ DefineEngineMethod( Camera, setOrbitPoint, void, (TransformF orbitPoint, F32 min
//-----------------------------------------------------------------------------
DefineEngineMethod( Camera, setTrackObject, bool, (GameBase* trackObject, Point3F offset), (Point3F(0.0f, 0.0f, 0.0f)),
DefineEngineMethod( Camera, setTrackObject, bool, (GameBase* trackObject, Point3F offset), (Point3F::Zero),
"Set the camera to track a given object.\n\n"
"@param trackObject The object to track.\n"
"@param offset [optional] An offset added to the camera's position. Default is no offset.\n"

View file

@ -138,8 +138,17 @@ ConsoleDocClass( Explosion,
MRandomLCG sgRandom(0xdeadbeef);
//WLE - Vince - The defaults are bad, the whole point of calling this function\
//is to determine the explosion coverage on a object. Why would you want them
//To call this with a null for the ID? In fact, it just returns a 1f if
//it can't find the object. Seems useless to me. Cause how can I apply
//damage to a object that doesn't exist?
DefineEngineFunction(calcExplosionCoverage, F32, (Point3F pos, S32 id, U32 covMask),(Point3F(0.0f,0.0f,0.0f), NULL, NULL),
//I could possible see a use with passing in a null covMask, but even that
//sounds flaky because it will be 100 percent if your saying not to take
//any thing in consideration for coverage. So I'm removing these defaults they are just bad.
DefineEngineFunction(calcExplosionCoverage, F32, (Point3F pos, S32 id, U32 covMask),,
"@brief Calculates how much an explosion effects a specific object.\n\n"
"Use this to determine how much damage to apply to objects based on their "
"distance from the explosion's center point, and whether the explosion is "

View file

@ -929,13 +929,10 @@ DefineEngineMethod(Lightning, strikeRandomPoint, void, (),,
object->strikeRandomPoint();
}
DefineEngineMethod(Lightning, strikeObject, void, (S32 id), (NULL),
DefineEngineMethod(Lightning, strikeObject, void, (ShapeBase* pSB),,
"Creates a LightningStrikeEvent which strikes a specific object.\n"
"@note This method is currently unimplemented.\n" )
{
ShapeBase* pSB;
if (object->isServerObject() && Sim::findObject(id, pSB))
object->strikeObject(pSB);
}

View file

@ -393,8 +393,9 @@ void ParticleEmitterNode::setEmitterDataBlock(ParticleEmitterData* data)
mEmitterDatablock = data;
}
DefineEngineMethod(ParticleEmitterNode, setEmitterDataBlock, void, (ParticleEmitterData* emitterDatablock), (0),
DefineEngineMethod(ParticleEmitterNode, setEmitterDataBlock, void, (ParticleEmitterData* emitterDatablock), (NULL),
"Assigns the datablock for this emitter node.\n"
"@param emitterDatablock ParticleEmitterData datablock to assign\n"
"@tsexample\n"

View file

@ -506,7 +506,7 @@ DefineEngineMethod(Precipitation, modifyStorm, void, (F32 percentage, F32 second
object->modifyStorm(percentage, S32(seconds * 1000.0f));
}
DefineEngineMethod(Precipitation, setTurbulence, void, (F32 max, F32 speed, F32 seconds), (1.0f, 5.0f, 5.0),
DefineEngineMethod(Precipitation, setTurbulence, void, (F32 max, F32 speed, F32 seconds), (1.0f, 5.0f, 5.0f),
"Smoothly change the turbulence parameters over a period of time.\n"
"@param max New #maxTurbulence value. Set to 0 to disable turbulence.\n"
"@param speed New #turbulenceSpeed value.\n"

View file

@ -20,6 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "console/engineAPI.h"
#include "platform/platform.h"
#include "T3D/gameBase/gameProcess.h"
@ -33,7 +34,7 @@ ClientProcessList* ClientProcessList::smClientProcessList = NULL;
ServerProcessList* ServerProcessList::smServerProcessList = NULL;
static U32 gNetOrderNextId = 0;
ConsoleFunction( dumpProcessList, void, 1, 1,
DefineConsoleFunction( dumpProcessList, void, ( bool allow ), ,
"Dumps all ProcessObjects in ServerProcessList and ClientProcessList to the console." )
{
Con::printf( "client process list:" );

View file

@ -88,7 +88,7 @@ extern void ShowInit();
//------------------------------------------------------------------------------
/// Camera and FOV info
namespace {
namespace CameraAndFOV{
const U32 MaxZoomSpeed = 2000; ///< max number of ms to reach target FOV
@ -112,7 +112,7 @@ static U32 sgServerQueryIndex = 0;
//SERVER FUNCTIONS ONLY
ConsoleFunctionGroupBegin( Containers, "Spatial query functions. <b>Server side only!</b>");
ConsoleFunction(containerFindFirst, const char*, 6, 6, "(int mask, Point3F point, float x, float y, float z)"
DefineConsoleFunction( containerFindFirst, const char*, (U32 typeMask, Point3F origin, Point3F size), , "(int mask, Point3F point, float x, float y, float z)"
"@brief Find objects matching the bitmask type within a box centered at point, with extents x, y, z.\n\n"
"@returns The first object found, or an empty string if nothing was found. Thereafter, you can get more "
"results using containerFindNext()."
@ -120,17 +120,6 @@ ConsoleFunction(containerFindFirst, const char*, 6, 6, "(int mask, Point3F point
"@ingroup Game")
{
//find out what we're looking for
U32 typeMask = U32(dAtoi(argv[1]));
//find the center of the container volume
Point3F origin(0.0f, 0.0f, 0.0f);
dSscanf(argv[2], "%g %g %g", &origin.x, &origin.y, &origin.z);
//find the box dimensions
Point3F size(0.0f, 0.0f, 0.0f);
size.x = mFabs(dAtof(argv[3]));
size.y = mFabs(dAtof(argv[4]));
size.z = mFabs(dAtof(argv[5]));
//build the container volume
Box3F queryBox;
@ -155,7 +144,7 @@ ConsoleFunction(containerFindFirst, const char*, 6, 6, "(int mask, Point3F point
return buff;
}
ConsoleFunction( containerFindNext, const char*, 1, 1, "()"
DefineConsoleFunction( containerFindNext, const char*, (), , "()"
"@brief Get more results from a previous call to containerFindFirst().\n\n"
"@note You must call containerFindFirst() to begin the search.\n"
"@returns The next object found, or an empty string if nothing else was found.\n"
@ -191,9 +180,9 @@ DefineEngineFunction( setDefaultFov, void, ( F32 defaultFOV ),,
"@param defaultFOV The default field of view in degrees\n"
"@ingroup CameraSystem")
{
sDefaultFov = mClampF(defaultFOV, MinCameraFov, MaxCameraFov);
if(sCameraFov == sTargetFov)
sTargetFov = sDefaultFov;
CameraAndFOV::sDefaultFov = mClampF(defaultFOV, MinCameraFov, MaxCameraFov);
if(CameraAndFOV::sCameraFov == CameraAndFOV::sTargetFov)
CameraAndFOV::sTargetFov = CameraAndFOV::sDefaultFov;
}
DefineEngineFunction( setZoomSpeed, void, ( S32 speed ),,
@ -203,7 +192,7 @@ DefineEngineFunction( setZoomSpeed, void, ( S32 speed ),,
"@param speed The camera's zoom speed in ms per 90deg FOV change\n"
"@ingroup CameraSystem")
{
sZoomSpeed = mClamp(speed, 0, MaxZoomSpeed);
CameraAndFOV::sZoomSpeed = mClamp(speed, 0, CameraAndFOV::MaxZoomSpeed);
}
DefineEngineFunction( setFov, void, ( F32 FOV ),,
@ -211,22 +200,22 @@ DefineEngineFunction( setFov, void, ( F32 FOV ),,
"@param FOV The camera's new FOV in degrees\n"
"@ingroup CameraSystem")
{
sTargetFov = mClampF(FOV, MinCameraFov, MaxCameraFov);
CameraAndFOV::sTargetFov = mClampF(FOV, MinCameraFov, MaxCameraFov);
}
F32 GameGetCameraFov()
{
return(sCameraFov);
return(CameraAndFOV::sCameraFov);
}
void GameSetCameraFov(F32 fov)
{
sTargetFov = sCameraFov = fov;
CameraAndFOV::sTargetFov = CameraAndFOV::sCameraFov = fov;
}
void GameSetCameraTargetFov(F32 fov)
{
sTargetFov = fov;
CameraAndFOV::sTargetFov = fov;
}
void GameUpdateCameraFov()
@ -234,29 +223,29 @@ void GameUpdateCameraFov()
F32 time = F32(Platform::getVirtualMilliseconds());
// need to update fov?
if(sTargetFov != sCameraFov)
if(CameraAndFOV::sTargetFov != CameraAndFOV::sCameraFov)
{
F32 delta = time - sLastCameraUpdateTime;
F32 delta = time - CameraAndFOV::sLastCameraUpdateTime;
// snap zoom?
if((sZoomSpeed == 0) || (delta <= 0.f))
sCameraFov = sTargetFov;
if((CameraAndFOV::sZoomSpeed == 0) || (delta <= 0.f))
CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov;
else
{
// gZoomSpeed is time in ms to zoom 90deg
F32 step = 90.f * (delta / F32(sZoomSpeed));
F32 step = 90.f * (delta / F32(CameraAndFOV::sZoomSpeed));
if(sCameraFov > sTargetFov)
if(CameraAndFOV::sCameraFov > CameraAndFOV::sTargetFov)
{
sCameraFov -= step;
if(sCameraFov < sTargetFov)
sCameraFov = sTargetFov;
CameraAndFOV::sCameraFov -= step;
if(CameraAndFOV::sCameraFov < CameraAndFOV::sTargetFov)
CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov;
}
else
{
sCameraFov += step;
if(sCameraFov > sTargetFov)
sCameraFov = sTargetFov;
CameraAndFOV::sCameraFov += step;
if(CameraAndFOV::sCameraFov > CameraAndFOV::sTargetFov)
CameraAndFOV::sCameraFov = CameraAndFOV::sTargetFov;
}
}
}
@ -266,23 +255,23 @@ void GameUpdateCameraFov()
if(connection)
{
// check if fov is valid on control object
if(connection->isValidControlCameraFov(sCameraFov))
connection->setControlCameraFov(sCameraFov);
if(connection->isValidControlCameraFov(CameraAndFOV::sCameraFov))
connection->setControlCameraFov(CameraAndFOV::sCameraFov);
else
{
// will set to the closest fov (fails only on invalid control object)
if(connection->setControlCameraFov(sCameraFov))
if(connection->setControlCameraFov(CameraAndFOV::sCameraFov))
{
F32 setFov = sCameraFov;
F32 setFov = CameraAndFOV::sCameraFov;
connection->getControlCameraFov(&setFov);
sTargetFov = sCameraFov = setFov;
CameraAndFOV::sTargetFov =CameraAndFOV::sCameraFov = setFov;
}
}
}
// update the console variable
sConsoleCameraFov = sCameraFov;
sLastCameraUpdateTime = time;
CameraAndFOV::sConsoleCameraFov = CameraAndFOV::sCameraFov;
CameraAndFOV::sLastCameraUpdateTime = time;
}
//--------------------------------------------------------------------------
@ -355,8 +344,8 @@ bool GameProcessCameraQuery(CameraQuery *query)
// Scale the normal visible distance by the performance
// tuning scale which we never let over 1.
sVisDistanceScale = mClampF( sVisDistanceScale, 0.01f, 1.0f );
query->farPlane = gClientSceneGraph->getVisibleDistance() * sVisDistanceScale;
CameraAndFOV::sVisDistanceScale = mClampF( CameraAndFOV::sVisDistanceScale, 0.01f, 1.0f );
query->farPlane = gClientSceneGraph->getVisibleDistance() * CameraAndFOV::sVisDistanceScale;
// Provide some default values
query->projectionOffset = Point2F::Zero;
@ -432,10 +421,10 @@ static void Process3D()
static void RegisterGameFunctions()
{
Con::addVariable( "$pref::Camera::distanceScale", TypeF32, &sVisDistanceScale,
Con::addVariable( "$pref::Camera::distanceScale", TypeF32, &CameraAndFOV::sVisDistanceScale,
"A scale to apply to the normal visible distance, typically used for tuning performance.\n"
"@ingroup Game");
Con::addVariable( "$cameraFov", TypeF32, &sConsoleCameraFov,
Con::addVariable( "$cameraFov", TypeF32, &CameraAndFOV::sConsoleCameraFov,
"The camera's Field of View.\n\n"
"@ingroup Game" );

View file

@ -425,21 +425,22 @@ static ConsoleDocFragment _lbplayAnimation2(
"LightBase",
"void playAnimation(LightAnimData anim);"
);
ConsoleMethod( LightBase, playAnimation, void, 2, 3, "( [LightAnimData anim] )\t"
DefineConsoleMethod( LightBase, playAnimation, void, (const char * anim), (""), "( [LightAnimData anim] )\t"
"Plays a light animation on the light. If no LightAnimData is passed the "
"existing one is played."
"@hide")
{
if ( argc == 2 )
if ( anim == "" )
{
object->playAnimation();
return;
}
LightAnimData *animData;
if ( !Sim::findObject( argv[2], animData ) )
if ( !Sim::findObject( anim, animData ) )
{
Con::errorf( "LightBase::playAnimation() - Invalid LightAnimData '%s'.", (const char*)argv[2] );
Con::errorf( "LightBase::playAnimation() - Invalid LightAnimData '%s'.", anim );
return;
}
@ -469,7 +470,7 @@ void LightBase::playAnimation( LightAnimData *animData )
}
}
ConsoleMethod( LightBase, pauseAnimation, void, 2, 2, "Stops the light animation." )
DefineConsoleMethod( LightBase, pauseAnimation, void, (), , "Stops the light animation." )
{
object->pauseAnimation();
}

View file

@ -223,12 +223,6 @@ ConsoleDocClass( WayPoint,
"@ingroup enviroMisc\n"
);
WayPointTeam::WayPointTeam()
{
mTeamId = 0;
mWayPoint = 0;
}
WayPoint::WayPoint()
{
mName = StringTable->insert("");
@ -252,7 +246,6 @@ bool WayPoint::onAdd()
Sim::getWayPointSet()->addObject(this);
else
{
mTeam.mWayPoint = this;
setMaskBits(UpdateNameMask|UpdateTeamMask);
}
@ -272,8 +265,6 @@ 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);
@ -284,48 +275,17 @@ 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
//-----------------------------------------------------------------------------
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();
}
@ -546,16 +506,17 @@ ConsoleDocFragment _SpawnSpherespawnObject1(
"bool spawnObject(string additionalProps);"
);
ConsoleMethod(SpawnSphere, spawnObject, S32, 2, 3,
//ConsoleMethod(SpawnSphere, spawnObject, S32, 2, 3,
DefineConsoleMethod(SpawnSphere, spawnObject, S32, (String additionalProps), ,
"([string additionalProps]) Spawns the object based on the SpawnSphere's "
"class, datablock, properties, and script settings. Allows you to pass in "
"extra properties."
"@hide" )
{
String additionalProps;
//String additionalProps;
if (argc == 3)
additionalProps = (const char*)argv[2];
//if (argc == 3)
// additionalProps = String(argv[2]);
SimObject* obj = object->spawnObject(additionalProps);

View file

@ -92,17 +92,6 @@ 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
{
@ -132,7 +121,6 @@ class WayPoint : public MissionMarker
// field data
StringTableEntry mName;
WayPointTeam mTeam;
static void initPersistFields();

View file

@ -581,7 +581,7 @@ static CameraSpline::Knot::Path resolveKnotPath(const char *arg)
}
DefineEngineMethod(PathCamera, pushBack, void, (TransformF transform, F32 speed, const char* type, const char* path),
(1.0, "Normal", "Linear"),
(1.0f, "Normal", "Linear"),
"@brief Adds a new knot to the back of a path camera's path.\n"
"@param transform Transform for the new knot. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform()\n"
"@param speed Speed setting for this knot.\n"
@ -606,7 +606,7 @@ DefineEngineMethod(PathCamera, pushBack, void, (TransformF transform, F32 speed,
}
DefineEngineMethod(PathCamera, pushFront, void, (TransformF transform, F32 speed, const char* type, const char* path),
(1.0, "Normal", "Linear"),
(1.0f, "Normal", "Linear"),
"@brief Adds a new knot to the front of a path camera's path.\n"
"@param transform Transform for the new knot. In the form of \"x y z ax ay az aa\" such as returned by SceneObject::getTransform()\n"
"@param speed Speed setting for this knot.\n"

View file

@ -27,6 +27,7 @@
#include "math/mathUtils.h"
#include "console/consoleTypes.h"
#include "console/consoleObject.h"
#include "console/engineAPI.h"
#include "sim/netConnection.h"
#include "scene/sceneRenderState.h"
#include "scene/sceneManager.h"
@ -237,7 +238,7 @@ void PhysicsDebrisData::unpackData(BitStream* stream)
shapeName = stream->readSTString();
}
ConsoleMethod( PhysicsDebrisData, preload, void, 2, 2,
DefineConsoleMethod( PhysicsDebrisData, preload, void, (), ,
"@brief Loads some information to have readily available at simulation time.\n\n"
"Forces generation of shaders, materials, and other data used by the %PhysicsDebris object. "
"This function should be used while a level is loading in order to shorten "

View file

@ -24,6 +24,7 @@
#include "T3D/physics/physicsPlugin.h"
#include "console/console.h"
#include "console/engineAPI.h"
#include "console/consoleTypes.h"
#include "console/simSet.h"
#include "core/strings/stringFunctions.h"
@ -123,55 +124,53 @@ void PhysicsPlugin::_debugDraw( SceneManager *graph, const SceneRenderState *sta
world->onDebugDraw( state );
}
ConsoleFunction( physicsPluginPresent, bool, 1, 1, "physicsPluginPresent()\n"
DefineConsoleFunction( physicsPluginPresent, bool, (), , "physicsPluginPresent()"
"@brief Returns true if a physics plugin exists and is initialized.\n\n"
"@ingroup Physics" )
{
return PHYSICSMGR != NULL;
}
ConsoleFunction( physicsInit, bool, 1, 2, "physicsInit( [string library] )" )
DefineConsoleFunction( physicsInit, bool, (const char * library), (""), "physicsInit( [string library] )")
{
const char *library = "default";
if ( argc > 1 )
library = argv[1];
return PhysicsPlugin::activate( library );
}
ConsoleFunction( physicsDestroy, void, 1, 1, "physicsDestroy()" )
DefineConsoleFunction( physicsDestroy, void, (), , "physicsDestroy()")
{
if ( PHYSICSMGR )
PHYSICSMGR->destroyPlugin();
}
ConsoleFunction( physicsInitWorld, bool, 2, 2, "physicsInitWorld( String worldName )" )
DefineConsoleFunction( physicsInitWorld, bool, (const char * worldName), , "physicsInitWorld( String worldName )")
{
return PHYSICSMGR && PHYSICSMGR->createWorld( (const char*)argv[1] );
bool res = PHYSICSMGR && PHYSICSMGR->createWorld( String( worldName ) );
return res;
}
ConsoleFunction( physicsDestroyWorld, void, 2, 2, "physicsDestroyWorld( String worldName )" )
DefineConsoleFunction( physicsDestroyWorld, void, (const char * worldName), , "physicsDestroyWorld( String worldName )")
{
if ( PHYSICSMGR )
PHYSICSMGR->destroyWorld( (const char*)argv[1] );
{ PHYSICSMGR->destroyWorld( String( worldName ) ); }
}
// Control/query of the stop/started state
// of the currently running simulation.
ConsoleFunction( physicsStartSimulation, void, 2, 2, "physicsStartSimulation( String worldName )" )
DefineConsoleFunction( physicsStartSimulation, void, (const char * worldName), , "physicsStartSimulation( String worldName )")
{
if ( PHYSICSMGR )
PHYSICSMGR->enableSimulation( (const char*)argv[1], true );
PHYSICSMGR->enableSimulation( String( worldName ), true );
}
ConsoleFunction( physicsStopSimulation, void, 2, 2, "physicsStopSimulation( String worldName )" )
DefineConsoleFunction( physicsStopSimulation, void, (const char * worldName), , "physicsStopSimulation( String worldName )")
{
if ( PHYSICSMGR )
PHYSICSMGR->enableSimulation( (const char*)argv[1], false );
PHYSICSMGR->enableSimulation( String( worldName ), false );
}
ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled()" )
DefineConsoleFunction( physicsSimulationEnabled, bool, (), , "physicsStopSimulation( String worldName )")
{
return PHYSICSMGR && PHYSICSMGR->isSimulationEnabled();
}
@ -179,14 +178,14 @@ ConsoleFunction( physicsSimulationEnabled, bool, 1, 1, "physicsSimulationEnabled
// Used for slowing down time on the
// physics simulation, and for pausing/restarting
// the simulation.
ConsoleFunction( physicsSetTimeScale, void, 2, 2, "physicsSetTimeScale( F32 scale )" )
DefineConsoleFunction( physicsSetTimeScale, void, (F32 scale), , "physicsSetTimeScale( F32 scale )")
{
if ( PHYSICSMGR )
PHYSICSMGR->setTimeScale( argv[1] );
PHYSICSMGR->setTimeScale( scale );
}
// Get the currently set time scale.
ConsoleFunction( physicsGetTimeScale, F32, 1, 1, "physicsGetTimeScale()" )
DefineConsoleFunction( physicsGetTimeScale, F32, (), , "physicsGetTimeScale()")
{
return PHYSICSMGR && PHYSICSMGR->getTimeScale();
}
@ -195,7 +194,7 @@ ConsoleFunction( physicsGetTimeScale, F32, 1, 1, "physicsGetTimeScale()" )
// physics simulation that they should store
// their current state for later restoration,
// such as when the editor is closed.
ConsoleFunction( physicsStoreState, void, 1, 1, "physicsStoreState()" )
DefineConsoleFunction( physicsStoreState, void, (), , "physicsStoreState()")
{
PhysicsPlugin::getPhysicsResetSignal().trigger( PhysicsResetEvent_Store );
}
@ -203,14 +202,14 @@ ConsoleFunction( physicsStoreState, void, 1, 1, "physicsStoreState()" )
// Used to send a signal to objects in the
// physics simulation that they should restore
// their saved state, such as when the editor is opened.
ConsoleFunction( physicsRestoreState, void, 1, 1, "physicsRestoreState()" )
DefineConsoleFunction( physicsRestoreState, void, (), , "physicsRestoreState()")
{
if ( PHYSICSMGR )
PHYSICSMGR->reset();
}
ConsoleFunction( physicsDebugDraw, void, 2, 2, "physicsDebugDraw( bool enable )" )
DefineConsoleFunction( physicsDebugDraw, void, (bool enable), , "physicsDebugDraw( bool enable )")
{
if ( PHYSICSMGR )
PHYSICSMGR->enableDebugDraw( (S32)argv[1] );
PHYSICSMGR->enableDebugDraw( enable );
}

View file

@ -28,6 +28,7 @@
#include "console/simBase.h"
#include "console/console.h"
#include "console/consoleTypes.h"
#include "console/engineAPI.h"
#include "T3D/gameBase/moveManager.h"
#include "ts/tsShapeInstance.h"
#include "T3D/staticShape.h"
@ -317,15 +318,15 @@ void StaticShape::unpackUpdate(NetConnection *connection, BitStream *bstream)
// This appears to be legacy T2 stuff
// Marked internal, as this is flagged to be deleted
// [8/1/2010 mperry]
ConsoleMethod( StaticShape, setPoweredState, void, 3, 3, "(bool isPowered)"
DefineConsoleMethod( StaticShape, setPoweredState, void, (bool isPowered), , "(bool isPowered)"
"@internal")
{
if(!object->isServerObject())
return;
object->setPowered(dAtob(argv[2]));
object->setPowered(isPowered);
}
ConsoleMethod( StaticShape, getPoweredState, bool, 2, 2, "@internal")
DefineConsoleMethod( StaticShape, getPoweredState, bool, (), , "@internal")
{
if(!object->isServerObject())
return(false);