Re: [A little long] Little problem with creating structures.

From: Mike Stilson (mike@velgarian.sytes.net)
Date: 06/28/02


On Fri, Jun 28, 2002 at 12:07:13PM +0200, Templar Viper wrote:
>Hello,
>
>I'm trying to implend weapon spells, but I'm not happy at all the way
>they are working, too limiting. I'm giving the builders the opportunity
>to modify the weapons-spells with strings. Here the troubled code:
>
>void oedit_setup_new(struct descriptor_data *d)
>{
[--snip--]

>  for(counter=0;counter<MAX_WEAPON_SPELLS;counter++) {
>    OLC_OBJ(d)->wpn_spells[counter].text = strdup("$p leaps to action with an attack of its own!");
>    OLC_OBJ(d)->wpn_spells[counter].text2 = strdup("In your hands, $p leaps to action with an attack of its own!");
>  }
>  SET_BIT_AR(GET_OBJ_WEAR(OLC_OBJ(d)), ITEM_WEAR_TAKE);
>  OLC_VAL(d) = 0;
>  OLC_ITEM_TYPE(d) = OBJ_TRIGGER;
>  oedit_disp_menu(d);
>}

This looking very much like my weapon spell snippet, I tossed in your
code and additions to struct weapon_spells.  In gdb, with a break set
at the oedit_disp_menu(d) line, here's my gdb output with a break set
before the oedit_disp_menu(d); call:

Breakpoint 1, oedit_setup_new (d=0x8570710) at oedit.c:217
217             oedit_disp_menu(d);
(gdb) p *d->olc->obj
$2 = {
  item_number = -1,
  in_room = -1,
  vroom = -1,
  obj_flags = {
  [--snip--]
  },
  affected = {{
    [--snip--]
    }},
  name = 0x8570be0 "unfinished object",
  description = 0x8576ac8 "An unfinished object is lying here.",
  short_description = 0x8570bf8 "an unfinished object",
  action_description = 0x0,
  ex_description = 0x0,
  carried_by = 0x0,
  worn_by = 0x0,
  worn_on = -1,
  in_obj = 0x0,
  contains = 0x0,
  id = 0,
  proto_script = 0x0,
  script = 0x0,
  has_spells = FALSE,
  wpn_spells = {{
      spellnum = 0,
      level = 0,
      percent = 0,
      engage = 0,
      text = 0x8576af0 "$p leaps to action with an attack of its own!.",
      text2 = 0x8576b08 "In your hands, $p leaps to action with an attack of its own!"
    }, {
    [ repeat above ]
    }, {
    [ repeat above ]
    }},
  next_content = 0x0,
  next = 0x0,
  sitting_here = 0x0
}

I made no changes anywhere else at all to the weapon spells code
including loading the obj protos, etc.

To figure it out further, let's see the backtrace of the crash since it
doesn't look to me like it's in that code.

The stack trace will show which line is giving the problem when it
crashes (You'll probably have to look a few frames above the actual
crash, but find which line w/in that command is called when it crashes.
That'll be the error.)

>However, when this function is called, the mud crashes with the
>following gdb output:
>
>Program received signal SIGSEGV, Segmentation fault.
>0x6108d3e5 in _libkernel32_a_iname ()

Looks to me like you're using cygwin.  I don't have access to it to
test/check it out on there, but at this point, type "bt" and copy/paste
that information.

>/* For weapon spells. */
>struct weapon_spells {
>  int spellnum;
>  int level;
>  int percent;
>  int engage;
>  char *text;
>  char *text2;
>};

I added the other 3 fields.

>Anyone know how to get this thing working?
Yes.  Fix the errant code, wherever that may be.


-me

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT