aboutsummaryrefslogtreecommitdiffstats
path: root/src/Quest.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-10-02 08:47:11 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-10-02 08:47:11 -0400
commita277430f0ddde9ea2583f4b0c44fcafe8a2528bf (patch)
tree32a4bf8f1b6a32e237a9c486555f8215a2213ca9 /src/Quest.cpp
parentaa73352387af9efc77495ebdac6d19fb276dd75a (diff)
added inventories
Diffstat (limited to 'src/Quest.cpp')
-rw-r--r--src/Quest.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Quest.cpp b/src/Quest.cpp
index 28aade2..c331e32 100644
--- a/src/Quest.cpp
+++ b/src/Quest.cpp
@@ -1,22 +1,23 @@
#include <Quest.h>
+#include <entities.h>
const Quest QuestList[TOTAL_QUESTS]={
- Quest("Test","A test quest",0)
+ Quest("Test","A test quest",(struct item_t){1,TEST_ITEM})
};
-Quest::Quest(const char *t,const char *d,unsigned int r){
+Quest::Quest(const char *t,const char *d,struct item_t r){
size_t len;
title=(char *)malloc((len=strlen(t)));
strncpy(title,t,len);
desc=(char *)malloc((len=strlen(d)));
strncpy(desc,d,len);
- reward=r;
+ memcpy(&reward,&r,sizeof(struct item_t));
}
Quest::~Quest(){
free(title);
free(desc);
- reward=0;
+ memset(&reward,0,sizeof(struct item_t));
}
int QuestHandler::assign(const char *t){
@@ -46,14 +47,14 @@ int QuestHandler::drop(const char *t){
return -1;
}
-int QuestHandler::finish(const char *t){
+int QuestHandler::finish(const char *t,void *completer){
unsigned char i;
unsigned int r;
for(i=0;i<current.size();i++){
if(!strcmp(current[i]->title,t)){
- r=current[i]->reward;
+ ((Entity *)completer)->inv->addItem(current[i]->reward.id,current[i]->reward.count);
current.erase(current.begin()+i);
- return r;
+ return 0;
}
}
return -1;