void cAllTerritories::check( P_CHAR pc ) { cUOSocket *socket = NULL; if( pc->objectType() == enPlayer ) socket = dynamic_cast<P_PLAYER>(pc)->socket(); cTerritory* currRegion = this->region( pc->pos().x, pc->pos().y, pc->pos().map ); cTerritory* lastRegion = pc->region(); if( !currRegion ) return; if (!lastRegion) { pc->setRegion(currRegion); return; } if (currRegion != lastRegion) { pc->setRegion(currRegion); if (socket) { // If the last region was a cave or if the new region is a cave, // update the lightlevel. if ((currRegion->isCave() && !lastRegion->isCave()) || (!currRegion->isCave() && lastRegion->isCave())) { socket->updateLightLevel(); } socket->playMusic(); } PyObject *args = Py_BuildValue("(NNN)", PyGetCharObject(pc), PyGetRegionObject(lastRegion), PyGetRegionObject(currRegion)); if (!cPythonScript::callChainedEventHandler(EVENT_CHANGEREGION, pc->getEvents(), args) && socket) { if (lastRegion && !lastRegion->name().isEmpty()) socket->sysMessage(tr("You have left %1.").arg(lastRegion->name())); if (currRegion && !currRegion->name().isEmpty()) socket->sysMessage(tr("You have entered %1.").arg(currRegion->name())); if( (currRegion->isGuarded() != lastRegion->isGuarded()) || (currRegion->isGuarded() && (currRegion->guardOwner() != lastRegion->guardOwner()))) { if (currRegion->isGuarded()) { if(currRegion->guardOwner().isEmpty()) socket->clilocMessage(500112); // You are now under the protection of the town guards else socket->sysMessage(currRegion->guardOwner()); } else { if(lastRegion->guardOwner().isEmpty()) socket->clilocMessage(500113); // You have left the protection of the town guards. else socket->sysMessage(lastRegion->guardOwner()); } } } Py_DECREF(args); } }
void cTempEffects::dispel( P_CHAR pc_dest, P_CHAR pSource, bool silent ) { if (cPythonScript::canChainHandleEvent(EVENT_DISPEL, pc_dest->getEvents())) { PyObject *source; if (pSource) { source = pSource->getPyObject(); } else { Py_INCREF(Py_None); source = Py_None; } PyObject *args = Py_BuildValue("(NNBBsN", pc_dest->getPyObject(), source, silent ? 1 : 0, 0, "", PyTuple_New(0)); bool result = cPythonScript::callChainedEventHandler(EVENT_DISPEL, pc_dest->getEvents(), args); Py_DECREF(args); if (result) { return; } } std::vector< cTempEffect* >::iterator i = teffects.begin(); for( i = teffects.begin(); i != teffects.end(); i++ ) if( (*i) != NULL && (*i)->dispellable && (*i)->getDest() == pc_dest->serial() ) { if( isCharSerial( (*i)->getDest() ) ) { P_CHAR pChar = FindCharBySerial( (*i)->getDest() ); if( pChar ) pChar->removeEffect( (*i) ); } (*i)->Dispel( pSource, silent ); teffects.erase( i ); } std::make_heap( teffects.begin(), teffects.end(), cTempEffects::ComparePredicate() ); }