Latest work has been... a little fruitful? Sort of?
I've managed to get it to save onto the mob file AND medit will pull up the data. However... look at how it saves it.
Code:
#1
old man~
an old man~
Sitting on a small stool is an old man, who mumbles to himself quietly.
~
Dressed in old grey robes, this old man has only a few wisps of spindly white
hair left on his head. His beard, though it reaches his chest, is thin and can
be seen through. Wrinkles form creases on his face, and his eyes look like they
are shut at first glance. However, they're just barely open, and he mumbles to
himself in an incoherent manner. He slowly rocks back and forth on the stool,
as if constantly shifting his weight to get more comfortable.
~
He nods approvingly. "@YWell done, well done indeed!@n"
~
262154 0 0 0 0 0 0 0 0 E
0 20 10 1d1+0 1d1+0
0 0
8 8 1
E
T 10
A
A
help~
giving
~
A
A
name~
higgins
~
For some reason it saves 2 As in a row. So, while it DOES read the keyword and desc properly... every single topic now has an A as one of the keywords.
I had to make a change in db.c and it MIGHT be part of the problem... see, objects and rooms had code for parsing extra descs but mobs? Nada. And the formatting for objects and rooms is different enough that you can't just copy and paste it. So... here is what I tried to do.
Code:
switch (UPPER(letter)) {
case 'S': /* Simple monsters */
parse_simple_mob(mob_f, i, nr);
break;
case 'E': /* Circle3 Enhanced monsters */
parse_enhanced_mob(mob_f, i, nr);
break;
/* add new mob types here.. */
default:
log("SYSERR: Unsupported mob type '%c' in mob #%d", letter, nr);
exit(1);
}
letter = fread_letter(mob_f);
ungetc(letter, mob_f);
while ((letter =='E') || (letter == 'T')) {
if (letter == 'E') {
CREATE(new_descr, struct extra_descr_data, 1);
new_descr->keyword = fread_string(mob_f, buf2);
new_descr->description = fread_string(mob_f, buf2);
new_descr->next = mob_proto[i].ex_description;
mob_proto[i].ex_description = new_descr;
} else if (letter == 'T')
dg_read_trigger(mob_f, &mob_proto[i], MOB_TRIGGER);
letter = fread_letter(mob_f);
ungetc(letter, mob_f);
}
/* DG triggers -- script info follows mob S/E section
letter = fread_letter(mob_f);
ungetc(letter, mob_f);
while (letter=='T') {
dg_read_trigger(mob_f, &mob_proto[i], MOB_TRIGGER);
letter = fread_letter(mob_f);
ungetc(letter, mob_f);
} */
The commented out portion is what was used before: on reading a line, if ungetc gets a letter that is T, that means it's a trigger and it will put the trigger number afterwards on the same line. I took the same principle but had it read lines from the file instead.
Code:
fprintf(fd, "%d %d %d %d %d %d %d %d %d E\n"
"%d %d %d %dd%d+%d %dd%d+%d\n",
MOB_FLAGS(mob)[0], MOB_FLAGS(mob)[1],
MOB_FLAGS(mob)[2], MOB_FLAGS(mob)[3],
AFF_FLAGS(mob)[0], AFF_FLAGS(mob)[1],
AFF_FLAGS(mob)[2], AFF_FLAGS(mob)[3],
GET_ALIGNMENT(mob),
GET_LEVEL(mob), 20 - GET_HITROLL(mob), GET_AC(mob) / 10, GET_HIT(mob),
GET_MANA(mob), GET_MOVE(mob), GET_NDD(mob), GET_SDD(mob),
GET_DAMROLL(mob));
fprintf(fd, "%d %d\n"
"%d %d %d\n",
GET_GOLD(mob), GET_EXP(mob),
GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob)
);
/* Do we have extra descriptions? These are used for the ask chain system */
if (write_mobile_espec(mvnum, mob, fd) < 0)
log("SYSERR: GenOLC: Error writing E-specs for mobile #%d.", mvnum);
script_save_to_disk(fd, mob, MOB_TRIGGER);
if (mob->ex_description) { /* Yes, save them too. */
for (ex_desc = mob->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, LVL_IMMORT, TRUE, "SYSERR: OLC: medit_save_to_disk: Corrupt ex_desc/ask_chain!");
continue;
}
strncpy(buf, ex_desc->description, sizeof(buf) - 1);
strip_cr(buf);
fprintf(fd, "A\n"
"%s~\n"
"%s~\n", ex_desc->keyword, buf);
}
}
In this section of genmob.c, I decided to add in the saving of extra_descs after saving scripts to file. So, I have the feeling it is here that there are two As written to the file. It might just be due to me having worked at it for a while and needing a break, but I'm not seeing why it writes two As like it does.
I'm glad someone is finding this interesting.
This is a frustrating one for me; I really don't know that much about reading and writing files so it's hard for me.
Edit: Huh... it's the while loop I modded in db.c, I'm sure of it. Anyone see how I got it wrong?