Crossfire Server, Trunk  R20513
Data Structures | Macros | Typedefs | Functions | Variables
cfpython.c File Reference
#include <cfpython.h>
#include <stdarg.h>
#include <node.h>
#include <svnversion.h>
Include dependency graph for cfpython.c:

Go to the source code of this file.

Data Structures

struct  CFConstant
 
struct  pycode_cache_entry
 One compiled script, cached in memory. More...
 
struct  PythonCmdStruct
 

Macros

#define NR_CUSTOM_CMD   1024
 
#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 */
 

Typedefs

typedef struct PythonCmdStruct PythonCmd
 

Functions

static void addConstants (PyObject *module, const char *name, const CFConstant *constants)
 
static PyObject * addReply (PyObject *self, PyObject *args)
 
static void addSimpleConstants (PyObject *module, const char *name, const CFConstant *constants)
 Do half the job of addConstants. More...
 
CF_PLUGIN int cfpython_globalEventListener (int *type,...)
 
static void cfpython_init_types (PyObject *m)
 Set up the various types (map, object, archetype and so on) as well as some constants, and Crossfire.error. More...
 
static PyObject * cfpython_openpyfile (char *filename)
 Open a file in the way we need it for compilePython() and postInitPlugin(). More...
 
static FILE * cfpython_pyfile_asfile (PyObject *obj)
 Return a file object from a Python file (as needed for compilePython() and postInitPlugin()) More...
 
CF_PLUGIN void cfpython_runPluginCommand (object *op, const char *params)
 
CF_PLUGIN int closePlugin (void)
 Close the plugin. More...
 
static PyCodeObject * compilePython (char *filename)
 Outputs the compiled bytecode for a given python file, using in-memory caching of bytecode. More...
 
static PyObject * costStringFromValue (PyObject *self, PyObject *args)
 
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 int eventListener (int *type,...)
 Handles an object-related event. More...
 
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,...)
 Gets a plugin property. More...
 
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)
 Plugin initialisation function. More...
 
static PyObject * log_message (PyObject *self, PyObject *args)
 
static void log_python_error (void)
 Trace a Python error to the Crossfire log. More...
 
static PyObject * matchString (PyObject *self, PyObject *args)
 
static PyObject * npcSay (PyObject *self, PyObject *args)
 
static CFPContextpopContext (void)
 
CF_PLUGIN int postInitPlugin (void)
 Plugin was initialized, now to finish. More...
 
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,...)
 Set up an Python exception object. More...
 
static PyObject * setPlayerMessage (PyObject *self, PyObject *args)
 
static PyObject * setReturnValue (PyObject *self, PyObject *args)
 
static PyObject * unregisterGEvent (PyObject *self, PyObject *args)
 

Variables

static PyObject * catcher = NULL
 A Python object receiving the contents of Python's stderr, and used to output to the Crossfire log instead of stderr. More...
 
static PyObject * CFPythonError
 
static PyMethodDef CFPythonMethods []
 
CFPContextcontext_stack
 
static int current_command = -999
 
CFPContextcurrent_context
 
static PythonCmd CustomCommand [NR_CUSTOM_CMD]
 Commands defined by scripts. More...
 
static PyObject * private_data = NULL
 
static pycode_cache_entry pycode_cache [PYTHON_CACHE_SIZE]
 Cached compiled scripts. More...
 
static PyObject * shared_data = NULL
 
CF_PLUGIN char SvnRevPlugin [] = SVN_REV
 

Macro Definition Documentation

#define NR_CUSTOM_CMD   1024

Definition at line 88 of file cfpython.c.

Referenced by closePlugin(), getPluginProperty(), initPlugin(), and registerCommand().

#define PYTHON_CACHE_SIZE   16 /* number of python scripts to store the bytecode of at a time */

Definition at line 68 of file cfpython.c.

Referenced by closePlugin(), compilePython(), and postInitPlugin().

#define PYTHON_DEBUG   /* give us some general infos out */

Definition at line 67 of file cfpython.c.

Typedef Documentation

typedef struct PythonCmdStruct PythonCmd

Function Documentation

static void addConstants ( PyObject *  module,
const char *  name,
const CFConstant constants 
)
static

Definition at line 947 of file cfpython.c.

References snprintf.

Referenced by initConstants().

Here is the caller graph for this function:

static PyObject* addReply ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 575 of file cfpython.c.

References cf_add_string(), MAX_REPLIES, talk_info::replies, talk_info::replies_count, talk_info::replies_words, set_exception(), and _cfpcontext::talk.

Here is the call graph for this function:

static void addSimpleConstants ( PyObject *  module,
const char *  name,
const CFConstant constants 
)
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 979 of file cfpython.c.

References snprintf.

Referenced by initConstants().

Here is the caller graph for this function:

CF_PLUGIN int cfpython_globalEventListener ( int *  type,
  ... 
)
static void cfpython_init_types ( PyObject *  m)
static

Set up the various types (map, object, archetype and so on) as well as some constants, and Crossfire.error.

Definition at line 1306 of file cfpython.c.

References CFPythonError, CFPythonMethods, Crossfire_ArchetypeType, Crossfire_MapType, Crossfire_ObjectType, Crossfire_PartyType, Crossfire_PlayerType, Crossfire_RegionType, initcjson(), llevDebug, llevError, llevInfo, and llevMonster.

Referenced by initPlugin().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* cfpython_openpyfile ( char *  filename)
static

Open a file in the way we need it for compilePython() and postInitPlugin().

Definition at line 755 of file cfpython.c.

Referenced by compilePython(), and postInitPlugin().

Here is the caller graph for this function:

static FILE* cfpython_pyfile_asfile ( PyObject *  obj)
static

Return a file object from a Python file (as needed for compilePython() and postInitPlugin())

Definition at line 777 of file cfpython.c.

Referenced by compilePython(), and postInitPlugin().

Here is the caller graph for this function:

CF_PLUGIN void cfpython_runPluginCommand ( object op,
const char *  params 
)
CF_PLUGIN int closePlugin ( void  )

Close the plugin.

Closes the sqlite database.

Returns
0.

Definition at line 1762 of file cfpython.c.

References cf_free_string(), cf_log(), llevDebug, PythonCmdStruct::name, NR_CUSTOM_CMD, PYTHON_CACHE_SIZE, and PythonCmdStruct::script.

Here is the call graph for this function:

static PyCodeObject* compilePython ( char *  filename)
static

Outputs the compiled bytecode for a given python file, using in-memory caching of bytecode.

Definition at line 817 of file cfpython.c.

References pycode_cache_entry::cached_time, cf_add_string(), cf_free_string(), cf_log(), cfpython_openpyfile(), cfpython_pyfile_asfile(), pycode_cache_entry::code, pycode_cache_entry::file, llevDebug, log_python_error(), PYTHON_CACHE_SIZE, and replace().

Referenced by do_script().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* costStringFromValue ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 653 of file cfpython.c.

References cf_cost_string_from_value().

Here is the call graph for this function:

static PyObject* createCFObject ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 144 of file cfpython.c.

References cf_create_object(), and Crossfire_Object_wrap().

Here is the call graph for this function:

static PyObject* createCFObjectByName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 152 of file cfpython.c.

References cf_create_object_by_name(), and Crossfire_Object_wrap().

Here is the call graph for this function:

static PyObject* createMap ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 229 of file cfpython.c.

References cf_get_empty_map(), and Crossfire_Map_wrap().

Here is the call graph for this function:

static PyObject* destroyTimer ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 475 of file cfpython.c.

References cf_timer_destroy().

Here is the call graph for this function:

static int do_script ( CFPContext context,
int  silent 
)
static

Definition at line 906 of file cfpython.c.

References compilePython(), log_python_error(), pushContext(), and _cfpcontext::script.

Referenced by cfpython_globalEventListener(), cfpython_runPluginCommand(), and eventListener().

Here is the call graph for this function:

Here is the caller graph for this function:

CF_PLUGIN int eventListener ( int *  type,
  ... 
)

Handles an object-related event.

Doesn't do anything.

Parameters
typeignored.
Returns
0.
Todo:
build from current map's path, probably

Definition at line 1721 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::talk, _cfpcontext::third, and _cfpcontext::who.

Here is the call graph for this function:

static PyObject* findAnimation ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 535 of file cfpython.c.

References cf_find_animation(), and PythonCmdStruct::name.

Here is the call graph for this function:

static PyObject* findFace ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 491 of file cfpython.c.

References cf_find_face(), and PythonCmdStruct::name.

Here is the call graph for this function:

static PyObject* findPlayer ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 199 of file cfpython.c.

References cf_player_find(), Crossfire_Object_wrap(), and pl::ob.

Here is the call graph for this function:

static void freeContext ( CFPContext context)
static

Definition at line 744 of file cfpython.c.

References _cfpcontext::activator, _cfpcontext::event, _cfpcontext::third, and _cfpcontext::who.

Referenced by cfpython_globalEventListener(), cfpython_runPluginCommand(), and eventListener().

Here is the caller graph for this function:

static PyObject* getArchetypes ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 342 of file cfpython.c.

References cf_archetype_get_first(), cf_archetype_get_next(), and Crossfire_Archetype_wrap().

Here is the call graph for this function:

static PyObject* getCFPythonVersion ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 164 of file cfpython.c.

static PyObject* getConfigDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 253 of file cfpython.c.

References cf_get_directory().

Here is the call graph for this function:

static PyObject* getDataDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 265 of file cfpython.c.

References cf_get_directory().

Here is the call graph for this function:

static PyObject* getEvent ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 315 of file cfpython.c.

References _cfpcontext::event.

static PyObject* getFriendlyList ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 407 of file cfpython.c.

References cf_friendlylist_get_first(), cf_friendlylist_get_next(), and Crossfire_Object_wrap().

Here is the call graph for this function:

static PyObject* getLocalDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 257 of file cfpython.c.

References cf_get_directory().

Here is the call graph for this function:

static PyObject* getMapDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 241 of file cfpython.c.

References cf_get_directory().

Here is the call graph for this function:

static PyObject* getMapHasBeenLoaded ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 483 of file cfpython.c.

References cf_map_has_been_loaded(), Crossfire_Map_wrap(), and PythonCmdStruct::name.

Here is the call graph for this function:

static PyObject* getMaps ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 368 of file cfpython.c.

References cf_map_get_first(), cf_map_get_map_property(), CFAPI_MAP_PROP_NEXT, and Crossfire_Map_wrap().

Here is the call graph for this function:

static PyObject* getMonthName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 551 of file cfpython.c.

References cf_get_month_name().

Here is the call graph for this function:

static PyObject* getParties ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 381 of file cfpython.c.

References cf_party_get_first(), cf_party_get_next(), and Crossfire_Party_wrap().

Here is the call graph for this function:

static PyObject* getPeriodofdayName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 567 of file cfpython.c.

References cf_get_periodofday_name().

Here is the call graph for this function:

static PyObject* getPlayerDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 261 of file cfpython.c.

References cf_get_directory().

Here is the call graph for this function:

static PyObject* getPlayers ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 355 of file cfpython.c.

References cf_object_get_object_property(), CFAPI_PLAYER_PROP_NEXT, and Crossfire_Object_wrap().

Here is the call graph for this function:

CF_PLUGIN void* getPluginProperty ( int *  type,
  ... 
)

Gets a plugin property.

Parameters
typeignored.
Returns
  • the name, if asked for 'Identification'.
  • the version, if asked for 'FullName'.
  • NULL else.

Definition at line 1435 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, PythonCmdStruct::speed, and command_array_struct::time.

Here is the call graph for this function:

static PyObject* getPrivateDictionary ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 324 of file cfpython.c.

References private_data, and _cfpcontext::script.

static PyObject* getRegions ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 394 of file cfpython.c.

References cf_region_get_first(), cf_region_get_next(), and Crossfire_Region_wrap().

Here is the call graph for this function:

static PyObject* getReturnValue ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 170 of file cfpython.c.

References _cfpcontext::returnvalue.

static PyObject* getScriptName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 303 of file cfpython.c.

References _cfpcontext::script.

static PyObject* getScriptParameters ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 307 of file cfpython.c.

References _cfpcontext::options.

static PyObject* getSeasonName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 543 of file cfpython.c.

References cf_get_season_name().

Here is the call graph for this function:

static PyObject* getSharedDictionary ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 337 of file cfpython.c.

References shared_data.

static PyObject* getTempDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 249 of file cfpython.c.

References cf_get_directory().

Here is the call graph for this function:

static PyObject* getTime ( PyObject *  self,
PyObject *  args 
)
static
static PyObject* getUniqueDirectory ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 245 of file cfpython.c.

References cf_get_directory().

Here is the call graph for this function:

static PyObject* getWeekdayName ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 559 of file cfpython.c.

References cf_get_weekday_name().

Here is the call graph for this function:

static PyObject* getWhatIsMessage ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 296 of file cfpython.c.

References _cfpcontext::message.

static PyObject* getWhoAmI ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 269 of file cfpython.c.

References _cfpcontext::who.

static PyObject* getWhoIsActivator ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 278 of file cfpython.c.

References _cfpcontext::activator.

static PyObject* getWhoIsThird ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 287 of file cfpython.c.

References _cfpcontext::third.

PyMODINIT_FUNC initcjson ( void  )

Definition at line 1389 of file cjson.c.

References cjson_methods, and initcjson_shared().

Referenced by cfpython_init_types(), and initPlugin().

Here is the call graph for this function:

Here is the caller graph for this function:

static void initConstants ( PyObject *  module)
static

Definition at line 995 of file cfpython.c.

References addConstants(), addSimpleConstants(), ALLRUN, 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, CIRCLE1, CIRCLE2, CLASS, CLOAK, CLOCK, CLOSE_CON, CONTAINER, CONVERTER, CORPSE, CREATOR, DAYS_PER_WEEK, DEAD_OBJECT, DEEP_SWAMP, DETECTOR, DIRECTOR, DISEASE, DISTATT, DISTHIT, DOOR, DRINK, DUPLICATOR, EARTHWALL, ENCOUNTER, EVENT_APPLY, EVENT_ATTACKED, EVENT_ATTACKS, 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, FIREWALL, FLESH, FLOOR, FOOD, FORCE, GATE, GEM, GIRDLE, GLOVES, GOD, GOLEM, GRIMREAPER, HELMET, HITRUN, HOLE, HOLY_ALTAR, 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_ALL_DMS, 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, PACEH, PACEH2, PACEV, PACEV2, PEACEMAKER, PEDESTAL, PERIODS_PER_DAY, PETMOVE, PLAYER, PLAYER_CHANGER, PLAYERMOVER, POISON, POISONING, POTION, POTION_RESIST_EFFECT, POWER_CRYSTAL, RANDO, RANDO2, RING, ROD, rt_question, rt_reply, rt_say, RUNATT, RUNE, RUSH, 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, WAIT2, WAITATT, WALL, WAND, WEAPON, WEAPON_IMPROVER, and WEEKS_PER_MONTH.

Referenced by initPlugin().

Here is the call graph for this function:

Here is the caller graph for this function:

static void initContextStack ( void  )
static

Definition at line 717 of file cfpython.c.

Referenced by postInitPlugin().

Here is the caller graph for this function:

CF_PLUGIN int initPlugin ( const char *  iversion,
f_plug_api  gethooksptr 
)

Plugin initialisation function.

Parameters
iversionserver version.
gethooksptrfunction to get the hooks.
Returns
0

Plugin initialisation function.

Parameters
iversionserver version.
gethooksptrfunction to get hooks from.
Returns
always 0.

Definition at line 1372 of file cfpython.c.

References catcher, cf_init_plugin(), cf_log(), cfpython_init_types(), CFPythonMethods, init_map_assoc_table(), init_object_assoc_table(), initcjson(), initConstants(), llevDebug, PythonCmdStruct::name, NR_CUSTOM_CMD, private_data, PythonCmdStruct::script, shared_data, and PythonCmdStruct::speed.

Here is the call graph for this function:

static PyObject* log_message ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 499 of file cfpython.c.

References cf_log(), llevDebug, llevError, llevInfo, and llevMonster.

Here is the call graph for this function:

static void log_python_error ( void  )
static

Trace a Python error to the Crossfire log.

This uses code from: http://stackoverflow.com/questions/4307187/how-to-catch-python-stdout-in-c-code See also in initPlugin() the parts about stdOutErr.

Definition at line 797 of file cfpython.c.

References catcher, cf_log_plain(), and llevError.

Referenced by compilePython(), and do_script().

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* matchString ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 184 of file cfpython.c.

References cf_re_cmp().

Here is the call graph for this function:

static PyObject* npcSay ( PyObject *  self,
PyObject *  args 
)
static
Todo:
fix by wrapping monster_format_say() (or the whole talk structure methods)

Definition at line 624 of file cfpython.c.

References cf_add_string(), cf_log(), Crossfire_ObjectType, llevError, MAX_NPC, obj::name, talk_info::npc_msg_count, talk_info::npc_msgs, Crossfire_Object::obj, set_exception(), snprintf, and _cfpcontext::talk.

Here is the call graph for this function:

static CFPContext* popContext ( void  )
static

Definition at line 732 of file cfpython.c.

References current_context, and _cfpcontext::down.

Referenced by cfpython_globalEventListener(), cfpython_runPluginCommand(), and eventListener().

Here is the caller graph for this function:

CF_PLUGIN int postInitPlugin ( void  )
static void pushContext ( CFPContext context)
static

Definition at line 722 of file cfpython.c.

References current_context, and _cfpcontext::down.

Referenced by do_script().

Here is the caller graph for this function:

static PyObject* readyMap ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 216 of file cfpython.c.

References cf_map_get_map(), Crossfire_Map_wrap(), and flags.

Here is the call graph for this function:

static PyObject* registerCommand ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 420 of file cfpython.c.

References cf_add_string(), PythonCmdStruct::name, NR_CUSTOM_CMD, PythonCmdStruct::script, set_exception(), and PythonCmdStruct::speed.

Here is the call graph for this function:

static PyObject* registerGEvent ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 120 of file cfpython.c.

References cf_system_register_global_event(), cfpython_globalEventListener(), and PLUGIN_NAME.

Here is the call graph for this function:

static void set_exception ( const char *  fmt,
  ... 
)
static

Set up an Python exception object.

Definition at line 99 of file cfpython.c.

References vsnprintf.

Referenced by addReply(), npcSay(), registerCommand(), and setPlayerMessage().

Here is the caller graph for this function:

static PyObject* setPlayerMessage ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 602 of file cfpython.c.

References cf_add_string(), cf_free_string(), talk_info::message, talk_info::message_type, rt_reply, set_exception(), and _cfpcontext::talk.

Here is the call graph for this function:

static PyObject* setReturnValue ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 174 of file cfpython.c.

References _cfpcontext::returnvalue.

static PyObject* unregisterGEvent ( PyObject *  self,
PyObject *  args 
)
static

Definition at line 132 of file cfpython.c.

References cf_system_unregister_global_event(), EVENT_TELL, and PLUGIN_NAME.

Here is the call graph for this function:

Variable Documentation

PyObject* catcher = NULL
static

A Python object receiving the contents of Python's stderr, and used to output to the Crossfire log instead of stderr.

Definition at line 789 of file cfpython.c.

Referenced by initPlugin(), and log_python_error().

PyObject* CFPythonError
static

Definition at line 96 of file cfpython.c.

Referenced by cfpython_init_types().

PyMethodDef CFPythonMethods[]
static

Definition at line 665 of file cfpython.c.

Referenced by cfpython_init_types(), and initPlugin().

CFPContext* context_stack

Definition at line 110 of file cfpython.c.

int current_command = -999
static

Definition at line 114 of file cfpython.c.

Referenced by cfpython_runPluginCommand(), and getPluginProperty().

CFPContext* current_context

Definition at line 112 of file cfpython.c.

Referenced by Crossfire_Object_Remove(), Crossfire_Object_Say(), popContext(), and pushContext().

PythonCmd CustomCommand[NR_CUSTOM_CMD]
static

Commands defined by scripts.

Definition at line 91 of file cfpython.c.

PyObject* private_data = NULL
static

Definition at line 118 of file cfpython.c.

Referenced by getPrivateDictionary(), and initPlugin().

pycode_cache_entry pycode_cache[PYTHON_CACHE_SIZE]
static

Cached compiled scripts.

Definition at line 94 of file cfpython.c.

PyObject* shared_data = NULL
static

Definition at line 116 of file cfpython.c.

Referenced by getSharedDictionary(), and initPlugin().

CF_PLUGIN char SvnRevPlugin[] = SVN_REV

Definition at line 65 of file cfpython.c.