Crossfire Server, Branch 1.12  R12190
cfpython_object.h
Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /* CFPython - A Python module for Crossfire RPG.                             */
00003 /* Version: 2.0beta8 (also known as "Alexander")                             */
00004 /* Contact: yann.chachkoff@myrealbox.com                                     */
00005 /*****************************************************************************/
00006 /* That code is placed under the GNU General Public Licence (GPL)            */
00007 /* (C)2001-2005 by Chachkoff Yann (Feel free to deliver your complaints)     */
00008 /*****************************************************************************/
00009 /*  CrossFire, A Multiplayer game for X-windows                              */
00010 /*                                                                           */
00011 /*  Copyright (C) 2000 Mark Wedel                                            */
00012 /*  Copyright (C) 1992 Frank Tore Johansen                                   */
00013 /*                                                                           */
00014 /*  This program is free software; you can redistribute it and/or modify     */
00015 /*  it under the terms of the GNU General Public License as published by     */
00016 /*  the Free Software Foundation; either version 2 of the License, or        */
00017 /*  (at your option) any later version.                                      */
00018 /*                                                                           */
00019 /*  This program is distributed in the hope that it will be useful,          */
00020 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of           */
00021 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            */
00022 /*  GNU General Public License for more details.                             */
00023 /*                                                                           */
00024 /*  You should have received a copy of the GNU General Public License        */
00025 /*  along with this program; if not, write to the Free Software              */
00026 /*  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
00027 /*                                                                           */
00028 /*****************************************************************************/
00029 #ifndef CFPYTHON_OBJECT_H
00030 #define CFPYTHON_OBJECT_H
00031 
00032 typedef struct {
00033     PyObject_HEAD
00034     object *obj;
00035     tag_t count;
00036 } Crossfire_Object;
00037 
00038 extern PyTypeObject Crossfire_ObjectType;
00039 
00040 typedef struct {
00041     PyObject_HEAD
00042     object *obj;
00043     tag_t count;
00044 } Crossfire_Player;
00045 
00046 extern PyTypeObject Crossfire_PlayerType;
00047 
00048 #define EXISTCHECK(ob) { \
00049     if (!ob || !ob->obj || (was_destroyed(ob->obj, ob->obj->count))) { \
00050         PyErr_SetString(PyExc_ReferenceError, "Crossfire object no longer exists"); \
00051         return NULL; \
00052     } }
00053 
00059 #define TYPEEXISTCHECK(ob) { \
00060     if (!ob || !PyObject_TypeCheck((PyObject*)ob, &Crossfire_ObjectType) || !ob->obj || (was_destroyed(ob->obj, ob->obj->count))) { \
00061         PyErr_SetString(PyExc_ReferenceError, "Not a Crossfire object or Crossfire object no longer exists"); \
00062         return NULL; \
00063     } }
00064 
00065 #define EXISTCHECK_INT(ob) { \
00066     if (!ob || !ob->obj || (was_destroyed(ob->obj, ob->obj->count))) { \
00067         PyErr_SetString(PyExc_ReferenceError, "Crossfire object no longer exists"); \
00068         return -1; \
00069     } }
00070 
00071 #endif /* CFPYTHON_OBJECT_H */