Fix more warnings and some style.

This commit is contained in:
Zach Langley 2014-11-07 21:19:32 -08:00
parent 4e27091e57
commit 0ded4cf7e2
6 changed files with 48 additions and 45 deletions

View file

@ -219,7 +219,7 @@ static void House_save_control(void)
return;
}
/* write all the house control recs in one fell swoop. Pretty nifty, eh? */
if (fwrite(house_control, sizeof(struct house_control_rec), num_of_houses, fl) != num_of_houses) {
if (fwrite(house_control, sizeof(struct house_control_rec), num_of_houses, fl) != (size_t)num_of_houses) {
perror("SYSERR: Unable to save house control file.");
return;
}

View file

@ -1282,7 +1282,7 @@ EVENTFUNC(get_protocols)
struct descriptor_data *d;
struct mud_event_data *pMudEvent;
char buf[MAX_STRING_LENGTH];
int len;
size_t len;
if (event_obj == NULL)
return 0;

View file

@ -133,7 +133,7 @@ static void show_messages(struct char_data *ch)
{
int i, half = MAX_MESSAGES / 2, count = 0;
char buf[MAX_STRING_LENGTH];
int len;
size_t len;
len = snprintf(buf, sizeof(buf), "\t1Message List:\tn \r\n");

View file

@ -231,13 +231,13 @@ void clear_char_event_list(struct char_data * ch)
}
/* change_event_duration contributed by Ripley */
void change_event_duration(struct char_data * ch, event_id iId, long time) {
void change_event_duration(struct char_data * ch, event_id iId, long time)
{
struct event * pEvent;
struct mud_event_data * pMudEvent;
bool found = FALSE;
if (ch->events == NULL);
if (ch->events == NULL)
return;
if (ch->events->iSize == 0)
@ -246,7 +246,6 @@ void change_event_duration(struct char_data * ch, event_id iId, long time) {
clear_simple_list();
while ((pEvent = (struct event *) simple_list(ch->events)) != NULL) {
if (!pEvent->isMudEvent)
continue;

View file

@ -41,7 +41,8 @@ static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zon
void perform_mob_flag_list(struct char_data * ch, char *arg)
{
int num, mob_flag, found = 0, len;
int num, mob_flag, found = 0;
size_t len;
struct char_data *mob;
char buf[MAX_STRING_LENGTH];
@ -77,7 +78,8 @@ void perform_mob_flag_list(struct char_data * ch, char *arg)
void perform_mob_level_list(struct char_data * ch, char *arg)
{
int num, mob_level, found = 0, len;
int num, mob_level, found = 0;
size_t len;
struct char_data *mob;
char buf[MAX_STRING_LENGTH];
@ -91,7 +93,6 @@ void perform_mob_level_list(struct char_data * ch, char *arg)
len = snprintf(buf, sizeof(buf), "Listing mobiles of level %s%d%s\r\n", QYEL, mob_level, QNRM);
for (num = 0; num <= top_of_mobt; num++) {
if ((mob_proto[num].player.level) == mob_level) {
if ((mob = read_mobile(num, REAL)) != NULL) {
char_to_room(mob, 0);
len += snprintf(buf + len, sizeof(buf) - len, "%s%3d. %s[%s%5d%s]%s %s%s\r\n", CCNRM(ch, C_NRM),++found,
@ -132,7 +133,8 @@ void add_to_obj_list(struct obj_list_item *lst, int num_items, obj_vnum nvo, int
void perform_obj_type_list(struct char_data * ch, char *arg)
{
int num, itemtype, v1, v2, found = 0, len = 0, tmp_len = 0;
int num, itemtype, v1, v2, found = 0;
size_t len = 0, tmp_len = 0;
obj_vnum ov;
obj_rnum r_num;
char buf[MAX_STRING_LENGTH];
@ -246,7 +248,8 @@ void perform_obj_type_list(struct char_data * ch, char *arg)
void perform_obj_aff_list(struct char_data * ch, char *arg)
{
int num, i, apply, v1 = 0, found = 0, len = 0, tmp_len = 0;
int num, i, apply, v1 = 0, found = 0;
size_t len = 0, tmp_len = 0;
struct obj_list_item lst[MAX_OBJ_LIST];
obj_rnum r_num;
obj_vnum ov;
@ -258,7 +261,7 @@ void perform_obj_aff_list(struct char_data * ch, char *arg)
}
apply = atoi(arg);
if (!(apply>0 && apply<NUM_APPLIES) ){
if (apply <= 0 || apply >= NUM_APPLIES) {
send_to_char(ch, "Not a valid affect");
return;
} /* Special cases below */
@ -330,7 +333,8 @@ void perform_obj_aff_list(struct char_data * ch, char *arg)
void perform_obj_name_list(struct char_data * ch, char *arg)
{
int num, found = 0, len = 0, tmp_len = 0;
int num, found = 0;
size_t len = 0, tmp_len = 0;
obj_vnum ov;
char buf[MAX_STRING_LENGTH];
@ -393,7 +397,6 @@ ACMD(do_oasis_list)
switch (subcmd) {
case SCMD_OASIS_MLIST:
two_arguments(argument, arg, arg2);
if (is_abbrev(arg, "help")) {
@ -409,8 +412,7 @@ ACMD(do_oasis_list)
if (!*arg2) {
send_to_char(ch, "Which mobile flag or level do you want to list?\r\n");
for (i=0; i<NUM_MOB_FLAGS; i++)
{
for (i = 0; i < NUM_MOB_FLAGS; i++) {
send_to_char(ch, "%s%2d%s-%s%-14s%s", CCNRM(ch, C_NRM), i, CCNRM(ch, C_NRM), CCYEL(ch, C_NRM), action_bits[i], CCNRM(ch, C_NRM));
if (!((i+1)%4)) send_to_char(ch, "\r\n");
}
@ -439,8 +441,7 @@ ACMD(do_oasis_list)
send_to_char(ch, " %solist affect <num>%s - List top %d objects with affect\r\n", QYEL, QNRM, MAX_OBJ_LIST);
send_to_char(ch, "Just type %solist affect%s or %solist type%s to view available options\r\n", QYEL, QNRM, QYEL, QNRM);
return;
}
else if (is_abbrev(arg, "type") || is_abbrev(arg, "affect")) {
} else if (is_abbrev(arg, "type") || is_abbrev(arg, "affect")) {
if (is_abbrev(arg, "type")) {
if (!*arg2) {
send_to_char(ch, "Which object type do you want to list?\r\n");
@ -459,8 +460,7 @@ ACMD(do_oasis_list)
} else { /* Assume arg = affect */
if (!*arg2) {
send_to_char(ch, "Which object affect do you want to list?\r\n");
for (i=0; i<NUM_APPLIES; i++)
{
for (i = 0; i < NUM_APPLIES; i++) {
if (i == APPLY_CLASS) /* Special Case 1 - Weapon Dam */
send_to_char(ch, "%s%2d-%s%-14s%s", QNRM, i, QYEL, "Weapon Dam", QNRM);
else if (i == APPLY_LEVEL) /* Special Case 2 - Armor AC Apply */
@ -558,7 +558,8 @@ static void list_rooms(struct char_data *ch, zone_rnum rnum, room_vnum vmin, roo
{
room_rnum i;
room_vnum bottom, top;
int j, counter = 0, len;
int j, counter = 0;
size_t len;
char buf[MAX_STRING_LENGTH];
/* Expect a minimum / maximum number if the rnum for the zone is NOWHERE. */
@ -619,7 +620,8 @@ static void list_mobiles(struct char_data *ch, zone_rnum rnum, mob_vnum vmin, mo
{
mob_rnum i;
mob_vnum bottom, top;
int counter = 0, len;
int counter = 0;
size_t len;
char buf[MAX_STRING_LENGTH];
if (rnum != NOWHERE) {
@ -666,7 +668,7 @@ static void list_objects(struct char_data *ch, zone_rnum rnum, obj_vnum vmin, ob
obj_vnum bottom, top;
char buf[MAX_STRING_LENGTH];
int counter = 0;
int len;
size_t len;
if (rnum != NOWHERE) {
bottom = zone_table[rnum].bot;
@ -694,6 +696,7 @@ static void list_objects(struct char_data *ch, zone_rnum rnum, obj_vnum vmin, ob
item_types[obj_proto[i].obj_flags.type_flag], QNRM,
obj_proto[i].proto_script ? " [TRIG]" : ""
);
if (len > sizeof(buf))
break;
}
@ -752,7 +755,8 @@ static void list_shops(struct char_data *ch, zone_rnum rnum, shop_vnum vmin, sho
/* List all zones in the world (sort of like 'show zones'). */
static void list_zones(struct char_data *ch, zone_rnum rnum, zone_vnum vmin, zone_vnum vmax, char *name)
{
int counter = 0, len=0, tmp_len = 0;
int counter = 0;
size_t len = 0, tmp_len = 0;
zone_rnum i;
zone_vnum bottom, top;
char buf[MAX_STRING_LENGTH];

View file

@ -983,8 +983,8 @@ void char_from_furniture(struct char_data *ch)
*/
void column_list(struct char_data *ch, int num_cols, const char **list, int list_length, bool show_nums)
{
size_t max_len = 0;
int num_per_col, col_width,r,c,i, offset=0, len=0, temp_len;
size_t max_len = 0, len = 0, temp_len;
int num_per_col, col_width, r, c, i, offset = 0;
char buf[MAX_STRING_LENGTH];
/* Work out the longest list item */