Bitvector_t woes continued

From: Mathew Earle Reuther (graymere@zipcon.net)
Date: 09/17/02


So, I've managed to get the flags on my mud to correctly display in OLC
(as in, they will register correctly when I type in one above 31 now) and
am trying to continue my fight to have working flags/bitvectors.
I needed to add a type of flag to my objects for antis (didn't want to mix
antis and other item flags, and will have over 64 of the two combined when
I've finished up anyway, so splitting them now seemed a good plan) and
I've placed appropriate entries in db.c and genobj.c for the
loading/saving.
However, this is not working.  Bear with my long example below, please,
this is driving me insane: (Doesn't help that I'm massively sick with a
sinus infection either!)
Editing an item in OasisOLC.  I make changes to it so that it looks like
below:
-- Item number : [1250]
1) Namelist : spellbook book
2) S-Desc   : a spellbook
3) L-Desc   :-
A spellbook lies here.
4) A-Desc   :-
<not set>
5) Type        : SPELLBOOK
6) Extra flags : GLOW HUM NO_RENT
7) Anti flags  : WANDERER APPRENTICE ARMSMAN FAITHFUL URCHIN
8) Wear flags  : TAKE FINGER NECK BODY HEAD LEGS FEET
9) Weight      : 5
A) Cost        : 50
B) Cost/Day    : 10
C) Timer       : 0
D) Values      : 50 53 0 0
E) Applies menu
F) Extra descriptions menu
M) Min Level   : 0
P) Perm Affects: NOBITS
S) Script      : Not Set.
Q) Quit
Enter choice : q
Do you wish to save this object internally? : y
Saving object to memory.
> saveall
World files saved.
So, now that it is saved, I open up my objects file and see this:
#1250
spellbook book~
a spellbook~
A spellbook lies here.~
~
24 abcGHI abcdefgGHIJKLM 0
0 50 53 0
0 5 50 10
(null)
$~
Obviously, something has gone horribly wrong here!  (Way too many flags,
things shifting, etc.)  So I open up the item again.  Everything is in the
right place, the display is as it was when I exited.  So, I reboot.  Load
up the object again:
-- Item number : [1250]
1) Namelist : spellbook book
2) S-Desc   : a spellbook
3) L-Desc   :-
A spellbook lies here.
4) A-Desc   :-
<not set>
5) Type        : SPELLBOOK
6) Extra flags : GLOW HUM NO_RENT
7) Anti flags  : WANDERER APPRENTICE ARMSMAN
8) Wear flags  : TAKE FINGER NECK BODY HEAD LEGS FEET
9) Weight      : 0
A) Cost        : 5
B) Cost/Day    : 50
C) Timer       : 0
D) Values      : 0 50 53 0
E) Applies menu
F) Extra descriptions menu
M) Min Level   : 10
P) Perm Affects: NOBITS
S) Script      : Not Set.
Q) Quit
Enter choice :
The anti flags have changed for one (big shock considering they are saving
as "(null)" in the .obj files) . . . also, the values have shifted over
one place: weight is 0 and the others have "acquired" some different
values.
Here is the code from my genobj.c and db.c:
db.c parse_object, section on numeric data, I've added a line to hold my
new flag:
  /* *** numeric data *** */
  if (!get_line(obj_f, line)) {
    log("SYSERR: Expecting first numeric line of %s, but file ended!",
buf2);
    exit(1);
  }
  if ((retval = sscanf(line, "%d %s %s %d", t, f1, f2, t + 3)) != 4) {
    if (retval == 3)
      t[3] = 0;
    else {
      log("SYSERR: Format error in first numeric line (expecting 4 args,
got %d), %s", retval, buf2);
    exit(1);
  }
  }

  /* Object flags checked in check_object(). */
  GET_OBJ_TYPE(obj_proto + i) = t[0];
  GET_OBJ_EXTRA(obj_proto + i) = asciiflag_conv(f1);
  GET_OBJ_WEAR(obj_proto + i) = asciiflag_conv(f2);
  GET_OBJ_PERM(obj_proto + i) = t[3];

  if (!get_line(obj_f, line)) {
    log("SYSERR: Expecting second numeric line of %s, but file ended!",
buf2);
    exit(1);
  }
  if ((retval = sscanf(line, "%d %d %d %d", t, t + 1, t + 2, t + 3)) != 4)
{
    log("SYSERR: Format error in second numeric line (expecting 4 args,
got %d), %s", retval, buf2);
    exit(1);
  }
  GET_OBJ_VAL(obj_proto + i, 0) = t[0];
  GET_OBJ_VAL(obj_proto + i, 1) = t[1];
  GET_OBJ_VAL(obj_proto + i, 2) = t[2];
  GET_OBJ_VAL(obj_proto + i, 3) = t[3];

  if (!get_line(obj_f, line)) {
    log("SYSERR: Expecting third numeric line of %s, but file ended!",
buf2);
    exit(1);
  }
  if ((retval = sscanf(line, "%d %d %d %d", t, t + 1, t + 2, t + 3)) != 4)
{
    if (retval == 3)
      t[3] = 0;
    else {
      log("SYSERR: Format error in third numeric line (expecting 4 args,
got %d), %s", retval, buf2);
    exit(1);
  }
  }
  GET_OBJ_WEIGHT(obj_proto + i) = t[0];
  GET_OBJ_COST(obj_proto + i) = t[1];
  GET_OBJ_RENT(obj_proto + i) = t[2];
  GET_OBJ_LEVEL(obj_proto + i) = t[3];

  if (!get_line(obj_f, line)) {
    log("SYSERR: Expecting fourth numeric line of %s, but file ended!",
buf2);
    exit(1);
  }
  if ((retval = sscanf(line, "%s", f3)) != 1) {
    log("SYSERR: Format error in fourth numeric line (expecting 1 arg, got
%d), %s", retval, buf2);
    exit(1);
  }
  GET_OBJ_ANTI(obj_proto + i) = asciiflag_conv(f1);

  /* check to make sure that weight of containers exceeds curr. quantity
*/

genobj.c in save_objects I've added a line to be saved as follows:
      sprintascii(buf1, GET_OBJ_EXTRA(obj));
      sprintascii(buf3, GET_OBJ_ANTI(obj));
      sprintascii(buf2, GET_OBJ_WEAR(obj));

      fprintf(fp,
              "%d %s %s %Lu\n"
              "%d %d %d %d\n"
              "%d %d %d %d\n"
              "%s\n",

              GET_OBJ_TYPE(obj), buf1, buf2, GET_OBJ_PERM(obj),
              GET_OBJ_VAL(obj, 0), GET_OBJ_VAL(obj, 1), GET_OBJ_VAL(obj,
2), GET_OBJ_VAL(obj, 3),
              GET_OBJ_WEIGHT(obj), GET_OBJ_COST(obj), GET_OBJ_RENT(obj),
GET_OBJ_LEVEL(obj),
              buf3
      );
My asciiflag/sprintb/sprinta routines were posted earlier, I don't want to
repost them and make this much longer than it already is.
If anyone has any idea what I'm doing wrong, please let me know.  This is
really starting to frustrate me to no end. :)
-Mathew

--
   +---------------------------------------------------------------+
   | 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