Little problem with creating structures.

From: Templar Viper (
Date: 06/28/02


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)
  int counter;

  CREATE(OLC_OBJ(d), struct obj_data, 1);

  OLC_OBJ(d)->name = strdup("unfinished object");
  OLC_OBJ(d)->description = strdup("An unfinished object is lying here.");
  OLC_OBJ(d)->short_description = strdup("an unfinished object");
  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!");
  OLC_VAL(d) = 0;

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 ()

So, I think the memory is not being created, allocated, something
like that. My knowledge of C is not good enough to find out what is
wrong. Here are the structures and macro's themself:

#define OLC(d)  ((struct oasis_olc_data *)(d)->olc)
#define OLC_OBJ(d)  (OLC(d)->obj)  /* Object structure. */

struct oasis_olc_data {
  The normal structures.. You know.
  struct char_data *mob;

  struct trig_proto_list *script;
  char *storage;
  struct assembly_data *OlcAssembly;

struct obj_data {
   The normal obj_data structures etc.  

   bool   has_spells;
   struct weapon_spells wpn_spells[MAX_WEAPON_SPELLS];

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

Anyone know how to get this thing working? 

   | FAQ: |
   | Archives: |
   | Newbie List:   |

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