diff options
author | Kevin <Kevin@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-04-11 01:38:41 +0000 |
---|---|---|
committer | Kevin <Kevin@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-04-11 01:38:41 +0000 |
commit | eb9d9a5e40f78993ab6280df285b1a15a7f27abb (patch) | |
tree | e9431a807a8fdfa9252a12d5f0eac1a51c8f32d9 /src/map | |
parent | 773729d995cc32f98e87f6996b210ff6a2cc8d96 (diff) | |
download | hercules-eb9d9a5e40f78993ab6280df285b1a15a7f27abb.tar.gz hercules-eb9d9a5e40f78993ab6280df285b1a15a7f27abb.tar.bz2 hercules-eb9d9a5e40f78993ab6280df285b1a15a7f27abb.tar.xz hercules-eb9d9a5e40f78993ab6280df285b1a15a7f27abb.zip |
More questlog code.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12556 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/Makefile.in | 4 | ||||
-rw-r--r-- | src/map/chrif.c | 1 | ||||
-rw-r--r-- | src/map/clif.c | 4 | ||||
-rw-r--r-- | src/map/clif.h | 5 | ||||
-rw-r--r-- | src/map/pc.c | 6 | ||||
-rw-r--r-- | src/map/quest.c | 137 | ||||
-rw-r--r-- | src/map/quest.h | 11 |
7 files changed, 164 insertions, 4 deletions
diff --git a/src/map/Makefile.in b/src/map/Makefile.in index 7799b43ce..c92318060 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -17,14 +17,14 @@ MAP_OBJ = map.o chrif.o clif.o pc.o status.o npc.o \ npc_chat.o chat.o path.o itemdb.o mob.o script.o \ storage.o skill.o atcommand.o charcommand.o battle.o \ intif.o trade.o party.o vending.o guild.o pet.o \ - log.o mail.o date.o irc.o unit.o mercenary.o + log.o mail.o date.o irc.o unit.o mercenary.o quest.o MAP_TXT_OBJ = $(MAP_OBJ:%=obj_txt/%) MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%) MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \ chat.h itemdb.h mob.h script.h path.h \ storage.h skill.h atcommand.h charcommand.h battle.h \ intif.h trade.h party.h vending.h guild.h pet.h \ - log.h mail.h date.h irc.h unit.h mercenary.h + log.h mail.h date.h irc.h unit.h mercenary.h quest.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) diff --git a/src/map/chrif.c b/src/map/chrif.c index 78b8c1733..cc75359ef 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -20,6 +20,7 @@ #include "status.h" #include "mercenary.h" #include "chrif.h" +#include "quest.h" #include <stdio.h> #include <stdlib.h> diff --git a/src/map/clif.c b/src/map/clif.c index 21d246cfa..01417b2dd 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -37,6 +37,7 @@ #include "irc.h" #include "clif.h" #include "mail.h" +#include "quest.h" #include <stdio.h> #include <stdlib.h> @@ -7968,8 +7969,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) mail_clear(sd); #endif - //Send quest log [Kevin] - clif_send_questlog(sd); + quest_pc_login(sd); if(map[sd->bl.m].flag.loadevent) // Lance npc_script_event(sd, NPCE_LOADMAP); diff --git a/src/map/clif.h b/src/map/clif.h index 684ee0fc0..832829a04 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -396,6 +396,11 @@ void clif_equipcheckbox(struct map_session_data* sd); //quest system [Kevin] void clif_send_questlog(struct map_session_data * sd); +void clif_send_questlog_info(struct map_session_data * sd); +void clif_send_quest_info(struct map_session_data * sd, struct quest * qd); +void clif_send_quest_delete(struct map_session_data * sd, int quest_id); +void clif_send_quest_status(struct map_session_data * sd, int quest_id, bool active); + int clif_foreachclient(int (*)(struct map_session_data*,va_list),...); int clif_send(const uint8* buf, int len, struct block_list* bl, enum send_target type); diff --git a/src/map/pc.c b/src/map/pc.c index 3d7572326..32f102b6e 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -32,6 +32,7 @@ #include "status.h" // struct status_data #include "vending.h" // vending_closevending() #include "pc.h" +#include "quest.h" #ifndef TXT_ONLY // mail system [Valaris] #include "mail.h" @@ -372,6 +373,8 @@ int pc_makesavestatus(struct map_session_data *sd) else memcpy(&sd->status.last_point,&sd->status.save_point,sizeof(sd->status.last_point)); } + + quest_make_savedata(sd); return 0; } @@ -863,6 +866,9 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim clif_wis_message(sd->fd, wisp_server_name, tmpstr, strlen(tmpstr)+1); } + //Get quest data out of char dat + quest_load_info(sd, st); + // Request all registries (auth is considered completed whence they arrive) intif_request_registry(sd,7); return true; diff --git a/src/map/quest.c b/src/map/quest.c new file mode 100644 index 000000000..499d78d6c --- /dev/null +++ b/src/map/quest.c @@ -0,0 +1,137 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#include "../common/cbasetypes.h"
+#include "../common/socket.h"
+#include "../common/timer.h"
+#include "../common/malloc.h"
+#include "../common/version.h"
+#include "../common/nullpo.h"
+#include "../common/showmsg.h"
+#include "../common/strlib.h"
+#include "../common/utils.h"
+
+#include "map.h"
+#include "chrif.h"
+#include "pc.h"
+#include "npc.h"
+#include "itemdb.h"
+#include "script.h"
+#include "intif.h"
+#include "battle.h"
+#include "mob.h"
+#include "party.h"
+#include "unit.h"
+#include "log.h"
+#include "clif.h"
+#include "quest.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <time.h>
+
+//Send quest info on login
+int quest_pc_login(TBL_PC * sd)
+{
+ clif_send_questlog(sd);
+ clif_send_questlog_info(sd);
+ return 0;
+}
+
+struct quest * quest_make(int id, time_t time, int num_objs, struct quest_objective ** qo_arr)
+{
+ return NULL;
+}
+
+int quest_add(TBL_PC * sd, struct quest * qd)
+{
+
+ int i;
+
+ //Search to see if this quest exists
+ ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == qd->quest_id);
+
+ //Already have this quest
+ if(i!=MAX_QUEST)
+ return 1;
+
+ //Find empty quest log spot
+ ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == 0);
+
+ //Quest log is full
+ if(i == MAX_QUEST)
+ return -1;
+
+ //Copy over quest data
+ memcpy(&sd->quest_log[i], qd, sizeof(struct quest));
+ sd->num_quests++;
+
+ //Notify client
+ clif_send_quest_info(sd, &sd->quest_log[i]);
+
+ return 0;
+
+}
+
+int quest_delete(TBL_PC * sd, int quest_id)
+{
+
+ int i;
+
+ //Search for quest
+ ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == quest_id);
+
+ //Quest not found
+ if(i != MAX_QUEST)
+ return -1;
+
+ //Zero quest
+ memset(&sd->quest_log[i], 0, sizeof(struct quest));
+
+ //Notify client
+ clif_send_quest_delete(sd, quest_id);
+
+ return 0;
+
+}
+
+int quest_update_objective(TBL_PC * sd, int quest_id, int objective_num, struct quest_objective qod)
+{
+
+ int i;
+
+ //Search for quest
+ ARR_FIND(0, MAX_QUEST, i, sd->quest_log[i].quest_id == quest_id);
+
+ //Quest not found
+ if(i != MAX_QUEST)
+ return -1;
+
+ memcpy(sd->quest_log[i].objectives[objective_num].name, qod.name, NAME_LENGTH);
+ sd->quest_log[i].objectives[objective_num].count = qod.count;
+
+ //Notify client
+ clif_send_quest_info(sd, &sd->quest_log[i]);
+
+ return 0;
+
+}
+
+int quest_load_info(TBL_PC * sd, struct mmo_charstatus * st)
+{
+ sd->num_quests = st->num_quests;
+ memcpy(sd->quest_log, st->quest_log, sizeof(st->quest_log));
+
+ return 0;
+}
+
+int quest_make_savedata(TBL_PC * sd)
+{
+ sd->status.num_quests = sd->num_quests;
+ memcpy(sd->status.quest_log, sd->quest_log, sizeof(sd->quest_log));
+
+ return 0;
+}
+
diff --git a/src/map/quest.h b/src/map/quest.h new file mode 100644 index 000000000..efcfbc2d0 --- /dev/null +++ b/src/map/quest.h @@ -0,0 +1,11 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#ifndef _QUEST_H_
+#define _QUEST_H_
+
+int quest_pc_login(TBL_PC * sd);
+int quest_load_info(TBL_PC * sd, struct mmo_charstatus * st);
+int quest_make_savedata(TBL_PC * sd);
+
+#endif
|