本文整理汇总了C++中PyErr_PrintEx函数的典型用法代码示例。如果您正苦于以下问题:C++ PyErr_PrintEx函数的具体用法?C++ PyErr_PrintEx怎么用?C++ PyErr_PrintEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyErr_PrintEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: t_bootstrap
static void
t_bootstrap(void *boot_raw)
{
struct bootstate *boot = (struct bootstate *) boot_raw;
PyThreadState *tstate;
PyObject *res;
tstate = PyThreadState_New(boot->interp);
PyEval_AcquireThread(tstate);
res = PyEval_CallObjectWithKeywords(
boot->func, boot->args, boot->keyw);
if (res == NULL) {
if (PyErr_ExceptionMatches(PyExc_SystemExit))
PyErr_Clear();
else {
PyObject *file;
PySys_WriteStderr(
"Unhandled exception in thread started by ");
file = PySys_GetObject("stderr");
if (file)
PyFile_WriteObject(boot->func, file, 0);
else
PyObject_Print(boot->func, stderr, 0);
PySys_WriteStderr("\n");
PyErr_PrintEx(0);
}
}
else
Py_DECREF(res);
Py_DECREF(boot->func);
Py_DECREF(boot->args);
Py_XDECREF(boot->keyw);
PyMem_DEL(boot_raw);
PyThreadState_Clear(tstate);
PyThreadState_DeleteCurrent();
PyThread_exit_thread();
}
示例2: htpy_log_callback
int htpy_log_callback(htp_log_t *log) {
PyObject *obj = (PyObject *) htp_connp_get_user_data(log->connp);
PyObject *arglist = NULL;
PyObject *res;
long i;
if (((htpy_connp *) obj)->obj_store)
arglist = Py_BuildValue("(OsiO)", (htpy_connp *) obj, log->msg, log->level, ((htpy_connp *) obj)->obj_store);
else
arglist = Py_BuildValue("(Osi)", (htpy_connp *) obj, log->msg, log->level);
if (!arglist)
return HTP_ERROR;
res = PyObject_CallObject(((htpy_connp *) obj)->log_callback, arglist);
Py_DECREF(arglist);
if (PyErr_Occurred() != NULL) {
PyErr_PrintEx(0);
return HTP_ERROR;
}
i = PyInt_AsLong(res);
Py_DECREF(res);
return((int) i);
}
示例3: run_code
int run_code(int val){
//int main(void){
int ret = 0;
PyObject* retval;
Py_Initialize();
PyRun_SimpleString("print('hello word from embedded python')");
PyObject* main_mod = PyImport_AddModule("__main__");
PyObject* main_dic = PyModule_GetDict(main_mod);
const char *script_name = "hello.py";
FILE* script = fopen(script_name,"r");
retval = PyImport_ImportModule("numpy");
// retval = PyImport_ImportModuleEx("numpy", main_dic, main_dic, NULL);
if(!retval) goto py_error;
retval = PyRun_File(script, script_name, Py_file_input, main_dic, main_dic);
if(!retval) goto py_error;
/*
PyObject* retobj = PyRun_String("foo(11)", Py_eval_input, main_dic, main_dic);
long retval = PyLong_AsLong(retobj);
*/
py_exit:
Py_Finalize();
return ret;
py_error:
ret = -1;
printf("exception in script !?");
PyErr_PrintEx(0);
goto py_exit;
}
示例4: PyLong_AsLong
PyObject * Entities<T>::mp_subscript(PyObject* self, PyObject* key /*entityID*/)
{
Entities* lpEntities = static_cast<Entities*>(self);
ENTITY_ID entityID = PyLong_AsLong(key);
if (PyErr_Occurred())
return NULL;
PyObject * pyEntity = NULL;
ENTITYS_MAP& entities = lpEntities->getEntities();
ENTITYS_MAP::const_iterator iter = entities.find(entityID);
if (iter != entities.end())
pyEntity = iter->second.get();
if(pyEntity == NULL)
{
PyErr_Format(PyExc_KeyError, "%d", entityID);
PyErr_PrintEx(0);
return NULL;
}
Py_INCREF(pyEntity);
return pyEntity;
}
示例5: PyErr_SetString
//-------------------------------------------------------------------------------------
PyObject* ScriptVector2::__py_pyDistSqrTo(PyObject* self, PyObject* args)
{
if (PyTuple_Size(args) != 1)
{
PyErr_SetString(PyExc_TypeError, "args > 1 is error!\n");
PyErr_PrintEx(0);
S_Return;
}
PyObject* pyVal = PyTuple_GET_ITEM(args, 0);
if(!check(pyVal))
{
S_Return;
}
ScriptVector2* sv = static_cast<ScriptVector2*>(self);
Vector2& v = sv->getVector();
Vector2 v1;
convertPyObjectToVector2(v1, pyVal);
Vector2 rv = (v - v1);
return PyFloat_FromDouble(KBEVec2LengthSq(&rv)); //计算点乘并返回
}
示例6: PyErr_Format
//-------------------------------------------------------------------------------------
PyObject* EntityRemoteMethod::tp_call(PyObject* self, PyObject* args,
PyObject* kwds)
{
EntityRemoteMethod* rmethod = static_cast<EntityRemoteMethod*>(self);
MethodDescription* methodDescription = rmethod->getDescription();
EntityMailboxAbstract* mailbox = rmethod->getMailbox();
if(!mailbox->isClient())
{
return RemoteEntityMethod::tp_call(self, args, kwds);
}
Entity* pEntity = Cellapp::getSingleton().findEntity(mailbox->id());
if(pEntity == NULL || pEntity->pWitness() == NULL)
{
//WARNING_MSG(fmt::format("EntityRemoteMethod::callClientMethod: not found entity({}).\n",
// mailbox->id()));
return RemoteEntityMethod::tp_call(self, args, kwds);
}
Network::Channel* pChannel = pEntity->pWitness()->pChannel();
if(!pChannel)
{
PyErr_Format(PyExc_AssertionError, "%s:EntityRemoteMethod(%s)::tp_call: no client, srcEntityID(%d).\n",
pEntity->scriptName(), methodDescription->getName(), pEntity->id());
PyErr_PrintEx(0);
return RemoteEntityMethod::tp_call(self, args, kwds);
}
// 如果是调用客户端方法, 我们记录事件并且记录带宽
if(methodDescription->checkArgs(args))
{
Network::Bundle* pBundle = pChannel->createSendBundle();
mailbox->newMail((*pBundle));
MemoryStream* mstream = MemoryStream::createPoolObject();
methodDescription->addToStream(mstream, args);
if(mstream->wpos() > 0)
(*pBundle).append(mstream->data(), (int)mstream->wpos());
if(Network::g_trace_packet > 0)
{
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger("packetlogs");
DEBUG_MSG(fmt::format("EntityRemoteMethod::tp_call: pushUpdateData: ClientInterface::onRemoteMethodCall({}::{})\n",
pEntity->scriptName(), methodDescription->getName()));
switch(Network::g_trace_packet)
{
case 1:
mstream->hexlike();
break;
case 2:
mstream->textlike();
break;
default:
mstream->print_storage();
break;
};
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger(COMPONENT_NAME_EX(g_componentType));
}
// 记录这个事件产生的数据量大小
g_privateClientEventHistoryStats.trackEvent(pEntity->scriptName(),
methodDescription->getName(),
pBundle->currMsgLength(),
"::");
pEntity->pWitness()->sendToClient(ClientInterface::onRemoteMethodCall, pBundle);
MemoryStream::reclaimPoolObject(mstream);
}
S_Return;
}
示例7: PyTuple_Size
//-------------------------------------------------------------------------------------
PyObject* Proxy::__py_pyStreamStringToClient(PyObject* self, PyObject* args)
{
uint16 currargsSize = PyTuple_Size(args);
Proxy* pobj = static_cast<Proxy*>(self);
if(pobj->clientMailbox() == NULL)
{
PyErr_Format(PyExc_AssertionError,
"Proxy::streamStringToClient: has no client.");
PyErr_PrintEx(0);
return NULL;
}
if(currargsSize > 3 || currargsSize == 0)
{
PyErr_Format(PyExc_AssertionError,
"Proxy::streamStringToClient: args max require 3, gived %d! is script[%s].\n",
currargsSize, pobj->scriptName());
PyErr_PrintEx(0);
return NULL;
}
PyObject* pyData = NULL;
PyObject* pyDesc = NULL;
int16 id = -1;
if(currargsSize == 1)
{
if(PyArg_ParseTuple(args, "O", &pyData) == -1)
{
PyErr_Format(PyExc_TypeError, "Proxy::streamStringToClient: args is error!");
PyErr_PrintEx(0);
return NULL;
}
}
else if(currargsSize == 2)
{
if(PyArg_ParseTuple(args, "O|O", &pyData, &pyDesc) == -1)
{
PyErr_Format(PyExc_TypeError, "Proxy::streamStringToClient: args is error!");
PyErr_PrintEx(0);
return NULL;
}
}
else if(currargsSize == 3)
{
if(PyArg_ParseTuple(args, "O|O|H", &pyData, &pyDesc, &id) == -1)
{
PyErr_Format(PyExc_TypeError, "Proxy::streamStringToClient: args is error!");
PyErr_PrintEx(0);
return NULL;
}
}
char* pDescr = NULL;
if(pDescr != NULL)
{
wchar_t* PyUnicode_AsWideCharStringRet1 = PyUnicode_AsWideCharString(pyDesc, NULL);
pDescr = strutil::wchar2char(PyUnicode_AsWideCharStringRet1);
PyMem_Free(PyUnicode_AsWideCharStringRet1);
}
if(pDescr && strlen(pDescr) > 255)
{
PyErr_Format(PyExc_TypeError, "Proxy::streamFileToClient: the descr-size(%d > 255)!",
strlen(pDescr));
PyErr_PrintEx(0);
free(pDescr);
return NULL;
}
int16 rid = pobj->streamStringToClient(pyData,
(pDescr == NULL ? "" : pDescr),
id);
if(pDescr)
free(pDescr);
return PyLong_FromLong(rid);
}
示例8: kbe_snprintf
//-------------------------------------------------------------------------------------
void Proxy::giveClientTo(Proxy* proxy)
{
if(isDestroyed())
{
char err[255];
kbe_snprintf(err, 255, "Proxy[%s]::giveClientTo: %d is destroyed.",
scriptName(), id());
PyErr_SetString(PyExc_TypeError, err);
PyErr_PrintEx(0);
onGiveClientToFailure();
return;
}
if(clientMailbox_ == NULL || clientMailbox_->getChannel() == NULL)
{
char err[255];
kbe_snprintf(err, 255, "Proxy[%s]::giveClientTo: no has client.", scriptName());
PyErr_SetString(PyExc_TypeError, err);
PyErr_PrintEx(0);
onGiveClientToFailure();
return;
}
Network::Channel* lpChannel = clientMailbox_->getChannel();
if(proxy)
{
if(proxy->isDestroyed())
{
char err[255];
kbe_snprintf(err, 255, "Proxy[%s]::giveClientTo: target(%d) is destroyed.",
scriptName(), proxy->id());
PyErr_SetString(PyExc_TypeError, err);
PyErr_PrintEx(0);
onGiveClientToFailure();
return;
}
if(proxy->id() == this->id())
{
char err[255];
kbe_snprintf(err, 255, "Proxy[%s]::giveClientTo: target(%d) is self.",
scriptName(), proxy->id());
PyErr_SetString(PyExc_TypeError, err);
PyErr_PrintEx(0);
onGiveClientToFailure();
return;
}
EntityMailbox* mb = proxy->clientMailbox();
if(mb != NULL)
{
ERROR_MSG(fmt::format("Proxy::giveClientTo: {}[{}] give client to {}[{}], {} has clientMailbox.\n",
scriptName(),
id(),
proxy->scriptName(),
proxy->id(),
proxy->scriptName()));
onGiveClientToFailure();
return;
}
if(cellMailbox())
{
// 当前这个entity如果有cell,说明已经绑定了witness, 那么既然我们将控制权
// 交换给了另一个entity, 这个entity需要解绑定witness。
// 通知cell丢失witness
Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
(*pBundle).newMessage(CellappInterface::onLoseWitness);
(*pBundle) << this->id();
sendToCellapp(pBundle);
}
// 既然客户端失去对其的控制, 那么通知client销毁这个entity
Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
(*pBundle).newMessage(ClientInterface::onEntityDestroyed);
(*pBundle) << this->id();
sendToClient(ClientInterface::onEntityDestroyed, pBundle);
// 将控制权交换
entitiesEnabled_ = false;
clientMailbox()->addr(Network::Address::NONE);
Py_DECREF(clientMailbox());
proxy->setClientType(this->getClientType());
proxy->setClientDatas(this->getClientDatas());
this->setClientType(UNKNOWN_CLIENT_COMPONENT_TYPE);
this->setClientDatas("");
clientMailbox(NULL);
proxy->onGiveClientTo(lpChannel);
addr(Network::Address::NONE);
}
}
示例9: Py_INCREF
//-------------------------------------------------------------------------------------
PyObject* ScriptVector2::seq_slice(PyObject* self, Py_ssize_t startIndex, Py_ssize_t endIndex)
{
if(startIndex < 0)
startIndex = 0;
if(endIndex > VECTOR_SIZE)
endIndex = VECTOR_SIZE;
if(endIndex < startIndex)
endIndex = startIndex;
ScriptVector2* sv = static_cast<ScriptVector2*>(self);
Vector2& my_v = sv->getVector();
PyObject* pyResult = NULL;
int length = (int)(endIndex - startIndex);
if (length == VECTOR_SIZE)
{
pyResult = sv;
Py_INCREF(pyResult);
}
else
switch(length)
{
case 0:
pyResult = PyTuple_New(0);
break;
case 1:
pyResult = PyTuple_New(1);
PyTuple_SET_ITEM(pyResult, 0, PyFloat_FromDouble(sv->getVector()[static_cast<int>(startIndex)]));
break;
case 2:
{
Vector2 v;
for (int i = (int)startIndex; i < (int)endIndex; ++i){
v[i - static_cast<int>(startIndex)] = my_v[i];
}
pyResult = new ScriptVector2(v);
break;
}
case 3:
{
Vector3 v;
for (int i = (int)startIndex; i < (int)endIndex; ++i){
v[i - static_cast<int>(startIndex)] = my_v[i];
}
pyResult = new ScriptVector3(v);
break;
}
default:
PyErr_Format(PyExc_IndexError, "Bad slice indexes [%d, %d] for Vector%d", startIndex, endIndex, VECTOR_SIZE);
PyErr_PrintEx(0);
break;
}
return pyResult;
}
示例10: PyErr_Print
void
PyErr_Print(void)
{
PyErr_PrintEx(1);
}
示例11: PyErr_Format
PyObject *TuplesDefaultImpl::ubiquitous_caller
(
exceptionHandler &h
, PyObject *args
, PyObject *kwds
, const bool is_probe
, const callerTypes ct
)
{
const callVariants cv = m_data.cv;
const modes mode = is_probe ? (_G_signature_hack_enabled ? modeInitHack : modeInit) : modeRun;
TuplesData2DefaultImpl &data = dynamic_cast<TuplesData2DefaultImpl &>(m_data);
if (mode == modeRun && !m_data.m_valid)
{
PyErr_Format(PyExc_AttributeError, "Tuple invalid due to one or more previous errors. Call impossible in any way (%s)", Container::container().context_by_address(data.m_address).c_str());
return NULL;
}
if (ct == ctGetter)
{
TupleState::set_mode_getter();
}
else if (ct == ctSetter)
{
TupleState::set_mode_setter();
}
if (mode == modeRun)
{
m_exec = true;
m_tuple = args;
m_kw = kwds;
m_retval = NULL;
}
if (mode == modeRun || mode == modeInitHack)
{
m_clear_before_execute();
bool
just_filled = false
, exception_thrown
;
try
{
exception_thrown = !exceptionHandler::call(h, data.m_address);
just_filled = !exception_thrown;
}
catch (const ParseException &ex)
{
//Неверные аргументы Python; только в режиме исполнения
PyErr_Format(PyExc_TypeError, "%s (%s)", ex.what(), Container::container().context_by_address(data.m_address).c_str());
exception_thrown = true;
just_filled = true;
}
/* NOTE
Despite of exception thrown user call can leave return value inited
Non null return value in case of not filled tuple is unbelievable internal error
*/
if (m_retval && (exception_thrown || !TupleState::is_filled()))
{
Py_DecRef(m_retval);
m_retval = NULL;
}
if (mode == modeInitHack && PyErr_Occurred())
{
PyErr_PrintEx(0);
PyErr_Clear();
}
if (!TupleState::is_filled())
{
/* NOTE
Tuple must be filled during first call in any way.
Any exceptions or invalid actions inside (TuplesData::*call_t) whereby tuple not filled
during first call causes inevitable invalidation. Any subsequent calls waved aside
This in the same way as for v_getsetter calls: even if getter filled successfully, error in setter
invalidates tuple at all and virce versa
*/
m_data.m_valid = false;
just_filled = false;
if (!exception_thrown)
{
PyErr_Format(PyExc_AttributeError, "Tuple invalid due to unknown reason. Any further calls impossible in any way (%s)", Container::container().context_by_address(data.m_address).c_str());
}
}
else if (just_filled)
{
//Here: user call executed successfully or caused parse error
just_filled = false;
try
{
just_filled = TupleState::just_filled();
}
catch (const CheckCalls::ForbiddenCall &ex)
{
//.........这里部分代码省略.........
示例12: handle_python_attribute
static tree
handle_python_attribute(tree *node, tree name, tree args,
int flags, bool *no_add_attrs)
{
PyObject *callable;
/* Debug code: */
if (0) {
printf("handle_python_attribute called\n");
fprintf(stderr, "node: ");
debug_tree(*node); /* the site of the attribute e.g. a var_decl */
fprintf(stderr, "name: ");
debug_tree(name); /* an identifier_node e.g. "custom_attribute_without_args" */
fprintf(stderr, "args: ");
debug_tree(args); /* if present, a tree_list, e.g. of constants */
fprintf(stderr, "flags: %i\n", flags);
fprintf(stderr, "and here!\n");
}
/*
How do we get to the attribute?
This code:
const struct attribute_spec *spec = lookup_attribute_spec (name);
suggests that attributes must have unique names, so keep a dict mapping
strings to callables
*/
assert(IDENTIFIER_NODE == TREE_CODE(name));
callable = PyDict_GetItemString(attribute_dict, IDENTIFIER_POINTER(name));
assert(callable);
{
PyGILState_STATE gstate;
PyObject *py_args = NULL;
PyObject *result = NULL;
gstate = PyGILState_Ensure();
/*
The args to the function call will be the node, plus the args of the
attribute:
*/
py_args = make_args_for_attribute_callback(*node, args);
if (!py_args) {
goto cleanup;
}
result = PyObject_Call(callable, py_args, NULL);
if (!result) {
/* Treat an unhandled Python error as a compilation error: */
error("Unhandled Python exception raised within %s attribute handler",
IDENTIFIER_POINTER(name));
PyErr_PrintEx(1);
}
/* (the result is ignored) */
cleanup:
Py_XDECREF(py_args);
Py_XDECREF(result);
PyGILState_Release(gstate);
}
return NULL; // FIXME
}
示例13: PyErr_Format
//-------------------------------------------------------------------------------------
PyObject* ClientEntity::onScriptGetAttribute(PyObject* attr)
{
Entity* srcEntity = Cellapp::getSingleton().findEntity(srcEntityID_);
if(srcEntity == NULL)
{
PyErr_Format(PyExc_AssertionError, "Entity::clientEntity: srcEntityID(%d) not found!\n",
srcEntityID_);
PyErr_PrintEx(0);
return 0;
}
if(srcEntity->isDestroyed())
{
PyErr_Format(PyExc_AssertionError, "Entity::clientEntity: srcEntityID(%d) is destroyed!\n",
srcEntityID_);
PyErr_PrintEx(0);
return 0;
}
if(srcEntity->pWitness() == NULL)
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity: no client, srcEntityID(%d).\n",
srcEntity->getScriptName(), srcEntity->getID());
PyErr_PrintEx(0);
return 0;
}
EntityRef::AOI_ENTITIES::iterator iter = srcEntity->pWitness()->aoiEntities().begin();
Entity* e = NULL;
for(; iter != srcEntity->pWitness()->aoiEntities().end(); iter++)
{
if((*iter)->id() == clientEntityID_ && ((*iter)->flags() & ENTITYREF_FLAG_ENTER_CLIENT_PENDING) <= 0)
{
e = (*iter)->pEntity();
break;
}
}
if(e == NULL)
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity: not found entity(%d), srcEntityID(%d).\n",
srcEntity->getScriptName(), clientEntityID_, srcEntity->getID());
PyErr_PrintEx(0);
return 0;
}
wchar_t* PyUnicode_AsWideCharStringRet0 = PyUnicode_AsWideCharString(attr, NULL);
char* ccattr = strutil::wchar2char(PyUnicode_AsWideCharStringRet0);
PyMem_Free(PyUnicode_AsWideCharStringRet0);
MethodDescription* md = const_cast<ScriptDefModule*>(e->getScriptModule())->findClientMethodDescription(ccattr);
free(ccattr);
if(md != NULL)
{
return new ClientEntityMethod(md, srcEntityID_, clientEntityID_);
}
return ScriptObject::onScriptGetAttribute(attr);
}
示例14: PyErr_Format
//-------------------------------------------------------------------------------------
bool MethodDescription::checkArgs(PyObject* args)
{
if (args == NULL || !PyTuple_Check(args))
{
PyErr_Format(PyExc_AssertionError, "Method::checkArgs: method[%s] args is not a tuple.\n",
getName());
PyErr_PrintEx(0);
return false;
}
int offset = (isExposed() == true && g_componentType == CELLAPP_TYPE && isCell()) ? 1 : 0;
uint8 argsSize = argTypes_.size();
uint8 giveArgsSize = PyTuple_Size(args);
if (giveArgsSize != argsSize + offset)
{
PyErr_Format(PyExc_AssertionError, "Method::checkArgs: method[%s] requires exactly %d argument%s%s; %d given",
getName(),
argsSize,
(offset > 0) ? " + exposed(1)" : "",
(argsSize == 1) ? "" : "s",
PyTuple_Size(args));
PyErr_PrintEx(0);
return false;
}
// 检查是否是一个exposed方法
if(offset > 0)
{
PyObject* pyExposed = PyTuple_GetItem(args, 0);
if (!PyLong_Check(pyExposed))
{
PyObject* pyeid = PyObject_GetAttrString(pyExposed, "id");
if (pyeid == NULL || !PyLong_Check(pyeid))
{
Py_XDECREF(pyeid);
PyErr_Format( PyExc_TypeError,
"Method::checkArgs: method[%s] requires None, an id, or an object with an "
"id as its first agument", getName());
PyErr_PrintEx(0);
return false;
}
Py_DECREF(pyeid);
}
}
for(uint8 i=0; i <argsSize; i++)
{
PyObject* pyArg = PyTuple_GetItem(args, i + offset);
if (!argTypes_[i]->isSameType(pyArg))
{
PyObject* pExample = argTypes_[i]->parseDefaultStr("");
PyErr_Format(PyExc_AssertionError,
"Method::checkArgs: method[%s] argument %d: Expected %s, %s found",
getName(),
i+1,
pExample->ob_type->tp_name,
pyArg != NULL ? pyArg->ob_type->tp_name : "NULL");
PyErr_PrintEx(0);
Py_DECREF(pExample);
return false;
}
}
return true;
}
示例15: PyErr_Format
//-------------------------------------------------------------------------------------
PyObject* ClientEntityMethod::callmethod(PyObject* args, PyObject* kwds)
{
Entity* srcEntity = Cellapp::getSingleton().findEntity(srcEntityID_);
if(srcEntity == NULL)
{
PyErr_Format(PyExc_AssertionError, "Entity::clientEntity(%s): srcEntityID(%d) not found!\n",
methodDescription_->getName(), srcEntityID_);
PyErr_PrintEx(0);
return 0;
}
if(srcEntity->isDestroyed())
{
PyErr_Format(PyExc_AssertionError, "Entity::clientEntity(%s): srcEntityID(%d) is destroyed!\n",
methodDescription_->getName(), srcEntityID_);
PyErr_PrintEx(0);
return 0;
}
if(!srcEntity->isReal())
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity(%s): not is real entity, srcEntityID(%d).\n",
srcEntity->scriptName(), methodDescription_->getName(), srcEntity->id());
PyErr_PrintEx(0);
return 0;
}
if(srcEntity->pWitness() == NULL)
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity(%s): no client, srcEntityID(%d).\n",
srcEntity->scriptName(), methodDescription_->getName(), srcEntity->id());
PyErr_PrintEx(0);
return 0;
}
Network::Channel* pChannel = srcEntity->pWitness()->pChannel();
if(!pChannel)
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity(%s): no client, srcEntityID(%d).\n",
srcEntity->scriptName(), methodDescription_->getName(), srcEntity->id());
PyErr_PrintEx(0);
return 0;
}
EntityRef* pEntityRef = srcEntity->pWitness()->getAOIEntityRef(clientEntityID_);
Entity* e = (pEntityRef && ((pEntityRef->flags() & (ENTITYREF_FLAG_ENTER_CLIENT_PENDING | ENTITYREF_FLAG_LEAVE_CLIENT_PENDING)) <= 0))
? pEntityRef->pEntity() : NULL;
if(e == NULL)
{
PyErr_Format(PyExc_AssertionError, "%s::clientEntity(%s): not found entity(%d), srcEntityID(%d).\n",
srcEntity->scriptName(), methodDescription_->getName(), clientEntityID_, srcEntity->id());
PyErr_PrintEx(0);
return 0;
}
MethodDescription* methodDescription = getDescription();
if(methodDescription->checkArgs(args))
{
MemoryStream* mstream = MemoryStream::createPoolObject();
methodDescription->addToStream(mstream, args);
Network::Bundle* pSendBundle = pChannel->createSendBundle();
NETWORK_ENTITY_MESSAGE_FORWARD_CLIENT_START(srcEntity->id(), (*pSendBundle));
int ialiasID = -1;
const Network::MessageHandler& msgHandler =
srcEntity->pWitness()->getAOIEntityMessageHandler(ClientInterface::onRemoteMethodCall,
ClientInterface::onRemoteMethodCallOptimized, clientEntityID_, ialiasID);
ENTITY_MESSAGE_FORWARD_CLIENT_START(pSendBundle, msgHandler, aOIEntityMessage);
if(ialiasID != -1)
{
KBE_ASSERT(msgHandler.msgID == ClientInterface::onRemoteMethodCallOptimized.msgID);
(*pSendBundle) << (uint8)ialiasID;
}
else
{
KBE_ASSERT(msgHandler.msgID == ClientInterface::onRemoteMethodCall.msgID);
(*pSendBundle) << clientEntityID_;
}
if(mstream->wpos() > 0)
(*pSendBundle).append(mstream->data(), (int)mstream->wpos());
if(Network::g_trace_packet > 0)
{
if(Network::g_trace_packet_use_logfile)
DebugHelper::getSingleton().changeLogger("packetlogs");
DEBUG_MSG(fmt::format("ClientEntityMethod::callmethod: pushUpdateData: ClientInterface::onRemoteOtherEntityMethodCall({}::{})\n",
srcEntity->scriptName(), methodDescription->getName()));
switch(Network::g_trace_packet)
{
//.........这里部分代码省略.........