Fixed warnings in act.informative.c, act.social.c and someone made

changes to act.comm.c...

Welcor
This commit is contained in:
Rumble
2008-05-01 23:32:11 +00:00
parent 1a8c04e46f
commit 84bd1766b2
3 changed files with 47 additions and 83 deletions

View File

@@ -22,11 +22,6 @@
#include "act.h" #include "act.h"
#include "modify.h" #include "modify.h"
/* prototypes of local functions */
/* do_tell utility functions */
static void perform_tell(struct char_data *ch, struct char_data *vict, char *arg);
static int is_tell_ok(struct char_data *ch, struct char_data *vict);
ACMD(do_say) ACMD(do_say)
{ {
skip_spaces(&argument); skip_spaces(&argument);
@@ -52,7 +47,8 @@ ACMD(do_say)
add_history(ch, msg, HIST_SAY); add_history(ch, msg, HIST_SAY);
} }
} }
/* trigger check */
/* Trigger check. */
speech_mtrigger(ch, argument); speech_mtrigger(ch, argument);
speech_wtrigger(ch, argument); speech_wtrigger(ch, argument);
} }
@@ -156,11 +152,12 @@ ACMD(do_tell)
return; return;
} }
} }
/* only a-z and +/- allowed */
for (p = buf2, q = word; *p ; p++) { /* Only a-z and +/- allowed. */
for (p = buf2, q = word; *p ; p++)
if ((LOWER(*p) <= 'z' && LOWER(*p) >= 'a') || (*p == '+') || (*p == '-')) if ((LOWER(*p) <= 'z' && LOWER(*p) >= 'a') || (*p == '+') || (*p == '-'))
*q++ = *p; *q++ = *p;
}
*q = '\0'; *q = '\0';
if (!*word) { if (!*word) {
@@ -171,7 +168,6 @@ ACMD(do_tell)
system(buf); system(buf);
last_webster_teller = GET_IDNUM(ch); last_webster_teller = GET_IDNUM(ch);
send_to_char(ch, "You look up '%s' in Merriam-Webster.\r\n", word); send_to_char(ch, "You look up '%s' in Merriam-Webster.\r\n", word);
} else if (GET_LEVEL(ch) < LVL_IMMORT && !(vict = get_player_vis(ch, buf, NULL, FIND_CHAR_WORLD))) } else if (GET_LEVEL(ch) < LVL_IMMORT && !(vict = get_player_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
send_to_char(ch, "%s", CONFIG_NOPERSON); send_to_char(ch, "%s", CONFIG_NOPERSON);
else if (GET_LEVEL(ch) >= LVL_IMMORT && !(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_WORLD))) else if (GET_LEVEL(ch) >= LVL_IMMORT && !(vict = get_char_vis(ch, buf, NULL, FIND_CHAR_WORLD)))
@@ -200,10 +196,10 @@ ACMD(do_reply)
* work if someone logs out and back in again. A descriptor list based * work if someone logs out and back in again. A descriptor list based
* search would be faster although we could not find link dead people. * search would be faster although we could not find link dead people.
* Not that they can hear tells anyway. :) -gg 2/24/98 */ * Not that they can hear tells anyway. :) -gg 2/24/98 */
while (tch != NULL && (IS_NPC(tch) || GET_IDNUM(tch) != GET_LAST_TELL(ch))) while (tch && (IS_NPC(tch) || GET_IDNUM(tch) != GET_LAST_TELL(ch)))
tch = tch->next; tch = tch->next;
if (tch == NULL) if (!tch)
send_to_char(ch, "They are no longer playing.\r\n"); send_to_char(ch, "They are no longer playing.\r\n");
else if (is_tell_ok(ch, tch)) else if (is_tell_ok(ch, tch))
perform_tell(ch, tch, argument); perform_tell(ch, tch, argument);
@@ -258,7 +254,6 @@ ACMD(do_spec_comm)
} }
} }
/* buf1, buf2 = MAX_OBJECT_NAME_LENGTH (if it existed) */
ACMD(do_write) ACMD(do_write)
{ {
struct obj_data *paper, *pen = NULL; struct obj_data *paper, *pen = NULL;
@@ -273,11 +268,13 @@ ACMD(do_write)
if (!ch->desc) if (!ch->desc)
return; return;
if (!*papername) { /* nothing was delivered */ if (!*papername) {
/* Nothing was delivered. */
send_to_char(ch, "Write? With what? ON what? What are you trying to do?!?\r\n"); send_to_char(ch, "Write? With what? ON what? What are you trying to do?!?\r\n");
return; return;
} }
if (*penname) { /* there were two arguments */ if (*penname) {
/* Nothing was delivered. */
if (!(paper = get_obj_in_list_vis(ch, papername, NULL, ch->carrying))) { if (!(paper = get_obj_in_list_vis(ch, papername, NULL, ch->carrying))) {
send_to_char(ch, "You have no %s.\r\n", papername); send_to_char(ch, "You have no %s.\r\n", papername);
return; return;
@@ -286,18 +283,19 @@ ACMD(do_write)
send_to_char(ch, "You have no %s.\r\n", penname); send_to_char(ch, "You have no %s.\r\n", penname);
return; return;
} }
} else { /* there was one arg.. let's see what we can find */ } else { /* There was one arg.. let's see what we can find. */
if (!(paper = get_obj_in_list_vis(ch, papername, NULL, ch->carrying))) { if (!(paper = get_obj_in_list_vis(ch, papername, NULL, ch->carrying))) {
send_to_char(ch, "There is no %s in your inventory.\r\n", papername); send_to_char(ch, "There is no %s in your inventory.\r\n", papername);
return; return;
} }
if (GET_OBJ_TYPE(paper) == ITEM_PEN) { /* oops, a pen.. */ if (GET_OBJ_TYPE(paper) == ITEM_PEN) { /* Oops, a pen. */
pen = paper; pen = paper;
paper = NULL; paper = NULL;
} else if (GET_OBJ_TYPE(paper) != ITEM_NOTE) { } else if (GET_OBJ_TYPE(paper) != ITEM_NOTE) {
send_to_char(ch, "That thing has nothing to do with writing.\r\n"); send_to_char(ch, "That thing has nothing to do with writing.\r\n");
return; return;
} }
/* One object was found.. now for the other one. */ /* One object was found.. now for the other one. */
if (!GET_EQ(ch, WEAR_HOLD)) { if (!GET_EQ(ch, WEAR_HOLD)) {
send_to_char(ch, "You can't write with %s %s alone.\r\n", AN(papername), papername); send_to_char(ch, "You can't write with %s %s alone.\r\n", AN(papername), papername);
@@ -313,7 +311,7 @@ ACMD(do_write)
pen = GET_EQ(ch, WEAR_HOLD); pen = GET_EQ(ch, WEAR_HOLD);
} }
/* ok.. now let's see what kind of stuff we've found */ /* Now let's see what kind of stuff we've found. */
if (GET_OBJ_TYPE(pen) != ITEM_PEN) if (GET_OBJ_TYPE(pen) != ITEM_PEN)
act("$p is no good for writing with.", FALSE, ch, pen, 0, TO_CHAR); act("$p is no good for writing with.", FALSE, ch, pen, 0, TO_CHAR);
else if (GET_OBJ_TYPE(paper) != ITEM_NOTE) else if (GET_OBJ_TYPE(paper) != ITEM_NOTE)
@@ -328,7 +326,7 @@ ACMD(do_write)
send_to_char(ch, "%s", paper->action_description); send_to_char(ch, "%s", paper->action_description);
} }
/* we can write - hooray! */ /* We can write. */
act("$n begins to jot down a note.", TRUE, ch, 0, 0, TO_ROOM); act("$n begins to jot down a note.", TRUE, ch, 0, 0, TO_ROOM);
send_editor_help(ch->desc); send_editor_help(ch->desc);
string_write(ch->desc, &paper->action_description, MAX_NOTE_LENGTH, 0, backstr); string_write(ch->desc, &paper->action_description, MAX_NOTE_LENGTH, 0, backstr);
@@ -360,7 +358,7 @@ ACMD(do_page)
send_to_char(ch, "You will never be godly enough to do that!\r\n"); send_to_char(ch, "You will never be godly enough to do that!\r\n");
return; return;
} }
if ((vict = get_char_vis(ch, arg, NULL, FIND_CHAR_WORLD)) != NULL) { if (!(vict = get_char_vis(ch, arg, NULL, FIND_CHAR_WORLD))) {
act(buf, FALSE, ch, 0, vict, TO_VICT); act(buf, FALSE, ch, 0, vict, TO_VICT);
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT)) if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK); send_to_char(ch, "%s", CONFIG_OK);
@@ -371,17 +369,7 @@ ACMD(do_page)
} }
} }
int first_word_is_name(struct char_data *ch, char * argument) { /* Generalized communication function by Fred C. Merkel (Torg). */
char buf[MAX_INPUT_LENGTH];
char name_p[MAX_INPUT_LENGTH];
if (argument == NULL || IS_NPC(ch))
return 0;
strlcpy(buf, argument, sizeof(buf));
one_argument(buf, name_p);
return !str_cmp(GET_NAME(ch), name_p);
}
/* generalized communication func, originally by Fred C. Merkel (Torg) */
ACMD(do_gen_comm) ACMD(do_gen_comm)
{ {
struct descriptor_data *i; struct descriptor_data *i;
@@ -389,7 +377,7 @@ ACMD(do_gen_comm)
char buf1[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH], *msg; char buf1[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH], *msg;
bool emoting = FALSE; bool emoting = FALSE;
/* Array of flags which must _not_ be set in order for comm to be heard */ /* Array of flags which must _not_ be set in order for comm to be heard. */
int channels[] = { int channels[] = {
0, 0,
PRF_NOSHOUT, PRF_NOSHOUT,
@@ -444,10 +432,6 @@ ACMD(do_gen_comm)
KYEL} KYEL}
}; };
/* to keep pets, etc from being ordered to shout */
if (!ch->desc)
return;
if (PLR_FLAGGED(ch, PLR_NOSHOUT)) { if (PLR_FLAGGED(ch, PLR_NOSHOUT)) {
send_to_char(ch, "%s", com_msgs[subcmd][0]); send_to_char(ch, "%s", com_msgs[subcmd][0]);
return; return;
@@ -457,33 +441,30 @@ ACMD(do_gen_comm)
return; return;
} }
if (subcmd == SCMD_GOSSIP && *argument == '*') {
subcmd = SCMD_GEMOTE;
}
if (subcmd == SCMD_GEMOTE) { if (subcmd == SCMD_GEMOTE) {
if (*argument == '*') if (!*argument)
do_gmote(ch, argument + 1, 0, 1); send_to_char(ch, "Gemote? Yes? Gemote what?\r\n");
else else
do_gmote(ch, argument, 0, 1); do_gmote(ch, argument, 0, 1);
return; return;
} }
/* level_can_shout defined in config.c */ /* Level_can_shout defined in config.c. */
if (GET_LEVEL(ch) < CONFIG_LEVEL_CAN_SHOUT) { if (GET_LEVEL(ch) < CONFIG_LEVEL_CAN_SHOUT) {
send_to_char(ch, "You must be at least level %d before you can %s.\r\n", CONFIG_LEVEL_CAN_SHOUT, com_msgs[subcmd][1]); send_to_char(ch, "You must be at least level %d before you can %s.\r\n", CONFIG_LEVEL_CAN_SHOUT, com_msgs[subcmd][1]);
return; return;
} }
/* make sure the char is on the channel */ /* Make sure the char is on the channel. */
if (PRF_FLAGGED(ch, channels[subcmd])) { if (PRF_FLAGGED(ch, channels[subcmd])) {
send_to_char(ch, "%s", com_msgs[subcmd][2]); send_to_char(ch, "%s", com_msgs[subcmd][2]);
return; return;
} }
/* skip leading spaces */ /* skip leading spaces */
skip_spaces(&argument); skip_spaces(&argument);
/* make sure that there is something there to say! */ /* Make sure that there is something there to say! */
if (!*argument) { if (!*argument) {
send_to_char(ch, "Yes, %s, fine, %s we must, but WHAT???\r\n", com_msgs[subcmd][1], com_msgs[subcmd][1]); send_to_char(ch, "Yes, %s, fine, %s we must, but WHAT???\r\n", com_msgs[subcmd][1], com_msgs[subcmd][1]);
return; return;
@@ -495,27 +476,23 @@ ACMD(do_gen_comm)
} else } else
GET_MOVE(ch) -= CONFIG_HOLLER_MOVE_COST; GET_MOVE(ch) -= CONFIG_HOLLER_MOVE_COST;
} }
/* set up the color on code */ /* Set up the color on code. */
strlcpy(color_on, com_msgs[subcmd][3], sizeof(color_on)); strlcpy(color_on, com_msgs[subcmd][3], sizeof(color_on));
/* first, set up strings to be given to the communicator */ /* First, set up strings to be given to the communicator. */
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT)) if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_NOREPEAT))
send_to_char(ch, "%s", CONFIG_OK); send_to_char(ch, "%s", CONFIG_OK);
else { else {
if (!first_word_is_name(ch, argument)) { snprintf(buf1, sizeof(buf1), "%sYou %s, '%s%s'%s", COLOR_LEV(ch) >= C_CMP ? color_on : "",
snprintf(buf1, sizeof(buf1), "%sYou %s, '%s%s'%s", COLOR_LEV(ch) >= C_CMP ? color_on : "", com_msgs[subcmd][1], argument, COLOR_LEV(ch) >= C_CMP com_msgs[subcmd][1], argument, COLOR_LEV(ch) >= C_CMP ? color_on : "", CCNRM(ch, C_CMP));
? color_on : "", CCNRM(ch, C_CMP));
} else {
emoting = TRUE;
snprintf(buf1, sizeof(buf1), "%s%s: %s%s", COLOR_LEV(ch) >= C_CMP ? color_on : "", com_msgs[subcmd][1], CAP(argument), CCNRM(ch, C_CMP));
}
msg = act(buf1, FALSE, ch, 0, 0, TO_CHAR); msg = act(buf1, FALSE, ch, 0, 0, TO_CHAR);
add_history(ch, msg, hist_type[subcmd]); add_history(ch, msg, hist_type[subcmd]);
} }
if (!emoting) if (!emoting)
snprintf(buf1, sizeof(buf1), "$n %ss, '%s'", com_msgs[subcmd][1], argument); snprintf(buf1, sizeof(buf1), "$n %ss, '%s'", com_msgs[subcmd][1], argument);
/* now send all the strings out */ /* Now send all the strings out. */
for (i = descriptor_list; i; i = i->next) { for (i = descriptor_list; i; i = i->next) {
if (STATE(i) != CON_PLAYING || i == ch->desc || !i->character ) if (STATE(i) != CON_PLAYING || i == ch->desc || !i->character )
continue; continue;
@@ -525,8 +502,7 @@ ACMD(do_gen_comm)
if (ROOM_FLAGGED(IN_ROOM(i->character), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD)) if (ROOM_FLAGGED(IN_ROOM(i->character), ROOM_SOUNDPROOF) && (GET_LEVEL(ch) < LVL_GOD))
continue; continue;
if (subcmd == SCMD_SHOUT && if (subcmd == SCMD_SHOUT && ((world[IN_ROOM(ch)].zone != world[IN_ROOM(i->character)].zone) ||
((world[IN_ROOM(ch)].zone != world[IN_ROOM(i->character)].zone) ||
!AWAKE(i->character))) !AWAKE(i->character)))
continue; continue;
@@ -569,4 +545,3 @@ ACMD(do_qcomm)
act(buf, 0, ch, 0, i->character, TO_VICT | TO_SLEEP); act(buf, 0, ch, 0, i->character, TO_VICT | TO_SLEEP);
} }
} }

View File

@@ -1639,8 +1639,8 @@ ACMD(do_where)
ACMD(do_levels) ACMD(do_levels)
{ {
char buf[MAX_STRING_LENGTH], arg[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH], arg[MAX_STRING_LENGTH];
size_t i, len = 0, nlen; size_t len = 0, nlen;
int ret, min_lev=1, max_lev=LVL_IMMORT, val; int i, ret, min_lev=1, max_lev=LVL_IMMORT, val;
if (IS_NPC(ch)) { if (IS_NPC(ch)) {
send_to_char(ch, "You ain't nothin' but a hound-dog.\r\n"); send_to_char(ch, "You ain't nothin' but a hound-dog.\r\n");
@@ -1682,7 +1682,7 @@ ACMD(do_levels)
for (i = min_lev; i < max_lev; i++) { for (i = min_lev; i < max_lev; i++) {
nlen = snprintf(buf + len, sizeof(buf) - len, "[%2d] %8d-%-8d : ", (int)i, nlen = snprintf(buf + len, sizeof(buf) - len, "[%2d] %8d-%-8d : ", (int)i,
level_exp(GET_CLASS(ch), i), level_exp(GET_CLASS(ch), i + 1) - 1); level_exp(GET_CLASS(ch), i), level_exp(GET_CLASS(ch), i + 1) - 1);
if (len + nlen >= sizeof(buf) || nlen < 0) if (len + nlen >= sizeof(buf))
break; break;
len += nlen; len += nlen;
@@ -1698,7 +1698,7 @@ ACMD(do_levels)
nlen = snprintf(buf + len, sizeof(buf) - len, "Oh dear. You seem to be sexless.\r\n"); nlen = snprintf(buf + len, sizeof(buf) - len, "Oh dear. You seem to be sexless.\r\n");
break; break;
} }
if (len + nlen >= sizeof(buf) || nlen < 0) if (len + nlen >= sizeof(buf))
break; break;
len += nlen; len += nlen;
} }

View File

@@ -150,23 +150,12 @@ void create_command_list(void)
complete_cmd_info[k++].subcmd = 0; complete_cmd_info[k++].subcmd = 0;
} }
} }
complete_cmd_info[k].command = strdup("\n"); complete_cmd_info[k] = cmd_info[i];
complete_cmd_info[k].sort_as = strdup("zzzzzzz");
complete_cmd_info[k].minimum_position = 0;
complete_cmd_info[k].command_pointer = 0;
complete_cmd_info[k].minimum_level = 0;
complete_cmd_info[k].subcmd = 0;
log("Command info rebuilt, %d total commands.", k); log("Command info rebuilt, %d total commands.", k);
} }
void free_command_list(void) void free_command_list(void)
{ {
int i;
for (i = 0;*complete_cmd_info[i].command !='\n';i++);
free((char *)complete_cmd_info[i].command); /* special case, the terminator */
free((char *)complete_cmd_info[i].sort_as);
free(complete_cmd_info); free(complete_cmd_info);
complete_cmd_info = NULL; complete_cmd_info = NULL;
} }