static PyObject* wpElement_getAttr( wpElement* self, char* name ) { cElement* element = self->element; // \rproperty element.name A string containing the name of the element. if ( !strcmp( name, "name" ) ) { return PyString_FromString( element->name().data() ); } /* \rproperty element.parent An <object id="element">element</object> object for the parent of this element. If there is no parent this property is None. */ else if ( !strcmp( name, "parent" ) ) { if ( element->parent() ) { cElement* parent = const_cast<cElement*>( element->parent() ); return parent->getPyObject(); } else { Py_RETURN_NONE; } } /* \rproperty element.value The parsed value of this node. This converts hexadecimal numbers to decimal numers and computes random values. The result still is a unicode string. */ else if ( !strcmp( name, "value" ) ) { return QString2Python( element->value() ); } /* \rproperty element.text This is the text enclosed by this element. */ else if ( !strcmp( name, "text" ) ) { return QString2Python( element->text() ); } /* \rproperty element.childcount This is the number of children this element has. */ else if ( !strcmp( name, "childcount" ) ) { return PyInt_FromLong( self->element->childCount() ); } return Py_FindMethod( methods, ( PyObject * ) self, name ); }
/* \method dbresult.getstring \param position The position of the string value you want to get. \return A string value. \description Get a string value from the row at the given position. Please be careful with this function. If you specify an invalid position it can lead to a crash of your server. */ static PyObject* wpDbResult_getstring( wpDbResult* self, PyObject* args ) { unsigned int pos; if ( !PyArg_ParseTuple( args, "I:dbresult.getstring(position)", &pos ) ) { return 0; } QString value = self->result.value(pos).toString(); return QString2Python( value ); }
static PyObject* wpSpawnRegion_getAttr( wpSpawnRegion* self, char* name ) { /* \rproperty spawnregion.id The id of this region. */ if ( !strcmp( name, "id" ) ) { return QString2Python( self->pRegion->id() ); } /* \rproperty spawnregion.maxitems The maximum number of items spawned by this region. */ else if ( !strcmp( name, "maxitems" ) ) { return PyInt_FromLong( self->pRegion->maxItems() ); } /* \rproperty spawnregion.maxnpcs The maximum number of npcs spawned by this region. */ else if ( !strcmp( name, "maxnpcs" ) ) { return PyInt_FromLong( self->pRegion->maxNpcs() ); } /* \rproperty spawnregion.spawnednpcs The number of npcs currently spawned in this region. */ else if ( !strcmp( name, "spawnednpcs" ) ) { return PyInt_FromLong( self->pRegion->npcs() ); } /* \rproperty spawnregion.spawneditems The number of items currently spawned in this region. */ else if ( !strcmp( name, "spawneditems" ) ) { return PyInt_FromLong( self->pRegion->items() ); } /* \rproperty spawnregion.items A list of serials for the items currently spawned in this region. */ else if ( !strcmp( name, "items" ) ) { QList<cUObject*> objects = self->pRegion->spawnedItems(); PyObject* list = PyTuple_New( objects.count() ); cUObject *object; int offset = 0; foreach ( object, objects ) { PyTuple_SetItem( list, offset++, PyInt_FromLong( object->serial() ) ); }
/* \method packet.getunicode \param offset The byte offset within the packet. \param length The maximum length. \description This method gets an unicode string from the packet. */ static PyObject* wpPacket_getunicode( PyObject* self, PyObject* args ) { int pos; int length; if ( !PyArg_ParseTuple( args, "ii:wppacket.getunicode(position, length)", &pos, &length ) ) { return 0; } cUOPacket* packet = ( ( wpPacket* ) self )->packet; QString string = packet->getUnicodeString( pos, length ); return QString2Python( string ); }
// Getters & Setters static PyObject* wpSocket_getAttr( wpSocket* self, char* name ) { /* \rproperty socket.player The <object id="CHAR">char</object> object for the player played by this socket. May be None. */ if ( !strcmp( name, "player" ) ) return PyGetCharObject( self->pSock->player() ); /* \rproperty socket.screenwidth The width of the game window in pixels as sent by the client. */ else if ( !strcmp( name, "screenwidth" ) ) { return PyInt_FromLong( self->pSock->screenWidth() ); } /* \rproperty socket.screenheight The height of the game window in pixels as sent by the client. */ else if ( !strcmp( name, "screenheight" ) ) { return PyInt_FromLong( self->pSock->screenHeight() ); } else if ( !strcmp( name, "walksequence" ) ) { return PyInt_FromLong( self->pSock->walkSequence() ); } /* \rproperty socket.account An <object id="account">account</object> object for the account used by this socket. Should not be None. */ else if ( !strcmp( name, "account" ) ) { return PyGetAccountObject( self->pSock->account() ); } /* \rproperty socket.address A string containing the IP address this socket is connected to. */ else if ( !strcmp( name, "address" ) ) { return QString2Python( self->pSock->ip() ); } else { return Py_FindMethod( wpSocketMethods, ( PyObject * ) self, name ); } }
/* \method socket.gettag \description Get a custom tag attached to the socket. Please keep in mind these tags are temporary in nature. When the socket disconnects, the tag will be gone. \return None if there is no such tag, the tag value otherwise. Possible return types are: unicode (string), float, integer. \param name The name of the tag. */ static PyObject* wpSocket_gettag( wpSocket* self, PyObject* args ) { if ( PyTuple_Size( args ) < 1 || !checkArgStr( 0 ) ) { PyErr_BadArgument(); return NULL; } QString key = PyString_AsString( PyTuple_GetItem( args, 0 ) ); cVariant value = self->pSock->tags().get( key ); if ( value.type() == cVariant::StringType ) return QString2Python( value.toString() ); else if ( value.type() == cVariant::IntType ) return PyInt_FromLong( value.asInt() ); else if ( value.type() == cVariant::DoubleType ) return PyFloat_FromDouble( value.asDouble() ); Py_RETURN_NONE; }
/* \method element.getattribute \param name The name of the attribute. \param default The return value if the attribute doesn't exist. Defaults to an empty string. \return A unicode string containing the value of the attribute or the default value if the attribute doesn't exist. \description This method retrieves the string value of an attribute. */ static PyObject* wpElement_getattribute( wpElement* self, PyObject* args ) { char* name; char* value = 0; if ( !PyArg_ParseTuple( args, "s|es:element.getattribute(name, [default])", &name, "utf-8", &value ) ) { return 0; } QString defvalue = QString::null; if ( value != 0 ) { defvalue = QString::fromUtf8( value ); PyMem_Free( value ); } QString result = self->element->getAttribute( name, defvalue ); return QString2Python( result ); }
// Getters & Setters static PyObject* wpSocket_getAttr( wpSocket* self, char* name ) { /* \rproperty socket.player The <object id="CHAR">char</object> object for the player played by this socket. May be None. */ if ( !strcmp( name, "player" ) ) return PyGetCharObject( self->pSock->player() ); /* \rproperty socket.screenwidth The width of the game window in pixels as sent by the client. */ else if ( !strcmp( name, "screenwidth" ) ) { return PyInt_FromLong( self->pSock->screenWidth() ); } /* \rproperty socket.screenheight The height of the game window in pixels as sent by the client. */ else if ( !strcmp( name, "screenheight" ) ) { return PyInt_FromLong( self->pSock->screenHeight() ); } else if ( !strcmp( name, "walksequence" ) ) { return PyInt_FromLong( self->pSock->walkSequence() ); } /* \rproperty socket.account An <object id="account">account</object> object for the account used by this socket. Should not be None. */ else if ( !strcmp( name, "account" ) ) { return PyGetAccountObject( self->pSock->account() ); } /* \rproperty socket.address A string containing the IP address this socket is connected to. */ else if ( !strcmp( name, "address" ) ) { return QString2Python( self->pSock->ip() ); } /* \rproperty socket.id The unique socket identifier for this socket. */ else if ( !strcmp( name, "id" ) ) { return PyInt_FromLong( self->pSock->uniqueId() ); } /* \rproperty socket.version The client version string sent by the client. */ else if ( !strcmp( name, "version" ) ) { return QString2Python( self->pSock->version() ); } /* \rproperty socket.3dclient indicates that this is a 3d client. */ else if ( !strcmp( name, "3dclient" ) ) { if (self->pSock->is3dClient()) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; } } /* \rproperty socket.flags This is the bitfield sent by the client on character selection. Propable flags: <code>0x100 - 3d Client 0x10 - Samurai Empire 0x08 - Age of Shadows 0x04 - Lord Blackthornes Revenge 0x02 - Third Dawn 0x01 - Renaissance 0x00 - The Second Age</code> */ else if ( !strcmp( name, "flags" ) ) { return PyInt_FromLong(self->pSock->flags()); } /* \rproperty socket.rxbytes The number of bytes received by this socket. */ else if ( !strcmp( name, "rxbytes" ) ) { return PyInt_FromLong( self->pSock->rxBytes() ); } /* \rproperty socket.txbytes The number of bytes sent by this socket. */ else if ( !strcmp( name, "txbytes" ) ) { return PyInt_FromLong( self->pSock->txBytes() ); } /* \rproperty socket.txbytesraw The number of bytes sent by this socket before compression. */ else if ( !strcmp( name, "txbytesraw" ) ) { return PyInt_FromLong( self->pSock->txBytesRaw() ); } else { return Py_FindMethod( wpSocketMethods, ( PyObject * ) self, name ); } }
static PyObject* wpRegion_getAttr( wpRegion* self, char* name ) { /* \rproperty region.parent This property represents the parent region of this region. If there is no parent region this property contains None, otherwise another region object for the parent region. */ if ( !strcmp( name, "parent" ) ) { // Check if valid region cTerritory* pRegion = dynamic_cast<cTerritory*>( self->pRegion->parent() ); return PyGetRegionObject( pRegion ); } /* \rproperty region.children This property contains a tuple of region objects for the subregions within this region. */ else if ( !strcmp( name, "children" ) ) { QValueVector<cBaseRegion*> children = self->pRegion->children(); PyObject* tuple = PyTuple_New( children.size() ); for ( uint i = 0; i < children.size(); ++i ) { cTerritory* pRegion = dynamic_cast<cTerritory*>( children[i] ); PyTuple_SetItem( tuple, i, PyGetRegionObject( pRegion ) ); } return tuple; } /* \rproperty region.rectangles This property is a tuple of tuples containing x1, y1, x2 and y2 for the rectangles that define the area of this region. */ else if ( !strcmp( name, "rectangles" ) ) { QValueVector<cBaseRegion::rect_st> rectangles = self->pRegion->rectangles(); PyObject* tuple = PyTuple_New( rectangles.size() ); for ( uint i = 0; i < rectangles.size(); ++i ) { PyObject* subtuple = PyTuple_New( 4 ); PyTuple_SetItem( subtuple, 0, PyInt_FromLong( rectangles[i].x1 ) ); PyTuple_SetItem( subtuple, 1, PyInt_FromLong( rectangles[i].y1 ) ); PyTuple_SetItem( subtuple, 2, PyInt_FromLong( rectangles[i].x2 ) ); PyTuple_SetItem( subtuple, 3, PyInt_FromLong( rectangles[i].y2 ) ); PyTuple_SetItem( tuple, i, subtuple ); } return tuple; } /* \rproperty region.name The name of this region. */ else if ( !strcmp( name, "name" ) ) return QString2Python( self->pRegion->name() ); /* \rproperty region.midilist A list of midi sounds to be played for this region. */ else if ( !strcmp( name, "midilist" ) ) return QString2Python( self->pRegion->midilist() ); /* \rproperty region.guardowner The name of the guardowner for this region. */ else if ( !strcmp( name, "guardowner" ) ) return QString2Python( self->pRegion->guardOwner() ); // Flags /* \rproperty region.guarded This boolean flag indicates whether the region is guarded or not. */ else if ( !strcmp( name, "guarded" ) ) return PyInt_FromLong( self->pRegion->isGuarded() ? 1 : 0 ); /* \rproperty region.nomark This boolean flag indicates whether runes aren't markable in this region or not. */ else if ( !strcmp( name, "nomark" ) ) return PyInt_FromLong( self->pRegion->isNoMark() ? 1 : 0 ); /* \rproperty region.nogate This boolean flag indicates whether gates in or out of this region are allowed. */ else if ( !strcmp( name, "nogate" ) ) return PyInt_FromLong( self->pRegion->isNoGate() ? 1 : 0 ); /* \rproperty region.norecallout This boolean flag indicates whether recalling out of this region is allowed. */ else if ( !strcmp( name, "norecallout" ) ) return PyInt_FromLong( self->pRegion->isNoRecallOut() ? 1 : 0 ); /* \rproperty region.norecallin This boolean flag indicates whether recalling into this region is allowed. */ else if ( !strcmp( name, "norecallin" ) ) return PyInt_FromLong( self->pRegion->isNoRecallIn() ? 1 : 0 ); /* \rproperty region.noagressivemagic This boolean flag indicates whether agressive magic is forbidden in this region or not. */ else if ( !strcmp( name, "noagressivemagic" ) ) return PyInt_FromLong( self->pRegion->isNoAgressiveMagic() ? 1 : 0 ); /* \rproperty region.noagressivemagic This boolean flag indicates whether magic is forbidden in this region or not. */ else if ( !strcmp( name, "antimagic" ) ) return PyInt_FromLong( self->pRegion->isAntiMagic() ? 1 : 0 ); /* \rproperty region.cave This boolean flag indicates that this region is underground. */ else if ( !strcmp( name, "cave" ) ) return PyInt_FromLong( self->pRegion->isCave() ? 1 : 0 ); /* \rproperty region.nomusic This boolean flag indicates that no music should be played in this region. */ else if ( !strcmp( name, "nomusic" ) ) return PyInt_FromLong( self->pRegion->isNoMusic() ? 1 : 0 ); /* \rproperty region.noguardmessage This boolean flag indicates that no guard message should show when entering this region.. */ else if ( !strcmp( name, "noguardmessage" ) ) return PyInt_FromLong( self->pRegion->isNoGuardMessage() ? 1 : 0 ); /* \rproperty region.noentermessage This boolean flag indicates that no entrance message should show when entering this region. */ else if ( !strcmp( name, "noentermessage" ) ) return PyInt_FromLong( self->pRegion->isNoEnterMessage() ? 1 : 0 ); return Py_FindMethod( wpRegionMethods, ( PyObject * ) self, name ); }
static PyObject* wpRegion_str( wpRegion* self ) { return QString2Python( self->pRegion->name() ); }
static PyObject* wpAccount_str( wpAccount* self ) { return QString2Python( self->account->login() ); }
static PyObject *wpRegion_getAttr( wpRegion *self, char *name ) { if( !strcmp( name, "parent" ) ) { // Check if valid region cTerritory *pRegion = dynamic_cast< cTerritory* >( self->pRegion->parent() ); return PyGetRegionObject( pRegion ); } else if( !strcmp( name, "children" ) ) { QValueVector< cBaseRegion* > children = self->pRegion->children(); PyObject *tuple = PyTuple_New( children.size() ); for( uint i = 0; i < children.size(); ++i ) { cTerritory *pRegion = dynamic_cast< cTerritory* >( children[i] ); PyTuple_SetItem( tuple, i, PyGetRegionObject( pRegion ) ); } return tuple; } // Return a Tuple of Tuples else if( !strcmp( name, "rectangles" ) ) { QValueVector< cBaseRegion::rect_st > rectangles = self->pRegion->rectangles(); PyObject *tuple = PyTuple_New( rectangles.size() ); for( uint i = 0; i < rectangles.size(); ++i ) { PyObject *subtuple = PyTuple_New( 4 ); PyTuple_SetItem( subtuple, 0, PyInt_FromLong( rectangles[i].x1 ) ); PyTuple_SetItem( subtuple, 1, PyInt_FromLong( rectangles[i].y1 ) ); PyTuple_SetItem( subtuple, 2, PyInt_FromLong( rectangles[i].x2 ) ); PyTuple_SetItem( subtuple, 3, PyInt_FromLong( rectangles[i].y2 ) ); PyTuple_SetItem( tuple, i, subtuple ); } return tuple; } else if( !strcmp( name, "name" ) ) return QString2Python(self->pRegion->name()); else if( !strcmp( name, "midilist" ) ) return QString2Python(self->pRegion->midilist()); else if( !strcmp( name, "guardowner" ) ) return QString2Python(self->pRegion->guardOwner()); else if( !strcmp( name, "rainchance" ) ) return PyInt_FromLong( self->pRegion->rainChance() ); else if( !strcmp( name, "snowchance" ) ) return PyInt_FromLong( self->pRegion->snowChance() ); // Flags else if( !strcmp( name, "guarded" ) ) return PyInt_FromLong( self->pRegion->isGuarded() ? 1 : 0 ); else if( !strcmp( name, "nomark" ) ) return PyInt_FromLong( self->pRegion->isNoMark() ? 1 : 0 ); else if( !strcmp( name, "nogate" ) ) return PyInt_FromLong( self->pRegion->isNoGate() ? 1 : 0 ); else if( !strcmp( name, "norecallout" ) ) return PyInt_FromLong( self->pRegion->isNoRecallOut() ? 1 : 0 ); else if( !strcmp( name, "norecallin" ) ) return PyInt_FromLong( self->pRegion->isNoRecallIn() ? 1 : 0 ); else if( !strcmp( name, "recallshield" ) ) return PyInt_FromLong( self->pRegion->isRecallShield() ? 1 : 0 ); else if( !strcmp( name, "noagressivemagic" ) ) return PyInt_FromLong( self->pRegion->isNoAgressiveMagic() ? 1 : 0 ); else if( !strcmp( name, "antimagic" ) ) return PyInt_FromLong( self->pRegion->isAntiMagic() ? 1 : 0 ); else if( !strcmp( name, "validescortregion" ) ) return PyInt_FromLong( self->pRegion->isValidEscortRegion() ? 1 : 0 ); else if( !strcmp( name, "cave" ) ) return PyInt_FromLong( self->pRegion->isCave() ? 1 : 0 ); else if( !strcmp( name, "nomusic" ) ) return PyInt_FromLong( self->pRegion->isNoMusic() ? 1 : 0 ); return Py_FindMethod( wpRegionMethods, (PyObject*)self, name ); }
static PyObject* wpRegion_getAttr( wpRegion* self, char* name ) { /* \rproperty region.parent This property represents the parent region of this region. If there is no parent region this property contains None, otherwise another region object for the parent region. */ if ( !strcmp( name, "parent" ) ) { // Check if valid region cTerritory* pRegion = dynamic_cast<cTerritory*>( self->pRegion->parent() ); return PyGetRegionObject( pRegion ); } /* \rproperty region.children This property contains a tuple of region objects for the subregions within this region. */ else if ( !strcmp( name, "children" ) ) { QList<cBaseRegion*> children = self->pRegion->children(); PyObject* tuple = PyTuple_New( children.size() ); for ( int i = 0; i < children.size(); ++i ) { cTerritory* pRegion = dynamic_cast<cTerritory*>( children[i] ); PyTuple_SetItem( tuple, i, PyGetRegionObject( pRegion ) ); } return tuple; } /* \rproperty region.rectangles This property is a tuple of tuples containing x1, y1, x2 and y2 for the rectangles that define the area of this region. */ else if ( !strcmp( name, "rectangles" ) ) { QList<cBaseRegion::rect_st> rectangles = self->pRegion->rectangles(); PyObject* tuple = PyTuple_New( rectangles.size() ); for ( int i = 0; i < rectangles.size(); ++i ) { PyObject* subtuple = PyTuple_New( 4 ); PyTuple_SetItem( subtuple, 0, PyInt_FromLong( rectangles[i].x1 ) ); PyTuple_SetItem( subtuple, 1, PyInt_FromLong( rectangles[i].y1 ) ); PyTuple_SetItem( subtuple, 2, PyInt_FromLong( rectangles[i].x2 ) ); PyTuple_SetItem( subtuple, 3, PyInt_FromLong( rectangles[i].y2 ) ); PyTuple_SetItem( tuple, i, subtuple ); } return tuple; } /* \rproperty region.name The name of this region. */ else if ( !strcmp( name, "name" ) ) return QString2Python( self->pRegion->name() ); /* \rproperty region.resores The Definition of Ores of this Region. */ else if ( !strcmp( name, "resores" ) ) return QString2Python( self->pRegion->resores() ); /* \rproperty region.firstcoin The Definition of the First Coin for this Region (From New Monetary). */ else if ( !strcmp( name, "firstcoin" ) ) return QString2Python( self->pRegion->firstcoin() ); /* \rproperty region.secondcoin The Definition of the Second Coin for this Region (From New Monetary). */ else if ( !strcmp( name, "secondcoin" ) ) return QString2Python( self->pRegion->secondcoin() ); /* \rproperty region.thirdcoin The Definition of the Third Coin for this Region (From New Monetary). */ else if ( !strcmp( name, "thirdcoin" ) ) return QString2Python( self->pRegion->thirdcoin() ); /* \rproperty region.midilist A list of midi sounds to be played for this region. */ else if ( !strcmp( name, "midilist" ) ) return QString2Python( self->pRegion->midilist() ); /* \rproperty region.guardowner The name of the guardowner for this region. */ else if ( !strcmp( name, "guardowner" ) ) return QString2Python( self->pRegion->guardOwner() ); /* \rproperty region.fixedlight The Fixed LightLevel for this Region (Will return -1 to no fixed light level) */ else if ( !strcmp( name, "fixedlight" ) ) return PyInt_FromLong( self->pRegion->fixedlight() ); /* \rproperty region.lightmodifier The Modifier for LightLevel in this Region */ else if ( !strcmp( name, "lightmodifier" ) ) return PyInt_FromLong( self->pRegion->lightmodifier() ); // Flags /* \rproperty region.guarded This boolean flag indicates whether the region is guarded or not. */ else if ( !strcmp( name, "guarded" ) ) return PyInt_FromLong( self->pRegion->isGuarded() ? 1 : 0 ); /* \rproperty region.nomark This boolean flag indicates whether runes aren't markable in this region or not. */ else if ( !strcmp( name, "nomark" ) ) return PyInt_FromLong( self->pRegion->isNoMark() ? 1 : 0 ); /* \rproperty region.nogate This boolean flag indicates whether gates in or out of this region are allowed. */ else if ( !strcmp( name, "nogate" ) ) return PyInt_FromLong( self->pRegion->isNoGate() ? 1 : 0 ); /* \rproperty region.norecallout This boolean flag indicates whether recalling out of this region is allowed. */ else if ( !strcmp( name, "norecallout" ) ) return PyInt_FromLong( self->pRegion->isNoRecallOut() ? 1 : 0 ); /* \rproperty region.norecallin This boolean flag indicates whether recalling into this region is allowed. */ else if ( !strcmp( name, "norecallin" ) ) return PyInt_FromLong( self->pRegion->isNoRecallIn() ? 1 : 0 ); /* \rproperty region.noagressivemagic This boolean flag indicates whether agressive magic is forbidden in this region or not. */ else if ( !strcmp( name, "noagressivemagic" ) ) return PyInt_FromLong( self->pRegion->isNoAgressiveMagic() ? 1 : 0 ); /* \rproperty region.antimagic This boolean flag indicates whether magic is forbidden in this region or not. */ else if ( !strcmp( name, "antimagic" ) ) return PyInt_FromLong( self->pRegion->isAntiMagic() ? 1 : 0 ); /* \rproperty region.cave This boolean flag indicates that this region is underground. */ else if ( !strcmp( name, "cave" ) ) return PyInt_FromLong( self->pRegion->isCave() ? 1 : 0 ); /* \rproperty region.nodecay This boolean flag indicates that items do not decay in this region. */ else if ( !strcmp( name, "nodecay" ) ) return PyInt_FromLong( self->pRegion->isNoDecay() ? 1 : 0 ); /* \rproperty region.nomusic This boolean flag indicates that no music should be played in this region. */ else if ( !strcmp( name, "nomusic" ) ) return PyInt_FromLong( self->pRegion->isNoMusic() ? 1 : 0 ); /* \rproperty region.noguardmessage This boolean flag indicates that no guard message should show when entering this region.. */ else if ( !strcmp( name, "noguardmessage" ) ) return PyInt_FromLong( self->pRegion->isNoGuardMessage() ? 1 : 0 ); /* \rproperty region.noentermessage This boolean flag indicates that no entrance message should show when entering this region. */ else if ( !strcmp( name, "noentermessage" ) ) return PyInt_FromLong( self->pRegion->isNoEnterMessage() ? 1 : 0 ); /* \rproperty region.instalogout This boolean flag indicates if Region is a InstaLogout Region or not. */ else if ( !strcmp( name, "instalogout" ) ) return PyInt_FromLong( self->pRegion->isInstaLogout() ? 1 : 0 ); /* \rproperty region.noteleport This boolean flag indicates that no Teleport Magic is allowed in this place. */ else if ( !strcmp( name, "noteleport" ) ) return PyInt_FromLong( self->pRegion->isNoTeleport() ? 1 : 0 ); /* \rproperty region.safe This boolean flag indicates the Region is a Safe Region (no one can be harmed here). */ else if ( !strcmp( name, "safe" ) ) return PyInt_FromLong( self->pRegion->isSafe() ? 1 : 0 ); /* \rproperty region.nocriminalcombat This boolean flag indicates that attacks here against innocent targets, cant make attacker criminal. */ else if ( !strcmp( name, "nocriminalcombat" ) ) return PyInt_FromLong( self->pRegion->isNoCriminalCombat() ? 1 : 0 ); /* \rproperty region.nokillcount This boolean flag indicates that Kills are not counted on this area. */ else if ( !strcmp( name, "nokillcount" ) ) return PyInt_FromLong( self->pRegion->isNoKillCount() ? 1 : 0 ); /* \rproperty region.israining This boolean flag indicates that this Region is Raining or not. */ else if ( !strcmp( name, "israining" ) ) return PyInt_FromLong( self->pRegion->isRaining() ? 1 : 0); /* \rproperty region.issnowing This boolean flag indicates that this Region is Raining or not. */ else if ( !strcmp( name, "issnowing" ) ) return PyInt_FromLong( self->pRegion->isSnowing() ? 1 : 0); /* \rproperty region.rainchance The Rain Chance for that Region */ else if ( !strcmp( name, "rainchance" ) ) return PyInt_FromLong( self->pRegion->rainChance() ); /* \rproperty region.snowchance The Snow Chance for that Region */ else if ( !strcmp( name, "snowchance" ) ) return PyInt_FromLong( self->pRegion->snowChance() ); /* \rproperty region.weatherday The day for Next Weather Change */ else if ( !strcmp( name, "weatherday" ) ) return PyInt_FromLong( self->pRegion->weatherday() ); /* \rproperty region.weatherhour The hour for Next Weather Change */ else if ( !strcmp( name, "weatherhour" ) ) return PyInt_FromLong( self->pRegion->weatherhour() ); /* \rproperty region.rainduration The Default duration for Rain in this Region */ else if ( !strcmp( name, "rainduration" ) ) return PyInt_FromLong( self->pRegion->rainduration() ); /* \rproperty region.snowduration The Default duration for Snow in this Region */ else if ( !strcmp( name, "snowduration" ) ) return PyInt_FromLong( self->pRegion->snowduration() ); /* \rproperty region.dryduration The Default duration for Dry in this Region */ else if ( !strcmp( name, "dryduration" ) ) return PyInt_FromLong( self->pRegion->dryduration() ); /* \rproperty region.rainrangeduration The Default range for Rain duration in this Region */ else if ( !strcmp( name, "rainrangeduration" ) ) return PyInt_FromLong( self->pRegion->rainrangeduration() ); /* \rproperty region.snowrangeduration The Default range for Snow duration in this Region */ else if ( !strcmp( name, "snowrangeduration" ) ) return PyInt_FromLong( self->pRegion->snowrangeduration() ); /* \rproperty region.dryrangeduration The Default range for Dry duration in this Region */ else if ( !strcmp( name, "dryrangeduration" ) ) return PyInt_FromLong( self->pRegion->dryrangeduration() ); /* \rproperty region.maxintensity The Max Value for Weather Intensity in this Region */ else if ( !strcmp( name, "maxintensity" ) ) return PyInt_FromLong( self->pRegion->maxintensity() ); /* \rproperty region.minintensity The Min Value for Weather Intensity in this Region */ else if ( !strcmp( name, "minintensity" ) ) return PyInt_FromLong( self->pRegion->minintensity() ); /* \rproperty region.intensity The Actual Value for Weather Intensity in this Region */ else if ( !strcmp( name, "intensity" ) ) return PyInt_FromLong( self->pRegion->intensity() ); /* \rproperty region.extraflags The Extra Flags for this Region */ else if ( !strcmp( name, "extraflags" ) ) return PyInt_FromLong( self->pRegion->extraflags() ); return Py_FindMethod( wpRegionMethods, ( PyObject * ) self, name ); }
/* Log to the logfile only. */ void cLog::log( eLogLevel loglevel, cUOSocket* sock, const QString& string, bool timestamp ) { if ( !( Config::instance()->logMask() & loglevel ) ) { return; } // -> Log Event cPythonScript *globalHook = ScriptManager::instance()->getGlobalHook(EVENT_LOG); if (globalHook && globalHook->canHandleEvent(EVENT_LOG)) { PyObject *args = Py_BuildValue("(iNNO)", (unsigned int)loglevel, PyGetSocketObject(sock), QString2Python(string), Py_None ); bool result = globalHook->callEventHandler(EVENT_LOG, args); Py_DECREF(args); if (result) { return; } } if ( !checkLogFile() ) return; // Timestamp the data QTime now = QTime::currentTime(); QString prelude; if ( timestamp || loglevel == LOG_PYTHON ) { prelude.sprintf( "%02u:%02u:", now.hour(), now.minute() ); if ( sock ) prelude.append( QString( "%1:" ).arg( sock->uniqueId(), 0, 16 ) ); } // LogLevel switch ( loglevel ) { case LOG_ERROR: prelude.append( " ERROR: " ); break; case LOG_WARNING: prelude.append( " WARNING: " ); break; case LOG_PYTHON: prelude.append( " PYTHON: " ); break; default: prelude.append( " " ); } QByteArray utfdata = string.toUtf8(); utfdata.prepend( prelude.toUtf8() ); logfile.write( utfdata ); logfile.flush(); }