From a277430f0ddde9ea2583f4b0c44fcafe8a2528bf Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 2 Oct 2015 08:47:11 -0400 Subject: added inventories --- src/Quest.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/Quest.cpp') 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 +#include 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;ititle,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; -- cgit v1.2.3