libwld: Rename some things to get closer to current coding standard.

This commit is contained in:
Gregory Nutt 2016-11-10 16:20:35 -06:00
parent 9885b5c9b3
commit 505d80dd4c
17 changed files with 172 additions and 159 deletions

View File

@ -69,5 +69,5 @@ uint16_t g_nbitmaps;
* the sky and ground * the sky and ground
*/ */
uint8_t skyColor; uint8_t g_sky_color;
uint8_t groundColor; uint8_t g_ground_color;

View File

@ -115,8 +115,8 @@ extern uint16_t g_nbitmaps;
* the sky and ground * the sky and ground
*/ */
extern uint8_t skyColor; extern uint8_t g_sky_color;
extern uint8_t groundColor; extern uint8_t g_ground_color;
/************************************************************************* /*************************************************************************
* Global Function Prototypes * Global Function Prototypes

View File

@ -77,15 +77,15 @@ wld_camera_t g_initial_camera;
* the position of the player's "feet" * the position of the player's "feet"
*/ */
wld_coord_t playerHeight; wld_coord_t g_player_height;
/* This is size of something that the player can step over when "walking" */ /* This is size of something that the player can step over when "walking" */
wld_coord_t walkStepHeight; wld_coord_t g_walk_stepheight;
/* This is size of something that the player can step over when "running" */ /* This is size of something that the player can step over when "running" */
wld_coord_t runStepHeight; wld_coord_t g_run_stepheight;
/************************************************************************* /*************************************************************************
* Private Constant Data * Private Constant Data
@ -164,7 +164,7 @@ static uint8_t wld_manage_worldfile(INIHANDLE handle)
/* Get the height of the player */ /* Get the height of the player */
result = wld_read_shortint(handle, &playerHeight, result = wld_read_shortint(handle, &g_player_height,
g_player_section_name, g_player_height_name); g_player_section_name, g_player_height_name);
if (result != 0) if (result != 0)
{ {
@ -173,7 +173,7 @@ static uint8_t wld_manage_worldfile(INIHANDLE handle)
/* Read the player's capability to step on top of things in the world. */ /* Read the player's capability to step on top of things in the world. */
result = wld_read_shortint(handle, &walkStepHeight, result = wld_read_shortint(handle, &g_walk_stepheight,
g_player_section_name, g_player_section_name,
g_player_walk_stepheight_name); g_player_walk_stepheight_name);
if (result != 0) if (result != 0)
@ -181,7 +181,7 @@ static uint8_t wld_manage_worldfile(INIHANDLE handle)
return result; return result;
} }
result = wld_read_shortint(handle, &runStepHeight, result = wld_read_shortint(handle, &g_run_stepheight,
g_player_section_name, g_player_section_name,
g_player_run_stepheight_name); g_player_run_stepheight_name);
if (result != 0) if (result != 0)

View File

@ -48,12 +48,12 @@
*************************************************************************/ *************************************************************************/
/************************************************************************* /*************************************************************************
* Name: wld_DiscardWorldPlane * Name: wld_discard_worldplane
* Description: * Description:
* This function deallocates one plane of the world * This function deallocates one plane of the world
************************************************************************/ ************************************************************************/
static void wld_DiscardWorldPlane(rect_list_t * rect) static void wld_discard_worldplane(rect_list_t * rect)
{ {
rect_list_t *next; rect_list_t *next;
@ -77,12 +77,12 @@ static void wld_DiscardWorldPlane(rect_list_t * rect)
void wld_discard_planes(void) void wld_discard_planes(void)
{ {
wld_DiscardWorldPlane(g_xplane_list.head); wld_discard_worldplane(g_xplane_list.head);
g_xplane_list.head = g_xplane_list.tail = NULL; g_xplane_list.head = g_xplane_list.tail = NULL;
wld_DiscardWorldPlane(g_yplane_list.head); wld_discard_worldplane(g_yplane_list.head);
g_yplane_list.head = g_yplane_list.tail = NULL; g_yplane_list.head = g_yplane_list.tail = NULL;
wld_DiscardWorldPlane(g_zplane_list.head); wld_discard_worldplane(g_zplane_list.head);
g_zplane_list.head = g_zplane_list.tail = NULL; g_zplane_list.head = g_zplane_list.tail = NULL;
wld_DiscardWorldPlane(freeList); wld_discard_worldplane(freeList);
freeList = NULL; freeList = NULL;
} }

View File

@ -76,8 +76,8 @@ rect_list_t *wld_find_plane(wld_coord_t h, wld_coord_t v, wld_coord_t plane,
* within the rectangle. * within the rectangle.
*/ */
if ((h >= rect->d.hStart) && (h <= rect->d.hEnd) if ((h >= rect->d.hstart) && (h <= rect->d.hend)
&& (v >= rect->d.vStart) && (v <= rect->d.vEnd)) && (v >= rect->d.vstart) && (v <= rect->d.vend))
return rect; return rect;
} }

View File

@ -68,19 +68,19 @@
enum graphic_file_format_e enum graphic_file_format_e
{ {
formatGIF87, FORMAT_GIT87,
formatGIF89, FORMAT_GIT89,
formatPPM, FORMAT_PPM,
formatPCX, FORMAT_PCX,
formatUnknown FORMAT_UNKNOWN
}; };
typedef enum graphic_file_format_e graphic_file_format_t; typedef enum graphic_file_format_e graphic_file_format_t;
enum graphic_file_enum_e enum graphic_file_enum_e
{ {
gfTrueColor, GFILE_TRUECOLOR,
gfPaletted GFILE_PALETTED
}; };
typedef enum graphic_file_enum_e graphic_file_enum_t; typedef enum graphic_file_enum_e graphic_file_enum_t;
@ -88,7 +88,8 @@ typedef enum graphic_file_enum_e graphic_file_enum_t;
struct graphic_file_e struct graphic_file_e
{ {
graphic_file_enum_t type; graphic_file_enum_t type;
uint16_t height, width; uint16_t height;
uint16_t width;
int palette_entries; int palette_entries;
long transparent_entry; long transparent_entry;
color_rgb_t *palette; color_rgb_t *palette;

View File

@ -52,7 +52,7 @@
color_rgb_t wld_graphicfile_pixel(graphic_file_t *gfile, int x, int y) color_rgb_t wld_graphicfile_pixel(graphic_file_t *gfile, int x, int y)
{ {
if (gfile->type == gfPaletted) if (gfile->type == GFILE_PALETTED)
{ {
int i; int i;

View File

@ -61,6 +61,7 @@
#define PLAYER_SECTION_NAME "player" #define PLAYER_SECTION_NAME "player"
/* These are charwld_erictics of the player. */ /* These are charwld_erictics of the player. */
#define PLAYER_HEIGHT "playerheight" #define PLAYER_HEIGHT "playerheight"
#define PLAYER_WALK_STEPHEIGHT "playerwalkstepheight" #define PLAYER_WALK_STEPHEIGHT "playerwalkstepheight"
#define PLAYER_RUN_STEPHEIGHT "playerrunstepheight" #define PLAYER_RUN_STEPHEIGHT "playerrunstepheight"

View File

@ -148,8 +148,8 @@ static uint8_t wld_load_bitmaps(FILE * fp)
/* Read the colors used to rend the sky and ground */ /* Read the colors used to rend the sky and ground */
skyColor = wld_read_decimal(fp); g_sky_color = wld_read_decimal(fp);
groundColor = wld_read_decimal(fp); g_ground_color = wld_read_decimal(fp);
#if MSWINDOWS #if MSWINDOWS
/* Load the textures -- Note that the first texture will be used to define /* Load the textures -- Note that the first texture will be used to define

View File

@ -52,76 +52,76 @@
* Pre-processor Definitions * Pre-processor Definitions
*************************************************************************/ *************************************************************************/
#define NEXTBYTE (*ptr++) #define NEXTBYTE (*ptr++)
#define IMAGESEP 0x2c #define IMAGESEP 0x2c
#define GRAPHIC_EXT 0xf9 #define GRAPHIC_EXT 0xf9
#define PLAINTEXT_EXT 0x01 #define PLAINTEXT_EXT 0x01
#define APPLICATION_EXT 0xff #define APPLICATION_EXT 0xff
#define COMMENT_EXT 0xfe #define COMMENT_EXT 0xfe
#define START_EXTENSION 0x21 #define START_EXTENSION 0x21
#define INTERLACEMASK 0x40 #define INTERLACEMASK 0x40
#define COLORMAPMASK 0x80 #define COLORMAPMASK 0x80
/************************************************************************* /*************************************************************************
* Private Data * Private Data
*************************************************************************/ *************************************************************************/
int BitOffset = 0, /* Bit Offset of next code */ static int BitOffset = 0; /* Bit Offset of next code */
XC = 0, YC = 0, /* Output X and Y coords of current pixel */ static int XC = 0, YC = 0; /* Output X and Y coords of current pixel */
Pass = 0, /* Used by output routine if interlaced pic */ static int Pass = 0; /* Used by output routine if interlaced pic */
OutCount = 0, /* Decompressor output 'stack count' */ static int OutCount = 0; /* Decompressor output 'stack count' */
RWidth, RHeight, /* screen dimensions */ static int RWidth, RHeight; /* screen dimensions */
Width, Height, /* image dimensions */ static int Width, Height; /* image dimensions */
LeftOfs, TopOfs, /* image offset */ static int LeftOfs, TopOfs; /* image offset */
BitsPerPixel, /* Bits per pixel, read from GIF header */ static int BitsPerPixel; /* Bits per pixel, read from GIF header */
BytesPerScanline, /* bytes per scanline in output rwld_er */ static int BytesPerScanline; /* bytes per scanline in output rwld_er */
ColorMapSize, /* number of colors */ static int ColorMapSize; /* number of colors */
Background, /* background color */ static int Background; /* background color */
CodeSize, /* Code size, read from GIF header */ static int CodeSize; /* Code size, read from GIF header */
InitCodeSize, /* Starting code size, used during Clear */ static int InitCodeSize; /* Starting code size, used during Clear */
Code, /* Value returned by ReadCode */ static int Code; /* Value returned by ReadCode */
MaxCode, /* limiting value for current code size */ static int MaxCode; /* limiting value for current code size */
ClearCode, /* GIF clear code */ static int ClearCode; /* GIF clear code */
EOFCode, /* GIF end-of-information code */ static int EOFCode; /* GIF end-of-information code */
CurCode, OldCode, InCode, /* Decompressor variables */ static int CurCode, OldCode, InCode; /* Decompressor variables */
FirstFree, /* First free code, generated per GIF spec */ static int FirstFree; /* First free code, generated per GIF spec */
FreeCode, /* Decompressor, next free slot in hash table */ static int FreeCode; /* Decompressor, next free slot in hash table */
FinChar, /* Decompressor variable */ static int FinChar; /* Decompressor variable */
BitMask, /* AND mask for data size */ static int BitMask; /* AND mask for data size */
ReadMask; /* Code AND mask for current code size */ static int ReadMask; /* Code AND mask for current code size */
bool Interlace, HasColormap; static bool Interlace, HasColormap;
bool Verbose = true; static bool Verbose = true;
uint8_t *Image; /* The result array */ static uint8_t *Image; /* The result array */
uint8_t *RawGIF; /* The heap array to hold it, raw */ static uint8_t *RawGIF; /* The heap array to hold it, raw */
uint8_t *Rwld_er; /* The rwld_er data stream, unblocked */ static uint8_t *Rwld_er; /* The rwld_er data stream, unblocked */
/* The hash table used by the decompressor */ /* The hash table used by the decompressor */
int Prefix[4096]; static int Prefix[4096];
int Suffix[4096]; static int Suffix[4096];
/* An output array used by the decompressor */ /* An output array used by the decompressor */
int OutCode[1025]; static int OutCode[1025];
/* The color map, read from the GIF header */ /* The color map, read from the GIF header */
uint8_t Red[256], Green[256], Blue[256], used[256]; static uint8_t Red[256], Green[256], Blue[256], used[256];
int numused; static int numused;
char *id87 = "GIF87a"; static char *id87 = "GIF87a";
char *id89 = "GIF89a"; static char *id89 = "GIF89a";
/************************************************************************* /*************************************************************************
* Private Functions * Private Functions
************************************************************************/ ************************************************************************/
/************************************************************************* /*************************************************************************
* Name: * Name: ReadCode
* Description: * Description:
* Fetch the next code from the rwld_er data stream. The codes can be * Fetch the next code from the data stream. The codes can be
* any length from 3 to 12 bits, packed into 8-bit bytes, so we have to * any length from 3 to 12 bits, packed into 8-bit bytes, so we have to
* maintain our location in the Rwld_er array as a BIT Offset. We compute * maintain our location in the Rwld_er array as a BIT Offset. We compute
* the byte Offset into the rwld_er array by dividing this by 8, pick up * the byte Offset into the rwld_er array by dividing this by 8, pick up
@ -131,7 +131,8 @@ char *id89 = "GIF89a";
static int ReadCode(void) static int ReadCode(void)
{ {
int RawCode, ByteOffset; int RawCode;
int ByteOffset;
ByteOffset = BitOffset / 8; ByteOffset = BitOffset / 8;
RawCode = Rwld_er[ByteOffset] + (0x100 * Rwld_er[ByteOffset + 1]); RawCode = Rwld_er[ByteOffset] + (0x100 * Rwld_er[ByteOffset + 1]);
@ -376,7 +377,7 @@ graphic_file_t *wld_LoadGIF(FILE * fp, char *fname)
} }
gfile->bitmap = (uint8_t *) wld_malloc(Width * Height); gfile->bitmap = (uint8_t *) wld_malloc(Width * Height);
gfile->type = gfPaletted; gfile->type = GFILE_PALETTED;
gfile->width = Width; gfile->width = Width;
gfile->height = Height; gfile->height = Height;
gfile->transparent_entry = transparency; gfile->transparent_entry = transparency;

View File

@ -52,21 +52,21 @@
* Private Function Prototypes * Private Function Prototypes
*************************************************************************/ *************************************************************************/
static void wld_loadpcxHeader(FILE * fp, pcx_header_t * header); static void wld_load_pcxheader(FILE * fp, pcx_header_t * header);
static void wld_loadpcxData(FILE * fp, int32_t imagSize, uint8_t * imageBuffer); static void wld_load_pcxdata(FILE * fp, int32_t imagSize,
static void wld_loadpcxPalette(FILE * fp, color_rgb_t * palette); uint8_t * imageBuffer);
static void wld_load_pcxpalette(FILE * fp, color_rgb_t * palette);
/************************************************************************* /*************************************************************************
* Private Functions * Private Functions
*************************************************************************/ *************************************************************************/
/************************************************************************* /*************************************************************************
* Name: wld_loadpcxHeader * Name: wld_load_pcxheader
* Description: * Description:
************************************************************************/ ************************************************************************/
static void wld_loadpcxHeader(FILE * fp, pcx_header_t * header) static void wld_load_pcxheader(FILE * fp, pcx_header_t * header)
{ {
uint8_t *tempBuffer; uint8_t *tempBuffer;
int i; int i;
@ -82,11 +82,11 @@ static void wld_loadpcxHeader(FILE * fp, pcx_header_t * header)
} }
/************************************************************************* /*************************************************************************
* Name: wld_loadpcxData * Name: wld_load_pcxdata
* Description: * Description:
************************************************************************/ ************************************************************************/
static void wld_loadpcxData(FILE * fp, int32_t imageSize, uint8_t * imageBuffer) static void wld_load_pcxdata(FILE * fp, int32_t imageSize, uint8_t * imageBuffer)
{ {
uint32_t count; uint32_t count;
int16_t numBytes; int16_t numBytes;
@ -128,11 +128,11 @@ static void wld_loadpcxData(FILE * fp, int32_t imageSize, uint8_t * imageBuffer)
} }
/************************************************************************* /*************************************************************************
* Name: wld_loadpcxPalette * Name: wld_load_pcxpalette
* Description: * Description:
************************************************************************/ ************************************************************************/
static void wld_loadpcxPalette(FILE * fp, color_rgb_t * palette) static void wld_load_pcxpalette(FILE * fp, color_rgb_t * palette)
{ {
int i; int i;
@ -188,7 +188,7 @@ uint8_t wld_loadpcx(char *filename, pcxPicturePtr image)
/* Load the PCX Header */ /* Load the PCX Header */
wld_loadpcxHeader(fp, &image->header); wld_load_pcxheader(fp, &image->header);
/* Load the PCX data */ /* Load the PCX data */
@ -197,14 +197,14 @@ uint8_t wld_loadpcx(char *filename, pcxPicturePtr image)
imageWidth = image->header.width - image->header.x + 1; imageWidth = image->header.width - image->header.x + 1;
imageHeight = image->header.height - image->header.y + 1; imageHeight = image->header.height - image->header.y + 1;
imageSize = imageHeight * imageWidth; imageSize = imageHeight * imageWidth;
wld_loadpcxData(fp, imageSize, image->buffer); wld_load_pcxdata(fp, imageSize, image->buffer);
} }
/* Load the PCX palette */ /* Load the PCX palette */
if (image->palette) if (image->palette)
{ {
wld_loadpcxPalette(fp, &image->palette); wld_load_pcxpalette(fp, &image->palette);
} }
fclose(fp); fclose(fp);
@ -222,7 +222,7 @@ graphic_file_t *wld_loadpcx(FILE * fp, char *filename)
/* Load the PCX Header */ /* Load the PCX Header */
wld_loadpcxHeader(fp, &header); wld_load_pcxheader(fp, &header);
/* Allocate Space to hold the image data */ /* Allocate Space to hold the image data */
@ -233,7 +233,7 @@ graphic_file_t *wld_loadpcx(FILE * fp, char *filename)
/* Load the PCX data into the buffer */ /* Load the PCX data into the buffer */
wld_loadpcxData(fp, imageSize, (uint8_t *) buffer); wld_load_pcxdata(fp, imageSize, (uint8_t *) buffer);
/* Allocate space to hold the PCX palette */ /* Allocate space to hold the PCX palette */
@ -241,12 +241,12 @@ graphic_file_t *wld_loadpcx(FILE * fp, char *filename)
/* Load the PCX palette */ /* Load the PCX palette */
wld_loadpcxPalette(fp, palette); wld_load_pcxpalette(fp, palette);
/* Now save the resulting data in a graphic_file_t structure */ /* Now save the resulting data in a graphic_file_t structure */
gFile = wld_new_graphicfile(); gFile = wld_new_graphicfile();
gFile->type = gfPaletted; gFile->type = GFILE_PALETTED;
gFile->palette = palette; gFile->palette = palette;
gFile->width = imageWidth; gFile->width = imageWidth;
gFile->height = imageHeight; gFile->height = imageHeight;

View File

@ -108,11 +108,11 @@ uint8_t wld_load_planes(FILE * fp)
/* Then load each grid, performing run length (rle) decoding */ /* Then load each grid, performing run length (rle) decoding */
result = wld_load_worldplane(fp, &g_xplane_list, fileHeader.numXRects); result = wld_load_worldplane(fp, &g_xplane_list, fileHeader.num_xrects);
if (!result) if (!result)
result = wld_load_worldplane(fp, &g_yplane_list, fileHeader.numYRects); result = wld_load_worldplane(fp, &g_yplane_list, fileHeader.num_yrects);
if (!result) if (!result)
result = wld_load_worldplane(fp, &g_zplane_list, fileHeader.numZRects); result = wld_load_worldplane(fp, &g_zplane_list, fileHeader.num_zrects);
return result; return result;
} }

View File

@ -127,7 +127,7 @@ graphic_file_t *wld_LoadPPM(FILE * fp, char *filename)
} }
gfile = wld_new_graphicfile(); gfile = wld_new_graphicfile();
gfile->type = gfTrueColor; gfile->type = GFILE_TRUECOLOR;
gfile->palette = NULL; gfile->palette = NULL;
gfile->width = width; gfile->width = width;
gfile->height = height; gfile->height = height;

View File

@ -108,38 +108,48 @@ enum
typedef short wld_coord_t; /* Max world size is +/- 65536/64 = 1024 */ typedef short wld_coord_t; /* Max world size is +/- 65536/64 = 1024 */
typedef uint8_t attrib_t; /* Max attributes = 8 */ typedef uint8_t attrib_t; /* Max attributes = 8 */
typedef struct rectDataStruct struct rect_data_s
{ {
wld_coord_t plane; /* defines the plane that the rect lies in */ wld_coord_t plane; /* defines the plane that the rect lies in */
wld_coord_t hStart; /* defines the starting "horizontal" position */ wld_coord_t hstart; /* defines the starting "horizontal" position */
wld_coord_t hEnd; /* defines the ending "horizontal" position */ wld_coord_t hend; /* defines the ending "horizontal" position */
wld_coord_t vStart; /* defines the starting "vertical" position */ wld_coord_t vstart; /* defines the starting "vertical" position */
wld_coord_t vEnd; /* defines the ending "vertical" position */ wld_coord_t vend; /* defines the ending "vertical" position */
attrib_t attribute; /* bit-encoded attributes of the plane */ attrib_t attribute; /* bit-encoded attributes of the plane */
uint8_t texture; /* defines the texture that should be applied */ uint8_t texture; /* defines the texture that should be applied */
uint8_t scale; /* defines the scaling of the texture */ uint8_t scale; /* defines the scaling of the texture */
} rect_data_t; };
typedef struct rect_data_s rect_data_t;
#define SIZEOF_RECTDATATYPE 13 #define SIZEOF_RECTDATATYPE 13
typedef struct rectListStruct struct rect_list_s
{ {
struct rectListStruct *flink; /* points at next rectangle in a list */ struct rect_list_s *flink; /* points at next rectangle in a list */
struct rectListStruct *blink; /* points at previous rectangle in a list */ struct rect_list_s *blink; /* points at previous rectangle in a list */
rect_data_t d; /* the data which defines the rectangle */ rect_data_t d; /* the data which defines the rectangle */
} rect_list_t; };
typedef struct typedef struct rect_list_s rect_list_t;
struct rect_head_s
{ {
rect_list_t *head; /* points to the start of the list */ rect_list_t *head; /* points to the start of the list */
rect_list_t *tail; /* points to the end of the list */ rect_list_t *tail; /* points to the end of the list */
} rect_head_t; };
typedef struct typedef struct rect_head_s rect_head_t;
struct plane_file_header_s
{ {
uint16_t numXRects; uint16_t num_xrects;
uint16_t numYRects; uint16_t num_yrects;
uint16_t numZRects; uint16_t num_zrects;
} plane_file_header_t; };
typedef struct plane_file_header_s plane_file_header_t;
#define SIZEOF_PLANEFILEHEADERTYPE 6 #define SIZEOF_PLANEFILEHEADERTYPE 6
/************************************************************************* /*************************************************************************
@ -166,23 +176,23 @@ extern rect_list_t *freeList;
* Public Function Prototypes * Public Function Prototypes
*************************************************************************/ *************************************************************************/
extern uint8_t wld_initialize_planes(void); uint8_t wld_initialize_planes(void);
extern void wld_discard_planes(void); void wld_discard_planes(void);
extern uint8_t wld_load_planefile(const char *wldfile); uint8_t wld_load_planefile(const char *wldfile);
extern uint8_t wld_load_planes(FILE *fp); uint8_t wld_load_planes(FILE *fp);
extern uint8_t wld_save_planes(const char *wldFile); uint8_t wld_save_planes(const char *wldFile);
extern rect_list_t *wld_new_plane(void); rect_list_t *wld_new_plane(void);
extern void wld_add_plane(rect_list_t *rect, void wld_add_plane(rect_list_t *rect,
rect_head_t *list); rect_head_t *list);
extern void wld_merge_planelists(rect_head_t *outList, void wld_merge_planelists(rect_head_t *outList,
rect_head_t *inList); rect_head_t *inList);
extern void wld_remove_plane(rect_list_t *rect, void wld_remove_plane(rect_list_t *rect,
rect_head_t *list); rect_head_t *list);
extern void wld_move_plane(rect_list_t *rect, void wld_move_plane(rect_list_t *rect,
rect_head_t *destList, rect_head_t *destList,
rect_head_t *srcList); rect_head_t *srcList);
extern rect_list_t *wld_find_plane(wld_coord_t h, wld_coord_t v, wld_coord_t plane, rect_list_t *wld_find_plane(wld_coord_t h, wld_coord_t v, wld_coord_t plane,
rect_head_t *list); rect_head_t *list);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -54,18 +54,18 @@ graphic_file_t *wld_LoadGIF(FILE * fp, char *filename);
* Private Data * Private Data
*************************************************************************/ *************************************************************************/
static const char pcxExtension[] = ".PCX"; static const char g_pcx_extension[] = ".PCX";
/************************************************************************* /*************************************************************************
* Private Functions * Private Functions
*************************************************************************/ *************************************************************************/
/************************************************************************* /*************************************************************************
* Name: wld_CheckFormat * Name: wld_check_format
* Description: * Description:
************************************************************************/ ************************************************************************/
static graphic_file_format_t wld_CheckFormat(FILE * fp, char *filename) static graphic_file_format_t wld_check_format(FILE * fp, char *filename)
{ {
char magic[MAGIC_LENGTH]; char magic[MAGIC_LENGTH];
@ -76,15 +76,15 @@ static graphic_file_format_t wld_CheckFormat(FILE * fp, char *filename)
if (strncmp(magic, PPM_MAGIC, sizeof(PPM_MAGIC) - 1) == 0) if (strncmp(magic, PPM_MAGIC, sizeof(PPM_MAGIC) - 1) == 0)
{ {
return formatPPM; return FORMAT_PPM;
} }
else if (strncmp(magic, GIF_MAGIC, sizeof(GIF_MAGIC) - 1) == 0) else if (strncmp(magic, GIF_MAGIC, sizeof(GIF_MAGIC) - 1) == 0)
{ {
return formatGIF87; return FORMAT_GIT87;
} }
else if (strncmp(magic, GIF89_MAGIC, sizeof(GIF89_MAGIC) - 1) == 0) else if (strncmp(magic, GIF89_MAGIC, sizeof(GIF89_MAGIC) - 1) == 0)
{ {
return formatGIF89; return FORMAT_GIT89;
} }
else else
{ {
@ -101,11 +101,11 @@ static graphic_file_format_t wld_CheckFormat(FILE * fp, char *filename)
/* Check if the extension matches */ /* Check if the extension matches */
for (ptr2 = (char *)pcxExtension; ((*ptr1) && (*ptr2)); ptr1++, ptr2++) for (ptr2 = (char *)g_pcx_extension; ((*ptr1) && (*ptr2)); ptr1++, ptr2++)
{ {
if (toupper((int)*ptr1) != *ptr2) if (toupper((int)*ptr1) != *ptr2)
{ {
return formatUnknown; return FORMAT_UNKNOWN;
} }
} }
@ -115,11 +115,11 @@ static graphic_file_format_t wld_CheckFormat(FILE * fp, char *filename)
if (!(*ptr1) && !(*ptr2)) if (!(*ptr1) && !(*ptr2))
{ {
return formatPCX; return FORMAT_PCX;
} }
} }
return formatUnknown; return FORMAT_UNKNOWN;
} }
/************************************************************************* /*************************************************************************
@ -142,25 +142,25 @@ graphic_file_t *wld_readgraphic_file(char *filename)
wld_fatal_error("Could not open texture %s", filename); wld_fatal_error("Could not open texture %s", filename);
} }
format = wld_CheckFormat(fp, filename); format = wld_check_format(fp, filename);
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);
switch (format) switch (format)
{ {
case formatGIF89: case FORMAT_GIT89:
case formatGIF87: case FORMAT_GIT87:
gfile = wld_LoadGIF(fp, filename); gfile = wld_LoadGIF(fp, filename);
break; break;
case formatPPM: case FORMAT_PPM:
gfile = wld_LoadPPM(fp, filename); gfile = wld_LoadPPM(fp, filename);
break; break;
case formatPCX: case FORMAT_PCX:
gfile = wld_loadpcx(fp, filename); gfile = wld_loadpcx(fp, filename);
break; break;
case formatUnknown: case FORMAT_UNKNOWN:
wld_fatal_error("Unknown graphic file format.\n"); wld_fatal_error("Unknown graphic file format.\n");
break; break;

View File

@ -48,12 +48,12 @@
*************************************************************************/ *************************************************************************/
/************************************************************************* /*************************************************************************
* Name: wld_CountRectangles * Name: wld_count_rectangles
* Description: * Description:
* This function counts the number of rectangles in one plane * This function counts the number of rectangles in one plane
************************************************************************/ ************************************************************************/
static uint16_t wld_CountRectangles(rect_list_t * rect) static uint16_t wld_count_rectangles(rect_list_t * rect)
{ {
uint16_t count; uint16_t count;
for (count = 0; (rect); count++, rect = rect->flink); for (count = 0; (rect); count++, rect = rect->flink);
@ -61,12 +61,12 @@ static uint16_t wld_CountRectangles(rect_list_t * rect)
} }
/************************************************************************* /*************************************************************************
* Name: wld_SaveWorldPlane * Name: wld_save_worldplane
* Description: * Description:
* This function stores the world data for one plane * This function stores the world data for one plane
************************************************************************/ ************************************************************************/
static uint8_t wld_SaveWorldPlane(FILE * fp, rect_list_t * rect) static uint8_t wld_save_worldplane(FILE * fp, rect_list_t * rect)
{ {
/* For each rectangle in the list */ /* For each rectangle in the list */
@ -107,9 +107,9 @@ uint8_t wld_save_planes(const char *wldFile)
/* Create world file header */ /* Create world file header */
fileHeader.numXRects = wld_CountRectangles(g_xplane_list.head); fileHeader.num_xrects = wld_count_rectangles(g_xplane_list.head);
fileHeader.numYRects = wld_CountRectangles(g_yplane_list.head); fileHeader.num_yrects = wld_count_rectangles(g_yplane_list.head);
fileHeader.numZRects = wld_CountRectangles(g_zplane_list.head); fileHeader.num_zrects = wld_count_rectangles(g_zplane_list.head);
/* Write the file header to the output file */ /* Write the file header to the output file */
@ -122,15 +122,15 @@ uint8_t wld_save_planes(const char *wldFile)
else else
{ {
result = wld_SaveWorldPlane(fp, g_xplane_list.head); result = wld_save_worldplane(fp, g_xplane_list.head);
if (result == PLANE_SUCCESS) if (result == PLANE_SUCCESS)
{ {
result = wld_SaveWorldPlane(fp, g_yplane_list.head); result = wld_save_worldplane(fp, g_yplane_list.head);
} }
if (result == PLANE_SUCCESS) if (result == PLANE_SUCCESS)
{ {
wld_SaveWorldPlane(fp, g_zplane_list.head); wld_save_worldplane(fp, g_zplane_list.head);
} }
} }

View File

@ -98,15 +98,15 @@ extern wld_camera_t g_initial_camera;
* the position of the player's "feet" * the position of the player's "feet"
*/ */
extern wld_coord_t playerHeight; extern wld_coord_t g_player_height;
/* This is size of something that the player can step over when "walking" */ /* This is size of something that the player can step over when "walking" */
extern wld_coord_t walkStepHeight; extern wld_coord_t g_walk_stepheight;
/* This is size of something that the player can step over when "running" */ /* This is size of something that the player can step over when "running" */
extern wld_coord_t runStepHeight; extern wld_coord_t g_run_stepheight;
/************************************************************************* /*************************************************************************
* Global Function Prototypes * Global Function Prototypes