Merge branch 'master' into console-func-refactor

Conflicts:
	Engine/source/app/net/net.cpp
	Engine/source/console/astNodes.cpp
	Engine/source/console/compiledEval.cpp
	Engine/source/console/console.h
	Engine/source/console/consoleInternal.h
	Engine/source/console/engineAPI.h
This commit is contained in:
Daniel Buckmaster 2014-10-14 14:40:17 +11:00
commit b507dc9555
6487 changed files with 315149 additions and 609761 deletions

View file

@ -23,10 +23,6 @@
#ifndef _AUTH_H_
#define _AUTH_H_
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
/// Formerly contained a certificate, showing that something was valid.
class Auth2Certificate
{

View file

@ -241,6 +241,16 @@ void StandardMainLoop::init()
DebugOutputConsumer::init();
#endif
// init Filesystem first, so we can actually log errors for all components that follow
Platform::FS::InstallFileSystems(); // install all drives for now until we have everything using the volume stuff
Platform::FS::MountDefaults();
// Set our working directory.
Torque::FS::SetCwd( "game:/" );
// Set our working directory.
Platform::setCurrentDirectory( Platform::getMainDotCsDir() );
Processor::init();
Math::init();
Platform::init(); // platform specific initialization
@ -291,6 +301,9 @@ void StandardMainLoop::init()
tm = new TimeManager;
tm->timeEvent.notify(&::processTimeEvent);
// Start up the Input Event Manager
INPUTMGR->start();
Sampler::init();
// Hook in for UDP notification
@ -307,6 +320,9 @@ void StandardMainLoop::init()
void StandardMainLoop::shutdown()
{
// Stop the Input Event Manager
INPUTMGR->stop();
delete tm;
preShutdown();
@ -380,15 +396,6 @@ bool StandardMainLoop::handleCommandLine( S32 argc, const char **argv )
for (i = 0; i < argc; i++)
Con::setVariable(avar("Game::argv%d", i), argv[i]);
Platform::FS::InstallFileSystems(); // install all drives for now until we have everything using the volume stuff
Platform::FS::MountDefaults();
// Set our working directory.
Torque::FS::SetCwd( "game:/" );
// Set our working directory.
Platform::setCurrentDirectory( Platform::getMainDotCsDir() );
#ifdef TORQUE_PLAYER
if(argc > 2 && dStricmp(argv[1], "-project") == 0)
{

View file

@ -23,7 +23,6 @@
#include "app/net/httpObject.h"
#include "platform/platform.h"
#include "platform/event.h"
#include "core/stream/fileStream.h"
#include "console/simBase.h"
#include "console/consoleInternal.h"
@ -299,7 +298,7 @@ void HTTPObject::onDisconnect()
Parent::onDisconnect();
}
bool HTTPObject::processLine(U8 *line)
bool HTTPObject::processLine(UTF8 *line)
{
if(mParseState == ParsingStatusLine)
{

View file

@ -72,7 +72,7 @@ public:
virtual void onConnected();
virtual void onConnectFailed();
virtual void onDisconnect();
bool processLine(U8 *line);
bool processLine(UTF8 *line);
DECLARE_CONOBJECT(HTTPObject);
};

View file

@ -31,27 +31,14 @@
#include "sim/netObject.h"
#include "app/net/serverQuery.h"
#include "console/engineAPI.h"
#include <vector>
#include "net.h"
//----------------------------------------------------------------
// remote procedure call console functions
//----------------------------------------------------------------
class RemoteCommandEvent : public NetEvent
{
public:
typedef NetEvent Parent;
enum {
MaxRemoteCommandArgs = 20,
CommandArgsBits = 5
};
private:
S32 mArgc;
char *mArgv[MaxRemoteCommandArgs + 1];
NetStringHandle mTagv[MaxRemoteCommandArgs + 1];
static char mBuf[1024];
public:
RemoteCommandEvent(S32 argc=0, const char **argv=NULL, NetConnection *conn = NULL)
RemoteCommandEvent::RemoteCommandEvent(S32 argc, const char **argv, NetConnection *conn)
{
mArgc = argc;
for(S32 i = 0; i < argc; i++)
@ -73,7 +60,7 @@ public:
}
#ifdef TORQUE_DEBUG_NET
const char *getDebugName()
const char *RemoteCommandEvent::getDebugName()
{
static char buffer[256];
dSprintf(buffer, sizeof(buffer), "%s [%s]", getClassName(), mTagv[1].isValidString() ? mTagv[1].getString() : "--unknown--" );
@ -81,13 +68,13 @@ public:
}
#endif
~RemoteCommandEvent()
RemoteCommandEvent::~RemoteCommandEvent()
{
for(S32 i = 0; i < mArgc; i++)
dFree(mArgv[i+1]);
}
virtual void pack(NetConnection* conn, BitStream *bstream)
void RemoteCommandEvent::pack(NetConnection* conn, BitStream *bstream)
{
bstream->writeInt(mArgc, CommandArgsBits);
// write it out reversed... why?
@ -98,12 +85,12 @@ public:
conn->packString(bstream, mArgv[i+1]);
}
virtual void write(NetConnection* conn, BitStream *bstream)
void RemoteCommandEvent::write(NetConnection* conn, BitStream *bstream)
{
pack(conn, bstream);
}
virtual void unpack(NetConnection* conn, BitStream *bstream)
void RemoteCommandEvent::unpack(NetConnection* conn, BitStream *bstream)
{
mArgc = bstream->readInt(CommandArgsBits);
@ -115,7 +102,7 @@ public:
}
}
virtual void process(NetConnection *conn)
void RemoteCommandEvent::process(NetConnection *conn)
{
static char idBuf[10];
@ -165,8 +152,52 @@ public:
}
}
DECLARE_CONOBJECT(RemoteCommandEvent);
};
void RemoteCommandEvent::sendRemoteCommand(NetConnection *conn, S32 argc, const char **argv)
{
if(U8(argv[0][0]) != StringTagPrefixByte)
{
Con::errorf(ConsoleLogEntry::Script, "Remote Command Error - command must be a tag.");
return;
}
S32 i;
for(i = argc - 1; i >= 0; i--)
{
if(argv[i][0] != 0)
break;
argc = i;
}
for(i = 0; i < argc; i++)
conn->validateSendString(argv[i]);
RemoteCommandEvent *cevt = new RemoteCommandEvent(argc, argv, conn);
conn->postNetEvent(cevt);
}
const char* RemoteCommandEvent::getTaggedString(const char* tag)
{
const char *indexPtr = tag;
if (*indexPtr == StringTagPrefixByte)
indexPtr++;
return gNetStringTable->lookupString(dAtoi(indexPtr));
}
void RemoteCommandEvent::removeTaggedString(S32 tag)
{
if (tag)
gNetStringTable->removeString(tag, true);
}
const char* RemoteCommandEvent::addTaggedString(const char* str)
{
NetStringHandle s(str);
gNetStringTable->incStringRefScript(s.getIndex());
char *ret = Con::getReturnBuffer(10);
ret[0] = StringTagPrefixByte;
dSprintf(ret + 1, 9, "%d", s.getIndex());
return ret;
}
char RemoteCommandEvent::mBuf[1024];
IMPLEMENT_CO_NETEVENT_V1(RemoteCommandEvent);
@ -176,30 +207,13 @@ ConsoleDocClass( RemoteCommandEvent,
"Not intended for game development, for exposing ConsoleFunctions (such as commandToClient) only.\n\n"
"@internal");
static void sendRemoteCommand(NetConnection *conn, S32 argc, const char **argv)
{
if(U8(argv[0][0]) != StringTagPrefixByte)
{
Con::errorf(ConsoleLogEntry::Script, "Remote Command Error - command must be a tag.");
return;
}
S32 i;
for(i = argc - 1; i >= 0; i--)
{
if(argv[i][0] != 0)
break;
argc = i;
}
for(i = 0; i < argc; i++)
conn->validateSendString(argv[i]);
RemoteCommandEvent *cevt = new RemoteCommandEvent(argc, argv, conn);
conn->postNetEvent(cevt);
}
ConsoleFunctionGroupBegin( Net, "Functions for use with the network; tagged strings and remote commands.");
ConsoleFunction( commandToServer, void, 2, RemoteCommandEvent::MaxRemoteCommandArgs + 1, "(string func, ...)"
"@brief Send a command to the server.\n\n"
"@brief Send a command to the server.\n\n"
"@param func Name of the server command being called\n"
"@param ... Various parameters being passed to server command\n\n"
@ -237,9 +251,8 @@ ConsoleFunction( commandToServer, void, 2, RemoteCommandEvent::MaxRemoteCommandA
NetConnection *conn = NetConnection::getConnectionToServer();
if(!conn)
return;
StringStackWrapper args(argc - 1, argv + 1);
sendRemoteCommand(conn, args.count(), args);
RemoteCommandEvent::sendRemoteCommand(conn, args.count(), args);
}
ConsoleFunction( commandToClient, void, 3, RemoteCommandEvent::MaxRemoteCommandArgs + 2, "(NetConnection client, string func, ...)"
@ -277,11 +290,14 @@ ConsoleFunction( commandToClient, void, 3, RemoteCommandEvent::MaxRemoteCommandA
if(!Sim::findObject(argv[1], conn))
return;
StringStackWrapper args(argc - 2, argv + 2);
sendRemoteCommand(conn, args.count(), args);
RemoteCommandEvent::sendRemoteCommand(conn, args.count(), args);
}
ConsoleFunction(removeTaggedString, void, 2, 2, "(int tag)"
DefineEngineFunction(removeTaggedString, void, (S32 tag), (-1),
"@brief Remove a tagged string from the Net String Table\n\n"
"@param tag The tag associated with the string\n\n"
@ -290,11 +306,12 @@ ConsoleFunction(removeTaggedString, void, 2, 2, "(int tag)"
"@see addTaggedString()\n"
"@see getTaggedString()\n"
"@ingroup Networking\n")
{
gNetStringTable->removeString(dAtoi(((const char*)argv[1])+1), true);
}
{
RemoteCommandEvent::removeTaggedString(tag);
}
ConsoleFunction( addTaggedString, const char*, 2, 2, "(string str)"
DefineEngineFunction(addTaggedString, const char* , (const char* str), (""),
"@brief Use the addTaggedString function to tag a new string and add it to the NetStringTable\n\n"
"@param str The string to be tagged and placed in the NetStringTable. Tagging ignores case, "
@ -306,17 +323,12 @@ ConsoleFunction( addTaggedString, const char*, 2, 2, "(string str)"
"@see removeTaggedString()\n"
"@see getTaggedString()\n"
"@ingroup Networking\n")
{
NetStringHandle s((const char*)argv[1]);
gNetStringTable->incStringRefScript(s.getIndex());
{
return RemoteCommandEvent::addTaggedString(str);
}
char *ret = Con::getReturnBuffer(10);
ret[0] = StringTagPrefixByte;
dSprintf(ret + 1, 9, "%d", s.getIndex());
return ret;
}
ConsoleFunction( getTaggedString, const char*, 2, 2, "(int tag)"
DefineEngineFunction(getTaggedString, const char* , (const char *tag), (""),
"@brief Use the getTaggedString function to convert a tag to a string.\n\n"
"This is not the same as detag() which can only be used within the context "
@ -331,12 +343,11 @@ ConsoleFunction( getTaggedString, const char*, 2, 2, "(int tag)"
"@see addTaggedString()\n"
"@see removeTaggedString()\n"
"@ingroup Networking\n")
{
const char *indexPtr = argv[1];
if (*indexPtr == StringTagPrefixByte)
indexPtr++;
return gNetStringTable->lookupString(dAtoi(indexPtr));
}
{
return RemoteCommandEvent::getTaggedString(tag);
}
ConsoleFunction( buildTaggedString, const char*, 2, 11, "(string format, ...)"
"@brief Build a string using the specified tagged string format.\n\n"
@ -373,10 +384,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;

View file

@ -0,0 +1,59 @@
#ifndef _NET_H_
#define _NET_H_
#include "platform/platform.h"
#include "core/dnet.h"
#include "core/idGenerator.h"
#include "core/stream/bitStream.h"
#include "console/simBase.h"
#include "console/console.h"
#include "console/consoleTypes.h"
#include "sim/netConnection.h"
#include "sim/netObject.h"
#include "app/net/serverQuery.h"
#include "console/engineAPI.h"
class RemoteCommandEvent : public NetEvent
{
public:
typedef NetEvent Parent;
enum {
MaxRemoteCommandArgs = 20,
CommandArgsBits = 5
};
private:
S32 mArgc;
char *mArgv[MaxRemoteCommandArgs + 1];
NetStringHandle mTagv[MaxRemoteCommandArgs + 1];
static char mBuf[1024];
public:
RemoteCommandEvent(S32 argc=0, const char **argv=NULL, NetConnection *conn = NULL);
#ifdef TORQUE_DEBUG_NET
const char *getDebugName();
#endif
~RemoteCommandEvent();
virtual void pack(NetConnection* conn, BitStream *bstream);
virtual void write(NetConnection* conn, BitStream *bstream);
virtual void unpack(NetConnection* conn, BitStream *bstream);
virtual void process(NetConnection *conn);
static void sendRemoteCommand(NetConnection *conn, S32 argc, const char **argv);
static void removeTaggedString(S32);
static const char* addTaggedString(const char* str);
static const char* getTaggedString(const char* tag);
DECLARE_CONOBJECT(RemoteCommandEvent);
};
#endif

View file

@ -22,7 +22,6 @@
#include "platform/platform.h"
#include "console/simBase.h"
#include "platform/event.h"
#include "sim/netConnection.h"
#include "core/stream/bitStream.h"
#include "sim/netObject.h"

View file

@ -96,7 +96,6 @@
#include "app/net/serverQuery.h"
#include "platform/platform.h"
#include "platform/event.h"
#include "core/dnet.h"
#include "core/util/tVector.h"
#include "core/stream/bitStream.h"

View file

@ -26,9 +26,6 @@
#ifndef _PLATFORM_H_
#include "platform/platform.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#ifndef _BITSET_H_
#include "core/bitSet.h"
#endif

View file

@ -23,7 +23,6 @@
#include "app/net/tcpObject.h"
#include "platform/platform.h"
#include "platform/event.h"
#include "console/simBase.h"
#include "console/consoleInternal.h"
#include "core/strings/stringUnit.h"
@ -422,7 +421,7 @@ DefineEngineMethod(TCPObject, send, void, (const char *data),,
object->send( (const U8*)data, dStrlen(data) );
}
DefineEngineMethod(TCPObject, listen, void, (int port),,
DefineEngineMethod(TCPObject, listen, void, (U32 port),,
"@brief Start listening on the specified port for connections.\n\n"
"This method starts a listener which looks for incoming TCP connections to a port. "

View file

@ -25,23 +25,35 @@
#include "console/console.h"
static const U32 csgVersionNumber = TORQUE_GAME_ENGINE;
static const U32 appVersionNumber = TORQUE_APP_VERSION;
U32 getVersionNumber()
{
return csgVersionNumber;
}
U32 getAppVersionNumber()
{
return appVersionNumber;
}
const char* getVersionString()
{
return TORQUE_GAME_ENGINE_VERSION_STRING;
}
const char* getAppVersionString()
{
return TORQUE_APP_VERSION_STRING;
}
/// TGE 0001
/// TGEA 0002
/// TGB 0003
/// TGEA 360 0004
/// TGE WII 0005
/// Torque 3D 0006
/// Torque 3D MIT 0007
const char* getEngineProductString()
{
@ -62,7 +74,9 @@ const char* getEngineProductString()
return "Torque for Wii";
case 0006:
return "Torque 3D";
case 0007:
return "Torque 3D MIT";
default:
return "Torque Engine";
};
@ -77,18 +91,31 @@ const char* getCompileTimeString()
ConsoleFunctionGroupBegin( CompileInformation, "Functions to get version information about the current executable." );
ConsoleFunction( getVersionNumber, S32, 1, 1, "Get the version of the build, as a string.\n\n"
ConsoleFunction( getVersionNumber, S32, 1, 1, "Get the version of the engine build, as a string.\n\n"
"@ingroup Debugging")
{
return getVersionNumber();
}
ConsoleFunction( getVersionString, const char*, 1, 1, "Get the version of the build, as a string.\n\n"
ConsoleFunction( getAppVersionNumber, S32, 1, 1, "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"
"@ingroup Debugging")
{
return getVersionString();
}
ConsoleFunction( getAppVersionString, const char*, 1, 1, "Get the version of the aplication, 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"
"@ingroup Debugging")
{

View file

@ -23,23 +23,41 @@
#ifndef _VERSION_H_
#define _VERSION_H_
/// Since we can build different engine "products" out of the same
/// base engine source we need a way to differentiate which product
/// this particular game is using.
///
/// TGE 0001
/// TGEA 0002
/// TGB 0003
/// TGEA 360 0004
/// TGE WII 0005
/// Torque 3D 0006
/// Torque 3D MIT 0007
#define TORQUE_ENGINE_PRODUCT 0007
/// This is our global version number for the engine source code that
/// we are using. See <game>/source/torqueConfig.h for the game's source
/// code version, the game name, and which type of game it is (TGB, TGE, TGEA, etc.).
///
/// Version number is major * 1000 + minor * 100 + revision * 10.
#define TORQUE_GAME_ENGINE 1100
#define TORQUE_GAME_ENGINE 3610
/// Human readable engine version string.
#define TORQUE_GAME_ENGINE_VERSION_STRING "2011"
#define TORQUE_GAME_ENGINE_VERSION_STRING "3.6.1"
/// Gets the specified version number. The version number is specified as a global in version.cc
/// Gets the engine version number. The version number is specified as a global in version.cc
U32 getVersionNumber();
/// Gets the version number in string form
/// Gets the engine version number in a human readable form
const char* getVersionString();
/// Gets the engine product name in string form
const char* getEngineProductString();
/// Gets the compile date and time
const char* getCompileTimeString();
/// Gets the application version number. The version number is specified as a global in torqueConfig.h
U32 getAppVersionNumber();
/// Gets the human readable application version string.
const char* getAppVersionString();
#endif