Atrinik Server 2.5
Defines | Functions | Variables
plugins/plugin_python/atrinik_map.c File Reference
#include <plugin_python.h>

Go to the source code of this file.

Defines

#define NUM_MAPFLAGS   (sizeof(mapflag_names) / sizeof(mapflag_names[0]))

Functions

static PyObject * Atrinik_Map_GetFirstObject (Atrinik_Map *map, PyObject *args)
static PyObject * Atrinik_Map_GetLastObject (Atrinik_Map *map, PyObject *args)
static PyObject * Atrinik_Map_GetLayer (Atrinik_Map *map, PyObject *args)
static PyObject * Atrinik_Map_GetMapFromCoord (Atrinik_Map *map, PyObject *args)
static PyObject * Atrinik_Map_PlaySound (Atrinik_Map *map, PyObject *args, PyObject *keywds)
static PyObject * Atrinik_Map_Message (Atrinik_Map *map, PyObject *args, PyObject *keywds)
static PyObject * Atrinik_Map_CreateObject (Atrinik_Map *map, PyObject *args)
static PyObject * Atrinik_Map_CountPlayers (Atrinik_Map *map, PyObject *args)
static PyObject * Atrinik_Map_GetPlayers (Atrinik_Map *map, PyObject *args)
static PyObject * Atrinik_Map_Insert (Atrinik_Map *map, PyObject *args)
static PyObject * Atrinik_Map_Wall (Atrinik_Map *map, PyObject *args)
static PyObject * Atrinik_Map_Blocked (Atrinik_Map *map, PyObject *args)
static PyObject * Atrinik_Map_FreeSpot (Atrinik_Map *map, PyObject *args)
static PyObject * get_attribute (Atrinik_Map *map, void *context)
static int set_attribute (Atrinik_Map *map, PyObject *value, void *context)
static PyObject * Map_GetFlag (Atrinik_Map *map, void *context)
static int Map_SetFlag (Atrinik_Map *map, PyObject *val, void *context)
static PyObject * Atrinik_Map_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
static void Atrinik_Map_dealloc (Atrinik_Map *self)
static PyObject * Atrinik_Map_str (Atrinik_Map *self)
static int Atrinik_Map_InternalCompare (Atrinik_Map *left, Atrinik_Map *right)
static PyObject * Atrinik_Map_RichCompare (Atrinik_Map *left, Atrinik_Map *right, int op)
int Atrinik_Map_init (PyObject *module)
PyObject * wrap_map (mapstruct *what)

Variables

static fields_struct fields []
static char * mapflag_names []
static PyMethodDef MapMethods []
static PyGetSetDef getseters [NUM_FIELDS+NUM_MAPFLAGS+1]
PyTypeObject Atrinik_MapType

Detailed Description

Atrinik Python plugin map related code.

Definition in file atrinik_map.c.


Define Documentation

#define NUM_MAPFLAGS   (sizeof(mapflag_names) / sizeof(mapflag_names[0]))

Number of map flags

Definition at line 78 of file atrinik_map.c.


Function Documentation

static void Atrinik_Map_dealloc ( Atrinik_Map self) [static]

Free a map wrapper.

Parameters:
selfThe wrapper to free.

Definition at line 611 of file atrinik_map.c.

int Atrinik_Map_init ( PyObject *  module)

Initialize the map wrapper.

Parameters:
moduleThe Atrinik Python module.
Returns:
1 on success, 0 on failure.

Definition at line 694 of file atrinik_map.c.

static PyObject* Atrinik_Map_new ( PyTypeObject *  type,
PyObject *  args,
PyObject *  kwds 
) [static]

Create a new map wrapper.

Parameters:
typeType object.
argsUnused.
kwdsUnused.
Returns:
The new wrapper.

Definition at line 591 of file atrinik_map.c.

static PyObject* Atrinik_Map_str ( Atrinik_Map self) [static]

Return a string representation of a map.

Parameters:
selfThe map type.
Returns:
Python object containing the map path and name of the map.

Definition at line 625 of file atrinik_map.c.

static PyObject* get_attribute ( Atrinik_Map map,
void *  context 
) [static]

Get map's attribute.

Parameters:
mapPython map wrapper.
contextVoid pointer to the field.
Returns:
Python object with the attribute value, NULL on failure.

Definition at line 504 of file atrinik_map.c.

static PyObject* Map_GetFlag ( Atrinik_Map map,
void *  context 
) [static]

Get map's flag.

Parameters:
mapPython map wrapper.
contextVoid pointer to the flag ID.
Return values:
Py_TrueThe map has the flag set.
Py_FalseThe map doesn't have the flag set.
NULLAn error occurred.

Definition at line 537 of file atrinik_map.c.

static int Map_SetFlag ( Atrinik_Map map,
PyObject *  val,
void *  context 
) [static]

Set map's flag.

Parameters:
mapPython map wrapper.
valValue to set. Should be either Py_True or Py_False.
contextVoid pointer to the flag ID.
Returns:
0 on success, -1 on failure.

Definition at line 557 of file atrinik_map.c.

static int set_attribute ( Atrinik_Map map,
PyObject *  value,
void *  context 
) [static]

Set attribute of a map.

Parameters:
mapPython map wrapper.
valueValue to set.
contextVoid pointer to the field.
Returns:
0 on success, -1 on failure.

Definition at line 515 of file atrinik_map.c.

PyObject* wrap_map ( mapstruct what)

Utility method to wrap a map.

Parameters:
whatMap to wrap.
Returns:
Python object wrapping the real map.

Definition at line 741 of file atrinik_map.c.


Variable Documentation

PyTypeObject Atrinik_MapType

Our actual Python MapType.

Definition at line 653 of file atrinik_map.c.

fields_struct fields[] [static]
Initial value:
{
    {"next", FIELDTYPE_MAP, offsetof(mapstruct, next), FIELDFLAG_READONLY, 0},
    {"previous", FIELDTYPE_MAP, offsetof(mapstruct, previous), FIELDFLAG_READONLY, 0},

    {"name", FIELDTYPE_CSTR, offsetof(mapstruct, name), 0, 0},
    {"msg", FIELDTYPE_CSTR, offsetof(mapstruct, msg), 0, 0},
    {"reset_timeout", FIELDTYPE_UINT32, offsetof(mapstruct, reset_timeout), 0, 0},
    {"timeout", FIELDTYPE_SINT32, offsetof(mapstruct, timeout), 0, 0},
    {"difficulty", FIELDTYPE_UINT16, offsetof(mapstruct, difficulty), 0, 0},
    {"height", FIELDTYPE_UINT16, offsetof(mapstruct, height), FIELDFLAG_READONLY, 0},
    {"width", FIELDTYPE_UINT16, offsetof(mapstruct, width), FIELDFLAG_READONLY, 0},
    {"darkness", FIELDTYPE_UINT8, offsetof(mapstruct, darkness), 0, 0},
    {"path", FIELDTYPE_SHSTR, offsetof(mapstruct, path), FIELDFLAG_READONLY, 0},
    {"enter_x", FIELDTYPE_UINT8, offsetof(mapstruct, enter_x), 0, 0},
    {"enter_y", FIELDTYPE_UINT8, offsetof(mapstruct, enter_y), 0, 0},
    {"region", FIELDTYPE_REGION, offsetof(mapstruct, region), FIELDFLAG_READONLY, 0},
    {"bg_music", FIELDTYPE_CSTR, offsetof(mapstruct, bg_music), 0, 0},
    {"weather", FIELDTYPE_CSTR, offsetof(mapstruct, weather), 0, 0}
}

Map fields.

Definition at line 38 of file atrinik_map.c.

PyGetSetDef getseters[NUM_FIELDS+NUM_MAPFLAGS+1] [static]

This is filled in when we initialize our map type.

Definition at line 650 of file atrinik_map.c.

char* mapflag_names[] [static]
Initial value:
{
    "f_outdoor", "f_unique", "f_fixed_rtime", "f_nomagic",
    "f_nopriest", "f_noharm", "f_nosummon", "f_fixed_login",
    "f_player_no_save", "f_unused2", "f_unused3", "f_pvp",
    "f_no_save"
}

Map flags.

Note:
These must be in same order as map flags.

Definition at line 68 of file atrinik_map.c.

PyMethodDef MapMethods[] [static]
Initial value:
{
    {"GetFirstObject", (PyCFunction) Atrinik_Map_GetFirstObject, METH_VARARGS, 0},
    {"GetLastObject", (PyCFunction) Atrinik_Map_GetLastObject, METH_VARARGS, 0},
    {"GetLayer", (PyCFunction) Atrinik_Map_GetLayer, METH_VARARGS, 0},
    {"GetMapFromCoord", (PyCFunction) Atrinik_Map_GetMapFromCoord, METH_VARARGS, 0},
    {"PlaySound", (PyCFunction) Atrinik_Map_PlaySound, METH_VARARGS | METH_KEYWORDS, 0},
    {"Message", (PyCFunction) Atrinik_Map_Message, METH_VARARGS | METH_KEYWORDS, 0},
    {"CreateObject", (PyCFunction) Atrinik_Map_CreateObject, METH_VARARGS, 0},
    {"CountPlayers", (PyCFunction) Atrinik_Map_CountPlayers, METH_NOARGS, 0},
    {"GetPlayers", (PyCFunction) Atrinik_Map_GetPlayers, METH_NOARGS, 0},
    {"Insert", (PyCFunction) Atrinik_Map_Insert, METH_VARARGS, 0},
    {"Wall", (PyCFunction) Atrinik_Map_Wall, METH_VARARGS, 0},
    {"Blocked", (PyCFunction) Atrinik_Map_Blocked, METH_VARARGS, 0},
    {"FreeSpot", (PyCFunction) Atrinik_Map_FreeSpot, METH_VARARGS, 0},
    {NULL, NULL, 0, 0}
}

Available Python methods for the AtrinikMap object

Definition at line 481 of file atrinik_map.c.