28 Jul, 2009, Bojack wrote in the 1st comment:
Votes: 0
Has anyone come across a weird bug with hedit.c, ill see if I can explain this correctly. If you create a help, hedit create <keyword> then delete that help cuz you messed up or something then try to recreate again… itll put you into the editor and whatever command you type it kicks you out of it. If you try to look up the help it says it doesnt exist. No matter how many times you hedit create that same name and get put into the editor.. whatever you type will kick you out of it so basically you get stuck not being able to create that name again or any name for that matter until you do a copyover to reset it all, and yes in between I was asave changing it all too just to make sure. Dont know if that makes any sense but here are the 3 main codes it uses:
btw dont mind all the "test", trying to find the problem.
void do_hedit( CHAR_DATA *ch, char *argument )
{
HELP_DATA *pHelp;
char arg1[MIL];
char argall[MAX_INPUT_LENGTH],argone[MAX_INPUT_LENGTH];
bool found = FALSE;
bool exist = FALSE;

strcpy(arg1,argument);

if(argument[0] != '\0')
{ sendch("dotest\n\r", ch);
/* Taken from do_help */
argall[0] = '\0';
while (argument[0] != '\0' )
{ sendch("dotest1\n\r", ch);
argument = one_argument(argument,argone);
if (argall[0] != '\0') { sendch("dotest1.1\n\r",ch);
strcat(argall," "); }
strcat(argall,argone);
}
for ( pHelp = help_first; pHelp != NULL; pHelp = pHelp->next )
{
if ( is_name( argall, pHelp->keyword ) && pHelp->level <= ch->level)
{ sendch("dotest2\n\r", ch);
ch->desc->pEdit=(void *)pHelp;
ch->desc->editor= ED_HELP;
found = TRUE;
exist = TRUE;
return;
}
else if(is_name( argall, pHelp->keyword ))
{ sendch ("dotest3\n\r", ch);
exist = TRUE;
}
}
}
if(!exist)
{
argument = one_argument(arg1, arg1);

if(!str_cmp(arg1,"create"))
{
if (argument[0] == '\0')
{
sendch("Syntax: edit help create [topic]\n\r",ch);
return;
}
if (hedit_create(ch, argument) ) {
ch->desc->editor = ED_HELP;
sendch("dotest4\n\r", ch); }
return;
}
}
if(exist && !found)
{
sendch("There is no helpfile by that name.\n\r", ch);
return;
}
sendch( "HEdit: There is no default help to edit.\n\r", ch );
return;
}

HEDIT (hedit_delete)
{
HELP_DATA *pHelp, *temp;
HELP_AREA *had;
DESCRIPTOR_DATA *d;
bool found = FALSE;

EDIT_HELP (ch, pHelp);

for (d = descriptor_list; d; d = d->next) {
if (d->editor == ED_HELP && pHelp == (HELP_DATA *) d->pEdit)
edit_done (d->character); sendch("dtest1\n\r", ch);}

if (help_first == pHelp) {
help_first = help_first->next; sendch("dtest2\n\r", ch); }
else
{
for (temp = help_first; temp; temp = temp->next)
if (temp->next == pHelp) { sendch("dtest3\n\r", ch);
break; }

if (!temp)
{
logstr (LOG_BUG, "hedit_delete : help %s not found in help_first",
pHelp->keyword);
return FALSE;
}

temp->next = pHelp->next;
}

for (had = had_list; had; had = had->next)
if (pHelp == had->first)
{
sendch("dtest4\n\r", ch);
found = TRUE;
had->first = had->first->next_area;
}
else
{
for (temp = had->first; temp; temp = temp->next_area)
if (temp->next_area == pHelp) { sendch("dtest5\n\r",ch);
break; }

if (temp)
{
sendch("dtest6\n\r", ch);
temp->next_area = pHelp->next_area;
found = TRUE;
break;
}
}

if (!found)
{
logstr (LOG_BUG, "hedit_delete : help %s not found in had_list",
pHelp->keyword);
return FALSE;
}

free_help (pHelp);

sendch ("Ok.\n\r", ch);
return TRUE;

}

HEDIT (hedit_create) {
extern HELP_DATA *help_last;
HELP_AREA *had;
HELP_DATA *help;

if (IS_NULLSTR (argument)) {
sendch ("Syntax: create [name]\n\r", ch);
return FALSE;
}

if (!(had = had_lookup ("help_new.are")))
had = ch->in_room->area->helps;

if (help_lookup (argument)) {
sendch ("HEdit : help already exists.\n\r", ch);
return FALSE;
}

// the area has no helps
if (!had) {
had = new_had ();
had->filename = str_dup (ch->in_room->area->file_name);
had->area = ch->in_room->area;
had->first = NULL;
had->last = NULL;
had->changed = TRUE;
had->next = had_list;
had_list = had;
ch->in_room->area->helps = had;
SET_BIT (ch->in_room->area->area_flags, AREA_CHANGED);
sendch("test\n\r", ch);
}
sendch ("test1\n\r",ch);
help = new_help ();
help->level = 0;
help->keyword = str_dup (argument);
help->text = str_dup ("");

if (help_last) {
help_last->next = help; sendch("test2\n\r",ch); }

if (help_first == NULL) {
help_first = help; sendch("test3\n\r",ch); }

help_last = help;
help->next = NULL;

if (!had->first) {
had->first = help; sendch("test5\n\r", ch); }
if (!had->last) {
had->last = help; sendch("test6\n\r", ch); }

had->last->next_area = help;
had->last = help;
help->next_area = NULL;

ch->desc->pEdit = (HELP_DATA *) help;
ch->desc->editor = ED_HELP;

sendch ("Ok.\n\r", ch);
return FALSE;
}
20 Aug, 2009, Bojack wrote in the 2nd comment:
Votes: 0
Still trying to narrow this bug down. When I create, its put into memory and then I save it to file. Right after I delete it, deletes it from memory and file then I save again. When I recreate the same name.. it goes into the editor but anything command wise I type for that editor, itll immediately kick me out of it and I cant look that help up. Its either something in the memory or this which doesnt look right to me:
HELP_AREA *get_help_area (HELP_DATA * help)
{
HELP_AREA *temp;
HELP_DATA *thelp;

for (temp = had_list; temp; temp = temp->next)
for (thelp = temp->first; thelp; thelp = thelp->next_area)
if (thelp == help)
return temp;

return NULL;
}

This is called in void hedit right at the beginning which is where im getting kicked out of the editor at too because its returning NULL instead of temp. Can someone help me figure this out, im really annoyed by this bug.
0.0/2