--- deliantra/server/include/object.h 2007/05/12 13:27:37 1.119 +++ deliantra/server/include/object.h 2007/05/27 23:56:21 1.127 @@ -33,14 +33,14 @@ typedef int tag_t; enum { + body_skill, + body_combat, body_range, body_shield, - body_combat, body_arm, body_torso, body_head, body_neck, - body_skill, body_finger, body_shoulder, body_foot, @@ -50,11 +50,18 @@ NUM_BODY_LOCATIONS }; +enum slottype_t +{ + slot_none, + slot_combat, + slot_ranged, +}; + /* See common/item.c */ typedef struct Body_Locations { - const char *save_name; /* Name used to load/save it to disk */ + keyword save_name; /* Name used to load/save it to disk */ const char *use_name; /* Name used when describing an item we can use */ const char *nonuse_name; /* Name to describe objects we can't use */ } Body_Locations; @@ -102,11 +109,6 @@ #define WILL_APPLY_DOOR 0x08 #define WILL_APPLY_FOOD 0x10 -/* However, if you're keeping a pointer of some sort, you probably - * don't just want it copied, so you'll need to add to common/object.C, - * e.g. ->copy_to () - */ - struct body_slot { signed char info:4; /* body info as loaded from the file */ @@ -273,6 +275,7 @@ static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. bool write (object_freezer &f); + MTH int slottype () const; MTH static object *create (); object &operator =(const object &src); MTH void copy_to (object *dst); @@ -291,22 +294,6 @@ do_remove (); } - // move this object to the top of its env's inventory to speed up - // searches for it. - MTH void inv_splay () - { - if (env && env->inv != this) - { - if (above) above->below = below; - if (below) below->above = above; - - above = 0; - below = env->inv; - below->above = this; - env->inv = this; - } - } - static bool can_merge_slow (object *op1, object *op2); // this is often used in time-critical code, so optimise @@ -319,7 +306,8 @@ MTH void set_owner (object *owner); MTH void set_speed (float speed); - MTH void set_weapon (object *ob); + MTH bool change_weapon (object *ob); + MTH bool change_skill (object *ob); MTH void open_container (object *new_container); MTH void close_container () @@ -327,6 +315,12 @@ open_container (0); } + // overwrite the attachable should_invoke function with a version that also checks ev_want_type + bool should_invoke (event_type event) + { + return ev_want_event [event] || ev_want_type [type] || cb; + } + MTH void instantiate (); // recalculate all stats @@ -499,6 +493,25 @@ ~object (); }; +// move this object to the top of its env's inventory to speed up +// searches for it. +static object * +splay (object *ob) +{ + if (ob->env && ob->env->inv != ob) + { + if (ob->above) ob->above->below = ob->below; + if (ob->below) ob->below->above = ob->above; + + ob->above = 0; + ob->below = ob->env->inv; + ob->below->above = ob; + ob->env->inv = ob; + } + + return ob; +} + typedef object_vector objectvec; typedef object_vector activevec; @@ -526,6 +539,10 @@ struct oblinkpt *next; } oblinkpt; +object *find_skill_by_name (object *who, const char *name); +object *find_skill_by_name (object *who, const shstr &sh); +object *find_skill_by_number (object *who, int skillno); + /* * The archetype structure is a set of rules on how to generate and manipulate * objects which point to archetypes.