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
+132 -122
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 pctiles.c $NHDT-Date: 1425319883 2015/03/02 18:11:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */
/* NetHack 3.6 pctiles.c $NHDT-Date: 1431192781 2015/05/09 17:33:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
/* NetHack 3.6 pctiles.c $Date: 2009/05/06 10:49:39 $ $Revision: 1.5 $ */
/* SCCS Id: @(#)pctiles.c 3.5 1995/07/31 */
/* Copyright (c) NetHack PC Development Team 1993, 1994 */
@@ -6,7 +6,7 @@
/* */
/*
* pctiles.c - PC Graphical Tile Support Routines
*
*
*Edit History:
* Initial Creation M. Allison 93/10/30
*
@@ -18,18 +18,18 @@
#if defined(__GO32__) || defined(__DJGPP__)
#include <unistd.h>
#define TILES_IN_RAM /* allow tiles to be read into ram */
#define TILES_IN_RAM /* allow tiles to be read into ram */
#endif
# if defined(_MSC_VER)
# if _MSC_VER >= 700
#pragma warning(disable:4018) /* signed/unsigned mismatch */
#pragma warning(disable:4127) /* conditional expression is constant */
#pragma warning(disable:4131) /* old style declarator */
#pragma warning(disable:4309) /* initializing */
# endif
#if defined(_MSC_VER)
#if _MSC_VER >= 700
#pragma warning(disable : 4018) /* signed/unsigned mismatch */
#pragma warning(disable : 4127) /* conditional expression is constant */
#pragma warning(disable : 4131) /* old style declarator */
#pragma warning(disable : 4309) /* initializing */
#endif
#include <conio.h>
# endif
#endif
#include "pcvideo.h"
#include "tile.h"
@@ -37,14 +37,14 @@
STATIC_VAR FILE *tilefile;
STATIC_VAR FILE *tilefile_O;
extern short glyph2tile[]; /* in tile.c (made from tilemap.c) */
extern short glyph2tile[]; /* in tile.c (made from tilemap.c) */
#ifdef TILES_IN_RAM
struct planar_cell_struct *ramtiles;
struct overview_planar_cell_struct *oramtiles;
boolean tiles_in_ram = FALSE;
boolean otiles_in_ram = FALSE;
extern int total_tiles_used; /* tile.c */
extern int total_tiles_used; /* tile.c */
#endif
/*
@@ -55,19 +55,20 @@ extern int total_tiles_used; /* tile.c */
* at the start of the file, including a palette.
*
*/
int ReadTileFileHeader(tibhdr, filestyle)
int
ReadTileFileHeader(tibhdr, filestyle)
struct tibhdr_struct *tibhdr;
boolean filestyle;
{
FILE *x;
x = filestyle ? tilefile_O : tilefile;
if (fseek(x,0L,SEEK_SET)) {
return 1;
} else {
fread(tibhdr, sizeof(struct tibhdr_struct), 1, x);
}
return 0;
}
FILE *x;
x = filestyle ? tilefile_O : tilefile;
if (fseek(x, 0L, SEEK_SET)) {
return 1;
} else {
fread(tibhdr, sizeof(struct tibhdr_struct), 1, x);
}
return 0;
}
/*
* Open the requested tile file.
@@ -91,74 +92,80 @@ char *tilefilename;
boolean filestyle;
{
#ifdef TILES_IN_RAM
int k;
int k;
#endif
if (filestyle) {
tilefile_O = fopen(tilefilename,"rb");
if (tilefile_O == (FILE *)0) return 1;
} else {
tilefile = fopen(tilefilename,"rb");
if (tilefile == (FILE *)0) return 1;
}
if (filestyle) {
tilefile_O = fopen(tilefilename, "rb");
if (tilefile_O == (FILE *) 0)
return 1;
} else {
tilefile = fopen(tilefilename, "rb");
if (tilefile == (FILE *) 0)
return 1;
}
#ifdef TILES_IN_RAM
if (iflags.preload_tiles) {
if (filestyle) {
struct overview_planar_cell_struct *gp;
long ram_needed = sizeof(struct overview_planar_cell_struct) *
total_tiles_used;
if (fseek(tilefile_O,(long)TIBHEADER_SIZE, SEEK_SET)) { /*failure*/
}
oramtiles = (struct overview_planar_cell_struct *)alloc(ram_needed);
/* Todo: fall back to file method here if alloc failed */
gp = oramtiles;
for(k=0; k < total_tiles_used; ++k) {
fread(gp, sizeof(struct overview_planar_cell_struct),
1, tilefile_O);
++gp;
}
if (filestyle) {
struct overview_planar_cell_struct *gp;
long ram_needed =
sizeof(struct overview_planar_cell_struct) * total_tiles_used;
if (fseek(tilefile_O, (long) TIBHEADER_SIZE,
SEEK_SET)) { /*failure*/
}
oramtiles =
(struct overview_planar_cell_struct *) alloc(ram_needed);
/* Todo: fall back to file method here if alloc failed */
gp = oramtiles;
for (k = 0; k < total_tiles_used; ++k) {
fread(gp, sizeof(struct overview_planar_cell_struct), 1,
tilefile_O);
++gp;
}
#ifdef DEBUG_RAMTILES
pline("%d overview tiles read into ram.", k);
mark_synch();
pline("%d overview tiles read into ram.", k);
mark_synch();
#endif
otiles_in_ram = TRUE;
} else {
struct planar_cell_struct *gp;
long ram_needed = sizeof(struct planar_cell_struct) *
total_tiles_used;
if (fseek(tilefile,(long)TIBHEADER_SIZE, SEEK_SET)) { /*failure*/
}
ramtiles = (struct planar_cell_struct *)alloc(ram_needed);
/* Todo: fall back to file method here if alloc failed */
gp = ramtiles;
for(k=0; k < total_tiles_used; ++k) {
fread(gp, sizeof(struct planar_cell_struct),
1, tilefile);
++gp;
}
otiles_in_ram = TRUE;
} else {
struct planar_cell_struct *gp;
long ram_needed =
sizeof(struct planar_cell_struct) * total_tiles_used;
if (fseek(tilefile, (long) TIBHEADER_SIZE,
SEEK_SET)) { /*failure*/
}
ramtiles = (struct planar_cell_struct *) alloc(ram_needed);
/* Todo: fall back to file method here if alloc failed */
gp = ramtiles;
for (k = 0; k < total_tiles_used; ++k) {
fread(gp, sizeof(struct planar_cell_struct), 1, tilefile);
++gp;
}
#ifdef DEBUG_RAMTILES
pline("%d tiles read into ram.", k);
mark_synch();
pline("%d tiles read into ram.", k);
mark_synch();
#endif
tiles_in_ram = TRUE;
}
tiles_in_ram = TRUE;
}
}
#endif
return 0;
return 0;
}
void
CloseTileFile(filestyle)
boolean filestyle;
{
fclose(filestyle ? tilefile_O : tilefile);
fclose(filestyle ? tilefile_O : tilefile);
#ifdef TILES_IN_RAM
if (!filestyle && tiles_in_ram) {
if (ramtiles) free((genericptr_t) ramtiles);
tiles_in_ram = FALSE;
} else if (filestyle && otiles_in_ram) {
if (oramtiles) free((genericptr_t) oramtiles);
otiles_in_ram = FALSE;
}
if (!filestyle && tiles_in_ram) {
if (ramtiles)
free((genericptr_t) ramtiles);
tiles_in_ram = FALSE;
} else if (filestyle && otiles_in_ram) {
if (oramtiles)
free((genericptr_t) oramtiles);
otiles_in_ram = FALSE;
}
#endif
}
@@ -184,72 +191,75 @@ struct overview_planar_cell_struct oplancell;
* increasing the memory requirement - can't have everything).
*
*/
# ifdef PLANAR_FILE
int ReadPlanarTileFile(tilenum,gp)
#ifdef PLANAR_FILE
int
ReadPlanarTileFile(tilenum, gp)
int tilenum;
struct planar_cell_struct **gp;
{
long fpos;
long fpos;
#ifdef TILES_IN_RAM
if (tiles_in_ram) {
*gp = ramtiles + tilenum;
return 0;
}
if (tiles_in_ram) {
*gp = ramtiles + tilenum;
return 0;
}
#endif
fpos = ((long)(tilenum) * (long)sizeof(struct planar_cell_struct)) +
(long)TIBHEADER_SIZE;
if (fseek(tilefile,fpos,SEEK_SET)) {
return 1;
} else {
fread(&plancell, sizeof(struct planar_cell_struct), 1, tilefile);
}
*gp = &plancell;
return 0;
fpos = ((long) (tilenum) * (long) sizeof(struct planar_cell_struct))
+ (long) TIBHEADER_SIZE;
if (fseek(tilefile, fpos, SEEK_SET)) {
return 1;
} else {
fread(&plancell, sizeof(struct planar_cell_struct), 1, tilefile);
}
*gp = &plancell;
return 0;
}
int ReadPlanarTileFile_O(tilenum,gp)
int
ReadPlanarTileFile_O(tilenum, gp)
int tilenum;
struct overview_planar_cell_struct **gp;
{
long fpos;
long fpos;
#ifdef TILES_IN_RAM
if (otiles_in_ram) {
*gp = oramtiles + tilenum;
return 0;
}
if (otiles_in_ram) {
*gp = oramtiles + tilenum;
return 0;
}
#endif
fpos = ((long)(tilenum) *
(long)sizeof(struct overview_planar_cell_struct)) +
(long)TIBHEADER_SIZE;
if (fseek(tilefile_O,fpos,SEEK_SET)) {
return 1;
} else {
fread(&oplancell, sizeof(struct overview_planar_cell_struct),
1, tilefile_O);
}
*gp = &oplancell;
return 0;
fpos =
((long) (tilenum) * (long) sizeof(struct overview_planar_cell_struct))
+ (long) TIBHEADER_SIZE;
if (fseek(tilefile_O, fpos, SEEK_SET)) {
return 1;
} else {
fread(&oplancell, sizeof(struct overview_planar_cell_struct), 1,
tilefile_O);
}
*gp = &oplancell;
return 0;
}
# endif
#endif
# ifdef PACKED_FILE
int ReadPackedTileFile(tilenum,pta)
#ifdef PACKED_FILE
int
ReadPackedTileFile(tilenum, pta)
int tilenum;
char (*pta)[TILE_X];
{
long fpos;
fpos = ((long)(tilenum) * (long)(TILE_Y * TILE_X) +
(long)TIBHEADER_SIZE);
if (fseek(tilefile,fpos,SEEK_SET)) {
return 1;
} else {
fread(pta, (TILE_Y * TILE_X), 1, tilefile);
}
return 0;
long fpos;
fpos =
((long) (tilenum) * (long) (TILE_Y * TILE_X) + (long) TIBHEADER_SIZE);
if (fseek(tilefile, fpos, SEEK_SET)) {
return 1;
} else {
fread(pta, (TILE_Y * TILE_X), 1, tilefile);
}
return 0;
}
# endif
#endif
#endif /* USE_TILES */
/* pctiles.c */