Re: Obj Value referencing

From: Dan Argent (mbax7dja@FS1.CS.MAN.AC.UK)
Date: 05/21/98


Okay, I've been trying to reference the values of my objects using
one of the methods described by Daniel Koepke, i.e. loading an
instance of the ammo, whose vnum is held in one of the values of the
gun.

However, I don't seem to have the technical aptitude to make it
work. This is how I've written the code (please forgive the
hackishness of it, but I'm just trying to get it to work.)

As far as I can see, I can't convert the obj value in the way that I
am trying to do, but I can't see any other way to actually do it.
So when I try and use the command, I get: [CODE FOLLOWS BELOW]

Program received signal SIGSEGV, Segmentation fault.
0x806bed7 in fire_missile (ch=0x81ccc90, arg1=0xbffff584 "ser",
missile=0x0,
    pos=17, range=2, dir=0) at fight.c:1032
1032      if (GET_OBJ_TYPE(missile) == ITEM_GRENADE) {
(gdb) print anum
$1 = (struct obj_data *) 0x1e
(gdb) print *anum
Cannot access memory at address 0x1e.
(gdb) bt
#0  0x806bed7 in fire_missile (ch=0x81ccc90, arg1=0xbffff584 "ser",
    missile=0x0, pos=17, range=2, dir=0) at fight.c:1032
#1  0x805654d in do_shoot (ch=0x81ccc90, argument=0xbffff831 " ser n",
    cmd=238, subcmd=0) at act.offensive.c:508
#2  0x806fe92 in command_interpreter (ch=0x81ccc90,
    argument=0xbffff82c "shoot ser n") at interpreter.c:551
#3  0x8049de4 in game_loop (mother_desc=7) at comm.c:630
#4  0x80495b6 in init_game (port=4000) at comm.c:275
#5  0x804954a in main (argc=1, argv=0xbffffdac) at comm.c:245
#6  0x804928b in ___crt_dummy__ ()

[CODE]

void fire_missile(struct char_data *ch, char arg1[MAX_INPUT_LENGTH],
                  struct obj_data *missile, int pos, int range, int
                  dir)
{
struct obj_data *anum;
bool shot = FALSE, found = FALSE;
  int attacktype;
  int room, nextroom, distance;
  int ammo_num;
  struct char_data *vict;
   struct obj_data *weapon = GET_EQ(ch, WEAR_WIELD);

  if (ROOM_FLAGGED(ch->in_room, ROOM_PEACEFUL)) {
    send_to_char("This room just has such a peaceful, easy
    feeling...\r\n", ch); return;
  }

  room = ch->in_room;

ammo_num =   GET_EQ(ch, WEAR_WIELD)->obj_flags.value[0];
send_to_char ("ammo number %d \r\n", ch);

anum =  read_object(ammo_num, VIRTUAL);
send_to_char ("anum  number %d \r\n", ch);
obj_to_char ( anum, ch);
equip_char(ch, anum, WEAR_HOLD );
  if CAN_GO2(room, dir)
    nextroom = EXIT2(room, dir)->to_room;
  else
    nextroom = NOWHERE;

  if (GET_OBJ_TYPE(missile) == ITEM_GRENADE) {
    send_to_char("You throw it!\r\n", ch);
    sprintf(buf, "$n throws %s %s.",


Anyway,
If someone can help, I'd appreciate it.

Cheers

Dan.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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