22 Jan, 2012, thecircuitbox wrote in the 1st comment:
Votes: 0
I am having trouble saving object flags. Oedit/olc sets it right, i can insert the object, but it does not keep through copy/reboot.
Stuff with an <——————– I added.


structs.h
struct obj_flag_data
{
int value[NUM_OBJ_VAL_POSITIONS]; /**< Values of the item (see list) */
byte type_flag; /**< Type of item */
int level; /**< Minimum level to use object */
int wear_flags[TW_ARRAY_MAX]; /**< Where you can wear it, if wearable */
int extra_flags[EF_ARRAY_MAX]; /**< If it hums, glows, etc. */
int weight; /**< Weight of the object */
int cost; /**< Value when sold */
int cost_per_day; /**< Rent cost per real day */
int timer; /**< Timer for object */
int bitvector[AF_ARRAY_MAX]; /**< Affects characters */
byte implant_flag; /**< Type of item */ <——————–
int insert_flags[IM_ARRAY_MAX]; /**< Where you can wear it, if wearable */ <——————–
};


/** The Object structure. */
struct obj_data
{
obj_rnum item_number; /**< The unique id of this object instance. */
room_rnum in_room; /**< What room is the object lying in, or -1? */

struct obj_flag_data obj_flags; /**< Object information */
struct obj_affected_type affected[MAX_OBJ_AFFECT]; /**< affects */

char *name; /**< Keyword reference(s) for object. */
char *description; /**< Shown when the object is lying in a room. */
char *short_description; /**< Shown when worn, carried, in a container */
char *action_description; /**< Displays when (if) the object is used */
struct extra_descr_data *ex_description; /**< List of extra descriptions */
struct char_data *carried_by; /**< Points to PC/NPC carrying, or NULL */
struct char_data *worn_by; /**< Points to PC/NPC wearing, or NULL */
sh_int worn_on; /**< If the object can be worn, where can it be worn? */
struct char_data *insert_by; /**< Points to PC/NPC wearing, or NULL */ <——————–
sh_int insert_on; /**< If the object can be worn, where can it be worn? */ <——————–

struct obj_data *in_obj; /**< Points to carrying object, or NULL */
struct obj_data *contains; /**< List of objects being carried, or NULL */

long id; /**< used by DG triggers - unique id */
struct trig_proto_list *proto_script; /**< list of default triggers */
struct script_data *script; /**< script info for the object */

struct obj_data *next_content; /**< For 'contains' lists */
struct obj_data *next; /**< For the object list */
struct char_data *sitting_here; /**< For furniture, who is sitting in it */
struct mail_data *in_mail; /**< Which mail object is attached to */
};


/** Instance info for an object that gets saved to disk.
* DO NOT CHANGE if you are using binary object files
* and already have a player base and don't want to do a player wipe. */
struct obj_file_elem
{
obj_vnum item_number; /**< The prototype, non-unique info for this object. */

#if USE_AUTOEQ
sh_int location; /**< If re-equipping objects on load, wear object here */
#endif
int value[NUM_OBJ_VAL_POSITIONS]; /**< Current object values */
int extra_flags[EF_ARRAY_MAX]; /**< Object extra flags */
int weight; /**< Object weight */
int timer; /**< Current object timer setting */
int bitvector[AF_ARRAY_MAX]; /**< Object affects */
struct obj_affected_type affected[MAX_OBJ_AFFECT]; /**< Affects to mobs */
};



genobj.c
int save_objects(zone_rnum zone_num)
{
char filename[128], buf[MAX_STRING_LENGTH];
char ebuf1[MAX_STRING_LENGTH], ebuf2[MAX_STRING_LENGTH], ebuf3[MAX_STRING_LENGTH], ebuf4[MAX_STRING_LENGTH];
char wbuf1[MAX_STRING_LENGTH], wbuf2[MAX_STRING_LENGTH], wbuf3[MAX_STRING_LENGTH], wbuf4[MAX_STRING_LENGTH];
char pbuf1[MAX_STRING_LENGTH], pbuf2[MAX_STRING_LENGTH], pbuf3[MAX_STRING_LENGTH], pbuf4[MAX_STRING_LENGTH];
char ibuf1[MAX_STRING_LENGTH], ibuf2[MAX_STRING_LENGTH], ibuf3[MAX_STRING_LENGTH], ibuf4[MAX_STRING_LENGTH]; <——————–
int counter, counter2, realcounter;
FILE *fp;
struct obj_data *obj;
struct extra_descr_data *ex_desc;

#if CIRCLE_UNSIGNED_INDEX
if (zone_num == NOWHERE || zone_num > top_of_zone_table) {
#else
if (zone_num < 0 || zone_num > top_of_zone_table) {
#endif
log("SYSERR: GenOLC: save_objects: Invalid real zone number %d. (0-%d)", zone_num, top_of_zone_table);
return FALSE;
}

snprintf(filename, sizeof(filename), "%s/%d.new", OBJ_PREFIX, zone_table[zone_num].number);
if (!(fp = fopen(filename, "w+"))) {
mudlog(BRF, ADMLVL_IMMORT, TRUE, "SYSERR: OLC: Cannot open objects file %s!", filename);
return FALSE;
}
/* Start running through all objects in this zone. */
for (counter = genolc_zone_bottom(zone_num); counter <= zone_table[zone_num].top; counter++) {
if ((realcounter = real_object(counter)) != NOTHING) {
if ((obj = &obj_proto[realcounter])->action_description) {
strncpy(buf, obj->action_description, sizeof(buf) - 1);
strip_cr(buf);
} else
*buf = '\0';

fprintf(fp,
"#%d\n"
"%s~\n"
"%s~\n"
"%s~\n"
"%s~\n",

GET_OBJ_VNUM(obj),
(obj->name && *obj->name) ? obj->name : "undefined",
(obj->short_description && *obj->short_description) ? obj->short_description : "undefined",
(obj->description && *obj->description) ? obj->description : "undefined",
buf);

sprintascii(ebuf1, GET_OBJ_EXTRA(obj)[0]);
sprintascii(ebuf2, GET_OBJ_EXTRA(obj)[1]);
sprintascii(ebuf3, GET_OBJ_EXTRA(obj)[2]);
sprintascii(ebuf4, GET_OBJ_EXTRA(obj)[3]);
sprintascii(wbuf1, GET_OBJ_WEAR(obj)[0]);
sprintascii(wbuf2, GET_OBJ_WEAR(obj)[1]);
sprintascii(wbuf3, GET_OBJ_WEAR(obj)[2]);
sprintascii(wbuf4, GET_OBJ_WEAR(obj)[3]);
sprintascii(pbuf1, GET_OBJ_PERM(obj)[0]);
sprintascii(pbuf2, GET_OBJ_PERM(obj)[1]);
sprintascii(pbuf3, GET_OBJ_PERM(obj)[2]);
sprintascii(pbuf4, GET_OBJ_PERM(obj)[3]);
sprintascii(ibuf1, GET_OBJ_INSERT(obj)[0]); <——————–
sprintascii(ibuf2, GET_OBJ_INSERT(obj)[1]); <——————–
sprintascii(ibuf3, GET_OBJ_INSERT(obj)[2]); <——————–
sprintascii(ibuf4, GET_OBJ_INSERT(obj)[3]); <——————–

fprintf(fp, "%d %s %s %s %s %s %s %s %s %s %s %s %s\n"
"%d %d %d %d\n"
"%d %d %d %d %d\n"
"%d\n" <——————–
"%s %s %s %s", <——————–

GET_OBJ_TYPE(obj),
ebuf1, ebuf2, ebuf3, ebuf4,
wbuf1, wbuf2, wbuf3, wbuf4,
pbuf1, pbuf2, pbuf3, pbuf4,
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), GET_OBJ_TIMER(obj),
GET_OBJ_IMPLANT(obj), <——————–
ibuf1, ibuf2, ibuf3, ibuf4 <——————–
);

/* Do we have script(s) attached? */
script_save_to_disk(fp, obj, OBJ_TRIGGER);

/* Do we have extra descriptions? */
if (obj->ex_description) { /* Yes, save them too. */
for (ex_desc = obj->ex_description; ex_desc; ex_desc = ex_desc->next) {
/* Sanity check to prevent nasty protection faults. */
if (!ex_desc->keyword || !ex_desc->description || !*ex_desc->keyword || !*ex_desc->description) {
mudlog(BRF, ADMLVL_IMMORT, TRUE, "SYSERR: OLC: oedit_save_to_disk: Corrupt ex_desc!");
continue;
}
strncpy(buf, ex_desc->description, sizeof(buf) - 1);
strip_cr(buf);
fprintf(fp, "E\n"
"%s~\n"
"%s~\n", ex_desc->keyword, buf);
}
}
/* Do we have affects? */
for (counter2 = 0; counter2 < MAX_OBJ_AFFECT; counter2++)
if (obj->affected[counter2].modifier)
fprintf(fp, "A\n"
"%d %d\n", obj->affected[counter2].location,
obj->affected[counter2].modifier);
}
}

/* Write the final line, close the file. */
fprintf(fp, "$~\n");
fclose(fp);
snprintf(buf, sizeof(buf), "%s/%d.obj", OBJ_PREFIX, zone_table[zone_num].number);
remove(buf);
rename(filename, buf);

if (in_save_list(zone_table[zone_num].number, SL_OBJ))
remove_from_save_list(zone_table[zone_num].number, SL_OBJ);
return TRUE;
}


db.c
/* read all objects from obj file; generate index and prototypes */
char *parse_object(FILE *obj_f, int nr)
{
static int i = 0;
static char line[READ_SIZE];
int t[10], j, retval;
char *tmpptr, buf2[128], f1[READ_SIZE], f2[READ_SIZE], f3[READ_SIZE], f4[READ_SIZE];
char f5[READ_SIZE], f6[READ_SIZE], f7[READ_SIZE], f8[READ_SIZE];
char f9[READ_SIZE], f10[READ_SIZE], f11[READ_SIZE], f12[READ_SIZE];
struct extra_descr_data *new_descr;

obj_index[i].vnum = nr;
obj_index[i].number = 0;
obj_index[i].func = NULL;

clear_object(obj_proto + i);
obj_proto[i].item_number = i;

sprintf(buf2, "object #%d", nr); /* sprintf: OK (for 'buf2 >= 19') */

/* string data */
if ((obj_proto[i].name = fread_string(obj_f, buf2)) == NULL) {
log("SYSERR: Null obj name or format error at or near %s", buf2);
exit(1);
}
tmpptr = obj_proto[i].short_description = fread_string(obj_f, buf2);
if (tmpptr && *tmpptr)
if (!str_cmp(fname(tmpptr), "a") || !str_cmp(fname(tmpptr), "an") ||
!str_cmp(fname(tmpptr), "the"))
*tmpptr = LOWER(*tmpptr);

tmpptr = obj_proto[i].description = fread_string(obj_f, buf2);
if (tmpptr && *tmpptr)
CAP(tmpptr);
obj_proto[i].action_description = fread_string(obj_f, buf2);

/* 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 %s %s %s %s %s %s %s %s %s %s %s %s %s %s", t, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12)) == 4) && (bitwarning == TRUE)) {
/* Let's make the implementor read some, before converting his world files. */
log("WARNING: Conventional object files detected. Please see config.c.");
exit(1);
} else if (((retval == 4) || (retval == 3)) && (bitwarning == FALSE)) {

if (retval == 3)
t[3] = 0;
else if (retval == 4)
t[3] = asciiflag_conv(f4);

log("Converting object #%d to 128bits..", nr);
GET_OBJ_EXTRA(obj_proto + i)[0] = asciiflag_conv(f1);
GET_OBJ_EXTRA(obj_proto + i)[1] = 0;
GET_OBJ_EXTRA(obj_proto + i)[2] = 0;
GET_OBJ_EXTRA(obj_proto + i)[3] = 0;
GET_OBJ_WEAR(obj_proto + i)[0] = asciiflag_conv(f2);
GET_OBJ_WEAR(obj_proto + i)[1] = 0;
GET_OBJ_WEAR(obj_proto + i)[2] = 0;
GET_OBJ_WEAR(obj_proto + i)[3] = 0;
GET_OBJ_PERM(obj_proto + i)[0] = asciiflag_conv_aff(f3);
GET_OBJ_PERM(obj_proto + i)[1] = 0;
GET_OBJ_PERM(obj_proto + i)[2] = 0;
GET_OBJ_PERM(obj_proto + i)[3] = 0;

if(bitsavetodisk) {
add_to_save_list(zone_table[real_zone_by_thing(nr)].number, 1);
converting = TRUE;
}

log(" done.");
} else if (retval == 13) {

GET_OBJ_EXTRA(obj_proto + i)[0] = asciiflag_conv(f1);
GET_OBJ_EXTRA(obj_proto + i)[1] = asciiflag_conv(f2);
GET_OBJ_EXTRA(obj_proto + i)[2] = asciiflag_conv(f3);
GET_OBJ_EXTRA(obj_proto + i)[3] = asciiflag_conv(f4);
GET_OBJ_WEAR(obj_proto + i)[0] = asciiflag_conv(f5);
GET_OBJ_WEAR(obj_proto + i)[1] = asciiflag_conv(f6);
GET_OBJ_WEAR(obj_proto + i)[2] = asciiflag_conv(f7);
GET_OBJ_WEAR(obj_proto + i)[3] = asciiflag_conv(f8);
GET_OBJ_PERM(obj_proto + i)[0] = asciiflag_conv(f9);
GET_OBJ_PERM(obj_proto + i)[1] = asciiflag_conv(f10);
GET_OBJ_PERM(obj_proto + i)[2] = asciiflag_conv(f11);
GET_OBJ_PERM(obj_proto + i)[3] = asciiflag_conv(f12);

} else {
log("SYSERR: Format error in first numeric line (expecting 13 args, got %d), %s", retval, buf2);
exit(1);
}

/* Object flags checked in check_object(). */
GET_OBJ_TYPE(obj_proto + i) = t[0];

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 %d", t, t + 1, t + 2, t + 3, t + 4)) != 5) {
if (retval == 3) {
t[3] = 0;
t[4] = 0;
} else if (retval == 4)
t[4] = 0;
else {
log("SYSERR: Format error in third numeric line (expecting 5 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];
GET_OBJ_TIMER(obj_proto + i) = t[4];

GET_OBJ_IMPLANT(obj_proto + i) = t[0]; <——————–
if (!get_line(obj_f, line)) { <——————–
log("SYSERR: Expecting fifth 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 fifth numeric line (expecting 4 args, got %d), %s", retval, buf2); <——————–
exit(1); <——————–
} <——————–

GET_OBJ_INSERT(obj_proto + i, 0) = t[0]; <——————–
GET_OBJ_INSERT(obj_proto + i, 1) = t[1]; <——————–
GET_OBJ_INSERT(obj_proto + i, 2) = t[2]; <——————–
GET_OBJ_INSERT(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 %d", t, t + 1, t + 2, t + 3, t + 4)) != 5) { <——————–
if (retval == 3) { <——————–
t[3] = 0; <——————–
t[4] = 0; <——————–
} else if (retval == 4) <——————–
t[4] = 0; <——————–
else { <——————–
log("SYSERR: Format error in third numeric line (expecting 5 args, got %d), %s", retval, buf2); <——————–
exit(1); <——————–
} <——————–
} <——————–

obj_proto[i].sitting_here = NULL;

/* check to make sure that weight of containers exceeds curr. quantity */
if (GET_OBJ_TYPE(obj_proto + i) == ITEM_DRINKCON ||
GET_OBJ_TYPE(obj_proto + i) == ITEM_FOUNTAIN) {
if (GET_OBJ_WEIGHT(obj_proto + i) < GET_OBJ_VAL(obj_proto + i, 1) && CAN_WEAR(obj_proto + i, ITEM_WEAR_TAKE))
GET_OBJ_WEIGHT(obj_proto + i) = GET_OBJ_VAL(obj_proto + i, 1) + 5;
}

/* extra descriptions and affect fields */
for (j = 0; j < MAX_OBJ_AFFECT; j++) {
obj_proto[i].affected[j].location = APPLY_NONE;
obj_proto[i].affected[j].modifier = 0;
}

strcat(buf2, ", after numeric constants\n" /* strcat: OK (for 'buf2 >= 87') */
"…expecting 'E', 'A', '$', or next object number");
j = 0;

for (;;) {
if (!get_line(obj_f, line)) {
log("SYSERR: Format error in %s", buf2);
exit(1);
}
switch (*line) {
case 'E':
CREATE(new_descr, struct extra_descr_data, 1);
new_descr->keyword = fread_string(obj_f, buf2);
new_descr->description = fread_string(obj_f, buf2);
new_descr->next = obj_proto[i].ex_description;
obj_proto[i].ex_description = new_descr;
break;
case 'A':
if (j >= MAX_OBJ_AFFECT) {
log("SYSERR: Too many A fields (%d max), %s", MAX_OBJ_AFFECT, buf2);
exit(1);
}
if (!get_line(obj_f, line)) {
log("SYSERR: Format error in 'A' field, %s\n"
"…expecting 2 numeric constants but file ended!", buf2);
exit(1);
}

if ((retval = sscanf(line, " %d %d ", t, t + 1)) != 2) {
log("SYSERR: Format error in 'A' field, %s\n"
"…expecting 2 numeric arguments, got %d\n"
"…offending line: '%s'", buf2, retval, line);
exit(1);
}
obj_proto[i].affected[j].location = t[0];
obj_proto[i].affected[j].modifier = t[1];
j++;
break;
case 'T': /* DG triggers */
dg_obj_trigger(line, &obj_proto[i]);
break;
case '$':
case '#':
top_of_objt = i;
check_object(obj_proto + i);
i++;
return (line);
default:
log("SYSERR: Format error in (%c): %s", *line, buf2);
exit(1);
}
}
}


* Parses the object records stored in fl, and returns the first object in a
* linked list, which also handles location if worn. This list can then be
* handled by house code, listrent code, autoeq code, etc. */
obj_save_data *objsave_parse_objects(FILE *fl)
{
obj_save_data *head, *current, *tempsave;
char f1[128], f2[128], f3[128], f4[128], i1[128], i2[128], i3[128], i4[128], line[READ_SIZE];
int t[4],i, nr;
struct obj_data *temp;

CREATE(current, obj_save_data, 1);
head = current;
current->locate = 0;

temp = NULL;
while (TRUE) {
char tag[6];
int num;

/* if the file is done, wrap it all up */
if(get_line(fl, line) == FALSE || (*line == '$' && line[1] == '~')) {
if (temp == NULL && current->obj == NULL) {
/* Remove current from list. */
tempsave = head;
if (tempsave == current) {
free(current);
head = NULL;
} else {
while (tempsave) {
if (tempsave->next == current)
tempsave->next = NULL;
tempsave = tempsave->next; }
free(current);
}
}
else if (temp != NULL && current->obj == NULL)
current->obj = temp;
else if (temp == NULL && current->obj != NULL) {
/* Do nothing. */
} else if (temp != NULL && current->obj != NULL) {
if (temp != current->obj)
log("inconsistent object pointers in objsave_parse_objects: %p/%p", temp, current->obj);
}

break;
}

/* if it's a new record, wrap up the old one, and make space for a new one */
if (*line == '#') {
/* check for false alarm. */
if (sscanf(line, "#%d", &nr) == 1) {
if (real_object(nr) == NOTHING) { //object does not exist
log("SYSERR: Protection: deleting object %d.", nr);
continue;
}
if (temp) {
current->obj = temp;
CREATE(current->next, obj_save_data, 1);
current=current->next;

current->locate = 0;
temp = NULL;
}
}
else
continue;
/* we have the number, check it, load obj. */
if (nr == NOTHING) { /* then it is unique */
temp = create_obj();
temp->item_number=NOTHING;
} else if (nr < 0) {
continue;
} else {
if(real_object(nr) != NOTHING) {
temp=read_object(nr,VIRTUAL);
/* Go read next line - nothing more to see here. */
} else {
log("Nonexistent object %d found in rent file.", nr);
}
}
/* go read next line - nothing more to see here. */
continue;
}

tag_argument(line, tag);
num = atoi(line);

switch(*tag) {
case 'A':
if (!strcmp(tag, "ADes")) {
char error[40];
snprintf(error, sizeof(error)-1, "rent(Ades):%s", temp->name);
temp->action_description = fread_string(fl, error);
} else if (!strcmp(tag, "Aff ")) {
sscanf(line, "%d %d %d", &t[0], &t[1], &t[2]);
if (t[0] < MAX_OBJ_AFFECT) {
temp->affected[t[0]].location = t[1];
temp->affected[t[0]].modifier = t[2];
}
}
break;
case 'C':
if (!strcmp(tag, "Cost"))
GET_OBJ_COST(temp) = num;
break;
case 'D':
if (!strcmp(tag, "Desc"))
temp->description = strdup(line);
break;
case 'E':
if(!strcmp(tag, "EDes")) {
struct extra_descr_data *new_desc;
char error[40];
snprintf(error, sizeof(error)-1, "rent(Edes): %s", temp->name);
if (temp->item_number != NOTHING && /* Regular object */
temp->ex_description && /* with ex_desc == prototype */
(temp->ex_description == obj_proto[real_object(temp->item_number)].ex_description))
temp->ex_description = NULL;
CREATE(new_desc, struct extra_descr_data, 1);
new_desc->keyword = fread_string(fl, error);
new_desc->description = fread_string(fl, error);
new_desc->next = temp->ex_description;
temp->ex_description = new_desc;
}
break;
case 'F':
if (!strcmp(tag, "Flag")) {
sscanf(line, "%s %s %s %s", f1, f2, f3, f4);
GET_OBJ_EXTRA(temp)[0] = asciiflag_conv(f1);
GET_OBJ_EXTRA(temp)[1] = asciiflag_conv(f2);
GET_OBJ_EXTRA(temp)[2] = asciiflag_conv(f3);
GET_OBJ_EXTRA(temp)[3] = asciiflag_conv(f4);
}
break;
case 'L':
if(!strcmp(tag, "Loc "))
current->locate = num;
break;
case 'N':
if (!strcmp(tag, "Name"))
temp->name = strdup(line);
break;
case 'P':
if (!strcmp(tag, "Perm")) {
sscanf(line, "%s %s %s %s", f1, f2, f3, f4);
GET_OBJ_PERM(temp)[0] = asciiflag_conv(f1);
GET_OBJ_PERM(temp)[1] = asciiflag_conv(f2);
GET_OBJ_PERM(temp)[2] = asciiflag_conv(f3);
GET_OBJ_PERM(temp)[3] = asciiflag_conv(f4);
}
break;
case 'R':
if (!strcmp(tag, "Rent"))
GET_OBJ_RENT(temp) = num;
break;
case 'S':
if (!strcmp(tag, "Shrt"))
temp->short_description = strdup(line);
break;
case 'T':
if (!strcmp(tag, "Type"))
GET_OBJ_TYPE(temp) = num;
break;
case 'W':
if (!strcmp(tag, "Wear")) {
sscanf(line, "%s %s %s %s", f1, f2, f3, f4);
GET_OBJ_WEAR(temp)[0] = asciiflag_conv(f1);
GET_OBJ_WEAR(temp)[1] = asciiflag_conv(f2);
GET_OBJ_WEAR(temp)[2] = asciiflag_conv(f3);
GET_OBJ_WEAR(temp)[3] = asciiflag_conv(f4);
}
else if (!strcmp(tag, "Wght"))
GET_OBJ_WEIGHT(temp) = num;
break;
case 'V':
if (!strcmp(tag, "Vals")) {
sscanf(line, "%d %d %d %d", &t[0], &t[1], &t[2], &t[3]);
for (i = 0; i < NUM_OBJ_VAL_POSITIONS; i++)
GET_OBJ_VAL(temp, i) = t[i];
}
break;
case 'G': <——————–
if (!strcmp(tag, "Implant")) <——————–
GET_OBJ_IMPLANT(temp) = num; <——————–
break; <——————–
case 'I': <——————–
if (!strcmp(tag, "Insert")) { <——————–
sscanf(line, "%s %s %s %s", i1, i2, i3, i4); <——————–
GET_OBJ_INSERT(temp)[0] = asciiflag_conv(i1); <——————–
GET_OBJ_INSERT(temp)[1] = asciiflag_conv(i2); <——————–
GET_OBJ_INSERT(temp)[2] = asciiflag_conv(i3); <——————–
GET_OBJ_INSERT(temp)[3] = asciiflag_conv(i4); <——————–
}
default:
log("Unknown tag in rentfile: %s", tag);
}
}

return head;
}
22 Jan, 2012, thecircuitbox wrote in the 2nd comment:
Votes: 0
make ../bin/circle
make[1]: Entering directory `/home/fubar/Desktop/test/src'
gcc -g -O2 -Wall -DIMC -DIMCCIRCLE -c -o db.o db.c
db.c: In function parse_object:
db.c:1847:3: warning: too few arguments for format
db.c:1946:34: error: macro "GET_OBJ_INSERT" passed 2 arguments, but takes just 1
db.c:1946:3: error: GET_OBJ_INSERT undeclared (first use in this function)
db.c:1946:3: note: each undeclared identifier is reported only once for each function it appears in
db.c:1947:34: error: macro "GET_OBJ_INSERT" passed 2 arguments, but takes just 1
db.c:1948:34: error: macro "GET_OBJ_INSERT" passed 2 arguments, but takes just 1
db.c:1949:34: error: macro "GET_OBJ_INSERT" passed 2 arguments, but takes just 1
make[1]: *** [db.o] Error 1
make[1]: Leaving directory `/home/fubar/Desktop/test/src'
make: *** [all] Error 2
23 Jan, 2012, David Haley wrote in the 3rd comment:
Votes: 0
You'll have to fix your compilation errors before the code will actually work. Do you understand what the errors are telling you?
23 Jan, 2012, thecircuitbox wrote in the 4th comment:
Votes: 0
No not reaLLY.
23 Jan, 2012, David Haley wrote in the 5th comment:
Votes: 0
Well, let's start with this one.

db.c:1946:34: error: macro "GET_OBJ_INSERT" passed 2 arguments, but takes just 1


This is saying that the macro only takes one argument, but you gave it two. Where did you define the macro? Is it a macro that you defined, or that somebody else wrote? You seem to think that you need two arguments for it… why? If you wrote it yourself, then you should fix the definition to account for the other argument, or not use the argument.

You're also using the macro inconsistently. Sometimes you have a 2nd argument, and sometimes you have a subscript…

Are you familiar with macros, function calls, and arguments?
23 Jan, 2012, thecircuitbox wrote in the 6th comment:
Votes: 0
This works however I do not know if it is the correct macro.
GET_OBJ_INSERT(obj_proto + i)[0] = 0;


before was:
GET_OBJ_INSERT(obj_proto + i, 0) = t[0];



The GET_OBJ is a macro? The "i, 0" is the argument?
23 Jan, 2012, David Haley wrote in the 7th comment:
Votes: 0
:sad:

I hope you don't take this the wrong way, but you really need to do some basic C tutorials before you do this. You need to understand what a macro is, and what arguments are. For example, the arguments are obj_proto+i, and then 0. But clearly the macro isn't defined to take two arguments. It's not really possible to help you here because you haven't given enough information, but I suspect that you're not sure what information to give because these aren't concepts that you're familiar with. So my best suggestion to you at this point is to find a C tutorial and work through it a bit, so that you can grasp the basic language concepts. Then these problems will be easy-peasy to you and you'll get a lot more done more quickly.
23 Jan, 2012, thecircuitbox wrote in the 8th comment:
Votes: 0
Yeah the macro is the same as the GET_OBJ_WEAR macro which does not have 2 arguments. SO trying to pass the macro through 2 arguments but only needs 1, gives the error.
23 Jan, 2012, thecircuitbox wrote in the 9th comment:
Votes: 0
if (!get_line(obj_f, line)) {
log("SYSERR: Expecting fourth numeric line of %s, but file ended!", buf2);
exit(1);
}
if ((retval = sscanf(line, "%d", t)) != 1) {
if (retval == 3) {
t[0] = 0;
} else if (retval == 4)
t[0] = 0;
else {
log("SYSERR: Format error in fourth numeric line (expecting 1 args, got %d), %s", retval, buf2);
exit(1);
}
}

GET_OBJ_IMPLANT(obj_proto + i) = t[0];

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 %s %s %s", i1, i2, i3, i4)) != 4) {
if (retval == 3) {
t[3] = 0;
} else if (retval == 4)
t[3] = asciiflag_conv_aff(i1);
else {
log("SYSERR: Format error in fourth numeric line (expecting 1 args, got %d), %s", retval, buf2);
exit(1);
}
}

GET_OBJ_INSERT(obj_proto + i)[0] = asciiflag_conv(i1);
GET_OBJ_INSERT(obj_proto + i)[1] = asciiflag_conv(i2);
GET_OBJ_INSERT(obj_proto + i)[2] = asciiflag_conv(i3);
GET_OBJ_INSERT(obj_proto + i)[3] = asciiflag_conv(i4);



I was able to fix it with the code above for now, will do more testing.

//EDIT: Initial testing looks good will test some more.
Random Picks
0.0/9