aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-10-13 08:47:09 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-10-13 08:47:09 -0400
commitcf8ed3fe2dfb2e5f569e1dbb3fd19c2673bd4b53 (patch)
tree677e5075aa5088ec91090dc7b563c883e835c173 /src
parent8f2f66a7b90f97911bbffce3ccc8c7ad01ba61ad (diff)
quest debug
Diffstat (limited to 'src')
-rw-r--r--src/Quest.cpp27
-rw-r--r--src/common.cpp4
-rw-r--r--src/gameplay.cpp14
3 files changed, 29 insertions, 16 deletions
diff --git a/src/Quest.cpp b/src/Quest.cpp
index c331e32..5d19795 100644
--- a/src/Quest.cpp
+++ b/src/Quest.cpp
@@ -1,5 +1,6 @@
-#include <Quest.h>
-#include <entities.h>
+#include <common.h>
+//#include <Quest.h>
+//#include <entities.h>
const Quest QuestList[TOTAL_QUESTS]={
Quest("Test","A test quest",(struct item_t){1,TEST_ITEM})
@@ -22,17 +23,26 @@ Quest::~Quest(){
int QuestHandler::assign(const char *t){
unsigned char i;
- for(i=0;i<current.size();i++){
+ for(i=0;i<current.size();i++){ // Make sure we don't already have this quest
if(!strcmp(current[i]->title,t)){
+#ifdef DEBUG
+ DEBUG_printf("The QuestHandler already has this quest: %s\n",t);
+#endif // DEBUG
return -2;
}
}
- for(i=0;i<TOTAL_QUESTS;i++){
+ for(i=0;i<TOTAL_QUESTS;i++){ // Add the quest (if it really exists)
if(!strcmp(QuestList[i].title,t)){
current.push_back(&QuestList[i]);
+#ifdef DEBUG
+ DEBUG_printf("Added quest %s, now have %u active quests.\n",t,current.size());
+#endif // DEBUG
return current.size();
}
}
+#ifdef DEBUG
+ DEBUG_printf("Quest %s does not exist.\n",t);
+#endif // DEBUG
return -1;
}
@@ -52,11 +62,20 @@ int QuestHandler::finish(const char *t,void *completer){
unsigned int r;
for(i=0;i<current.size();i++){
if(!strcmp(current[i]->title,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;
}
diff --git a/src/common.cpp b/src/common.cpp
index 80488eb..8dcbd11 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -4,9 +4,9 @@ GLuint loadTexture(const char *fileName){
SDL_Surface *image = IMG_Load(fileName);
if(!image)return 0;
- #ifdef DEBUG
+#ifdef DEBUG
DEBUG_printf("Loaded image file: %s\n", fileName);
- #endif // DEBUG
+#endif // DEBUG
unsigned object = 0; //creates a new unsigned variable for the texture
glGenTextures(1, &object); //turns "object" into a texture
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 5ffe5a6..17a7bed 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -20,15 +20,8 @@ int compTestQuest(NPC *speaker){
}
int giveTestQuest(NPC *speaker){
- static bool done=false;
- if(!done){
- ui::dialogBox(speaker->name,"Here, have a quest!");
- player->qh.assign("Test");
- done=true;
- }
- /*while(ui::dialogBoxExists){
- mainLoop();
- }*/
+ ui::dialogBox(speaker->name,"Here, have a quest!");
+ player->qh.assign("Test");
NPCp(entity[2])->addAIFunc(compTestQuest);
return 0;
}
@@ -70,9 +63,10 @@ void initEverything(void){
entity[entity.size()-1]->spawn(200,100); //sets the position of the villager around the village
entity.pop_back();
+
+ NPCp(entity[1])->addAIFunc(giveStuff);
NPCp(entity[1])->addAIFunc(giveTestQuest);
for(i=0;i<entity.size()+1;i++){
entity[i]->inWorld=test;
- if(entity[i]->type==NPCT&&i>1)NPCp(entity[i])->addAIFunc(giveStuff);
}
}