# HG changeset patch # User Matti Hamalainen # Date 1412589563 -10800 # Node ID f05330267c66ca9082bbbbb6f41a28e80030f1f7 # Parent c91965fc33b65234defeeda8860cc5df31dce090 Use stdint types. diff -r c91965fc33b6 -r f05330267c66 src/colour4.cc --- a/src/colour4.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/colour4.cc Mon Oct 06 12:59:23 2014 +0300 @@ -58,7 +58,7 @@ * Convert an 8-bit RGB component value to a 16-bit one. * Will convert 00h to 0000h, 80h to 8080h and FFh to FFFFh. */ -static inline u16 eight2sixteen(u8 v) +static inline uint16_t eight2sixteen(uint8_t v) { return (v << 8) | v; } diff -r c91965fc33b6 -r f05330267c66 src/drawmap.cc --- a/src/drawmap.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/drawmap.cc Mon Oct 06 12:59:23 2014 +0300 @@ -599,7 +599,7 @@ class Thing_npixels { public: - Thing_npixels(i16 thing_no, unsigned long npixels, + Thing_npixels(int16_t thing_no, unsigned long npixels, wad_ttype_t type):thing_no(thing_no), npixels(npixels), type(type) { @@ -610,7 +610,7 @@ this->npixels == other.npixels) && this->type < other.type); } - i16 thing_no; + int16_t thing_no; unsigned long npixels; wad_ttype_t type; }; @@ -640,7 +640,7 @@ wad_res.sprites.loc_by_root(sprite_root, loc); else loc.len = 0; - a.push_back(Thing_npixels((i16) n, loc.len, Things[n].type)); + a.push_back(Thing_npixels((int16_t) n, loc.len, Things[n].type)); } sort(a.begin(), a.end()); } @@ -669,7 +669,7 @@ unsigned short height; }; -typedef std::map < i16, sprite_dim_t > dim_map_t; +typedef std::map < int16_t, sprite_dim_t > dim_map_t; static dim_map_t dim_map; // FIXME there should be one for each game diff -r c91965fc33b6 -r f05330267c66 src/editloop.cc --- a/src/editloop.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/editloop.cc Mon Oct 06 12:59:23 2014 +0300 @@ -150,9 +150,9 @@ // A table of the modes in the editor. typedef struct { - i8 obj_type; // Corresponding object type - i8 item_no; // # of item to tick in the "View" menu - i8 menu_no; // # of flavour of the "Misc op." menu + int8_t obj_type; // Corresponding object type + int8_t item_no; // # of item to tick in the "View" menu + int8_t menu_no; // # of flavour of the "Misc op." menu } editmode_t; const int NB_MODES = 4; diff -r c91965fc33b6 -r f05330267c66 src/endian.cc --- a/src/endian.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/endian.cc Mon Oct 06 12:59:23 2014 +0300 @@ -41,7 +41,7 @@ union { char mem[17]; // 5 is enough in theory - u32 n; + uint32_t n; } u; memset(u.mem, '\0', sizeof(u.mem)); u.n = 0x31323334; diff -r c91965fc33b6 -r f05330267c66 src/gcolour1.cc --- a/src/gcolour1.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/gcolour1.cc Mon Oct 06 12:59:23 2014 +0300 @@ -56,7 +56,7 @@ pcolour_t *alloc_game_colours(int playpalnum) { MDirPtr dir; - u8 *dpal; + uint8_t *dpal; pcolour_t *game_colours = 0; dir = FindMasterDir(cfg.MasterDir, "PLAYPAL"); @@ -74,7 +74,7 @@ playpalnum = 0; } - dpal = (u8 *) GetMemory(3 * DOOM_COLOURS); + dpal = (uint8_t *) GetMemory(3 * DOOM_COLOURS); dir->wadfile->seek(dir->dir.start); if (dir->wadfile->error()) { @@ -95,9 +95,9 @@ rgb_c rgb_values[DOOM_COLOURS]; for (size_t n = 0; n < DOOM_COLOURS; n++) { - rgb_values[n].r = (u8) dpal[3 * n]; - rgb_values[n].g = (u8) dpal[3 * n + 1]; - rgb_values[n].b = (u8) dpal[3 * n + 2]; + rgb_values[n].r = (int8_t) dpal[3 * n]; + rgb_values[n].g = (int8_t) dpal[3 * n + 1]; + rgb_values[n].b = (int8_t) dpal[3 * n + 2]; } game_colours = alloc_colours(rgb_values, DOOM_COLOURS); diff -r c91965fc33b6 -r f05330267c66 src/gcolour3.h --- a/src/gcolour3.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/gcolour3.h Mon Oct 06 12:59:23 2014 +0300 @@ -56,7 +56,7 @@ */ -typedef u8 pv24_t[3]; // A 24-bit pixel value +typedef uint8_t pv24_t[3]; // A 24-bit pixel value class Game_colour_24 diff -r c91965fc33b6 -r f05330267c66 src/img.h --- a/src/img.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/img.h Mon Oct 06 12:59:23 2014 +0300 @@ -8,7 +8,7 @@ #define YH_IMG -typedef u8 img_pixel_t; +typedef uint8_t img_pixel_t; typedef unsigned short img_dim_t; class Img_priv; diff -r c91965fc33b6 -r f05330267c66 src/imgspect.cc --- a/src/imgspect.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/imgspect.cc Mon Oct 06 12:59:23 2014 +0300 @@ -38,7 +38,7 @@ void spectrify_img(Img & img) { int x, y; - u8 grey; + uint8_t grey; // FIXME this is gross if (cfg.GameId == IWAD_DOOM1 || cfg.GameId == IWAD_DOOM2) diff -r c91965fc33b6 -r f05330267c66 src/l_align.cc --- a/src/l_align.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/l_align.cc Mon Oct 06 12:59:23 2014 +0300 @@ -154,9 +154,9 @@ int vert1, vert2; // vertex 1 and 2 for the linedef under scrutiny int xoffset; // xoffset accumulator int useroffset; // user input offset for first input - i16 texlength; // the length of texture to format to + int16_t texlength; // the length of texture to format to int length; // length of linedef under scrutiny - i16 dummy; // holds useless data + int16_t dummy; // holds useless data vert1 = -1; vert2 = -1; // 1st time round the while loop the -1 value is needed diff -r c91965fc33b6 -r f05330267c66 src/l_flags.cc --- a/src/l_flags.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/l_flags.cc Mon Oct 06 12:59:23 2014 +0300 @@ -41,7 +41,7 @@ void frob_linedefs_flags(SelPtr list, int op, int operand) { SelPtr cur; - i16 mask; + int16_t mask; if (op == YO_CLEAR || op == YO_SET || op == YO_TOGGLE) mask = 1 << operand; diff -r c91965fc33b6 -r f05330267c66 src/levels.cc --- a/src/levels.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/levels.cc Mon Oct 06 12:59:23 2014 +0300 @@ -119,7 +119,7 @@ static char *tex_list = 0; static size_t ntex = 0; static char tex_name[WAD_TEX_NAME + 1]; -inline const char *texno_texname(i16 texno) +inline const char *texno_texname(int16_t texno) { if (texno < 0) return "-"; @@ -130,7 +130,7 @@ } else { - if (texno < (i16) ntex) + if (texno < (int16_t) ntex) return tex_list + WAD_TEX_NAME * texno; else return "unknown"; @@ -155,8 +155,8 @@ fatal_error("level data not found"); // Get the number of vertices - i32 v_offset = 42; - i32 v_length = 42; + int32_t v_offset = 42; + int32_t v_length = 42; { const char *lump_name = "BUG"; if (yg_level_format == YGLF_ALPHA) // Doom alpha @@ -176,7 +176,7 @@ v_length -= 4; } OldNumVertices = (int) (v_length / WAD_VERTEX_BYTES); - if ((i32) (OldNumVertices * WAD_VERTEX_BYTES) != v_length) + if ((int32_t) (OldNumVertices * WAD_VERTEX_BYTES) != v_length) warn("the %s lump has a weird size." " The wad might be corrupt.\n", lump_name); } @@ -186,8 +186,8 @@ { const char *lump_name = "THINGS"; verbmsg("Reading %s things", levelname); - i32 offset = 42; - i32 length; + int32_t offset = 42; + int32_t length; dir = FindMasterDir(Level, lump_name); if (dir == 0) NumThings = 0; @@ -198,7 +198,7 @@ if (cfg.GameId == IWAD_HEXEN) // Hexen mode { NumThings = (int) (length / WAD_HEXEN_THING_BYTES); - if ((i32) (NumThings * WAD_HEXEN_THING_BYTES) != length) + if ((int32_t) (NumThings * WAD_HEXEN_THING_BYTES) != length) warn("the %s lump has a weird size." " The wad might be corrupt.\n", lump_name); } @@ -212,7 +212,7 @@ size_t thing_size = yg_level_format == YGLF_ALPHA ? 12 : WAD_THING_BYTES; NumThings = (int) (length / thing_size); - if ((i32) (NumThings * thing_size) != length) + if ((int32_t) (NumThings * thing_size) != length) warn("the %s lump has a weird size." " The wad might be corrupt.\n", lump_name); } @@ -234,7 +234,7 @@ if (cfg.GameId == IWAD_HEXEN) // Hexen mode for (long n = 0; n < NumThings; n++) { - u8 dummy2[6]; + uint8_t dummy2[6]; wf->read_i16(); // Tid wf->read_i16(&Things[n].xpos); wf->read_i16(&Things[n].ypos); @@ -283,7 +283,7 @@ if (cfg.GameId == IWAD_HEXEN) // Hexen mode { NumLineDefs = (int) (dir->dir.size / WAD_HEXEN_LINEDEF_BYTES); - if ((i32) (NumLineDefs * WAD_HEXEN_LINEDEF_BYTES) != + if ((int32_t) (NumLineDefs * WAD_HEXEN_LINEDEF_BYTES) != dir->dir.size) warn("the %s lump has a weird size." " The wad might be corrupt.\n", lump_name); @@ -291,7 +291,7 @@ else // Doom/Heretic/Strife mode { NumLineDefs = (int) (dir->dir.size / WAD_LINEDEF_BYTES); - if ((i32) (NumLineDefs * WAD_LINEDEF_BYTES) != dir->dir.size) + if ((int32_t) (NumLineDefs * WAD_LINEDEF_BYTES) != dir->dir.size) warn("the %s lump has a weird size." " The wad might be corrupt.\n", lump_name); } @@ -311,7 +311,7 @@ if (cfg.GameId == IWAD_HEXEN) // Hexen mode for (long n = 0; n < NumLineDefs; n++) { - u8 dummy[6]; + uint8_t dummy[6]; wf->read_i16(&LineDefs[n].start); wf->read_i16(&LineDefs[n].end); wf->read_i16(&LineDefs[n].flags); @@ -355,7 +355,7 @@ if (dir) { NumSideDefs = (int) (dir->dir.size / WAD_SIDEDEF_BYTES); - if ((i32) (NumSideDefs * WAD_SIDEDEF_BYTES) != dir->dir.size) + if ((int32_t) (NumSideDefs * WAD_SIDEDEF_BYTES) != dir->dir.size) warn("the SIDEDEFS lump has a weird size." " The wad might be corrupt.\n"); } @@ -455,7 +455,7 @@ const char *lump_name = "TEXTURES"; bool success = false; ntex = 0; - i32 *offset_table = 0; + int32_t *offset_table = 0; MDirPtr d = FindMasterDir(cfg.MasterDir, lump_name); if (!d) { @@ -470,7 +470,7 @@ warn("%s: seek error\n", lump_name); goto textures_done; } - i32 num; + int32_t num; wf->read_i32(&num); if (wf->error()) { @@ -482,7 +482,7 @@ goto textures_done; } ntex = num; - offset_table = new i32[ntex]; + offset_table = new int32_t[ntex]; for (size_t n = 0; n < ntex; n++) { wf->read_i32(offset_table + n); @@ -540,17 +540,17 @@ ld->type = wf->read_i16(); ld->tag = wf->read_i16(); wf->read_i16(); // Unused ? - i16 sector1 = wf->read_i16(); - i16 xofs1 = wf->read_i16(); - i16 tex1m = wf->read_i16(); - i16 tex1u = wf->read_i16(); - i16 tex1l = wf->read_i16(); + int16_t sector1 = wf->read_i16(); + int16_t xofs1 = wf->read_i16(); + int16_t tex1m = wf->read_i16(); + int16_t tex1u = wf->read_i16(); + int16_t tex1l = wf->read_i16(); wf->read_i16(); // Unused ? - i16 sector2 = wf->read_i16(); - i16 xofs2 = wf->read_i16(); - i16 tex2m = wf->read_i16(); - i16 tex2u = wf->read_i16(); - i16 tex2l = wf->read_i16(); + int16_t sector2 = wf->read_i16(); + int16_t xofs2 = wf->read_i16(); + int16_t tex2m = wf->read_i16(); + int16_t tex2u = wf->read_i16(); + int16_t tex2l = wf->read_i16(); if (sector1 >= 0) // Create first sidedef { ld->sidedef1 = s; @@ -698,7 +698,7 @@ MapMinY = 32767; for (long n = 0; n < NumVertices; n++) { - i16 val; + int16_t val; wf->read_i16(&val); if (val < MapMinX) MapMinX = val; @@ -736,7 +736,7 @@ if (dir) { NumSectors = (int) (dir->dir.size / WAD_SECTOR_BYTES); - if ((i32) (NumSectors * WAD_SECTOR_BYTES) != dir->dir.size) + if ((int32_t) (NumSectors * WAD_SECTOR_BYTES) != dir->dir.size) warn("the %s lump has a weird size." " The wad might be corrupt.\n", lump_name); } @@ -774,9 +774,9 @@ } else // Doom alpha--a wholly different SECTORS format { - i32 *offset_table = 0; - i32 nsectors = 0; - i32 nflatnames = 0; + int32_t *offset_table = 0; + int32_t nsectors = 0; + int32_t nflatnames = 0; char *flatnames = 0; if (dir == 0) { @@ -807,7 +807,7 @@ NumSectors = nsectors; Sectors = (SPtr) GetMemory((unsigned long) NumSectors * sizeof(struct Sector)); - offset_table = new i32[nsectors]; + offset_table = new int32_t[nsectors]; for (size_t n = 0; n < (size_t) nsectors; n++) wf->read_i32(offset_table + n); if (wf->error()) @@ -877,7 +877,7 @@ rc = 1; goto sectors_alpha_done; } - i16 index; + int16_t index; wf->read_i16(&Sectors[n].floorh); wf->read_i16(&Sectors[n].ceilh); wf->read_i16(&index); @@ -1305,7 +1305,7 @@ { MDirPtr dir; int n; - i32 val; + int32_t val; verbmsg("Reading texture names\n"); @@ -1362,7 +1362,7 @@ || yg_texture_format == YGTF_STRIFE11)) { const char *lump_name = "TEXTURES"; - i32 *offsets = 0; + int32_t *offsets = 0; dir = FindMasterDir(cfg.MasterDir, lump_name); if (dir == NULL) // In theory it always exists, though { @@ -1385,7 +1385,7 @@ } NumWTexture = (int) val + 1; // read in the offsets for texture1 names - offsets = (i32 *) GetMemory((long) NumWTexture * 4); + offsets = (int32_t *) GetMemory((long) NumWTexture * 4); wf->read_i32(offsets + 1, NumWTexture - 1); if (wf->error()) { @@ -1426,7 +1426,7 @@ || yg_texture_format == YGTF_STRIFE11)) { const char *lump_name = "TEXTURE1"; - i32 *offsets = 0; + int32_t *offsets = 0; dir = FindMasterDir(cfg.MasterDir, lump_name); if (dir != NULL) // In theory it always exists, though { @@ -1444,7 +1444,7 @@ } NumWTexture = (int) val + 1; // read in the offsets for texture1 names - offsets = (i32 *) GetMemory((long) NumWTexture * 4); + offsets = (int32_t *) GetMemory((long) NumWTexture * 4); wf->read_i32(offsets + 1, NumWTexture - 1); { // FIXME @@ -1489,7 +1489,7 @@ // FIXME } // read in the offsets for texture2 names - offsets = (i32 *) GetMemory((long) val * 4); + offsets = (int32_t *) GetMemory((long) val * 4); wf->read_i32(offsets, val); if (wf->error()) { diff -r c91965fc33b6 -r f05330267c66 src/levels.h --- a/src/levels.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/levels.h Mon Oct 06 12:59:23 2014 +0300 @@ -37,7 +37,7 @@ { char name[WAD_NAME + 1]; // Name of flat const Wad_file *wadfile; // Pointer on wad where flat comes from - i32 offset; // Offset of flat in wad + int32_t offset; // Offset of flat in wad } flat_list_entry_t; // Length is implicit (always 4096) extern flat_list_entry_t *flat_list; // List of all flats in the directory diff -r c91965fc33b6 -r f05330267c66 src/mkpalette.cc --- a/src/mkpalette.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/mkpalette.cc Mon Oct 06 12:59:23 2014 +0300 @@ -36,7 +36,7 @@ #include "wads.h" -static int palette_read_from_wad(int playpalnum, u8 **dpal) +static int palette_read_from_wad(int playpalnum, uint8_t **dpal) { const char *lump_name = "PLAYPAL"; @@ -55,7 +55,7 @@ playpalnum = 0; } - *dpal = (u8 *) GetMemory(3 * DOOM_COLOURS); + *dpal = (uint8_t *) GetMemory(3 * DOOM_COLOURS); if (*dpal == NULL) { err("Could not allocate memory for the palette entry"); @@ -89,7 +89,7 @@ return f; } -static void palette_cleanup(FILE *outfile, u8 *dpal, int *rc) +static void palette_cleanup(FILE *outfile, uint8_t *dpal, int *rc) { FreeMemory(dpal); if (outfile != NULL) @@ -108,7 +108,7 @@ int make_gimp_palette(int playpalnum, const char *filename) { int rc = 0; - u8 *dpal = NULL; + uint8_t *dpal = NULL; FILE *outfile = NULL; if ((rc = palette_read_from_wad(playpalnum, &dpal)) != 0) @@ -144,7 +144,7 @@ int make_palette_ppm(int playpalnum, const char *filename) { int rc = 0; - u8 *dpal = NULL; + uint8_t *dpal = NULL; FILE *outfile = NULL; const int width = 128; const int height = 128; @@ -202,7 +202,7 @@ int make_palette_ppm_2(int playpalnum, const char *filename) { int rc = 0; - u8 *dpal = NULL; + uint8_t *dpal = NULL; FILE *outfile = NULL; const int width = DOOM_COLOURS; const int height = DOOM_COLOURS; diff -r c91965fc33b6 -r f05330267c66 src/objid.h --- a/src/objid.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/objid.h Mon Oct 06 12:59:23 2014 +0300 @@ -48,7 +48,7 @@ #define OBJ_ANY 11 // Special object numbers -typedef i16 obj_no_t; +typedef int16_t obj_no_t; typedef char obj_type_t; #define OBJ_NO_NONE -1 #define OBJ_NO_CANVAS -2 diff -r c91965fc33b6 -r f05330267c66 src/palview.cc --- a/src/palview.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/palview.cc Mon Oct 06 12:59:23 2014 +0300 @@ -48,7 +48,7 @@ // One COLORMAP entry. Wrapped in struct to avoid array<->pointer problems typedef struct { - u8 c[DOOM_COLOURS]; + uint8_t c[DOOM_COLOURS]; } colormap_entry_t; void Palette_viewer::run() diff -r c91965fc33b6 -r f05330267c66 src/patchdir.cc --- a/src/patchdir.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/patchdir.cc Mon Oct 06 12:59:23 2014 +0300 @@ -89,8 +89,8 @@ do { MDirPtr dir; - i32 npatches_head = -42; - i32 npatches_body = -42; + int32_t npatches_head = -42; + int32_t npatches_body = -42; dir = FindMasterDir(master_dir, lump_name); if (dir == 0) @@ -99,7 +99,7 @@ lump_name); break; } - i32 pnames_body_size = dir->dir.size - 4; + int32_t pnames_body_size = dir->dir.size - 4; if (pnames_body_size < 0) { warn("Bad %s (negative size %ld), won't be able to render textures\n", lump_name, (long) dir->dir.size); @@ -254,7 +254,7 @@ * Return the (wad, offset, length) location of the lump * that contains patch# . */ -void Patch_dir::loc_by_num(i16 num, Lump_loc & loc) +void Patch_dir::loc_by_num(int16_t num, Lump_loc & loc) { wad_pic_name_t *nm = name_for_num(num); if (nm == 0) @@ -271,7 +271,7 @@ * Return a pointer on the name of the patch of number * or 0 if no such patch. */ -wad_pic_name_t *Patch_dir::name_for_num(i16 num) +wad_pic_name_t *Patch_dir::name_for_num(int16_t num) { if (num < 0 || (size_t) num >= npnames) // Cast to silence GCC warning return 0; diff -r c91965fc33b6 -r f05330267c66 src/patchdir.h --- a/src/patchdir.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/patchdir.h Mon Oct 06 12:59:23 2014 +0300 @@ -106,8 +106,8 @@ ~Patch_dir(); void refresh(MDirPtr master_dir); void loc_by_name(const char *name, Lump_loc & loc); - void loc_by_num(i16 num, Lump_loc & loc); - wad_pic_name_t *name_for_num(i16 num); + void loc_by_num(int16_t num, Lump_loc & loc); + wad_pic_name_t *name_for_num(int16_t num); void list(Patch_list & pl); private: char *pnames; // The contents of PNAMES diff -r c91965fc33b6 -r f05330267c66 src/pic2img.cc --- a/src/pic2img.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/pic2img.cc Mon Oct 06 12:59:23 2014 +0300 @@ -73,14 +73,14 @@ int *pic_height) // (can be NULL) { MDirPtr dir; - i16 pic_width_; - i16 pic_height_; - i16 pic_intrinsic_x_ofs; - i16 pic_intrinsic_y_ofs; - u8 *ColumnData; - u8 *Column; - i32 *NeededOffsets; - i32 CurrentOffset; + int16_t pic_width_; + int16_t pic_height_; + int16_t pic_intrinsic_x_ofs; + int16_t pic_intrinsic_y_ofs; + uint8_t *ColumnData; + uint8_t *Column; + int32_t *NeededOffsets; + int32_t CurrentOffset; int ColumnInMemory; long ActualBufLen; int pic_x; @@ -88,7 +88,7 @@ int pic_x1; int pic_y0; int pic_y1; - u8 *buf; /* This variable is set to point to the element of + uint8_t *buf; /* This variable is set to point to the element of the image buffer where the top of the current column should be pasted. It can be off the image buffer! */ @@ -190,16 +190,16 @@ (255 x 5 + 1) = 1276 bytes per column. */ #define TEX_COLUMNSIZE 1300 - ColumnData = (u8 *) GetMemory(TEX_COLUMNBUFFERSIZE); + ColumnData = (uint8_t *) GetMemory(TEX_COLUMNBUFFERSIZE); // FIXME DOS and pic_width_ > 16000 - NeededOffsets = (i32 *) GetMemory((long) pic_width_ * sizeof(i32)); + NeededOffsets = (int32_t *) GetMemory((long) pic_width_ * sizeof(int32_t)); if (long_offsets) dir->wadfile->read_i32(NeededOffsets, pic_width_); else for (int n = 0; n < pic_width_; n++) { - i16 ofs; + int16_t ofs; dir->wadfile->read_i16(&ofs); NeededOffsets[n] = ofs; } @@ -252,7 +252,7 @@ buf = img.wbuf() + al_amax(pic_x_offset, 0) + img_width * pic_y_offset; pic_x <= pic_x1; pic_x++, buf++) { - u8 *filedata; + uint8_t *filedata; CurrentOffset = NeededOffsets[pic_x]; ColumnInMemory = CurrentOffset >= NeededOffsets[0] @@ -263,7 +263,7 @@ Column = ColumnData + CurrentOffset - NeededOffsets[0]; else { - Column = (u8 *) GetMemory(TEX_COLUMNSIZE); + Column = (uint8_t *) GetMemory(TEX_COLUMNSIZE); dir->wadfile->seek(dir->dir.start + CurrentOffset); if (dir->wadfile->error()) { @@ -282,7 +282,7 @@ // For each post of the column... { - register u8 *post; + register uint8_t *post; for (post = filedata; *post != 0xff;) { int post_y_offset; // Y-offset of top of post to origin of buffer @@ -323,8 +323,8 @@ { // "Paste" the post onto the buffer register img_pixel_t *b; - register const u8 *p = post + post_y0; - const u8 *const pmax = post + post_y1; + register const uint8_t *p = post + post_y0; + const uint8_t *const pmax = post + post_y1; int buf_width = img_width; for (b = buf + buf_width * (post_y_offset + post_y0); diff -r c91965fc33b6 -r f05330267c66 src/r_images.cc --- a/src/r_images.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/r_images.cc Mon Oct 06 12:59:23 2014 +0300 @@ -101,12 +101,12 @@ Img *Tex2Img(const wad_tex_name_t & texname) { MDirPtr dir = 0; // main directory pointer to the TEXTURE* entries - i32 *offsets; // array of offsets to texture names + int32_t *offsets; // array of offsets to texture names int n; // general counter - i16 width, height; // size of the texture - i16 npatches; // number of wall patches used to build this texture - i32 numtex; // number of texture names in TEXTURE* list - i32 texofs; // offset in the wad file to the texture data + int16_t width, height; // size of the texture + int16_t npatches; // number of wall patches used to build this texture + int32_t numtex; // number of texture names in TEXTURE* list + int32_t texofs; // offset in the wad file to the texture data char tname[WAD_TEX_NAME + 1]; // texture name char picname[WAD_PIC_NAME + 1]; // wall patch name bool have_dummy_bytes; @@ -183,7 +183,7 @@ dir->wadfile->seek(dir->dir.start); dir->wadfile->read_i32(&numtex); // read in the offsets for texture1 names and info. - offsets = (i32 *) GetMemory((long) numtex * 4); + offsets = (int32_t *) GetMemory((long) numtex * 4); dir->wadfile->read_i32(offsets, numtex); for (n = 0; n < numtex && !texofs; n++) { @@ -207,7 +207,7 @@ dir->wadfile->seek(dir->dir.start); dir->wadfile->read_i32(&numtex); // read in the offsets for texture1 names and info. - offsets = (i32 *) GetMemory((long) numtex * 4); + offsets = (int32_t *) GetMemory((long) numtex * 4); dir->wadfile->read_i32(offsets, numtex); for (n = 0; n < numtex && !texofs; n++) { @@ -227,7 +227,7 @@ dir->wadfile->seek(dir->dir.start); dir->wadfile->read_i32(&numtex); // read in the offsets for texture2 names - offsets = (i32 *) GetMemory((long) numtex * 4); + offsets = (int32_t *) GetMemory((long) numtex * 4); dir->wadfile->read_i32(offsets, numtex); for (n = 0; n < numtex && !texofs; n++) { @@ -248,7 +248,7 @@ return 0; // read the info for this texture - i32 header_ofs; + int32_t header_ofs; if (yg_texture_format == YGTF_NAMELESS) header_ofs = texofs; else @@ -259,7 +259,7 @@ dir->wadfile->read_i16(&height); if (have_dummy_bytes) { - i16 dummy; + int16_t dummy; dir->wadfile->read_i16(&dummy); dir->wadfile->read_i16(&dummy); } @@ -271,8 +271,8 @@ // Paste onto the buffer all the patches that the texture is made of. for (n = 0; n < npatches; n++) { - i16 xofs, yofs; // offset in texture space for the patch - i16 pnameind; // index of patch in PNAMES + int16_t xofs, yofs; // offset in texture space for the patch + int16_t pnameind; // index of patch in PNAMES dir->wadfile->seek(header_ofs + header_size + (long) n * item_size); dir->wadfile->read_i16(&xofs); @@ -281,8 +281,8 @@ if (have_dummy_bytes) { - i16 stepdir; - i16 colormap; + int16_t stepdir; + int16_t colormap; dir->wadfile->read_i16(&stepdir); // Always 1, unused. dir->wadfile->read_i16(&colormap); // Always 0, unused. } diff -r c91965fc33b6 -r f05330267c66 src/rgb.h --- a/src/rgb.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/rgb.h Mon Oct 06 12:59:23 2014 +0300 @@ -38,14 +38,14 @@ } // Must be defined before rbg_c (r, g, b) - void set(u8 red, u8 green, u8 blue) + void set(uint8_t red, uint8_t green, uint8_t blue) { r = red; g = green; b = blue; } - rgb_c(u8 red, u8 green, u8 blue) + rgb_c(uint8_t red, uint8_t green, uint8_t blue) { set(red, green, blue); } @@ -60,9 +60,9 @@ return abs(rgb2.r - r) + abs(rgb2.g - g) + abs(rgb2.b - b); } - u8 r; - u8 g; - u8 b; + uint8_t r; + uint8_t g; + uint8_t b; }; diff -r c91965fc33b6 -r f05330267c66 src/rgbbmp.h --- a/src/rgbbmp.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/rgbbmp.h Mon Oct 06 12:59:23 2014 +0300 @@ -4,7 +4,7 @@ * * This is a simple bitmap where each pixel is an RGB * triplet. Each component is coded as an 8-bit unsigned - * integer (of type u8). + * integer (of type int8_t). * * AYM 1999-06-06 */ @@ -39,9 +39,9 @@ typedef struct { - u8 r; - u8 g; - u8 b; + uint8_t r; + uint8_t g; + uint8_t b; } Rgbbmp_pixel_t; @@ -94,46 +94,46 @@ memset(pixel, 0, _width * _height * sizeof *pixel); } - void get(int x, int y, u8 & r, u8 & g, u8 & b) const + void get(int x, int y, uint8_t & r, uint8_t & g, uint8_t & b) const { r = pixel[y * _width + x].r; g = pixel[y * _width + x].g; b = pixel[y * _width + x].b; } - u8 get_r(int x, int y) const + uint8_t get_r(int x, int y) const { return pixel[y * _width + x].r; } - u8 get_g(int x, int y) const + uint8_t get_g(int x, int y) const { return pixel[y * _width + x].g; } - u8 get_b(int x, int y) const + uint8_t get_b(int x, int y) const { return pixel[y * _width + x].b; } - void set(int x, int y, u8 r, u8 g, u8 b) + void set(int x, int y, uint8_t r, uint8_t g, uint8_t b) { pixel[y * _width + x].r = r; pixel[y * _width + x].g = g; pixel[y * _width + x].b = b; } - void set_r(int x, int y, u8 r) + void set_r(int x, int y, uint8_t r) { pixel[y * _width + x].r = r; } - void set_g(int x, int y, u8 g) + void set_g(int x, int y, uint8_t g) { pixel[y * _width + x].g = g; } - void set_b(int x, int y, u8 b) + void set_b(int x, int y, uint8_t b) { pixel[y * _width + x].b = b; } diff -r c91965fc33b6 -r f05330267c66 src/sanity.cc --- a/src/sanity.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/sanity.cc Mon Oct 06 12:59:23 2014 +0300 @@ -40,44 +40,45 @@ * Useful when porting. */ -#define assert_size(type,size) \ - do \ - { \ - if (sizeof (type) != size) \ - fatal_error ("sizeof " #type " is %d (should be " #size ")", \ +#define assert_size(type,size) \ + do \ + { \ + if (sizeof (type) != size) \ + fatal_error ("sizeof " #type " is %d (should be " #size ")", \ (int) sizeof (type)); \ - } \ + } \ while (0) -#define assert_wrap(type,high,low) \ - do \ - { \ - type n = high; \ - if (++n != low) \ +#define assert_wrap(type,high,low) \ + do \ + { \ + type n = high; \ + if (++n != low) \ fatal_error ("Type " #type " wraps around to %lu (should be " #low ")",\ - (unsigned long) n); \ - } \ + (unsigned long) n); \ + } \ while (0) + void check_types() { - assert_size(u8, 1); - assert_size(i8, 1); - assert_size(u16, 2); - assert_size(i16, 2); - assert_size(u32, 4); - assert_size(i32, 4); + assert_size(uint8_t, 1); + assert_size(int8_t, 1); + assert_size(uint16_t, 2); + assert_size(int16_t, 2); + assert_size(uint32_t, 4); + assert_size(int32_t, 4); assert_size(struct LineDef, 14); assert_size(struct Sector, 26); assert_size(struct SideDef, 30); assert_size(struct Thing, 10); assert_size(struct Vertex, 4); - assert_wrap(u8, 255, 0); - assert_wrap(i8, 127, -128); - assert_wrap(u16, 65535, 0); - assert_wrap(i16, 32767, -32768); - assert_wrap(u32, 4294967295u, 0); - assert_wrap(i32, 2147483647, -2147483648); + assert_wrap(uint8_t, 255, 0); + assert_wrap(int8_t, 127, -128); + assert_wrap(uint16_t, 65535, 0); + assert_wrap(int16_t, 32767, -32768); + assert_wrap(uint32_t, 4294967295u, 0); + assert_wrap(int32_t, 2147483647, -2147483648); } diff -r c91965fc33b6 -r f05330267c66 src/sticker.cc --- a/src/sticker.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/sticker.cc Mon Oct 06 12:59:23 2014 +0300 @@ -232,7 +232,7 @@ bytes_per_line++; padding++; } - u8 *buf = (u8 *) GetMemory((unsigned long) bytes_per_line * height); + uint8_t *buf = (uint8_t *) GetMemory((unsigned long) bytes_per_line * height); if (!buf) { err("Not enough memory to display %dx%d image", width, height); @@ -244,11 +244,11 @@ if (ximage_bpp == 1) { register const img_pixel_t *image_ptr; - register u8 *buf_ptr = (u8 *) buf; + register uint8_t *buf_ptr = (uint8_t *) buf; if (padding == 0) { for (image_ptr = img.buf(); image_ptr < image_end; image_ptr++) - *buf_ptr++ = (u8) game_colour[*image_ptr]; + *buf_ptr++ = (int8_t) game_colour[*image_ptr]; } else { @@ -259,7 +259,7 @@ { image_line_end += img_width; for (; image_ptr < image_line_end; image_ptr++) - *buf_ptr++ = (u8) game_colour[*image_ptr]; + *buf_ptr++ = (int8_t) game_colour[*image_ptr]; buf_ptr += padding; // Line padding } } @@ -268,14 +268,14 @@ else if (ximage_bpp == 2) { register const img_pixel_t *image_ptr; - register u16 *buf_ptr = (u16 *) buf; + register uint16_t *buf_ptr = (uint16_t *) buf; if (cfg.cpu_big_endian == x_server_big_endian) { if (padding == 0) { for (image_ptr = img.buf(); image_ptr < image_end; image_ptr++) - *buf_ptr++ = (u16) game_colour[*image_ptr]; + *buf_ptr++ = (int16_t) game_colour[*image_ptr]; } else { @@ -286,8 +286,8 @@ { image_line_end += img_width; for (; image_ptr < image_line_end; image_ptr++) - *buf_ptr++ = (u16) game_colour[*image_ptr]; - buf_ptr = (u16 *) ((char *) buf_ptr + padding); // Line padding + *buf_ptr++ = (int16_t) game_colour[*image_ptr]; + buf_ptr = (uint16_t *) ((char *) buf_ptr + padding); // Line padding } } } @@ -297,7 +297,7 @@ { for (image_ptr = img.buf(); image_ptr < image_end; image_ptr++) - *buf_ptr++ = (u16) ((game_colour[*image_ptr] >> 8) // Assume game_colour unsigned + *buf_ptr++ = (int16_t) ((game_colour[*image_ptr] >> 8) // Assume game_colour unsigned | (game_colour[*image_ptr] << 8)); } else @@ -309,9 +309,9 @@ { image_line_end += img_width; for (; image_ptr < image_line_end; image_ptr++) - *buf_ptr++ = (u16) ((game_colour[*image_ptr] >> 8) // Assume game_colour uns. + *buf_ptr++ = (int16_t) ((game_colour[*image_ptr] >> 8) // Assume game_colour uns. | (game_colour[*image_ptr] << 8)); - buf_ptr = (u16 *) ((char *) buf_ptr + padding); // Line padding + buf_ptr = (uint16_t *) ((char *) buf_ptr + padding); // Line padding } } } @@ -346,14 +346,14 @@ else if (ximage_bpp == 4) { register const img_pixel_t *image_ptr; - register u32 *buf_ptr = (u32 *) buf; + register uint32_t *buf_ptr = (uint32_t *) buf; if (cfg.cpu_big_endian == x_server_big_endian) { if (padding == 0) { for (image_ptr = img.buf(); image_ptr < image_end; image_ptr++) - *buf_ptr++ = (u32) game_colour[*image_ptr]; + *buf_ptr++ = (int32_t) game_colour[*image_ptr]; } else { @@ -364,8 +364,8 @@ { image_line_end += img_width; for (; image_ptr < image_line_end; image_ptr++) - *buf_ptr++ = (u32) game_colour[*image_ptr]; - buf_ptr = (u32 *) ((char *) buf_ptr + padding); // Line padding + *buf_ptr++ = (int32_t) game_colour[*image_ptr]; + buf_ptr = (uint32_t *) ((char *) buf_ptr + padding); // Line padding } } } @@ -374,7 +374,7 @@ if (padding == 0) { for (image_ptr = img.buf(); image_ptr < image_end; image_ptr++) - *buf_ptr++ = (u32) + *buf_ptr++ = (int32_t) ((game_colour[*image_ptr] >> 24) | ((game_colour[*image_ptr] >> 8) & 0x0000ff00) | ((game_colour[*image_ptr] << 8) & 0x00ff0000) | @@ -389,12 +389,12 @@ { image_line_end += img_width; for (; image_ptr < image_line_end; image_ptr++) - *buf_ptr++ = (u32) + *buf_ptr++ = (int32_t) ((game_colour[*image_ptr] >> 24) | ((game_colour[*image_ptr] >> 8) & 0x0000ff00) | ((game_colour[*image_ptr] << 8) & 0x00ff0000) | (game_colour[*image_ptr] << 24)); - buf_ptr = (u32 *) ((char *) buf_ptr + padding); // Line padding + buf_ptr = (uint32_t *) ((char *) buf_ptr + padding); // Line padding } } } @@ -441,7 +441,7 @@ const size_t bitmap_pad = BitmapPad(dpy); const size_t bytes_per_line = (width + bitmap_pad - 1) / bitmap_pad * bitmap_pad / CHAR_BIT; - u8 *buf = (u8 *) GetMemory((unsigned long) bytes_per_line * height); + uint8_t *buf = (uint8_t *) GetMemory((unsigned long) bytes_per_line * height); if (!buf) { err("Not enough memory to display %dx%d image", width, height); @@ -451,22 +451,22 @@ // Copy the "profile" of the Img onto the XImage { int bitmap_bit_order = BitmapBitOrder(dpy); - register u8 *buf_ptr = (u8 *) buf; + register uint8_t *buf_ptr = (uint8_t *) buf; const int IMG_TRANSP = 0; const img_pixel_t *image_ptr = img.buf(); const img_pixel_t *const image_end = image_ptr + width * height; while (image_ptr < image_end) { - register const u8 *src = image_ptr; - const u8 *const stop1 = src + width - 7; - const u8 *const stop2 = image_ptr + width; - u8 *dest = buf_ptr; + register const uint8_t *src = image_ptr; + const uint8_t *const stop1 = src + width - 7; + const uint8_t *const stop2 = image_ptr + width; + uint8_t *dest = buf_ptr; if (bitmap_bit_order == LSBFirst) { while (src < stop1) { - register u8 d = 0; + register uint8_t d = 0; if (*src++ != IMG_TRANSP) d |= 1; if (*src++ != IMG_TRANSP) @@ -487,7 +487,7 @@ } if (src < stop2) { - register u8 d = 0; + register uint8_t d = 0; if (*src++ != IMG_TRANSP) d |= 1; if (src >= stop2) @@ -526,7 +526,7 @@ { while (src < stop1) { - register u8 d = 0; + register uint8_t d = 0; if (*src++ != IMG_TRANSP) d |= 128; if (*src++ != IMG_TRANSP) @@ -547,7 +547,7 @@ } if (src < stop2) { - register u8 d = 0; + register uint8_t d = 0; if (*src++ != IMG_TRANSP) d |= 128; if (src >= stop2) diff -r c91965fc33b6 -r f05330267c66 src/t_flags.cc --- a/src/t_flags.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/t_flags.cc Mon Oct 06 12:59:23 2014 +0300 @@ -42,7 +42,7 @@ void frob_things_flags(SelPtr list, int op, int operand) { SelPtr cur; - i16 mask; + int16_t mask; if (op == YO_CLEAR || op == YO_SET || op == YO_TOGGLE) mask = 1 << operand; diff -r c91965fc33b6 -r f05330267c66 src/textures.cc --- a/src/textures.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/textures.cc Mon Oct 06 12:59:23 2014 +0300 @@ -78,10 +78,10 @@ { MDirPtr dir = 0; // Main directory pointer to the TEXTURE* entries int n; // General counter - i16 width, height; // Size of the texture - i16 npatches; // Number of patches in the textures - i32 numtex; // number of texture names in TEXTURE* list - i32 texofs; // Offset in the wad file to the texture data + int16_t width, height; // Size of the texture + int16_t npatches; // Number of patches in the textures + int32_t numtex; // number of texture names in TEXTURE* list + int32_t texofs; // Offset in the wad file to the texture data char tname[WAD_TEX_NAME + 1]; // texture name char picname[WAD_PIC_NAME + 1]; // wall patch name bool have_dummy_bytes; @@ -190,7 +190,7 @@ dir = FindMasterDir(cfg.MasterDir, lump_name); if (dir != NULL) // (Theoretically, it should always exist) { - i32 *offsets = NULL; // Array of offsets to texture names + int32_t *offsets = NULL; // Array of offsets to texture names const Wad_file *wf = dir->wadfile; wf->seek(dir->dir.start); @@ -206,7 +206,7 @@ goto textures_done; } // Read in the offsets for texture1 names and info - offsets = (i32 *) GetMemory((long) numtex * 4); + offsets = (int32_t *) GetMemory((long) numtex * 4); wf->read_i32(offsets, numtex); if (wf->error()) { @@ -249,7 +249,7 @@ if (dir != NULL) // (Theoretically, it should always exist) { const Wad_file *wf = dir->wadfile; - i32 *offsets = NULL; // Array of offsets to texture names + int32_t *offsets = NULL; // Array of offsets to texture names wf->seek(dir->dir.start); if (wf->error()) @@ -264,7 +264,7 @@ goto texture1_done; } // Read in the offsets for texture1 names and info - offsets = (i32 *) GetMemory((long) numtex * 4); + offsets = (int32_t *) GetMemory((long) numtex * 4); wf->read_i32(offsets, numtex); if (wf->error()) { @@ -298,7 +298,7 @@ if (texofs == 0) { const char *lump_name = "TEXTURE2"; - i32 *offsets = NULL; // Array of offsets to texture names + int32_t *offsets = NULL; // Array of offsets to texture names dir = FindMasterDir(cfg.MasterDir, lump_name); if (dir != NULL) // Doom II has no TEXTURE2 @@ -317,7 +317,7 @@ goto texture2_done; } // Read in the offsets for TEXTURE2 names - offsets = (i32 *) GetMemory((long) numtex * 4); + offsets = (int32_t *) GetMemory((long) numtex * 4); wf->read_i32(offsets, numtex); if (wf->error()) { @@ -356,7 +356,7 @@ return; // Read the info for this texture - i32 header_ofs; + int32_t header_ofs; if (yg_texture_format == YGTF_NAMELESS) header_ofs = texofs; else @@ -369,7 +369,7 @@ // FIXME if (have_dummy_bytes) { - i16 dummy; + int16_t dummy; dir->wadfile->read_i16(&dummy); dir->wadfile->read_i16(&dummy); } @@ -399,8 +399,8 @@ for (n = 0; n < maxpatches; n++) { hookfunc_comm_t subc; - i16 xofs, yofs; // Offset in texture space for the patch - i16 pnameind; // Index of patch in PNAMES + int16_t xofs, yofs; // Offset in texture space for the patch + int16_t pnameind; // Index of patch in PNAMES dir->wadfile->seek(header_ofs + header_size + (long) n * item_size); dir->wadfile->read_i16(&xofs); @@ -408,8 +408,8 @@ dir->wadfile->read_i16(&pnameind); if (have_dummy_bytes) { - i16 stepdir; - i16 colormap; + int16_t stepdir; + int16_t colormap; dir->wadfile->read_i16(&stepdir); // Always 1, unused. dir->wadfile->read_i16(&colormap); // Always 0, unused. } @@ -467,13 +467,13 @@ /* Function to get the size of a wall texture */ -void GetWallTextureSize(i16 * width, i16 * height, const char *texname) +void GetWallTextureSize(int16_t * width, int16_t * height, const char *texname) { MDirPtr dir = 0; // Pointer in main directory to texname - i32 *offsets; // Array of offsets to texture names + int32_t *offsets; // Array of offsets to texture names int n; // General counter - i32 numtex; // Number of texture names in TEXTURE* - i32 texofs; // Offset in wad for the texture data + int32_t numtex; // Number of texture names in TEXTURE* + int32_t texofs; // Offset in wad for the texture data char tname[WAD_TEX_NAME + 1]; // Texture name // Offset for texture we want @@ -527,7 +527,7 @@ warn("Could not seek or read the textures directory (1).\n"); // Read in the offsets for texture1 names and info - offsets = (i32 *) GetMemory((long) numtex * 4); + offsets = (int32_t *) GetMemory((long) numtex * 4); dir->wadfile->read_i32(offsets, numtex); for (n = 0; n < numtex && !texofs; n++) { @@ -556,7 +556,7 @@ warn("Could not seek or read the textures directory (2).\n"); // Read in the offsets for texture2 names - offsets = (i32 *) GetMemory((long) numtex * 4); + offsets = (int32_t *) GetMemory((long) numtex * 4); dir->wadfile->read_i32(offsets, numtex); for (n = 0; n < numtex && !texofs; n++) { diff -r c91965fc33b6 -r f05330267c66 src/textures.h --- a/src/textures.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/textures.h Mon Oct 06 12:59:23 2014 +0300 @@ -14,7 +14,7 @@ /* textures.cc */ void DisplayPic(hookfunc_comm_t * c); void ChooseWallTexture(int, int, const char *, int, char **, char *); -void GetWallTextureSize(i16 *, i16 *, const char *); +void GetWallTextureSize(int16_t *, int16_t *, const char *); bool InvalidTextureName(const char *); bool ValidTextureName(const char *); diff -r c91965fc33b6 -r f05330267c66 src/wadfile.cc --- a/src/wadfile.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/wadfile.cc Mon Oct 06 12:59:23 2014 +0300 @@ -153,14 +153,14 @@ /* - * Wad_file::read_u8 - read a byte + * Wad_file::read_uint8_t - read a byte * * If an error occurs, set the error flag and the return * value is undefined. */ -u8 Wad_file::read_u8() const +uint8_t Wad_file::read_u8() const { - u8 v = u8(getc(fp)); + uint8_t v = getc(fp); if (feof(fp) || ferror(fp)) { @@ -173,12 +173,12 @@ /* - * Wad_file::read_u8 - read a byte + * Wad_file::read_uint8_t - read a byte * * If an error occurs, set the error flag and the contents * of buf is undefined. */ -void Wad_file::read_u8(u8 & buf) const +void Wad_file::read_u8(uint8_t & buf) const { buf = getc(fp); @@ -192,17 +192,16 @@ /* - * Wad_file::read_i16 - read a little-endian 16-bit signed integer + * Wad_file::read_int16_t - read a little-endian 16-bit signed integer * * If an error occurs, set the error flag and the return * value is undefined. */ -i16 Wad_file::read_i16() const +int16_t Wad_file::read_i16() const { - const size_t nbytes = 2; - u8 buf[nbytes]; + uint8_t buf[2]; - if (fread(buf, 1, nbytes, fp) != nbytes) + if (fread(buf, 1, sizeof(buf), fp) != sizeof(buf)) { if (!error_) err("%s: read error", where()); @@ -214,12 +213,12 @@ /* - * Wad_file::read_i16 - read a little-endian 16-bit signed integer + * Wad_file::read_int16_t - read a little-endian 16-bit signed integer * * The value read is stored in *buf. If an error occurs, * set the error flag and the contents of *buf is undefined. */ -void Wad_file::read_i16(i16 * buf) const +void Wad_file::read_i16(int16_t * buf) const { *buf = getc(fp) | (getc(fp) << 8); @@ -233,19 +232,19 @@ /* - * Wad_file::read_i32 - read little-endian 32-bit signed integers + * Wad_file::read_int32_t - read little-endian 32-bit signed integers * * Read little-endian 32-bit signed integers from * wad file into *buf. If an error occurs, set * error_ and the contents of *buf is undefined. */ -void Wad_file::read_i32(i32 * buf, long count) const +void Wad_file::read_i32(int32_t * buf, long count) const { while (count-- > 0) { *buf++ = getc(fp) | (getc(fp) << 8) - | ((i32) getc(fp) << 16) | ((i32) getc(fp) << 24); + | ((int32_t) getc(fp) << 16) | ((int32_t) getc(fp) << 24); } if (feof(fp) || ferror(fp)) diff -r c91965fc33b6 -r f05330267c66 src/wadfile.h --- a/src/wadfile.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/wadfile.h Mon Oct 06 12:59:23 2014 +0300 @@ -130,11 +130,11 @@ bool error() const; const char *where() const; void seek(long offset) const; - u8 read_u8() const; - void read_u8(u8 & buf) const; - i16 read_i16() const; - void read_i16(i16 * buf) const; - void read_i32(i32 * buf, long count = 1) const; + uint8_t read_u8() const; + void read_u8(uint8_t & buf) const; + int16_t read_i16() const; + void read_i16(int16_t * buf) const; + void read_i32(int32_t * buf, long count = 1) const; void read_bytes(void *buf, long count) const; long read_vbytes(void *buf, long count) const; const char *what() const; @@ -144,8 +144,8 @@ ygpf_t pic_format_; // Picture format (usually PF_NORMAL) FILE *fp; // C file stream information char type[4]; // Type of wad file ("IWAD" or "PWAD") - i32 dirsize; // Entries in directory - i32 dirstart; // Offset to start of directory + int32_t dirsize; // Entries in directory + int32_t dirstart; // Offset to start of directory DirPtr directory; // Array of directory information mutable bool error_; // I/O error occur since last error() mutable char where_[101]; // Static workspace for where() diff -r c91965fc33b6 -r f05330267c66 src/wads.cc --- a/src/wads.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/wads.cc Mon Oct 06 12:59:23 2014 +0300 @@ -34,11 +34,11 @@ /* - * file_read_i16 - read little-endian 16-bit signed integers from a file + * file_read_int16_t - read little-endian 16-bit signed integers from a file * * Return 0 on success, non-zero on failure. */ -int file_read_i16(FILE * fp, i16 * buf, long count) +int file_read_i16(FILE * fp, int16_t * buf, long count) { while (count-- > 0) *buf = getc(fp) | (getc(fp) << 8); @@ -47,17 +47,17 @@ /* - * file_read_i32 - read little-endian 32-bit signed integers from a file + * file_read_int32_t - read little-endian 32-bit signed integers from a file * * Return 0 on success, non-zero on failure. */ -int file_read_i32(FILE * fp, i32 * buf, long count) +int file_read_i32(FILE * fp, int32_t * buf, long count) { while (count-- > 0) { *buf++ = getc(fp) | (getc(fp) << 8) - | ((i32) getc(fp) << 16) | ((i32) getc(fp) << 24); + | ((int32_t) getc(fp) << 16) | ((int32_t) getc(fp) << 24); } return feof(fp) || ferror(fp); } @@ -103,11 +103,11 @@ /* - * file_write_i16 - write a little-endian 16-bit signed integer to a file + * file_write_int16_t - write a little-endian 16-bit signed integer to a file * * Does no error checking. */ -void file_write_i16(FILE * fd, i16 buf) +void file_write_i16(FILE * fd, int16_t buf) { putc(buf & 0xff, fd); putc((buf >> 8) & 0xff, fd); @@ -115,14 +115,14 @@ /* - * file_write_i32 - write little-endian 32-bit signed integers to a file + * file_write_int32_t - write little-endian 32-bit signed integers to a file * * Does no error checking. */ -void file_write_i32(FILE * fd, i32 buf, long count) +void file_write_i32(FILE * fd, int32_t buf, long count) { /* It would probably be more efficient to swap bytes in-core - and write the whole i32 at once. */ + and write the whole int32_t at once. */ while (count-- > 0) { putc(buf & 0xff, fd); diff -r c91965fc33b6 -r f05330267c66 src/wads.h --- a/src/wads.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/wads.h Mon Oct 06 12:59:23 2014 +0300 @@ -8,12 +8,12 @@ #define YH_WADS -int file_read_i16(FILE *, i16 * buf, long count = 1); -int file_read_i32(FILE *, i32 * buf, long count = 1); +int file_read_i16(FILE *, int16_t * buf, long count = 1); +int file_read_i32(FILE *, int32_t * buf, long count = 1); long file_read_vbytes(FILE *, void *buf, long count); int file_read_bytes(FILE *, void *buf, long count); -void file_write_i16(FILE *, i16 buf); -void file_write_i32(FILE *, i32 buf, long count = 1); +void file_write_i16(FILE *, int16_t buf); +void file_write_i32(FILE *, int32_t buf, long count = 1); void file_write_name(FILE *, const char *name); void WriteBytes(FILE *, const void *, long); int copy_bytes(FILE * dest, FILE * source, long size); @@ -22,9 +22,9 @@ void wad_seek(WadPtr, long offset); void wad_read_bytes(WadPtr, void *buf, long count); long wad_read_vbytes(WadPtr, void *buf, long count); -i16 wad_read_i16(WadPtr); -void wad_read_i16(WadPtr, i16 * buf); -void wad_read_i32(WadPtr, i32 * buf, long count = 1); +int16_t wad_read_i16(WadPtr); +void wad_read_i16(WadPtr, int16_t * buf); +void wad_read_i32(WadPtr, int32_t * buf, long count = 1); #endif diff -r c91965fc33b6 -r f05330267c66 src/wads2.cc --- a/src/wads2.cc Mon Oct 06 12:46:32 2014 +0300 +++ b/src/wads2.cc Mon Oct 06 12:59:23 2014 +0300 @@ -479,7 +479,7 @@ fail = true; goto byebye; } - for (i32 n = 0; n < wf->dirsize; n++) + for (int32_t n = 0; n < wf->dirsize; n++) { bool e = file_read_i32(wf->fp, &wf->directory[n].start); e |= file_read_i32(wf->fp, &wf->directory[n].size); diff -r c91965fc33b6 -r f05330267c66 src/wstructs.h --- a/src/wstructs.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/wstructs.h Mon Oct 06 12:59:23 2014 +0300 @@ -44,8 +44,8 @@ typedef struct Directory *DirPtr; struct Directory { - i32 start; // Offset to start of data - i32 size; // Byte size of data + int32_t start; // Offset to start of data + int32_t size; // Byte size of data wad_name_t name; // Name of data block }; @@ -66,22 +66,22 @@ // Level objects properties -typedef i16 wad_coord_t; // Map (X,Y) coordinates -typedef i16 wad_ldn_t; // Linedef# -typedef i16 wad_sdn_t; // Sidedef# -typedef i16 wad_sn_t; // Sector# -typedef i16 wad_tag_t; // Tag -typedef i16 wad_tn_t; // Thing# (theor. there might be more) -typedef i16 wad_vn_t; // Vertex# -typedef i16 wad_z_t; // Map Z coordinate +typedef int16_t wad_coord_t; // Map (X,Y) coordinates +typedef int16_t wad_ldn_t; // Linedef# +typedef int16_t wad_sdn_t; // Sidedef# +typedef int16_t wad_sn_t; // Sector# +typedef int16_t wad_tag_t; // Tag +typedef int16_t wad_tn_t; // Thing# (theor. there might be more) +typedef int16_t wad_vn_t; // Vertex# +typedef int16_t wad_z_t; // Map Z coordinate // Things const size_t WAD_THING_BYTES = 10; // Size in the wad file const size_t WAD_HEXEN_THING_BYTES = 20; // Size in the wad file -typedef i16 wad_ttype_t; -typedef i16 wad_tangle_t; -typedef i16 wad_tflags_t; +typedef int16_t wad_ttype_t; +typedef int16_t wad_tangle_t; +typedef int16_t wad_tflags_t; struct Thing { wad_coord_t xpos; // FIXME rename to "x" @@ -92,19 +92,19 @@ }; typedef struct { - i16 tid; + int16_t tid; wad_coord_t x; wad_coord_t y; wad_z_t height; wad_tangle_t angle; wad_ttype_t type; - i16 options; - u8 special; - u8 arg1; - u8 arg2; - u8 arg3; - u8 arg4; - u8 arg5; + int16_t options; + uint8_t special; + uint8_t arg1; + uint8_t arg2; + uint8_t arg3; + uint8_t arg4; + uint8_t arg5; } wad_hexen_thing_t; typedef struct Thing *TPtr; @@ -112,8 +112,8 @@ // Linedefs const size_t WAD_LINEDEF_BYTES = 14; // Size in the wad file const size_t WAD_HEXEN_LINEDEF_BYTES = 16; // Size in the wad file -typedef i16 wad_ldflags_t; -typedef i16 wad_ldtype_t; +typedef int16_t wad_ldflags_t; +typedef int16_t wad_ldtype_t; struct LineDef { wad_vn_t start; // # of start vertex @@ -129,12 +129,12 @@ wad_vn_t start; wad_vn_t end; wad_ldflags_t flags; - u8 type; - u8 arg1; - u8 arg2; - u8 arg3; - u8 arg4; - u8 arg5; + uint8_t type; + uint8_t arg1; + uint8_t arg2; + uint8_t arg3; + uint8_t arg4; + uint8_t arg5; wad_sdn_t sidedef1; wad_sdn_t sidedef2; } wad_hexen_linedef_t; @@ -169,14 +169,14 @@ // Sectors const size_t WAD_SECTOR_BYTES = 26; // Size in the wad file -typedef i16 wad_stype_t; +typedef int16_t wad_stype_t; struct Sector { wad_z_t floorh; // Floor height wad_z_t ceilh; // Ceiling height wad_flat_name_t floort; // Name of floor texture wad_flat_name_t ceilt; // Name of ceiling texture - i16 light; // Light level (0-255) + int16_t light; // Light level (0-255) wad_stype_t special; // FIXME rename to "type" wad_tag_t tag; }; diff -r c91965fc33b6 -r f05330267c66 src/yadex.h --- a/src/yadex.h Mon Oct 06 12:46:32 2014 +0300 +++ b/src/yadex.h Mon Oct 06 12:59:23 2014 +0300 @@ -50,6 +50,7 @@ #include #include #include +#include #ifdef Y_UNIX #include #endif @@ -63,31 +64,8 @@ #include "aym.h" /* Needs yerror.h */ #include "windim.h" #include "ymemory.h" - #include "serialnum.h" -/* - * Platform-independant types and formats. - */ -typedef unsigned char u8; -typedef signed char i8; - -typedef unsigned short u16; -#define F_U16_D "hu" -#define F_U16_H "hX" - -typedef signed short i16; -#define F_I16_D "hd" -#define F_I16_H "hX" - -typedef unsigned long u32; -#define F_U32_D "lu" -#define F_U32_H "lX" - -typedef signed long i32; -#define F_I32_D "ld" -#define F_I32_H "lX" - /* * Platform definitions @@ -170,7 +148,7 @@ { wad = 0; } - Lump_loc(const Wad_file * w, i32 o, i32 l) + Lump_loc(const Wad_file * w, int32_t o, int32_t l) { wad = w; ofs = o; @@ -181,8 +159,8 @@ return wad == other.wad && ofs == other.ofs && len == other.len; } const Wad_file *wad; - i32 ofs; - i32 len; + int32_t ofs; + int32_t len; }; #include "wstructs.h" @@ -198,7 +176,7 @@ /* acolour_t -- an application colour number. Several different application colours may refer to the same physical colour. */ -typedef u8 acolour_t; +typedef uint8_t acolour_t; #define ACOLOUR_NONE 0xff // The out-of-band value /* The 16 VGA colours that DEU used to use.