]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
quest debug
authorClyne Sullivan <tullivan99@gmail.com>
Tue, 13 Oct 2015 12:47:09 +0000 (08:47 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Tue, 13 Oct 2015 12:47:09 +0000 (08:47 -0400)
include/Quest.h
include/entities.h
main.cpp
src/Quest.cpp
src/common.cpp
src/gameplay.cpp

index 11d04a684a7832d0880b60722d5e7dc3e9f030d8..bbcf7ee29de72303a24aa92e802c846b7e975d2d 100644 (file)
@@ -7,6 +7,8 @@
 \r
 #include <inventory.h>\r
 \r
+#define DEBUG\r
+\r
 #define TOTAL_QUESTS 1\r
 \r
 class Quest {\r
index ecfe539285e0993287f43e239188badf0be7a463..537ed499d61244b624fa13442f7ef9baafac0545 100644 (file)
@@ -51,7 +51,7 @@ public:
 private:
 };
 
-class Player : public Entity{
+class Player : public Entity {
 public:
        QuestHandler qh;
        Player();
@@ -95,4 +95,4 @@ ENTITY TYPES
 |
 2 MOBS
 |->1 Skirl
-**/
\ No newline at end of file
+**/
index 386d4191735d531381ee83b683b3a984d2190fd4..6e10420837d7b80ef08a066baecf476166d157a3 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -134,9 +134,9 @@ static float debugY=0;
 
 void mainLoop(void){
        static unsigned int debugDiv=0;
-       unsigned int i,
-                                prevTime    = 0,
-                                currentTime = 0;
+       unsigned int i;
+       static unsigned int prevTime    = 0,
+                                               currentTime = 0;
        
        if(!currentTime)currentTime=millis();
        prevTime = currentTime;
index c331e3226574b00ff86bfe0280c651e2ea0c8be1..5d197950bd04db31ed313e524552b7a88681fa1e 100644 (file)
@@ -1,5 +1,6 @@
-#include <Quest.h>\r
-#include <entities.h>\r
+#include <common.h>\r
+//#include <Quest.h>\r
+//#include <entities.h>\r
 \r
 const Quest QuestList[TOTAL_QUESTS]={\r
        Quest("Test","A test quest",(struct item_t){1,TEST_ITEM})\r
@@ -22,17 +23,26 @@ Quest::~Quest(){
 \r
 int QuestHandler::assign(const char *t){\r
        unsigned char i;\r
-       for(i=0;i<current.size();i++){\r
+       for(i=0;i<current.size();i++){                          // Make sure we don't already have this quest\r
                if(!strcmp(current[i]->title,t)){\r
+#ifdef DEBUG\r
+                       DEBUG_printf("The QuestHandler already has this quest: %s\n",t);\r
+#endif // DEBUG\r
                        return -2;\r
                }\r
        }\r
-       for(i=0;i<TOTAL_QUESTS;i++){\r
+       for(i=0;i<TOTAL_QUESTS;i++){                            // Add the quest (if it really exists)\r
                if(!strcmp(QuestList[i].title,t)){\r
                        current.push_back(&QuestList[i]);\r
+#ifdef DEBUG\r
+                       DEBUG_printf("Added quest %s, now have %u active quests.\n",t,current.size());\r
+#endif // DEBUG\r
                        return current.size();\r
                }\r
        }\r
+#ifdef DEBUG\r
+       DEBUG_printf("Quest %s does not exist.\n",t);\r
+#endif // DEBUG\r
        return -1;\r
 }\r
 \r
@@ -52,11 +62,20 @@ int QuestHandler::finish(const char *t,void *completer){
        unsigned int r;\r
        for(i=0;i<current.size();i++){\r
                if(!strcmp(current[i]->title,t)){\r
+#ifdef DEBUG\r
+                       DEBUG_printf("Completing quest %s.\n",t);\r
+#endif // DEBUG\r
                        ((Entity *)completer)->inv->addItem(current[i]->reward.id,current[i]->reward.count);\r
                        current.erase(current.begin()+i);\r
+#ifdef DEBUG\r
+                       DEBUG_printf("QuestHandler now has %u active quests.\n",current.size());\r
+#endif // DEBUG\r
                        return 0;\r
                }\r
        }\r
+#ifdef DEBUG\r
+       DEBUG_printf("QuestHandler never had quest %s.\n",t);\r
+#endif // DEBUG\r
        return -1;\r
 }\r
 \r
index 80488eb30c87913e61d8b049f2adf306d04316f6..8dcbd1181ab4ce5181dc87646bb8f863b34609ed 100644 (file)
@@ -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
index 5ffe5a67755a587a9d9e44ebdf33e9d2c2c69cc7..17a7bedbdd58d68a746b2000f56c69bc7331c2da 100644 (file)
@@ -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);
        }
 }