Crossfire Server, Branches 1.12
R18729
|
Go to the source code of this file.
Data Structures | |
struct | CFConstant |
struct | pycode_cache_entry |
Macros | |
#define | PYTHON_CACHE_SIZE 16 /* number of python scripts to store the bytecode of at a time */ |
#define | PYTHON_DEBUG /* give us some general infos out */ |
Functions | |
static void | addConstants (PyObject *module, const char *name, const CFConstant *constants) |
static void | addSimpleConstants (PyObject *module, const char *name, const CFConstant *constants) |
CF_PLUGIN void * | cfpython_globalEventListener (int *type,...) |
CF_PLUGIN int | cfpython_runPluginCommand (object *op, char *params) |
CF_PLUGIN int | closePlugin (void) |
static PyCodeObject * | compilePython (char *filename) |
static PyObject * | createCFObject (PyObject *self, PyObject *args) |
static PyObject * | createCFObjectByName (PyObject *self, PyObject *args) |
static PyObject * | createMap (PyObject *self, PyObject *args) |
static PyObject * | destroyTimer (PyObject *self, PyObject *args) |
static int | do_script (CFPContext *context, int silent) |
CF_PLUGIN void * | eventListener (int *type,...) |
static PyObject * | findAnimation (PyObject *self, PyObject *args) |
static PyObject * | findFace (PyObject *self, PyObject *args) |
static PyObject * | findPlayer (PyObject *self, PyObject *args) |
static void | freeContext (CFPContext *context) |
static PyObject * | getArchetypes (PyObject *self, PyObject *args) |
static PyObject * | getCFPythonVersion (PyObject *self, PyObject *args) |
static PyObject * | getConfigDirectory (PyObject *self, PyObject *args) |
static PyObject * | getDataDirectory (PyObject *self, PyObject *args) |
static PyObject * | getEvent (PyObject *self, PyObject *args) |
static PyObject * | getFriendlyList (PyObject *self, PyObject *args) |
static PyObject * | getLocalDirectory (PyObject *self, PyObject *args) |
static PyObject * | getMapDirectory (PyObject *self, PyObject *args) |
static PyObject * | getMapHasBeenLoaded (PyObject *self, PyObject *args) |
static PyObject * | getMaps (PyObject *self, PyObject *args) |
static PyObject * | getMonthName (PyObject *self, PyObject *args) |
static PyObject * | getParties (PyObject *self, PyObject *args) |
static PyObject * | getPeriodofdayName (PyObject *self, PyObject *args) |
static PyObject * | getPlayerDirectory (PyObject *self, PyObject *args) |
static PyObject * | getPlayers (PyObject *self, PyObject *args) |
CF_PLUGIN void * | getPluginProperty (int *type,...) |
static PyObject * | getPrivateDictionary (PyObject *self, PyObject *args) |
static PyObject * | getRegions (PyObject *self, PyObject *args) |
static PyObject * | getReturnValue (PyObject *self, PyObject *args) |
static PyObject * | getScriptName (PyObject *self, PyObject *args) |
static PyObject * | getScriptParameters (PyObject *self, PyObject *args) |
static PyObject * | getSeasonName (PyObject *self, PyObject *args) |
static PyObject * | getSharedDictionary (PyObject *self, PyObject *args) |
static PyObject * | getTempDirectory (PyObject *self, PyObject *args) |
static PyObject * | getTime (PyObject *self, PyObject *args) |
static PyObject * | getUniqueDirectory (PyObject *self, PyObject *args) |
static PyObject * | getWeekdayName (PyObject *self, PyObject *args) |
static PyObject * | getWhatIsMessage (PyObject *self, PyObject *args) |
static PyObject * | getWhoAmI (PyObject *self, PyObject *args) |
static PyObject * | getWhoIsActivator (PyObject *self, PyObject *args) |
static PyObject * | getWhoIsThird (PyObject *self, PyObject *args) |
PyMODINIT_FUNC | initcjson (void) |
static void | initConstants (PyObject *module) |
static void | initContextStack (void) |
CF_PLUGIN int | initPlugin (const char *iversion, f_plug_api gethooksptr) |
static PyObject * | log_message (PyObject *self, PyObject *args) |
static PyObject * | matchString (PyObject *self, PyObject *args) |
static CFPContext * | popContext (void) |
CF_PLUGIN int | postInitPlugin (void) |
static void | pushContext (CFPContext *context) |
static PyObject * | readyMap (PyObject *self, PyObject *args) |
static PyObject * | registerCommand (PyObject *self, PyObject *args) |
static PyObject * | registerGEvent (PyObject *self, PyObject *args) |
static void | set_exception (const char *fmt,...) |
static PyObject * | setReturnValue (PyObject *self, PyObject *args) |
static PyObject * | unregisterGEvent (PyObject *self, PyObject *args) |
Variables | |
static PyObject * | CFPythonError |
static PyMethodDef | CFPythonMethods [] |
CFPContext * | context_stack |
static int | current_command = -999 |
CFPContext * | current_context |
static PythonCmd | CustomCommand [NR_CUSTOM_CMD] |
static PyObject * | private_data = NULL |
static pycode_cache_entry | pycode_cache [PYTHON_CACHE_SIZE] |
static PyObject * | shared_data = NULL |
#define PYTHON_CACHE_SIZE 16 /* number of python scripts to store the bytecode of at a time */ |
Definition at line 65 of file cfpython.c.
Referenced by compilePython().
#define PYTHON_DEBUG /* give us some general infos out */ |
Definition at line 64 of file cfpython.c.
|
static |
Definition at line 818 of file cfpython.c.
Referenced by initConstants().
|
static |
Do half the job of addConstants. It only Set constantc, but not a hashtable to get constant names from values. To be used for collections of constants which are not unique but still are usefull for scripts
Definition at line 852 of file cfpython.c.
Referenced by initConstants().
CF_PLUGIN void* cfpython_globalEventListener | ( | int * | type, |
... | |||
) |
Definition at line 1342 of file cfpython.c.
References _cfpcontext::activator, cf_get_maps_directory(), cf_log(), Crossfire_Map_wrap(), Crossfire_Object_wrap(), do_script(), _cfpcontext::event, EVENT_BORN, EVENT_CLOCK, _cfpcontext::event_code, EVENT_CRASH, EVENT_GKILL, EVENT_KICK, EVENT_LOGIN, EVENT_LOGOUT, EVENT_MAPENTER, EVENT_MAPLEAVE, EVENT_MAPLOAD, EVENT_MAPRESET, EVENT_MAPUNLOAD, EVENT_MUZZLE, EVENT_PLAYER_DEATH, EVENT_REMOVE, EVENT_SHOUT, EVENT_TELL, freeContext(), Handle_Map_Unload_Hook(), llevDebug, _cfpcontext::message, pl::ob, _cfpcontext::options, popContext(), _cfpcontext::returnvalue, _cfpcontext::script, snprintf(), _cfpcontext::third, and _cfpcontext::who.
Referenced by postInitPlugin(), and registerGEvent().
Definition at line 1269 of file cfpython.c.
References _cfpcontext::activator, cf_get_maps_directory(), cf_log(), Crossfire_Object_wrap(), current_command, do_script(), _cfpcontext::fix, freeContext(), llevError, _cfpcontext::message, _cfpcontext::options, popContext(), _cfpcontext::returnvalue, _cfpcontext::script, snprintf(), _cfpcontext::third, and _cfpcontext::who.
Referenced by getPluginProperty().
CF_PLUGIN int closePlugin | ( | void | ) |
Close the plugin.
Closes the sqlite database.
Definition at line 1546 of file cfpython.c.
References cf_log(), and llevDebug.
|
static |
Outputs the compiled bytecode for a given python file, using in-memory caching of bytecode
Definition at line 685 of file cfpython.c.
References pycode_cache_entry::cached_time, cf_add_string(), cf_free_string(), cf_log(), pycode_cache_entry::code, pycode_cache_entry::file, llevDebug, PYTHON_CACHE_SIZE, and replace().
Referenced by do_script().
|
static |
Definition at line 218 of file cfpython.c.
References cf_create_object(), and Crossfire_Object_wrap().
|
static |
Definition at line 226 of file cfpython.c.
References cf_create_object_by_name(), and Crossfire_Object_wrap().
|
static |
Definition at line 303 of file cfpython.c.
References cf_get_empty_map(), and Crossfire_Map_wrap().
|
static |
Definition at line 549 of file cfpython.c.
References cf_timer_destroy().
|
static |
Definition at line 777 of file cfpython.c.
References compilePython(), pushContext(), and _cfpcontext::script.
Referenced by cfpython_globalEventListener(), cfpython_runPluginCommand(), and eventListener().
CF_PLUGIN void* eventListener | ( | int * | type, |
... | |||
) |
Handles an object-related event. Doesn't do anything.
type | ignored. |
Definition at line 1504 of file cfpython.c.
References _cfpcontext::activator, cf_get_maps_directory(), Crossfire_Object_wrap(), do_script(), _cfpcontext::event, _cfpcontext::event_code, _cfpcontext::fix, freeContext(), _cfpcontext::message, obj::name, _cfpcontext::options, popContext(), _cfpcontext::returnvalue, _cfpcontext::script, obj::slaying, snprintf(), _cfpcontext::third, and _cfpcontext::who.
|
static |
Definition at line 609 of file cfpython.c.
References cf_find_animation().
|
static |
Definition at line 565 of file cfpython.c.
References cf_find_face().
|
static |
Definition at line 273 of file cfpython.c.
References cf_player_find(), Crossfire_Object_wrap(), and pl::ob.
|
static |
Definition at line 676 of file cfpython.c.
References _cfpcontext::activator, _cfpcontext::event, _cfpcontext::third, and _cfpcontext::who.
Referenced by cfpython_globalEventListener(), cfpython_runPluginCommand(), and eventListener().
|
static |
Definition at line 416 of file cfpython.c.
References cf_archetype_get_first(), cf_archetype_get_next(), and Crossfire_Archetype_wrap().
|
static |
Definition at line 238 of file cfpython.c.
|
static |
Definition at line 327 of file cfpython.c.
References cf_get_directory().
|
static |
Definition at line 339 of file cfpython.c.
References cf_get_directory().
|
static |
Definition at line 389 of file cfpython.c.
References _cfpcontext::event.
|
static |
Definition at line 481 of file cfpython.c.
References cf_friendlylist_get_first(), cf_friendlylist_get_next(), and Crossfire_Object_wrap().
|
static |
Definition at line 331 of file cfpython.c.
References cf_get_directory().
|
static |
Definition at line 315 of file cfpython.c.
References cf_get_directory().
|
static |
Definition at line 557 of file cfpython.c.
References cf_map_has_been_loaded(), and Crossfire_Map_wrap().
|
static |
Definition at line 442 of file cfpython.c.
References cf_map_get_first(), cf_map_get_map_property(), CFAPI_MAP_PROP_NEXT, and Crossfire_Map_wrap().
|
static |
Definition at line 625 of file cfpython.c.
References cf_get_month_name().
|
static |
Definition at line 455 of file cfpython.c.
References cf_party_get_first(), cf_party_get_next(), and Crossfire_Party_wrap().
|
static |
Definition at line 641 of file cfpython.c.
References cf_get_periodofday_name().
|
static |
Definition at line 335 of file cfpython.c.
References cf_get_directory().
|
static |
Definition at line 429 of file cfpython.c.
References cf_object_get_object_property(), CFAPI_PLAYER_PROP_NEXT, and Crossfire_Object_wrap().
CF_PLUGIN void* getPluginProperty | ( | int * | type, |
... | |||
) |
Gets a plugin property.
type | ignored. |
Definition at line 1224 of file cfpython.c.
References cfpython_runPluginCommand(), current_command, command_array_struct::func, command_array_struct::name, PythonCmdStruct::name, NR_CUSTOM_CMD, PLUGIN_NAME, PLUGIN_VERSION, snprintf(), and command_array_struct::time.
|
static |
Definition at line 398 of file cfpython.c.
References private_data, and _cfpcontext::script.
|
static |
Definition at line 468 of file cfpython.c.
References cf_region_get_first(), cf_region_get_next(), and Crossfire_Region_wrap().
|
static |
Definition at line 244 of file cfpython.c.
References _cfpcontext::returnvalue.
|
static |
Definition at line 377 of file cfpython.c.
References _cfpcontext::script.
|
static |
Definition at line 381 of file cfpython.c.
References _cfpcontext::options.
|
static |
Definition at line 617 of file cfpython.c.
References cf_get_season_name().
|
static |
Definition at line 411 of file cfpython.c.
References shared_data.
|
static |
Definition at line 323 of file cfpython.c.
References cf_get_directory().
|
static |
Definition at line 529 of file cfpython.c.
References cf_get_time(), _timeofday::day, _timeofday::dayofweek, _timeofday::hour, _timeofday::minute, _timeofday::month, _timeofday::periodofday, _timeofday::season, _timeofday::weekofmonth, and _timeofday::year.
|
static |
Definition at line 319 of file cfpython.c.
References cf_get_directory().
|
static |
Definition at line 633 of file cfpython.c.
References cf_get_weekday_name().
|
static |
Definition at line 370 of file cfpython.c.
References _cfpcontext::message.
|
static |
Definition at line 343 of file cfpython.c.
References _cfpcontext::who.
|
static |
Definition at line 352 of file cfpython.c.
References _cfpcontext::activator.
|
static |
Definition at line 361 of file cfpython.c.
References _cfpcontext::third.
PyMODINIT_FUNC initcjson | ( | void | ) |
Definition at line 1108 of file cjson.c.
References cjson_methods, JSON_DecodeError, JSON_EncodeError, JSON_Error, and MODULE_VERSION.
Referenced by initPlugin().
|
static |
Definition at line 873 of file cfpython.c.
References addConstants(), addSimpleConstants(), ALTAR, AMULET, ARMOUR, ARMOUR_IMPROVER, ARROW, AT_ACID, AT_BLIND, AT_CANCELLATION, AT_CHAOS, AT_COLD, AT_CONFUSION, AT_COUNTERSPELL, AT_DEATH, AT_DEPLETE, AT_DISEASE, AT_DRAIN, AT_ELECTRICITY, AT_FEAR, AT_FIRE, AT_GHOSTHIT, AT_GODPOWER, AT_HOLYWORD, AT_INTERNAL, AT_LIFE_STEALING, AT_MAGIC, AT_PARALYZE, AT_PHYSICAL, AT_POISON, AT_SLOW, AT_TURN_UNDEAD, AT_WEAPONMAGIC, ATNR_ACID, ATNR_BLIND, ATNR_CANCELLATION, ATNR_CHAOS, ATNR_COLD, ATNR_CONFUSION, ATNR_COUNTERSPELL, ATNR_DEATH, ATNR_DEPLETE, ATNR_DISEASE, ATNR_DRAIN, ATNR_ELECTRICITY, ATNR_FEAR, ATNR_FIRE, ATNR_GHOSTHIT, ATNR_GODPOWER, ATNR_HOLYWORD, ATNR_INTERNAL, ATNR_LIFE_STEALING, ATNR_MAGIC, ATNR_PARALYZE, ATNR_PHYSICAL, ATNR_POISON, ATNR_SLOW, ATNR_TURN_UNDEAD, ATNR_WEAPONMAGIC, BATTLEGROUND, BLINDNESS, BOOK, BOOTS, BOW, BRACERS, BUILDER, BUTTON, CF_HANDLE, CHECK_INV, CLASS, CLOAK, CLOCK, CLOSE_CON, CONTAINER, CONVERTER, CORPSE, CREATOR, DAYS_PER_WEEK, DEAD_OBJECT, DEEP_SWAMP, DETECTOR, DIRECTOR, DISEASE, DOOR, DRINK, DUPLICATOR, EARTHWALL, ENCOUNTER, EVENT_APPLY, EVENT_ATTACK, EVENT_BORN, EVENT_CLOCK, EVENT_CLOSE, EVENT_CONNECTOR, EVENT_CRASH, EVENT_DEATH, EVENT_DESTROY, EVENT_DROP, EVENT_GKILL, EVENT_KICK, EVENT_LOGIN, EVENT_LOGOUT, EVENT_MAPENTER, EVENT_MAPLEAVE, EVENT_MAPLOAD, EVENT_MAPRESET, EVENT_MAPUNLOAD, EVENT_MUZZLE, EVENT_PICKUP, EVENT_PLAYER_DEATH, EVENT_REMOVE, EVENT_SAY, EVENT_SHOUT, EVENT_STOP, EVENT_TELL, EVENT_THROW, EVENT_TIME, EVENT_TIMER, EVENT_TRIGGER, EVENT_USER, EXIT, EXPERIENCE, F_BUY, F_IDENTIFIED, F_NO_BARGAIN, F_NOT_CURSED, F_SELL, F_TRUE, FIREWALL, FLESH, FLOOR, FOOD, FORCE, GATE, GEM, GIRDLE, GLOVES, GOD, GOLEM, GRIMREAPER, HELMET, HOLE, HOLY_ALTAR, HORN, HOURS_PER_DAY, IDENTIFY_ALTAR, INORGANIC, KEY, LAMP, LIGHTER, LOCKED_DOOR, MAGIC_EAR, MAP, MARKER, MATERIAL, MISC_OBJECT, MONEY, MONSTER, MONTHS_PER_YEAR, MOOD_FLOOR, MOVE_ALL, MOVE_BOAT, MOVE_FLY_HIGH, MOVE_FLY_LOW, MOVE_FLYING, MOVE_SWIM, MOVE_WALK, NDI_ALL, NDI_BLACK, NDI_BLUE, NDI_BROWN, NDI_DK_ORANGE, NDI_GOLD, NDI_GREEN, NDI_GREY, NDI_LT_GREEN, NDI_NAVY, NDI_ORANGE, NDI_RED, NDI_TAN, NDI_UNIQUE, NDI_WHITE, PEACEMAKER, PEDESTAL, PERIODS_PER_DAY, PLAYER, PLAYER_CHANGER, PLAYERMOVER, POISON, POISONING, POTION, POTION_EFFECT, POWER_CRYSTAL, RING, ROD, RUNE, SAVEBED, SCROLL, SEASONS_PER_YEAR, SHIELD, SHOP_FLOOR, SHOP_INVENTORY, SHOP_MAT, SIGN, SKILL, SKILL_TOOL, SKILLSCROLL, SPECIAL_KEY, SPELL, SPELL_EFFECT, SPELLBOOK, SPINNER, SYMPTOM, TELEPORTER, THROWN_OBJ, TIMED_GATE, TRANSPORT, TRAP, TRAPDOOR, TREASURE, TRIGGER, TRIGGER_ALTAR, TRIGGER_BUTTON, TRIGGER_MARKER, TRIGGER_PEDESTAL, WALL, WAND, WEAPON, WEAPON_IMPROVER, and WEEKS_PER_MONTH.
Referenced by initPlugin().
|
static |
Definition at line 649 of file cfpython.c.
Referenced by postInitPlugin().
CF_PLUGIN int initPlugin | ( | const char * | iversion, |
f_plug_api | gethooksptr | ||
) |
Plugin initialisation function.
iversion | server version. |
gethooksptr | function to get the hooks. |
Main plugin entry point.
iversion | server version. |
gethooksptr | function to get hooks from. |
Definition at line 1159 of file cfpython.c.
References cf_init_plugin(), cf_log(), CFPythonError, CFPythonMethods, Crossfire_ArchetypeType, Crossfire_MapType, Crossfire_ObjectType, Crossfire_PartyType, Crossfire_PlayerType, Crossfire_RegionType, init_map_assoc_table(), init_object_assoc_table(), initcjson(), initConstants(), llevDebug, llevError, llevInfo, llevMonster, PythonCmdStruct::name, NR_CUSTOM_CMD, private_data, PythonCmdStruct::script, shared_data, and PythonCmdStruct::speed.
|
static |
Definition at line 573 of file cfpython.c.
References cf_log(), llevDebug, llevError, llevInfo, and llevMonster.
|
static |
Definition at line 258 of file cfpython.c.
References cf_re_cmp().
|
static |
Definition at line 664 of file cfpython.c.
References current_context, and _cfpcontext::down.
Referenced by cfpython_globalEventListener(), cfpython_runPluginCommand(), and eventListener().
CF_PLUGIN int postInitPlugin | ( | void | ) |
Plugin was initialized, now to finish.
Registers events, initializes the database.
Definition at line 1309 of file cfpython.c.
References cf_get_maps_directory(), cf_log(), cf_system_register_global_event(), cfpython_globalEventListener(), EVENT_BORN, EVENT_CLOCK, EVENT_GKILL, EVENT_KICK, EVENT_LOGIN, EVENT_LOGOUT, EVENT_MAPENTER, EVENT_MAPLEAVE, EVENT_MAPLOAD, EVENT_MAPRESET, EVENT_MAPUNLOAD, EVENT_MUZZLE, EVENT_PLAYER_DEATH, EVENT_REMOVE, EVENT_SHOUT, EVENT_TELL, initContextStack(), llevDebug, and PLUGIN_NAME.
|
static |
Definition at line 654 of file cfpython.c.
References current_context, and _cfpcontext::down.
Referenced by do_script().
|
static |
Definition at line 290 of file cfpython.c.
References cf_map_get_map(), Crossfire_Map_wrap(), and flags.
|
static |
Definition at line 494 of file cfpython.c.
References cf_strdup_local(), PythonCmdStruct::name, NR_CUSTOM_CMD, PythonCmdStruct::script, set_exception(), and PythonCmdStruct::speed.
|
static |
Definition at line 194 of file cfpython.c.
References cf_system_register_global_event(), cfpython_globalEventListener(), and PLUGIN_NAME.
|
static |
Set up an Python exception object.
Definition at line 125 of file cfpython.c.
References vsnprintf.
Referenced by registerCommand().
|
static |
Definition at line 248 of file cfpython.c.
References _cfpcontext::returnvalue.
|
static |
Definition at line 206 of file cfpython.c.
References cf_system_unregister_global_event(), EVENT_TELL, and PLUGIN_NAME.
|
static |
Definition at line 112 of file cfpython.c.
Referenced by initPlugin().
|
static |
Definition at line 136 of file cfpython.c.
Referenced by initPlugin().
CFPContext* context_stack |
Definition at line 184 of file cfpython.c.
|
static |
Definition at line 188 of file cfpython.c.
Referenced by cfpython_runPluginCommand(), and getPluginProperty().
CFPContext* current_context |
Definition at line 186 of file cfpython.c.
Referenced by Crossfire_Object_Remove(), popContext(), and pushContext().
|
static |
Definition at line 73 of file cfpython.c.
|
static |
Definition at line 192 of file cfpython.c.
Referenced by getPrivateDictionary(), and initPlugin().
|
static |
Definition at line 75 of file cfpython.c.
|
static |
Definition at line 190 of file cfpython.c.
Referenced by getSharedDictionary(), and initPlugin().