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

@ -33,6 +33,7 @@
#include "console/simBase.h"
#include "console/console.h"
#include "console/consoleTypes.h"
#include "console/engineAPI.h"
#include "gui/controls/guiMLTextCtrl.h"
#ifdef TORQUE_TGB_ONLY
#include "T2D/oldModel/networking/t2dGameConnection.h"
@ -57,22 +58,22 @@ bool gEditingMission = false;
ConsoleFunctionGroupBegin( InputManagement, "Functions that let you deal with input from scripts" );
ConsoleFunction( deactivateDirectInput, void, 1, 1, "()"
DefineConsoleFunction( deactivateDirectInput, void, (), ,
"()"
"@brief Disables DirectInput.\n\n"
"Also deactivates any connected joysticks.\n\n"
"@ingroup Input" )
{
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
if ( Input::isActive() )
Input::deactivate();
}
ConsoleFunction( activateDirectInput, void, 1, 1,"()"
DefineConsoleFunction( activateDirectInput, void, (), ,
"()"
"@brief Activates DirectInput.\n\n"
"Also activates any connected joysticks."
"@ingroup Input")
{
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
if ( !Input::isActive() )
Input::activate();
}
@ -81,11 +82,8 @@ ConsoleFunctionGroupEnd( InputManagement );
//--------------------------------------------------------------------------
static const U32 MaxPlayerNameLength = 16;
ConsoleFunction( strToPlayerName, const char*, 2, 2, "strToPlayerName( string )" )
DefineConsoleFunction( strToPlayerName, const char*, (const char* ptr ), , "strToPlayerName(string);" )
{
TORQUE_UNUSED(argc);
const char* ptr = argv[1];
// Strip leading spaces and underscores:
while ( *ptr == ' ' || *ptr == '_' )
@ -140,16 +138,16 @@ ConsoleFunction( strToPlayerName, const char*, 2, 2, "strToPlayerName( string )"
ConsoleFunctionGroupBegin( Platform , "General platform functions.");
ConsoleFunction( lockMouse, void, 2, 2, "(bool isLocked)"
DefineConsoleFunction( lockMouse, void, (bool isLocked ), , "(bool isLocked)"
"@brief Lock or unlock the mouse to the window.\n\n"
"When true, prevents the mouse from leaving the bounds of the game window.\n\n"
"@ingroup Input")
{
Platform::setWindowLocked(dAtob(argv[1]));
Platform::setWindowLocked(isLocked);
}
ConsoleFunction( setNetPort, bool, 2, 3, "(int port, bool bind=true)"
DefineConsoleFunction( setNetPort, bool, (int port, bool bind), (true), "(int port, bool bind=true)"
"@brief Set the network port for the game to use.\n\n"
"@param port The port to use.\n"
@ -161,37 +159,34 @@ ConsoleFunction( setNetPort, bool, 2, 3, "(int port, bool bind=true)"
"If you don't have firewall tunneling tech you can set this to false to avoid the prompt.\n\n"
"@ingroup Networking")
{
bool bind = true;
if (argc == 3)
bind = dAtob(argv[2]);
return Net::openPort(dAtoi(argv[1]), bind);
return Net::openPort((S32)port, bind);
}
ConsoleFunction( closeNetPort, void, 1, 1, "()"
DefineConsoleFunction( closeNetPort, void, (), , "()"
"@brief Closes the current network port\n\n"
"@ingroup Networking")
{
Net::closePort();
}
ConsoleFunction( saveJournal, void, 2, 2, "(string filename)"
DefineConsoleFunction( saveJournal, void, (const char * filename), , "(string filename)"
"Save the journal to the specified file.\n\n"
"@ingroup Platform")
{
Journal::Record(argv[1]);
Journal::Record(filename);
}
ConsoleFunction( playJournal, void, 2, 3, "(string filename)"
DefineConsoleFunction( playJournal, void, (const char * filename), , "(string filename)"
"@brief Begin playback of a journal from a specified field.\n\n"
"@param filename Name and path of file journal file\n"
"@ingroup Platform")
{
// CodeReview - BJG 4/24/2007 - The break flag needs to be wired back in.
// bool jBreak = (argc > 2)? dAtob(argv[2]): false;
Journal::Play(argv[1]);
Journal::Play(filename);
}
ConsoleFunction( getSimTime, S32, 1, 1, "()"
DefineConsoleFunction( getSimTime, S32, (), , "()"
"Return the current sim time in milliseconds.\n\n"
"@brief Sim time is time since the game started.\n\n"
"@ingroup Platform")
@ -199,7 +194,7 @@ ConsoleFunction( getSimTime, S32, 1, 1, "()"
return Sim::getCurrentTime();
}
ConsoleFunction( getRealTime, S32, 1, 1, "()"
DefineConsoleFunction( getRealTime, S32, (), , "()"
"@brief Return the current real time in milliseconds.\n\n"
"Real time is platform defined; typically time since the computer booted.\n\n"
"@ingroup Platform")

View file

@ -410,25 +410,20 @@ void queryLanServers(U32 port, U8 flags, const char* gameType, const char* missi
//-----------------------------------------------------------------------------
ConsoleFunction( queryAllServers, void, 12, 12, "queryAllServers(...);" )
DefineConsoleFunction( queryAllServers
, void, ( U32 lanPort
, U32 flags
, const char * gameType
, const char * missionType
, U32 minPlayers
, U32 maxPlayers
, U32 maxBots
, U32 regionMask
, U32 maxPing
, U32 minCPU
, U32 filterFlags )
, , "queryAllServers(...);" )
{
TORQUE_UNUSED(argc);
U32 lanPort = dAtoi(argv[1]);
U8 flags = dAtoi(argv[2]);
// It's not a good idea to hold onto args, recursive calls to
// console exec will trash them.
char* gameType = dStrdup(argv[3]);
char* missionType = dStrdup(argv[4]);
U8 minPlayers = dAtoi(argv[5]);
U8 maxPlayers = dAtoi(argv[6]);
U8 maxBots = dAtoi(argv[7]);
U32 regionMask = dAtoi(argv[8]);
U32 maxPing = dAtoi(argv[9]);
U16 minCPU = dAtoi(argv[10]);
U8 filterFlags = dAtoi(argv[11]);
U32 buddyList = 0;
clearServerList();
@ -442,32 +437,27 @@ ConsoleFunction( queryAllServers, void, 12, 12, "queryAllServers(...);" )
dFree(missionType);
}
ConsoleFunction( queryLanServers, void, 12, 12, "queryLanServers(...);" )
DefineConsoleFunction( queryLanServers
, void, ( U32 lanPort
, U32 flags
, const char * gameType
, const char * missionType
, U32 minPlayers
, U32 maxPlayers
, U32 maxBots
, U32 regionMask
, U32 maxPing
, U32 minCPU
, U32 filterFlags )
, , "queryLanServers(...);" )
{
TORQUE_UNUSED(argc);
U32 lanPort = dAtoi(argv[1]);
U8 flags = dAtoi(argv[2]);
// It's not a good idea to hold onto args, recursive calls to
// console exec will trash them.
char* gameType = dStrdup(argv[3]);
char* missionType = dStrdup(argv[4]);
U8 minPlayers = dAtoi(argv[5]);
U8 maxPlayers = dAtoi(argv[6]);
U8 maxBots = dAtoi(argv[7]);
U32 regionMask = dAtoi(argv[8]);
U32 maxPing = dAtoi(argv[9]);
U16 minCPU = dAtoi(argv[10]);
U8 filterFlags = dAtoi(argv[11]);
clearServerList();
queryLanServers(lanPort, flags, gameType, missionType, minPlayers, maxPlayers, maxBots,
regionMask, maxPing, minCPU, filterFlags);
dFree(gameType);
dFree(missionType);
}
//-----------------------------------------------------------------------------
@ -550,24 +540,20 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
processMasterServerQuery( gPingSession );
}
ConsoleFunction( queryMasterServer, void, 11, 11, "queryMasterServer(...);" )
DefineConsoleFunction( queryMasterServer
, void, ( U32 lanPort
, U32 flags
, const char * gameType
, const char * missionType
, U32 minPlayers
, U32 maxPlayers
, U32 maxBots
, U32 regionMask
, U32 maxPing
, U32 minCPU
, U32 filterFlags )
, , "queryMasterServer(...);" )
{
TORQUE_UNUSED(argc);
U8 flags = dAtoi(argv[1]);
// It's not a good idea to hold onto args, recursive calls to
// console exec will trash them.
char* gameType = dStrdup(argv[2]);
char* missionType = dStrdup(argv[3]);
U8 minPlayers = dAtoi(argv[4]);
U8 maxPlayers = dAtoi(argv[5]);
U8 maxBots = dAtoi(argv[6]);
U32 regionMask = dAtoi(argv[7]);
U32 maxPing = dAtoi(argv[8]);
U16 minCPU = dAtoi(argv[9]);
U8 filterFlags = dAtoi(argv[10]);
U32 buddyList = 0;
clearServerList();
@ -580,15 +566,12 @@ ConsoleFunction( queryMasterServer, void, 11, 11, "queryMasterServer(...);" )
//-----------------------------------------------------------------------------
ConsoleFunction( querySingleServer, void, 3, 3, "querySingleServer(address, flags);" )
DefineConsoleFunction( querySingleServer
, void, ( const char* addrText, U8 flags )
,(0) , "querySingleServer(...);" )
{
TORQUE_UNUSED(argc);
NetAddress addr;
char* addrText;
addrText = dStrdup(argv[1]);
U8 flags = dAtoi(argv[2]);
Net::stringToAddress( addrText, &addr );
@ -672,9 +655,8 @@ void cancelServerQuery()
}
}
ConsoleFunction( cancelServerQuery, void, 1, 1, "cancelServerQuery()" )
DefineConsoleFunction( cancelServerQuery, void, (), , "cancelServerQuery(...);" )
{
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
cancelServerQuery();
}
@ -701,43 +683,36 @@ void stopServerQuery()
}
}
ConsoleFunction( stopServerQuery, void, 1, 1, "stopServerQuery()" )
DefineConsoleFunction( stopServerQuery, void, (), , "stopServerQuery(...);" )
{
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
stopServerQuery();
}
//-----------------------------------------------------------------------------
ConsoleFunction(startHeartbeat, void, 1, 1, "startHeartbeat()")
DefineConsoleFunction( startHeartbeat, void, (), , "startHeartbeat(...);" )
{
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
if (validateAuthenticatedServer()) {
gHeartbeatSeq++;
processHeartbeat(gHeartbeatSeq); // thump-thump...
}
}
ConsoleFunction(stopHeartbeat, void, 1, 1, "stopHeartbeat();")
DefineConsoleFunction( stopHeartbeat, void, (), , "stopHeartbeat(...);" )
{
TORQUE_UNUSED(argc); TORQUE_UNUSED(argv);
gHeartbeatSeq++;
}
//-----------------------------------------------------------------------------
ConsoleFunction( getServerCount, int, 1, 1, "getServerCount();" )
DefineConsoleFunction( getServerCount, int, (), , "getServerCount(...);" )
{
TORQUE_UNUSED(argv); TORQUE_UNUSED(argc);
return gServerList.size();
}
ConsoleFunction( setServerInfo, bool, 2, 2, "setServerInfo(index);" )
DefineConsoleFunction( setServerInfo, bool, (U32 index), , "setServerInfo(...);" )
{
TORQUE_UNUSED(argc);
U32 index = dAtoi(argv[1]);
if (index >= 0 && index < gServerList.size()) {
if (index < gServerList.size()) {
ServerInfo& info = gServerList[index];
char addrString[256];

View file

@ -23,6 +23,7 @@
#include "platform/platform.h"
#include "app/version.h"
#include "console/console.h"
#include "console/engineAPI.h"
static const U32 csgVersionNumber = TORQUE_GAME_ENGINE;
static const U32 appVersionNumber = TORQUE_APP_VERSION;
@ -91,44 +92,44 @@ const char* getCompileTimeString()
ConsoleFunctionGroupBegin( CompileInformation, "Functions to get version information about the current executable." );
ConsoleFunction( getVersionNumber, S32, 1, 1, "Get the version of the engine build, as a string.\n\n"
DefineConsoleFunction( getVersionNumber, S32, (), , "Get the version of the engine build, as a string.\n\n"
"@ingroup Debugging")
{
return getVersionNumber();
}
ConsoleFunction( getAppVersionNumber, S32, 1, 1, "Get the version of the application build, as a string.\n\n"
DefineConsoleFunction( getAppVersionNumber, S32, (), , "Get the version of the application build, as a string.\n\n"
"@ingroup Debugging")
{
return getAppVersionNumber();
}
ConsoleFunction( getVersionString, const char*, 1, 1, "Get the version of the engine build, as a human readable string.\n\n"
DefineConsoleFunction( getVersionString, const char*, (), , "Get the version of the engine build, as a human readable string.\n\n"
"@ingroup Debugging")
{
return getVersionString();
}
ConsoleFunction( getAppVersionString, const char*, 1, 1, "Get the version of the aplication, as a human readable string.\n\n"
DefineConsoleFunction( getAppVersionString, const char*, (), , "Get the version of the aplication build, as a human readable string.\n\n"
"@ingroup Debugging")
{
return getAppVersionString();
}
ConsoleFunction( getEngineName, const char*, 1, 1, "Get the name of the engine product that this is running from, as a string.\n\n"
DefineConsoleFunction( getEngineName, const char*, (), , "Get the name of the engine product that this is running from, as a string.\n\n"
"@ingroup Debugging")
{
return getEngineProductString();
}
ConsoleFunction( getCompileTimeString, const char*, 1, 1, "Get the time of compilation.\n\n"
DefineConsoleFunction( getCompileTimeString, const char*, (), , "Get the time of compilation.\n\n"
"@ingroup Debugging")
{
return getCompileTimeString();
}
ConsoleFunction( getBuildString, const char*, 1, 1, "Get the type of build, \"Debug\" or \"Release\".\n\n"
DefineConsoleFunction( getBuildString, const char*, (), , "Get the type of build, \"Debug\" or \"Release\".\n\n"
"@ingroup Debugging")
{
#ifdef TORQUE_DEBUG
@ -140,7 +141,7 @@ ConsoleFunction( getBuildString, const char*, 1, 1, "Get the type of build, \"De
ConsoleFunctionGroupEnd( CompileInformation );
ConsoleFunction(isDemo, bool, 1, 1, "")
DefineConsoleFunction( isDemo, bool, (), , "")
{
#ifdef TORQUE_DEMO
return true;
@ -149,7 +150,7 @@ ConsoleFunction(isDemo, bool, 1, 1, "")
#endif
}
ConsoleFunction(isWebDemo, bool, 1, 1, "")
DefineConsoleFunction( isWebDemo, bool, (), , "")
{
#ifdef TORQUE_DEMO
return Platform::getWebDeployment();