MultiMUD how to extend object values:

From: Katzlberger Thomas (cat@garfield.Vanderbilt.Edu)
Date: 08/20/95


Hi all !
Greetings from MultiMUD telnet 132.230.36.55 4242 !

More useful code to implement :)
I ran out of object values (4 isn't that many)
so I found this solution:

old:
0 0 0 0

new:
s 0 0 0 0 0 0 0 0

You have to decide with the item type what is inside the union
and use the appropriate value. Un modified Circle 3.0's should
swallow this modification without complain.

structs.h:
----------
struct obj_flag_data 
    {
        union {
            int    value[4];     /* Values of the item (see list)    */
            short svalue[8];
            byte  bvalue[16];
        } values;
        byte    type_flag;   /* Type of item                */
        int     wear_flags;  /* Where you can wear it       */
        int     extra_flags;     /* If it hums, glows, etc.     */
        int     weight;      /* Weigt what else                  */
        int     cost;        /* Value when sold (gp.)            */
        int     cost_per_day;    /* Cost to keep pr. real day        */
        int     timer;       /* Timer for object                 */
        long    bitvector;   /* To set chars bits                */
        int     minlevel;  /* to set minlevel */
    };



utils.h:
--------
#define GET_OBJ_VAL(obj, val)   ((obj)->obj_flags.values.value[(val)])
#define GET_OBJ_SVAL(obj, val)  ((obj)->obj_flags.values.svalue[(val)])
#define GET_OBJ_CVAL(obj, val)  ((obj)->obj_flags.values.bvalue[(val)])


db.h
----
    if(*file_linebuf=='s')
    {   if((retval = sscanf(file_linebuf+1, "%d %d %d %d %d %d %d %d",
           t, t+1, t+2, t+3, t+4, t+5, t+6, t+7)) != 8)
            parse_error("Format error in second numeric line (expected 8 args)\n",1);

        obj_proto[i].obj_flags.values.svalue[0] = t[0];
        obj_proto[i].obj_flags.values.svalue[1] = t[1];
        obj_proto[i].obj_flags.values.svalue[2] = t[2];
        obj_proto[i].obj_flags.values.svalue[3] = t[3];
        obj_proto[i].obj_flags.values.svalue[4] = t[4];
        obj_proto[i].obj_flags.values.svalue[5] = t[5];
        obj_proto[i].obj_flags.values.svalue[6] = t[6];
        obj_proto[i].obj_flags.values.svalue[7] = t[7];
    }
    else    
    {   if((retval = sscanf(file_linebuf, "%d %d %d %d", t, t + 1, t + 2, t + 3)) != 4)
            parse_error("Format error in second numeric line (expected 4 args)\n",1);
        
        ... as usual here ...
    }

Please don't bug me with questions like I don't have this function ...
If you are an experienced programmer you know what I mean, otherwise
ignore this mail.

Kilian@MultiMud. telnet 132.230.36.55 4242



This archive was generated by hypermail 2b30 : 12/18/00 PST