[DGD] Inherited objects list

Lord Lerkista lordlerkista at gmx.net
Thu Oct 27 11:37:02 CEST 2005


I need some help to fix this function, don't work like i want, i want to 
use it like "inherits <object>"
but always gives me information about the object that has the function 
call, ignoring my given object
I don't remember where i get this code, i had to edit it to make it run 
in my Mud, but i think i made
something wrong, any help??

/*
 * string *inherits(object obj)
 *
 * obj - the object for which the inherit information is required.
 *
 * Returns an array of the names of the objects that obj inherits.
 */

#ifdef FUNCDEF
FUNCDEF("inherits", kf_inherits, pt_inherits)
#else
char pt_inherits[] = { C_TYPECHECKED | C_STATIC, 1, 0, 0, 7, T_OBJECT, 
T_OBJECT };

int kf_inherits(f)
register frame *f;
{
   array       *inherit_list;
   control     *ctrl;
   object      *obj;
   value       *v;
   int         i;
   char                *object_name;
   char         buf[17];

   /*
    * Get the object argument and its control structure
    */
   obj = &otable[f->oindex];
   ctrl = o_control(obj);

   /*
    * Get the "base" name of the object
    */
   if (obj->flags & O_MASTER) {
      object_name = o_name(buf, obj);
   }
   else {
      object_name = o_name(buf, &otable[obj->u_master]);
   }
   if (ctrl->ninherits <= 0) {
      /*
       * This object doesn't inherit any others.
       * Return a "blank" array.
       */
      inherit_list = arr_new(f->data, 0L);
   }
   else {
      /*
       * Create a list of the names of objects inherited by this object
       */
      inherit_list = arr_new(f->data, (long) ctrl->ninherits - 1);
      for (i = 0, v = inherit_list->elts; i < ctrl->ninherits - 1; ) {
        /*
         * Don't include the name of the object's master object
         */
        if (strcmp(OBJR(ctrl->inherits[i].oindex)->chain.name, 
object_name)) {
            v->type = T_STRING;
            str_ref(v->u.string =
                       str_new(OBJR(ctrl->inherits[i].oindex)->chain.name,
                               
strlen(OBJR(ctrl->inherits[i].oindex)->chain.name)));
           i++;
           v++;
        }
      }
   }

   /*
    * Push the array on the stack
    */
   f->sp->type = T_ARRAY;
   arr_ref(f->sp->u.array = inherit_list);
   return 0;
}
#endif /* FUNCDEF */




More information about the DGD mailing list