Cleaned up numerous warnings found by adding -Wextra -Wcast-qual -Wshadow -Wno-unused flags. --Rumble

This commit is contained in:
Rumble 2008-05-07 23:34:40 +00:00
parent e8c87e82e4
commit 4f1403558a
28 changed files with 186 additions and 187 deletions

View file

@ -3,6 +3,14 @@ help, find any bugs, or have ideas for improvement please stop by TBA at
telnet://tbamud.com:9091 or email rumble@tbamud.com --Rumble
tbaMUD 3.56
[May 05 2008] - Rumble
Changed command do_list_llog_entries to normal function, it was not being used as a command.
Changed command do_list_llog_entries to normal function
Changed command do_list_llog_entries to normal function
Changed command do_list_llog_entries to normal function
Changed command do_list_llog_entries to normal function
Removed several useless if checks. (thanks Elanthis)
Fixed zmalloc to work on 64 bit machines.
[May 04 2008] - Rumble
Fixed numerous warnings for gcc -g -O2 -W -Wshadow -Wcast-qual flags.
Fixed zpurge mudlog to use zone vnum not rnum. (thanks Jamdog)

View file

@ -56,7 +56,7 @@ char *find_exdesc(char *word, struct extra_descr_data *list);
/** @todo Move to a mud centric string utility library */
void space_to_minus(char *str);
/** @todo Move to a help module? */
int search_help(char *argument, int level);
int search_help(const char *argument, int level);
/* functions with subcommands */
/* do_commands */
ACMD(do_commands);

View file

@ -999,7 +999,7 @@ void space_to_minus(char *str)
*str = '-';
}
int search_help(char *argument, int level)
int search_help(const char *argument, int level)
{
int chk, bot, top, mid, minlen;

View file

@ -590,7 +590,7 @@ ACMD(do_gen_door)
if ((obj) || (door >= 0)) {
keynum = DOOR_KEY(ch, obj, door);
if (!(DOOR_IS_OPENABLE(ch, obj, door)))
act("You can't $F that!", FALSE, ch, 0, cmd_door[subcmd], TO_CHAR);
send_to_char(ch, "You can't %s that!\r\n", cmd_door[subcmd]);
else if (!DOOR_IS_OPEN(ch, obj, door) &&
IS_SET(flags_door[subcmd], NEED_OPEN))
send_to_char(ch, "But it's already closed!\r\n");

View file

@ -258,7 +258,7 @@ int valid_name(char *newname)
return (0);
/* return valid if list doesn't exist */
if (!invalid_list || num_invalid < 1)
if (invalid_list == NULL || num_invalid < 1)
return (1);
/* change to lowercase */

View file

@ -2403,7 +2403,7 @@ const char *ACTNULL = "<NULL>";
if ((pointer) == NULL) i = ACTNULL; else i = (expression);
/* higher-level communication: the act() function */
void perform_act(const char *orig, struct char_data *ch, struct obj_data *obj,
const void *vict_obj, const struct char_data *to)
void *vict_obj, struct char_data *to)
{
const char *i = NULL;
char lbuf[MAX_STRING_LENGTH], *buf, *j;
@ -2531,9 +2531,9 @@ void perform_act(const char *orig, struct char_data *ch, struct obj_data *obj,
}
char *act(const char *str, int hide_invisible, struct char_data *ch,
struct obj_data *obj, const void *vict_obj, int type)
struct obj_data *obj, void *vict_obj, int type)
{
const struct char_data *to;
struct char_data *to;
int to_sleeping;
if (!str || !*str)
@ -2565,7 +2565,7 @@ char *act(const char *str, int hide_invisible, struct char_data *ch,
}
if (type == TO_VICT) {
if ((to = (const struct char_data *) vict_obj) != NULL && SENDOK(to)) {
if ((to = vict_obj) != NULL && SENDOK(to)) {
perform_act(str, ch, obj, vict_obj, to);
return last_act_message;
}

View file

@ -40,8 +40,8 @@ void send_to_range(room_vnum start, room_vnum finish, const char *messg, ...)
/* act functions */
void perform_act(const char *orig, struct char_data *ch, struct obj_data *obj, const void *vict_obj, const struct char_data *to);
char * act(const char *str, int hide_invisible, struct char_data *ch, struct obj_data *obj, const void *vict_obj, int type);
void perform_act(const char *orig, struct char_data *ch, struct obj_data *obj, void *vict_obj, struct char_data *to);
char * act(const char *str, int hide_invisible, struct char_data *ch, struct obj_data *obj, void *vict_obj, int type);
/* I/O functions */
void write_to_q(const char *txt, struct txt_q *queue, int aliased);

View file

@ -719,12 +719,12 @@ void boot_db(void)
#if 1
{
int i;
int j;
for (i = 0 ; i < top_of_objt; i++) {
if (obj_proto[i].script == (struct script_data *)&shop_keeper) {
log("Item %d (%s) had shopkeeper trouble.", obj_index[i].vnum, obj_proto[i].short_description);
obj_proto[i].script = NULL;
for (j = 0 ; j < top_of_objt; j++) {
if (obj_proto[j].script == (struct script_data *)&shop_keeper) {
log("Item %d (%s) had shopkeeper trouble.", obj_index[j].vnum, obj_proto[j].short_description);
obj_proto[j].script = NULL;
}
}
}
@ -2083,14 +2083,14 @@ static void get_one_line(FILE *fl, char *buf)
buf[strlen(buf) - 1] = '\0'; /* take off the trailing \n */
}
void free_help(struct help_index_element *help)
void free_help(struct help_index_element *hentry)
{
if (help->keywords)
free(help->keywords);
if (help->entry && !help->duplicate)
free(help->entry);
if (hentry->keywords)
free(hentry->keywords);
if (hentry->entry && !hentry->duplicate)
free(hentry->entry);
free(help);
free(hentry);
}
void free_help_table(void)
@ -3216,7 +3216,7 @@ static int check_object(struct obj_data *obj)
GET_OBJ_VNUM(obj), obj->short_description, obj->name);
}
next_name = any_one_arg(next_name, onealias);
} while (onealias && *onealias);
} while (*onealias);
}
break;
case ITEM_FURNITURE:
@ -3430,14 +3430,14 @@ void load_config( void )
else if (!str_cmp(tag, "dflt_dir")) {
if (CONFIG_DFLT_DIR)
free(CONFIG_DFLT_DIR);
if (line && *line)
if (line != NULL && *line)
CONFIG_DFLT_DIR = strdup(line);
else
CONFIG_DFLT_DIR = strdup(DFLT_DIR);
} else if (!str_cmp(tag, "dflt_ip")) {
if (CONFIG_DFLT_IP)
free(CONFIG_DFLT_IP);
if (line && *line)
if (line != NULL && *line)
CONFIG_DFLT_IP = strdup(line);
else
CONFIG_DFLT_IP = NULL;
@ -3482,7 +3482,7 @@ void load_config( void )
else if (!str_cmp(tag, "logname")) {
if (CONFIG_LOGNAME)
free(CONFIG_LOGNAME);
if (line && *line)
if (line != NULL && *line)
CONFIG_LOGNAME = strdup(line);
else
CONFIG_LOGNAME = NULL;

View file

@ -169,8 +169,8 @@ void do_dg_affect(void *go, struct script_data *sc, trig_data *trig,
half_chop(cmd, value_p, duration_p);
/* make sure all parameters are present */
if (!charname || !*charname || !property || !*property ||
!value_p || !*value_p || !duration_p || !*duration_p) {
if (charname == NULL || !*charname || property == NULL || !*property ||
value_p == NULL || !*value_p || duration_p == NULL || !*duration_p) {
script_log("Trigger: %s, VNum %d. dg_affect usage: <target> <property> <value> <duration>",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig));
return;

View file

@ -378,12 +378,10 @@ ACMD(do_mload)
return;
}
two_arguments(target, arg1, arg2); /* recycling ... */
tch = (arg1 && *arg1 == UID_CHAR) ? get_char(arg1) : get_char_room_vis(ch, arg1, NULL);
tch = (arg1 != NULL && *arg1 == UID_CHAR) ? get_char(arg1) : get_char_room_vis(ch, arg1, NULL);
if (tch) {
if (arg2 && *arg2 &&
(pos = find_eq_pos_script(arg2)) >= 0 &&
!GET_EQ(tch, pos) &&
can_wear_on_pos(object, pos)) {
if (arg2 != NULL && *arg2 && (pos = find_eq_pos_script(arg2)) >= 0 &&
!GET_EQ(tch, pos) && can_wear_on_pos(object, pos)) {
equip_char(tch, object, pos);
load_otrigger(object);
return;
@ -392,7 +390,7 @@ ACMD(do_mload)
load_otrigger(object);
return;
}
cnt = (arg1 && *arg1 == UID_CHAR) ? get_obj(arg1) : get_obj_vis(ch, arg1, NULL);
cnt = (arg1 != NULL && *arg1 == UID_CHAR) ? get_obj(arg1) : get_obj_vis(ch, arg1, NULL);
if (cnt && GET_OBJ_TYPE(cnt) == ITEM_CONTAINER) {
obj_to_obj(object, cnt);
load_otrigger(object);

View file

@ -510,10 +510,8 @@ static OCMD(do_dgoload)
two_arguments(target, arg1, arg2); /* recycling ... */
tch = get_char_near_obj(obj, arg1);
if (tch) {
if (arg2 && *arg2 &&
(pos = find_eq_pos_script(arg2)) >= 0 &&
!GET_EQ(tch, pos) &&
can_wear_on_pos(object, pos)) {
if (arg2 != NULL && *arg2 && (pos = find_eq_pos_script(arg2)) >= 0 &&
!GET_EQ(tch, pos) && can_wear_on_pos(object, pos)) {
equip_char(tch, object, pos);
load_otrigger(object);
return;
@ -688,8 +686,7 @@ static OCMD(do_osetval)
int position, new_value;
two_arguments(argument, arg1, arg2);
if (!arg1 || !*arg1 || !arg2 || !*arg2 ||
!is_number(arg1) || !is_number(arg2)) {
if (arg1 == NULL || !*arg1 || arg2 == NULL || !*arg2 || !is_number(arg1) || !is_number(arg2)) {
obj_log(obj, "osetval: bad syntax");
return;
}

View file

@ -1189,7 +1189,7 @@ ACMD(do_detach)
}
}
if (!arg3 || !*arg3)
if (arg3 == NULL || !*arg3)
send_to_char(ch, "You must specify a trigger to remove.\r\n");
else
trigger = arg3;
@ -1214,7 +1214,7 @@ ACMD(do_detach)
}
}
if (!arg3 || !*arg3)
if (!arg3 == NULL || *arg3)
send_to_char(ch, "You must specify a trigger to remove.\r\n");
else
trigger = arg3;
@ -1952,7 +1952,7 @@ static void makeuid_var(void *go, struct script_data *sc, trig_data *trig,
return;
}
if (!arg || !*arg) {
if (arg == NULL || !*arg) {
script_log("Trigger: %s, VNum %d. makeuid invalid id arg: '%s'",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), cmd);
return;
@ -1964,7 +1964,7 @@ static void makeuid_var(void *go, struct script_data *sc, trig_data *trig,
eval_expr(arg, result, go, sc, trig, type);
snprintf(uid, sizeof(uid), "%c%s", UID_CHAR, result);
} else { /* a lot more work without it */
if (!name || !*name) {
if (name == NULL || !*name) {
script_log("Trigger: %s, VNum %d. makeuid needs name: '%s'",
GET_TRIG_NAME(trig), GET_TRIG_VNUM(trig), cmd);
return;
@ -2237,7 +2237,7 @@ int perform_set_dg_var(struct char_data *ch, struct char_data *vict, char *val_a
var_value = any_one_arg(val_arg, var_name);
if (!var_name || !*var_name || !var_value || !*var_value) {
if (var_name == NULL || !*var_name || var_value == NULL || !*var_value) {
send_to_char(ch, "Usage: set <char> <varname> <value>\r\n");
return 0;
}

View file

@ -320,7 +320,7 @@ void dg_obj_trigger(char *line, struct obj_data *obj);
void assign_triggers(void *i, int type);
/* From dg_variables.c */
void add_var(struct trig_var_data **var_list, char *name, char *value, long id);
void add_var(struct trig_var_data **var_list, const char *name, const char *value, long id);
int item_in_list(char *item, obj_data *list);
char *skill_percent(struct char_data *ch, char *skill);
int char_has_item(char *item, struct char_data *ch);

View file

@ -217,7 +217,7 @@ int greet_mtrigger(char_data *actor, int dir)
IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET_ALL)) &&
!GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
if (dir>=0 && dir < NUM_OF_DIRS)
add_var(&GET_TRIG_VARS(t), "direction", (char *)dirs[rev_dir[dir]], 0);
add_var(&GET_TRIG_VARS(t), "direction", dirs[rev_dir[dir]], 0);
else
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
ADD_UID_VAR(buf, t, actor, "actor", 0);
@ -543,7 +543,7 @@ int cast_mtrigger(char_data *actor, char_data *ch, int spellnum)
ADD_UID_VAR(buf, t, actor, "actor", 0);
sprintf(buf, "%d", spellnum);
add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
add_var(&GET_TRIG_VARS(t), "spellname", (char*)skill_name(spellnum), 0);
add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
}
}
@ -570,7 +570,7 @@ int leave_mtrigger(char_data *actor, int dir)
if ((IS_SET(GET_TRIG_TYPE(t), MTRIG_LEAVE) && CAN_SEE(ch, actor)) &&
!GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
if (dir>=0 && dir < NUM_OF_DIRS)
add_var(&GET_TRIG_VARS(t), "direction", (char *)dirs[dir], 0);
add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
else
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
ADD_UID_VAR(buf, t, actor, "actor", 0);
@ -596,9 +596,9 @@ int door_mtrigger(char_data *actor, int subcmd, int dir)
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
if (IS_SET(GET_TRIG_TYPE(t), MTRIG_DOOR) && CAN_SEE(ch, actor) &&
!GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
add_var(&GET_TRIG_VARS(t), "cmd", (char *)cmd_door[subcmd], 0);
add_var(&GET_TRIG_VARS(t), "cmd", cmd_door[subcmd], 0);
if (dir>=0 && dir < NUM_OF_DIRS)
add_var(&GET_TRIG_VARS(t), "direction", (char *)dirs[dir], 0);
add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
else
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
ADD_UID_VAR(buf, t, actor, "actor", 0);
@ -890,7 +890,7 @@ int cast_otrigger(char_data *actor, obj_data *obj, int spellnum)
ADD_UID_VAR(buf, t, actor, "actor", 0);
sprintf(buf, "%d", spellnum);
add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
add_var(&GET_TRIG_VARS(t), "spellname", (char *)skill_name(spellnum), 0);
add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
return script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
}
}
@ -917,7 +917,7 @@ int leave_otrigger(room_data *room, char_data *actor, int dir)
if (TRIGGER_CHECK(t, OTRIG_LEAVE) &&
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
if (dir>=0 && dir < NUM_OF_DIRS)
add_var(&GET_TRIG_VARS(t), "direction", (char *)dirs[dir], 0);
add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
else
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
ADD_UID_VAR(buf, t, actor, "actor", 0);
@ -1030,7 +1030,7 @@ int enter_wtrigger(struct room_data *room, char_data *actor, int dir)
if (TRIGGER_CHECK(t, WTRIG_ENTER) &&
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
if (dir>=0 && dir < NUM_OF_DIRS)
add_var(&GET_TRIG_VARS(t), "direction", (char *)dirs[rev_dir[dir]], 0);
add_var(&GET_TRIG_VARS(t), "direction", dirs[rev_dir[dir]], 0);
else
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
ADD_UID_VAR(buf, t, actor, "actor", 0);
@ -1159,7 +1159,7 @@ int cast_wtrigger(char_data *actor, char_data *vict, obj_data *obj, int spellnum
ADD_UID_VAR(buf, t, obj, "object", 0);
sprintf(buf, "%d", spellnum);
add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
add_var(&GET_TRIG_VARS(t), "spellname", (char *)skill_name(spellnum), 0);
add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
}
}
@ -1182,7 +1182,7 @@ int leave_wtrigger(struct room_data *room, char_data *actor, int dir)
if (TRIGGER_CHECK(t, WTRIG_LEAVE) &&
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
if (dir>=0 && dir < NUM_OF_DIRS)
add_var(&GET_TRIG_VARS(t), "direction", (char *)dirs[dir], 0);
add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
else
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
ADD_UID_VAR(buf, t, actor, "actor", 0);
@ -1206,9 +1206,9 @@ int door_wtrigger(char_data *actor, int subcmd, int dir)
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
if (TRIGGER_CHECK(t, WTRIG_DOOR) &&
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
add_var(&GET_TRIG_VARS(t), "cmd", (char *)cmd_door[subcmd], 0);
add_var(&GET_TRIG_VARS(t), "cmd", cmd_door[subcmd], 0);
if (dir>=0 && dir < NUM_OF_DIRS)
add_var(&GET_TRIG_VARS(t), "direction", (char *)dirs[dir], 0);
add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
else
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
ADD_UID_VAR(buf, t, actor, "actor", 0);

View file

@ -29,7 +29,7 @@
/* Thanks to James Long for his assistance in plugging the memory leak that
* used to be here. - Welcor */
/* Adds a variable with given name and value to trigger. */
void add_var(struct trig_var_data **var_list, char *name, char *value, long id)
void add_var(struct trig_var_data **var_list, const char *name, const char *value, long id)
{
struct trig_var_data *vd;
@ -174,11 +174,11 @@ int text_processed(char *field, char *subfield, struct trig_var_data *vd,
snprintf(str, slen, "%s", cdr);
return TRUE;
} else if (!str_cmp(field, "charat")) { /* CharAt */
size_t len = strlen(vd->value), index = atoi(subfield);
if (index > len || index < 1)
size_t len = strlen(vd->value), cindex = atoi(subfield);
if (cindex > len || cindex < 1)
strcpy(str, "");
else
snprintf(str, slen, "%c", vd->value[index - 1]);
snprintf(str, slen, "%c", vd->value[cindex - 1]);
return TRUE;
} else if (!str_cmp(field, "mudcommand")) {
/* find the mud command returned from this text */

View file

@ -483,10 +483,8 @@ WCMD(do_wload)
two_arguments(target, arg1, arg2); /* recycling ... */
tch = get_char_in_room(room, arg1);
if (tch) {
if (arg2 && *arg2 &&
(pos = find_eq_pos_script(arg2)) >= 0 &&
!GET_EQ(tch, pos) &&
can_wear_on_pos(object, pos)) {
if (arg2 != NULL && *arg2 && (pos = find_eq_pos_script(arg2)) >= 0 &&
!GET_EQ(tch, pos) && can_wear_on_pos(object, pos)) {
equip_char(tch, object, pos);
load_otrigger(object);
return;

View file

@ -177,7 +177,7 @@ obj_rnum index_object(struct obj_data *obj, obj_vnum ovnum, obj_rnum ornum)
int save_objects(zone_rnum zone_num)
{
char fname[128], buf[MAX_STRING_LENGTH];
char filename[128], buf[MAX_STRING_LENGTH];
char ebuf1[MAX_STRING_LENGTH], ebuf2[MAX_STRING_LENGTH], ebuf3[MAX_STRING_LENGTH], ebuf4[MAX_STRING_LENGTH];
char wbuf1[MAX_STRING_LENGTH], wbuf2[MAX_STRING_LENGTH], wbuf3[MAX_STRING_LENGTH], wbuf4[MAX_STRING_LENGTH];
char pbuf1[MAX_STRING_LENGTH], pbuf2[MAX_STRING_LENGTH], pbuf3[MAX_STRING_LENGTH], pbuf4[MAX_STRING_LENGTH];
@ -195,9 +195,9 @@ int save_objects(zone_rnum zone_num)
return FALSE;
}
snprintf(fname, sizeof(fname), "%s/%d.new", OBJ_PREFIX, zone_table[zone_num].number);
if (!(fp = fopen(fname, "w+"))) {
mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: OLC: Cannot open objects file %s!", fname);
snprintf(filename, sizeof(filename), "%s/%d.new", OBJ_PREFIX, zone_table[zone_num].number);
if (!(fp = fopen(filename, "w+"))) {
mudlog(BRF, LVL_IMMORT, TRUE, "SYSERR: OLC: Cannot open objects file %s!", filename);
return FALSE;
}
/* Start running through all objects in this zone. */
@ -281,7 +281,7 @@ int save_objects(zone_rnum zone_num)
fclose(fp);
snprintf(buf, sizeof(buf), "%s/%d.obj", OBJ_PREFIX, zone_table[zone_num].number);
remove(buf);
rename(fname, buf);
rename(filename, buf);
if (in_save_list(zone_table[zone_num].number, SL_OBJ))
remove_from_save_list(zone_table[zone_num].number, SL_OBJ);

View file

@ -281,24 +281,24 @@ int sprintascii(char *out, bitvector_t bits)
char *fix_filename(char *str)
{
static char good_file_name[MAX_STRING_LENGTH];
char *index = good_file_name;
char *cindex = good_file_name;
while(*str) {
switch(*str) {
case ' ': *index = '_'; index++; break;
case '(': *index = '{'; index++; break;
case ')': *index = '}'; index++; break;
case ' ': *cindex = '_'; cindex++; break;
case '(': *cindex = '{'; cindex++; break;
case ')': *cindex = '}'; cindex++; break;
/* skip the following */
case '\'': break;
case '"': break;
/* Legal character */
default: *index = *str; index++;break;
default: *cindex = *str; cindex++;break;
}
str++;
}
*index = '\0';
*cindex = '\0';
return good_file_name;
}

View file

@ -367,7 +367,7 @@ ACMD(do_helpcheck)
for (i = 1; *(complete_cmd_info[i].command) != '\n'; i++) {
if (complete_cmd_info[i].command_pointer != do_action && complete_cmd_info[i].minimum_level >= 0) {
if (search_help((char *)(complete_cmd_info[i].command), LVL_IMPL) == NOWHERE) {
if (search_help(complete_cmd_info[i].command, LVL_IMPL) == NOWHERE) {
nlen = snprintf(buf + len, sizeof(buf) - len, "%-20.20s%s", complete_cmd_info[i].command,
(++count % 3 ? "" : "\r\n"));
if (len + nlen >= sizeof(buf))

View file

@ -467,7 +467,7 @@ void command_interpreter(struct char_data *ch, char *argument)
continue;
/* Only apply levenshtein counts if the command is not a trigger command. */
if ( (levenshtein_distance(arg, (char *) cmd_info[cmd].command) <= 2) &&
if ( (levenshtein_distance(arg, cmd_info[cmd].command) <= 2) &&
(cmd_info[cmd].minimum_level >= 0) )
{
if (!found)

View file

@ -247,7 +247,7 @@ ACMD(do_skillset)
{
struct char_data *vict;
char name[MAX_INPUT_LENGTH];
char buf[MAX_INPUT_LENGTH], help[MAX_STRING_LENGTH];
char buf[MAX_INPUT_LENGTH], helpbuf[MAX_STRING_LENGTH];
int skill, value, i, qend;
argument = one_argument(argument, name);
@ -291,9 +291,9 @@ ACMD(do_skillset)
send_to_char(ch, "Skill must be enclosed in: ''\r\n");
return;
}
strcpy(help, (argument + 1)); /* strcpy: OK (MAX_INPUT_LENGTH <= MAX_STRING_LENGTH) */
help[qend - 1] = '\0';
if ((skill = find_skill_num(help)) <= 0) {
strcpy(helpbuf, (argument + 1)); /* strcpy: OK (MAX_INPUT_LENGTH <= MAX_STRING_LENGTH) */
helpbuf[qend - 1] = '\0';
if ((skill = find_skill_num(helpbuf)) <= 0) {
send_to_char(ch, "Unrecognized skill.\r\n");
return;
}

View file

@ -94,7 +94,7 @@ ACMD(do_oasis_links)
skip_spaces(&argument);
one_argument(argument, arg);
if (!arg || !*arg) {
if (!*arg) {
send_to_char(ch,
"Syntax: links <zone_vnum> ('.' for zone you are standing in)\r\n");
return;

View file

@ -282,18 +282,18 @@ int Crash_delete_file(char *name)
int Crash_delete_crashfile(struct char_data *ch)
{
char fname[MAX_INPUT_LENGTH];
char filename[MAX_INPUT_LENGTH];
int numread;
FILE *fl;
int rentcode;
char line[READ_SIZE];
if (!get_filename(fname, sizeof(fname), CRASH_FILE, GET_NAME(ch)))
if (!get_filename(filename, sizeof(filename), CRASH_FILE, GET_NAME(ch)))
return FALSE;
if (!(fl = fopen(fname, "r"))) {
if (!(fl = fopen(filename, "r"))) {
if (errno != ENOENT) /* if it fails, NOT because of no file */
log("SYSERR: checking for crash file %s (3): %s", fname, strerror(errno));
log("SYSERR: checking for crash file %s (3): %s", filename, strerror(errno));
return FALSE;
}
numread = get_line(fl,line);
@ -311,19 +311,19 @@ int Crash_delete_crashfile(struct char_data *ch)
int Crash_clean_file(char *name)
{
char fname[MAX_INPUT_LENGTH], filetype[20];
char filename[MAX_INPUT_LENGTH], filetype[20];
int numread;
FILE *fl;
int rentcode, timed, netcost, gold, account, nitems;
char line[READ_SIZE];
if (!get_filename(fname, sizeof(fname), CRASH_FILE, name))
if (!get_filename(filename, sizeof(filename), CRASH_FILE, name))
return FALSE;
/* Open so that permission problems will be flagged now, at boot time. */
if (!(fl = fopen(fname, "r"))) {
if (!(fl = fopen(filename, "r"))) {
if (errno != ENOENT) /* if it fails, NOT because of no file */
log("SYSERR: OPENING OBJECT FILE %s (4): %s", fname, strerror(errno));
log("SYSERR: OPENING OBJECT FILE %s (4): %s", filename, strerror(errno));
return FALSE;
}
@ -379,18 +379,18 @@ void update_obj_file(void)
void Crash_listrent(struct char_data *ch, char *name)
{
FILE *fl;
char fname[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH], line[READ_SIZE];
char filename[MAX_INPUT_LENGTH], buf[MAX_STRING_LENGTH], line[READ_SIZE];
obj_save_data *loaded, *current;
int rentcode,timed,netcost,gold,account,nitems, numread, len;
if (!get_filename(fname, sizeof(fname), CRASH_FILE, name))
if (!get_filename(filename, sizeof(filename), CRASH_FILE, name))
return;
if (!(fl = fopen(fname, "r"))) {
if (!(fl = fopen(filename, "r"))) {
send_to_char(ch, "%s has no rent file.\r\n", name);
return;
}
len = snprintf(buf, sizeof(buf),"%s\r\n", fname);
len = snprintf(buf, sizeof(buf),"%s\r\n", filename);
numread = get_line(fl, line);
@ -822,51 +822,51 @@ static void Crash_report_rent(struct char_data *ch, struct char_data *recep, str
}
}
static int Crash_offer_rent(struct char_data *ch, struct char_data *receptionist,
static int Crash_offer_rent(struct char_data *ch, struct char_data *recep,
int display, int factor)
{
char buf[MAX_INPUT_LENGTH];
int i;
long totalcost = 0, numitems = 0, norent;
norent = Crash_report_unrentables(ch, receptionist, ch->carrying);
norent = Crash_report_unrentables(ch, recep, ch->carrying);
for (i = 0; i < NUM_WEARS; i++)
norent += Crash_report_unrentables(ch, receptionist, GET_EQ(ch, i));
norent += Crash_report_unrentables(ch, recep, GET_EQ(ch, i));
if (norent)
return FALSE;
totalcost = CONFIG_MIN_RENT_COST * factor;
Crash_report_rent(ch, receptionist, ch->carrying, &totalcost, &numitems, display, factor);
Crash_report_rent(ch, recep, ch->carrying, &totalcost, &numitems, display, factor);
for (i = 0; i < NUM_WEARS; i++)
Crash_report_rent(ch, receptionist, GET_EQ(ch, i), &totalcost, &numitems, display, factor);
Crash_report_rent(ch, recep, GET_EQ(ch, i), &totalcost, &numitems, display, factor);
if (!numitems) {
act("$n tells you, 'But you are not carrying anything! Just quit!'",
FALSE, receptionist, 0, ch, TO_VICT);
FALSE, recep, 0, ch, TO_VICT);
return FALSE;
}
if (numitems > CONFIG_MAX_OBJ_SAVE) {
sprintf(buf, "$n tells you, 'Sorry, but I cannot store more than %d items.'",
CONFIG_MAX_OBJ_SAVE);
act(buf, FALSE, receptionist, 0, ch, TO_VICT);
act(buf, FALSE, recep, 0, ch, TO_VICT);
return FALSE;
}
if (display) {
sprintf(buf, "$n tells you, 'Plus, my %d coin fee..'",
CONFIG_MIN_RENT_COST * factor);
act(buf, FALSE, receptionist, 0, ch, TO_VICT);
act(buf, FALSE, recep, 0, ch, TO_VICT);
sprintf(buf, "$n tells you, 'For a total of %ld coins%s.'",
totalcost, (factor == RENT_FACTOR ? " per day" : ""));
act(buf, FALSE, receptionist, 0, ch, TO_VICT);
act(buf, FALSE, recep, 0, ch, TO_VICT);
if (totalcost > GET_GOLD(ch) + GET_BANK_GOLD(ch)) {
act("$n tells you, '...which I see you can't afford.'",
FALSE, receptionist, 0, ch, TO_VICT);
FALSE, recep, 0, ch, TO_VICT);
return FALSE;
} else if (factor == RENT_FACTOR)
Crash_rent_deadline(ch, receptionist, totalcost);
Crash_rent_deadline(ch, recep, totalcost);
}
return (totalcost);
}
@ -979,7 +979,7 @@ void Crash_save_all(void)
* handled by house code, listrent code, autoeq code, etc. */
obj_save_data *objsave_parse_objects(FILE *fl)
{
obj_save_data *head, *current;
obj_save_data *head, *current, *tempsave;
char f1[128], f2[128], f3[128], f4[128], line[READ_SIZE];
int t[4],i, nr;
struct obj_data *temp;
@ -997,16 +997,15 @@ obj_save_data *objsave_parse_objects(FILE *fl)
if(get_line(fl, line) == FALSE || (*line == '$' && line[1] == '~')) {
if (temp == NULL && current->obj == NULL) {
/* Remove current from list. */
obj_save_data *t = head;
if (t == current) {
tempsave = head;
if (tempsave == current) {
free(current);
head = NULL;
} else {
while (t) {
if (t->next == current)
t->next = NULL;
t = t->next;
}
while (tempsave) {
if (tempsave->next == current)
tempsave->next = NULL;
tempsave = tempsave->next; }
free(current);
}
}
@ -1162,23 +1161,23 @@ obj_save_data *objsave_parse_objects(FILE *fl)
static int Crash_load_objs(struct char_data *ch) {
FILE *fl;
char fname[MAX_STRING_LENGTH];
char filename[MAX_STRING_LENGTH];
char line[READ_SIZE];
int i, num_of_days, orig_rent_code, cost, num_objs=0;
struct obj_data *cont_row[MAX_BAG_ROWS];
int rentcode,timed,netcost,gold,account,nitems;
obj_save_data *loaded, *current;
if (!get_filename(fname, sizeof(fname), CRASH_FILE, GET_NAME(ch)))
if (!get_filename(filename, sizeof(filename), CRASH_FILE, GET_NAME(ch)))
return 1;
for (i = 0; i < MAX_BAG_ROWS; i++)
cont_row[i] = NULL;
if (!(fl = fopen(fname, "r"))) {
if (!(fl = fopen(filename, "r"))) {
if (errno != ENOENT) { /* if it fails, NOT because of no file */
char buf[MAX_STRING_LENGTH];
sprintf(buf, "SYSERR: READING OBJECT FILE %s (5)", fname);
sprintf(buf, "SYSERR: READING OBJECT FILE %s (5)", filename);
perror(buf);
send_to_char(ch, "\r\n********************* NOTICE *********************\r\n"
"There was a problem loading your objects from disk.\r\n"

View file

@ -200,17 +200,17 @@ int load_char(const char *name, struct char_data *ch)
{
int id, i;
FILE *fl;
char fname[40];
char filename[40];
char buf[128], buf2[128], line[MAX_INPUT_LENGTH + 1], tag[6];
char f1[128], f2[128], f3[128], f4[128];
if ((id = get_ptable_by_name(name)) < 0)
return (-1);
else {
if (!get_filename(fname, sizeof(fname), PLR_FILE, player_table[id].name))
if (!get_filename(filename, sizeof(filename), PLR_FILE, player_table[id].name))
return (-1);
if (!(fl = fopen(fname, "r"))) {
mudlog(NRM, LVL_GOD, TRUE, "SYSERR: Couldn't open player file %s", fname);
if (!(fl = fopen(filename, "r"))) {
mudlog(NRM, LVL_GOD, TRUE, "SYSERR: Couldn't open player file %s", filename);
return (-1);
}
@ -449,7 +449,7 @@ int load_char(const char *name, struct char_data *ch)
void save_char(struct char_data * ch)
{
FILE *fl;
char fname[40], buf[MAX_STRING_LENGTH], bits[127], bits2[127], bits3[127], bits4[127];
char filename[40], buf[MAX_STRING_LENGTH], bits[127], bits2[127], bits3[127], bits4[127];
int i, id, save_index = FALSE;
struct affected_type *aff, tmp_aff[MAX_AFFECT];
struct obj_data *char_eq[NUM_WEARS];
@ -475,10 +475,10 @@ void save_char(struct char_data * ch)
}
}
if (!get_filename(fname, sizeof(fname), PLR_FILE, GET_NAME(ch)))
if (!get_filename(filename, sizeof(filename), PLR_FILE, GET_NAME(ch)))
return;
if (!(fl = fopen(fname, "w"))) {
mudlog(NRM, LVL_GOD, TRUE, "SYSERR: Couldn't open player file %s for write", fname);
if (!(fl = fopen(filename, "w"))) {
mudlog(NRM, LVL_GOD, TRUE, "SYSERR: Couldn't open player file %s for write", filename);
return;
}
@ -716,7 +716,7 @@ void tag_argument(char *argument, char *tag)
* deleted by an immortal, or deleted by the auto-wipe system (if enabled). */
void remove_player(int pfilepos)
{
char fname[40];
char filename[MAX_STRING_LENGTH];
int i;
if (!*player_table[pfilepos].name)
@ -727,8 +727,8 @@ void remove_player(int pfilepos)
/* Unlink all player-owned files */
for (i = 0; i < MAX_FILES; i++) {
if (get_filename(fname, sizeof(fname), i, player_table[pfilepos].name))
unlink(fname);
if (get_filename(filename, sizeof(filename), i, player_table[pfilepos].name))
unlink(filename);
}
log("PCLEAN: %s Lev: %d Last: %s",
@ -895,7 +895,7 @@ static void read_aliases_ascii(FILE *file, struct char_data *ch, int count)
/* read the type */
get_line(file, tbuf);
if (abuf && *abuf && tbuf && *tbuf && rbuf && *rbuf) {
if (*abuf && *tbuf && *rbuf) {
CREATE(temp, struct alias_data, 1);
temp->alias = strdup(abuf);
temp->replacement = strdup(rbuf);

View file

@ -1547,20 +1547,20 @@ void destroy_shops(void)
static int find_shop(int vnum)
{
int bot, mid, top;
int bot, mid, ltop;
bot = 0;
top= top_shop - 1;
ltop= top_shop - 1;
while (bot <= top) {
mid = (top + bot) / 2;
while (bot <= ltop) {
mid = (ltop + bot) / 2;
if (shop_index[mid].vnum == vnum)
return mid;
else if (shop_index[mid].vnum < vnum)
bot = mid + 1;
else
top = mid - 1;
ltop = mid - 1;
}
return -1;
}

View file

@ -847,10 +847,10 @@ int room_is_dark(room_rnum room)
* @param s1 The input string.
* @param s2 The string to be compared to.
* @retval int The Levenshtein distance between s1 and s2. */
int levenshtein_distance(char *s1, char *s2)
int levenshtein_distance(const char *s1, const char *s2)
{
int s1_len = strlen(s1), s2_len = strlen(s2);
int **d, i, j;
int s1_len = strlen(s1), s2_len = strlen(s2);
CREATE(d, int *, s1_len + 1);
@ -934,8 +934,7 @@ void char_from_furniture(struct char_data *ch)
/* Helper function for column_list. */
void process_column_list_format(char **out_buffer, const char *format,
int buf_left, int index,
const char *item)
int buf_left, int index_data, const char *item)
{
/* Initialize the index format with a % */
char index_format[80] = {'%'};
@ -968,7 +967,7 @@ void process_column_list_format(char **out_buffer, const char *format,
* we already constructed above.
*/
else if (*format == 'i')
*out_buffer += sprintf(*out_buffer, index_format, index);
*out_buffer += sprintf(*out_buffer, index_format, index_data);
/*
* Or output the current list item. Use part of the

View file

@ -54,7 +54,7 @@ int num_pc_in_room(struct room_data *room);
void core_dump_real(const char *who, int line);
int count_color_chars(char *string);
int room_is_dark(room_rnum room);
int levenshtein_distance(char *s1, char *s2);
int levenshtein_distance(const char *s1, const char *s2);
struct time_info_data *real_time_passed(time_t t2, time_t t1);
struct time_info_data *mud_time_passed(time_t t2, time_t t1);
void prune_crlf(char *txt);

View file

@ -20,7 +20,7 @@
#include <ctype.h>
#define NUM_ZBUCKETS 256
#define GET_ZBUCKET(addr) (((int)(addr) >> 3) & 0xFF)
#define GET_ZBUCKET(addr) (((long)(addr) >> 3) & 0xFF)
//#define NO_MEMORY_PADDING
@ -131,7 +131,7 @@ unsigned char *zmalloc(int len, char *file, int line)
#endif
if (zmalloclogging > 2)
fprintf(zfd,"zmalloc: 0x%4.4x %d bytes %s:%d\n",(int)ret,len,file,line);
fprintf(zfd,"zmalloc: 0x%p %d bytes %s:%d\n", ret, len, file, line);
m = (meminfo *) calloc(1, sizeof(meminfo));
if (!m) {
@ -167,9 +167,9 @@ unsigned char *zrealloc(unsigned char *what, int len, char *file, int line)
ret = (unsigned char *) realloc(what, len);
#endif
if (!ret) {
fprintf(zfd,"zrealloc: FAILED for 0x%4.4x %d bytes mallocd at %s:%d,\n"
fprintf(zfd,"zrealloc: FAILED for 0x%p %d bytes mallocd at %s:%d,\n"
" %d bytes reallocd at %s:%d.\n",
(int)m->addr, m->size, m->file, m->line, len, file, line);
m->addr, m->size, m->file, m->line, len, file, line);
if (zmalloclogging > 1) zdump(m);
return NULL;
}
@ -180,8 +180,8 @@ unsigned char *zrealloc(unsigned char *what, int len, char *file, int line)
memcpy(ret + len, endPad, sizeof(endPad));
#endif
if (zmalloclogging > 2)
fprintf(zfd,"zrealloc: 0x%4.4x %d bytes mallocd at %s:%d, %d bytes reallocd at %s:%d.\n",
(int)m->addr, m->size, m->file, m->line, len, file, line);
fprintf(zfd,"zrealloc: 0x%p %d bytes mallocd at %s:%d, %d bytes reallocd at %s:%d.\n",
m->addr, m->size, m->file, m->line, len, file, line);
m->addr = ret;
m->size = len;
@ -207,8 +207,8 @@ unsigned char *zrealloc(unsigned char *what, int len, char *file, int line)
}
/* NULL or invalid pointer given */
fprintf(zfd,"zrealloc: invalid pointer 0x%4.4x, %d bytes to realloc at %s:%d.\n",
(int)what, len, file, line);
fprintf(zfd,"zrealloc: invalid pointer 0x%p, %d bytes to realloc at %s:%d.\n",
what, len, file, line);
return (zmalloc(len, file, line));
}
@ -229,8 +229,8 @@ void zfree(unsigned char *what, char *file, int line)
if (m->addr == what) {
/* got it. Print it if verbose: */
if (zmalloclogging > 2) {
fprintf(zfd,"zfree: Freed 0x%4.4x %d bytes mallocd at %s:%d, freed at %s:%d\n",
(int)m->addr, m->size, m->file, m->line, file, line);
fprintf(zfd,"zfree: Freed 0x%p %d bytes mallocd at %s:%d, freed at %s:%d\n",
m->addr, m->size, m->file, m->line, file, line);
}
/* check the padding: */
pad_check(m);
@ -240,9 +240,9 @@ void zfree(unsigned char *what, char *file, int line)
/* check to see if it was freed > once */
if (m->frees > 1) {
fprintf(zfd,"zfree: ERR: multiple frees! 0x%4.4x %d bytes\n"
fprintf(zfd,"zfree: ERR: multiple frees! 0x%p %d bytes\n"
" mallocd at %s:%d, freed at %s:%d.\n",
(int)m->addr, m->size, m->file, m->line, file, line);
m->addr, m->size, m->file, m->line, file, line);
if (zmalloclogging > 1) zdump(m);
}
gotit++;
@ -250,12 +250,12 @@ void zfree(unsigned char *what, char *file, int line)
} /* for.. */
if (!gotit) {
fprintf(zfd,"zfree: ERR: attempt to free unallocated memory 0x%4.4x at %s:%d.\n",
(int)what, file, line);
fprintf(zfd,"zfree: ERR: attempt to free unallocated memory 0x%p at %s:%d.\n",
what, file, line);
}
if (gotit > 1) {
/* this shouldn't happen, eh? */
fprintf(zfd,"zfree: ERR: Multiply-allocd memory 0x%4.4x.\n", (int)what);
fprintf(zfd,"zfree: ERR: Multiply-allocd memory 0x%p.\n", what);
}
}
@ -291,8 +291,8 @@ void zmalloc_check()
for (m = memlist[i]; m; m = next_m) {
next_m = m->next;
if (m->addr != 0 && m->frees <= 0) {
fprintf(zfd,"zmalloc: UNfreed memory 0x%4.4x %d bytes mallocd at %s:%d\n",
(int)m->addr, m->size, m->file, m->line);
fprintf(zfd,"zmalloc: UNfreed memory 0x%p %d bytes mallocd at %s:%d\n",
m->addr, m->size, m->file, m->line);
if (zmalloclogging > 1) zdump(m);
/* check padding on un-freed memory too: */