Crossfire Server, Branch 1.12  R12190
cfpython_object.c
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 
00030 #include <cfpython.h>
00031 #include <cfpython_object_private.h>
00032 #include <hashtable.h>
00033 
00034 /* Table for keeping track of which PyObject goes with with Crossfire object */
00035 static ptr_assoc_table object_assoc_table;
00036 
00037 /* Helper functions for dealing with object_assoc_table */
00038 void init_object_assoc_table(void) {
00039     init_ptr_assoc_table(object_assoc_table);
00040 }
00041 
00042 static void add_object_assoc(object *key, PyObject *value) {
00043     add_ptr_assoc(object_assoc_table, key, value);
00044 }
00045 
00046 static PyObject *find_assoc_pyobject(object *key) {
00047     return (PyObject *)find_assoc_value(object_assoc_table, key);
00048 }
00049 
00050 static void free_object_assoc(object *key) {
00051     free_ptr_assoc(object_assoc_table, key);
00052 }
00053 
00054 static PyObject *Player_GetTitle(Crossfire_Object *whoptr, void *closure) {
00055     EXISTCHECK(whoptr);
00056     return Py_BuildValue("s", cf_player_get_title(whoptr->obj));
00057 }
00058 
00059 static int Player_SetTitle(Crossfire_Object *whoptr, PyObject *value, void *closure) {
00060     char *val;
00061 
00062     EXISTCHECK_INT(whoptr);
00063     if (value == NULL) {
00064         PyErr_SetString(PyExc_TypeError, "Cannot delete the Title attribute");
00065         return -1;
00066     }
00067     if (!CF_IS_PYSTR(value)) {
00068         PyErr_SetString(PyExc_TypeError, "The Title attribute must be a string");
00069         return -1;
00070     }
00071     if (!PyArg_Parse(value, "s", &val))
00072         return -1;
00073 
00074     cf_player_set_title(whoptr->obj, val);
00075     return 0;
00076 }
00077 
00078 static PyObject *Player_GetIP(Crossfire_Player *whoptr, void *closure) {
00079     EXISTCHECK(whoptr);
00080     return Py_BuildValue("s", cf_player_get_ip(whoptr->obj));
00081 }
00082 
00083 static PyObject *Player_GetMarkedItem(Crossfire_Player *whoptr, void *closure) {
00084     EXISTCHECK(whoptr);
00085     return Crossfire_Object_wrap(cf_player_get_marked_item(whoptr->obj));
00086 }
00087 
00088 static int Player_SetMarkedItem(Crossfire_Player *whoptr, PyObject *value, void *closure) {
00089     Crossfire_Object *ob;
00090 
00091     EXISTCHECK_INT(whoptr);
00092     if (!PyArg_Parse(value, "O!", &Crossfire_ObjectType, &ob))
00093         return -1;
00094         cf_player_set_marked_item(whoptr->obj, ob->obj);
00095         return 0;
00096 }
00097 
00098 static PyObject *Crossfire_Player_Message(Crossfire_Player *who, PyObject *args) {
00099     char *message;
00100     int color  = NDI_UNIQUE|NDI_ORANGE;
00101 
00102     EXISTCHECK(who);
00103     if (!PyArg_ParseTuple(args, "s|i", &message, &color))
00104         return NULL;
00105 
00106     cf_player_message(who->obj, message, color);
00107     Py_INCREF(Py_None);
00108     return Py_None;
00109 }
00110 
00111 static PyObject *Player_GetParty(Crossfire_Player *whoptr, void *closure) {
00112     EXISTCHECK(whoptr);
00113     return Crossfire_Party_wrap(cf_player_get_party(whoptr->obj));
00114 }
00115 
00116 static int Player_SetParty(Crossfire_Player *whoptr, PyObject *value, void *closure) {
00117     Crossfire_Party *ob;
00118 
00119     EXISTCHECK_INT(whoptr);
00120     if (!PyArg_Parse(value, "O!", &Crossfire_PartyType, &ob))
00121         return -1;
00122     cf_player_set_party(whoptr->obj, ob->party);
00123     return 0;
00124 }
00125 
00126 static PyObject *Crossfire_Player_CanPay(Crossfire_Player *who, PyObject *args) {
00127     EXISTCHECK(who);
00128     return Py_BuildValue("i", cf_player_can_pay(who->obj));
00129 }
00130 
00131 static PyObject *Player_GetBedMap(Crossfire_Player *whoptr, void *closure) {
00132     char bed[200];
00133 
00134     EXISTCHECK(whoptr);
00135     return Py_BuildValue("s", cf_object_get_string_property(whoptr->obj, CFAPI_PLAYER_PROP_BED_MAP, bed, sizeof(bed)));
00136 }
00137 
00138 static int Player_SetBedMap(Crossfire_Player *whoptr, PyObject *value, void *closure) {
00139     char *location;
00140 
00141     EXISTCHECK_INT(whoptr);
00142     if (!PyArg_Parse(value, "s", &location))
00143         return -1;
00144     cf_object_set_string_property(whoptr->obj, CFAPI_PLAYER_PROP_BED_MAP, location);
00145     return 0;
00146 }
00147 
00148 static PyObject *Player_GetBedX(Crossfire_Player *whoptr, void *closure) {
00149     EXISTCHECK(whoptr);
00150     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_PLAYER_PROP_BED_X));
00151 }
00152 
00153 static int Player_SetBedX(Crossfire_Player *whoptr, PyObject *value, void *closure) {
00154     int x;
00155 
00156     EXISTCHECK_INT(whoptr);
00157     if (!PyArg_Parse(value, "i", &x))
00158         return -1;
00159     cf_object_set_int_property(whoptr->obj, CFAPI_PLAYER_PROP_BED_X, x);
00160     return 0;
00161 }
00162 
00163 static PyObject *Player_GetBedY(Crossfire_Player *whoptr, void *closure) {
00164     EXISTCHECK(whoptr);
00165     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_PLAYER_PROP_BED_Y));
00166 }
00167 
00168 static int Player_SetBedY(Crossfire_Player *whoptr, PyObject *value, void *closure) {
00169     int y;
00170 
00171     EXISTCHECK_INT(whoptr);
00172     if (!PyArg_Parse(value, "i", &y))
00173         return -1;
00174     cf_object_set_int_property(whoptr->obj, CFAPI_PLAYER_PROP_BED_Y, y);
00175     return 0;
00176 }
00177 
00178 /* Object properties. Get and maybe set. */
00179 static PyObject *Object_GetName(Crossfire_Object *whoptr, void *closure) {
00180     char name[200];
00181 
00182     EXISTCHECK(whoptr);
00183     return Py_BuildValue("s", cf_query_name(whoptr->obj, name, sizeof(name)));
00184 }
00185 
00186 static PyObject *Object_GetNamePl(Crossfire_Object *whoptr, void *closure) {
00187     EXISTCHECK(whoptr);
00188     return Py_BuildValue("s", (char *)cf_query_name_pl(whoptr->obj));
00189 }
00190 
00191 static PyObject *Object_GetTitle(Crossfire_Object *whoptr, void *closure) {
00192     EXISTCHECK(whoptr);
00193     return Py_BuildValue("s", cf_object_get_sstring_property(whoptr->obj, CFAPI_OBJECT_PROP_TITLE));
00194 }
00195 
00196 static PyObject *Object_GetRace(Crossfire_Object *whoptr, void *closure) {
00197     EXISTCHECK(whoptr);
00198     return Py_BuildValue("s", cf_object_get_sstring_property(whoptr->obj, CFAPI_OBJECT_PROP_RACE));
00199 }
00200 
00201 static PyObject *Object_GetMap(Crossfire_Object *whoptr, void *closure) {
00202     mapstruct *m;
00203 
00204     EXISTCHECK(whoptr);
00205     m = cf_object_get_map_property(whoptr->obj, CFAPI_OBJECT_PROP_MAP);
00206     return Crossfire_Map_wrap(m);
00207 }
00208 
00209 static PyObject *Object_GetCha(Crossfire_Object *whoptr, void *closure) {
00210     EXISTCHECK(whoptr);
00211     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_CHA));
00212 }
00213 
00214 static PyObject *Object_GetCon(Crossfire_Object *whoptr, void *closure) {
00215     EXISTCHECK(whoptr);
00216     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_CON));
00217 }
00218 
00219 static PyObject *Object_GetDex(Crossfire_Object *whoptr, void *closure) {
00220     EXISTCHECK(whoptr);
00221     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_DEX));
00222 }
00223 
00224 static PyObject *Object_GetInt(Crossfire_Object *whoptr, void *closure) {
00225     EXISTCHECK(whoptr);
00226     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_INT));
00227 }
00228 
00229 static PyObject *Object_GetPow(Crossfire_Object *whoptr, void *closure) {
00230     EXISTCHECK(whoptr);
00231     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_POW));
00232 }
00233 
00234 static PyObject *Object_GetStr(Crossfire_Object *whoptr, void *closure) {
00235     EXISTCHECK(whoptr);
00236     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_STR));
00237 }
00238 
00239 static PyObject *Object_GetWis(Crossfire_Object *whoptr, void *closure) {
00240     EXISTCHECK(whoptr);
00241     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_WIS));
00242 }
00243 
00244 static PyObject *Object_GetHP(Crossfire_Object *whoptr, void *closure) {
00245     EXISTCHECK(whoptr);
00246     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_HP));
00247 }
00248 
00249 static PyObject *Object_GetMaxHP(Crossfire_Object *whoptr, void *closure) {
00250     EXISTCHECK(whoptr);
00251     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_MAXHP));
00252 }
00253 
00254 static PyObject *Object_GetSP(Crossfire_Object *whoptr, void *closure) {
00255     EXISTCHECK(whoptr);
00256     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_SP));
00257 }
00258 
00259 static PyObject *Object_GetMaxSP(Crossfire_Object *whoptr, void *closure) {
00260     EXISTCHECK(whoptr);
00261     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_MAXSP));
00262 }
00263 
00264 static PyObject *Object_GetGrace(Crossfire_Object *whoptr, void *closure) {
00265     EXISTCHECK(whoptr);
00266     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_GP));
00267 }
00268 
00269 static PyObject *Object_GetMaxGrace(Crossfire_Object *whoptr, void *closure) {
00270     EXISTCHECK(whoptr);
00271     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_MAXGP));
00272 }
00273 
00274 static PyObject *Object_GetFood(Crossfire_Object *whoptr, void *closure) {
00275     EXISTCHECK(whoptr);
00276     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_FP));
00277 }
00278 
00279 static PyObject *Object_GetAC(Crossfire_Object *whoptr, void *closure) {
00280     EXISTCHECK(whoptr);
00281     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_AC));
00282 }
00283 
00284 static PyObject *Object_GetWC(Crossfire_Object *whoptr, void *closure) {
00285     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_WC));
00286 }
00287 
00288 static PyObject *Object_GetDam(Crossfire_Object *whoptr, void *closure) {
00289     EXISTCHECK(whoptr);
00290     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_DAM));
00291 }
00292 
00293 static PyObject *Object_GetLuck(Crossfire_Object *whoptr, void *closure) {
00294     EXISTCHECK(whoptr);
00295     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_LUCK));
00296 }
00297 
00298 static PyObject *Object_GetMessage(Crossfire_Object *whoptr, void *closure) {
00299     EXISTCHECK(whoptr);
00300     return Py_BuildValue("s", cf_object_get_sstring_property(whoptr->obj, CFAPI_OBJECT_PROP_MESSAGE));
00301 }
00302 
00303 static PyObject *Object_GetSkill(Crossfire_Object *whoptr, void *closure) {
00304     EXISTCHECK(whoptr);
00305     return Py_BuildValue("s", cf_object_get_sstring_property(whoptr->obj, CFAPI_OBJECT_PROP_SKILL));
00306 }
00307 
00308 static PyObject *Object_GetExp(Crossfire_Object *whoptr, void *closure) {
00309     EXISTCHECK(whoptr);
00310     return Py_BuildValue("L", cf_object_get_int64_property(whoptr->obj, CFAPI_OBJECT_PROP_EXP));
00311 }
00312 
00313 static PyObject *Object_GetPermExp(Crossfire_Object *whoptr, void *closure) {
00314     EXISTCHECK(whoptr);
00315     return Py_BuildValue("L", cf_object_get_int64_property(whoptr->obj, CFAPI_OBJECT_PROP_PERM_EXP));
00316 }
00317 
00318 static PyObject *Object_GetExpMul(Crossfire_Object *whoptr, void *closure) {
00319     EXISTCHECK(whoptr);
00320     return Py_BuildValue("d", cf_object_get_double_property(whoptr->obj, CFAPI_OBJECT_PROP_EXP_MULTIPLIER));
00321 }
00322 
00323 static PyObject *Object_GetSlaying(Crossfire_Object *whoptr, void *closure) {
00324     EXISTCHECK(whoptr);
00325     return Py_BuildValue("s", cf_object_get_sstring_property(whoptr->obj, CFAPI_OBJECT_PROP_SLAYING));
00326 }
00327 
00328 static PyObject *Object_GetCursed(Crossfire_Object *whoptr, void *closure) {
00329     EXISTCHECK(whoptr);
00330     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_CURSED));
00331 }
00332 
00333 static PyObject *Object_GetDamned(Crossfire_Object *whoptr, void *closure) {
00334     EXISTCHECK(whoptr);
00335     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_DAMNED));
00336 }
00337 
00338 static PyObject *Object_GetWeight(Crossfire_Object *whoptr, void *closure) {
00339     EXISTCHECK(whoptr);
00340     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_WEIGHT));
00341 }
00342 
00343 static PyObject *Object_GetWeightLimit(Crossfire_Object *whoptr, void *closure) {
00344     EXISTCHECK(whoptr);
00345     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_WEIGHT_LIMIT));
00346 }
00347 
00348 static PyObject *Object_GetAbove(Crossfire_Object *whoptr, void *closure) {
00349     object *op;
00350 
00351     EXISTCHECK(whoptr);
00352     op = cf_object_get_object_property(whoptr->obj, CFAPI_OBJECT_PROP_OB_ABOVE);
00353     return Crossfire_Object_wrap(op);
00354 }
00355 
00356 static PyObject *Object_GetBelow(Crossfire_Object *whoptr, void *closure) {
00357     object *op;
00358 
00359     EXISTCHECK(whoptr);
00360     op = cf_object_get_object_property(whoptr->obj, CFAPI_OBJECT_PROP_OB_BELOW);
00361     return Crossfire_Object_wrap(op);
00362 }
00363 
00364 static PyObject *Object_GetInventory(Crossfire_Object *whoptr, void *closure) {
00365     object *op;
00366 
00367     EXISTCHECK(whoptr);
00368     op = cf_object_get_object_property(whoptr->obj, CFAPI_OBJECT_PROP_INVENTORY);
00369     return Crossfire_Object_wrap(op);
00370 }
00371 
00372 static PyObject *Object_GetX(Crossfire_Object *whoptr, void *closure) {
00373     EXISTCHECK(whoptr);
00374     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_X));
00375 }
00376 
00377 static PyObject *Object_GetY(Crossfire_Object *whoptr, void *closure) {
00378     EXISTCHECK(whoptr);
00379     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_Y));
00380 }
00381 
00382 static PyObject *Object_GetDirection(Crossfire_Object *whoptr, void *closure) {
00383     EXISTCHECK(whoptr);
00384     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_DIRECTION));
00385 }
00386 
00387 static PyObject *Object_GetFacing(Crossfire_Object *whoptr, void *closure) {
00388     EXISTCHECK(whoptr);
00389     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_FACING));
00390 }
00391 
00392 static PyObject *Object_GetUnaggressive(Crossfire_Object *whoptr, void *closure) {
00393     EXISTCHECK(whoptr);
00394     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_UNAGGRESSIVE));
00395 }
00396 
00397 static PyObject *Object_GetGod(Crossfire_Object *whoptr, void *closure) {
00398     EXISTCHECK(whoptr);
00399     return Py_BuildValue("s", cf_object_get_sstring_property(whoptr->obj, CFAPI_OBJECT_PROP_GOD));
00400 }
00401 
00402 static PyObject *Object_GetPickable(Crossfire_Object *whoptr, void *closure) {
00403     EXISTCHECK(whoptr);
00404     return Py_BuildValue("i", !cf_object_get_flag(whoptr->obj, FLAG_NO_PICK));
00405 }
00406 
00407 static PyObject *Object_GetQuantity(Crossfire_Object *whoptr, void *closure) {
00408     EXISTCHECK(whoptr);
00409     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_NROF));
00410 }
00411 
00412 static PyObject *Object_GetInvisible(Crossfire_Object *whoptr, void *closure) {
00413     EXISTCHECK(whoptr);
00414     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_INVISIBLE));
00415 }
00416 
00417 static PyObject *Object_GetSpeed(Crossfire_Object *whoptr, void *closure) {
00418     EXISTCHECK(whoptr);
00419     return Py_BuildValue("f", cf_object_get_float_property(whoptr->obj, CFAPI_OBJECT_PROP_SPEED));
00420 }
00421 
00422 static PyObject *Object_GetSpeedLeft(Crossfire_Object *whoptr, void *closure) {
00423     EXISTCHECK(whoptr);
00424     return Py_BuildValue("f", cf_object_get_float_property(whoptr->obj, CFAPI_OBJECT_PROP_SPEED_LEFT));
00425 }
00426 
00427 static PyObject *Object_GetLastSP(Crossfire_Object *whoptr, void *closure) {
00428     EXISTCHECK(whoptr);
00429     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_LAST_SP));
00430 }
00431 
00432 static PyObject *Object_GetLastGrace(Crossfire_Object *whoptr, void *closure) {
00433     EXISTCHECK(whoptr);
00434     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_LAST_GRACE));
00435 }
00436 
00437 static PyObject *Object_GetLastEat(Crossfire_Object *whoptr, void *closure) {
00438     EXISTCHECK(whoptr);
00439     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_LAST_EAT));
00440 }
00441 
00442 static PyObject *Object_GetLevel(Crossfire_Object *whoptr, void *closure) {
00443     EXISTCHECK(whoptr);
00444     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_LEVEL));
00445 }
00446 
00447 static PyObject *Object_GetFace(Crossfire_Object *whoptr, void *closure) {
00448     EXISTCHECK(whoptr);
00449     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_FACE));
00450 }
00451 
00452 static PyObject *Object_GetAnim(Crossfire_Object *whoptr, void *closure) {
00453     EXISTCHECK(whoptr);
00454     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_ANIMATION));
00455 }
00456 
00457 static PyObject *Object_GetAnimSpeed(Crossfire_Object *whoptr, void *closure) {
00458     EXISTCHECK(whoptr);
00459     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_ANIM_SPEED));
00460 }
00461 
00462 static PyObject *Object_GetAttackType(Crossfire_Object *whoptr, void *closure) {
00463     EXISTCHECK(whoptr);
00464     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_ATTACK_TYPE));
00465 }
00466 
00467 static PyObject *Object_GetBeenApplied(Crossfire_Object *whoptr, void *closure) {
00468     EXISTCHECK(whoptr);
00469     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_BEEN_APPLIED));
00470 }
00471 
00472 static PyObject *Object_GetIdentified(Crossfire_Object *whoptr, void *closure) {
00473     EXISTCHECK(whoptr);
00474     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_IDENTIFIED));
00475 }
00476 
00477 static PyObject *Object_GetAlive(Crossfire_Object *whoptr, void *closure) {
00478     EXISTCHECK(whoptr);
00479     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_ALIVE));
00480 }
00481 
00482 static PyObject *Object_GetDM(Crossfire_Object *whoptr, void *closure) {
00483     EXISTCHECK(whoptr);
00484     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_WIZ));
00485 }
00486 
00487 static PyObject *Object_GetWasDM(Crossfire_Object *whoptr, void *closure) {
00488     EXISTCHECK(whoptr);
00489     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_WAS_WIZ));
00490 }
00491 
00492 static PyObject *Object_GetApplied(Crossfire_Object *whoptr, void *closure) {
00493     EXISTCHECK(whoptr);
00494     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_APPLIED));
00495 }
00496 
00497 static PyObject *Object_GetUnpaid(Crossfire_Object *whoptr, void *closure) {
00498     EXISTCHECK(whoptr);
00499     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_UNPAID));
00500 }
00501 
00502 static PyObject *Object_GetMonster(Crossfire_Object *whoptr, void *closure) {
00503     EXISTCHECK(whoptr);
00504     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_MONSTER));
00505 }
00506 
00507 static PyObject *Object_GetFriendly(Crossfire_Object *whoptr, void *closure) {
00508     EXISTCHECK(whoptr);
00509     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_FRIENDLY));
00510 }
00511 
00512 static PyObject *Object_GetGenerator(Crossfire_Object *whoptr, void *closure) {
00513     EXISTCHECK(whoptr);
00514     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_GENERATOR));
00515 }
00516 
00517 static PyObject *Object_GetThrown(Crossfire_Object *whoptr, void *closure) {
00518     EXISTCHECK(whoptr);
00519     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_IS_THROWN));
00520 }
00521 
00522 static PyObject *Object_GetCanSeeInvisible(Crossfire_Object *whoptr, void *closure) {
00523     EXISTCHECK(whoptr);
00524     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_SEE_INVISIBLE));
00525 }
00526 
00527 static PyObject *Object_GetRollable(Crossfire_Object *whoptr, void *closure) {
00528     EXISTCHECK(whoptr);
00529     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_CAN_ROLL));
00530 }
00531 
00532 static PyObject *Object_GetTurnable(Crossfire_Object *whoptr, void *closure) {
00533     EXISTCHECK(whoptr);
00534     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_IS_TURNABLE));
00535 }
00536 
00537 static PyObject *Object_GetUsedUp(Crossfire_Object *whoptr, void *closure) {
00538     EXISTCHECK(whoptr);
00539     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_IS_USED_UP));
00540 }
00541 
00542 static PyObject *Object_GetSplitting(Crossfire_Object *whoptr, void *closure) {
00543     EXISTCHECK(whoptr);
00544     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_SPLITTING));
00545 }
00546 
00547 static PyObject *Object_GetBlind(Crossfire_Object *whoptr, void *closure) {
00548     EXISTCHECK(whoptr);
00549     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_BLIND));
00550 }
00551 
00552 static PyObject *Object_GetCanUseHorn(Crossfire_Object *whoptr, void *closure) {
00553     EXISTCHECK(whoptr);
00554     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_USE_HORN));
00555 }
00556 
00557 static PyObject *Object_GetCanUseRod(Crossfire_Object *whoptr, void *closure) {
00558     EXISTCHECK(whoptr);
00559     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_USE_ROD));
00560 }
00561 
00562 static PyObject *Object_GetCanUseSkill(Crossfire_Object *whoptr, void *closure) {
00563     EXISTCHECK(whoptr);
00564     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_CAN_USE_SKILL));
00565 }
00566 
00567 static PyObject *Object_GetKnownCursed(Crossfire_Object *whoptr, void *closure) {
00568     EXISTCHECK(whoptr);
00569     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_KNOWN_CURSED));
00570 }
00571 
00572 static PyObject *Object_GetStealthy(Crossfire_Object *whoptr, void *closure) {
00573     EXISTCHECK(whoptr);
00574     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_STEALTH));
00575 }
00576 
00577 static PyObject *Object_GetConfused(Crossfire_Object *whoptr, void *closure) {
00578     EXISTCHECK(whoptr);
00579     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_CONFUSED));
00580 }
00581 
00582 static PyObject *Object_GetSleeping(Crossfire_Object *whoptr, void *closure) {
00583     EXISTCHECK(whoptr);
00584     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_SLEEP));
00585 }
00586 
00587 static PyObject *Object_GetLifesaver(Crossfire_Object *whoptr, void *closure) {
00588     EXISTCHECK(whoptr);
00589     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_LIFESAVE));
00590 }
00591 
00592 static PyObject *Object_GetFloor(Crossfire_Object *whoptr, void *closure) {
00593     EXISTCHECK(whoptr);
00594     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_IS_FLOOR));
00595 }
00596 
00597 static PyObject *Object_GetHasXRays(Crossfire_Object *whoptr, void *closure) {
00598     EXISTCHECK(whoptr);
00599     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_XRAYS));
00600 }
00601 
00602 static PyObject *Object_GetCanUseRing(Crossfire_Object *whoptr, void *closure) {
00603     EXISTCHECK(whoptr);
00604     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_USE_RING));
00605 }
00606 
00607 static PyObject *Object_GetCanUseBow(Crossfire_Object *whoptr, void *closure) {
00608     EXISTCHECK(whoptr);
00609     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_USE_BOW));
00610 }
00611 
00612 static PyObject *Object_GetCanUseWand(Crossfire_Object *whoptr, void *closure) {
00613     EXISTCHECK(whoptr);
00614     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_USE_RANGE));
00615 }
00616 
00617 static PyObject *Object_GetCanSeeInDark(Crossfire_Object *whoptr, void *closure) {
00618     EXISTCHECK(whoptr);
00619     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_SEE_IN_DARK));
00620 }
00621 
00622 static PyObject *Object_GetKnownMagical(Crossfire_Object *whoptr, void *closure) {
00623     EXISTCHECK(whoptr);
00624     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_KNOWN_MAGICAL));
00625 }
00626 
00627 static PyObject *Object_GetCanUseWeapon(Crossfire_Object *whoptr, void *closure) {
00628     EXISTCHECK(whoptr);
00629     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_USE_WEAPON));
00630 }
00631 
00632 static PyObject *Object_GetCanUseArmour(Crossfire_Object *whoptr, void *closure) {
00633     EXISTCHECK(whoptr);
00634     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_USE_ARMOUR));
00635 }
00636 
00637 static PyObject *Object_GetCanUseScroll(Crossfire_Object *whoptr, void *closure) {
00638     EXISTCHECK(whoptr);
00639     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_USE_SCROLL));
00640 }
00641 
00642 static PyObject *Object_GetCanCastSpell(Crossfire_Object *whoptr, void *closure) {
00643     EXISTCHECK(whoptr);
00644     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_CAST_SPELL));
00645 }
00646 
00647 static PyObject *Object_GetReflectSpells(Crossfire_Object *whoptr, void *closure) {
00648     EXISTCHECK(whoptr);
00649     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_REFL_SPELL));
00650 }
00651 
00652 static PyObject *Object_GetReflectMissiles(Crossfire_Object *whoptr, void *closure) {
00653     EXISTCHECK(whoptr);
00654     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_REFL_MISSILE));
00655 }
00656 
00657 static PyObject *Object_GetUnique(Crossfire_Object *whoptr, void *closure) {
00658     EXISTCHECK(whoptr);
00659     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_UNIQUE));
00660 }
00661 
00662 static PyObject *Object_GetRunAway(Crossfire_Object *whoptr, void *closure) {
00663     EXISTCHECK(whoptr);
00664     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_RUN_AWAY));
00665 }
00666 
00667 static PyObject *Object_GetScared(Crossfire_Object *whoptr, void *closure) {
00668     EXISTCHECK(whoptr);
00669     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_SCARED));
00670 }
00671 
00672 static PyObject *Object_GetUndead(Crossfire_Object *whoptr, void *closure) {
00673     EXISTCHECK(whoptr);
00674     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_UNDEAD));
00675 }
00676 
00677 static PyObject *Object_GetBlocksView(Crossfire_Object *whoptr, void *closure) {
00678     EXISTCHECK(whoptr);
00679     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_BLOCKSVIEW));
00680 }
00681 
00682 static PyObject *Object_GetHitBack(Crossfire_Object *whoptr, void *closure) {
00683     EXISTCHECK(whoptr);
00684     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_HITBACK));
00685 }
00686 
00687 static PyObject *Object_GetStandStill(Crossfire_Object *whoptr, void *closure) {
00688     EXISTCHECK(whoptr);
00689     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_STAND_STILL));
00690 }
00691 
00692 static PyObject *Object_GetOnlyAttack(Crossfire_Object *whoptr, void *closure) {
00693     EXISTCHECK(whoptr);
00694     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_ONLY_ATTACK));
00695 }
00696 
00697 static PyObject *Object_GetMakeInvisible(Crossfire_Object *whoptr, void *closure) {
00698     EXISTCHECK(whoptr);
00699     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_MAKE_INVIS));
00700 }
00701 
00702 static PyObject *Object_GetMoney(Crossfire_Object *whoptr, void *closure) {
00703     EXISTCHECK(whoptr);
00704     return Py_BuildValue("i", cf_object_query_money(whoptr->obj));
00705 }
00706 
00707 static PyObject *Object_GetType(Crossfire_Object *whoptr, void *closure) {
00708     EXISTCHECK(whoptr);
00709     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_TYPE));
00710 }
00711 
00712 static PyObject *Object_GetSubtype(Crossfire_Object *whoptr, void *closure) {
00713     EXISTCHECK(whoptr);
00714     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_SUBTYPE));
00715 }
00716 
00717 static PyObject *Object_GetValue(Crossfire_Object *whoptr, void *closure) {
00718     EXISTCHECK(whoptr);
00719     return Py_BuildValue("l", cf_object_get_long_property(whoptr->obj, CFAPI_OBJECT_PROP_VALUE));
00720 }
00721 
00722 static PyObject *Object_GetArchName(Crossfire_Object *whoptr, void *closure) {
00723     EXISTCHECK(whoptr);
00724     return Py_BuildValue("s", cf_object_get_sstring_property(whoptr->obj, CFAPI_OBJECT_PROP_ARCH_NAME));
00725 }
00726 
00727 static PyObject *Object_GetArchetype(Crossfire_Object *whoptr, void *closure) {
00728     EXISTCHECK(whoptr);
00729     return Crossfire_Archetype_wrap(cf_object_get_archetype_property(whoptr->obj, CFAPI_OBJECT_PROP_ARCHETYPE));
00730 }
00731 
00732 static PyObject *Object_GetNoSave(Crossfire_Object *whoptr, void *closure) {
00733     EXISTCHECK(whoptr);
00734     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_NO_SAVE));
00735 }
00736 
00737 static PyObject *Object_GetExists(Crossfire_Object *whoptr, void *closure) {
00738     if (!was_destroyed(whoptr->obj, whoptr->obj->count)) {
00739         Py_INCREF(Py_True);
00740         return Py_True;
00741     } else {
00742         Py_INCREF(Py_False);
00743         return Py_False;
00744     }
00745 }
00746 
00747 static PyObject *Object_GetEnv(Crossfire_Object *whoptr, void *closure) {
00748     EXISTCHECK(whoptr);
00749     return Crossfire_Object_wrap(cf_object_get_object_property(whoptr->obj, CFAPI_OBJECT_PROP_ENVIRONMENT));
00750 }
00751 
00752 static PyObject *Object_GetMoveType(Crossfire_Object *whoptr, void *closure) {
00753     EXISTCHECK(whoptr);
00754     return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_TYPE));
00755 }
00756 
00757 static PyObject *Object_GetMoveBlock(Crossfire_Object *whoptr, void *closure) {
00758     EXISTCHECK(whoptr);
00759     return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_BLOCK));
00760 }
00761 
00762 static PyObject *Object_GetMoveAllow(Crossfire_Object *whoptr, void *closure) {
00763     EXISTCHECK(whoptr);
00764     return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_ALLOW));
00765 }
00766 
00767 static PyObject *Object_GetMoveOn(Crossfire_Object *whoptr, void *closure) {
00768     EXISTCHECK(whoptr);
00769     return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_ON));
00770 }
00771 
00772 static PyObject *Object_GetMoveOff(Crossfire_Object *whoptr, void *closure) {
00773     EXISTCHECK(whoptr);
00774     return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_OFF));
00775 }
00776 
00777 static PyObject *Object_GetMoveSlow(Crossfire_Object *whoptr, void *closure) {
00778     EXISTCHECK(whoptr);
00779     return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_SLOW));
00780 }
00781 
00782 static PyObject *Object_GetMoveSlowPenalty(Crossfire_Object *whoptr, void *closure) {
00783     EXISTCHECK(whoptr);
00784     return Py_BuildValue("f", cf_object_get_float_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY));
00785 }
00786 
00787 static PyObject *Object_GetOwner(Crossfire_Object *whoptr, void *closure) {
00788     EXISTCHECK(whoptr);
00789     return Crossfire_Object_wrap(cf_object_get_object_property(whoptr->obj, CFAPI_OBJECT_PROP_OWNER));
00790 }
00791 
00792 static PyObject *Object_GetEnemy(Crossfire_Object *whoptr, void *closure) {
00793     EXISTCHECK(whoptr);
00794     return Crossfire_Object_wrap(cf_object_get_object_property(whoptr->obj, CFAPI_OBJECT_PROP_ENEMY));
00795 }
00796 
00797 static PyObject *Object_GetCount(Crossfire_Object *whoptr, void *closure) {
00798     EXISTCHECK(whoptr);
00799     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_COUNT));
00800 }
00801 
00802 static PyObject *Object_GetGodGiven(Crossfire_Object *whoptr, void *closure) {
00803     EXISTCHECK(whoptr);
00804     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_STARTEQUIP));
00805 }
00806 
00807 static PyObject *Object_GetNoDamage(Crossfire_Object *whoptr, void *closure) {
00808     EXISTCHECK(whoptr);
00809     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_NO_DAMAGE));
00810 }
00811 
00812 static PyObject *Object_GetRandomMovement(Crossfire_Object *whoptr, void *closure) {
00813     EXISTCHECK(whoptr);
00814     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_RANDOM_MOVE));
00815 }
00816 
00817 static PyObject *Object_GetIsPet(Crossfire_Object *whoptr, void *closure) {
00818     EXISTCHECK(whoptr);
00819     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_FRIENDLY));
00820 }
00821 
00822 static PyObject *Object_GetAttackMovement(Crossfire_Object *whoptr, void *closure) {
00823     EXISTCHECK(whoptr);
00824     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_ATTACK_MOVEMENT));
00825 }
00826 
00827 static PyObject *Object_GetDuration(Crossfire_Object *whoptr, void *closure) {
00828     EXISTCHECK(whoptr);
00829     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_DURATION));
00830 }
00831 
00832 static PyObject *Object_GetGlowRadius(Crossfire_Object *whoptr, void *closure) {
00833     EXISTCHECK(whoptr);
00834     return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_GLOW_RADIUS));
00835 }
00836 
00837 static PyObject *Object_GetAnimated(Crossfire_Object *whoptr, void *closure) {
00838     EXISTCHECK(whoptr);
00839     return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, FLAG_ANIMATE));
00840 }
00841 
00843 static int Object_SetMessage(Crossfire_Object *whoptr, PyObject *value, void *closure) {
00844     char *val;
00845 
00846     EXISTCHECK_INT(whoptr);
00847     if (value == NULL) {
00848         PyErr_SetString(PyExc_TypeError, "Cannot delete the Message attribute");
00849         return -1;
00850     }
00851     if (!CF_IS_PYSTR(value)) {
00852         PyErr_SetString(PyExc_TypeError, "The Message attribute must be a string");
00853         return -1;
00854     }
00855     if (!PyArg_Parse(value, "s", &val))
00856         return -1;
00857 
00858     cf_object_set_string_property(whoptr->obj, CFAPI_OBJECT_PROP_MESSAGE, val);
00859     return 0;
00860 }
00861 
00862 static int Object_SetName(Crossfire_Object *whoptr, PyObject *value, void *closure) {
00863     char *val;
00864 
00865     EXISTCHECK_INT(whoptr);
00866     if (value == NULL) {
00867         PyErr_SetString(PyExc_TypeError, "Cannot delete the Name attribute");
00868         return -1;
00869     }
00870     if (!CF_IS_PYSTR(value)) {
00871         PyErr_SetString(PyExc_TypeError, "The Name attribute must be a string");
00872         return -1;
00873     }
00874     if (!PyArg_Parse(value, "s", &val))
00875         return -1;
00876 
00877     cf_object_set_string_property(whoptr->obj, CFAPI_OBJECT_PROP_NAME, val);
00878     cf_object_set_string_property(whoptr->obj, CFAPI_OBJECT_PROP_NAME_PLURAL, val);
00879     return 0;
00880 }
00881 
00882 static int Object_SetNamePl(Crossfire_Object *whoptr, PyObject *value, void *closure) {
00883     char *val;
00884 
00885     EXISTCHECK_INT(whoptr);
00886     if (value == NULL) {
00887         PyErr_SetString(PyExc_TypeError, "Cannot delete the NamePl attribute");
00888         return -1;
00889     }
00890     if (!CF_IS_PYSTR(value)) {
00891         PyErr_SetString(PyExc_TypeError, "The NamePl attribute must be a string");
00892         return -1;
00893     }
00894     if (!PyArg_Parse(value, "s", &val))
00895         return -1;
00896 
00897     cf_object_set_string_property(whoptr->obj, CFAPI_OBJECT_PROP_NAME_PLURAL, val);
00898     return 0;
00899 }
00900 
00901 static int Object_SetTitle(Crossfire_Object *whoptr, PyObject *value, void *closure) {
00902     char *val;
00903 
00904     EXISTCHECK_INT(whoptr);
00905     if (value == NULL) {
00906         PyErr_SetString(PyExc_TypeError, "Cannot delete the Title attribute");
00907         return -1;
00908     }
00909     if (!CF_IS_PYSTR(value)) {
00910         PyErr_SetString(PyExc_TypeError, "The Title attribute must be a string");
00911         return -1;
00912     }
00913     if (!PyArg_Parse(value, "s", &val))
00914         return -1;
00915 
00916     cf_object_set_string_property(whoptr->obj, CFAPI_OBJECT_PROP_TITLE, val);
00917     return 0;
00918 }
00919 
00920 static int Object_SetRace(Crossfire_Object *whoptr, PyObject *value, void *closure) {
00921     char *val;
00922 
00923     EXISTCHECK_INT(whoptr);
00924     if (value == NULL) {
00925         PyErr_SetString(PyExc_TypeError, "Cannot delete the Race attribute");
00926         return -1;
00927     }
00928     if (!CF_IS_PYSTR(value)) {
00929         PyErr_SetString(PyExc_TypeError, "The Race attribute must be a string");
00930         return -1;
00931     }
00932     if (!PyArg_Parse(value, "s", &val))
00933         return -1;
00934 
00935     cf_object_set_string_property(whoptr->obj, CFAPI_OBJECT_PROP_RACE, val);
00936     return 0;
00937 }
00938 
00939 static int Object_SetMap(Crossfire_Object *whoptr, PyObject *value, void *closure) {
00940     Crossfire_Map *val;
00941 
00942     EXISTCHECK_INT(whoptr);
00943     if (!PyArg_Parse(value, "O!", &Crossfire_MapType, &val))
00944         return -1;
00945 
00946     cf_object_change_map(whoptr->obj, val->map, NULL, 0, -1, -1);
00947     return 0;
00948 }
00949 
00950 static int Object_SetSlaying(Crossfire_Object *whoptr, PyObject *value, void *closure) {
00951     char *val;
00952 
00953     EXISTCHECK_INT(whoptr);
00954     if (value == NULL) {
00955         PyErr_SetString(PyExc_TypeError, "Cannot delete the Slaying attribute");
00956         return -1;
00957     }
00958     if (!CF_IS_PYSTR(value)) {
00959         PyErr_SetString(PyExc_TypeError, "The Slaying attribute must be a string");
00960         return -1;
00961     }
00962     if (!PyArg_Parse(value, "s", &val))
00963         return -1;
00964 
00965     cf_object_set_string_property(whoptr->obj, CFAPI_OBJECT_PROP_SLAYING, val);
00966     return 0;
00967 }
00968 
00969 static int Object_SetSkill(Crossfire_Object *whoptr, PyObject *value, void *closure) {
00970     char *val;
00971 
00972     EXISTCHECK_INT(whoptr);
00973     if (value == NULL) {
00974         PyErr_SetString(PyExc_TypeError, "Cannot delete the Skill attribute");
00975         return -1;
00976     }
00977     if (!CF_IS_PYSTR(value)) {
00978         PyErr_SetString(PyExc_TypeError, "The Skill attribute must be a string");
00979         return -1;
00980     }
00981     if (!PyArg_Parse(value, "s", &val))
00982         return -1;
00983 
00984     cf_object_set_string_property(whoptr->obj, CFAPI_OBJECT_PROP_SKILL, val);
00985     return 0;
00986 }
00987 
00988 static int Object_SetCursed(Crossfire_Object *whoptr, PyObject *value, void *closure) {
00989     int val;
00990 
00991     EXISTCHECK_INT(whoptr);
00992     if (!PyArg_Parse(value, "i", &val))
00993         return -1;
00994 
00995     cf_object_set_flag(whoptr->obj, FLAG_CURSED, val);
00996     return 0;
00997 }
00998 
00999 static int Object_SetDamned(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01000     int val;
01001 
01002     EXISTCHECK_INT(whoptr);
01003     if (!PyArg_Parse(value, "i", &val))
01004         return -1;
01005 
01006     cf_object_set_flag(whoptr->obj, FLAG_DAMNED, val);
01007     return 0;
01008 }
01009 
01010 static int Object_SetApplied(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01011     int val;
01012 
01013     EXISTCHECK_INT(whoptr);
01014     if (!PyArg_Parse(value, "i", &val))
01015         return -1;
01016 
01017     cf_object_set_flag(whoptr->obj, FLAG_APPLIED, val);
01018     return 0;
01019 }
01020 
01021 static int Object_SetStr(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01022     int val;
01023 
01024     EXISTCHECK_INT(whoptr);
01025     if (!PyArg_Parse(value, "i", &val))
01026         return -1;
01027 
01028     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_STR, val);
01029 /*    cf_fix_object(whoptr->obj);*/
01030     return 0;
01031 }
01032 
01033 static int Object_SetDex(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01034     int val;
01035 
01036     EXISTCHECK_INT(whoptr);
01037     if (!PyArg_Parse(value, "i", &val))
01038         return -1;
01039 
01040     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_DEX, val);
01041     /*cf_fix_object(whoptr->obj);*/
01042     return 0;
01043 }
01044 
01045 static int Object_SetCon(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01046     int val;
01047 
01048     EXISTCHECK_INT(whoptr);
01049     if (!PyArg_Parse(value, "i", &val))
01050         return -1;
01051 
01052     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_CON, val);
01053     /*cf_fix_object(whoptr->obj);*/
01054     return 0;
01055 }
01056 
01057 static int Object_SetInt(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01058     int val;
01059 
01060     EXISTCHECK_INT(whoptr);
01061     if (!PyArg_Parse(value, "i", &val))
01062         return -1;
01063 
01064     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_INT, val);
01065     /*cf_fix_object(whoptr->obj);*/
01066     return 0;
01067 }
01068 
01069 static int Object_SetPow(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01070     int val;
01071 
01072     EXISTCHECK_INT(whoptr);
01073     if (!PyArg_Parse(value, "i", &val))
01074         return -1;
01075 
01076     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_POW, val);
01077     /*cf_fix_object(whoptr->obj);*/
01078     return 0;
01079 }
01080 
01081 static int Object_SetWis(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01082     int val;
01083 
01084     EXISTCHECK_INT(whoptr);
01085     if (!PyArg_Parse(value, "i", &val))
01086         return -1;
01087 
01088     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_WIS, val);
01089     /*cf_fix_object(whoptr->obj);*/
01090     return 0;
01091 }
01092 
01093 static int Object_SetCha(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01094     int val;
01095 
01096     EXISTCHECK_INT(whoptr);
01097     if (!PyArg_Parse(value, "i", &val))
01098         return -1;
01099 
01100     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_CHA, val);
01101     /*cf_fix_object(whoptr->obj);*/
01102     return 0;
01103 }
01104 
01105 static int Object_SetHP(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01106     int val;
01107 
01108     EXISTCHECK_INT(whoptr);
01109     if (!PyArg_Parse(value, "i", &val))
01110         return -1;
01111 
01112     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_HP, val);
01113     return 0;
01114 }
01115 
01116 static int Object_SetMaxHP(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01117     int val;
01118 
01119     EXISTCHECK_INT(whoptr);
01120     if (!PyArg_Parse(value, "i", &val))
01121         return -1;
01122 
01123     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_MAXHP, val);
01124     return 0;
01125 }
01126 
01127 static int Object_SetSP(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01128     int val;
01129 
01130     EXISTCHECK_INT(whoptr);
01131     if (!PyArg_Parse(value, "i", &val))
01132         return -1;
01133 
01134     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_SP, val);
01135     return 0;
01136 }
01137 
01138 static int Object_SetMaxSP(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01139     int val;
01140 
01141     EXISTCHECK_INT(whoptr);
01142     if (!PyArg_Parse(value, "i", &val))
01143         return -1;
01144 
01145     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_MAXSP, val);
01146     return 0;
01147 }
01148 
01149 static int Object_SetGrace(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01150     int val;
01151 
01152     EXISTCHECK_INT(whoptr);
01153     if (!PyArg_Parse(value, "i", &val))
01154         return -1;
01155 
01156     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_GP, val);
01157     return 0;
01158 }
01159 
01160 static int Object_SetMaxGrace(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01161     int val;
01162 
01163     EXISTCHECK_INT(whoptr);
01164     if (!PyArg_Parse(value, "i", &val))
01165         return -1;
01166 
01167     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_MAXGP, val);
01168     return 0;
01169 }
01170 
01171 static int Object_SetAC(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01172     int val;
01173 
01174     EXISTCHECK_INT(whoptr);
01175     if (!PyArg_Parse(value, "i", &val))
01176         return -1;
01177 
01178     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_AC, val);
01179     return 0;
01180 }
01181 
01182 static int Object_SetWC(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01183     int val;
01184 
01185     EXISTCHECK_INT(whoptr);
01186     if (!PyArg_Parse(value, "i", &val))
01187         return -1;
01188 
01189     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_WC, val);
01190     return 0;
01191 }
01192 
01193 static int Object_SetDam(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01194     int val;
01195 
01196     EXISTCHECK_INT(whoptr);
01197     if (!PyArg_Parse(value, "i", &val))
01198         return -1;
01199 
01200     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_DAM, val);
01201     return 0;
01202 }
01203 
01204 static int Object_SetFood(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01205     int val;
01206 
01207     EXISTCHECK_INT(whoptr);
01208     if (!PyArg_Parse(value, "i", &val))
01209         return -1;
01210 
01211     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_FP, val);
01212     return 0;
01213 }
01214 
01215 static int Object_SetWeight(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01216     int val;
01217 
01218     EXISTCHECK_INT(whoptr);
01219     if (!PyArg_Parse(value, "i", &val))
01220         return -1;
01221 
01222     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_WEIGHT, val);
01223     return 0;
01224 }
01225 
01226 static int Object_SetWeightLimit(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01227     int val;
01228 
01229     EXISTCHECK_INT(whoptr);
01230     if (!PyArg_Parse(value, "i", &val))
01231         return -1;
01232 
01233     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_WEIGHT_LIMIT, val);
01234     return 0;
01235 }
01236 
01237 static int Object_SetDirection(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01238     int val;
01239 
01240     EXISTCHECK_INT(whoptr);
01241     if (!PyArg_Parse(value, "i", &val))
01242         return -1;
01243 
01244     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_DIRECTION, val);
01245     return 0;
01246 }
01247 
01248 static int Object_SetFacing(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01249     int val;
01250 
01251     EXISTCHECK_INT(whoptr);
01252     if (!PyArg_Parse(value, "i", &val))
01253         return -1;
01254 
01255     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_FACING, val);
01256     return 0;
01257 }
01258 
01259 static int Object_SetGod(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01260     char *val;
01261 
01262     EXISTCHECK_INT(whoptr);
01263     if (!PyArg_Parse(value, "s", &val))
01264         return -1;
01265 
01266     cf_object_set_string_property(whoptr->obj, CFAPI_OBJECT_PROP_GOD, val);
01267     return 0;
01268 }
01269 
01270 static int Object_SetSpeed(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01271     float val;
01272 
01273     EXISTCHECK_INT(whoptr);
01274     if (!PyArg_Parse(value, "f", &val))
01275         return -1;
01276 
01277     cf_object_set_float_property(whoptr->obj, CFAPI_OBJECT_PROP_SPEED, val);
01278 /*    cf_fix_object(whoptr->obj);*/
01279     return 0;
01280 }
01281 
01282 static int Object_SetSpeedLeft(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01283     float val;
01284 
01285     EXISTCHECK_INT(whoptr);
01286     if (!PyArg_Parse(value, "f", &val))
01287         return -1;
01288 
01289     cf_object_set_float_property(whoptr->obj, CFAPI_OBJECT_PROP_SPEED_LEFT, val);
01290 /*    cf_fix_object(whoptr->obj);*/
01291     return 0;
01292 }
01293 
01294 static int Object_SetQuantity(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01295     int val;
01296 
01297     EXISTCHECK_INT(whoptr);
01298     if (!PyArg_Parse(value, "i", &val))
01299         return -1;
01300 
01301     if (cf_object_set_nrof(whoptr->obj, val) != 0) {
01302         PyErr_SetString(PyExc_TypeError, "Invalid quantity");
01303         return -1;
01304     }
01305 
01306 /*    cf_fix_object(whoptr->obj);*/
01307     return 0;
01308 }
01309 
01310 static int Object_SetLastSP(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01311     int val;
01312 
01313     EXISTCHECK_INT(whoptr);
01314     if (!PyArg_Parse(value, "i", &val))
01315         return -1;
01316 
01317     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_LAST_SP, val);
01318 /*    cf_fix_object(whoptr->obj);*/
01319     return 0;
01320 }
01321 
01322 static int Object_SetLastGrace(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01323     int val;
01324 
01325     EXISTCHECK_INT(whoptr);
01326     if (!PyArg_Parse(value, "i", &val))
01327         return -1;
01328 
01329     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_LAST_GRACE, val);
01330 /*    cf_fix_object(whoptr->obj);*/
01331     return 0;
01332 }
01333 
01334 static int Object_SetLastEat(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01335     int val;
01336 
01337     EXISTCHECK_INT(whoptr);
01338     if (!PyArg_Parse(value, "i", &val))
01339         return -1;
01340 
01341     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_LAST_EAT, val);
01342     return 0;
01343 }
01344 
01345 static int Object_SetFace(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01346     char *txt;
01347     int face;
01348 
01349     EXISTCHECK_INT(whoptr);
01350     if (!PyArg_Parse(value, "s", &txt))
01351         return -1;
01352 
01353     face = cf_find_face(txt, -1);
01354     if (face == -1) {
01355         PyErr_SetString(PyExc_TypeError, "Unknown face.");
01356         return -1;
01357     }
01358 
01359     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_FACE, face);
01360     return 0;
01361 }
01362 
01363 static int Object_SetAnim(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01364     char *txt;
01365     int anim;
01366 
01367     EXISTCHECK_INT(whoptr);
01368     if (!PyArg_Parse(value, "s", &txt))
01369         return -1;
01370 
01371     anim = cf_find_animation(txt);
01372     if (anim == 0) {
01373         PyErr_SetString(PyExc_TypeError, "Unknown animation.");
01374         return -1;
01375     }
01376 
01377     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_ANIMATION, anim);
01378     return 0;
01379 }
01380 
01381 static int Object_SetAnimSpeed(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01382     int val;
01383 
01384     EXISTCHECK_INT(whoptr);
01385     if (!PyArg_Parse(value, "i", &val))
01386         return -1;
01387 
01388     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_ANIM_SPEED, val);
01389     return 0;
01390 }
01391 
01392 static int Object_SetAttackType(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01393     int val;
01394 
01395     EXISTCHECK_INT(whoptr);
01396     if (!PyArg_Parse(value, "i", &val))
01397         return -1;
01398 
01399     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_ATTACK_TYPE, val);
01400 /*    cf_fix_object(whoptr->obj);*/
01401     return 0;
01402 }
01403 
01404 static int Object_SetIdentified(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01405     int val;
01406 
01407     EXISTCHECK_INT(whoptr);
01408     if (!PyArg_Parse(value, "i", &val))
01409         return -1;
01410 
01411     cf_object_set_flag(whoptr->obj, FLAG_IDENTIFIED, val);
01412     return 0;
01413 }
01414 
01415 static int Object_SetUnaggressive(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01416     int val;
01417 
01418     EXISTCHECK_INT(whoptr);
01419     if (!PyArg_Parse(value, "i", &val))
01420         return -1;
01421 
01422     cf_object_set_flag(whoptr->obj, FLAG_UNAGGRESSIVE, val);
01423     return 0;
01424 }
01425 
01426 static int Object_SetPickable(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01427     int val;
01428 
01429     EXISTCHECK_INT(whoptr);
01430     if (!PyArg_Parse(value, "i", &val))
01431         return -1;
01432 
01433     cf_object_set_flag(whoptr->obj, FLAG_NO_PICK, !val);
01434     return 0;
01435 }
01436 
01437 static int Object_SetInvisible(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01438     int val;
01439 
01440     EXISTCHECK_INT(whoptr);
01441     if (!PyArg_ParseTuple(value, "i", &val))
01442         return -1;
01443 
01444     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_INVISIBLE, val);
01445     return 0;
01446 }
01447 
01448 static int Object_SetUnpaid(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01449     int val;
01450 
01451     EXISTCHECK_INT(whoptr);
01452     if (!PyArg_Parse(value, "i", &val))
01453         return -1;
01454 
01455     cf_object_set_flag(whoptr->obj, FLAG_UNPAID, val);
01456     return 0;
01457 }
01458 
01459 static int Object_SetFriendly(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01460     int val;
01461 
01462     EXISTCHECK_INT(whoptr);
01463     if (!PyArg_Parse(value, "i", &val))
01464         return -1;
01465 
01466     cf_object_set_flag(whoptr->obj, FLAG_FRIENDLY, val);
01467     return 0;
01468 }
01469 
01470 static int Object_SetCanSeeInvisible(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01471     int val;
01472 
01473     EXISTCHECK_INT(whoptr);
01474     if (!PyArg_Parse(value, "i", &val))
01475         return -1;
01476 
01477     cf_object_set_flag(whoptr->obj, FLAG_SEE_INVISIBLE, val);
01478     return 0;
01479 }
01480 
01481 static int Object_SetRollable(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01482     int val;
01483 
01484     EXISTCHECK_INT(whoptr);
01485     if (!PyArg_Parse(value, "i", &val))
01486         return -1;
01487 
01488     cf_object_set_flag(whoptr->obj, FLAG_CAN_ROLL, val);
01489     return 0;
01490 }
01491 
01492 static int Object_SetTurnable(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01493     int val;
01494 
01495     EXISTCHECK_INT(whoptr);
01496     if (!PyArg_Parse(value, "i", &val))
01497         return -1;
01498 
01499     cf_object_set_flag(whoptr->obj, FLAG_IS_TURNABLE, val);
01500     return 0;
01501 }
01502 
01503 static int Object_SetUsedUp(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01504     int val;
01505 
01506     EXISTCHECK_INT(whoptr);
01507     if (!PyArg_Parse(value, "i", &val))
01508         return -1;
01509 
01510     cf_object_set_flag(whoptr->obj, FLAG_IS_USED_UP, val);
01511     return 0;
01512 }
01513 
01514 static int Object_SetBlind(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01515     int val;
01516 
01517     EXISTCHECK_INT(whoptr);
01518     if (!PyArg_Parse(value, "i", &val))
01519         return -1;
01520 
01521     cf_object_set_flag(whoptr->obj, FLAG_BLIND, val);
01522     return 0;
01523 }
01524 
01525 static int Object_SetKnownCursed(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01526     int val;
01527 
01528     EXISTCHECK_INT(whoptr);
01529     if (!PyArg_Parse(value, "i", &val))
01530         return -1;
01531 
01532     cf_object_set_flag(whoptr->obj, FLAG_KNOWN_CURSED, val);
01533     return 0;
01534 }
01535 
01536 static int Object_SetStealthy(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01537     int val;
01538 
01539     EXISTCHECK_INT(whoptr);
01540     if (!PyArg_Parse(value, "i", &val))
01541         return -1;
01542 
01543     cf_object_set_flag(whoptr->obj, FLAG_STEALTH, val);
01544     return 0;
01545 }
01546 
01547 static int Object_SetConfused(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01548     int val;
01549 
01550     EXISTCHECK_INT(whoptr);
01551     if (!PyArg_Parse(value, "i", &val))
01552         return -1;
01553 
01554     cf_object_set_flag(whoptr->obj, FLAG_CONFUSED, val);
01555     return 0;
01556 }
01557 
01558 static int Object_SetSleeping(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01559     int val;
01560 
01561     EXISTCHECK_INT(whoptr);
01562     if (!PyArg_Parse(value, "i", &val))
01563         return -1;
01564 
01565     cf_object_set_flag(whoptr->obj, FLAG_SLEEP, val);
01566     return 0;
01567 }
01568 
01569 static int Object_SetLifesaver(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01570     int val;
01571 
01572     EXISTCHECK_INT(whoptr);
01573     if (!PyArg_Parse(value, "i", &val))
01574         return -1;
01575 
01576     cf_object_set_flag(whoptr->obj, FLAG_LIFESAVE, val);
01577     return 0;
01578 }
01579 
01580 static int Object_SetHasXRays(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01581     int val;
01582 
01583     EXISTCHECK_INT(whoptr);
01584     if (!PyArg_Parse(value, "i", &val))
01585         return -1;
01586 
01587     cf_object_set_flag(whoptr->obj, FLAG_XRAYS, val);
01588     return 0;
01589 }
01590 
01591 static int Object_SetCanSeeInDark(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01592     int val;
01593 
01594     EXISTCHECK_INT(whoptr);
01595     if (!PyArg_Parse(value, "i", &val))
01596         return -1;
01597 
01598     cf_object_set_flag(whoptr->obj, FLAG_SEE_IN_DARK, val);
01599     return 0;
01600 }
01601 
01602 static int Object_SetKnownMagical(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01603     int val;
01604 
01605     EXISTCHECK_INT(whoptr);
01606     if (!PyArg_Parse(value, "i", &val))
01607         return -1;
01608 
01609     cf_object_set_flag(whoptr->obj, FLAG_KNOWN_MAGICAL, val);
01610     return 0;
01611 }
01612 
01613 static int Object_SetReflectSpells(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01614     int val;
01615 
01616     EXISTCHECK_INT(whoptr);
01617     if (!PyArg_Parse(value, "i", &val))
01618         return -1;
01619 
01620     cf_object_set_flag(whoptr->obj, FLAG_REFL_SPELL, val);
01621     return 0;
01622 }
01623 
01624 static int Object_SetReflectMissiles(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01625     int val;
01626 
01627     EXISTCHECK_INT(whoptr);
01628     if (!PyArg_Parse(value, "i", &val))
01629         return -1;
01630 
01631     cf_object_set_flag(whoptr->obj, FLAG_REFL_MISSILE, val);
01632     return 0;
01633 }
01634 
01635 static int Object_SetUnique(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01636     int val;
01637 
01638     EXISTCHECK_INT(whoptr);
01639     if (!PyArg_Parse(value, "i", &val))
01640         return -1;
01641 
01642     cf_object_set_flag(whoptr->obj, FLAG_UNIQUE, val);
01643     return 0;
01644 }
01645 
01646 static int Object_SetCanPassThru(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01647     int val;
01648 
01649     EXISTCHECK_INT(whoptr);
01650     if (!PyArg_Parse(value, "i", &val))
01651         return -1;
01652     /* FIXME */
01653     /*cf_object_set_flag(whoptr->obj, FLAG_CAN_PASS_THRU, val);*/
01654     return 0;
01655 }
01656 
01657 static int Object_SetRunAway(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01658     int val;
01659 
01660     EXISTCHECK_INT(whoptr);
01661     if (!PyArg_Parse(value, "i", &val))
01662         return -1;
01663 
01664     cf_object_set_flag(whoptr->obj, FLAG_RUN_AWAY, val);
01665     return 0;
01666 }
01667 
01668 static int Object_SetScared(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01669     int val;
01670 
01671     EXISTCHECK_INT(whoptr);
01672     if (!PyArg_Parse(value, "i", &val))
01673         return -1;
01674 
01675     cf_object_set_flag(whoptr->obj, FLAG_SCARED, val);
01676     return 0;
01677 }
01678 
01679 static int Object_SetUndead(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01680     int val;
01681 
01682     EXISTCHECK_INT(whoptr);
01683     if (!PyArg_Parse(value, "i", &val))
01684         return -1;
01685 
01686     cf_object_set_flag(whoptr->obj, FLAG_UNDEAD, val);
01687     return 0;
01688 }
01689 
01690 static int Object_SetBlocksView(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01691     int val;
01692 
01693     EXISTCHECK_INT(whoptr);
01694     if (!PyArg_Parse(value, "i", &val))
01695         return -1;
01696 
01697     cf_object_set_flag(whoptr->obj, FLAG_BLOCKSVIEW, val);
01698     return 0;
01699 }
01700 
01701 static int Object_SetHitBack(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01702     int val;
01703 
01704     EXISTCHECK_INT(whoptr);
01705     if (!PyArg_Parse(value, "i", &val))
01706         return -1;
01707 
01708     cf_object_set_flag(whoptr->obj, FLAG_HITBACK, val);
01709     return 0;
01710 }
01711 
01712 static int Object_SetStandStill(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01713     int val;
01714 
01715     EXISTCHECK_INT(whoptr);
01716     if (!PyArg_Parse(value, "i", &val))
01717         return -1;
01718 
01719     cf_object_set_flag(whoptr->obj, FLAG_STAND_STILL, val);
01720     return 0;
01721 }
01722 
01723 static int Object_SetOnlyAttack(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01724     int val;
01725 
01726     EXISTCHECK_INT(whoptr);
01727     if (!PyArg_Parse(value, "i", &val))
01728         return -1;
01729 
01730     cf_object_set_flag(whoptr->obj, FLAG_ONLY_ATTACK, val);
01731     return 0;
01732 }
01733 
01734 static int Object_SetMakeInvisible(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01735     int val;
01736 
01737     EXISTCHECK_INT(whoptr);
01738     if (!PyArg_Parse(value, "i", &val))
01739         return -1;
01740 
01741     cf_object_set_flag(whoptr->obj, FLAG_MAKE_INVIS, val);
01742     return 0;
01743 }
01744 
01745 static int Object_SetValue(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01746     long val;
01747 
01748     EXISTCHECK_INT(whoptr);
01749     if (!PyArg_Parse(value, "l", &val))
01750         return -1;
01751 
01752     cf_object_set_long_property(whoptr->obj, CFAPI_OBJECT_PROP_VALUE, val);
01753     return 0;
01754 }
01755 
01756 static int Object_SetNoSave(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01757     long val;
01758 
01759     EXISTCHECK_INT(whoptr);
01760     if (!PyArg_Parse(value, "i", &val))
01761         return -1;
01762 
01763     cf_object_set_long_property(whoptr->obj, CFAPI_OBJECT_PROP_NO_SAVE, val);
01764     return 0;
01765 }
01766 
01767 static int Object_SetOwner(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01768     Crossfire_Object *ob;
01769 
01770     EXISTCHECK_INT(whoptr);
01771     if (!PyArg_Parse(value, "O!", &Crossfire_ObjectType, &ob))
01772         return -1;
01773     cf_object_set_object_property(whoptr->obj, CFAPI_OBJECT_PROP_OWNER, ob->obj);
01774     return 0;
01775 }
01776 
01777 static int Object_SetEnemy(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01778     Crossfire_Object *ob;
01779 
01780     EXISTCHECK_INT(whoptr);
01781     if (!PyArg_Parse(value, "O!", &Crossfire_ObjectType, &ob))
01782         return -1;
01783     cf_object_set_object_property(whoptr->obj, CFAPI_OBJECT_PROP_ENEMY, ob->obj);
01784     return 0;
01785 }
01786 
01787 static int Object_SetGodGiven(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01788     int val;
01789 
01790     EXISTCHECK_INT(whoptr);
01791     if (!PyArg_Parse(value, "i", &val))
01792         return -1;
01793 
01794     cf_object_set_flag(whoptr->obj, FLAG_STARTEQUIP, val);
01795     return 0;
01796 }
01797 
01798 static int Object_SetNoDamage(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01799     int val;
01800 
01801     EXISTCHECK_INT(whoptr);
01802     if (!PyArg_Parse(value, "i", &val))
01803         return -1;
01804 
01805     cf_object_set_flag(whoptr->obj, FLAG_NO_DAMAGE, val);
01806     return 0;
01807 }
01808 
01809 static int Object_SetRandomMovement(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01810     int val;
01811 
01812     EXISTCHECK_INT(whoptr);
01813     if (!PyArg_Parse(value, "i", &val))
01814         return -1;
01815 
01816     cf_object_set_flag(whoptr->obj, FLAG_RANDOM_MOVE, val);
01817     return 0;
01818 }
01819 
01820 static int Object_SetIsPet(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01821     int val;
01822 
01823     EXISTCHECK_INT(whoptr);
01824     if (!PyArg_Parse(value, "i", &val))
01825         return -1;
01826 
01827     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_FRIENDLY, val);
01828     return 0;
01829 }
01830 
01831 static int Object_SetAttackMovement(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01832     int val;
01833 
01834     EXISTCHECK_INT(whoptr);
01835     if (!PyArg_Parse(value, "i", &val))
01836         return -1;
01837 
01838     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_ATTACK_MOVEMENT, val);
01839     return 0;
01840 }
01841 
01842 static int Object_SetExp(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01843     sint64 val;
01844 
01845     EXISTCHECK_INT(whoptr);
01846     if (!PyArg_Parse(value, "L", &val))
01847         return -1;
01848 
01849     cf_object_set_int64_property(whoptr->obj, CFAPI_OBJECT_PROP_EXP, val);
01850     return 0;
01851 }
01852 
01853 static int Object_SetDuration(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01854     int val;
01855 
01856     EXISTCHECK_INT(whoptr);
01857     if (!PyArg_Parse(value, "i", &val))
01858         return -1;
01859 
01860     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_DURATION, val);
01861     return 0;
01862 }
01863 
01864 static int Object_SetGlowRadius(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01865     int val;
01866 
01867     EXISTCHECK_INT(whoptr);
01868     if (!PyArg_Parse(value, "i", &val))
01869         return -1;
01870 
01871     cf_object_set_int_property(whoptr->obj, CFAPI_OBJECT_PROP_GLOW_RADIUS, val);
01872     return 0;
01873 }
01874 
01875 static int Object_SetAnimated(Crossfire_Object *whoptr, PyObject *value, void *closure) {
01876     int val;
01877 
01878     EXISTCHECK_INT(whoptr);
01879     if (!PyArg_Parse(value, "i", &val))
01880         return -1;
01881     cf_object_set_flag(whoptr->obj, FLAG_ANIMATE, val);
01882     return 0;
01883 }
01884 
01885 /* Methods. */
01886 
01887 static PyObject *Crossfire_Object_Remove(Crossfire_Object *who, PyObject *args) {
01888     EXISTCHECK(who);
01889 
01890     if ((current_context->who != NULL) && (((Crossfire_Object *)current_context->who)->obj == who->obj))
01891         current_context->who = NULL;
01892 
01893     if (!cf_object_get_flag(who->obj, FLAG_REMOVED)) {
01894         cf_object_remove(who->obj);
01895     }
01896 
01897     cf_object_free(who->obj);
01898     Py_INCREF(Py_None);
01899     return Py_None;
01900 }
01901 
01902 static PyObject *Crossfire_Object_Apply(Crossfire_Object *who, PyObject *args) {
01903     Crossfire_Object *whoptr;
01904     int flags;
01905 
01906     if (!PyArg_ParseTuple(args, "O!i", &Crossfire_ObjectType, &whoptr, &flags))
01907         return NULL;
01908     EXISTCHECK(who);
01909     EXISTCHECK(whoptr);
01910 
01911     return Py_BuildValue("i", cf_object_apply(whoptr->obj, who->obj, flags));
01912 }
01913 
01914 static PyObject *Crossfire_Object_Drop(Crossfire_Object *who, PyObject *args) {
01915     /* Note that this function uses the METH_O calling convention. */
01916     Crossfire_Object *whoptr = (Crossfire_Object*)args;
01917 
01918     EXISTCHECK(who);
01919     TYPEEXISTCHECK(whoptr);
01920 
01921     cf_object_drop(whoptr->obj, who->obj);
01922     Py_INCREF(Py_None);
01923     return Py_None;
01924 }
01925 
01926 static PyObject *Crossfire_Object_Fix(Crossfire_Object *who, PyObject *args) {
01927     cf_fix_object(who->obj);
01928     Py_INCREF(Py_None);
01929     return Py_None;
01930 }
01931 
01932 static PyObject *Crossfire_Object_Take(Crossfire_Object *who, PyObject *args) {
01933     /* Note that this function uses the METH_O calling convention. */
01934     Crossfire_Object *whoptr = (Crossfire_Object*)args;
01935 
01936     EXISTCHECK(who);
01937     TYPEEXISTCHECK(whoptr);
01938 
01939     cf_object_pickup(whoptr->obj, who->obj);
01940     Py_INCREF(Py_None);
01941     return Py_None;
01942 }
01943 
01944 static PyObject *Crossfire_Object_Teleport(Crossfire_Object *who, PyObject *args) {
01945     Crossfire_Map *where;
01946     int x, y;
01947     int val;
01948 
01949     EXISTCHECK(who);
01950     if (!PyArg_ParseTuple(args, "O!ii", &Crossfire_MapType, &where, &x, &y))
01951         return NULL;
01952 
01953     val = cf_object_teleport(who->obj, where->map, x, y);
01954 
01955     return Py_BuildValue("i", val);
01956 }
01957 
01958 static PyObject *Crossfire_Object_ActivateRune(Crossfire_Object *who, PyObject *args) {
01959     /* Note that this function uses the METH_O calling convention. */
01960     object *trap;
01961     object *victim;
01962     Crossfire_Object *pcause = (Crossfire_Object*)args;
01963 
01964     EXISTCHECK(who);
01965     TYPEEXISTCHECK(pcause);
01966     trap = who->obj;
01967     victim = pcause->obj;
01968     cf_spring_trap(trap, victim);
01969     Py_INCREF(Py_None);
01970     return Py_None;
01971 }
01972 
01973 static PyObject *Crossfire_Object_CheckTrigger(Crossfire_Object *who, PyObject *args) {
01974     /* Note that this function uses the METH_O calling convention. */
01975     object *trigger;
01976     object *cause;
01977     int result;
01978     Crossfire_Object *pcause = (Crossfire_Object*)args;
01979 
01980     EXISTCHECK(who);
01981     TYPEEXISTCHECK(pcause);
01982     trigger = who->obj;
01983     cause = pcause->obj;
01984     result = cf_object_check_trigger(trigger, cause);
01985 
01986     return Py_BuildValue("i", result);
01987 }
01988 
01989 static PyObject *Crossfire_Object_Say(Crossfire_Object *who, PyObject *args) {
01990     char *message;
01991 
01992     EXISTCHECK(who);
01993     if (!PyArg_ParseTuple(args, "s", &message))
01994         return NULL;
01995     cf_object_say(who->obj, message);
01996     Py_INCREF(Py_None);
01997     return Py_None;
01998 }
01999 
02000 static PyObject *Crossfire_Object_Reposition(Crossfire_Object *who, PyObject *args) {
02001     int x, y;
02002 
02003     EXISTCHECK(who);
02004     if (!PyArg_ParseTuple(args, "ii", &x, &y))
02005         return NULL;
02006 
02007     cf_object_transfer(who->obj, x, y, 0, NULL);
02008     Py_INCREF(Py_None);
02009     return Py_None;
02010 }
02011 
02012 static PyObject *Crossfire_Object_QueryName(Crossfire_Object *who, PyObject *args) {
02013     char name[200];
02014 
02015     EXISTCHECK(who);
02016     return Py_BuildValue("s", cf_query_name(who->obj, name, sizeof(name)));
02017 }
02018 
02019 static PyObject *Crossfire_Object_GetResist(Crossfire_Object *who, PyObject *args) {
02020     int resist;
02021 
02022     EXISTCHECK(who);
02023     if (!PyArg_ParseTuple(args, "i", &resist))
02024         return NULL;
02025     if ((resist < 0) || (resist >= NROFATTACKS)) {
02026         return Py_BuildValue("l", 0);
02027     }
02028     return Py_BuildValue("i", cf_object_get_resistance(who->obj, resist));
02029 }
02030 
02031 static PyObject *Crossfire_Object_SetResist(Crossfire_Object *who, PyObject *args) {
02032     int resist, value;
02033 
02034     EXISTCHECK(who);
02035     if (!PyArg_ParseTuple(args, "ii", &resist, &value))
02036         return NULL;
02037     if ((resist >= 0) && (resist < NROFATTACKS))
02038         cf_object_set_resistance(who->obj, resist, value);
02039     Py_INCREF(Py_None);
02040     return Py_None;
02041 }
02042 
02043 static PyObject *Crossfire_Object_QueryCost(Crossfire_Object *who, PyObject *args) {
02044     int flags;
02045     Crossfire_Object *pcause;
02046 
02047     if (!PyArg_ParseTuple(args, "O!i", &Crossfire_ObjectType, &pcause, &flags))
02048         return NULL;
02049     EXISTCHECK(who);
02050     EXISTCHECK(pcause);
02051     return Py_BuildValue("i", cf_object_query_cost(who->obj, pcause->obj, flags));
02052 }
02053 
02054 static PyObject *Crossfire_Object_Cast(Crossfire_Object *who, PyObject *args) {
02055     int dir;
02056     char *op;
02057     Crossfire_Object *pspell;
02058 
02059     if (!PyArg_ParseTuple(args, "O!is", &Crossfire_ObjectType, &pspell, &dir, &op))
02060         return NULL;
02061     EXISTCHECK(who);
02062     EXISTCHECK(pspell);
02063 
02064     cf_object_cast_spell(who->obj, who->obj, dir, pspell->obj, op);
02065 
02066     Py_INCREF(Py_None);
02067     return Py_None;
02068 }
02069 
02070 static PyObject *Crossfire_Object_LearnSpell(Crossfire_Object *who, PyObject *args) {
02071     /* Note that this function uses the METH_O calling convention. */
02072     Crossfire_Object *pspell = (Crossfire_Object*)args;
02073 
02074     EXISTCHECK(who);
02075     TYPEEXISTCHECK(pspell);
02076 
02077     cf_object_learn_spell(who->obj, pspell->obj, 0);
02078 
02079     Py_INCREF(Py_None);
02080     return Py_None;
02081 }
02082 
02083 static PyObject *Crossfire_Object_ForgetSpell(Crossfire_Object *who, PyObject *args) {
02084     /* Note that this function uses the METH_O calling convention. */
02085     Crossfire_Object *pspell = (Crossfire_Object*)args;
02086 
02087     EXISTCHECK(who);
02088     TYPEEXISTCHECK(pspell);
02089 
02090     cf_object_forget_spell(who->obj, pspell->obj);
02091     Py_INCREF(Py_None);
02092     return Py_None;
02093 }
02094 
02095 static PyObject *Crossfire_Object_KnowSpell(Crossfire_Object *who, PyObject *args) {
02096     char *spellname;
02097     object *op;
02098 
02099     EXISTCHECK(who);
02100     if (!PyArg_ParseTuple(args, "s", &spellname))
02101         return NULL;
02102 
02103     op = cf_object_check_for_spell(who->obj, spellname);
02104 
02105     return Crossfire_Object_wrap(op);
02106 }
02107 
02108 static PyObject *Crossfire_Object_CastAbility(Crossfire_Object *who, PyObject *args) {
02109     Crossfire_Object *pspell;
02110     int dir;
02111     char *str;
02112 
02113     if (!PyArg_ParseTuple(args, "O!is", &Crossfire_ObjectType, &pspell, &dir, &str))
02114         return NULL;
02115     EXISTCHECK(who);
02116     EXISTCHECK(pspell);
02117 
02118     cf_object_cast_ability(who->obj, who->obj, dir, pspell->obj, str);
02119 
02120     Py_INCREF(Py_None);
02121     return Py_None;
02122 }
02123 
02124 static PyObject *Crossfire_Object_PayAmount(Crossfire_Object *who, PyObject *args) {
02125     uint64 to_pay;
02126     int val;
02127 
02128     EXISTCHECK(who);
02129     if (!PyArg_ParseTuple(args, "L", &to_pay))
02130         return NULL;
02131 
02132     val = cf_object_pay_amount(who->obj, to_pay);
02133 
02134     return Py_BuildValue("i", val);
02135 }
02136 
02137 static PyObject *Crossfire_Object_Pay(Crossfire_Object *who, PyObject *args) {
02138     /* Note that this function uses the METH_O calling convention. */
02139     Crossfire_Object *op = (Crossfire_Object*)args;
02140     int val;
02141 
02142     EXISTCHECK(who);
02143     TYPEEXISTCHECK(op);
02144 
02145     val = cf_object_pay_item(who->obj, op->obj);
02146 
02147     return Py_BuildValue("i", val);
02148 }
02149 
02150 static PyObject *Crossfire_Object_ReadKey(Crossfire_Object *who, PyObject *args) {
02151     const char *val;
02152     char *keyname;
02153 
02154     EXISTCHECK(who);
02155     if (!PyArg_ParseTuple(args, "s", &keyname))
02156         return NULL;
02157 
02158     val = cf_object_get_key(who->obj, keyname);
02159 
02160     return Py_BuildValue("s", val ? val : "");
02161 }
02162 
02163 static PyObject *Crossfire_Object_WriteKey(Crossfire_Object *who, PyObject *args) {
02164     char *keyname;
02165     char *value;
02166     int add_key = 0;
02167 
02168     EXISTCHECK(who);
02169     if (!PyArg_ParseTuple(args, "ss|i", &keyname, &value, &add_key))
02170         return NULL;
02171 
02172     return Py_BuildValue("i", cf_object_set_key(who->obj, keyname, value, add_key));
02173 }
02174 
02175 static PyObject *Crossfire_Object_CreateTimer(Crossfire_Object *who, PyObject *args) {
02176     int mode;
02177     long delay;
02178 
02179     EXISTCHECK(who);
02180     if (!PyArg_ParseTuple(args, "li", &delay, &mode))
02181         return NULL;
02182 
02183     return Py_BuildValue("i", cf_timer_create(who->obj, delay, mode));
02184 }
02185 
02186 static PyObject *Crossfire_Object_CheckInventory(Crossfire_Object *who, PyObject *args) {
02187     char *whatstr;
02188     object *foundob;
02189 
02190     EXISTCHECK(who);
02191     if (!PyArg_ParseTuple(args, "s", &whatstr))
02192         return NULL;
02193 
02194     foundob = cf_object_present_archname_inside(who->obj, whatstr);
02195 
02196     return Crossfire_Object_wrap(foundob);
02197 /*  for (tmp = WHO->inv; tmp; tmp = tmp->below) {
02198         if (!strncmp(PyQueryName(tmp), whatstr, strlen(whatstr))) {
02199             return Py_BuildValue("l", (long)(tmp));
02200         }
02201         if (!strncmp(tmp->name, whatstr, strlen(whatstr))) {
02202             return Py_BuildValue("l", (long)(tmp));
02203         }
02204     }
02205 
02206     return Py_BuildValue("l", (long)0);*/
02207 }
02208 
02209 static PyObject *Crossfire_Object_CheckArchInventory(Crossfire_Object *who, PyObject *args) {
02210     char *whatstr;
02211     object *tmp;
02212 
02213     EXISTCHECK(who);
02214     if (!PyArg_ParseTuple(args, "s", &whatstr))
02215         return NULL;
02216 
02217     for (tmp = who->obj->inv; tmp != NULL; tmp = tmp->below) {
02218         if (!strcmp(tmp->arch->name, whatstr))
02219             break;
02220     }
02221     return Crossfire_Object_wrap(tmp);
02222 }
02223 
02224 static PyObject *Crossfire_Object_GetOutOfMap(Crossfire_Object *who, PyObject *args) {
02225     int x, y;
02226 
02227     EXISTCHECK(who);
02228     if (!PyArg_ParseTuple(args, "ii", &x, &y))
02229         return NULL;
02230 
02231     return Py_BuildValue("i", cf_object_out_of_map(who->obj, x, y));
02232 }
02233 
02234 static PyObject *Crossfire_Object_CreateInside(Crossfire_Object *who, PyObject *args) {
02235     char *txt;
02236     object *myob;
02237 
02238     EXISTCHECK(who);
02239     if (!PyArg_ParseTuple(args, "s", &txt))
02240         return NULL;
02241 
02242     myob = cf_create_object_by_name(txt);
02243     if (myob)
02244         myob = cf_object_insert_object(myob, who->obj);
02245 
02246     return Crossfire_Object_wrap(myob);
02247 }
02248 
02249 static PyObject *Crossfire_Object_InsertInto(Crossfire_Object *who, PyObject *args) {
02250     /* Note that this function uses the METH_O calling convention. */
02251     Crossfire_Object *op = (Crossfire_Object*)args;
02252     object *myob;
02253 
02254     EXISTCHECK(who);
02255     TYPEEXISTCHECK(op);
02256 
02257     /* we can only insert removed object, so first remove it
02258      * from it's current container
02259      */
02260     if (!cf_object_get_flag(who->obj, FLAG_REMOVED)) {
02261         cf_object_remove(who->obj);
02262     }
02263     myob = cf_object_insert_in_ob(who->obj, op->obj);
02264 
02265     return Crossfire_Object_wrap(myob);
02266 }
02267 
02268 static PyObject *Crossfire_Object_ChangeAbil(Crossfire_Object *who, PyObject *args) {
02269     /* Note that this function uses the METH_O calling convention. */
02270     Crossfire_Object *op = (Crossfire_Object*)args;
02271 
02272     EXISTCHECK(who);
02273     TYPEEXISTCHECK(op);
02274 
02275     return Py_BuildValue("i", cf_object_change_abil(who->obj, op->obj));
02276 }
02277 
02278 static PyObject *Crossfire_Object_AddExp(Crossfire_Object *who, PyObject *args) {
02279     sint64 exp;
02280     const char *skill = NULL;
02281     int arg = 0;
02282 
02283     if (!PyArg_ParseTuple(args, "L|si", &exp, &skill, &arg))
02284         return NULL;
02285     EXISTCHECK(who);
02286     cf_object_change_exp(who->obj, exp, skill, arg);
02287     Py_INCREF(Py_None);
02288     return Py_None;
02289 }
02290 
02291 static PyObject *Crossfire_Object_Move(Crossfire_Object *who, PyObject *args) {
02292     int dir;
02293 
02294     if (!PyArg_ParseTuple(args, "i", &dir))
02295         return NULL;
02296     EXISTCHECK(who);
02297     return Py_BuildValue("i", cf_object_move(who->obj, dir, who->obj));
02298 }
02299 
02300 static PyObject *Crossfire_Object_Event(Crossfire_Object *who, PyObject *args) {
02301     int fix;
02302     const char *message = NULL;
02303     object *op1 = NULL;
02304     object *op2 = NULL;
02305     object *op3 = NULL;
02306     Crossfire_Object *activator = NULL;
02307     Crossfire_Object *third = NULL;
02308 
02309     if (!PyArg_ParseTuple(args, "O!O!si", &Crossfire_ObjectType, &activator, &Crossfire_ObjectType, &third, &message, &fix))
02310         return NULL;
02311     EXISTCHECK(who);
02312     EXISTCHECK(activator);
02313     EXISTCHECK(third);
02314     op1 = who->obj;
02315     op2 = activator->obj;
02316     op3 = third->obj;
02317     return Py_BuildValue("i", cf_object_user_event(op1, op2, op3, message, fix));
02318 }
02319 
02320 static int Crossfire_Object_InternalCompare(Crossfire_Object *left, Crossfire_Object *right) {
02321     EXISTCHECK_INT(left);
02322     EXISTCHECK_INT(right);
02323     return (left->obj < right->obj ? -1 : (left->obj == right->obj ? 0 : 1));
02324 }
02325 
02326 /* Legacy code: convert to long so that non-object functions work correctly */
02327 static PyObject *Crossfire_Object_Long(PyObject *obj) {
02328     return Py_BuildValue("l", ((Crossfire_Object *)obj)->obj);
02329 }
02330 
02331 #ifndef IS_PY3K
02332 static PyObject *Crossfire_Object_Int(PyObject *obj) {
02333     return Py_BuildValue("i", ((Crossfire_Object *)obj)->obj);
02334 }
02335 #endif
02336 
02340 static PyObject *Crossfire_Object_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
02341     Crossfire_Object *self;
02342 
02343     self = (Crossfire_Object *)type->tp_alloc(type, 0);
02344     if (self) {
02345         self->obj = NULL;
02346         self->count = 0;
02347     }
02348 
02349     return (PyObject *)self;
02350 }
02351 
02352 static PyObject *Crossfire_Player_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
02353     Crossfire_Player *self;
02354 
02355     self = (Crossfire_Player *)type->tp_alloc(type, 0);
02356     if (self) {
02357         self->obj = NULL;
02358         self->count = 0;
02359     }
02360 
02361     return (PyObject *)self;
02362 }
02363 
02364 static void Crossfire_Object_dealloc(PyObject *obj) {
02365     Crossfire_Object *self;
02366 
02367     self = (Crossfire_Object *)obj;
02368     if (self) {
02369         if (self->obj) {
02370             free_object_assoc(self->obj);
02371         }
02372         Py_TYPE(self)->tp_free(obj);
02373     }
02374 }
02375 
02376 static void Crossfire_Player_dealloc(PyObject *obj) {
02377     Crossfire_Player *self;
02378 
02379     self = (Crossfire_Player *)obj;
02380     if (self) {
02381         if (self->obj) {
02382             free_object_assoc(self->obj);
02383         }
02384         Py_TYPE(self)->tp_free(obj);
02385     }
02386 }
02387 
02388 PyObject *Crossfire_Object_wrap(object *what) {
02389     Crossfire_Object *wrapper;
02390     Crossfire_Player *plwrap;
02391     PyObject *pyobj;
02392 
02393     /* return None if no object was to be wrapped */
02394     if (what == NULL) {
02395         Py_INCREF(Py_None);
02396         return Py_None;
02397     }
02398 
02399     pyobj = find_assoc_pyobject(what);
02400     if ((!pyobj) || (was_destroyed(((Crossfire_Object *)pyobj)->obj, ((Crossfire_Object *)pyobj)->count))) {
02401         if (what->type == PLAYER) {
02402             plwrap = PyObject_NEW(Crossfire_Player, &Crossfire_PlayerType);
02403             if (plwrap != NULL) {
02404                 plwrap->obj = what;
02405                 plwrap->count = what->count;
02406             }
02407             pyobj = (PyObject *)plwrap;
02408         } else {
02409             wrapper = PyObject_NEW(Crossfire_Object, &Crossfire_ObjectType);
02410             if (wrapper != NULL) {
02411                 wrapper->obj = what;
02412                 wrapper->count = what->count;
02413             }
02414             pyobj = (PyObject *)wrapper;
02415         }
02416         add_object_assoc(what, pyobj);
02417     } else {
02418         Py_INCREF(pyobj);
02419     }
02420     return pyobj;
02421 }