Fixed several warnings and a little cleanup.

This commit is contained in:
Rumble 2013-10-20 19:01:57 -05:00
parent 5986794156
commit 55253bdf61
6 changed files with 17 additions and 31 deletions

View file

@ -4263,10 +4263,10 @@ ACMD(do_file)
FILE *req_file; /* Pointer to file to be read. */ FILE *req_file; /* Pointer to file to be read. */
size_t req_file_size = 0; /* Size of file to be read. */ size_t req_file_size = 0; /* Size of file to be read. */
int req_file_lines = 0; /* Number of total lines in file to be read. */ int req_file_lines = 0; /* Number of total lines in file to be read. */
int lines_read = 0; /* Counts total number of lines read from the file. */ int lines_read = 0; /* Counts total number of lines read from the file. */
int req_lines = 0; /* Number of lines requested to be displayed. */ int req_lines = 0; /* Number of lines requested to be displayed. */
int i, j; /* Generic loop counters. */ int i, j; /* Generic loop counters. */
int l; /* Marks choice of file in fields array. */ int l; /* Marks choice of file in fields array. */
char field[MAX_INPUT_LENGTH]; /* Holds users choice of file to be read. */ char field[MAX_INPUT_LENGTH]; /* Holds users choice of file to be read. */
char value[MAX_INPUT_LENGTH]; /* Holds # lines to be read, if requested. */ char value[MAX_INPUT_LENGTH]; /* Holds # lines to be read, if requested. */
char buf[MAX_STRING_LENGTH]; /* Display buffer for req_file. */ char buf[MAX_STRING_LENGTH]; /* Display buffer for req_file. */
@ -4357,9 +4357,7 @@ ACMD(do_file)
/* Must be able to access the file on disk. */ /* Must be able to access the file on disk. */
if (!(req_file=fopen(fields[l].file,"r"))) { if (!(req_file=fopen(fields[l].file,"r"))) {
send_to_char(ch, "The file %s can not be opened.\r\n", fields[l].file); send_to_char(ch, "The file %s can not be opened.\r\n", fields[l].file);
mudlog(BRF, LVL_IMPL, TRUE, mudlog(BRF, LVL_IMPL, TRUE, "SYSERR: Error opening file %s using 'file' command.", fields[l].file);
"SYSERR: Error opening file %s using 'file' command.",
fields[l].file);
return; return;
} }
/**/ /**/
@ -4389,7 +4387,7 @@ ACMD(do_file)
lines_read = file_head( req_file, buf, sizeof(buf), req_lines ); lines_read = file_head( req_file, buf, sizeof(buf), req_lines );
} }
/** Since file_head and file_tail will add the overflow message, we /* Since file_head and file_tail will add the overflow message, we
* don't check for status here. */ * don't check for status here. */
if ( lines_read == req_file_lines ) if ( lines_read == req_file_lines )
{ {
@ -4580,7 +4578,7 @@ ACMD(do_wizupdate)
bool change_player_name(struct char_data *ch, struct char_data *vict, char *new_name) bool change_player_name(struct char_data *ch, struct char_data *vict, char *new_name)
{ {
struct char_data *temp_ch=NULL; struct char_data *temp_ch=NULL;
int plr_i = 0, i, j, k; int plr_i = 0, i, k;
char old_name[MAX_NAME_LENGTH], old_pfile[50], new_pfile[50], buf[MAX_STRING_LENGTH]; char old_name[MAX_NAME_LENGTH], old_pfile[50], new_pfile[50], buf[MAX_STRING_LENGTH];
if (!ch) if (!ch)
@ -4603,7 +4601,7 @@ bool change_player_name(struct char_data *ch, struct char_data *vict, char *new_
return FALSE; return FALSE;
} }
// Check that someone with new_name isn't already logged in /* Check that someone with new_name isn't already logged in */
if ((temp_ch = get_player_vis(ch, new_name, NULL, FIND_CHAR_WORLD)) != NULL) { if ((temp_ch = get_player_vis(ch, new_name, NULL, FIND_CHAR_WORLD)) != NULL) {
send_to_char(ch, "Sorry, the new name already exists.\r\n"); send_to_char(ch, "Sorry, the new name already exists.\r\n");
return FALSE; return FALSE;
@ -4655,7 +4653,6 @@ bool change_player_name(struct char_data *ch, struct char_data *vict, char *new_
/* Rename the player's pfile */ /* Rename the player's pfile */
sprintf(buf, "mv %s %s", old_pfile, new_pfile); sprintf(buf, "mv %s %s", old_pfile, new_pfile);
j = system(buf);
/* Save the changed player index - the pfile is saved by perform_set */ /* Save the changed player index - the pfile is saved by perform_set */
save_player_index(); save_player_index();

View file

@ -172,8 +172,9 @@ char *fread_action(FILE *fl, int nr)
parse_at(buf); parse_at(buf);
/* Some clients interpret '\r' the same as { '\r' '\n' }, so the original way of just /* Some clients interpret '\r' the same as { '\r' '\n' }, so the original way
replacing '\n' with '\0' would appear as 2 new lines following the action */ * of just replacing '\n' with '\0' would appear as 2 new lines following the
* action */
for (i = 0; buf[i] != '\0'; i++) for (i = 0; buf[i] != '\0'; i++)
if (buf[i] == '\r' || buf[i] == '\n') { if (buf[i] == '\r' || buf[i] == '\n') {
buf[i] = '\0'; buf[i] = '\0';

View file

@ -310,12 +310,10 @@ ACMD(do_export_zone)
zone_vnum zvnum; zone_vnum zvnum;
char sysbuf[MAX_INPUT_LENGTH]; char sysbuf[MAX_INPUT_LENGTH];
char zone_name[MAX_INPUT_LENGTH], *f; char zone_name[MAX_INPUT_LENGTH], *f;
int success, i; int success;
/* system command locations are relative to /* system command locations are relative to where the binary IS, not where it
* where the binary IS, not where it was run * was run from, thus we act like we are in the bin folder, because we are*/
* from, thus we act like we are in the bin
* folder, because we are*/
char *path = "../lib/world/export/"; char *path = "../lib/world/export/";
if (IS_NPC(ch) || GET_LEVEL(ch) < LVL_IMPL) if (IS_NPC(ch) || GET_LEVEL(ch) < LVL_IMPL)
@ -335,12 +333,10 @@ ACMD(do_export_zone)
return; return;
} }
/* If we fail, it might just be because the /* If we fail, it might just be because the directory didn't exist. Can't
* directory didn't exist. Can't hurt to try * hurt to try again. Do it silently though ( no logs ). */
* again. Do it silently though ( no logs ). */
if (!export_info_file(zrnum)) { if (!export_info_file(zrnum)) {
sprintf(sysbuf, "mkdir %s", path); sprintf(sysbuf, "mkdir %s", path);
i = system(sysbuf);
} }
if (!(success = export_info_file(zrnum))) if (!(success = export_info_file(zrnum)))
@ -371,15 +367,12 @@ ACMD(do_export_zone)
/* Remove the old copy. */ /* Remove the old copy. */
sprintf(sysbuf, "rm %s%s.tar.gz", path, f); sprintf(sysbuf, "rm %s%s.tar.gz", path, f);
i = system(sysbuf);
/* Tar the new copy. */ /* Tar the new copy. */
sprintf(sysbuf, "tar -cf %s%s.tar %sqq.info %sqq.wld %sqq.zon %sqq.mob %sqq.obj %sqq.trg %sqq.shp", path, f, path, path, path, path, path, path, path); sprintf(sysbuf, "tar -cf %s%s.tar %sqq.info %sqq.wld %sqq.zon %sqq.mob %sqq.obj %sqq.trg %sqq.shp", path, f, path, path, path, path, path, path, path);
i = system(sysbuf);
/* Gzip it. */ /* Gzip it. */
sprintf(sysbuf, "gzip %s%s.tar", path, f); sprintf(sysbuf, "gzip %s%s.tar", path, f);
i = system(sysbuf);
send_to_char(ch, "Files tar'ed to \"%s%s.tar.gz\"\r\n", path, f); send_to_char(ch, "Files tar'ed to \"%s%s.tar.gz\"\r\n", path, f);
} }

View file

@ -198,7 +198,6 @@ void run_autowiz(void)
if (CONFIG_USE_AUTOWIZ) { if (CONFIG_USE_AUTOWIZ) {
size_t res; size_t res;
char buf[256]; char buf[256];
int i;
#if defined(CIRCLE_UNIX) #if defined(CIRCLE_UNIX)
res = snprintf(buf, sizeof(buf), "nice ../bin/autowiz %d %s %d %s %d &", res = snprintf(buf, sizeof(buf), "nice ../bin/autowiz %d %s %d %s %d &",
@ -211,7 +210,6 @@ void run_autowiz(void)
/* Abusing signed -> unsigned conversion to avoid '-1' check. */ /* Abusing signed -> unsigned conversion to avoid '-1' check. */
if (res < sizeof(buf)) { if (res < sizeof(buf)) {
mudlog(CMP, LVL_IMMORT, FALSE, "Initiating autowiz."); mudlog(CMP, LVL_IMMORT, FALSE, "Initiating autowiz.");
i = system(buf);
reboot_wizlists(); reboot_wizlists();
} else } else
log("Cannot run autowiz: command-line doesn't fit in buffer."); log("Cannot run autowiz: command-line doesn't fit in buffer.");

View file

@ -354,10 +354,8 @@ static void sedit_no_trade_menu(struct descriptor_data *d)
static void sedit_types_menu(struct descriptor_data *d) static void sedit_types_menu(struct descriptor_data *d)
{ {
struct shop_data *shop;
int i, count = 0; int i, count = 0;
shop = OLC_SHOP(d);
get_char_colors(d->character); get_char_colors(d->character);
clear_screen(d); clear_screen(d);

View file

@ -412,13 +412,12 @@ bool zedit_get_levels(struct descriptor_data *d, char *buf)
/* the main menu */ /* the main menu */
static void zedit_disp_menu(struct descriptor_data *d) static void zedit_disp_menu(struct descriptor_data *d)
{ {
int subcmd = 0, room, counter = 0; int subcmd = 0, counter = 0;
char buf1[MAX_STRING_LENGTH], lev_string[50]; char buf1[MAX_STRING_LENGTH], lev_string[50];
bool levels_set = FALSE; bool levels_set = FALSE;
get_char_colors(d->character); get_char_colors(d->character);
clear_screen(d); clear_screen(d);
room = real_room(OLC_NUM(d));
sprintbitarray(OLC_ZONE(d)->zone_flags, zone_bits, ZN_ARRAY_MAX, buf1); sprintbitarray(OLC_ZONE(d)->zone_flags, zone_bits, ZN_ARRAY_MAX, buf1);
levels_set = zedit_get_levels(d, lev_string); levels_set = zedit_get_levels(d, lev_string);