mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
Merge branch 'GarageGames/master' into ueberengine-dev
Conflicts: Engine/source/T3D/fps/guiCrossHairHud.cpp
This commit is contained in:
commit
81750f3deb
2827 changed files with 315755 additions and 121398 deletions
|
|
@ -202,6 +202,26 @@ DefineConsoleFunction( getRealTime, S32, (), , "()"
|
|||
return Platform::getRealMilliseconds();
|
||||
}
|
||||
|
||||
ConsoleFunction( getLocalTime, const char *, 1, 1, "Return the current local time as: weekday month day year hour min sec.\n\n"
|
||||
"Local time is platform defined.")
|
||||
{
|
||||
Platform::LocalTime lt;
|
||||
Platform::getLocalTime(lt);
|
||||
|
||||
static const U32 bufSize = 128;
|
||||
char *retBuffer = Con::getReturnBuffer(bufSize);
|
||||
dSprintf(retBuffer, bufSize, "%d %d %d %d %02d %02d %02d",
|
||||
lt.weekday,
|
||||
lt.month + 1,
|
||||
lt.monthday,
|
||||
lt.year + 1900,
|
||||
lt.hour,
|
||||
lt.min,
|
||||
lt.sec);
|
||||
|
||||
return retBuffer;
|
||||
}
|
||||
|
||||
ConsoleFunctionGroupEnd(Platform);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -65,6 +65,14 @@
|
|||
#include "platform/platformVFS.h"
|
||||
#endif
|
||||
|
||||
#ifndef _MODULE_MANAGER_H
|
||||
#include "module/moduleManager.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ASSET_MANAGER_H_
|
||||
#include "assets/assetManager.h"
|
||||
#endif
|
||||
|
||||
DITTS( F32, gTimeScale, 1.0 );
|
||||
DITTS( U32, gTimeAdvance, 0 );
|
||||
DITTS( U32, gFrameSkip, 0 );
|
||||
|
|
@ -257,7 +265,7 @@ void StandardMainLoop::init()
|
|||
|
||||
// Initialize modules.
|
||||
|
||||
ModuleManager::initializeSystem();
|
||||
EngineModuleManager::initializeSystem();
|
||||
|
||||
// Initialise ITickable.
|
||||
#ifdef TORQUE_TGB_ONLY
|
||||
|
|
@ -288,6 +296,15 @@ void StandardMainLoop::init()
|
|||
Con::addVariable("MiniDump::Params", TypeString, &gMiniDumpParams);
|
||||
Con::addVariable("MiniDump::ExecDir", TypeString, &gMiniDumpExecDir);
|
||||
#endif
|
||||
|
||||
// Register the module manager.
|
||||
ModuleDatabase.registerObject("ModuleDatabase");
|
||||
|
||||
// Register the asset database.
|
||||
AssetDatabase.registerObject("AssetDatabase");
|
||||
|
||||
// Register the asset database as a module listener.
|
||||
ModuleDatabase.addListener(&AssetDatabase);
|
||||
|
||||
ActionMap* globalMap = new ActionMap;
|
||||
globalMap->registerObject("GlobalActionMap");
|
||||
|
|
@ -317,10 +334,16 @@ void StandardMainLoop::shutdown()
|
|||
|
||||
delete tm;
|
||||
preShutdown();
|
||||
|
||||
// Unregister the module database.
|
||||
ModuleDatabase.unregisterObject();
|
||||
|
||||
// Unregister the asset database.
|
||||
AssetDatabase.unregisterObject();
|
||||
|
||||
// Shut down modules.
|
||||
|
||||
ModuleManager::shutdownSystem();
|
||||
EngineModuleManager::shutdownSystem();
|
||||
|
||||
ThreadPool::GlobalThreadPool::deleteSingleton();
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "console/consoleInternal.h"
|
||||
#include "core/strings/stringUnit.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "core/stream/fileStream.h"
|
||||
|
||||
TCPObject *TCPObject::table[TCPObject::TableSize] = {0, };
|
||||
|
||||
|
|
@ -138,6 +139,15 @@ IMPLEMENT_CALLBACK(TCPObject, onLine, void, (const char* line), (line),
|
|||
"@param line Data sent from the server.\n"
|
||||
);
|
||||
|
||||
IMPLEMENT_CALLBACK(TCPObject, onPacket, bool, (const char* data), (data),
|
||||
"@brief Called when we get a packet with no newlines or nulls (probably websocket).\n\n"
|
||||
"@param data Data sent from the server.\n"
|
||||
"@return true if script handled the packet.\n"
|
||||
);
|
||||
IMPLEMENT_CALLBACK(TCPObject, onEndReceive, void, (), (),
|
||||
"@brief Called when we are done reading all lines.\n\n"
|
||||
);
|
||||
|
||||
IMPLEMENT_CALLBACK(TCPObject, onDNSResolved, void, (),(),
|
||||
"Called whenever the DNS has been resolved.\n"
|
||||
);
|
||||
|
|
@ -355,7 +365,7 @@ void TCPObject::onConnectFailed()
|
|||
onConnectFailed_callback();
|
||||
}
|
||||
|
||||
void TCPObject::finishLastLine()
|
||||
bool TCPObject::finishLastLine()
|
||||
{
|
||||
if(mBufferSize)
|
||||
{
|
||||
|
|
@ -364,6 +374,25 @@ void TCPObject::finishLastLine()
|
|||
dFree(mBuffer);
|
||||
mBuffer = 0;
|
||||
mBufferSize = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TCPObject::isBufferEmpty()
|
||||
{
|
||||
return (mBufferSize <= 0);
|
||||
}
|
||||
|
||||
void TCPObject::emptyBuffer()
|
||||
{
|
||||
if(mBufferSize)
|
||||
{
|
||||
dFree(mBuffer);
|
||||
mBuffer = 0;
|
||||
mBufferSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -400,6 +429,25 @@ void TCPObject::send(const U8 *buffer, U32 len)
|
|||
Net::sendtoSocket(mTag, buffer, S32(len));
|
||||
}
|
||||
|
||||
bool TCPObject::sendFile(const char* fileName)
|
||||
{
|
||||
//Open the file for reading
|
||||
FileStream readFile;
|
||||
if(!readFile.open(fileName, Torque::FS::File::Read))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//Read each byte into our buffer
|
||||
Vector<U8> buffer(readFile.getStreamSize());
|
||||
readFile.read(buffer.size(), &buffer);
|
||||
|
||||
//Send the buffer
|
||||
send(buffer.address(), buffer.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DefineEngineMethod(TCPObject, send, void, (const char *data),,
|
||||
"@brief Transmits the data string to the connected computer.\n\n"
|
||||
|
||||
|
|
@ -421,6 +469,20 @@ DefineEngineMethod(TCPObject, send, void, (const char *data),,
|
|||
object->send( (const U8*)data, dStrlen(data) );
|
||||
}
|
||||
|
||||
DefineEngineMethod(TCPObject, sendFile, bool, (const char *fileName),,
|
||||
"@brief Transmits the file in binary to the connected computer.\n\n"
|
||||
|
||||
"@param fileName The filename of the file to transfer.\n")
|
||||
{
|
||||
return object->sendFile(fileName);
|
||||
}
|
||||
|
||||
DefineEngineMethod(TCPObject, finishLastLine, void, (),,
|
||||
"@brief Eat the rest of the lines.\n")
|
||||
{
|
||||
object->finishLastLine();
|
||||
}
|
||||
|
||||
DefineEngineMethod(TCPObject, listen, void, (U32 port),,
|
||||
"@brief Start listening on the specified port for connections.\n\n"
|
||||
|
||||
|
|
@ -499,6 +561,29 @@ void processConnectedReceiveEvent(NetSocket sock, RawData incomingData)
|
|||
size -= ret;
|
||||
buffer += ret;
|
||||
}
|
||||
|
||||
//If our buffer now has something in it then it's probably a web socket packet and lets handle it
|
||||
if(!tcpo->isBufferEmpty())
|
||||
{
|
||||
//Copy all the data into a string (may be a quicker way of doing this)
|
||||
U8 *data = (U8*)incomingData.data;
|
||||
String temp;
|
||||
for(S32 i = 0; i < incomingData.size; i++)
|
||||
{
|
||||
temp += data[i];
|
||||
}
|
||||
|
||||
//Send the packet to script
|
||||
bool handled = tcpo->onPacket_callback(temp);
|
||||
|
||||
//If the script did something with it, clear the buffer
|
||||
if(handled)
|
||||
{
|
||||
tcpo->emptyBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
tcpo->onEndReceive_callback();
|
||||
}
|
||||
|
||||
void processConnectedAcceptEvent(NetSocket listeningPort, NetSocket newConnection, NetAddress originatingAddress)
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ public:
|
|||
|
||||
DECLARE_CALLBACK(void, onConnectionRequest, (const char* address, const char* ID));
|
||||
DECLARE_CALLBACK(void, onLine, (const char* line));
|
||||
DECLARE_CALLBACK(bool, onPacket, (const char* data));
|
||||
DECLARE_CALLBACK(void, onEndReceive, ());
|
||||
DECLARE_CALLBACK(void, onDNSResolved,());
|
||||
DECLARE_CALLBACK(void, onDNSFailed, ());
|
||||
DECLARE_CALLBACK(void, onConnected, ());
|
||||
|
|
@ -60,7 +62,9 @@ public:
|
|||
virtual ~TCPObject();
|
||||
|
||||
void parseLine(U8 *buffer, U32 *start, U32 bufferLen);
|
||||
void finishLastLine();
|
||||
bool finishLastLine();
|
||||
bool isBufferEmpty();
|
||||
void emptyBuffer();
|
||||
|
||||
static TCPObject *find(NetSocket tag);
|
||||
|
||||
|
|
@ -81,6 +85,12 @@ public:
|
|||
|
||||
bool processArguments(S32 argc, ConsoleValueRef *argv);
|
||||
void send(const U8 *buffer, U32 bufferLen);
|
||||
|
||||
///Send an entire file over tcp
|
||||
///@arg fileName Full path to file you want to send
|
||||
///@return true if file was sent, false if not (file doesn't exist)
|
||||
bool sendFile(const char* fileName);
|
||||
|
||||
void addToTable(NetSocket newTag);
|
||||
void removeFromTable();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue