[wpdev-commits] wolfpack/python char.cpp,1.172,1.173 global.cpp,1.136,1.137
Brought to you by:
rip,
thiagocorrea
From: Sebastian H. <dar...@us...> - 2004-07-02 13:35:46
|
Update of /cvsroot/wpdev/wolfpack/python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30391/python Modified Files: char.cpp global.cpp Log Message: New documentation. Index: global.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/global.cpp,v retrieving revision 1.136 retrieving revision 1.137 diff -C2 -d -r1.136 -r1.137 *** global.cpp 2 Jul 2004 06:01:32 -0000 1.136 --- global.cpp 2 Jul 2004 13:35:36 -0000 1.137 *************** *** 127,131 **** /* \function wolfpack.console.log ! \param loglevel The loglevel for this message. See the ERROR_ constants in wolfpack/consts.py for details. \param text The text of the message. --- 127,131 ---- /* \function wolfpack.console.log ! \param loglevel The loglevel for this message. See the "Log Constants" in <module id="wolfpack.consts">wolfpack.consts</module> for details. \param text The text of the message. *************** *** 988,992 **** \function wolfpack.registerglobal \param event An integer constant for the event that should be hooked. ! Take a look at the EVENT constants in <module id="wolfpack.consts">wolfpack.consts</module> for details. \param script The name of a script that should be notified about the given event. \description This function registers a script as a global hook for one given event type. Whenever the --- 988,992 ---- \function wolfpack.registerglobal \param event An integer constant for the event that should be hooked. ! Take a look at the "Event Constants" in <module id="wolfpack.consts">wolfpack.consts</module> for details. \param script The name of a script that should be notified about the given event. \description This function registers a script as a global hook for one given event type. Whenever the *************** *** 1411,1421 **** \function wolfpack.queueaction \param action The action you want to queue. ! One of these constants in <module>wolfpack.consts</module>: ! <code>RELOAD_SCRIPTS ! RELOAD_PYTHON ! RELOAD_ACCOUNTS ! RELOAD_CONFIGURATION ! SAVE_WORLD ! SAVE_ACCOUNTS</code> \description This function queues an action to be executed in the next iteration of the mainloop. */ --- 1411,1415 ---- \function wolfpack.queueaction \param action The action you want to queue. ! Take a look at the "Action Constants" in the <module id="wolfpack.consts">wolfpack.consts</module> module. \description This function queues an action to be executed in the next iteration of the mainloop. */ *************** *** 1437,1441 **** \function wolfpack.getdefinition \param type The definition type. ! Use one of the WPDT constants from <module id="wolfpack.consts">wolfpack.consts</module>. \param id A string representing the id of the desired definition section. \return None if the section could not be found or an <object id="element">element</object> object otherwise. --- 1431,1435 ---- \function wolfpack.getdefinition \param type The definition type. ! Use one of the "Definition Constants" from <module id="wolfpack.consts">wolfpack.consts</module>. \param id A string representing the id of the desired definition section. \return None if the section could not be found or an <object id="element">element</object> object otherwise. *************** *** 1471,1475 **** \function wolfpack.getdefinitions \param type The definition type. ! Use one of the WPDT constants from <module id="wolfpack.consts">wolfpack.consts</module>. \return A tuple of strings. \description This function will compile the ids of all sections of a given type. --- 1465,1469 ---- \function wolfpack.getdefinitions \param type The definition type. ! Use one of the "Definition Constants" from <module id="wolfpack.consts">wolfpack.consts</module>. \return A tuple of strings. \description This function will compile the ids of all sections of a given type. *************** *** 1508,1512 **** \param script The id of the script containing the event. \param event The numeric constant for the event you want to call. ! See the EVENT constants in wolfpack.consts for details. \param args A tuple containing the arguments for the event handler. \return The return value from the event handler is passed trough. --- 1502,1506 ---- \param script The id of the script containing the event. \param event The numeric constant for the event you want to call. ! See the "Event Constants" in <module id="wolfpack.consts">wolfpack.consts</module> for details. \param args A tuple containing the arguments for the event handler. \return The return value from the event handler is passed trough. *************** *** 1547,1551 **** \param script The id of the script containing the event. \param event The numeric constant for the event you want to check for. ! See the EVENT constants in wolfpack.consts for details. \return True or false. \description This function checks if the given script can handle an event of the given type and returns true if it can. --- 1541,1545 ---- \param script The id of the script containing the event. \param event The numeric constant for the event you want to check for. ! See the "Event Constants" in <module id="wolfpack.consts">wolfpack.consts</module> for details. \return True or false. \description This function checks if the given script can handle an event of the given type and returns true if it can. *************** *** 1660,1665 **** --- 1654,1697 ---- } + /* + \function wolfpack.getoption + \param key The name of the option. + \param default The default value that is returned if the option does not exist. + \return A string with the value of the option. + \description This function retrieves an option from the world database. + */ + static PyObject* wpGetOption( PyObject* self, PyObject* args ) + { + Q_UNUSED(self); + QString arg_key = getArgStr(0); + QString arg_def = getArgStr(1); + QString value; + World::instance()->getOption(arg_key, value, arg_def); + return PyString_FromString(value); + } + + /* + \function wolfpack.setoption + \param key The name of the option. + \param value A string containing the value of the option. + \description This function sets a given option in the world database. + */ + static PyObject* wpSetOption( PyObject* self, PyObject* args ) + { + Q_UNUSED( self ); + + QString arg_key = getArgStr( 0 ); + QString arg_val = getArgStr( 1 ); + + World::instance()->setOption( arg_key, arg_val ); + + Py_INCREF(Py_None); + return Py_None; + } + static PyMethodDef wpGlobal[] = { + { "getOption", wpGetOption, METH_VARARGS, "Reads a string value from the database." }, + { "setOption", wpSetOption, METH_VARARGS, "Sets a string value and a key to the database." }, { "callevent", wpCallEvent, METH_VARARGS, "Call an event in a script and return the result." }, { "hasevent", wpHasEvent, METH_VARARGS, "If the given script has the given event. Return true." }, *************** *** 1714,1717 **** --- 1746,1755 ---- }; + /* + \function wolfpack.sockets.first + \return A <object id="socket">socket</object> object or None. + \description This function resets the iterator to the first available socket + and returns it. + */ static PyObject* wpSocketsFirst( PyObject* self, PyObject* args ) { *************** *** 1721,1724 **** --- 1759,1768 ---- } + /* + \function wolfpack.sockets.next + \return A <object id="socket">socket</object> object or None. + \description This function sets the iterator to the next available socket + and returns it. If there is no socket available, None is returned. + */ static PyObject* wpSocketsNext( PyObject* self, PyObject* args ) { *************** *** 1728,1733 **** } ! /*! ! Retrieves the number of currently connected sockets */ static PyObject* wpSocketsCount( PyObject* self, PyObject* args ) --- 1772,1779 ---- } ! /* ! \function wolfpack.sockets.count ! \return An integer value. ! \description This function returns how many sockets are connected. */ static PyObject* wpSocketsCount( PyObject* self, PyObject* args ) *************** *** 1751,1757 **** }; ! /*! ! Finds an Account object. ! */ static PyObject* wpAccountsFind( PyObject* self, PyObject* args ) { --- 1797,1807 ---- }; ! /* ! \function wolfpack.accounts.find ! \param name A string containing the account name. ! \return An <object id="account">account</object> object if an account was found. ! None otherwise. ! \description This function tries to find an account with the given name and returns it. ! */ static PyObject* wpAccountsFind( PyObject* self, PyObject* args ) { *************** *** 1767,1774 **** } ! /*! ! Gets a list of Account names. ! */ ! static PyObject* wpAccountsList( PyObject* self, PyObject* args ) { Q_UNUSED( self ); --- 1817,1826 ---- } ! /* ! \function wolfpack.accounts.list ! \return A list of strings. ! \description This function generates a list of all account names and returns it. ! */ ! satic PyObject* wpAccountsList( PyObject* self, PyObject* args ) { Q_UNUSED( self ); *************** *** 1788,1794 **** } ! /*! ! Gets a list of ACL names. ! */ static PyObject* wpAccountsAcls( PyObject* self, PyObject* args ) { --- 1840,1848 ---- } ! /* ! \function wolfpack.accounts.acls ! \return A list of strings. ! \description This function generates a list of the names of all available acls and returns it. ! */ static PyObject* wpAccountsAcls( PyObject* self, PyObject* args ) { *************** *** 1809,1815 **** } ! /*! ! Returns an ACL as a dictionary. ! */ static PyObject* wpAccountsAcl( PyObject* self, PyObject* args ) { --- 1863,1881 ---- } ! /* ! \function wolfpack.accounts.acl ! \param acl The name of the acl. ! \return None if no acl with the given name could be found. Otherwise a dictionary ! with information about the acl is returned. For each group in the acl it contains ! a key-value pair where the value is another dictionary containing the actions within the ! group. If for instance you want to check if the gm acl has access to any command, the following ! code should give you an idea: ! <code> ! allowed = 0 ! acl = wolfpack.accounts.acl('gm') ! if acl.has_key('command') and acl['command'].has_key('any'): ! allowed = acl['command']['any'].lower() == 'true'</code> ! \description Retrieve an access control list from the server. ! */ static PyObject* wpAccountsAcl( PyObject* self, PyObject* args ) { *************** *** 1844,1850 **** } ! /*! ! Creates an account (username + password is enough) ! */ static PyObject* wpAccountsAdd( PyObject* self, PyObject* args ) { --- 1910,1922 ---- } ! /* ! \function wolfpack.accounts.add ! \param username A string containing the username of the new account. ! \param password A string containing the password for the new account. ! If MD5 password hashing is enabled, this password will be automatically converted. ! \return None or an <object id="account">account</object> object. ! \description This function creates a new account and returns it. If the account couldn't be created, ! it returns None. ! */ static PyObject* wpAccountsAdd( PyObject* self, PyObject* args ) { *************** *** 1859,1877 **** QString password = getArgStr( 1 ); ! if ( login.length() < 1 && password.length() < 1 ) ! return PyFalse(); ! cAccount* account = Accounts::instance()->getRecord( login ); ! if ( account ) ! return PyFalse(); ! account = Accounts::instance()->createAccount( login, password ); ! return PyGetAccountObject( account ); } ! /*! ! Reload accounts. ! */ static PyObject* wpAccountsReload( PyObject* self, PyObject* args ) { --- 1931,1955 ---- QString password = getArgStr( 1 ); ! if (login.length() < 1 && password.length() < 1) { ! Py_INCREF(Py_None); ! return Py_None; ! } ! cAccount* account = Accounts::instance()->getRecord(login); ! if (account) { ! Py_INCREF(Py_None); ! return Py_None; ! } ! account = Accounts::instance()->createAccount(login, password); ! return PyGetAccountObject(account); } ! /* ! \function wolfpack.accounts.reload ! \description Reload the accounts in the next mainloop tick. This means ! that the accounts will not be reloaded instantly. ! */ static PyObject* wpAccountsReload( PyObject* self, PyObject* args ) { *************** *** 1882,1888 **** } ! /*! ! Save accounts. ! */ static PyObject* wpAccountsSave( PyObject* self, PyObject* args ) { --- 1960,1968 ---- } ! /* ! \function wolfpack.accounts.save ! \description Save the account database during the next mainloop iteration. ! That means that the accounts will not be saved instantly. ! */ static PyObject* wpAccountsSave( PyObject* self, PyObject* args ) { *************** *** 1910,1918 **** }; ! /*! ! Reads the boolean entry specified by key and group. ! The key is created if it doesn't exist, using the default argument. ! If an error occurs the settings are left unchanged and FALSE is returned; ! otherwise TRUE is returned */ static PyObject* wpSettingsGetBool( PyObject* self, PyObject* args ) --- 1990,2002 ---- }; ! /* ! \function wolfpack.settings.getbool ! \param group A string containing the name of the group the configuration option is in. ! \param key A string containing the name of the configuration option within the given group. ! \param default If the configuration option does not exist, this value is returned instead. ! \param create Defaults to false. If this is true and the option does not exist, the value given ! as the default value will be written to the configuration file. ! \return A boolean value. ! \description This function retrieves a value from the configuration file. */ static PyObject* wpSettingsGetBool( PyObject* self, PyObject* args ) *************** *** 1929,1937 **** } ! /*! ! Writes the boolean entry value into specified key and group. ! The key is created if it doesn't exist. Any previous value is overwritten by value. ! If an error occurs the settings are left unchanged and FALSE is returned; ! otherwise TRUE is returned */ static PyObject* wpSettingsSetBool( PyObject* self, PyObject* args ) --- 2013,2022 ---- } ! /* ! \function wolfpack.settings.setbool ! \param group A string containing the name of the group the configuration option is in. ! \param key A string containing the name of the configuration option within the given group. ! \param value The new value of the configuration option. ! \description This function changes or creates a new configuration option. */ static PyObject* wpSettingsSetBool( PyObject* self, PyObject* args ) *************** *** 1948,1957 **** } ! /*! ! Reads the numeric entry specified by key and group. ! The key is created if it doesn't exist using the default argument, provided ! that \a create argument is true. ! If an error occurs the settings are left unchanged and FALSE is returned; ! otherwise TRUE is returned */ static PyObject* wpSettingsGetNumber( PyObject* self, PyObject* args ) --- 2033,2045 ---- } ! /* ! \function wolfpack.settings.getnumber ! \param group A string containing the name of the group the configuration option is in. ! \param key A string containing the name of the configuration option within the given group. ! \param default If the configuration option does not exist, this value is returned instead. ! \param create Defaults to false. If this is true and the option does not exist, the value given ! as the default value will be written to the configuration file. ! \return An integer value. ! \description This function retrieves a value from the configuration file. */ static PyObject* wpSettingsGetNumber( PyObject* self, PyObject* args ) *************** *** 1968,1976 **** } ! /*! ! Writes the numeric entry value into specified key and group. ! The key is created if it doesn't exist. Any previous value is overwritten by value. ! If an error occurs the settings are left unchanged and FALSE is returned; ! otherwise TRUE is returned */ static PyObject* wpSettingsSetNumber( PyObject* self, PyObject* args ) --- 2056,2065 ---- } ! /* ! \function wolfpack.settings.setnumber ! \param group A string containing the name of the group the configuration option is in. ! \param key A string containing the name of the configuration option within the given group. ! \param value The new value of the configuration option. ! \description This function changes or creates a new configuration option. */ static PyObject* wpSettingsSetNumber( PyObject* self, PyObject* args ) *************** *** 1987,1997 **** } ! /*! ! getString( group, key, default, create ) ! Reads the string entry specified by key and group. ! The key is created if it doesn't exist using the default argument, provided that ! \a create argument is true. ! If an error occurs the settings are left unchanged and FALSE is returned; ! otherwise TRUE is returned */ static PyObject* wpSettingsGetString( PyObject* self, PyObject* args ) --- 2076,2088 ---- } ! /* ! \function wolfpack.settings.getstring ! \param group A string containing the name of the group the configuration option is in. ! \param key A string containing the name of the configuration option within the given group. ! \param default If the configuration option does not exist, this value is returned instead. ! \param create Defaults to false. If this is true and the option does not exist, the value given ! as the default value will be written to the configuration file. ! \return A string. ! \description This function retrieves a value from the configuration file. */ static PyObject* wpSettingsGetString( PyObject* self, PyObject* args ) *************** *** 2008,2016 **** } ! /*! ! Writes the string entry value into specified key and group. ! The key is created if it doesn't exist. Any previous value is overwritten by value. ! If an error occurs the settings are left unchanged and FALSE is returned; ! otherwise TRUE is returned */ static PyObject* wpSettingsSetString( PyObject* self, PyObject* args ) --- 2099,2108 ---- } ! /* ! \function wolfpack.settings.setstring ! \param group A string containing the name of the group the configuration option is in. ! \param key A string containing the name of the configuration option within the given group. ! \param value The new value of the configuration option. ! \description This function changes or creates a new configuration option. */ static PyObject* wpSettingsSetString( PyObject* self, PyObject* args ) *************** *** 2027,2032 **** } ! /*! ! Reloads wolfpack.xml */ static PyObject* wpSettingsReload( PyObject* self, PyObject* args ) --- 2119,2125 ---- } ! /* ! \function wolfpack.settings.reload ! \description This function reloads the settings file. */ static PyObject* wpSettingsReload( PyObject* self, PyObject* args ) *************** *** 2038,2043 **** } ! /*! ! Saves wolfpack.xml */ static PyObject* wpSettingsSave( PyObject* self, PyObject* args ) --- 2131,2137 ---- } ! /* ! \function wolfpack.settings.save ! \description This function saves the settings file to disk. */ static PyObject* wpSettingsSave( PyObject* self, PyObject* args ) *************** *** 2055,2064 **** static PyMethodDef wpSettings[] = { ! { "getBool", wpSettingsGetBool, METH_VARARGS, "Reads a boolean value from wolfpack.xml." }, ! { "setBool", wpSettingsSetBool, METH_VARARGS, "Sets a boolean value to wolfpack.xml." }, ! { "getNumber", wpSettingsGetNumber, METH_VARARGS, "Gets a numeric value from wolfpack.xml." }, ! { "setNumber", wpSettingsSetNumber, METH_VARARGS, "Sets a numeric value to wolfpack.xml." }, ! { "getString", wpSettingsGetString, METH_VARARGS, "Reads a string value from wolfpack.xml." }, ! { "setString", wpSettingsSetString, METH_VARARGS, "Writes a string value to wolfpack.xml." }, { "reload", wpSettingsReload, METH_NOARGS, "Reloads wolfpack.xml." }, { "save", wpSettingsSave, METH_NOARGS, "Saves changes made to wolfpack.xml" }, --- 2149,2158 ---- static PyMethodDef wpSettings[] = { ! { "getbool", wpSettingsGetBool, METH_VARARGS, "Reads a boolean value from wolfpack.xml." }, ! { "setbool", wpSettingsSetBool, METH_VARARGS, "Sets a boolean value to wolfpack.xml." }, ! { "getnumber", wpSettingsGetNumber, METH_VARARGS, "Gets a numeric value from wolfpack.xml." }, ! { "setnumber", wpSettingsSetNumber, METH_VARARGS, "Sets a numeric value to wolfpack.xml." }, ! { "getstring", wpSettingsGetString, METH_VARARGS, "Reads a string value from wolfpack.xml." }, ! { "setstring", wpSettingsSetString, METH_VARARGS, "Writes a string value to wolfpack.xml." }, { "reload", wpSettingsReload, METH_NOARGS, "Reloads wolfpack.xml." }, { "save", wpSettingsSave, METH_NOARGS, "Saves changes made to wolfpack.xml" }, *************** *** 2067,2108 **** }; ! static PyObject* wpOptionsGetOption( PyObject* self, PyObject* args ) ! { ! Q_UNUSED( self ); ! ! QString arg_key = getArgStr( 0 ); ! QString arg_def = getArgStr( 1 ); ! ! QString value; ! ! World::instance()->getOption( arg_key, value, arg_def ); ! ! return PyString_FromString( value ); ! } ! ! static PyObject* wpOptionsSetOption( PyObject* self, PyObject* args ) ! { ! Q_UNUSED( self ); ! ! QString arg_key = getArgStr( 0 ); ! QString arg_val = getArgStr( 1 ); ! ! World::instance()->setOption( arg_key, arg_val ); ! ! return PyTrue(); ! } ! ! /*! ! wolfpack.options ! config using the settings table */ - static PyMethodDef wpOptions[] = - { - { "getOption", wpOptionsGetOption, METH_VARARGS, "Reads a string value from the database." }, - { "setOption", wpOptionsSetOption, METH_VARARGS, "Sets a string value and a key to the database." }, - { NULL, NULL, 0, NULL } // Terminator - - }; - static PyObject* wpQuery( PyObject* self, PyObject* args ) { --- 2161,2170 ---- }; ! /* ! \function wolfpack.database.query ! \param query A string containing the SQL query for the database. ! \return A <object id="dbresult">dbresult</object> object. ! \description This function executes the given SQL query in the currently connected database and returns the result. */ static PyObject* wpQuery( PyObject* self, PyObject* args ) { *************** *** 2138,2141 **** --- 2200,2208 ---- } + /* + \function wolfpack.database.execute + \param query A string containing the SQL statement. + \description This function executes the given SQL query in the currently connected database and discards the result if there is any. + */ static PyObject* wpExecute( PyObject* self, PyObject* args ) { *************** *** 2165,2171 **** PyMem_Free( query ); ! return PyTrue(); } static PyObject* wpDriver( PyObject* self, PyObject* args ) { --- 2232,2246 ---- PyMem_Free( query ); ! ! Py_INCREF(Py_None); ! return Py_None; } + /* + \function wolfpack.database.driver + \param database The id of the database you want to query. See the "Database Constants" in this module. + \return A string. + \description This function returns the name of the database driver in use for the given database. + */ static PyObject* wpDriver( PyObject* self, PyObject* args ) { *************** *** 2187,2190 **** --- 2262,2270 ---- } + /* + \function wolfpack.database.close + \param database The id of the database you want to close. See the "Database Constants" in this module. + \description This function closes the connection to the given database. + */ static PyObject* wpClose( PyObject* self, PyObject* args ) { *************** *** 2203,2206 **** --- 2283,2291 ---- } + /* + \function wolfpack.database.open + \param database The id of the database you want to open. See the "Database Constants" in this module. + \description This function opens the connection to the given database. + */ static PyObject* wpOpen( PyObject* self, PyObject* args ) { Index: char.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/python/char.cpp,v retrieving revision 1.172 retrieving revision 1.173 diff -C2 -d -r1.172 -r1.173 *** char.cpp 1 Jul 2004 21:37:44 -0000 1.172 --- char.cpp 2 Jul 2004 13:35:36 -0000 1.173 *************** *** 400,405 **** \description Play an animation for the character. The animation id is automatically translated if the character is on a horse or ! if the current body id of the character doesn't support the animation. \param id The id of the animation that should be played. */ static PyObject* wpChar_action( wpChar* self, PyObject* args ) --- 400,406 ---- \description Play an animation for the character. The animation id is automatically translated if the character is on a horse or ! if the current body id of the character doesn't support the animation. \param id The id of the animation that should be played. + See the "Animation Constants" in <module id="wolfpack.consts">wolfpack.consts</module> for a list. */ static PyObject* wpChar_action( wpChar* self, PyObject* args ) *************** *** 2448,2452 **** /* ! \rproperty char.party A <object id="PARTY">PARTY</object> object for the party the player belongs to. None for NPCs or if the player is not in a party. This property is exclusive to python scripts and overrides normal properties with the same name. --- 2449,2453 ---- /* ! \rproperty char.party A <object id="party">party</object> object for the party the player belongs to. None for NPCs or if the player is not in a party. This property is exclusive to python scripts and overrides normal properties with the same name. *************** *** 2466,2470 **** /* ! \rproperty char.guild A <object id="GUILD">GUILD</object> object for the guild the player belongs to. None for NPCs or if the player is not in a guild. This property is exclusive to python scripts and overrides normal properties with the same name. --- 2467,2471 ---- /* ! \rproperty char.guild A <object id="guild">guild</object> object for the guild the player belongs to. None for NPCs or if the player is not in a guild. This property is exclusive to python scripts and overrides normal properties with the same name. |