unsigned short -> uint16_t

master
an 2019-11-25 17:09:48 -05:00
parent 34c4b96309
commit ab64303a7f
26 changed files with 129 additions and 129 deletions

View File

@ -169,8 +169,8 @@ typedef struct
short children[2]; // negative numbers are -(leafs+1), not nodes
short mins[3]; // for sphere culling
short maxs[3];
unsigned short firstface;
unsigned short numfaces; // counting both sides
uint16_t firstface;
uint16_t numfaces; // counting both sides
} dsnode_t;
typedef struct
@ -219,7 +219,7 @@ typedef struct texinfo_s
// counterclockwise use of the edge in a face
typedef struct
{
unsigned short v[2]; // vertex numbers
uint16_t v[2]; // vertex numbers
} dsedge_t;
typedef struct
@ -273,8 +273,8 @@ typedef struct
short mins[3]; // for frustum culling
short maxs[3];
unsigned short firstmarksurface;
unsigned short nummarksurfaces;
uint16_t firstmarksurface;
uint16_t nummarksurfaces;
byte ambient_level[NUM_AMBIENTS];
} dsleaf_t;

View File

@ -155,18 +155,18 @@ void CL_ParseStartSoundPacket(void)
//johnfitz -- PROTOCOL_FITZQUAKE
if (field_mask & SND_LARGEENTITY)
{
ent = (unsigned short) MSG_ReadShort ();
ent = (uint16_t) MSG_ReadShort ();
channel = MSG_ReadByte ();
}
else
{
channel = (unsigned short) MSG_ReadShort ();
channel = (uint16_t) MSG_ReadShort ();
ent = channel >> 3;
channel &= 7;
}
if (field_mask & SND_LARGESOUND)
sound_num = (unsigned short) MSG_ReadShort ();
sound_num = (uint16_t) MSG_ReadShort ();
else
sound_num = MSG_ReadByte ();
//johnfitz
@ -670,7 +670,7 @@ void CL_ParseClientdata (void)
int i, j;
int bits; //johnfitz
bits = (unsigned short)MSG_ReadShort (); //johnfitz -- read bits here isntead of in CL_ParseServerMessage()
bits = (uint16_t)MSG_ReadShort (); //johnfitz -- read bits here isntead of in CL_ParseServerMessage()
//johnfitz -- PROTOCOL_FITZQUAKE
if (bits & SU_EXTEND1)

View File

@ -59,7 +59,7 @@ char com_cmdline[CMDLINE_LENGTH];
qboolean standard_quake = true, rogue, hipnotic;
// this graphic needs to be in the pak file to use registered features
static unsigned short pop[] =
static uint16_t pop[] =
{
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x6600,0x0000,0x0000,0x0000,0x6600,0x0000,
@ -1279,7 +1279,7 @@ being registered.
static void COM_CheckRegistered (void)
{
int h;
unsigned short check[128];
uint16_t check[128];
int i;
COM_OpenFile("gfx/pop.lmp", &h, NULL);
@ -1302,7 +1302,7 @@ static void COM_CheckRegistered (void)
for (i = 0; i < 128; i++)
{
if (pop[i] != (unsigned short)BigShort (check[i]))
if (pop[i] != (uint16_t)BigShort (check[i]))
Sys_Error ("Corrupted data file.");
}
@ -1953,7 +1953,7 @@ static pack_t *COM_LoadPackFile (const char *packfile)
pack_t *pack;
int packhandle;
dpackfile_t info[MAX_FILES_IN_PACK];
unsigned short crc;
uint16_t crc;
if (Sys_FileOpenRead (packfile, &packhandle) == -1)
return NULL;

View File

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define CRC_INIT_VALUE 0xffff
#define CRC_XOR_VALUE 0x0000
static unsigned short crctable[256] =
static uint16_t crctable[256] =
{
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
@ -66,25 +66,25 @@ static unsigned short crctable[256] =
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
};
void CRC_Init(unsigned short *crcvalue)
void CRC_Init(uint16_t *crcvalue)
{
*crcvalue = CRC_INIT_VALUE;
}
void CRC_ProcessByte(unsigned short *crcvalue, byte data)
void CRC_ProcessByte(uint16_t *crcvalue, byte data)
{
*crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];
}
unsigned short CRC_Value(unsigned short crcvalue)
uint16_t CRC_Value(uint16_t crcvalue)
{
return crcvalue ^ CRC_XOR_VALUE;
}
//johnfitz -- texture crc
unsigned short CRC_Block (const byte *start, int count)
uint16_t CRC_Block (const byte *start, int count)
{
unsigned short crc;
uint16_t crc;
CRC_Init (&crc);
while (count--)

View File

@ -24,10 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/* crc.h */
void CRC_Init(unsigned short *crcvalue);
void CRC_ProcessByte(unsigned short *crcvalue, byte data);
unsigned short CRC_Value(unsigned short crcvalue);
unsigned short CRC_Block (const byte *start, int count); //johnfitz -- texture crc
void CRC_Init(uint16_t *crcvalue);
void CRC_ProcessByte(uint16_t *crcvalue, byte data);
uint16_t CRC_Value(uint16_t crcvalue);
uint16_t CRC_Block (const byte *start, int count); //johnfitz -- texture crc
#endif /* _QUAKE_CRC_H */

View File

@ -371,7 +371,7 @@ void GL_MakeAliasModelDisplayLists_VBO (void)
int i, j;
int maxverts_vbo;
trivertx_t *verts;
unsigned short *indexes;
uint16_t *indexes;
aliasmesh_t *desc;
if (!gl_glsl_alias_able)
@ -389,7 +389,7 @@ void GL_MakeAliasModelDisplayLists_VBO (void)
desc = (aliasmesh_t *) Hunk_Alloc (sizeof (aliasmesh_t) * maxverts_vbo);
// there will always be this number of indexes
indexes = (unsigned short *) Hunk_Alloc (sizeof (unsigned short) * maxverts_vbo);
indexes = (uint16_t *) Hunk_Alloc (sizeof (uint16_t) * maxverts_vbo);
pheader->indexes = (intptr_t) indexes - (intptr_t) pheader;
pheader->meshdesc = (intptr_t) desc - (intptr_t) pheader;
@ -403,7 +403,7 @@ void GL_MakeAliasModelDisplayLists_VBO (void)
int v;
// index into hdr->vertexes
unsigned short vertindex = triangles[i].vertindex[j];
uint16_t vertindex = triangles[i].vertindex[j];
// basic s/t coords
int s = stverts[vertindex].s;
@ -493,7 +493,7 @@ static void GLMesh_LoadVertexBuffer (qmodel_t *m, const aliashdr_t *hdr)
GL_DeleteBuffersFunc (1, &m->meshindexesvbo);
GL_GenBuffersFunc (1, &m->meshindexesvbo);
GL_BindBufferFunc (GL_ELEMENT_ARRAY_BUFFER, m->meshindexesvbo);
GL_BufferDataFunc (GL_ELEMENT_ARRAY_BUFFER, hdr->numindexes * sizeof (unsigned short), indexes, GL_STATIC_DRAW);
GL_BufferDataFunc (GL_ELEMENT_ARRAY_BUFFER, hdr->numindexes * sizeof (uint16_t), indexes, GL_STATIC_DRAW);
// create the vertex buffer (empty)

View File

@ -903,8 +903,8 @@ void Mod_LoadEdges (lump_t *l, int bsp2)
for (i=0 ; i<count ; i++, in++, out++)
{
out->v[0] = (unsigned short)LittleShort(in->v[0]);
out->v[1] = (unsigned short)LittleShort(in->v[1]);
out->v[0] = (uint16_t)LittleShort(in->v[0]);
out->v[1] = (uint16_t)LittleShort(in->v[1]);
}
}
}
@ -1314,13 +1314,13 @@ void Mod_LoadNodes_S (lump_t *l)
p = LittleLong(in->planenum);
out->plane = loadmodel->planes + p;
out->firstsurface = (unsigned short)LittleShort (in->firstface); //johnfitz -- explicit cast as unsigned short
out->numsurfaces = (unsigned short)LittleShort (in->numfaces); //johnfitz -- explicit cast as unsigned short
out->firstsurface = (uint16_t)LittleShort (in->firstface); //johnfitz -- explicit cast as uint16_t
out->numsurfaces = (uint16_t)LittleShort (in->numfaces); //johnfitz -- explicit cast as uint16_t
for (j=0 ; j<2 ; j++)
{
//johnfitz -- hack to handle nodes > 32k, adapted from darkplaces
p = (unsigned short)LittleShort(in->children[j]);
p = (uint16_t)LittleShort(in->children[j]);
if (p < count)
out->children[j] = loadmodel->nodes + p;
else
@ -1366,8 +1366,8 @@ void Mod_LoadNodes_L1 (lump_t *l)
p = LittleLong(in->planenum);
out->plane = loadmodel->planes + p;
out->firstsurface = LittleLong (in->firstface); //johnfitz -- explicit cast as unsigned short
out->numsurfaces = LittleLong (in->numfaces); //johnfitz -- explicit cast as unsigned short
out->firstsurface = LittleLong (in->firstface); //johnfitz -- explicit cast as uint16_t
out->numsurfaces = LittleLong (in->numfaces); //johnfitz -- explicit cast as uint16_t
for (j=0 ; j<2 ; j++)
{
@ -1418,8 +1418,8 @@ void Mod_LoadNodes_L2 (lump_t *l)
p = LittleLong(in->planenum);
out->plane = loadmodel->planes + p;
out->firstsurface = LittleLong (in->firstface); //johnfitz -- explicit cast as unsigned short
out->numsurfaces = LittleLong (in->numfaces); //johnfitz -- explicit cast as unsigned short
out->firstsurface = LittleLong (in->firstface); //johnfitz -- explicit cast as uint16_t
out->numsurfaces = LittleLong (in->numfaces); //johnfitz -- explicit cast as uint16_t
for (j=0 ; j<2 ; j++)
{
@ -1484,8 +1484,8 @@ void Mod_ProcessLeafs_S (dsleaf_t *in, int filelen)
p = LittleLong(in->contents);
out->contents = p;
out->firstmarksurface = loadmodel->marksurfaces + (unsigned short)LittleShort(in->firstmarksurface); //johnfitz -- unsigned short
out->nummarksurfaces = (unsigned short)LittleShort(in->nummarksurfaces); //johnfitz -- unsigned short
out->firstmarksurface = loadmodel->marksurfaces + (uint16_t)LittleShort(in->firstmarksurface); //johnfitz -- uint16_t
out->nummarksurfaces = (uint16_t)LittleShort(in->nummarksurfaces); //johnfitz -- uint16_t
p = LittleLong(in->visofs);
if (p == -1)
@ -1527,8 +1527,8 @@ void Mod_ProcessLeafs_L1 (dl1leaf_t *in, int filelen)
p = LittleLong(in->contents);
out->contents = p;
out->firstmarksurface = loadmodel->marksurfaces + LittleLong(in->firstmarksurface); //johnfitz -- unsigned short
out->nummarksurfaces = LittleLong(in->nummarksurfaces); //johnfitz -- unsigned short
out->firstmarksurface = loadmodel->marksurfaces + LittleLong(in->firstmarksurface); //johnfitz -- uint16_t
out->nummarksurfaces = LittleLong(in->nummarksurfaces); //johnfitz -- uint16_t
p = LittleLong(in->visofs);
if (p == -1)
@ -1570,8 +1570,8 @@ void Mod_ProcessLeafs_L2 (dl2leaf_t *in, int filelen)
p = LittleLong(in->contents);
out->contents = p;
out->firstmarksurface = loadmodel->marksurfaces + LittleLong(in->firstmarksurface); //johnfitz -- unsigned short
out->nummarksurfaces = LittleLong(in->nummarksurfaces); //johnfitz -- unsigned short
out->firstmarksurface = loadmodel->marksurfaces + LittleLong(in->firstmarksurface); //johnfitz -- uint16_t
out->nummarksurfaces = LittleLong(in->nummarksurfaces); //johnfitz -- uint16_t
p = LittleLong(in->visofs);
if (p == -1)
@ -1698,8 +1698,8 @@ void Mod_LoadClipnodes (lump_t *l, qboolean bsp2)
//johnfitz
//johnfitz -- support clipnodes > 32k
out->children[0] = (unsigned short)LittleShort(ins->children[0]);
out->children[1] = (unsigned short)LittleShort(ins->children[1]);
out->children[0] = (uint16_t)LittleShort(ins->children[0]);
out->children[1] = (uint16_t)LittleShort(ins->children[1]);
if (out->children[0] >= count)
out->children[0] -= 65536;
@ -1799,7 +1799,7 @@ void Mod_LoadMarksurfaces (lump_t *l, int bsp2)
for (i=0 ; i<count ; i++)
{
j = (unsigned short)LittleShort(in[i]); //johnfitz -- explicit cast as unsigned short
j = (uint16_t)LittleShort(in[i]); //johnfitz -- explicit cast as uint16_t
if (j >= loadmodel->numsurfaces)
Sys_Error ("Mod_LoadMarksurfaces: bad surface number");
out[i] = loadmodel->surfaces + j;

View File

@ -291,7 +291,7 @@ Alias models are position independent, so the cache manager can move them.
typedef struct aliasmesh_s
{
float st[2];
unsigned short vertindex;
uint16_t vertindex;
} aliasmesh_t;
typedef struct meshxyz_s

View File

@ -1196,7 +1196,7 @@ TexMgr_LoadImage -- the one entry point for loading all textures
gltexture_t *TexMgr_LoadImage (qmodel_t *owner, const char *name, int width, int height, enum srcformat format,
byte *data, const char *source_file, src_offset_t source_offset, unsigned flags)
{
unsigned short crc;
uint16_t crc;
gltexture_t *glt;
int mark;

View File

@ -58,7 +58,7 @@ typedef struct gltexture_s {
enum srcformat source_format; //format of pixel data (indexed, lightmap, or rgba)
uint32_t source_width; //size of image in source data
uint32_t source_height; //size of image in source data
unsigned short source_crc; //generated by source data before modifications
uint16_t source_crc; //generated by source data before modifications
char shirt; //0-13 shirt color, or -1 if never colormapped
char pants; //0-13 pants color, or -1 if never colormapped
//used for rendering

View File

@ -157,13 +157,13 @@ cvar_t vid_contrast = {"contrast", "1", CVAR_ARCHIVE}; //QuakeSpasm, MarkV
#define USE_GAMMA_RAMPS 0
#if USE_GAMMA_RAMPS
static unsigned short vid_gamma_red[256];
static unsigned short vid_gamma_green[256];
static unsigned short vid_gamma_blue[256];
static uint16_t vid_gamma_red[256];
static uint16_t vid_gamma_green[256];
static uint16_t vid_gamma_blue[256];
static unsigned short vid_sysgamma_red[256];
static unsigned short vid_sysgamma_green[256];
static unsigned short vid_sysgamma_blue[256];
static uint16_t vid_sysgamma_red[256];
static uint16_t vid_sysgamma_green[256];
static uint16_t vid_sysgamma_blue[256];
#endif
static qboolean gammaworks = false; // whether hw-gamma works

View File

@ -103,9 +103,9 @@ byte *Image_LoadImage (const char *name, int *width, int *height)
typedef struct targaheader_s {
unsigned char id_length, colormap_type, image_type;
unsigned short colormap_index, colormap_length;
uint16_t colormap_index, colormap_length;
unsigned char colormap_size;
unsigned short x_origin, y_origin, width, height;
uint16_t x_origin, y_origin, width, height;
unsigned char pixel_size, attributes;
} targaheader_t;
@ -388,13 +388,13 @@ typedef struct
char version;
char encoding;
char bits_per_pixel;
unsigned short xmin,ymin,xmax,ymax;
unsigned short hdpi,vdpi;
uint16_t xmin,ymin,xmax,ymax;
uint16_t hdpi,vdpi;
byte colortable[48];
char reserved;
char color_planes;
unsigned short bytes_per_line;
unsigned short palette_type;
uint16_t bytes_per_line;
uint16_t palette_type;
char filler[58];
} pcxheader_t;
@ -414,11 +414,11 @@ byte *Image_LoadPCX (FILE *f, int *width, int *height)
start = ftell (f); //save start of file (since we might be inside a pak file, SEEK_SET might not be the start of the pcx)
fread(&pcx, sizeof(pcx), 1, f);
pcx.xmin = (unsigned short)LittleShort (pcx.xmin);
pcx.ymin = (unsigned short)LittleShort (pcx.ymin);
pcx.xmax = (unsigned short)LittleShort (pcx.xmax);
pcx.ymax = (unsigned short)LittleShort (pcx.ymax);
pcx.bytes_per_line = (unsigned short)LittleShort (pcx.bytes_per_line);
pcx.xmin = (uint16_t)LittleShort (pcx.xmin);
pcx.ymin = (uint16_t)LittleShort (pcx.ymin);
pcx.xmax = (uint16_t)LittleShort (pcx.xmax);
pcx.ymax = (uint16_t)LittleShort (pcx.ymax);
pcx.bytes_per_line = (uint16_t)LittleShort (pcx.bytes_per_line);
if (pcx.signature != 0x0A)
Sys_Error ("'%s' is not a valid PCX file", loadfilename);

View File

@ -1368,14 +1368,14 @@ typedef struct Hash
{
int* head; /*hash value to head circular pos - can be outdated if went around window*/
/*circular pos to prev circular pos*/
unsigned short* chain;
uint16_t* chain;
int* val; /*circular pos to hash value*/
/*TODO: do this not only for zeros but for any repeated byte. However for PNG
it's always going to be the zeros that dominate, so not important for PNG*/
int* headz; /*similar to head, but for chainz*/
unsigned short* chainz; /*those with same amount of zeros*/
unsigned short* zeros; /*length of zeros streak, used as a second hash chain*/
uint16_t* chainz; /*those with same amount of zeros*/
uint16_t* zeros; /*length of zeros streak, used as a second hash chain*/
} Hash;
static unsigned hash_init(Hash* hash, unsigned windowsize)
@ -1383,11 +1383,11 @@ static unsigned hash_init(Hash* hash, unsigned windowsize)
unsigned i;
hash->head = (int*)lodepng_malloc(sizeof(int) * HASH_NUM_VALUES);
hash->val = (int*)lodepng_malloc(sizeof(int) * windowsize);
hash->chain = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);
hash->chain = (uint16_t*)lodepng_malloc(sizeof(uint16_t) * windowsize);
hash->zeros = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);
hash->zeros = (uint16_t*)lodepng_malloc(sizeof(uint16_t) * windowsize);
hash->headz = (int*)lodepng_malloc(sizeof(int) * (MAX_SUPPORTED_DEFLATE_LENGTH + 1));
hash->chainz = (unsigned short*)lodepng_malloc(sizeof(unsigned short) * windowsize);
hash->chainz = (uint16_t*)lodepng_malloc(sizeof(uint16_t) * windowsize);
if(!hash->head || !hash->chain || !hash->val || !hash->headz|| !hash->chainz || !hash->zeros)
{
@ -1451,7 +1451,7 @@ static unsigned countZeros(const unsigned char* data, size_t size, size_t pos)
}
/*wpos = pos & (windowsize - 1)*/
static void updateHashChain(Hash* hash, size_t wpos, unsigned hashval, unsigned short numzeros)
static void updateHashChain(Hash* hash, size_t wpos, unsigned hashval, uint16_t numzeros)
{
hash->val[wpos] = (int)hashval;
if(hash->head[hashval] != -1) hash->chain[wpos] = hash->head[hashval];
@ -3049,7 +3049,7 @@ static unsigned rgba8ToPixel(unsigned char* out, size_t i,
{
if(mode->colortype == LCT_GREY)
{
unsigned char grey = r; /*((unsigned short)r + g + b) / 3*/;
unsigned char grey = r; /*((uint16_t)r + g + b) / 3*/;
if(mode->bitdepth == 8) out[i] = grey;
else if(mode->bitdepth == 16) out[i * 2 + 0] = out[i * 2 + 1] = grey;
else
@ -3083,7 +3083,7 @@ static unsigned rgba8ToPixel(unsigned char* out, size_t i,
}
else if(mode->colortype == LCT_GREY_ALPHA)
{
unsigned char grey = r; /*((unsigned short)r + g + b) / 3*/;
unsigned char grey = r; /*((uint16_t)r + g + b) / 3*/;
if(mode->bitdepth == 8)
{
out[i * 2 + 0] = grey;
@ -3119,11 +3119,11 @@ static unsigned rgba8ToPixel(unsigned char* out, size_t i,
/*put a pixel, given its RGBA16 color, into image of any color 16-bitdepth type*/
static void rgba16ToPixel(unsigned char* out, size_t i,
const LodePNGColorMode* mode,
unsigned short r, unsigned short g, unsigned short b, unsigned short a)
uint16_t r, uint16_t g, uint16_t b, uint16_t a)
{
if(mode->colortype == LCT_GREY)
{
unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;
uint16_t grey = r; /*((unsigned)r + g + b) / 3*/;
out[i * 2 + 0] = (grey >> 8) & 255;
out[i * 2 + 1] = grey & 255;
}
@ -3138,7 +3138,7 @@ static void rgba16ToPixel(unsigned char* out, size_t i,
}
else if(mode->colortype == LCT_GREY_ALPHA)
{
unsigned short grey = r; /*((unsigned)r + g + b) / 3*/;
uint16_t grey = r; /*((unsigned)r + g + b) / 3*/;
out[i * 4 + 0] = (grey >> 8) & 255;
out[i * 4 + 1] = grey & 255;
out[i * 4 + 2] = (a >> 8) & 255;
@ -3402,7 +3402,7 @@ static void getPixelColorsRGBA8(unsigned char* buffer, size_t numpixels,
/*Get RGBA16 color of pixel with index i (y * width + x) from the raw image with
given color type, but the given color type must be 16-bit itself.*/
static void getPixelColorRGBA16(unsigned short* r, unsigned short* g, unsigned short* b, unsigned short* a,
static void getPixelColorRGBA16(uint16_t* r, uint16_t* g, uint16_t* b, uint16_t* a,
const unsigned char* in, size_t i, const LodePNGColorMode* mode)
{
if(mode->colortype == LCT_GREY)
@ -3487,7 +3487,7 @@ unsigned lodepng_convert(unsigned char* out, const unsigned char* in,
{
for(i = 0; i != numpixels; ++i)
{
unsigned short r = 0, g = 0, b = 0, a = 0;
uint16_t r = 0, g = 0, b = 0, a = 0;
getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode_in);
rgba16ToPixel(out, i, mode_out, r, g, b, a);
}
@ -3578,7 +3578,7 @@ unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
/*Check if the 16-bit input is truly 16-bit*/
if(mode->bitdepth == 16)
{
unsigned short r, g, b, a;
uint16_t r, g, b, a;
for(i = 0; i != numpixels; ++i)
{
getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode);
@ -3593,7 +3593,7 @@ unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
if(sixteen)
{
unsigned short r = 0, g = 0, b = 0, a = 0;
uint16_t r = 0, g = 0, b = 0, a = 0;
profile->bits = 16;
bits_done = numcolors_done = 1; /*counting colors no longer useful, palette doesn't support 16-bit*/

View File

@ -564,9 +564,9 @@ typedef struct LodePNGColorProfile
{
unsigned colored; /*not greyscale*/
unsigned key; /*image is not opaque and color key is possible instead of full alpha*/
unsigned short key_r; /*key values, always as 16-bit, in 8-bit case the byte is duplicated, e.g. 65535 means 255*/
unsigned short key_g;
unsigned short key_b;
uint16_t key_r; /*key values, always as 16-bit, in 8-bit case the byte is duplicated, e.g. 65535 means 255*/
uint16_t key_g;
uint16_t key_b;
unsigned alpha; /*image is not opaque and alpha channel or alpha palette required*/
unsigned numcolors; /*amount of colors, up to 257. Not valid if bits == 16.*/
unsigned char palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order*/
@ -1330,7 +1330,7 @@ This may mean that, depending on your use case, you may want to convert the big
endian output of LodePNG to little endian with a for loop. This is certainly not
always needed, many applications and libraries support big endian 16-bit colors
anyway, but it means you cannot simply cast the unsigned char* buffer to an
unsigned short* buffer on x86 CPUs.
uint16_t* buffer on x86 CPUs.
7. error values

View File

@ -34,7 +34,7 @@
defined(__GNU__) /* GNU/Hurd */ || defined(__riscos__)
/* struct sockaddr has unsigned char sa_len as the first member in BSD
* variants and the family member is also an unsigned char instead of an
* unsigned short. This should matter only when PLATFORM_UNIX is defined,
* uint16_t. This should matter only when PLATFORM_UNIX is defined,
* however, checking for the offset of sa_family in every platform that
* provide a struct sockaddr doesn't hurt either (see down below for the
* compile time asserts.) */

View File

@ -134,15 +134,15 @@ enum
typedef struct statement_s
{
unsigned short op;
uint16_t op;
short a, b, c;
} dstatement_t;
typedef struct
{
unsigned short type; // if DEF_SAVEGLOBAL bit is set
uint16_t type; // if DEF_SAVEGLOBAL bit is set
// the variable needs to be saved in savegames
unsigned short ofs;
uint16_t ofs;
int s_name;
} ddef_t;

View File

@ -41,7 +41,7 @@ globalvars_t *pr_global_struct;
float *pr_globals; // same as pr_global_struct
int pr_edict_size; // in bytes
unsigned short pr_crc;
uint16_t pr_crc;
int type_size[8] = {
1, // ev_void

View File

@ -349,9 +349,9 @@ PR_ExecuteProgram
The interpretation main loop
====================
*/
#define OPA ((eval_t *)&pr_globals[(unsigned short)st->a])
#define OPB ((eval_t *)&pr_globals[(unsigned short)st->b])
#define OPC ((eval_t *)&pr_globals[(unsigned short)st->c])
#define OPA ((eval_t *)&pr_globals[(uint16_t)st->a])
#define OPB ((eval_t *)&pr_globals[(uint16_t)st->b])
#define OPC ((eval_t *)&pr_globals[(uint16_t)st->c])
void PR_ExecuteProgram (func_t fnum)
{
@ -625,9 +625,9 @@ void PR_ExecuteProgram (func_t fnum)
pr_xfunction->profile += profile - startprofile;
startprofile = profile;
pr_xstatement = st - pr_statements;
pr_globals[OFS_RETURN] = pr_globals[(unsigned short)st->a];
pr_globals[OFS_RETURN + 1] = pr_globals[(unsigned short)st->a + 1];
pr_globals[OFS_RETURN + 2] = pr_globals[(unsigned short)st->a + 2];
pr_globals[OFS_RETURN] = pr_globals[(uint16_t)st->a];
pr_globals[OFS_RETURN + 1] = pr_globals[(uint16_t)st->a + 1];
pr_globals[OFS_RETURN + 2] = pr_globals[(uint16_t)st->a + 2];
st = &pr_statements[PR_LeaveFunction()];
if (pr_depth == exitdepth)
{ // Done

View File

@ -128,7 +128,7 @@ extern qboolean pr_trace;
extern dfunction_t *pr_xfunction;
extern int pr_xstatement;
extern unsigned short pr_crc;
extern uint16_t pr_crc;
FUNC_NORETURN void PR_RunError (const char *error, ...) FUNC_PRINTF(1,2);
#ifdef __WATCOMC__

View File

@ -235,8 +235,8 @@ typedef struct
{
vec3_t origin;
vec3_t angles;
unsigned short modelindex; //johnfitz -- was int
unsigned short frame; //johnfitz -- was int
uint16_t modelindex; //johnfitz -- was int
uint16_t frame; //johnfitz -- was int
unsigned char colormap; //johnfitz -- was int
unsigned char skin; //johnfitz -- was int
unsigned char alpha; //johnfitz -- added

View File

@ -435,7 +435,7 @@ static int mp3_madseek(snd_stream_t *stream, unsigned long offset)
while (1) /* Decode frame headers */
{
static unsigned short samples;
static uint16_t samples;
p->Stream.error = MAD_ERROR_NONE;
/* Not an audio frame */

View File

@ -256,7 +256,7 @@ static void stbiw__putc(stbi__write_context *s, unsigned char c)
static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,
24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 };
static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) {
static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const uint16_t *bs) {
int bitBuf = *bitBufP, bitCnt = *bitCntP;
bitCnt += bs[1];
bitBuf |= bs[0] << (24 - bitCnt);
@ -321,7 +321,7 @@ static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float
*d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6;
}
static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) {
static void stbiw__jpg_calcBits(int val, uint16_t bits[2]) {
int tmp1 = val < 0 ? -val : val;
val = val < 0 ? val-1 : val;
bits[1] = 1;
@ -331,9 +331,9 @@ static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) {
bits[0] = val & ((1<<bits[1])-1);
}
static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt, float *CDU, float *fdtbl, int DC, const unsigned short HTDC[256][2], const unsigned short HTAC[256][2]) {
unsigned short EOB[2];
unsigned short M16zeroes[2];
static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt, float *CDU, float *fdtbl, int DC, const uint16_t HTDC[256][2], const uint16_t HTAC[256][2]) {
uint16_t EOB[2];
uint16_t M16zeroes[2];
int dataOff, i, diff, end0pos;
int DU[64];
@ -363,7 +363,7 @@ static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt
if (diff == 0) {
stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]);
} else {
unsigned short bits[2];
uint16_t bits[2];
stbiw__jpg_calcBits(diff, bits);
stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[bits[1]]);
stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);
@ -380,7 +380,7 @@ static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt
for(i = 1; i <= end0pos; ++i) {
int startpos = i;
int nrzeroes;
unsigned short bits[2];
uint16_t bits[2];
for (; DU[i]==0 && i<=end0pos; ++i) {
}
nrzeroes = i-startpos;
@ -428,9 +428,9 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa
};
// Huffman tables
static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}};
static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}};
static const unsigned short YAC_HT[256][2] = {
static const uint16_t YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}};
static const uint16_t UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}};
static const uint16_t YAC_HT[256][2] = {
{10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
@ -448,7 +448,7 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
{65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0},
{2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}
};
static const unsigned short UVAC_HT[256][2] = {
static const uint16_t UVAC_HT[256][2] = {
{0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
{26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
@ -530,7 +530,7 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
// Encode 8x8 macroblocks
{
static const unsigned short fillBits[] = {0x7F, 7};
static const uint16_t fillBits[] = {0x7F, 7};
const unsigned char *imageData = (const unsigned char *)data;
int DCY=0, DCU=0, DCV=0;
int bitBuf=0, bitCnt=0;

View File

@ -93,7 +93,7 @@ sys_socket_t UDP_Init (void)
broadcastaddr.sin_family = AF_INET;
broadcastaddr.sin_addr.s_addr = INADDR_BROADCAST;
broadcastaddr.sin_port = htons((unsigned short)net_hostport);
broadcastaddr.sin_port = htons((uint16_t)net_hostport);
UDP_GetSocketAddr (net_controlsocket, &addr);
strcpy(my_tcpip_address, UDP_AddrToString (&addr));
@ -157,7 +157,7 @@ sys_socket_t UDP_OpenSocket (int port)
memset(&address, 0, sizeof(struct sockaddr_in));
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons((unsigned short)port);
address.sin_port = htons((uint16_t)port);
if (bind (newsocket, (struct sockaddr *)&address, sizeof(address)) == 0)
return newsocket;
@ -226,7 +226,7 @@ static int PartialIPAddress (const char *in, struct qsockaddr *hostaddr)
port = net_hostport;
hostaddr->qsa_family = AF_INET;
((struct sockaddr_in *)hostaddr)->sin_port = htons((unsigned short)port);
((struct sockaddr_in *)hostaddr)->sin_port = htons((uint16_t)port);
((struct sockaddr_in *)hostaddr)->sin_addr.s_addr =
(myAddr & htonl(mask)) | htonl(addr);
@ -366,7 +366,7 @@ int UDP_StringToAddr (const char *string, struct qsockaddr *addr)
addr->qsa_family = AF_INET;
((struct sockaddr_in *)addr)->sin_addr.s_addr = htonl(ipaddr);
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)hp);
((struct sockaddr_in *)addr)->sin_port = htons((uint16_t)hp);
return 0;
}
@ -420,7 +420,7 @@ int UDP_GetAddrFromName (const char *name, struct qsockaddr *addr)
return -1;
addr->qsa_family = AF_INET;
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)net_hostport);
((struct sockaddr_in *)addr)->sin_port = htons((uint16_t)net_hostport);
((struct sockaddr_in *)addr)->sin_addr.s_addr =
*(in_addr_t *)hostentry->h_addr_list[0];
@ -455,7 +455,7 @@ int UDP_GetSocketPort (struct qsockaddr *addr)
int UDP_SetSocketPort (struct qsockaddr *addr, int port)
{
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)port);
((struct sockaddr_in *)addr)->sin_port = htons((uint16_t)port);
return 0;
}

View File

@ -49,7 +49,7 @@ typedef struct
{
pixel_t *buffer; // invisible buffer
pixel_t *colormap; // 256 * VID_GRADES size
unsigned short *colormap16; // 256 * VID_GRADES size
uint16_t *colormap16; // 256 * VID_GRADES size
int fullbright; // index of first fullbright color
int rowbytes; // may be > width if displayed in a window
int width;

View File

@ -174,7 +174,7 @@ sys_socket_t WINS_Init (void)
broadcastaddr.sin_family = AF_INET;
broadcastaddr.sin_addr.s_addr = INADDR_BROADCAST;
broadcastaddr.sin_port = htons((unsigned short)net_hostport);
broadcastaddr.sin_port = htons((uint16_t)net_hostport);
Con_SafePrintf("UDP Initialized\n");
tcpipAvailable = true;
@ -236,7 +236,7 @@ sys_socket_t WINS_OpenSocket (int port)
memset(&address, 0, sizeof(struct sockaddr_in));
address.sin_family = AF_INET;
address.sin_addr.s_addr = myAddr;
address.sin_port = htons((unsigned short)port);
address.sin_port = htons((uint16_t)port);
if (bind (newsocket, (struct sockaddr *)&address, sizeof(address)) == 0)
return newsocket;
@ -315,7 +315,7 @@ static int PartialIPAddress (const char *in, struct qsockaddr *hostaddr)
port = net_hostport;
hostaddr->qsa_family = AF_INET;
((struct sockaddr_in *)hostaddr)->sin_port = htons((unsigned short)port);
((struct sockaddr_in *)hostaddr)->sin_port = htons((uint16_t)port);
((struct sockaddr_in *)hostaddr)->sin_addr.s_addr =
(myAddr & htonl(mask)) | htonl(addr);
@ -448,7 +448,7 @@ int WINS_StringToAddr (const char *string, struct qsockaddr *addr)
addr->qsa_family = AF_INET;
((struct sockaddr_in *)addr)->sin_addr.s_addr = htonl(ipaddr);
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)hp);
((struct sockaddr_in *)addr)->sin_port = htons((uint16_t)hp);
return 0;
}
@ -501,7 +501,7 @@ int WINS_GetAddrFromName (const char *name, struct qsockaddr *addr)
return -1;
addr->qsa_family = AF_INET;
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)net_hostport);
((struct sockaddr_in *)addr)->sin_port = htons((uint16_t)net_hostport);
((struct sockaddr_in *)addr)->sin_addr.s_addr =
*(in_addr_t *)hostentry->h_addr_list[0];
@ -536,7 +536,7 @@ int WINS_GetSocketPort (struct qsockaddr *addr)
int WINS_SetSocketPort (struct qsockaddr *addr, int port)
{
((struct sockaddr_in *)addr)->sin_port = htons((unsigned short)port);
((struct sockaddr_in *)addr)->sin_port = htons((uint16_t)port);
return 0;
}

View File

@ -94,7 +94,7 @@ sys_socket_t WIPX_Init (void)
broadcastaddr.sa_family = AF_IPX;
memset(broadcastaddr.sa_netnum, 0, 4);
memset(broadcastaddr.sa_nodenum, 0xff, 6);
broadcastaddr.sa_socket = htons((unsigned short)net_hostport);
broadcastaddr.sa_socket = htons((uint16_t)net_hostport);
WIPX_GetSocketAddr (net_controlsocket, &addr);
Q_strcpy(my_ipx_address, WIPX_AddrToString (&addr));
@ -176,7 +176,7 @@ sys_socket_t WIPX_OpenSocket (int port)
address.sa_family = AF_IPX;
memset(address.sa_netnum, 0, 4);
memset(address.sa_nodenum, 0, 6);;
address.sa_socket = htons((unsigned short)port);
address.sa_socket = htons((uint16_t)port);
if (bind (newsocket, (struct sockaddr *)&address, sizeof(address)) == 0)
{
ipxsocket[handle] = newsocket;
@ -352,7 +352,7 @@ int WIPX_StringToAddr (const char *string, struct qsockaddr *addr)
#undef DO
sscanf (&string[22], "%u", &val);
((struct sockaddr_ipx *)addr)->sa_socket = htons((unsigned short)val);
((struct sockaddr_ipx *)addr)->sa_socket = htons((uint16_t)val);
return 0;
}
@ -440,7 +440,7 @@ int WIPX_GetSocketPort (struct qsockaddr *addr)
int WIPX_SetSocketPort (struct qsockaddr *addr, int port)
{
((struct sockaddr_ipx *)addr)->sa_socket = htons((unsigned short)port);
((struct sockaddr_ipx *)addr)->sa_socket = htons((uint16_t)port);
return 0;
}