mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 08:15:44 +00:00
Fix stack balancing problems by refactoring execution calls
- Con::executef now uses a template - All public execution functions now restore the console stack upon return - Fixed bad parameters on some callbacks - Reverts get*Arg behavior
This commit is contained in:
parent
b1ad72692c
commit
f44a3f27d6
43 changed files with 1781 additions and 358 deletions
|
|
@ -459,6 +459,14 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr
|
|||
return false;
|
||||
}
|
||||
ConsoleValueRef connectArgv[MaxConnectArgs + 3];
|
||||
ConsoleValue connectArgvValue[MaxConnectArgs + 3];
|
||||
|
||||
for(U32 i = 0; i < mConnectArgc+3; i++)
|
||||
{
|
||||
connectArgv[i].value = &connectArgvValue[i];
|
||||
connectArgvValue[i].init();
|
||||
}
|
||||
|
||||
for(U32 i = 0; i < mConnectArgc; i++)
|
||||
{
|
||||
char argString[256];
|
||||
|
|
@ -466,11 +474,11 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr
|
|||
mConnectArgv[i] = dStrdup(argString);
|
||||
connectArgv[i + 3] = mConnectArgv[i];
|
||||
}
|
||||
connectArgv[0] = "onConnectRequest";
|
||||
connectArgv[1] = 0;
|
||||
connectArgvValue[0].setStackStringValue("onConnectRequest");
|
||||
connectArgvValue[1].setIntValue(0);
|
||||
char buffer[256];
|
||||
Net::addressToString(getNetAddress(), buffer);
|
||||
connectArgv[2] = buffer;
|
||||
connectArgvValue[2].setStackStringValue(buffer);
|
||||
|
||||
// NOTE: Cannot convert over to IMPLEMENT_CALLBACK as it has variable args.
|
||||
const char *ret = Con::execute(this, mConnectArgc + 3, connectArgv);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include "app/game.h"
|
||||
#include "T3D/gameBase/gameConnection.h"
|
||||
#include "T3D/gameBase/gameConnectionEvents.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
#define DebugChecksum 0xF00DBAAD
|
||||
|
||||
|
|
@ -234,7 +235,7 @@ void SimDataBlockEvent::process(NetConnection *cptr)
|
|||
if(mProcess)
|
||||
{
|
||||
//call the console function to set the number of blocks to be sent
|
||||
Con::executef("onDataBlockObjectReceived", Con::getIntArg(mIndex), Con::getIntArg(mTotal));
|
||||
Con::executef("onDataBlockObjectReceived", mIndex, mTotal);
|
||||
|
||||
String &errorBuffer = NetConnection::getErrorBuffer();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue