#include #define TITLE Quest( #define DESC , #define REWARD ,(struct item_t){ #define x , #define END }), const Quest QuestList[TOTAL_QUESTS]={ // Quest("Test","A test quest",(struct item_t){1,TEST_ITEM}), // Get quest list #include "../config/quest_list.txt" }; // Trust nobody #define STRLEN_MIN 16 unsigned int safe_strlen(const char *s){ unsigned int size=0; while(s[size])size++; if(sizetitle,t)){ #ifdef DEBUG DEBUG_printf("The QuestHandler already has this quest: %s\n",t); #endif // DEBUG return -2; } } for(i=0;ititle,t)){ current.erase(current.begin()+i); return current.size(); } } return -1; } int QuestHandler::finish(const char *t,void *completer){ unsigned char i; unsigned int r; for(i=0;ititle,t)){ #ifdef DEBUG DEBUG_printf("Completing quest %s.\n",t); #endif // DEBUG ((Entity *)completer)->inv->addItem(current[i]->reward.id,current[i]->reward.count); current.erase(current.begin()+i); #ifdef DEBUG DEBUG_printf("QuestHandler now has %u active quests.\n",current.size()); #endif // DEBUG return 0; } } #ifdef DEBUG DEBUG_printf("QuestHandler never had quest %s.\n",t); #endif // DEBUG return -1; } bool QuestHandler::hasQuest(const char *t){ unsigned int i; for(i=0;ititle,t)){ return true; } } return false; }