Reformat all C files.

I'll push a formatting guide at some point. There may still be
outstanding changes, but please feel free to resolve those as you arrive
a them.

To the best of my knowledge, there is no changes to the actual code
content, but the formatter does have the occasional bug. If you run into
an issue, please fix it!
This commit is contained in:
Sean Hunt
2015-05-09 13:43:16 -04:00
parent 167800afdf
commit 97d6fade74
270 changed files with 182649 additions and 173878 deletions
+79 -81
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 thintile.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 thintile.c $NHDT-Date: 1431192771 2015/05/09 17:32:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.8 $ */
/* NetHack 3.6 thintile.c $Date: 2012/01/10 17:47:40 $ $Revision: 1.5 $ */
/* Copyright (c) NetHack Development Team 1995 */
/* NetHack may be freely redistributed. See license for details. */
@@ -14,13 +14,13 @@
static char pixels[TILE_Y][TILE_X];
static char *tilefiles[] = { "../win/share/monsters.txt",
"../win/share/objects.txt",
"../win/share/other.txt"};
static char *tilefiles[] = { "../win/share/monsters.txt",
"../win/share/objects.txt",
"../win/share/other.txt" };
static char *thinfiles[] = { "../win/share/monthin.txt",
"../win/share/objthin.txt",
"../win/share/oththin.txt"};
static char *thinfiles[] = { "../win/share/monthin.txt",
"../win/share/objthin.txt",
"../win/share/oththin.txt" };
static FILE *infile, *outfile;
static int tilecount;
static int tilecount_per_file;
@@ -30,101 +30,99 @@ static char comment[BUFSZ];
static void
copy_colormap()
{
int r, g, b;
char c[2];
int r, g, b;
char c[2];
while (fscanf(infile, "%[A-Za-z0-9] = (%d, %d, %d) ", c, &r, &g, &b)
== 4) {
Fprintf(outfile, "%c = (%d, %d, %d)\n", c[0], r, g, b);
}
while (fscanf(infile, "%[A-Za-z0-9] = (%d, %d, %d) ", c, &r, &g, &b)
== 4) {
Fprintf(outfile, "%c = (%d, %d, %d)\n", c[0], r, g, b);
}
}
static boolean
read_txttile()
{
int i, j;
char buf[BUFSZ];
char buf2[BUFSZ];
int i, j;
char buf[BUFSZ];
char buf2[BUFSZ];
char c[2];
char c[2];
if (fscanf(infile, "# %s %d (%[^)])", buf2, &i, buf) <= 0)
return FALSE;
if (fscanf(infile, "# %s %d (%[^)])", buf2, &i, buf) <= 0)
return FALSE;
Sprintf(comment,"# tile %d (%s)", i, buf);
/* look for non-whitespace at each stage */
if (fscanf(infile, "%1s", c) < 0) {
Fprintf(stderr, "unexpected EOF\n");
return FALSE;
}
if (c[0] != '{') {
Fprintf(stderr, "didn't find expected '{'\n");
return FALSE;
}
for (j = 0; j < TILE_Y; j++) {
for (i = 0; i < TILE_X; i++) {
if (fscanf(infile, "%1s", c) < 0) {
Fprintf(stderr, "unexpected EOF\n");
return FALSE;
}
pixels[j][i] = c[0];
}
}
if (fscanf(infile, "%1s ", c) < 0) {
Fprintf(stderr, "unexpected EOF\n");
return FALSE;
}
if (c[0] != '}') {
Fprintf(stderr, "didn't find expected '}'\n");
return FALSE;
}
return TRUE;
Sprintf(comment, "# tile %d (%s)", i, buf);
/* look for non-whitespace at each stage */
if (fscanf(infile, "%1s", c) < 0) {
Fprintf(stderr, "unexpected EOF\n");
return FALSE;
}
if (c[0] != '{') {
Fprintf(stderr, "didn't find expected '{'\n");
return FALSE;
}
for (j = 0; j < TILE_Y; j++) {
for (i = 0; i < TILE_X; i++) {
if (fscanf(infile, "%1s", c) < 0) {
Fprintf(stderr, "unexpected EOF\n");
return FALSE;
}
pixels[j][i] = c[0];
}
}
if (fscanf(infile, "%1s ", c) < 0) {
Fprintf(stderr, "unexpected EOF\n");
return FALSE;
}
if (c[0] != '}') {
Fprintf(stderr, "didn't find expected '}'\n");
return FALSE;
}
return TRUE;
}
static void
write_thintile()
{
int i, j;
int i, j;
Fprintf(outfile, "%s\n", comment);
Fprintf(outfile, "{\n");
for (j = 0; j < TILE_Y; j++) {
Fprintf(outfile, " ");
for (i = 0; i < TILE_X; i += 2) {
(void) fputc(pixels[j][i], outfile);
}
Fprintf(outfile, "\n");
}
Fprintf(outfile, "}\n");
Fprintf(outfile, "%s\n", comment);
Fprintf(outfile, "{\n");
for (j = 0; j < TILE_Y; j++) {
Fprintf(outfile, " ");
for (i = 0; i < TILE_X; i += 2) {
(void) fputc(pixels[j][i], outfile);
}
Fprintf(outfile, "\n");
}
Fprintf(outfile, "}\n");
}
int
main(argc, argv)
int argc;
char *argv[];
{
while (filenum < 3) {
tilecount_per_file = 0;
infile = fopen(tilefiles[filenum], RDTMODE);
outfile = fopen(thinfiles[filenum], WRTMODE);
copy_colormap();
while (read_txttile()) {
write_thintile();
tilecount_per_file++;
tilecount++;
}
fclose(outfile);
fclose(infile);
printf("%d tiles processed from %s\n",
tilecount_per_file, tilefiles[filenum]);
++filenum;
}
printf("Grand total of %d tiles processed.\n", tilecount);
exit(EXIT_SUCCESS);
/*NOTREACHED*/
return 0;
while (filenum < 3) {
tilecount_per_file = 0;
infile = fopen(tilefiles[filenum], RDTMODE);
outfile = fopen(thinfiles[filenum], WRTMODE);
copy_colormap();
while (read_txttile()) {
write_thintile();
tilecount_per_file++;
tilecount++;
}
fclose(outfile);
fclose(infile);
printf("%d tiles processed from %s\n", tilecount_per_file,
tilefiles[filenum]);
++filenum;
}
printf("Grand total of %d tiles processed.\n", tilecount);
exit(EXIT_SUCCESS);
/*NOTREACHED*/
return 0;
}
/*thintile.c*/