Crossfire Server, Trunk  R21189
cfpython.c File Reference
#include <cfpython.h>
#include <fcntl.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
 
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)
 
CF_PLUGIN int cfpython_globalEventListener (int *type,...)
 
static void cfpython_init_types (PyObject *m)
 
static PyObject * cfpython_openpyfile (char *filename)
 
static FILE * cfpython_pyfile_asfile (PyObject *obj)
 
CF_PLUGIN void cfpython_runPluginCommand (object *op, const char *params)
 
CF_PLUGIN int closePlugin (void)
 
static PyCodeObject * compilePython (char *filename)
 
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,...)
 
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 const char * getGlobalEventPath (int code)
 
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 void log_python_error (void)
 
static PyObject * matchString (PyObject *self, PyObject *args)
 
static PyObject * npcSay (PyObject *self, PyObject *args)
 
static CFPContextpopContext (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 * setPlayerMessage (PyObject *self, PyObject *args)
 
static PyObject * setReturnValue (PyObject *self, PyObject *args)
 
static PyObject * unregisterGEvent (PyObject *self, PyObject *args)
 

Variables

static PyObject * catcher = NULL
 
static PyObject * CFPythonError
 
static PyMethodDef CFPythonMethods []
 
CFPContextcontext_stack
 
static int current_command = -999
 
CFPContextcurrent_context
 
static PythonCmd CustomCommand [NR_CUSTOM_CMD]
 
static int GECodes []
 
static const char * GEPaths []
 
static PyObject * private_data = NULL
 
static pycode_cache_entry pycode_cache [PYTHON_CACHE_SIZE]
 
static PyObject * shared_data = NULL
 
CF_PLUGIN char SvnRevPlugin [] = SVN_REV
 

Macro Definition Documentation

◆ NR_CUSTOM_CMD

#define NR_CUSTOM_CMD   1024

Definition at line 89 of file cfpython.c.

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

◆ PYTHON_CACHE_SIZE

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

Definition at line 69 of file cfpython.c.

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

◆ PYTHON_DEBUG

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

Definition at line 68 of file cfpython.c.

Typedef Documentation

◆ PythonCmd

typedef struct PythonCmdStruct PythonCmd

Function Documentation

◆ addConstants()

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

Definition at line 960 of file cfpython.c.

References snprintf.

Referenced by initConstants().

+ Here is the caller graph for this function:

◆ addReply()

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

Definition at line 576 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:

◆ addSimpleConstants()

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 992 of file cfpython.c.

References snprintf.

Referenced by initConstants().

+ Here is the caller graph for this function:

◆ cfpython_globalEventListener()

◆ cfpython_init_types()

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 1319 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:

◆ cfpython_openpyfile()

static PyObject* cfpython_openpyfile ( char *  filename)
static

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

Definition at line 756 of file cfpython.c.

Referenced by compilePython(), and postInitPlugin().

+ Here is the caller graph for this function:

◆ cfpython_pyfile_asfile()

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 778 of file cfpython.c.

Referenced by compilePython(), and postInitPlugin().

+ Here is the caller graph for this function:

◆ cfpython_runPluginCommand()

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

◆ compilePython()

static PyCodeObject* compilePython ( char *  filename)
static

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

Definition at line 826 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:

◆ costStringFromValue()

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

Definition at line 654 of file cfpython.c.

References cf_cost_string_from_value().

+ Here is the call graph for this function:

◆ createCFObject()

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

Definition at line 145 of file cfpython.c.

References cf_create_object(), and Crossfire_Object_wrap().

+ Here is the call graph for this function:

◆ createCFObjectByName()

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

Definition at line 153 of file cfpython.c.

References cf_create_object_by_name(), and Crossfire_Object_wrap().

+ Here is the call graph for this function:

◆ createMap()

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

Definition at line 230 of file cfpython.c.

References cf_get_empty_map(), and Crossfire_Map_wrap().

+ Here is the call graph for this function:

◆ destroyTimer()

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

Definition at line 476 of file cfpython.c.

References cf_timer_destroy().

+ Here is the call graph for this function:

◆ do_script()

static int do_script ( CFPContext context,
int  silent 
)
static

Definition at line 915 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:

◆ findAnimation()

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

Definition at line 536 of file cfpython.c.

References cf_find_animation(), and PythonCmdStruct::name.

+ Here is the call graph for this function:

◆ findFace()

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

Definition at line 492 of file cfpython.c.

References cf_find_face(), and PythonCmdStruct::name.

+ Here is the call graph for this function:

◆ findPlayer()

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

Definition at line 200 of file cfpython.c.

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

+ Here is the call graph for this function:

◆ freeContext()

static void freeContext ( CFPContext context)
static

Definition at line 745 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:

◆ getArchetypes()

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

Definition at line 343 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:

◆ getCFPythonVersion()

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

Definition at line 165 of file cfpython.c.

◆ getConfigDirectory()

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

Definition at line 254 of file cfpython.c.

References cf_get_directory().

+ Here is the call graph for this function:

◆ getDataDirectory()

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

Definition at line 266 of file cfpython.c.

References cf_get_directory().

+ Here is the call graph for this function:

◆ getEvent()

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

Definition at line 316 of file cfpython.c.

References _cfpcontext::event.

◆ getFriendlyList()

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

Definition at line 408 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:

◆ getGlobalEventPath()

static const char* getGlobalEventPath ( int  code)
static

Definition at line 1595 of file cfpython.c.

References GECodes, and GEPaths.

Referenced by cfpython_globalEventListener().

+ Here is the caller graph for this function:

◆ getLocalDirectory()

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

Definition at line 258 of file cfpython.c.

References cf_get_directory().

+ Here is the call graph for this function:

◆ getMapDirectory()

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

Definition at line 242 of file cfpython.c.

References cf_get_directory().

+ Here is the call graph for this function:

◆ getMapHasBeenLoaded()

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

Definition at line 484 of file cfpython.c.

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

+ Here is the call graph for this function:

◆ getMaps()

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

Definition at line 369 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:

◆ getMonthName()

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

Definition at line 552 of file cfpython.c.

References cf_get_month_name().

+ Here is the call graph for this function:

◆ getParties()

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

Definition at line 382 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:

◆ getPeriodofdayName()

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

Definition at line 568 of file cfpython.c.

References cf_get_periodofday_name().

+ Here is the call graph for this function:

◆ getPlayerDirectory()

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

Definition at line 262 of file cfpython.c.

References cf_get_directory().

+ Here is the call graph for this function:

◆ getPlayers()

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

Definition at line 356 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:

◆ getPrivateDictionary()

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

Definition at line 325 of file cfpython.c.

References private_data, and _cfpcontext::script.

◆ getRegions()

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

Definition at line 395 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:

◆ getReturnValue()

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

Definition at line 171 of file cfpython.c.

References _cfpcontext::returnvalue.

◆ getScriptName()

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

Definition at line 304 of file cfpython.c.

References _cfpcontext::script.

◆ getScriptParameters()

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

Definition at line 308 of file cfpython.c.

References _cfpcontext::options.

◆ getSeasonName()

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

Definition at line 544 of file cfpython.c.

References cf_get_season_name().

+ Here is the call graph for this function:

◆ getSharedDictionary()

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

Definition at line 338 of file cfpython.c.

References shared_data.

◆ getTempDirectory()

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

Definition at line 250 of file cfpython.c.

References cf_get_directory().

+ Here is the call graph for this function:

◆ getTime()

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

◆ getUniqueDirectory()

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

Definition at line 246 of file cfpython.c.

References cf_get_directory().

+ Here is the call graph for this function:

◆ getWeekdayName()

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

Definition at line 560 of file cfpython.c.

References cf_get_weekday_name().

+ Here is the call graph for this function:

◆ getWhatIsMessage()

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

Definition at line 297 of file cfpython.c.

References _cfpcontext::message.

◆ getWhoAmI()

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

Definition at line 270 of file cfpython.c.

References _cfpcontext::who.

◆ getWhoIsActivator()

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

Definition at line 279 of file cfpython.c.

References _cfpcontext::activator.

◆ getWhoIsThird()

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

Definition at line 288 of file cfpython.c.

References _cfpcontext::third.

◆ initcjson()

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:

◆ initConstants()

static void initConstants ( PyObject *  module)
static

Definition at line 1008 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:

◆ initContextStack()

static void initContextStack ( void  )
static

Definition at line 718 of file cfpython.c.

Referenced by postInitPlugin().

+ Here is the caller graph for this function:

◆ log_message()

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

Definition at line 500 of file cfpython.c.

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

+ Here is the call graph for this function:

◆ log_python_error()

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 798 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:

◆ matchString()

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

Definition at line 185 of file cfpython.c.

References cf_re_cmp().

+ Here is the call graph for this function:

◆ npcSay()

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

Definition at line 625 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:

◆ popContext()

static CFPContext* popContext ( void  )
static

Definition at line 733 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:

◆ pushContext()

static void pushContext ( CFPContext context)
static

Definition at line 723 of file cfpython.c.

References current_context, and _cfpcontext::down.

Referenced by do_script().

+ Here is the caller graph for this function:

◆ readyMap()

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

Definition at line 217 of file cfpython.c.

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

+ Here is the call graph for this function:

◆ registerCommand()

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

Definition at line 421 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:

◆ registerGEvent()

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

Definition at line 121 of file cfpython.c.

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

+ Here is the call graph for this function:

◆ set_exception()

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

Set up an Python exception object.

Definition at line 100 of file cfpython.c.

References vsnprintf.

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

+ Here is the caller graph for this function:

◆ setPlayerMessage()

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

Definition at line 603 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:

◆ setReturnValue()

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

Definition at line 175 of file cfpython.c.

References _cfpcontext::returnvalue.

◆ unregisterGEvent()

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

Definition at line 133 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

◆ catcher

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 790 of file cfpython.c.

Referenced by initPlugin(), and log_python_error().

◆ CFPythonError

PyObject* CFPythonError
static

Definition at line 97 of file cfpython.c.

Referenced by cfpython_init_types().

◆ CFPythonMethods

PyMethodDef CFPythonMethods[]
static

Definition at line 666 of file cfpython.c.

Referenced by cfpython_init_types(), and initPlugin().

◆ context_stack

CFPContext* context_stack

Definition at line 111 of file cfpython.c.

◆ current_command

int current_command = -999
static

Definition at line 115 of file cfpython.c.

Referenced by cfpython_runPluginCommand(), and getPluginProperty().

◆ current_context

CFPContext* current_context

Definition at line 113 of file cfpython.c.

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

◆ CustomCommand

PythonCmd CustomCommand[NR_CUSTOM_CMD]
static

Commands defined by scripts.

Definition at line 92 of file cfpython.c.

◆ GECodes

int GECodes[]
static
Initial value:
= {
0
}
#define EVENT_REMOVE
Definition: plugin.h:93
#define EVENT_SHOUT
Definition: plugin.h:94
#define EVENT_KICK
Definition: plugin.h:97
#define EVENT_LOGIN
Definition: plugin.h:88
#define EVENT_MAPLEAVE
Definition: plugin.h:91
#define EVENT_LOGOUT
Definition: plugin.h:89
#define EVENT_TELL
Definition: plugin.h:95
#define EVENT_MAPENTER
Definition: plugin.h:90
#define EVENT_MAPLOAD
Definition: plugin.h:99
#define EVENT_MAPUNLOAD
Definition: plugin.h:98
#define EVENT_MAPRESET
Definition: plugin.h:92
#define EVENT_GKILL
Definition: plugin.h:87
#define EVENT_CLOCK
Definition: plugin.h:84
#define EVENT_PLAYER_DEATH
Definition: plugin.h:86
#define EVENT_BORN
Definition: plugin.h:83
#define EVENT_MUZZLE
Definition: plugin.h:96

Definition at line 1528 of file cfpython.c.

Referenced by getGlobalEventPath(), and postInitPlugin().

◆ GEPaths

const char* GEPaths[]
static
Initial value:
= {
"born",
"clock",
"death",
"gkill",
"login",
"logout",
"mapenter",
"mapleave",
"mapreset",
"remove",
"shout",
"tell",
"muzzle",
"kick",
"mapunload",
"mapload",
NULL
}

Definition at line 1548 of file cfpython.c.

Referenced by getGlobalEventPath().

◆ private_data

PyObject* private_data = NULL
static

Definition at line 119 of file cfpython.c.

Referenced by getPrivateDictionary(), and initPlugin().

◆ pycode_cache

pycode_cache_entry pycode_cache[PYTHON_CACHE_SIZE]
static

Cached compiled scripts.

Definition at line 95 of file cfpython.c.

◆ shared_data

PyObject* shared_data = NULL
static

Definition at line 117 of file cfpython.c.

Referenced by getSharedDictionary(), and initPlugin().

◆ SvnRevPlugin

CF_PLUGIN char SvnRevPlugin[] = SVN_REV

Definition at line 66 of file cfpython.c.