2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

Merge pull request #206 from Hoikas/quabs

Engine fixes for AhnyQuabs
This commit is contained in:
Branan Purvine-Riley
2012-06-10 09:50:25 -07:00
17 changed files with 158 additions and 106 deletions

View File

@ -2700,7 +2700,7 @@ PyObject* cyMisc::LoadAvatarModel(const char* modelName, pyKey& spawnPoint, cons
void cyMisc::UnLoadAvatarModel(pyKey& avatar)
{
plAvatarMgr::GetInstance()->UnLoadAvatar(avatar.getKey(), false);
plAvatarMgr::GetInstance()->UnLoadAvatar(avatar.getKey(), false, true);
}
void cyMisc::ForceCursorHidden()
@ -2868,14 +2868,7 @@ PyObject* cyMisc::GetAIAvatarsByModelName(const char* name)
Py_DECREF(tuple);
}
}
if (PyList_Size(avList) > 0)
return avList;
else
{
Py_DECREF(avList);
PYTHON_RETURN_NONE;
}
return avList;
}
void cyMisc::ForceVaultNodeUpdate(unsigned nodeId)

View File

@ -374,7 +374,8 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtLoadAvatarModel, args, "Params: modelName, spa
return cyMisc::LoadAvatarModel(modelName, *key, userStr.c_str());
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtUnLoadAvatarModel, args, "Params: avatarKey\nUnloads the specified avatar model")
PYTHON_GLOBAL_METHOD_DEFINITION(PtUnLoadAvatarModel, args, "Params: avatarKey\nForcibly unloads the specified avatar model.\n"
"Do not use this method unless you require fine-grained control of avatar unloading.")
{
PyObject* keyObj = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObj))

View File

@ -852,6 +852,34 @@ void plPythonFileMod::AddTarget(plSceneObject* sobj)
DisplayPythonOutput();
}
// Oversight fix... Sometimes PythonFileMods are loaded after the AgeInitialState is received.
// We should really let the script know about that via OnServerInitComplete anyway because it's
// not good to make assumptions about game state in workarounds for that method not being called
plNetClientApp* na = plNetClientApp::GetInstance();
if (!na->GetFlagsBit(plNetClientApp::kLoadingInitialAgeState) &&
na->GetFlagsBit(plNetClientApp::kPlayingGame))
{
plgDispatch::Dispatch()->UnRegisterForExactType(plInitialAgeStateLoadedMsg::Index(), GetKey());
plProfile_BeginTiming(PythonUpdate);
// call it
PyObject* retVal = PyObject_CallMethod(
fPyFunctionInstances[kfunc_OnServerInitComplete],
(char*)fFunctionNames[kfunc_OnServerInitComplete], nil);
if ( retVal == nil )
{
#ifndef PLASMA_EXTERNAL_RELEASE
// for some reason this function didn't, remember that and not call it again
fPyFunctionInstances[kfunc_OnServerInitComplete] = nil;
#endif //PLASMA_EXTERNAL_RELEASE
// if there was an error make sure that the stderr gets flushed so it can be seen
ReportError();
}
Py_XDECREF(retVal);
plProfile_EndTiming(PythonUpdate);
// display any output (NOTE: this would be disabled in production)
DisplayPythonOutput();
}
// display python output
DisplayPythonOutput();
}

View File

@ -41,8 +41,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "pyCritterBrain.h"
#include "pyGeometry3.h"
#include "pySceneObject.h"
#include "plAvatar/plAvBrainCritter.h"
#include "pnSceneObject/plSceneObject.h"
pyCritterBrain::pyCritterBrain(): fBrain(nil) {}
@ -66,18 +68,12 @@ void pyCritterBrain::RemoveReceiver(pyKey& oldReceiver)
fBrain->RemoveReceiver(oldReceiver.getKey());
}
void pyCritterBrain::LocallyControlled(bool local)
PyObject* pyCritterBrain::GetSceneObject()
{
if (!fBrain)
return;
fBrain->LocallyControlled(local);
}
bool pyCritterBrain::LocallyControlled() const
{
if (!fBrain)
return false;
return fBrain->LocallyControlled();
if (fBrain)
if (plSceneObject* obj = fBrain->GetTarget())
return pySceneObject::New(obj->GetKey());
PYTHON_RETURN_NONE;
}
void pyCritterBrain::AddBehavior(const std::string& animationName, const std::string& behaviorName, bool loop /* = true */,

View File

@ -83,8 +83,7 @@ public:
void AddReceiver(pyKey& newReceiver);
void RemoveReceiver(pyKey& oldReceiver);
void LocallyControlled(bool local);
bool LocallyControlled() const;
PyObject* GetSceneObject();
void AddBehavior(const std::string& animationName, const std::string& behaviorName, bool loop = true, bool randomStartPos = true,
float fadeInLen = 2.f, float fadeOutLen = 2.f);

View File

@ -139,21 +139,9 @@ PYTHON_METHOD_DEFINITION(ptCritterBrain, removeReceiver, args)
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptCritterBrain, setLocallyControlled, args)
PYTHON_METHOD_DEFINITION(ptCritterBrain, getSceneObject, GetSceneObject)
{
char local;
if (!PyArg_ParseTuple(args, "b", &local))
{
PyErr_SetString(PyExc_TypeError, "setLocallyControlled expects a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->LocallyControlled(local != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCritterBrain, getLocallyControlled)
{
PYTHON_RETURN_BOOL(self->fThis->LocallyControlled());
return self->fThis->GetSceneObject();
}
PYTHON_METHOD_DEFINITION_WKEY(ptCritterBrain, addBehavior, args, keywords)
@ -472,10 +460,7 @@ PYTHON_METHOD_DEFINITION(ptCritterBrain, vectorToPlayer, args)
PYTHON_START_METHODS_TABLE(ptCritterBrain)
PYTHON_METHOD(ptCritterBrain, addReceiver, "Params: key\nTells the brain that the specified key wants AI messages"),
PYTHON_METHOD(ptCritterBrain, removeReceiver, "Params: key\nTells the brain that the specified key no longer wants AI messages"),
PYTHON_METHOD(ptCritterBrain, setLocallyControlled, "Params: local\nTells the brain that we are the ones making all the AI decisions, and to prop location "
"and other information to the server."),
PYTHON_METHOD_NOARGS(ptCritterBrain, getLocallyControlled, "Are we the one making AI decisions? NOTE: Not set automatically, some python script needs to "
"tell the brain this using setLocallyControlled()."),
PYTHON_METHOD(ptCritterBrain, getSceneObject, "Returns the ptSceneObject this brain controls."),
PYTHON_METHOD_WKEY(ptCritterBrain, addBehavior, "Params: animName, behaviorName, loop = 1, randomStartPos = 1, fadeInLen = 2.0, fadeOutLen = 2.0\n"
"Adds a new animation to the brain as a behavior with the specified name and parameters. If multiple animations are assigned to the same behavior, "
"they will be randomly picked from when started."),