Crossfire Server, Trunk  1.75.0
cfpython_map.cpp
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* CFPython - A Python module for Crossfire RPG. */
3 /* Version: 2.0beta8 (also known as "Alexander") */
4 /* Contact: yann.chachkoff@myrealbox.com */
5 /*****************************************************************************/
6 /* That code is placed under the GNU General Public Licence (GPL) */
7 /* (C)2001-2005 by Chachkoff Yann (Feel free to deliver your complaints) */
8 /*****************************************************************************/
9 /* CrossFire, A Multiplayer game for X-windows */
10 /* */
11 /* Copyright (C) 2000 Mark Wedel */
12 /* Copyright (C) 1992 Frank Tore Johansen */
13 /* */
14 /* This program is free software; you can redistribute it and/or modify */
15 /* it under the terms of the GNU General Public License as published by */
16 /* the Free Software Foundation; either version 2 of the License, or */
17 /* (at your option) any later version. */
18 /* */
19 /* This program is distributed in the hope that it will be useful, */
20 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
21 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
22 /* GNU General Public License for more details. */
23 /* */
24 /* You should have received a copy of the GNU General Public License */
25 /* along with this program; if not, write to the Free Software */
26 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
27 /* */
28 /*****************************************************************************/
29 
30 #include <cfpython.h>
31 #include <map>
32 
33 /* Table for keeping track of which PyObject goes with with Crossfire object */
34 static std::map<mapstruct *, Crossfire_Map *> map_assoc_table;
35 
36 static void add_map_assoc(mapstruct *key, Crossfire_Map *value) {
37  map_assoc_table[key] = value;
38 }
39 
41  auto f = map_assoc_table.find(key);
42  return f == map_assoc_table.end() ? nullptr : f->second;
43 }
44 
45 static void free_map_assoc(mapstruct *key) {
46  map_assoc_table.erase(key);
47 }
48 
49 
52  assert(map->map != NULL);
53  if (map->map->in_memory != MAP_IN_MEMORY) {
54  char* mapname = map->map->path;
55  int is_unique = cf_map_get_int_property(map->map, CFAPI_MAP_PROP_UNIQUE);
56  /* If the map is unique the path name will be freed. We need to handle that. */
57  if (is_unique) {
58  char* tmp = strdup(mapname);
59  if (!tmp) {
60  /* FIXME: We should fatal() here, but that doesn't exist in plugins. */
61  cf_log(llevError, "Out of memory in ensure_map_in_memory()!\n");
62  abort();
63  }
64  mapname = tmp;
65  }
66  cf_log(llevDebug, "MAP %s AIN'T READY ! Loading it...\n", mapname);
67  /* Map pointer may change for player unique maps. */
68  /* Also, is the MAP_PLAYER_UNIQUE logic correct? */
69  map->map = cf_map_get_map(mapname, is_unique ? MAP_PLAYER_UNIQUE : 0);
70  if (is_unique)
71  free(mapname);
72  }
73 }
74 
75 static PyObject *Map_GetDifficulty(Crossfire_Map *whoptr, void *closure) {
76  (void)closure;
77  MAPEXISTCHECK(whoptr);
78  return Py_BuildValue("i", cf_map_get_difficulty(whoptr->map));
79 }
80 
81 static PyObject *Map_GetPath(Crossfire_Map *whoptr, void *closure) {
82  (void)closure;
83  MAPEXISTCHECK(whoptr);
84  return Py_BuildValue("s", cf_map_get_sstring_property(whoptr->map, CFAPI_MAP_PROP_PATH));
85 }
86 
87 static PyObject *Map_GetTempName(Crossfire_Map *whoptr, void *closure) {
88  (void)closure;
89  MAPEXISTCHECK(whoptr);
90  return Py_BuildValue("s", cf_map_get_sstring_property(whoptr->map, CFAPI_MAP_PROP_TMPNAME));
91 }
92 
93 static PyObject *Map_GetName(Crossfire_Map *whoptr, void *closure) {
94  (void)closure;
95  MAPEXISTCHECK(whoptr);
96  return Py_BuildValue("s", cf_map_get_sstring_property(whoptr->map, CFAPI_MAP_PROP_NAME));
97 }
98 
99 static PyObject *Map_GetResetTime(Crossfire_Map *whoptr, void *closure) {
100  (void)closure;
101  MAPEXISTCHECK(whoptr);
102  return Py_BuildValue("i", cf_map_get_reset_time(whoptr->map));
103 }
104 
105 static PyObject *Map_GetResetTimeout(Crossfire_Map *whoptr, void *closure) {
106  (void)closure;
107  MAPEXISTCHECK(whoptr);
108  return Py_BuildValue("i", cf_map_get_reset_timeout(whoptr->map));
109 }
110 
111 static PyObject *Map_GetPlayers(Crossfire_Map *whoptr, void *closure) {
112  (void)closure;
113  MAPEXISTCHECK(whoptr);
114  return Py_BuildValue("i", cf_map_get_players(whoptr->map));
115 }
116 
117 static PyObject *Map_GetDarkness(Crossfire_Map *whoptr, void *closure) {
118  (void)closure;
119  MAPEXISTCHECK(whoptr);
120  return Py_BuildValue("i", cf_map_get_darkness(whoptr->map));
121 }
122 
123 static PyObject *Map_GetWidth(Crossfire_Map *whoptr, void *closure) {
124  (void)closure;
125  MAPEXISTCHECK(whoptr);
126  return Py_BuildValue("i", cf_map_get_width(whoptr->map));
127 }
128 
129 static PyObject *Map_GetHeight(Crossfire_Map *whoptr, void *closure) {
130  (void)closure;
131  MAPEXISTCHECK(whoptr);
132  return Py_BuildValue("i", cf_map_get_height(whoptr->map));
133 }
134 
135 static PyObject *Map_GetEnterX(Crossfire_Map *whoptr, void *closure) {
136  (void)closure;
137  MAPEXISTCHECK(whoptr);
138  return Py_BuildValue("i", cf_map_get_enter_x(whoptr->map));
139 }
140 
141 static PyObject *Map_GetEnterY(Crossfire_Map *whoptr, void *closure) {
142  (void)closure;
143  MAPEXISTCHECK(whoptr);
144  return Py_BuildValue("i", cf_map_get_enter_y(whoptr->map));
145 }
146 
147 static PyObject* Map_GetWPartX(Crossfire_Map* whoptr, void* closure)
148 {
149  MAPEXISTCHECK(whoptr);
150  return Py_BuildValue("i", cf_map_get_wpartx(whoptr->map));
151 }
152 static PyObject* Map_GetWPartY(Crossfire_Map* whoptr, void* closure)
153 {
154  MAPEXISTCHECK(whoptr);
155  return Py_BuildValue("i", cf_map_get_wparty(whoptr->map));
156 }
157 
158 static PyObject *Map_GetMessage(Crossfire_Map *whoptr, void *closure) {
159  (void)closure;
160  MAPEXISTCHECK(whoptr);
161  return Py_BuildValue("s", cf_map_get_sstring_property(whoptr->map, CFAPI_MAP_PROP_MESSAGE));
162 }
163 
164 static PyObject *Map_GetRegion(Crossfire_Map *whoptr, void *closure) {
165  (void)closure;
166  MAPEXISTCHECK(whoptr);
168 }
169 
170 static int Map_SetPath(Crossfire_Map *whoptr, PyObject *value, void *closure) {
171  const char *val;
172  (void)closure;
173 
174  MAPEXISTCHECK_INT(whoptr);
175  if (!PyArg_Parse(value, "s", &val))
176  return -1;
177 
179  return 0;
180 
181 }
182 
183 static PyObject *Map_GetUnique(Crossfire_Map *whoptr, void *closure) {
184  (void)closure;
185  MAPEXISTCHECK(whoptr);
186  return Py_BuildValue("i", cf_map_get_int_property(whoptr->map, CFAPI_MAP_PROP_UNIQUE));
187 }
188 
189 static PyObject *Map_Message(Crossfire_Map *map, PyObject *args) {
190  int color = NDI_BLUE|NDI_UNIQUE;
191  char *message;
192 
193  if (!PyArg_ParseTuple(args, "s|i", &message, &color))
194  return NULL;
195 
196  MAPEXISTCHECK(map);
197 
198  cf_map_message(map->map, message, color);
199 
200  Py_INCREF(Py_None);
201  return Py_None;
202 }
203 
204 static PyObject *Map_GetFirstObjectAt(Crossfire_Map *map, PyObject *args) {
205  int x, y;
206  object *val;
207 
208  if (!PyArg_ParseTuple(args, "ii", &x, &y))
209  return NULL;
210 
211  MAPEXISTCHECK(map);
212 
213  /* make sure the map is swapped in */
215 
216  val = cf_map_get_object_at(map->map, x, y);
217  return Crossfire_Object_wrap(val);
218 }
219 
220 static PyObject *Map_CreateObject(Crossfire_Map *map, PyObject *args) {
221  char *txt;
222  int x, y;
223  object *op;
224 
225  if (!PyArg_ParseTuple(args, "sii", &txt, &x, &y))
226  return NULL;
227 
228  MAPEXISTCHECK(map);
229 
230  /* make sure the map is swapped in */
232 
233  op = cf_create_object_by_name(txt);
234 
235  if (op)
236  op = cf_map_insert_object(map->map, op, x, y);
237  return Crossfire_Object_wrap(op);
238 }
239 
240 static PyObject *Map_Check(Crossfire_Map *map, PyObject *args) {
241  char *what;
242  int x, y;
243  object *foundob;
244  int16_t nx, ny;
245  int mflags;
246 
247  if (!PyArg_ParseTuple(args, "s(ii)", &what, &x, &y))
248  return NULL;
249 
250  MAPEXISTCHECK(map);
251 
252  /* make sure the map is swapped in */
254 
255  mflags = cf_map_get_flags(map->map, &(map->map), (int16_t)x, (int16_t)y, &nx, &ny);
256  if (mflags&P_OUT_OF_MAP) {
257  Py_INCREF(Py_None);
258  return Py_None;
259  }
260  foundob = cf_map_find_by_archetype_name(what, map->map, nx, ny);
261  return Crossfire_Object_wrap(foundob);
262 }
263 
264 static PyObject *Map_Next(Crossfire_Map *map, PyObject *args) {
265  (void)args;
266  MAPEXISTCHECK(map);
268 }
269 
270 static PyObject *Map_Insert(Crossfire_Map *map, PyObject *args) {
271  int x, y;
272  Crossfire_Object *what;
273 
274  if (!PyArg_ParseTuple(args, "O!ii", &Crossfire_ObjectType, &what, &x, &y))
275  return NULL;
276 
277  MAPEXISTCHECK(map);
278 
279  /* make sure the map is swapped in */
281 
282  return Crossfire_Object_wrap(cf_map_insert_object(map->map, what->obj, x, y));
283 }
284 
285 static PyObject *Map_InsertAround(Crossfire_Map *map, PyObject *args) {
286  int x, y;
287  Crossfire_Object *what;
288 
289  if (!PyArg_ParseTuple(args, "O!ii", &Crossfire_ObjectType, &what, &x, &y))
290  return NULL;
291 
292  MAPEXISTCHECK(map);
293 
294  /* make sure the map is swapped in */
296 
297  return Crossfire_Object_wrap(cf_map_insert_object_around(map->map, what->obj, x, y));
298 }
299 
300 static PyObject *Map_ChangeLight(Crossfire_Map *map, PyObject *args) {
301  int change;
302 
303  if (!PyArg_ParseTuple(args, "i", &change))
304  return NULL;
305 
306  MAPEXISTCHECK(map);
307 
308  return Py_BuildValue("i", cf_map_change_light(map->map, change));
309 }
325 static PyObject *Map_TriggerConnected(Crossfire_Map *map, PyObject *args) {
326  objectlink *ol = NULL;
327  int connected;
328  int state;
329  Crossfire_Object *cause = NULL;
330  oblinkpt *olp;
331 
332  if (!PyArg_ParseTuple(args, "ii|O!", &connected, &state, &Crossfire_ObjectType, &cause))
333  return NULL;
334 
335  MAPEXISTCHECK(map);
336 
337  /* make sure the map is swapped in */
339 
340  /* locate objectlink for this connected value */
341  if (!map->map->buttons) {
342  cf_log(llevError, "Map %s called for trigger on connected %d but there ain't any button list for that map!\n", cf_map_get_sstring_property(map->map, CFAPI_MAP_PROP_PATH), connected);
343  PyErr_SetString(PyExc_ReferenceError, "No objects connected to that ID on this map.");
344  return NULL;
345  }
346  for (olp = map->map->buttons; olp; olp = olp->next) {
347  if (olp->value == connected) {
348  ol = olp->link;
349  break;
350  }
351  }
352  if (ol == NULL) {
353  cf_log(llevInfo, "Map %s called for trigger on connected %d but there ain't any button list for that map!\n", cf_map_get_sstring_property(map->map, CFAPI_MAP_PROP_PATH), connected);
354  /* FIXME: I'm not sure about this message... */
355  PyErr_SetString(PyExc_ReferenceError, "No objects with that connection ID on this map.");
356  return NULL;
357  }
358  /* run the object link */
359  cf_map_trigger_connected(ol, cause ? cause->obj : NULL, state);
360 
361  Py_INCREF(Py_None);
362  return Py_None;
363 }
364 
366  MAPEXISTCHECK_INT(left);
367  MAPEXISTCHECK_INT(right);
368  return left->map < right->map ? -1 : (left->map == right->map ? 0 : 1);
369 }
370 
371 static PyObject *Crossfire_Map_RichCompare(Crossfire_Map *left, Crossfire_Map *right, int op) {
372  int result;
373  if (!left
374  || !right
375  || !PyObject_TypeCheck((PyObject*)left, &Crossfire_MapType)
376  || !PyObject_TypeCheck((PyObject*)right, &Crossfire_MapType)) {
377  Py_INCREF(Py_NotImplemented);
378  return Py_NotImplemented;
379  }
380  result = Map_InternalCompare(left, right);
381  /* Handle removed maps. */
382  if (result == -1 && PyErr_Occurred())
383  return NULL;
384  /* Based on how Python 3.0 (GPL compatible) implements it for internal types: */
385  switch (op) {
386  case Py_EQ:
387  result = (result == 0);
388  break;
389  case Py_NE:
390  result = (result != 0);
391  break;
392  case Py_LE:
393  result = (result <= 0);
394  break;
395  case Py_GE:
396  result = (result >= 0);
397  break;
398  case Py_LT:
399  result = (result == -1);
400  break;
401  case Py_GT:
402  result = (result == 1);
403  break;
404  }
405  return PyBool_FromLong(result);
406 }
407 
408 /* Legacy code: convert to long so that non-object functions work correctly */
409 static PyObject *Crossfire_Map_Long(PyObject *obj) {
411  return Py_BuildValue("l", ((Crossfire_Map *)obj)->map);
412 }
413 
417 static PyObject *Crossfire_Map_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
418  Crossfire_Map *self;
419  (void)args;
420  (void)kwds;
421 
422  self = (Crossfire_Map *)type->tp_alloc(type, 0);
423  if (self)
424  self->map = NULL;
425 
426  return (PyObject *)self;
427 }
428 
429 static void Crossfire_Map_dealloc(PyObject *obj) {
430  Crossfire_Map *self;
431 
432  self = (Crossfire_Map *)obj;
433  if (self) {
434  if (self->map && self->valid) {
435  free_map_assoc(self->map);
436  }
437  Py_TYPE(self)->tp_free(obj);
438  }
439 }
440 
442  map->valid = 0;
443  free_map_assoc(map->map);
444 }
445 
446 PyObject *Crossfire_Map_wrap(mapstruct *what) {
447  Crossfire_Map *wrapper;
448 
449  /* return None if no object was to be wrapped */
450  if (what == NULL) {
451  Py_INCREF(Py_None);
452  return Py_None;
453  }
454 
455  wrapper = find_assoc_pymap(what);
456  if (!wrapper) {
457  wrapper = PyObject_NEW(Crossfire_Map, &Crossfire_MapType);
458  if (wrapper != NULL) {
459  wrapper->map = what;
460  wrapper->valid = 1;
461  add_map_assoc(what, wrapper);
462  }
463  } else {
464  Py_INCREF(wrapper);
465  }
466 
467  return (PyObject *)wrapper;
468 }
469 
470 /* Python binding */
471 static PyGetSetDef Map_getseters[] = {
472  { "Difficulty", (getter)Map_GetDifficulty, NULL, NULL, NULL },
473  { "Path", (getter)Map_GetPath, (setter)Map_SetPath, NULL, NULL },
474  { "TempName", (getter)Map_GetTempName, NULL, NULL, NULL },
475  { "Name", (getter)Map_GetName, NULL, NULL, NULL },
476  { "ResetTime", (getter)Map_GetResetTime, NULL, NULL, NULL },
477  { "ResetTimeout", (getter)Map_GetResetTimeout, NULL, NULL, NULL },
478  { "Players", (getter)Map_GetPlayers, NULL, NULL, NULL },
479  { "Light", (getter)Map_GetDarkness, NULL, NULL, NULL },
480  { "Darkness", (getter)Map_GetDarkness, NULL, NULL, NULL },
481  { "Width", (getter)Map_GetWidth, NULL, NULL, NULL },
482  { "Height", (getter)Map_GetHeight, NULL, NULL, NULL },
483  { "EnterX", (getter)Map_GetEnterX, NULL, NULL, NULL },
484  { "EnterY", (getter)Map_GetEnterY, NULL, NULL, NULL },
485  { "WPartX", (getter)Map_GetWPartX, NULL, NULL, NULL },
486  { "WPartY", (getter)Map_GetWPartY, NULL, NULL, NULL },
487  { "Message", (getter)Map_GetMessage, NULL, NULL, NULL },
488  { "Region", (getter)Map_GetRegion, NULL, NULL, NULL },
489  { "Unique", (getter)Map_GetUnique, NULL, NULL, NULL },
490  { NULL, NULL, NULL, NULL, NULL }
491 };
492 
493 static PyMethodDef MapMethods[] = {
494  { "Print", (PyCFunction)Map_Message, METH_VARARGS, NULL },
495  { "ObjectAt", (PyCFunction)Map_GetFirstObjectAt, METH_VARARGS, NULL },
496  { "CreateObject", (PyCFunction)Map_CreateObject, METH_VARARGS, NULL },
497  { "Check", (PyCFunction)Map_Check, METH_VARARGS, NULL },
498  { "Next", (PyCFunction)Map_Next, METH_NOARGS, NULL },
499  { "Insert", (PyCFunction)Map_Insert, METH_VARARGS, NULL },
500  { "InsertAround", (PyCFunction)Map_InsertAround, METH_VARARGS, NULL },
501  { "ChangeLight", (PyCFunction)Map_ChangeLight, METH_VARARGS, NULL },
502  { "TriggerConnected", (PyCFunction)Map_TriggerConnected, METH_VARARGS, NULL },
503  { NULL, NULL, 0, NULL }
504 };
505 
507 
508 /* Our actual Python MapType */
511  &MapConvert,
512  PyObject_HashNotImplemented,
513  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
514  "Crossfire maps",
515  (richcmpfunc) Crossfire_Map_RichCompare,
516  MapMethods,
518  NULL,
520  );
add_map_assoc
static void add_map_assoc(mapstruct *key, Crossfire_Map *value)
Definition: cfpython_map.cpp:36
cf_map_get_region_property
region * cf_map_get_region_property(mapstruct *map, int propcode)
Definition: plugin_common.cpp:288
MAPEXISTCHECK_INT
#define MAPEXISTCHECK_INT(map)
Definition: cfpython_map.h:47
cf_log
void cf_log(LogLevel logLevel, const char *format,...)
Wrapper for LOG().
Definition: plugin_common.cpp:1541
cf_map_get_height
int cf_map_get_height(mapstruct *map)
Definition: plugin_common.cpp:1413
Map_GetDifficulty
static PyObject * Map_GetDifficulty(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:75
Crossfire_Object::obj
PyObject_HEAD object * obj
Definition: cfpython_object.h:34
cf_map_get_sstring_property
sstring cf_map_get_sstring_property(mapstruct *map, int propcode)
Definition: plugin_common.cpp:270
CFAPI_MAP_PROP_TMPNAME
#define CFAPI_MAP_PROP_TMPNAME
Definition: plugin.h:250
free_map_assoc
static void free_map_assoc(mapstruct *key)
Definition: cfpython_map.cpp:45
cf_map_get_int_property
int cf_map_get_int_property(mapstruct *map, int property)
Definition: plugin_common.cpp:254
llevError
@ llevError
Error, serious thing.
Definition: logger.h:11
cf_map_get_players
int cf_map_get_players(mapstruct *map)
Definition: plugin_common.cpp:1401
Map_SetPath
static int Map_SetPath(Crossfire_Map *whoptr, PyObject *value, void *closure)
Definition: cfpython_map.cpp:170
Map
One map for a player.
Definition: newserver.h:52
Map_Insert
static PyObject * Map_Insert(Crossfire_Map *map, PyObject *args)
Definition: cfpython_map.cpp:270
CFAPI_MAP_PROP_NEXT
#define CFAPI_MAP_PROP_NEXT
Definition: plugin.h:264
oblinkpt::next
oblinkpt * next
Next value in the list.
Definition: object.h:472
mapstruct::buttons
oblinkpt * buttons
Linked list of linked lists of buttons.
Definition: map.h:349
Map_GetHeight
static PyObject * Map_GetHeight(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:129
Crossfire_Object
Definition: cfpython_object.h:32
cf_create_object_by_name
object * cf_create_object_by_name(const char *name)
Wrapper for create_archetype() and create_archetype_by_object_name().
Definition: plugin_common.cpp:1102
cf_map_get_reset_time
int cf_map_get_reset_time(mapstruct *map)
Definition: plugin_common.cpp:1393
MAP_IN_MEMORY
#define MAP_IN_MEMORY
Map is fully loaded.
Definition: map.h:131
Map_ChangeLight
static PyObject * Map_ChangeLight(Crossfire_Map *map, PyObject *args)
Definition: cfpython_map.cpp:300
cf_map_insert_object_around
object * cf_map_insert_object_around(mapstruct *where, object *op, int x, int y)
Will insert op in the map where around the spot x, y.
Definition: plugin_common.cpp:1360
Map_getseters
static PyGetSetDef Map_getseters[]
Definition: cfpython_map.cpp:471
oblinkpt
Used to link together several object links.
Definition: object.h:469
cf_map_insert_object
object * cf_map_insert_object(mapstruct *where, object *op, int x, int y)
Wrapper for object_insert_in_map_at().
Definition: plugin_common.cpp:1338
CF_PYTHON_OBJECT
CF_PYTHON_OBJECT(Map, Crossfire_Map_dealloc, &MapConvert, PyObject_HashNotImplemented, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, "Crossfire maps",(richcmpfunc) Crossfire_Map_RichCompare, MapMethods, Map_getseters, NULL, Crossfire_Map_new)
CFAPI_MAP_PROP_UNIQUE
#define CFAPI_MAP_PROP_UNIQUE
Definition: plugin.h:266
mapstruct::path
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:361
Handle_Map_Unload_Hook
void Handle_Map_Unload_Hook(Crossfire_Map *map)
Definition: cfpython_map.cpp:441
NDI_BLUE
#define NDI_BLUE
Actually, it is Dodger Blue.
Definition: newclient.h:251
Map_GetEnterY
static PyObject * Map_GetEnterY(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:141
Crossfire_Object_wrap
PyObject * Crossfire_Object_wrap(object *what)
Python initialized.
Definition: cfpython_object.cpp:1621
Map_GetTempName
static PyObject * Map_GetTempName(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:87
MAPEXISTCHECK
#define MAPEXISTCHECK(map)
Definition: cfpython_map.h:40
CFAPI_MAP_PROP_REGION
#define CFAPI_MAP_PROP_REGION
Definition: plugin.h:265
Map_GetPath
static PyObject * Map_GetPath(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:81
Crossfire_Map_new
static PyObject * Crossfire_Map_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Python initialized.
Definition: cfpython_map.cpp:417
Crossfire_Map::map
PyObject_HEAD mapstruct * map
Definition: cfpython_map.h:34
oblinkpt::link
objectlink * link
Items for this value.
Definition: object.h:470
cf_map_get_object_at
object * cf_map_get_object_at(mapstruct *m, int x, int y)
Wrapper for GET_MAP_OB().
Definition: plugin_common.cpp:655
Map_Message
static PyObject * Map_Message(Crossfire_Map *map, PyObject *args)
Definition: cfpython_map.cpp:189
CFAPI_MAP_PROP_MESSAGE
#define CFAPI_MAP_PROP_MESSAGE
Definition: plugin.h:263
cf_map_get_enter_y
int cf_map_get_enter_y(mapstruct *map)
Definition: plugin_common.cpp:1421
oblinkpt::value
long value
Used as connected value in buttons/gates.
Definition: object.h:471
Map_GetUnique
static PyObject * Map_GetUnique(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:183
cfpython.h
map_assoc_table
static std::map< mapstruct *, Crossfire_Map * > map_assoc_table
Definition: cfpython_map.cpp:34
message
TIPS on SURVIVING Crossfire is populated with a wealth of different monsters These monsters can have varying immunities and attack types In some of them can be quite a bit smarter than others It will be important for new players to learn the abilities of different monsters and learn just how much it will take to kill them This section discusses how monsters can interact with players Most monsters in the game are out to mindlessly kill and destroy the players These monsters will help boost a player s after he kills them When fighting a large amount of monsters in a single attempt to find a narrower hallway so that you are not being attacked from all sides Charging into a room full of Beholders for instance would not be open the door and fight them one at a time For there are several maps designed for them Find these areas and clear them out All throughout these a player can find signs and books which they can read by stepping onto them and hitting A to apply the book sign These messages will help the player to learn the system One more always keep an eye on your food If your food drops to your character will soon so BE CAREFUL ! NPCs Non Player Character are special monsters which have intelligence Players may be able to interact with these monsters to help solve puzzles and find items of interest To speak with a monster you suspect to be a simply move to an adjacent square to them and push the double ie Enter your message
Definition: survival-guide.txt:34
cf_map_get_wpartx
int cf_map_get_wpartx(mapstruct *map)
Definition: plugin_common.cpp:1425
CFAPI_MAP_PROP_PATH
#define CFAPI_MAP_PROP_PATH
Definition: plugin.h:249
cf_map_message
void cf_map_message(mapstruct *m, const char *msg, int color)
Partial wrapper for ext_info_map().
Definition: plugin_common.cpp:667
cf_map_get_reset_timeout
int cf_map_get_reset_timeout(mapstruct *map)
Definition: plugin_common.cpp:1397
P_OUT_OF_MAP
#define P_OUT_OF_MAP
This space is outside the map.
Definition: map.h:254
Crossfire_Region_wrap
PyObject * Crossfire_Region_wrap(region *what)
Definition: cfpython_region.cpp:72
cf_map_get_enter_x
int cf_map_get_enter_x(mapstruct *map)
Definition: plugin_common.cpp:1417
cf_map_get_map_property
mapstruct * cf_map_get_map_property(mapstruct *map, int propcode)
Definition: plugin_common.cpp:279
cf_map_get_flags
int cf_map_get_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
Wrapper for get_map_flags().
Definition: plugin_common.cpp:1480
CFAPI_MAP_PROP_NAME
#define CFAPI_MAP_PROP_NAME
Definition: plugin.h:251
cf_map_set_string_property
void cf_map_set_string_property(mapstruct *map, int propcode, const char *value)
Definition: plugin_common.cpp:305
llevInfo
@ llevInfo
Information.
Definition: logger.h:12
NDI_UNIQUE
#define NDI_UNIQUE
Print immediately, don't buffer.
Definition: newclient.h:266
Crossfire_Map::valid
int valid
Definition: cfpython_map.h:35
Crossfire_Map_Long
static PyObject * Crossfire_Map_Long(PyObject *obj)
Definition: cfpython_map.cpp:409
Map_GetResetTimeout
static PyObject * Map_GetResetTimeout(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:105
cf_map_trigger_connected
void cf_map_trigger_connected(objectlink *ol, object *cause, int state)
Wrapper for trigger_connected().
Definition: plugin_common.cpp:1037
mapstruct
This is a game-map.
Definition: map.h:320
Map_TriggerConnected
static PyObject * Map_TriggerConnected(Crossfire_Map *map, PyObject *args)
Python backend method for Map.TriggerConnected(int connected, CfObject cause, int state)
Definition: cfpython_map.cpp:325
Map_GetPlayers
static PyObject * Map_GetPlayers(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:111
find_assoc_pymap
static Crossfire_Map * find_assoc_pymap(mapstruct *key)
Definition: cfpython_map.cpp:40
Map_GetFirstObjectAt
static PyObject * Map_GetFirstObjectAt(Crossfire_Map *map, PyObject *args)
Definition: cfpython_map.cpp:204
Map_GetResetTime
static PyObject * Map_GetResetTime(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:99
Map_GetRegion
static PyObject * Map_GetRegion(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:164
cf_map_get_wparty
int cf_map_get_wparty(mapstruct *map)
Definition: plugin_common.cpp:1430
mapstruct::in_memory
uint32_t in_memory
Combination of IN_MEMORY_xxx flags.
Definition: map.h:340
MapMethods
static PyMethodDef MapMethods[]
Definition: cfpython_map.cpp:493
Map_GetDarkness
static PyObject * Map_GetDarkness(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:117
ensure_map_in_memory
static void ensure_map_in_memory(Crossfire_Map *map)
This makes sure the map is in memory and not swapped out.
Definition: cfpython_map.cpp:51
Crossfire_Map_dealloc
static void Crossfire_Map_dealloc(PyObject *obj)
Definition: cfpython_map.cpp:429
Map_Check
static PyObject * Map_Check(Crossfire_Map *map, PyObject *args)
Definition: cfpython_map.cpp:240
Map_GetWPartX
static PyObject * Map_GetWPartX(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:147
MAP_PLAYER_UNIQUE
#define MAP_PLAYER_UNIQUE
This map is player-specific.
Definition: map.h:97
cf_map_get_difficulty
int cf_map_get_difficulty(mapstruct *map)
Definition: plugin_common.cpp:1389
Map_GetName
static PyObject * Map_GetName(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:93
cf_map_get_darkness
int cf_map_get_darkness(mapstruct *map)
Definition: plugin_common.cpp:1405
cf_map_get_map
mapstruct * cf_map_get_map(const char *name, int flags)
Wrapper for ready_map_name().
Definition: plugin_common.cpp:944
Map_InternalCompare
static int Map_InternalCompare(Crossfire_Map *left, Crossfire_Map *right)
Definition: cfpython_map.cpp:365
Map_GetMessage
static PyObject * Map_GetMessage(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:158
Crossfire_Map_wrap
PyObject * Crossfire_Map_wrap(mapstruct *what)
Definition: cfpython_map.cpp:446
Crossfire_Map
Definition: cfpython_map.h:32
Map_GetWidth
static PyObject * Map_GetWidth(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:123
Crossfire_ObjectType
PyTypeObject Crossfire_ObjectType
cf_map_find_by_archetype_name
object * cf_map_find_by_archetype_name(const char *str, mapstruct *map, int nx, int ny)
Kinda wrapper for map_find_by_archetype_name().
Definition: plugin_common.cpp:1380
Map_GetEnterX
static PyObject * Map_GetEnterX(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:135
cf_map_get_width
int cf_map_get_width(mapstruct *map)
Definition: plugin_common.cpp:1409
cf_map_change_light
int cf_map_change_light(mapstruct *m, int change)
Wrapper for change_map_light().
Definition: plugin_common.cpp:1439
Map_Next
static PyObject * Map_Next(Crossfire_Map *map, PyObject *args)
Definition: cfpython_map.cpp:264
Map_CreateObject
static PyObject * Map_CreateObject(Crossfire_Map *map, PyObject *args)
Definition: cfpython_map.cpp:220
llevDebug
@ llevDebug
Only for debugging purposes.
Definition: logger.h:13
Crossfire_Map_RichCompare
static PyObject * Crossfire_Map_RichCompare(Crossfire_Map *left, Crossfire_Map *right, int op)
Definition: cfpython_map.cpp:371
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
Map_InsertAround
static PyObject * Map_InsertAround(Crossfire_Map *map, PyObject *args)
Definition: cfpython_map.cpp:285
CF_PYTHON_NUMBER_METHODS
CF_PYTHON_NUMBER_METHODS(Map, Crossfire_Map_Long)
Map_GetWPartY
static PyObject * Map_GetWPartY(Crossfire_Map *whoptr, void *closure)
Definition: cfpython_map.cpp:152
Crossfire_MapType
PyTypeObject Crossfire_MapType