Crossfire Client, Trunk  R18666
/home/leaf/crossfire/client/trunk/common/item.h
Go to the documentation of this file.
00001 /*
00002  * static char *rcsid_common_item_h =
00003  *   "$Id: item.h 12149 2009-08-20 02:11:28Z kbulgrien $";
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 
00032 #ifndef ITEM_H
00033 #define ITEM_H
00034 
00035 /*
00036  *  Use static buffer for object names. Item names are changing so
00037  *  often that mallocing them it just a waste of time. Also there is
00038  *  probably some upper limits for names that client can show, Note
00039  *  that total number of items is small (<100) so this don't even
00040  *  waste too much memory
00041  */
00042 #define NAME_LEN        128
00043 #define copy_name(t,f) strncpy(t, f, NAME_LEN-1); t[NAME_LEN-1]=0;
00044 
00045 #define NO_ITEM_TYPE            30000
00046 /*
00047  *  item structure keeps all information what player
00048  *  (= client) knows about items in its inventory
00049  */
00050 typedef struct item_struct {
00051     struct item_struct *next;   /* next item in inventory */
00052     struct item_struct *prev;   /* previous item in inventory */
00053     struct item_struct *env;    /* which items inventory is this item */
00054     struct item_struct *inv;    /* items inventory */
00055     char d_name[NAME_LEN];      /* item's full name w/o status information */
00056     char s_name[NAME_LEN];      /* item's singular name as sent to us */
00057     char p_name[NAME_LEN];      /* item's plural name as sent to us */
00058     char flags[NAME_LEN];       /* item's status information */
00059     sint32 tag;                 /* item identifier (0 = free) */
00060     uint32 nrof;                /* number of items */
00061     float weight;               /* how much item weights */
00062     sint16 face;                /* index for face array */
00063     uint16 animation_id;        /* Index into animation array */
00064     uint8 anim_speed;           /* how often to animate */
00065     uint8 anim_state;           /* last face in sequence drawn */
00066     uint16 last_anim;           /* how many ticks have passed since we last animated */
00067     uint16 magical:1;           /* item is magical */
00068     uint16 cursed:1;            /* item is cursed */
00069     uint16 damned:1;            /* item is damned */
00070     uint16 unpaid:1;            /* item is unpaid */
00071     uint16 locked:1;            /* item is locked */
00072     uint16 applied:1;           /* item is applied */
00073     uint16 open:1;              /* container is open */
00074     uint16 was_open:1;          /* container was open */
00075     uint16 inv_updated:1;       /* item's inventory is updated, this is set
00076                                    when item's inventory is modified, draw
00077                                    routines can use this to redraw things */
00078     uint8 apply_type;           /* how item is applied (worn/wield/etc) */
00079     uint32 flagsval;            /* unmodified flags value as sent from the server*/
00080     uint16   type;              /* Item type for ordering */
00081 } item;
00082 
00083 /* Toolkits implement these. */
00084 extern void item_event_item_deleting(item * it);
00085 extern void item_event_container_clearing(item * container);
00086 /* TODO More fine-grained event - but how to handle it? */
00087 extern void item_event_item_changed(item * it);
00088 extern int can_write_spell_on(item* it);
00089 
00090 #endif /* ITEM_H */