clang-format file added, quest.c and .h formatted

This commit is contained in:
welcor
2024-09-30 22:36:30 +02:00
parent e6085172d5
commit 5c44f0575e
4 changed files with 205 additions and 151 deletions

55
.clang-format Normal file
View File

@@ -0,0 +1,55 @@
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: Align
AlignTrailingComments: true
AlwaysBreakTemplateDeclarations: Yes
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: false
BeforeLambdaBody: true
BeforeWhile: true
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBraces: Custom
BreakBeforeBinaryOperators: All
BreakConstructorInitializers: AfterColon
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: false
IncludeCategories:
- Regex: '^<.*'
Priority: 1
- Regex: '^".*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseBlocks: true
IndentWidth: 4
InsertNewlineAtEOF: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
TabWidth: 4
...

View File

@@ -66,11 +66,11 @@ qst_rnum real_quest(qst_vnum vnum)
for (rnum = 0; rnum < total_quests; rnum++) for (rnum = 0; rnum < total_quests; rnum++)
if (QST_NUM(rnum) == vnum) if (QST_NUM(rnum) == vnum)
return(rnum); return (rnum);
return(NOTHING); return (NOTHING);
} }
int is_complete(struct char_data *ch, qst_vnum vnum) int is_complete(const struct char_data *ch, qst_vnum vnum)
{ {
int i; int i;
@@ -83,7 +83,7 @@ int is_complete(struct char_data *ch, qst_vnum vnum)
qst_vnum find_quest_by_qmnum(struct char_data *ch, mob_vnum qm, int num) qst_vnum find_quest_by_qmnum(struct char_data *ch, mob_vnum qm, int num)
{ {
qst_rnum rnum; qst_rnum rnum;
int found=0; int found = 0;
for (rnum = 0; rnum < total_quests; rnum++) { for (rnum = 0; rnum < total_quests; rnum++) {
if (qm == QST_MASTER(rnum)) if (qm == QST_MASTER(rnum))
if (++found == num) if (++found == num)
@@ -109,8 +109,6 @@ void destroy_quests(void)
free(aquest_table); free(aquest_table);
aquest_table = NULL; aquest_table = NULL;
total_quests = 0; total_quests = 0;
return;
} }
int count_quests(qst_vnum low, qst_vnum high) int count_quests(qst_vnum low, qst_vnum high)
@@ -151,8 +149,8 @@ void parse_quest(FILE *quest_f, int nr)
aquest_table[i].func = NULL; aquest_table[i].func = NULL;
aquest_table[i].gold_reward = 0; aquest_table[i].gold_reward = 0;
aquest_table[i].exp_reward = 0; aquest_table[i].exp_reward = 0;
aquest_table[i].obj_reward = NOTHING; aquest_table[i].obj_reward = NOTHING;
/* begin to parse the data */ /* begin to parse the data */
aquest_table[i].name = fread_string(quest_f, buf2); aquest_table[i].name = fread_string(quest_f, buf2);
@@ -161,22 +159,22 @@ void parse_quest(FILE *quest_f, int nr)
aquest_table[i].done = fread_string(quest_f, buf2); aquest_table[i].done = fread_string(quest_f, buf2);
aquest_table[i].quit = fread_string(quest_f, buf2); aquest_table[i].quit = fread_string(quest_f, buf2);
if (!get_line(quest_f, line) || if (!get_line(quest_f, line) ||
(retval = sscanf(line, " %d %d %s %d %d %d %d", (retval = sscanf(line, " %d %d %s %d %d %d %d",
t, t+1, f1, t+2, t+3, t + 4, t + 5)) != 7) { t, t + 1, f1, t + 2, t + 3, t + 4, t + 5)) != 7) {
log("Format error in numeric line (expected 7, got %d), %s\n", log("Format error in numeric line (expected 7, got %d), %s\n",
retval, line); retval, line);
exit(1); exit(1);
} }
aquest_table[i].type = t[0]; aquest_table[i].type = t[0];
aquest_table[i].qm = (real_mobile(t[1]) == NOBODY) ? NOBODY : t[1]; aquest_table[i].qm = (real_mobile(t[1]) == NOBODY) ? NOBODY : t[1];
aquest_table[i].flags = asciiflag_conv(f1); aquest_table[i].flags = asciiflag_conv(f1);
aquest_table[i].target = (t[2] == -1) ? NOTHING : t[2]; aquest_table[i].target = (t[2] == -1) ? NOTHING : t[2];
aquest_table[i].prev_quest = (t[3] == -1) ? NOTHING : t[3]; aquest_table[i].prev_quest = (t[3] == -1) ? NOTHING : t[3];
aquest_table[i].next_quest = (t[4] == -1) ? NOTHING : t[4]; aquest_table[i].next_quest = (t[4] == -1) ? NOTHING : t[4];
aquest_table[i].prereq = (t[5] == -1) ? NOTHING : t[5]; aquest_table[i].prereq = (t[5] == -1) ? NOTHING : t[5];
if (!get_line(quest_f, line) || if (!get_line(quest_f, line) ||
(retval = sscanf(line, " %d %d %d %d %d %d %d", (retval = sscanf(line, " %d %d %d %d %d %d %d",
t, t+1, t+2, t+3, t+4, t + 5, t + 6)) != 7) { t, t + 1, t + 2, t + 3, t + 4, t + 5, t + 6)) != 7) {
log("Format error in numeric line (expected 7, got %d), %s\n", log("Format error in numeric line (expected 7, got %d), %s\n",
retval, line); retval, line);
exit(1); exit(1);
@@ -185,24 +183,23 @@ void parse_quest(FILE *quest_f, int nr)
aquest_table[i].value[j] = t[j]; aquest_table[i].value[j] = t[j];
if (!get_line(quest_f, line) || if (!get_line(quest_f, line) ||
(retval = sscanf(line, " %d %d %d", (retval = sscanf(line, " %d %d %d",
t, t+1, t+2)) != 3) { t, t + 1, t + 2)) != 3) {
log("Format error in numeric (rewards) line (expected 3, got %d), %s\n", log("Format error in numeric (rewards) line (expected 3, got %d), %s\n",
retval, line); retval, line);
exit(1); exit(1);
} }
aquest_table[i].gold_reward = t[0]; aquest_table[i].gold_reward = t[0];
aquest_table[i].exp_reward = t[1]; aquest_table[i].exp_reward = t[1];
aquest_table[i].obj_reward = (t[2] == -1) ? NOTHING : t[2]; aquest_table[i].obj_reward = (t[2] == -1) ? NOTHING : t[2];
for (;;) { for (;;) {
if (!get_line(quest_f, line)) { if (!get_line(quest_f, line)) {
log("Format error in %s\n", line); log("Format error in %s\n", line);
exit(1); exit(1);
} }
switch(*line) { if (*line == 'S') {
case 'S':
total_quests = ++i; total_quests = ++i;
return; return;
} }
@@ -216,7 +213,7 @@ void assign_the_quests(void)
cmd_tell = find_command("tell"); cmd_tell = find_command("tell");
for (rnum = 0; rnum < total_quests; rnum ++) { for (rnum = 0; rnum < total_quests; rnum++) {
if (QST_MASTER(rnum) == NOBODY) { if (QST_MASTER(rnum) == NOBODY) {
log("SYSERR: Quest #%d has no questmaster specified.", QST_NUM(rnum)); log("SYSERR: Quest #%d has no questmaster specified.", QST_NUM(rnum));
continue; continue;
@@ -226,7 +223,7 @@ void assign_the_quests(void)
continue; continue;
} }
if (mob_index[(mrnum)].func && if (mob_index[(mrnum)].func &&
mob_index[(mrnum)].func != questmaster) mob_index[(mrnum)].func != questmaster)
QST_FUNC(rnum) = mob_index[(mrnum)].func; QST_FUNC(rnum) = mob_index[(mrnum)].func;
mob_index[(mrnum)].func = questmaster; mob_index[(mrnum)].func = questmaster;
} }
@@ -235,56 +232,54 @@ void assign_the_quests(void)
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* Quest Completion Functions */ /* Quest Completion Functions */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
void set_quest(struct char_data *ch, qst_rnum rnum) void set_quest(const struct char_data *ch, qst_rnum rnum)
{ {
GET_QUEST(ch) = QST_NUM(rnum); GET_QUEST(ch) = QST_NUM(rnum);
GET_QUEST_TIME(ch) = QST_TIME(rnum); GET_QUEST_TIME(ch) = QST_TIME(rnum);
GET_QUEST_COUNTER(ch) = QST_QUANTITY(rnum); GET_QUEST_COUNTER(ch) = QST_QUANTITY(rnum);
SET_BIT_AR(PRF_FLAGS(ch), PRF_QUEST); SET_BIT_AR(PRF_FLAGS(ch), PRF_QUEST);
return;
} }
void clear_quest(struct char_data *ch) void clear_quest(const struct char_data *ch)
{ {
GET_QUEST(ch) = NOTHING; GET_QUEST(ch) = NOTHING;
GET_QUEST_TIME(ch) = -1; GET_QUEST_TIME(ch) = -1;
GET_QUEST_COUNTER(ch) = 0; GET_QUEST_COUNTER(ch) = 0;
REMOVE_BIT_AR(PRF_FLAGS(ch), PRF_QUEST); REMOVE_BIT_AR(PRF_FLAGS(ch), PRF_QUEST);
return;
} }
void add_completed_quest(struct char_data *ch, qst_vnum vnum) void add_completed_quest(const struct char_data *ch, qst_vnum vnum)
{ {
qst_vnum *temp; qst_vnum *temp;
int i; int i;
CREATE(temp, qst_vnum, GET_NUM_QUESTS(ch) +1); CREATE(temp, qst_vnum, GET_NUM_QUESTS(ch) +1);
for (i=0; i < GET_NUM_QUESTS(ch); i++) for (i = 0; i < GET_NUM_QUESTS(ch); i++)
temp[i] = ch->player_specials->saved.completed_quests[i]; temp[i] = GET_COMPLETED_QUEST(ch, i);
temp[GET_NUM_QUESTS(ch)] = vnum; temp[GET_NUM_QUESTS(ch)] = vnum;
GET_NUM_QUESTS(ch)++; GET_NUM_QUESTS(ch)++;
if (ch->player_specials->saved.completed_quests) if (GET_COMPLETED_QUESTS(ch) != NULL)
free(ch->player_specials->saved.completed_quests); free(GET_COMPLETED_QUESTS(ch));
ch->player_specials->saved.completed_quests = temp; GET_COMPLETED_QUESTS(ch) = temp;
} }
void remove_completed_quest(struct char_data *ch, qst_vnum vnum) void remove_completed_quest(const struct char_data *ch, qst_vnum vnum)
{ {
qst_vnum *temp; qst_vnum *temp;
int i, j = 0; int i, j = 0;
CREATE(temp, qst_vnum, GET_NUM_QUESTS(ch)); CREATE(temp, qst_vnum, GET_NUM_QUESTS(ch));
for (i = 0; i < GET_NUM_QUESTS(ch); i++) for (i = 0; i < GET_NUM_QUESTS(ch); i++)
if (ch->player_specials->saved.completed_quests[i] != vnum) if (GET_COMPLETED_QUEST(ch, i) != vnum)
temp[j++] = ch->player_specials->saved.completed_quests[i]; temp[j++] = GET_COMPLETED_QUEST(ch, i);
GET_NUM_QUESTS(ch)--; GET_NUM_QUESTS(ch)--;
if (ch->player_specials->saved.completed_quests) if (GET_COMPLETED_QUESTS(ch) != NULL)
free(ch->player_specials->saved.completed_quests); free(GET_COMPLETED_QUESTS(ch));
ch->player_specials->saved.completed_quests = temp; GET_COMPLETED_QUESTS(ch) = temp;
} }
void generic_complete_quest(struct char_data *ch) void generic_complete_quest(struct char_data *ch)
@@ -297,7 +292,7 @@ void generic_complete_quest(struct char_data *ch)
if (--GET_QUEST_COUNTER(ch) <= 0) { if (--GET_QUEST_COUNTER(ch) <= 0) {
rnum = real_quest(vnum); rnum = real_quest(vnum);
if (IS_HAPPYHOUR && IS_HAPPYQP) { if (IS_HAPPYHOUR && IS_HAPPYQP) {
happy_qp = (int)(QST_POINTS(rnum) * (((float)(100+HAPPY_QP))/(float)100)); happy_qp = (int)(QST_POINTS(rnum) * (((float)(100 + HAPPY_QP)) / (float)100));
happy_qp = MAX(happy_qp, 0); happy_qp = MAX(happy_qp, 0);
GET_QUESTPOINTS(ch) += happy_qp; GET_QUESTPOINTS(ch) += happy_qp;
send_to_char(ch, send_to_char(ch,
@@ -311,7 +306,7 @@ void generic_complete_quest(struct char_data *ch)
} }
if (QST_GOLD(rnum)) { if (QST_GOLD(rnum)) {
if ((IS_HAPPYHOUR) && (IS_HAPPYGOLD)) { if ((IS_HAPPYHOUR) && (IS_HAPPYGOLD)) {
happy_gold = (int)(QST_GOLD(rnum) * (((float)(100+HAPPY_GOLD))/(float)100)); happy_gold = (int)(QST_GOLD(rnum) * (((float)(100 + HAPPY_GOLD)) / (float)100));
happy_gold = MAX(happy_gold, 0); happy_gold = MAX(happy_gold, 0);
increase_gold(ch, happy_gold); increase_gold(ch, happy_gold);
send_to_char(ch, send_to_char(ch,
@@ -327,7 +322,7 @@ void generic_complete_quest(struct char_data *ch)
if (QST_EXP(rnum)) { if (QST_EXP(rnum)) {
gain_exp(ch, QST_EXP(rnum)); gain_exp(ch, QST_EXP(rnum));
if ((IS_HAPPYHOUR) && (IS_HAPPYEXP)) { if ((IS_HAPPYHOUR) && (IS_HAPPYEXP)) {
happy_exp = (int)(QST_EXP(rnum) * (((float)(100+HAPPY_EXP))/(float)100)); happy_exp = (int)(QST_EXP(rnum) * (((float)(100 + HAPPY_EXP)) / (float)100));
happy_exp = MAX(happy_exp, 0); happy_exp = MAX(happy_exp, 0);
send_to_char(ch, send_to_char(ch,
"You have been awarded %d experience for your service.\r\n", "You have been awarded %d experience for your service.\r\n",
@@ -351,8 +346,8 @@ void generic_complete_quest(struct char_data *ch)
add_completed_quest(ch, vnum); add_completed_quest(ch, vnum);
clear_quest(ch); clear_quest(ch);
if ((real_quest(QST_NEXT(rnum)) != NOTHING) && if ((real_quest(QST_NEXT(rnum)) != NOTHING) &&
(QST_NEXT(rnum) != vnum) && (QST_NEXT(rnum) != vnum) &&
!is_complete(ch, QST_NEXT(rnum))) { !is_complete(ch, QST_NEXT(rnum))) {
rnum = real_quest(QST_NEXT(rnum)); rnum = real_quest(QST_NEXT(rnum));
set_quest(ch, rnum); set_quest(ch, rnum);
send_to_char(ch, send_to_char(ch,
@@ -363,8 +358,8 @@ void generic_complete_quest(struct char_data *ch)
save_char(ch); save_char(ch);
} }
void autoquest_trigger_check(struct char_data *ch, struct char_data *vict, void autoquest_trigger_check(struct char_data *ch, const struct char_data *vict,
struct obj_data *object, int type) const struct obj_data *object, int type)
{ {
struct char_data *i; struct char_data *i;
qst_rnum rnum; qst_rnum rnum;
@@ -372,7 +367,7 @@ void autoquest_trigger_check(struct char_data *ch, struct char_data *vict,
if (IS_NPC(ch)) if (IS_NPC(ch))
return; return;
if (GET_QUEST(ch) == NOTHING) /* No current quest, skip this */ if (GET_QUEST(ch) == NOTHING) /* No current quest, skip this */
return; return;
if (GET_QUEST_TYPE(ch) != type) if (GET_QUEST_TYPE(ch) != type)
return; return;
@@ -388,7 +383,7 @@ void autoquest_trigger_check(struct char_data *ch, struct char_data *vict,
generic_complete_quest(ch); generic_complete_quest(ch);
break; break;
case AQ_MOB_FIND: case AQ_MOB_FIND:
for (i=world[IN_ROOM(ch)].people; i; i = i->next_in_room) for (i = world[IN_ROOM(ch)].people; i; i = i->next_in_room)
if (IS_NPC(i)) if (IS_NPC(i))
if (QST_TARGET(rnum) == GET_MOB_VNUM(i)) if (QST_TARGET(rnum) == GET_MOB_VNUM(i))
generic_complete_quest(ch); generic_complete_quest(ch);
@@ -402,9 +397,9 @@ void autoquest_trigger_check(struct char_data *ch, struct char_data *vict,
if (ch == vict) if (ch == vict)
found = FALSE; found = FALSE;
for (i = world[IN_ROOM(ch)].people; i && found; i = i->next_in_room) for (i = world[IN_ROOM(ch)].people; i && found; i = i->next_in_room)
if (i && IS_NPC(i) && !MOB_FLAGGED(i, MOB_NOTDEADYET)) if (IS_NPC(i) && !MOB_FLAGGED(i, MOB_NOTDEADYET))
if ((GET_MOB_VNUM(i) != QST_TARGET(rnum)) && if ((GET_MOB_VNUM(i) != QST_TARGET(rnum)) &&
!AFF_FLAGGED(i, AFF_CHARM)) !AFF_FLAGGED(i, AFF_CHARM))
found = FALSE; found = FALSE;
if (found) if (found)
generic_complete_quest(ch); generic_complete_quest(ch);
@@ -417,7 +412,7 @@ void autoquest_trigger_check(struct char_data *ch, struct char_data *vict,
case AQ_ROOM_CLEAR: case AQ_ROOM_CLEAR:
if (QST_TARGET(rnum) == world[IN_ROOM(ch)].number) { if (QST_TARGET(rnum) == world[IN_ROOM(ch)].number) {
for (i = world[IN_ROOM(ch)].people; i && found; i = i->next_in_room) for (i = world[IN_ROOM(ch)].people; i && found; i = i->next_in_room)
if (i && IS_NPC(i) && !MOB_FLAGGED(i, MOB_NOTDEADYET)) if (IS_NPC(i) && !MOB_FLAGGED(i, MOB_NOTDEADYET))
found = FALSE; found = FALSE;
if (found) if (found)
generic_complete_quest(ch); generic_complete_quest(ch);
@@ -459,16 +454,16 @@ void list_quests(struct char_data *ch, zone_rnum zone, qst_vnum vmin, qst_vnum v
if (zone != NOWHERE) { if (zone != NOWHERE) {
bottom = zone_table[zone].bot; bottom = zone_table[zone].bot;
top = zone_table[zone].top; top = zone_table[zone].top;
} else { } else {
bottom = vmin; bottom = vmin;
top = vmax; top = vmax;
} }
/* Print the header for the quest listing. */ /* Print the header for the quest listing. */
send_to_char (ch, send_to_char(ch,
"Index VNum Description Questmaster\r\n" "Index VNum Description Questmaster\r\n"
"----- ------- -------------------------------------------- -----------\r\n"); "----- ------- -------------------------------------------- -----------\r\n");
for (rnum = 0; rnum < total_quests ; rnum++) for (rnum = 0; rnum < total_quests; rnum++)
if (QST_NUM(rnum) >= bottom && QST_NUM(rnum) <= top) if (QST_NUM(rnum) >= bottom && QST_NUM(rnum) <= top)
send_to_char(ch, "\tg%4d\tn) [\tg%-5d\tn] \tc%-44.44s\tn \ty[%5d]\tn\r\n", send_to_char(ch, "\tg%4d\tn) [\tg%-5d\tn] \tc%-44.44s\tn \ty[%5d]\tn\r\n",
++counter, QST_NUM(rnum), QST_NAME(rnum), ++counter, QST_NUM(rnum), QST_NAME(rnum),
@@ -486,10 +481,12 @@ static void quest_hist(struct char_data *ch)
"Index Description Questmaster\r\n" "Index Description Questmaster\r\n"
"----- ---------------------------------------------------- -----------\r\n"); "----- ---------------------------------------------------- -----------\r\n");
for (i = 0; i < GET_NUM_QUESTS(ch); i++) { for (i = 0; i < GET_NUM_QUESTS(ch); i++) {
if ((rnum = real_quest(ch->player_specials->saved.completed_quests[i])) != NOTHING) if ((rnum = real_quest(GET_COMPLETED_QUEST(ch, i))) != NOTHING)
send_to_char(ch, "\tg%4d\tn) \tc%-52.52s\tn \ty%s\tn\r\n", send_to_char(ch, "\tg%4d\tn) \tc%-52.52s\tn \ty%s\tn\r\n",
++counter, QST_DESC(rnum), (real_mobile(QST_MASTER(rnum)) == NOBODY) ? "Unknown" : GET_NAME(&mob_proto[(real_mobile( ++counter, QST_DESC(rnum), (real_mobile(QST_MASTER(rnum)) == NOBODY)
QST_MASTER(rnum)))])); ? "Unknown"
: GET_NAME(&mob_proto[(real_mobile(
QST_MASTER(rnum)))]));
else else
send_to_char(ch, send_to_char(ch,
"\tg%4d\tn) \tcUnknown Quest (it no longer exists)\tn\r\n", ++counter); "\tg%4d\tn) \tcUnknown Quest (it no longer exists)\tn\r\n", ++counter);
@@ -510,10 +507,8 @@ static void quest_join(struct char_data *ch, struct char_data *qm, char argument
else if (GET_QUEST(ch) != NOTHING) else if (GET_QUEST(ch) != NOTHING)
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"%s But you are already part of a quest!", GET_NAME(ch)); "%s But you are already part of a quest!", GET_NAME(ch));
else if((vnum = find_quest_by_qmnum(ch, GET_MOB_VNUM(qm), atoi(argument))) == NOTHING) else if ((vnum = find_quest_by_qmnum(ch, GET_MOB_VNUM(qm), atoi(argument))) == NOTHING
snprintf(buf, sizeof(buf), || (rnum = real_quest(vnum)) == NOTHING)
"%s I don't know of such a quest!", GET_NAME(ch));
else if ((rnum = real_quest(vnum)) == NOTHING)
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"%s I don't know of such a quest!", GET_NAME(ch)); "%s I don't know of such a quest!", GET_NAME(ch));
else if (GET_LEVEL(ch) < QST_MINLEVEL(rnum)) else if (GET_LEVEL(ch) < QST_MINLEVEL(rnum))
@@ -536,7 +531,7 @@ static void quest_join(struct char_data *ch, struct char_data *qm, char argument
"%s You need to have %s first!", GET_NAME(ch), "%s You need to have %s first!", GET_NAME(ch),
obj_proto[real_object(QST_PREREQ(rnum))].short_description); obj_proto[real_object(QST_PREREQ(rnum))].short_description);
else { else {
act("You join the quest.", TRUE, ch, NULL, NULL, TO_CHAR); act("You join the quest.", TRUE, ch, NULL, NULL, TO_CHAR);
act("$n has joined a quest.", TRUE, ch, NULL, NULL, TO_ROOM); act("$n has joined a quest.", TRUE, ch, NULL, NULL, TO_ROOM);
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"%s Listen carefully to the instructions.", GET_NAME(ch)); "%s Listen carefully to the instructions.", GET_NAME(ch));
@@ -561,12 +556,11 @@ void quest_list(struct char_data *ch, struct char_data *qm, char argument[MAX_IN
qst_vnum vnum; qst_vnum vnum;
qst_rnum rnum; qst_rnum rnum;
if ((vnum = find_quest_by_qmnum(ch, GET_MOB_VNUM(qm), atoi(argument))) == NOTHING) if ((vnum = find_quest_by_qmnum(ch, GET_MOB_VNUM(qm), atoi(argument))) == NOTHING
send_to_char(ch, "That is not a valid quest!\r\n"); || (rnum = real_quest(vnum)) == NOTHING)
else if ((rnum = real_quest(vnum)) == NOTHING)
send_to_char(ch, "That is not a valid quest!\r\n"); send_to_char(ch, "That is not a valid quest!\r\n");
else if (QST_INFO(rnum)) { else if (QST_INFO(rnum)) {
send_to_char(ch,"Complete Details on Quest %d \tc%s\tn:\r\n%s", send_to_char(ch, "Complete Details on Quest %d \tc%s\tn:\r\n%s",
vnum, vnum,
QST_DESC(rnum), QST_DESC(rnum),
QST_INFO(rnum)); QST_INFO(rnum));
@@ -650,7 +644,7 @@ static void quest_show(struct char_data *ch, mob_vnum qm)
send_to_char(ch, "There are no quests available here at the moment.\r\n"); send_to_char(ch, "There are no quests available here at the moment.\r\n");
} }
static void quest_stat(struct char_data *ch, char argument[MAX_STRING_LENGTH]) static void quest_stat(struct char_data *ch, char argument[MAX_INPUT_LENGTH])
{ {
qst_rnum rnum; qst_rnum rnum;
mob_rnum qmrnum; mob_rnum qmrnum;
@@ -659,7 +653,7 @@ static void quest_stat(struct char_data *ch, char argument[MAX_STRING_LENGTH])
if (!*argument) if (!*argument)
send_to_char(ch, "%s\r\n", quest_imm_usage); send_to_char(ch, "%s\r\n", quest_imm_usage);
else if ((rnum = real_quest(atoi(argument))) == NOTHING ) else if ((rnum = real_quest(atoi(argument))) == NOTHING)
send_to_char(ch, "That quest does not exist.\r\n"); send_to_char(ch, "That quest does not exist.\r\n");
else { else {
sprintbit(QST_FLAGS(rnum), aq_flags, buf, sizeof(buf)); sprintbit(QST_FLAGS(rnum), aq_flags, buf, sizeof(buf));
@@ -667,24 +661,24 @@ static void quest_stat(struct char_data *ch, char argument[MAX_STRING_LENGTH])
case AQ_OBJ_FIND: case AQ_OBJ_FIND:
case AQ_OBJ_RETURN: case AQ_OBJ_RETURN:
snprintf(targetname, sizeof(targetname), "%s", snprintf(targetname, sizeof(targetname), "%s",
real_object(QST_TARGET(rnum)) == NOTHING ? real_object(QST_TARGET(rnum)) == NOTHING
"An unknown object" : ? "An unknown object"
obj_proto[real_object(QST_TARGET(rnum))].short_description); : obj_proto[real_object(QST_TARGET(rnum))].short_description);
break; break;
case AQ_ROOM_FIND: case AQ_ROOM_FIND:
case AQ_ROOM_CLEAR: case AQ_ROOM_CLEAR:
snprintf(targetname, sizeof(targetname), "%s", snprintf(targetname, sizeof(targetname), "%s",
real_room(QST_TARGET(rnum)) == NOWHERE ? real_room(QST_TARGET(rnum)) == NOWHERE
"An unknown room" : ? "An unknown room"
world[real_room(QST_TARGET(rnum))].name); : world[real_room(QST_TARGET(rnum))].name);
break; break;
case AQ_MOB_FIND: case AQ_MOB_FIND:
case AQ_MOB_KILL: case AQ_MOB_KILL:
case AQ_MOB_SAVE: case AQ_MOB_SAVE:
snprintf(targetname, sizeof(targetname), "%s", snprintf(targetname, sizeof(targetname), "%s",
real_mobile(QST_TARGET(rnum)) == NOBODY ? real_mobile(QST_TARGET(rnum)) == NOBODY
"An unknown mobile" : ? "An unknown mobile"
GET_NAME(&mob_proto[real_mobile(QST_TARGET(rnum))])); : GET_NAME(&mob_proto[real_mobile(QST_TARGET(rnum))]));
break; break;
default: default:
snprintf(targetname, sizeof(targetname), "Unknown"); snprintf(targetname, sizeof(targetname), "Unknown");
@@ -709,7 +703,8 @@ static void quest_stat(struct char_data *ch, char argument[MAX_STRING_LENGTH])
QST_INFO(rnum), QST_DONE(rnum), QST_INFO(rnum), QST_DONE(rnum),
(QST_QUIT(rnum) && (QST_QUIT(rnum) &&
(str_cmp(QST_QUIT(rnum), "undefined") != 0) (str_cmp(QST_QUIT(rnum), "undefined") != 0)
? QST_QUIT(rnum) : "Nothing\r\n"), ? QST_QUIT(rnum)
: "Nothing\r\n"),
quest_types[QST_TYPE(rnum)], quest_types[QST_TYPE(rnum)],
QST_TARGET(rnum) == NOBODY ? -1 : QST_TARGET(rnum), QST_TARGET(rnum) == NOBODY ? -1 : QST_TARGET(rnum),
targetname, targetname,
@@ -719,14 +714,17 @@ static void quest_stat(struct char_data *ch, char argument[MAX_STRING_LENGTH])
if (QST_PREREQ(rnum) != NOTHING) if (QST_PREREQ(rnum) != NOTHING)
send_to_char(ch, "Preq : [\ty%5d\tn] \ty%s\tn\r\n", send_to_char(ch, "Preq : [\ty%5d\tn] \ty%s\tn\r\n",
QST_PREREQ(rnum) == NOTHING ? -1 : QST_PREREQ(rnum), QST_PREREQ(rnum) == NOTHING ? -1 : QST_PREREQ(rnum),
QST_PREREQ(rnum) == NOTHING ? "" : QST_PREREQ(rnum) == NOTHING
real_object(QST_PREREQ(rnum)) == NOTHING ? "an unknown object" : ? ""
obj_proto[real_object(QST_PREREQ(rnum))].short_description); : real_object(QST_PREREQ(rnum)) == NOTHING
? "an unknown object"
: obj_proto[real_object(QST_PREREQ(rnum))].short_description);
if (QST_TYPE(rnum) == AQ_OBJ_RETURN) if (QST_TYPE(rnum) == AQ_OBJ_RETURN)
send_to_char(ch, "Mob : [\ty%5d\tn] \ty%s\tn\r\n", send_to_char(ch, "Mob : [\ty%5d\tn] \ty%s\tn\r\n",
QST_RETURNMOB(rnum), QST_RETURNMOB(rnum),
real_mobile(QST_RETURNMOB(rnum)) == NOBODY ? "an unknown mob" : real_mobile(QST_RETURNMOB(rnum)) == NOBODY
mob_proto[real_mobile(QST_RETURNMOB(rnum))].player.short_descr); ? "an unknown mob"
: mob_proto[real_mobile(QST_RETURNMOB(rnum))].player.short_descr);
if (QST_TIME(rnum) != -1) if (QST_TIME(rnum) != -1)
send_to_char(ch, "Limit : There is a time limit of %d turn%s to complete.\r\n", send_to_char(ch, "Limit : There is a time limit of %d turn%s to complete.\r\n",
QST_TIME(rnum), QST_TIME(rnum),
@@ -755,15 +753,11 @@ static void quest_stat(struct char_data *ch, char argument[MAX_STRING_LENGTH])
ACMD(do_quest) ACMD(do_quest)
{ {
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int tp; int tp;
two_arguments(argument, arg1, arg2); two_arguments(argument, arg1, arg2);
if (!*arg1) if (!*arg1 || (tp = search_block(arg1, quest_cmd, FALSE)) == -1)
send_to_char(ch, "%s\r\n", GET_LEVEL(ch) < LVL_IMMORT ? send_to_char(ch, "%s\r\n", GET_LEVEL(ch) < LVL_IMMORT ? quest_mort_usage : quest_imm_usage);
quest_mort_usage : quest_imm_usage);
else if (((tp = search_block(arg1, quest_cmd, FALSE)) == -1))
send_to_char(ch, "%s\r\n", GET_LEVEL(ch) < LVL_IMMORT ?
quest_mort_usage : quest_imm_usage);
else { else {
switch (tp) { switch (tp) {
case SCMD_QUEST_LIST: case SCMD_QUEST_LIST:
@@ -787,8 +781,7 @@ ACMD(do_quest)
quest_stat(ch, arg2); quest_stat(ch, arg2);
break; break;
default: /* Whe should never get here, but... */ default: /* Whe should never get here, but... */
send_to_char(ch, "%s\r\n", GET_LEVEL(ch) < LVL_IMMORT ? send_to_char(ch, "%s\r\n", GET_LEVEL(ch) < LVL_IMMORT ? quest_mort_usage : quest_imm_usage);
quest_mort_usage : quest_imm_usage);
break; break;
} /* switch on subcmd number */ } /* switch on subcmd number */
} }
@@ -796,41 +789,40 @@ ACMD(do_quest)
SPECIAL(questmaster) SPECIAL(questmaster)
{ {
qst_rnum rnum; qst_rnum rnum = 0;
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int tp; int tp;
struct char_data *qm = (struct char_data *)me; struct char_data *qm = (struct char_data *)me;
/* check that qm mob has quests assigned */ /* check that qm mob has quests assigned */
for (rnum = 0; (rnum < total_quests && while (rnum < total_quests && QST_MASTER(rnum) != GET_MOB_VNUM(qm))
QST_MASTER(rnum) != GET_MOB_VNUM(qm)) ; rnum ++); rnum++;
if (rnum >= total_quests) if (rnum >= total_quests)
return FALSE; /* No quests for this mob */ return FALSE; /* No quests for this mob */
else if (QST_FUNC(rnum) && (QST_FUNC(rnum) (ch, me, cmd, argument))) if (QST_FUNC(rnum) && QST_FUNC(rnum)(ch, me, cmd, argument))
return TRUE; /* The secondary spec proc handled this command */ return TRUE; /* The secondary spec proc handled this command */
else if (CMD_IS("quest")) { if (CMD_IS("quest")) {
two_arguments(argument, arg1, arg2); two_arguments(argument, arg1, arg2);
if (!*arg1) if (!*arg1)
return FALSE; return FALSE;
else if (((tp = search_block(arg1, quest_cmd, FALSE)) == -1)) if ((tp = search_block(arg1, quest_cmd, FALSE)) == -1)
return FALSE; return FALSE;
else {
switch (tp) { switch (tp) {
case SCMD_QUEST_LIST: case SCMD_QUEST_LIST:
if (!*arg2) if (!*arg2)
quest_show(ch, GET_MOB_VNUM(qm)); quest_show(ch, GET_MOB_VNUM(qm));
else else
quest_list(ch, qm, arg2); quest_list(ch, qm, arg2);
break; break;
case SCMD_QUEST_JOIN: case SCMD_QUEST_JOIN:
quest_join(ch, qm, arg2); quest_join(ch, qm, arg2);
break; break;
default: default:
return FALSE; /* fall through to the do_quest command processor */ return FALSE; /* fall through to the do_quest command processor */
} /* switch on subcmd number */ } /* switch on subcmd number */
return TRUE; return TRUE;
}
} else {
return FALSE; /* not a questmaster command */
} }
return FALSE; /* not a questmaster command */
} }

View File

@@ -34,27 +34,30 @@
/* AQ Flags (much room for expansion) ********************************* */ /* AQ Flags (much room for expansion) ********************************* */
#define AQ_REPEATABLE (1 << 0) /* Quest can be repeated */ #define AQ_REPEATABLE (1 << 0) /* Quest can be repeated */
#define NUM_AQ_FLAGS 1 #define NUM_AQ_FLAGS 1
/* Main quest struct ************************************************** */ /* Main quest struct ************************************************** */
struct aq_data { struct aq_data
qst_vnum vnum; /* Virtual nr of the quest */ {
char *name; /* For qlist and the sort */ qst_vnum vnum; /* Virtual nr of the quest */
char *desc; /* Description of the quest */ char *name; /* For qlist and the sort */
char *info; /* Message displayed when accepted */ char *desc; /* Description of the quest */
char *done; /* Message displayed when completed */ char *info; /* Message displayed when accepted */
char *quit; /* Message displayed when quit quest */ char *done; /* Message displayed when completed */
long flags; /* Flags (repeatable, etc */ char *quit; /* Message displayed when quit quest */
int type; /* Quest type */ bitvector_t flags; /* Flags (repeatable, etc */
mob_vnum qm; /* questmaster offering quest */ int type; /* Quest type */
int target; /* Target value */ mob_vnum qm; /* questmaster offering quest */
obj_vnum prereq; /* Object required to undertake quest */ int target; /* Target value */
int value[7]; /* Quest values */ obj_vnum prereq; /* Object required to undertake quest */
int gold_reward; /* Number of gold coins given as reward */ int value[7]; /* Quest values */
int exp_reward; /* Experience points given as a reward */ int gold_reward; /* Number of gold coins given as reward */
obj_vnum obj_reward; /* vnum of object given as a reward */ int exp_reward; /* Experience points given as a reward */
qst_vnum prev_quest; /* Link to prev quest, NOTHING is open */ obj_vnum obj_reward; /* vnum of object given as a reward */
qst_vnum next_quest; /* Link to next quest, NOTHING is end */ qst_vnum prev_quest; /* Link to prev quest, NOTHING is open */
SPECIAL (*func); /* secondary spec_proc for the QM */ qst_vnum next_quest; /* Link to next quest, NOTHING is end */
SPECIAL(*func); /* secondary spec_proc for the QM */
}; };
#define QST_NUM(i) (aquest_table[i].vnum) #define QST_NUM(i) (aquest_table[i].vnum)
#define QST_NAME(i) (aquest_table[i].name) #define QST_NAME(i) (aquest_table[i].name)
#define QST_DESC(i) (aquest_table[i].desc) #define QST_DESC(i) (aquest_table[i].desc)
@@ -85,17 +88,17 @@ struct aq_data {
void destroy_quests(void); void destroy_quests(void);
void assign_the_quests(void); void assign_the_quests(void);
void parse_quest(FILE *quest_f, int nr); void parse_quest(FILE *quest_f, int nr);
int count_quests(qst_vnum low, qst_vnum high); int count_quests(qst_vnum low, qst_vnum high);
void list_quests(struct char_data *ch, zone_rnum zone, qst_vnum vmin, qst_vnum vmax); void list_quests(struct char_data *ch, zone_rnum zone, qst_vnum vmin, qst_vnum vmax);
void set_quest(struct char_data *ch, qst_rnum rnum); void set_quest(const struct char_data *ch, qst_rnum rnum);
void clear_quest(struct char_data *ch); void clear_quest(const struct char_data *ch);
void generic_complete_quest(struct char_data *ch); void generic_complete_quest(struct char_data *ch);
void autoquest_trigger_check(struct char_data *ch, struct char_data *vict, struct obj_data *object, int type); void autoquest_trigger_check(struct char_data *ch, const struct char_data *vict, const struct obj_data *object, int type);
qst_rnum real_quest(qst_vnum vnum); qst_rnum real_quest(qst_vnum vnum);
int is_complete(struct char_data *ch, qst_vnum vnum); int is_complete(const struct char_data *ch, qst_vnum vnum);
qst_vnum find_quest_by_qmnum(struct char_data *ch, mob_rnum qm, int num); qst_vnum find_quest_by_qmnum(struct char_data *ch, mob_rnum qm, int num);
void add_completed_quest(struct char_data *ch, qst_vnum vnum); void add_completed_quest(const struct char_data *ch, qst_vnum vnum);
void remove_completed_quest(struct char_data *ch, qst_vnum vnum); void remove_completed_quest(const struct char_data *ch, qst_vnum vnum);
void quest_timeout(struct char_data *ch); void quest_timeout(struct char_data *ch);
void check_timed_quests(void); void check_timed_quests(void);
SPECIAL(questmaster); SPECIAL(questmaster);
@@ -141,7 +144,7 @@ int save_quests(zone_rnum zone_num);
/* ******************************************************************** */ /* ******************************************************************** */
/* AQ Global Variables ************************************************ */ /* AQ Global Variables ************************************************ */
extern const char *aq_flags[]; /* names for quest flags (quest.c) */ extern const char *aq_flags[]; /* names for quest flags (quest.c) */
extern const char *quest_types[]; /* named for quest types (quest.c) */ extern const char *quest_types[]; /* named for quest types (quest.c) */
#endif /* _QUEST_H_ */ #endif /* _QUEST_H_ */

View File

@@ -603,6 +603,10 @@ do \
#define GET_QUEST_COUNTER(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.quest_counter)) #define GET_QUEST_COUNTER(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.quest_counter))
/** Time remaining to complete the quest ch is currently on. */ /** Time remaining to complete the quest ch is currently on. */
#define GET_QUEST_TIME(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.quest_time)) #define GET_QUEST_TIME(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.quest_time))
/** The completed quest at index i for this player */
#define GET_COMPLETED_QUEST(ch, i) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.completed_quests[(i)]))
/** The array of completed quests for ch */
#define GET_COMPLETED_QUESTS(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.completed_quests))
/** The number of quests completed by ch. */ /** The number of quests completed by ch. */
#define GET_NUM_QUESTS(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.num_completed_quests)) #define GET_NUM_QUESTS(ch) CHECK_PLAYER_SPECIAL((ch), ((ch)->player_specials->saved.num_completed_quests))
/** The type of quest ch is currently participating in. */ /** The type of quest ch is currently participating in. */