if (add == TRUE) //start with the cases where we add a quest, can_get_quest sanity check has been performed before modify_quest is called
{
switch (type)
{
case(1)://has_quest
{
if (ch->pcdata->has_quest[number] == TRUE) //already has quest
{
bug("Char already has quest: %d added.",number);
break;
}
if (ch->pcdata->has_quest_completed[number] == TRUE) //already has completed quest
{
bug("Char already has completed quest: %d.",number);
break;
}
bug("adding hasquest %d",number);
ch->pcdata->has_quest[number] = TRUE;[i]
break;
}
case(2)://has_quest_completed
{
if (ch->pcdata->has_quest_completed[number] == TRUE) //already has completed quest
{
bug("Char already has completed quest: %d.",number);
break;
}
bug("adding compquest %d",number);
ch->pcdata->has_quest_completed[number] = TRUE;
break;
}
default:
break;
}
return;
}
bug("adding hasquest %d",number);
ch->pcdata->has_quest[number] = TRUE;[i]
break;
[i]there. Don't know exactly what it's doing there.
I could really use some fresh eyes on this bug I am encountering.
Basically I am creating a manuel quest code. I have a bool has_quest_completed [MAX_QUESTS] in the pcdata struct, so that when someone completes a quest, for instance quest number 4, bool has_quest[4] changes to FALSE and bool has_quest_completed[4] changes to TRUE.
The function is declared as:
void modify_quest(CHAR_DATA *ch, int type, bool add,int number) where type is has_quest (defined as 1) or has_quest_completed (defined as 2), bool add is TRUE if we need ot add, otherwise FALSE if remove, number is the quest number.
Now the weird part:
When I want to add a quest to pcdata->has_quest_completed the relevant code is:
Now the weird part, I have had numours checks on either side of the ch->pcdata->has_quest_completed[number] = TRUE; and it all shows that when I for instance throw in number = 1, I get the has_quest_completed[1] set to TRUE, however the character suddenly gets ch->pcdata->has_quest[21] set to TRUE as well.
If I throw in number = 4, the has_quest_completed[4] is set to TRUE as it should, but now the character gets pcdata->has_quest[24] set to TRUE as well.
So for some odd reason it seems that the code set has_quest[2X] (x being the number) to TRUE.
The code is pretty basic so I fear the bug is somewhere else - however the checks I made right before and after the line tells me that, that perticular line is acting odd.
Any ideas anyone ?
Thanks