Crossfire Client, Branch  R11627
item.h
Go to the documentation of this file.
00001 /*
00002  * static char *rcsid_item_h =
00003  *   "$Id: item.h 6716 2007-06-27 18:57:31Z akirschbaum $";
00004  */
00005 /*
00006     Crossfire client, a client program for the crossfire program.
00007 
00008     Copyright (C) 2001 Mark Wedel & Crossfire Development Team
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU General Public License for more details.
00019 
00020     You should have received a copy of the GNU General Public License
00021     along with this program; if not, write to the Free Software
00022     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00023 
00024     The author can be reached via e-mail to crossfire-devel@real-time.com
00025 */
00026 
00027 #ifndef ITEM_H
00028 #define ITEM_H
00029 
00030 /*
00031  *  Use static buffer for object names. Item names are changing so
00032  *  often that mallocing them it just a waste of time. Also there is
00033  *  probably some upper limits for names that client can show, Note
00034  *  that total number of items is small (<100) so this don't even
00035  *  waste too much memory
00036  */
00037 #define NAME_LEN        128
00038 #define copy_name(t,f) strncpy(t, f, NAME_LEN-1); t[NAME_LEN-1]=0;
00039 
00040 #define NO_ITEM_TYPE            30000
00041 /*
00042  *  item structure keeps all information what player
00043  *  (= client) knows about items in its inventory
00044  */
00045 typedef struct item_struct {
00046     struct item_struct *next;   /* next item in inventory */
00047     struct item_struct *prev;   /* previous item in inventory */
00048     struct item_struct *env;    /* which items inventory is this item */
00049     struct item_struct *inv;    /* items inventory */
00050     char d_name[NAME_LEN];      /* item's full name w/o status information */
00051     char s_name[NAME_LEN];      /* item's singular name as sent to us */
00052     char p_name[NAME_LEN];      /* item's plural name as sent to us */
00053     char flags[NAME_LEN];       /* item's status information */
00054     sint32 tag;                 /* item identifier (0 = free) */
00055     uint32 nrof;                /* number of items */
00056     float weight;               /* how much item weights */
00057     sint16 face;                /* index for face array */
00058     uint16 animation_id;        /* Index into animation array */
00059     uint8 anim_speed;           /* how often to animate */
00060     uint8 anim_state;           /* last face in sequence drawn */
00061     uint16 last_anim;           /* how many ticks have passed since we last animated */
00062     uint16 magical:1;           /* item is magical */
00063     uint16 cursed:1;            /* item is cursed */
00064     uint16 damned:1;            /* item is damned */
00065     uint16 unpaid:1;            /* item is unpaid */
00066     uint16 locked:1;            /* item is locked */
00067     uint16 applied:1;           /* item is applied */
00068     uint16 open:1;              /* container is open */
00069     uint16 was_open:1;          /* container was open */
00070     uint16 inv_updated:1;       /* item's inventory is updated, this is set
00071                                    when item's inventory is modified, draw
00072                                    routines can use this to redraw things */
00073     uint8 apply_type;           /* how item is applied (worn/wield/etc) */
00074     uint32 flagsval;            /* unmodified flags value as sent from the server*/
00075     uint16   type;              /* Item type for ordering */
00076 } item;
00077 
00078 /* Toolkits implement these. */
00079 extern void item_event_item_deleting(item * it);
00080 extern void item_event_container_clearing(item * container);
00081 /* TODO More fine-grained event - but how to handle it? */
00082 extern void item_event_item_changed(item * it);
00083 extern int can_write_spell_on(item* it);
00084 
00085 #endif /* ITEM_H */