mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-15 10:54:18 +00:00
Compare commits
21 Commits
OPENURU_BU
...
working
Author | SHA1 | Date | |
---|---|---|---|
4cc56d561b | |||
96facaa7bb | |||
883495c35c | |||
e1306da736 | |||
8d1d813df5 | |||
65d50895bb | |||
6a41bdbee7 | |||
3dcf1c2f26 | |||
70449244f4 | |||
82abcb2f07 | |||
870d0534df | |||
1f09d6c48a | |||
66ce08ed67 | |||
1c1d3dd82e | |||
4924156ad4 | |||
13ea0a98de | |||
f9723462d7 | |||
7d3774a732 | |||
ea7e4b2ab5 | |||
5d5ba00f7d | |||
af38137822 |
@ -7061,17 +7061,12 @@ PF_CONSOLE_CMD( Python,
|
|||||||
"string functions, ...", // Params
|
"string functions, ...", // Params
|
||||||
"Run a cheat command" )
|
"Run a cheat command" )
|
||||||
{
|
{
|
||||||
std::string extraParms;
|
const char* extraParms = "";
|
||||||
if (numParams > 1)
|
if (numParams > 1)
|
||||||
{
|
{
|
||||||
extraParms = "(";
|
extraParms = params[1];
|
||||||
extraParms.append(params[1]);
|
|
||||||
extraParms.append(",)");
|
|
||||||
}
|
}
|
||||||
else
|
PythonInterface::RunFunctionStringArg("xCheat", params[0], extraParms);
|
||||||
extraParms = "()";
|
|
||||||
|
|
||||||
PythonInterface::RunFunctionSafe("xCheat", params[0], extraParms.c_str());
|
|
||||||
|
|
||||||
std::string output;
|
std::string output;
|
||||||
// get the messages
|
// get the messages
|
||||||
|
@ -2102,38 +2102,32 @@ PyObject* PythonInterface::RunFunction(PyObject* module, const char* name, PyObj
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* PythonInterface::ParseArgs(const char* args)
|
bool PythonInterface::RunFunctionStringArg(const char* module, const char* name, const char* arg)
|
||||||
{
|
|
||||||
PyObject* result = NULL;
|
|
||||||
PyObject* scope = PyDict_New();
|
|
||||||
if (scope)
|
|
||||||
{
|
|
||||||
//- Py_eval_input makes this function accept only single expresion (not statement)
|
|
||||||
//- When using empty scope, functions and classes like 'file' or '__import__' are not visible
|
|
||||||
result = PyRun_String(args, Py_eval_input, scope, NULL);
|
|
||||||
Py_DECREF(scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PythonInterface::RunFunctionSafe(const char* module, const char* function, const char* args)
|
|
||||||
{
|
{
|
||||||
PyObject* moduleObj = ImportModule(module);
|
PyObject* moduleObj = ImportModule(module);
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (moduleObj)
|
if (moduleObj)
|
||||||
{
|
{
|
||||||
PyObject* argsObj = ParseArgs(args);
|
PyObject* argObj = PyString_FromString(arg);
|
||||||
if (argsObj)
|
if (argObj)
|
||||||
{
|
{
|
||||||
PyObject* callResult = RunFunction(moduleObj, function, argsObj);
|
PyObject* argsObj = PyTuple_New(1);
|
||||||
if (callResult)
|
if (argsObj)
|
||||||
{
|
{
|
||||||
result = true;
|
// PyTuple_SET_ITEM steals the reference to argObj.
|
||||||
Py_DECREF(callResult);
|
PyTuple_SET_ITEM(argsObj, 0, argObj);
|
||||||
|
PyObject* callResult = RunFunction(moduleObj, name, argsObj);
|
||||||
|
if (callResult)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
Py_DECREF(callResult);
|
||||||
|
}
|
||||||
|
Py_DECREF(argsObj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Py_DECREF(argObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_DECREF(argsObj);
|
|
||||||
}
|
}
|
||||||
Py_DECREF(moduleObj);
|
Py_DECREF(moduleObj);
|
||||||
}
|
}
|
||||||
|
@ -223,9 +223,7 @@ public:
|
|||||||
|
|
||||||
static PyObject* RunFunction(PyObject* module, const char* name, PyObject* args);
|
static PyObject* RunFunction(PyObject* module, const char* name, PyObject* args);
|
||||||
|
|
||||||
static PyObject* ParseArgs(const char* args);
|
static bool RunFunctionStringArg(const char* module, const char* name, const char* arg);
|
||||||
|
|
||||||
static bool RunFunctionSafe(const char* module, const char* function, const char* args);
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -217,6 +217,8 @@ bool plResponderModifier::IIsLocalOnlyCmd(plMessage* cmd)
|
|||||||
return true;
|
return true;
|
||||||
if (plCameraMsg::ConvertNoRef(cmd)) // don't want to change our camera
|
if (plCameraMsg::ConvertNoRef(cmd)) // don't want to change our camera
|
||||||
return true;
|
return true;
|
||||||
|
if (plSubWorldMsg::ConvertNoRef(cmd)) // don't want to enter a subworld (changes the avatar SDL)
|
||||||
|
return true;
|
||||||
|
|
||||||
plSoundMsg *snd = plSoundMsg::ConvertNoRef( cmd );
|
plSoundMsg *snd = plSoundMsg::ConvertNoRef( cmd );
|
||||||
if( snd != nil && snd->Cmd( plSoundMsg::kIsLocalOnly ) )
|
if( snd != nil && snd->Cmd( plSoundMsg::kIsLocalOnly ) )
|
||||||
|
@ -211,7 +211,7 @@ void plNCAgeJoiner::Start () {
|
|||||||
|
|
||||||
plNetClientMgr * nc = plNetClientMgr::GetInstance();
|
plNetClientMgr * nc = plNetClientMgr::GetInstance();
|
||||||
nc->SetFlagsBit(plNetClientMgr::kPlayingGame, false);
|
nc->SetFlagsBit(plNetClientMgr::kPlayingGame, false);
|
||||||
nc->fServerTimeOffset = 0; // reset since we're connecting to a new server
|
nc->ResetServerTimeOffset();
|
||||||
nc->fRequiredNumInitialSDLStates = 0;
|
nc->fRequiredNumInitialSDLStates = 0;
|
||||||
nc->fNumInitialSDLStates = 0;
|
nc->fNumInitialSDLStates = 0;
|
||||||
nc->SetFlagsBit(plNetClientApp::kNeedInitialAgeStateCount);
|
nc->SetFlagsBit(plNetClientApp::kNeedInitialAgeStateCount);
|
||||||
|
@ -133,9 +133,7 @@ plNetClientMgr::plNetClientMgr() :
|
|||||||
// fProgressBar( nil ),
|
// fProgressBar( nil ),
|
||||||
fTaskProgBar( nil ),
|
fTaskProgBar( nil ),
|
||||||
fMsgRecorder(nil),
|
fMsgRecorder(nil),
|
||||||
fServerTimeOffset(0),
|
fLastLocalTime(),
|
||||||
fTimeSamples(0),
|
|
||||||
fLastTimeUpdate(0),
|
|
||||||
fListenListMode(kListenList_Distance),
|
fListenListMode(kListenList_Distance),
|
||||||
fAgeSDLObjectKey(nil),
|
fAgeSDLObjectKey(nil),
|
||||||
fExperimentalLevel(0),
|
fExperimentalLevel(0),
|
||||||
@ -480,34 +478,23 @@ void plNetClientMgr::StartLinkInFX()
|
|||||||
//
|
//
|
||||||
void plNetClientMgr::UpdateServerTimeOffset(plNetMessage* msg)
|
void plNetClientMgr::UpdateServerTimeOffset(plNetMessage* msg)
|
||||||
{
|
{
|
||||||
if ((hsTimer::GetSysSeconds() - fLastTimeUpdate) > 5)
|
if (!msg->GetHasTimeSent())
|
||||||
{
|
return;
|
||||||
fLastTimeUpdate = hsTimer::GetSysSeconds();
|
if (msg->GetTimeSent().AtEpoch())
|
||||||
|
return;
|
||||||
|
|
||||||
const plUnifiedTime& msgSentUT = msg->GetTimeSent();
|
double localTime = hsTimer::GetSeconds();
|
||||||
if (!msgSentUT.AtEpoch())
|
if (localTime - fLastLocalTime < 1.0)
|
||||||
{
|
return;
|
||||||
double diff = plUnifiedTime::GetTimeDifference(msgSentUT, plClientUnifiedTime::GetCurrentTime());
|
|
||||||
|
|
||||||
if (fServerTimeOffset == 0)
|
fLastServerTime = msg->GetTimeSent();
|
||||||
{
|
fLastLocalTime = localTime;
|
||||||
fServerTimeOffset = diff;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fServerTimeOffset = fServerTimeOffset + ((diff - fServerTimeOffset) / ++fTimeSamples);
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugMsg("Setting server time offset to %f", fServerTimeOffset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void plNetClientMgr::ResetServerTimeOffset()
|
void plNetClientMgr::ResetServerTimeOffset()
|
||||||
{
|
{
|
||||||
fServerTimeOffset = 0;
|
fLastServerTime.ToEpoch();
|
||||||
fTimeSamples = 0;
|
fLastLocalTime = 0.0;
|
||||||
fLastTimeUpdate = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -515,14 +502,12 @@ void plNetClientMgr::ResetServerTimeOffset()
|
|||||||
//
|
//
|
||||||
plUnifiedTime plNetClientMgr::GetServerTime() const
|
plUnifiedTime plNetClientMgr::GetServerTime() const
|
||||||
{
|
{
|
||||||
if ( fServerTimeOffset==0 ) // offline mode or before connecting/calibrating to a server
|
if (fLastServerTime.AtEpoch()) {
|
||||||
|
WarningMsg("Someone asked for the server time, but we don't know it yet!");
|
||||||
return plUnifiedTime::GetCurrentTime();
|
return plUnifiedTime::GetCurrentTime();
|
||||||
|
}
|
||||||
|
|
||||||
plUnifiedTime serverUT;
|
return fLastServerTime + plUnifiedTime(hsTimer::GetSeconds() - fLastLocalTime);
|
||||||
if (fServerTimeOffset<0)
|
|
||||||
return plUnifiedTime::GetCurrentTime() - plUnifiedTime(fabs(fServerTimeOffset));
|
|
||||||
else
|
|
||||||
return plUnifiedTime::GetCurrentTime() + plUnifiedTime(fServerTimeOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -166,9 +166,8 @@ private:
|
|||||||
std::string fSPDesiredPlayerName; // SP: the player we want to load from vault.
|
std::string fSPDesiredPlayerName; // SP: the player we want to load from vault.
|
||||||
|
|
||||||
// server info
|
// server info
|
||||||
double fServerTimeOffset; // diff between our unified time and server's unified time
|
plUnifiedTime fLastServerTime; // Last received time update from the server
|
||||||
UInt32 fTimeSamples;
|
double fLastLocalTime; // Last monotonic time (in seconds) when the above update was received
|
||||||
double fLastTimeUpdate;
|
|
||||||
|
|
||||||
UInt8 fJoinOrder; // returned by the server
|
UInt8 fJoinOrder; // returned by the server
|
||||||
|
|
||||||
|
@ -59,8 +59,10 @@ plRegistryKeyList::~plRegistryKeyList()
|
|||||||
for (int i = 0; i < fStaticKeys.size(); i++)
|
for (int i = 0; i < fStaticKeys.size(); i++)
|
||||||
{
|
{
|
||||||
plKeyImp* keyImp = fStaticKeys[i];
|
plKeyImp* keyImp = fStaticKeys[i];
|
||||||
if (!keyImp->ObjectIsLoaded())
|
if (keyImp && !keyImp->ObjectIsLoaded()) {
|
||||||
|
fStaticKeys[i] = nullptr;
|
||||||
delete keyImp;
|
delete keyImp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +203,7 @@ void plRegistryPageNode::UnloadKeys()
|
|||||||
for (; it != fKeyLists.end(); it++)
|
for (; it != fKeyLists.end(); it++)
|
||||||
{
|
{
|
||||||
plRegistryKeyList* keyList = it->second;
|
plRegistryKeyList* keyList = it->second;
|
||||||
|
it->second = nullptr;
|
||||||
delete keyList;
|
delete keyList;
|
||||||
}
|
}
|
||||||
fKeyLists.clear();
|
fKeyLists.clear();
|
||||||
|
@ -219,14 +219,20 @@ void plResManager::IShutdown()
|
|||||||
// Shut down the registry (finally!)
|
// Shut down the registry (finally!)
|
||||||
ILockPages();
|
ILockPages();
|
||||||
|
|
||||||
PageSet::const_iterator it;
|
// Unload all keys before actually deleting the pages.
|
||||||
for (it = fAllPages.begin(); it != fAllPages.end(); it++)
|
// When a key's refcount drops to zero, IKeyUnreffed looks up the key's page.
|
||||||
delete *it;
|
// If the page is already deleted at that point, this causes a use after free and potential crash.
|
||||||
fAllPages.clear();
|
for (PageSet::const_iterator it = fAllPages.begin(); it != fAllPages.end(); it++) {
|
||||||
|
(*it)->UnloadKeys();
|
||||||
|
}
|
||||||
fLoadedPages.clear();
|
fLoadedPages.clear();
|
||||||
|
fLastFoundPage = nil;
|
||||||
|
for (PageSet::const_iterator it = fAllPages.begin(); it != fAllPages.end(); it++) {
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
fAllPages.clear();
|
||||||
|
|
||||||
IUnlockPages();
|
IUnlockPages();
|
||||||
fLastFoundPage = nil;
|
|
||||||
|
|
||||||
// Now, kill off the Dispatcher
|
// Now, kill off the Dispatcher
|
||||||
hsRefCnt_SafeUnRef(fDispatch);
|
hsRefCnt_SafeUnRef(fDispatch);
|
||||||
|
Reference in New Issue
Block a user