mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 10:37:41 -04:00
Compare commits
22 Commits
OPENURU_BU
...
master
Author | SHA1 | Date | |
---|---|---|---|
76ef5e0111 | |||
618fb8f13e | |||
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
|
||||
"Run a cheat command" )
|
||||
{
|
||||
std::string extraParms;
|
||||
const char* extraParms = "";
|
||||
if (numParams > 1)
|
||||
{
|
||||
extraParms = "(";
|
||||
extraParms.append(params[1]);
|
||||
extraParms.append(",)");
|
||||
extraParms = params[1];
|
||||
}
|
||||
else
|
||||
extraParms = "()";
|
||||
|
||||
PythonInterface::RunFunctionSafe("xCheat", params[0], extraParms.c_str());
|
||||
PythonInterface::RunFunctionStringArg("xCheat", params[0], extraParms);
|
||||
|
||||
std::string output;
|
||||
// get the messages
|
||||
|
@ -2102,38 +2102,32 @@ PyObject* PythonInterface::RunFunction(PyObject* module, const char* name, PyObj
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject* PythonInterface::ParseArgs(const char* args)
|
||||
{
|
||||
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)
|
||||
bool PythonInterface::RunFunctionStringArg(const char* module, const char* name, const char* arg)
|
||||
{
|
||||
PyObject* moduleObj = ImportModule(module);
|
||||
bool result = false;
|
||||
if (moduleObj)
|
||||
{
|
||||
PyObject* argsObj = ParseArgs(args);
|
||||
if (argsObj)
|
||||
PyObject* argObj = PyString_FromString(arg);
|
||||
if (argObj)
|
||||
{
|
||||
PyObject* callResult = RunFunction(moduleObj, function, argsObj);
|
||||
if (callResult)
|
||||
PyObject* argsObj = PyTuple_New(1);
|
||||
if (argsObj)
|
||||
{
|
||||
result = true;
|
||||
Py_DECREF(callResult);
|
||||
// PyTuple_SET_ITEM steals the reference to argObj.
|
||||
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);
|
||||
}
|
||||
|
@ -223,9 +223,7 @@ public:
|
||||
|
||||
static PyObject* RunFunction(PyObject* module, const char* name, PyObject* args);
|
||||
|
||||
static PyObject* ParseArgs(const char* args);
|
||||
|
||||
static bool RunFunctionSafe(const char* module, const char* function, const char* args);
|
||||
static bool RunFunctionStringArg(const char* module, const char* name, const char* arg);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -217,6 +217,8 @@ bool plResponderModifier::IIsLocalOnlyCmd(plMessage* cmd)
|
||||
return true;
|
||||
if (plCameraMsg::ConvertNoRef(cmd)) // don't want to change our camera
|
||||
return true;
|
||||
if (plSubWorldMsg::ConvertNoRef(cmd)) // don't want to enter a subworld (changes the avatar SDL)
|
||||
return true;
|
||||
|
||||
plSoundMsg *snd = plSoundMsg::ConvertNoRef( cmd );
|
||||
if( snd != nil && snd->Cmd( plSoundMsg::kIsLocalOnly ) )
|
||||
|
@ -211,7 +211,7 @@ void plNCAgeJoiner::Start () {
|
||||
|
||||
plNetClientMgr * nc = plNetClientMgr::GetInstance();
|
||||
nc->SetFlagsBit(plNetClientMgr::kPlayingGame, false);
|
||||
nc->fServerTimeOffset = 0; // reset since we're connecting to a new server
|
||||
nc->ResetServerTimeOffset();
|
||||
nc->fRequiredNumInitialSDLStates = 0;
|
||||
nc->fNumInitialSDLStates = 0;
|
||||
nc->SetFlagsBit(plNetClientApp::kNeedInitialAgeStateCount);
|
||||
|
@ -133,9 +133,7 @@ plNetClientMgr::plNetClientMgr() :
|
||||
// fProgressBar( nil ),
|
||||
fTaskProgBar( nil ),
|
||||
fMsgRecorder(nil),
|
||||
fServerTimeOffset(0),
|
||||
fTimeSamples(0),
|
||||
fLastTimeUpdate(0),
|
||||
fLastLocalTime(),
|
||||
fListenListMode(kListenList_Distance),
|
||||
fAgeSDLObjectKey(nil),
|
||||
fExperimentalLevel(0),
|
||||
@ -480,34 +478,23 @@ void plNetClientMgr::StartLinkInFX()
|
||||
//
|
||||
void plNetClientMgr::UpdateServerTimeOffset(plNetMessage* msg)
|
||||
{
|
||||
if ((hsTimer::GetSysSeconds() - fLastTimeUpdate) > 5)
|
||||
{
|
||||
fLastTimeUpdate = hsTimer::GetSysSeconds();
|
||||
if (!msg->GetHasTimeSent())
|
||||
return;
|
||||
if (msg->GetTimeSent().AtEpoch())
|
||||
return;
|
||||
|
||||
const plUnifiedTime& msgSentUT = msg->GetTimeSent();
|
||||
if (!msgSentUT.AtEpoch())
|
||||
{
|
||||
double diff = plUnifiedTime::GetTimeDifference(msgSentUT, plClientUnifiedTime::GetCurrentTime());
|
||||
double localTime = hsTimer::GetSeconds();
|
||||
if (localTime - fLastLocalTime < 1.0)
|
||||
return;
|
||||
|
||||
if (fServerTimeOffset == 0)
|
||||
{
|
||||
fServerTimeOffset = diff;
|
||||
}
|
||||
else
|
||||
{
|
||||
fServerTimeOffset = fServerTimeOffset + ((diff - fServerTimeOffset) / ++fTimeSamples);
|
||||
}
|
||||
|
||||
DebugMsg("Setting server time offset to %f", fServerTimeOffset);
|
||||
}
|
||||
}
|
||||
fLastServerTime = msg->GetTimeSent();
|
||||
fLastLocalTime = localTime;
|
||||
}
|
||||
|
||||
void plNetClientMgr::ResetServerTimeOffset()
|
||||
{
|
||||
fServerTimeOffset = 0;
|
||||
fTimeSamples = 0;
|
||||
fLastTimeUpdate = 0;
|
||||
fLastServerTime.ToEpoch();
|
||||
fLastLocalTime = 0.0;
|
||||
}
|
||||
|
||||
//
|
||||
@ -515,14 +502,12 @@ void plNetClientMgr::ResetServerTimeOffset()
|
||||
//
|
||||
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();
|
||||
|
||||
plUnifiedTime serverUT;
|
||||
if (fServerTimeOffset<0)
|
||||
return plUnifiedTime::GetCurrentTime() - plUnifiedTime(fabs(fServerTimeOffset));
|
||||
else
|
||||
return plUnifiedTime::GetCurrentTime() + plUnifiedTime(fServerTimeOffset);
|
||||
}
|
||||
|
||||
return fLastServerTime + plUnifiedTime(hsTimer::GetSeconds() - fLastLocalTime);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -166,9 +166,8 @@ private:
|
||||
std::string fSPDesiredPlayerName; // SP: the player we want to load from vault.
|
||||
|
||||
// server info
|
||||
double fServerTimeOffset; // diff between our unified time and server's unified time
|
||||
UInt32 fTimeSamples;
|
||||
double fLastTimeUpdate;
|
||||
plUnifiedTime fLastServerTime; // Last received time update from the server
|
||||
double fLastLocalTime; // Last monotonic time (in seconds) when the above update was received
|
||||
|
||||
UInt8 fJoinOrder; // returned by the server
|
||||
|
||||
|
@ -59,8 +59,10 @@ plRegistryKeyList::~plRegistryKeyList()
|
||||
for (int i = 0; i < fStaticKeys.size(); i++)
|
||||
{
|
||||
plKeyImp* keyImp = fStaticKeys[i];
|
||||
if (!keyImp->ObjectIsLoaded())
|
||||
if (keyImp && !keyImp->ObjectIsLoaded()) {
|
||||
fStaticKeys[i] = nullptr;
|
||||
delete keyImp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,6 +203,7 @@ void plRegistryPageNode::UnloadKeys()
|
||||
for (; it != fKeyLists.end(); it++)
|
||||
{
|
||||
plRegistryKeyList* keyList = it->second;
|
||||
it->second = nullptr;
|
||||
delete keyList;
|
||||
}
|
||||
fKeyLists.clear();
|
||||
|
@ -219,14 +219,20 @@ void plResManager::IShutdown()
|
||||
// Shut down the registry (finally!)
|
||||
ILockPages();
|
||||
|
||||
PageSet::const_iterator it;
|
||||
for (it = fAllPages.begin(); it != fAllPages.end(); it++)
|
||||
delete *it;
|
||||
fAllPages.clear();
|
||||
// Unload all keys before actually deleting the pages.
|
||||
// When a key's refcount drops to zero, IKeyUnreffed looks up the key's page.
|
||||
// If the page is already deleted at that point, this causes a use after free and potential crash.
|
||||
for (PageSet::const_iterator it = fAllPages.begin(); it != fAllPages.end(); it++) {
|
||||
(*it)->UnloadKeys();
|
||||
}
|
||||
fLoadedPages.clear();
|
||||
fLastFoundPage = nil;
|
||||
for (PageSet::const_iterator it = fAllPages.begin(); it != fAllPages.end(); it++) {
|
||||
delete *it;
|
||||
}
|
||||
fAllPages.clear();
|
||||
|
||||
IUnlockPages();
|
||||
fLastFoundPage = nil;
|
||||
|
||||
// Now, kill off the Dispatcher
|
||||
hsRefCnt_SafeUnRef(fDispatch);
|
||||
|
Reference in New Issue
Block a user