From 05bc75558afbdf80289fddf9a330dd7382a07d0d Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Wed, 24 Jan 2024 08:10:40 +1000 Subject: [PATCH] Fix signed int overflows and tidy nearby documentation Signed-off-by: bones_was_here --- cl_parse.c | 3 +- cmd.h | 88 ++++++------ cvar.c | 2 +- cvar.h | 2 +- gl_rmain.c | 6 +- gl_textures.c | 6 +- mdfour.c | 3 +- model_alias.c | 4 +- model_shared.h | 2 +- netconn.c | 4 +- protocol.h | 372 +++++++++++++++++++++++++------------------------ prvm_cmds.c | 4 +- prvm_cmds.h | 2 +- quakedef.h | 32 ++--- render.h | 127 ++++++++--------- sbar.c | 8 +- 16 files changed, 337 insertions(+), 328 deletions(-) diff --git a/cl_parse.c b/cl_parse.c index f02f63e1..dbeda386 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -1067,9 +1067,10 @@ static void CL_UpdateItemsAndWeapon(void) // check for important changes // set flash times + // UBSan: unsigned literals because left shifting by 31 causes signed overflow, although it works as expected on x86. if (cl.olditems != cl.stats[STAT_ITEMS]) for (j = 0;j < 32;j++) - if ((cl.stats[STAT_ITEMS] & (1< argc, so string operations are always safe. +// The functions that execute commands get their parameters with these functions. static inline int Cmd_Argc (cmd_state_t *cmd) { return cmd->argc; } +/// Cmd_Argv(cmd, ) will return an empty string (not a NULL) if arg > argc, so string operations are always safe. static inline const char *Cmd_Argv(cmd_state_t *cmd, int arg) { if (arg >= cmd->argc ) diff --git a/cvar.c b/cvar.c index 3008bb20..b1d7d91a 100644 --- a/cvar.c +++ b/cvar.c @@ -694,7 +694,7 @@ Cvar_Get Adds a newly allocated variable to the variable list or sets its value. ============ */ -cvar_t *Cvar_Get(cvar_state_t *cvars, const char *name, const char *value, int flags, const char *newdescription) +cvar_t *Cvar_Get(cvar_state_t *cvars, const char *name, const char *value, unsigned flags, const char *newdescription) { cvar_t *cvar; int i; diff --git a/cvar.h b/cvar.h index 709bc6aa..a489e1dc 100644 --- a/cvar.h +++ b/cvar.h @@ -193,7 +193,7 @@ void Cvar_Del_f(struct cmd_state_s *cmd); /// allocates a cvar by name and returns its address, /// or merely sets its value if it already exists. -cvar_t *Cvar_Get(cvar_state_t *cvars, const char *name, const char *value, int flags, const char *newdescription); +cvar_t *Cvar_Get(cvar_state_t *cvars, const char *name, const char *value, unsigned flags, const char *newdescription); extern const char *cvar_dummy_description; // ALWAYS the same pointer diff --git a/gl_rmain.c b/gl_rmain.c index cb77104b..cc0895cd 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1023,7 +1023,7 @@ static char *ShaderModeInfo_GetShaderText(shadermodeinfo_t *modeinfo, qbool prin static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode, uint64_t permutation) { - int i; + unsigned i; int ubibind; int sampler; shadermodeinfo_t *modeinfo = &shadermodeinfo[SHADERLANGUAGE_GLSL][mode]; @@ -1359,7 +1359,7 @@ static void R_SetupShader_SetPermutationGLSL(unsigned int mode, uint64_t permuta if (!r_glsl_permutation->program) { // remove features until we find a valid permutation - int i; + unsigned i; for (i = 0;i < SHADERPERMUTATION_COUNT;i++) { // reduce i more quickly whenever it would not remove any bits @@ -1418,7 +1418,7 @@ void R_GLSL_Restart_f(cmd_state_t *cmd) static void R_GLSL_DumpShader_f(cmd_state_t *cmd) { - int i, language, mode, dupe; + unsigned i, language, mode, dupe; char *text; shadermodeinfo_t *modeinfo; qfile_t *file; diff --git a/gl_textures.c b/gl_textures.c index b1cc74a1..10098972 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -1969,7 +1969,8 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen unsigned char *p = mipnewpixels; for (i = bytesperblock == 16 ? 8 : 0;i < (int)mipsize_total;i += bytesperblock, p += 4) { - c = mippixels_start[i] + 256*mippixels_start[i+1] + 65536*mippixels_start[i+2] + 16777216*mippixels_start[i+3]; + // UBSan: unsigned literals because promotion to int causes signed overflow when mippixels_start >= 128 + c = mippixels_start[i] + 256u*mippixels_start[i+1] + 65536u*mippixels_start[i+2] + 16777216u*mippixels_start[i+3]; p[2] = (((c >> 11) & 0x1F) + ((c >> 27) & 0x1F)) * (0.5f / 31.0f * 255.0f); p[1] = (((c >> 5) & 0x3F) + ((c >> 21) & 0x3F)) * (0.5f / 63.0f * 255.0f); p[0] = (((c ) & 0x1F) + ((c >> 16) & 0x1F)) * (0.5f / 31.0f * 255.0f); @@ -2014,7 +2015,8 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen { for (i = bytesperblock == 16 ? 8 : 0;i < mipsize;i += bytesperblock) { - c = mippixels[i] + 256*mippixels[i+1] + 65536*mippixels[i+2] + 16777216*mippixels[i+3]; + // UBSan: unsigned literals because promotion to int causes signed overflow when mippixels >= 128 + c = mippixels[i] + 256u*mippixels[i+1] + 65536u*mippixels[i+2] + 16777216u*mippixels[i+3]; avgcolor[0] += ((c >> 11) & 0x1F) + ((c >> 27) & 0x1F); avgcolor[1] += ((c >> 5) & 0x3F) + ((c >> 21) & 0x3F); avgcolor[2] += ((c ) & 0x1F) + ((c >> 16) & 0x1F); diff --git a/mdfour.c b/mdfour.c index ae92e375..5164994a 100644 --- a/mdfour.c +++ b/mdfour.c @@ -98,8 +98,9 @@ static void copy64(uint32_t *M, const unsigned char *in) { int i; + // UBSan: (unsigned) is because promotion to int causes signed overflow when in[] >= 128 for (i=0;i<16;i++) - M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) | + M[i] = ((unsigned)in[i*4+3]<<24) | (in[i*4+2]<<16) | (in[i*4+1]<<8) | (in[i*4+0]<<0); } diff --git a/model_alias.c b/model_alias.c index aea60dad..649324d1 100644 --- a/model_alias.c +++ b/model_alias.c @@ -1041,7 +1041,7 @@ void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend) BOUNDI((int)loadmodel->synctype,0,2); // convert model flags to EF flags (MF_ROCKET becomes EF_ROCKET, etc) i = LittleLong (pinmodel->flags); - loadmodel->effects = ((i & 255) << 24) | (i & 0x00FFFF00); + loadmodel->effects = (((unsigned)i & 255) << 24) | (i & 0x00FFFF00); if (strstr(r_nolerp_list.string, loadmodel->name)) loadmodel->nolerp = true; @@ -1616,7 +1616,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->synctype = ST_RAND; // convert model flags to EF flags (MF_ROCKET becomes EF_ROCKET, etc) i = LittleLong (pinmodel->flags); - loadmodel->effects = ((i & 255) << 24) | (i & 0x00FFFF00); + loadmodel->effects = (((unsigned)i & 255) << 24) | (i & 0x00FFFF00); // set up some global info about the model loadmodel->numframes = LittleLong(pinmodel->num_frames); diff --git a/model_shared.h b/model_shared.h index cf5e02dc..39572b54 100644 --- a/model_shared.h +++ b/model_shared.h @@ -442,7 +442,7 @@ typedef struct model_s // all models use textures... rtexturepool_t *texturepool; // EF_* flags (translated from the model file's different flags layout) - int effects; + unsigned effects; // number of QC accessible frame(group)s in the model int numframes; // number of QC accessible skin(group)s in the model diff --git a/netconn.c b/netconn.c index 6a78bd7e..5b569bf7 100644 --- a/netconn.c +++ b/netconn.c @@ -1353,8 +1353,8 @@ static int NetConn_ReceivedMessage(netconn_t *conn, const unsigned char *data, s conn->packetsReceived++; reliable_message = (sequence >> 31) != 0; reliable_ack = (sequence_ack >> 31) != 0; - sequence &= ~(1<<31); - sequence_ack &= ~(1<<31); + sequence &= ~(1u<<31); + sequence_ack &= ~(1u<<31); if (sequence <= conn->qw.incoming_sequence) { //Con_DPrint("Got a stale datagram\n"); diff --git a/protocol.h b/protocol.h index 047262d6..5a747a05 100644 --- a/protocol.h +++ b/protocol.h @@ -109,80 +109,82 @@ void Protocol_Names(char *buffer, size_t buffersize); #define PFLAGS_FULLDYNAMIC 128 // must be set or the light fields are ignored // if the high bit of the servercmd is set, the low bits are fast update flags: -#define U_MOREBITS (1<<0) -#define U_ORIGIN1 (1<<1) -#define U_ORIGIN2 (1<<2) -#define U_ORIGIN3 (1<<3) -#define U_ANGLE2 (1<<4) -// LadyHavoc: U_NOLERP was only ever used for monsters, so I renamed it U_STEP -#define U_STEP (1<<5) -#define U_FRAME (1<<6) -// just differentiates from other updates -#define U_SIGNAL (1<<7) - -#define U_ANGLE1 (1<<8) -#define U_ANGLE3 (1<<9) -#define U_MODEL (1<<10) -#define U_COLORMAP (1<<11) -#define U_SKIN (1<<12) -#define U_EFFECTS (1<<13) -#define U_LONGENTITY (1<<14) +#define U_MOREBITS (1u<<0) +#define U_ORIGIN1 (1u<<1) +#define U_ORIGIN2 (1u<<2) +#define U_ORIGIN3 (1u<<3) +#define U_ANGLE2 (1u<<4) +// LadyHavoc: U_NOLERP was uonly ever used for monsters, so I renamed it U_STEP +#define U_STEP (1u<<5) +#define U_FRAME (1u<<6) +// just differentiates fromu other updates +#define U_SIGNAL (1u<<7) + +#define U_ANGLE1 (1u<<8) +#define U_ANGLE3 (1u<<9) +#define U_MODEL (1u<<10) +#define U_COLORMAP (1u<<11) +#define U_SKIN (1u<<12) +#define U_EFFECTS (1u<<13) +#define U_LONGENTITY (1u<<14) // LadyHavoc: protocol extension -#define U_EXTEND1 (1<<15) +#define U_EXTEND1 (1u<<15) // LadyHavoc: first extend byte -#define U_DELTA (1<<16) // no data, while this is set the entity is delta compressed (uses previous frame as a baseline, meaning only things that have changed from the previous frame are sent, except for the forced full update every half second) -#define U_ALPHA (1<<17) // 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 1, and the entity is not sent if <=0 unless it has effects (model effects are checked as well) -#define U_SCALE (1<<18) // 1 byte, scale / 16 positive, not sent if 1.0 -#define U_EFFECTS2 (1<<19) // 1 byte, this is .effects & 0xFF00 (second byte) -#define U_GLOWSIZE (1<<20) // 1 byte, encoding is float/4.0, unsigned, not sent if 0 -#define U_GLOWCOLOR (1<<21) // 1 byte, palette index, default is 254 (white), this IS used for darklight (allowing colored darklight), however the particles from a darklight are always black, not sent if default value (even if glowsize or glowtrail is set) -#define U_COLORMOD (1<<22) // 1 byte, 3 bit red, 3 bit green, 2 bit blue, this lets you tint an object artifically, so you could make a red rocket, or a blue fiend... -#define U_EXTEND2 (1<<23) // another byte to follow +#define U_DELTA (1u<<16) ///< no data, while this is set the entity is delta compressed (uses previous frame as a baseline, meaning only things that have changed from the previous frame are sent, except for the forced full update every half second) +#define U_ALPHA (1u<<17) ///< 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 1, and the entity is not sent if <=0 unless it has effects (model effects are checked as well) +#define U_SCALE (1u<<18) ///< 1 byte, scale / 16 positive, not sent if 1.0 +#define U_EFFECTS2 (1u<<19) ///< 1 byte, this is .effects & 0xFF00 (second byte) +#define U_GLOWSIZE (1u<<20) ///< 1 byte, encoding is float/4.0, unsigned, not sent if 0 +#define U_GLOWCOLOR (1u<<21) ///< 1 byte, palette index, default is 254 (white), this IS used for darklight (allowing colored darklight), however the particles from a darklight are always black, not sent if default value (even if glowsize or glowtrail is set) +#define U_COLORMOD (1u<<22) ///< 1 byte, 3 bit red, 3 bit green, 2 bit blue, this lets you tint an object artifically, so you could make a red rocket, or a blue fiend... +#define U_EXTEND2 (1u<<23) ///< another byte to follow // LadyHavoc: second extend byte -#define U_GLOWTRAIL (1<<24) // leaves a trail of particles (of color .glowcolor, or black if it is a negative glowsize) -#define U_VIEWMODEL (1<<25) // attachs the model to the view (origin and angles become relative to it), only shown to owner, a more powerful alternative to .weaponmodel and such -#define U_FRAME2 (1<<26) // 1 byte, this is .frame & 0xFF00 (second byte) -#define U_MODEL2 (1<<27) // 1 byte, this is .modelindex & 0xFF00 (second byte) -#define U_EXTERIORMODEL (1<<28) // causes this model to not be drawn when using a first person view (third person will draw it, first person will not) -#define U_UNUSED29 (1<<29) // future expansion -#define U_UNUSED30 (1<<30) // future expansion -#define U_EXTEND3 (1<<31) // another byte to follow, future expansion - -#define SU_VIEWHEIGHT (1<<0) -#define SU_IDEALPITCH (1<<1) -#define SU_PUNCH1 (1<<2) -#define SU_PUNCH2 (1<<3) -#define SU_PUNCH3 (1<<4) -#define SU_VELOCITY1 (1<<5) -#define SU_VELOCITY2 (1<<6) -#define SU_VELOCITY3 (1<<7) -//define SU_AIMENT (1<<8) AVAILABLE BIT -#define SU_ITEMS (1<<9) -#define SU_ONGROUND (1<<10) // no data follows, the bit is it -#define SU_INWATER (1<<11) // no data follows, the bit is it -#define SU_WEAPONFRAME (1<<12) -#define SU_ARMOR (1<<13) -#define SU_WEAPON (1<<14) -#define SU_EXTEND1 (1<<15) +#define U_GLOWTRAIL (1u<<24) ///< leaves a trail of particles (of color .glowcolor, or black if it is a negative glowsize) +#define U_VIEWMODEL (1u<<25) ///< attachs the model to the view (origin and angles become relative to it), only shown to owner, a more powerful alternative to .weaponmodel and such +#define U_FRAME2 (1u<<26) ///< 1 byte, this is .frame & 0xFF00 (second byte) +#define U_MODEL2 (1u<<27) ///< 1 byte, this is .modelindex & 0xFF00 (second byte) +#define U_EXTERIORMODEL (1u<<28) ///< causes this model to not be drawn when using a first person view (third person will draw it, first person will not) +#define U_UNUSED29 (1u<<29) ///< future expansion +#define U_UNUSED30 (1u<<30) ///< future expansion +#define U_EXTEND3 (1u<<31) ///< another byte to follow, future expansion +// UBSan: unsigned literals because left shifting by 31 causes signed overflow, although it works as expected on x86. + +#define SU_VIEWHEIGHT (1u<<0) +#define SU_IDEALPITCH (1u<<1) +#define SU_PUNCH1 (1u<<2) +#define SU_PUNCH2 (1u<<3) +#define SU_PUNCH3 (1u<<4) +#define SU_VELOCITY1 (1u<<5) +#define SU_VELOCITY2 (1u<<6) +#define SU_VELOCITY3 (1u<<7) +//#define SU_AIMENT (1u<<8) AVAILABLE BIT +#define SU_ITEMS (1u<<9) +#define SU_ONGROUND (1u<<10) ///< no data follows, the bit is it +#define SU_INWATER (1u<<11) ///< no data follows, the bit is it +#define SU_WEAPONFRAME (1u<<12) +#define SU_ARMOR (1u<<13) +#define SU_WEAPON (1u<<14) +#define SU_EXTEND1 (1u<<15) // first extend byte -#define SU_PUNCHVEC1 (1<<16) -#define SU_PUNCHVEC2 (1<<17) -#define SU_PUNCHVEC3 (1<<18) -#define SU_VIEWZOOM (1<<19) // byte factor (0 = 0.0 (not valid), 255 = 1.0) -#define SU_UNUSED20 (1<<20) -#define SU_UNUSED21 (1<<21) -#define SU_UNUSED22 (1<<22) -#define SU_EXTEND2 (1<<23) // another byte to follow, future expansion +#define SU_PUNCHVEC1 (1u<<16) +#define SU_PUNCHVEC2 (1u<<17) +#define SU_PUNCHVEC3 (1u<<18) +#define SU_VIEWZOOM (1u<<19) ///< byte factor (0 = 0.0 (not valid), 255 = 1.0) +#define SU_UNUSED20 (1u<<20) +#define SU_UNUSED21 (1u<<21) +#define SU_UNUSED22 (1u<<22) +#define SU_EXTEND2 (1u<<23) ///< another byte to follow, future expansion // second extend byte -#define SU_UNUSED24 (1<<24) -#define SU_UNUSED25 (1<<25) -#define SU_UNUSED26 (1<<26) -#define SU_UNUSED27 (1<<27) -#define SU_UNUSED28 (1<<28) -#define SU_UNUSED29 (1<<29) -#define SU_UNUSED30 (1<<30) -#define SU_EXTEND3 (1<<31) // another byte to follow, future expansion +#define SU_UNUSED24 (1u<<24) +#define SU_UNUSED25 (1u<<25) +#define SU_UNUSED26 (1u<<26) +#define SU_UNUSED27 (1u<<27) +#define SU_UNUSED28 (1u<<28) +#define SU_UNUSED29 (1u<<29) +#define SU_UNUSED30 (1u<<30) +#define SU_EXTEND3 (1u<<31) ///< another byte to follow, future expansion +// UBSan: unsigned literals because left shifting by 31 causes signed overflow, although it works as expected on x86. // a sound with no channel is a local only sound #define SND_VOLUME (1<<0) // a byte @@ -609,43 +611,44 @@ entityframe_database_t; // order of the bits to minimize overhead from extend bytes // enough to describe a nail, gib, shell casing, bullet hole, or rocket -#define E_ORIGIN1 (1<<0) -#define E_ORIGIN2 (1<<1) -#define E_ORIGIN3 (1<<2) -#define E_ANGLE1 (1<<3) -#define E_ANGLE2 (1<<4) -#define E_ANGLE3 (1<<5) -#define E_MODEL1 (1<<6) -#define E_EXTEND1 (1<<7) +#define E_ORIGIN1 (1u<<0) +#define E_ORIGIN2 (1u<<1) +#define E_ORIGIN3 (1u<<2) +#define E_ANGLE1 (1u<<3) +#define E_ANGLE2 (1u<<4) +#define E_ANGLE3 (1u<<5) +#define E_MODEL1 (1u<<6) +#define E_EXTEND1 (1u<<7) // enough to describe almost anything -#define E_FRAME1 (1<<8) -#define E_EFFECTS1 (1<<9) -#define E_ALPHA (1<<10) -#define E_SCALE (1<<11) -#define E_COLORMAP (1<<12) -#define E_SKIN (1<<13) -#define E_FLAGS (1<<14) -#define E_EXTEND2 (1<<15) +#define E_FRAME1 (1u<<8) +#define E_EFFECTS1 (1u<<9) +#define E_ALPHA (1u<<10) +#define E_SCALE (1u<<11) +#define E_COLORMAP (1u<<12) +#define E_SKIN (1u<<13) +#define E_FLAGS (1u<<14) +#define E_EXTEND2 (1u<<15) // players, custom color glows, high model numbers -#define E_FRAME2 (1<<16) -#define E_MODEL2 (1<<17) -#define E_EFFECTS2 (1<<18) -#define E_GLOWSIZE (1<<19) -#define E_GLOWCOLOR (1<<20) -#define E_LIGHT (1<<21) -#define E_LIGHTPFLAGS (1<<22) -#define E_EXTEND3 (1<<23) - -#define E_SOUND1 (1<<24) -#define E_SOUNDVOL (1<<25) -#define E_SOUNDATTEN (1<<26) -#define E_TAGATTACHMENT (1<<27) -#define E_LIGHTSTYLE (1<<28) -#define E_UNUSED6 (1<<29) -#define E_UNUSED7 (1<<30) -#define E_EXTEND4 (1<<31) +#define E_FRAME2 (1u<<16) +#define E_MODEL2 (1u<<17) +#define E_EFFECTS2 (1u<<18) +#define E_GLOWSIZE (1u<<19) +#define E_GLOWCOLOR (1u<<20) +#define E_LIGHT (1u<<21) +#define E_LIGHTPFLAGS (1u<<22) +#define E_EXTEND3 (1u<<23) + +#define E_SOUND1 (1u<<24) +#define E_SOUNDVOL (1u<<25) +#define E_SOUNDATTEN (1u<<26) +#define E_TAGATTACHMENT (1u<<27) +#define E_LIGHTSTYLE (1u<<28) +#define E_UNUSED6 (1u<<29) +#define E_UNUSED7 (1u<<30) +#define E_EXTEND4 (1u<<31) +// UBSan: unsigned literals because left shifting by 31 causes signed overflow, although it works as expected on x86. // returns difference between two states as E_ flags int EntityState_DeltaBits(const entity_state_t *o, const entity_state_t *n); @@ -736,89 +739,90 @@ qbool EntityFrame4_WriteFrame(struct sizebuf_s *msg, int maxsize, entityframe4_d // reads a frame from the network stream void EntityFrame4_CL_ReadFrame(void); -// reset all entity fields (typically used if status changed) -#define E5_FULLUPDATE (1<<0) -// E5_ORIGIN32=0: short[3] = s->origin[0] * 8, s->origin[1] * 8, s->origin[2] * 8 -// E5_ORIGIN32=1: float[3] = s->origin[0], s->origin[1], s->origin[2] -#define E5_ORIGIN (1<<1) -// E5_ANGLES16=0: byte[3] = s->angle[0] * 256 / 360, s->angle[1] * 256 / 360, s->angle[2] * 256 / 360 -// E5_ANGLES16=1: short[3] = s->angle[0] * 65536 / 360, s->angle[1] * 65536 / 360, s->angle[2] * 65536 / 360 -#define E5_ANGLES (1<<2) -// E5_MODEL16=0: byte = s->modelindex -// E5_MODEL16=1: short = s->modelindex -#define E5_MODEL (1<<3) -// E5_FRAME16=0: byte = s->frame -// E5_FRAME16=1: short = s->frame -#define E5_FRAME (1<<4) -// byte = s->skin -#define E5_SKIN (1<<5) -// E5_EFFECTS16=0 && E5_EFFECTS32=0: byte = s->effects -// E5_EFFECTS16=1 && E5_EFFECTS32=0: short = s->effects -// E5_EFFECTS16=0 && E5_EFFECTS32=1: int = s->effects -// E5_EFFECTS16=1 && E5_EFFECTS32=1: int = s->effects -#define E5_EFFECTS (1<<6) -// bits >= (1<<8) -#define E5_EXTEND1 (1<<7) - -// byte = s->renderflags -#define E5_FLAGS (1<<8) -// byte = bound(0, s->alpha * 255, 255) -#define E5_ALPHA (1<<9) -// byte = bound(0, s->scale * 16, 255) -#define E5_SCALE (1<<10) -// flag -#define E5_ORIGIN32 (1<<11) -// flag -#define E5_ANGLES16 (1<<12) -// flag -#define E5_MODEL16 (1<<13) -// byte = s->colormap -#define E5_COLORMAP (1<<14) -// bits >= (1<<16) -#define E5_EXTEND2 (1<<15) - -// short = s->tagentity -// byte = s->tagindex -#define E5_ATTACHMENT (1<<16) -// short[4] = s->light[0], s->light[1], s->light[2], s->light[3] -// byte = s->lightstyle -// byte = s->lightpflags -#define E5_LIGHT (1<<17) -// byte = s->glowsize -// byte = s->glowcolor -#define E5_GLOW (1<<18) -// short = s->effects -#define E5_EFFECTS16 (1<<19) -// int = s->effects -#define E5_EFFECTS32 (1<<20) -// flag -#define E5_FRAME16 (1<<21) -// byte[3] = s->colormod[0], s->colormod[1], s->colormod[2] -#define E5_COLORMOD (1<<22) -// bits >= (1<<24) -#define E5_EXTEND3 (1<<23) - -// byte[3] = s->glowmod[0], s->glowmod[1], s->glowmod[2] -#define E5_GLOWMOD (1<<24) -// byte type=0 short frames[1] short times[1] -// byte type=1 short frames[2] short times[2] byte lerps[2] -// byte type=2 short frames[3] short times[3] byte lerps[3] -// byte type=3 short frames[4] short times[4] byte lerps[4] -// byte type=4 short modelindex byte numbones {short pose7s[7]} -// see also RENDER_COMPLEXANIMATION -#define E5_COMPLEXANIMATION (1<<25) -// ushort traileffectnum -#define E5_TRAILEFFECTNUM (1<<26) -// unused -#define E5_UNUSED27 (1<<27) -// unused -#define E5_UNUSED28 (1<<28) -// unused -#define E5_UNUSED29 (1<<29) -// unused -#define E5_UNUSED30 (1<<30) -// bits2 > 0 -#define E5_EXTEND4 (1<<31) +/// reset all entity fields (typically used if status changed) +#define E5_FULLUPDATE (1u<<0) +/// E5_ORIGIN32=0: short[3] = s->origin[0] * 8, s->origin[1] * 8, s->origin[2] * 8 +/// E5_ORIGIN32=1: float[3] = s->origin[0], s->origin[1], s->origin[2] +#define E5_ORIGIN (1u<<1) +/// E5_ANGLES16=0: byte[3] = s->angle[0] * 256 / 360, s->angle[1] * 256 / 360, s->angle[2] * 256 / 360 +/// E5_ANGLES16=1: short[3] = s->angle[0] * 65536 / 360, s->angle[1] * 65536 / 360, s->angle[2] * 65536 / 360 +#define E5_ANGLES (1u<<2) +/// E5_MODEL16=0: byte = s->modelindex +/// E5_MODEL16=1: short = s->modelindex +#define E5_MODEL (1u<<3) +/// E5_FRAME16=0: byte = s->frame +/// E5_FRAME16=1: short = s->frame +#define E5_FRAME (1u<<4) +/// byte = s->skin +#define E5_SKIN (1u<<5) +/// E5_EFFECTS16=0 && E5_EFFECTS32=0: byte = s->effects +/// E5_EFFECTS16=1 && E5_EFFECTS32=0: short = s->effects +/// E5_EFFECTS16=0 && E5_EFFECTS32=1: int = s->effects +/// E5_EFFECTS16=1 && E5_EFFECTS32=1: int = s->effects +#define E5_EFFECTS (1u<<6) +/// bits >= (1<<8) +#define E5_EXTEND1 (1u<<7) + +/// byte = s->renderflags +#define E5_FLAGS (1u<<8) +/// byte = bound(0, s->alpha * 255, 255) +#define E5_ALPHA (1u<<9) +/// byte = bound(0, s->scale * 16, 255) +#define E5_SCALE (1u<<10) +/// flag +#define E5_ORIGIN32 (1u<<11) +/// flag +#define E5_ANGLES16 (1u<<12) +/// flag +#define E5_MODEL16 (1u<<13) +/// byte = s->colormap +#define E5_COLORMAP (1u<<14) +/// bits >= (1<<16) +#define E5_EXTEND2 (1u<<15) + +/// short = s->tagentity +/// byte = s->tagindex +#define E5_ATTACHMENT (1u<<16) +/// short[4] = s->light[0], s->light[1], s->light[2], s->light[3] +/// byte = s->lightstyle +/// byte = s->lightpflags +#define E5_LIGHT (1u<<17) +/// byte = s->glowsize +/// byte = s->glowcolor +#define E5_GLOW (1u<<18) +/// short = s->effects +#define E5_EFFECTS16 (1u<<19) +/// int = s->effects +#define E5_EFFECTS32 (1u<<20) +/// flag +#define E5_FRAME16 (1u<<21) +/// byte[3] = s->colormod[0], s->colormod[1], s->colormod[2] +#define E5_COLORMOD (1u<<22) +/// bits >= (1<<24) +#define E5_EXTEND3 (1u<<23) + +/// byte[3] = s->glowmod[0], s->glowmod[1], s->glowmod[2] +#define E5_GLOWMOD (1u<<24) +/// byte type=0 short frames[1] short times[1] +/// byte type=1 short frames[2] short times[2] byte lerps[2] +/// byte type=2 short frames[3] short times[3] byte lerps[3] +/// byte type=3 short frames[4] short times[4] byte lerps[4] +/// byte type=4 short modelindex byte numbones {short pose7s[7]} +/// see also RENDER_COMPLEXANIMATION +#define E5_COMPLEXANIMATION (1u<<25) +/// ushort traileffectnum +#define E5_TRAILEFFECTNUM (1u<<26) +/// unused +#define E5_UNUSED27 (1u<<27) +/// unused +#define E5_UNUSED28 (1u<<28) +/// unused +#define E5_UNUSED29 (1u<<29) +/// unused +#define E5_UNUSED30 (1u<<30) +/// bits2 > 0 +#define E5_EXTEND4 (1u<<31) +// UBSan: unsigned literals because left shifting by 31 causes signed overflow, although it works as expected on x86. #define ENTITYFRAME5_MAXPACKETLOGS 64 #define ENTITYFRAME5_MAXSTATES 1024 diff --git a/prvm_cmds.c b/prvm_cmds.c index 6bc211c6..9a4e6921 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -1753,7 +1753,7 @@ float registercvar (string name, string value[, float flags]) void VM_registercvar(prvm_prog_t *prog) { const char *name, *value; - int flags; + unsigned flags; VM_SAFEPARMCOUNTRANGE(2, 3, VM_registercvar); @@ -3881,7 +3881,7 @@ static int BufStr_SortStringsDOWN (const void *in1, const void *in2) return strncmp(b, a, stringbuffers_sortlength); } -prvm_stringbuffer_t *BufStr_FindCreateReplace (prvm_prog_t *prog, int bufindex, int flags, const char *format) +prvm_stringbuffer_t *BufStr_FindCreateReplace (prvm_prog_t *prog, int bufindex, unsigned flags, const char *format) { prvm_stringbuffer_t *stringbuffer; int i; diff --git a/prvm_cmds.h b/prvm_cmds.h index 24fe4a91..217d67f1 100644 --- a/prvm_cmds.h +++ b/prvm_cmds.h @@ -219,7 +219,7 @@ void VM_CheckEmptyString (prvm_prog_t *prog, const char *s); /// Returns the length of the *out string excluding the \0 terminator. size_t VM_VarString(prvm_prog_t *prog, int first, char *out, size_t outsize); qbool PRVM_ConsoleCommand(prvm_prog_t *prog, const char *text, size_t textlen, int *func, qbool preserve_self, int curself, double ptime, qbool prog_loaded, const char *error_message); -prvm_stringbuffer_t *BufStr_FindCreateReplace (prvm_prog_t *prog, int bufindex, int flags, const char *format); +prvm_stringbuffer_t *BufStr_FindCreateReplace (prvm_prog_t *prog, int bufindex, unsigned flags, const char *format); void BufStr_Set(prvm_prog_t *prog, prvm_stringbuffer_t *stringbuffer, int strindex, const char *str); void BufStr_Del(prvm_prog_t *prog, prvm_stringbuffer_t *stringbuffer); void BufStr_Flush(prvm_prog_t *prog); diff --git a/quakedef.h b/quakedef.h index f423d598..510b4ec2 100644 --- a/quakedef.h +++ b/quakedef.h @@ -35,14 +35,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE 0x00000004 // stock defines - -#define IT_SHOTGUN 1 -#define IT_SUPER_SHOTGUN 2 -#define IT_NAILGUN 4 -#define IT_SUPER_NAILGUN 8 -#define IT_GRENADE_LAUNCHER 16 -#define IT_ROCKET_LAUNCHER 32 -#define IT_LIGHTNING 64 +#define IT_SHOTGUN 1 +#define IT_SUPER_SHOTGUN 2 +#define IT_NAILGUN 4 +#define IT_SUPER_NAILGUN 8 +#define IT_GRENADE_LAUNCHER 16 +#define IT_ROCKET_LAUNCHER 32 +#define IT_LIGHTNING 64 #define IT_SUPER_LIGHTNING 128 #define IT_SHELLS 256 #define IT_NAILS 512 @@ -55,14 +54,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define IT_SUPERHEALTH 65536 #define IT_KEY1 131072 #define IT_KEY2 262144 -#define IT_INVISIBILITY 524288 -#define IT_INVULNERABILITY 1048576 -#define IT_SUIT 2097152 -#define IT_QUAD 4194304 -#define IT_SIGIL1 (1<<28) -#define IT_SIGIL2 (1<<29) -#define IT_SIGIL3 (1<<30) -#define IT_SIGIL4 (1<<31) +#define IT_INVISIBILITY 524288 +#define IT_INVULNERABILITY 1048576 +#define IT_SUIT 2097152 +#define IT_QUAD 4194304 +#define IT_SIGIL1 (1u<<28) +#define IT_SIGIL2 (1u<<29) +#define IT_SIGIL3 (1u<<30) +#define IT_SIGIL4 (1u<<31) +// UBSan: unsigned literals because left shifting by 31 causes signed overflow, although it works as expected on x86. //=========================================== // AK nexuiz changed and added defines diff --git a/render.h b/render.h index 273e2147..8bfd9b77 100644 --- a/render.h +++ b/render.h @@ -46,7 +46,7 @@ typedef enum shaderlanguage_e } shaderlanguage_t; -// this enum selects which of the glslshadermodeinfo entries should be used +/// this enum selects which of the glslshadermodeinfo entries should be used typedef enum shadermode_e { SHADERMODE_GENERIC, ///< (particles/HUD/etc) vertex color, optionally multiplied by one texture @@ -70,39 +70,40 @@ typedef enum shadermode_e } shadermode_t; -#define SHADERPERMUTATION_DIFFUSE (1<<0) ///< (lightsource) whether to use directional shading -#define SHADERPERMUTATION_VERTEXTEXTUREBLEND (1<<1) ///< indicates this is a two-layer material blend based on vertex alpha (q3bsp) -#define SHADERPERMUTATION_VIEWTINT (1<<2) ///< view tint (postprocessing only), use vertex colors (generic only) -#define SHADERPERMUTATION_COLORMAPPING (1<<3) ///< indicates this is a colormapped skin -#define SHADERPERMUTATION_SATURATION (1<<4) ///< saturation (postprocessing only) -#define SHADERPERMUTATION_FOGINSIDE (1<<5) ///< tint the color by fog color or black if using additive blend mode -#define SHADERPERMUTATION_FOGOUTSIDE (1<<6) ///< tint the color by fog color or black if using additive blend mode -#define SHADERPERMUTATION_FOGHEIGHTTEXTURE (1<<7) ///< fog color and density determined by texture mapped on vertical axis -#define SHADERPERMUTATION_FOGALPHAHACK (1<<8) ///< fog color and density determined by texture mapped on vertical axis -#define SHADERPERMUTATION_GAMMARAMPS (1<<9) ///< gamma (postprocessing only) -#define SHADERPERMUTATION_CUBEFILTER (1<<10) ///< (lightsource) use cubemap light filter -#define SHADERPERMUTATION_GLOW (1<<11) ///< (lightmap) blend in an additive glow texture -#define SHADERPERMUTATION_BLOOM (1<<12) ///< bloom (postprocessing only) -#define SHADERPERMUTATION_SPECULAR (1<<13) ///< (lightsource or deluxemapping) render specular effects -#define SHADERPERMUTATION_POSTPROCESSING (1<<14) ///< user defined postprocessing (postprocessing only) -#define SHADERPERMUTATION_REFLECTION (1<<15) ///< normalmap-perturbed reflection of the scene infront of the surface, preformed as an overlay on the surface -#define SHADERPERMUTATION_OFFSETMAPPING (1<<16) ///< adjust texcoords to roughly simulate a displacement mapped surface -#define SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING (1<<17) ///< adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also be set!) -#define SHADERPERMUTATION_SHADOWMAP2D (1<<18) ///< (lightsource) use shadowmap texture as light filter -#define SHADERPERMUTATION_SHADOWMAPVSDCT (1<<19) ///< (lightsource) use virtual shadow depth cube texture for shadowmap indexing -#define SHADERPERMUTATION_SHADOWMAPORTHO (1<<20) ///< (lightsource) use orthographic shadowmap projection -#define SHADERPERMUTATION_DEFERREDLIGHTMAP (1<<21) ///< (lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping -#define SHADERPERMUTATION_ALPHAKILL (1<<22) ///< (deferredgeometry) discard pixel if diffuse texture alpha below 0.5, (generic) apply global alpha -#define SHADERPERMUTATION_REFLECTCUBE (1<<23) ///< fake reflections using global cubemap (not HDRI light probe) -#define SHADERPERMUTATION_NORMALMAPSCROLLBLEND (1<<24) ///< (water) counter-direction normalmaps scrolling -#define SHADERPERMUTATION_BOUNCEGRID (1<<25) ///< (lightmap) use Texture_BounceGrid as an additional source of ambient light -#define SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL (1<<26) ///< (lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standard 4-component -#define SHADERPERMUTATION_TRIPPY (1<<27) ///< use trippy vertex shader effect -#define SHADERPERMUTATION_DEPTHRGB (1<<28) ///< read/write depth values in RGB color coded format for older hardware without depth samplers -#define SHADERPERMUTATION_ALPHAGEN_VERTEX (1<<29) ///< alphaGen vertex -#define SHADERPERMUTATION_SKELETAL (1<<30) ///< (skeletal models) use skeletal matrices to deform vertices (gpu-skinning) -#define SHADERPERMUTATION_OCCLUDE (1<<31) ///< use occlusion buffer for corona -#define SHADERPERMUTATION_COUNT 32 ///< size of shaderpermutationinfo array +#define SHADERPERMUTATION_DIFFUSE (1u<<0) ///< (lightsource) whether to use directional shading +#define SHADERPERMUTATION_VERTEXTEXTUREBLEND (1u<<1) ///< indicates this is a two-layer material blend based on vertex alpha (q3bsp) +#define SHADERPERMUTATION_VIEWTINT (1u<<2) ///< view tint (postprocessing only), use vertex colors (generic only) +#define SHADERPERMUTATION_COLORMAPPING (1u<<3) ///< indicates this is a colormapped skin +#define SHADERPERMUTATION_SATURATION (1u<<4) ///< saturation (postprocessing only) +#define SHADERPERMUTATION_FOGINSIDE (1u<<5) ///< tint the color by fog color or black if using additive blend mode +#define SHADERPERMUTATION_FOGOUTSIDE (1u<<6) ///< tint the color by fog color or black if using additive blend mode +#define SHADERPERMUTATION_FOGHEIGHTTEXTURE (1u<<7) ///< fog color and density determined by texture mapped on vertical axis +#define SHADERPERMUTATION_FOGALPHAHACK (1u<<8) ///< fog color and density determined by texture mapped on vertical axis +#define SHADERPERMUTATION_GAMMARAMPS (1u<<9) ///< gamma (postprocessing only) +#define SHADERPERMUTATION_CUBEFILTER (1u<<10) ///< (lightsource) use cubemap light filter +#define SHADERPERMUTATION_GLOW (1u<<11) ///< (lightmap) blend in an additive glow texture +#define SHADERPERMUTATION_BLOOM (1u<<12) ///< bloom (postprocessing only) +#define SHADERPERMUTATION_SPECULAR (1u<<13) ///< (lightsource or deluxemapping) render specular effects +#define SHADERPERMUTATION_POSTPROCESSING (1u<<14) ///< user defined postprocessing (postprocessing only) +#define SHADERPERMUTATION_REFLECTION (1u<<15) ///< normalmap-perturbed reflection of the scene infront of the surface, preformed as an overlay on the surface +#define SHADERPERMUTATION_OFFSETMAPPING (1u<<16) ///< adjust texcoords to roughly simulate a displacement mapped surface +#define SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING (1u<<17) ///< adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also be set!) +#define SHADERPERMUTATION_SHADOWMAP2D (1u<<18) ///< (lightsource) use shadowmap texture as light filter +#define SHADERPERMUTATION_SHADOWMAPVSDCT (1u<<19) ///< (lightsource) use virtual shadow depth cube texture for shadowmap indexing +#define SHADERPERMUTATION_SHADOWMAPORTHO (1u<<20) ///< (lightsource) use orthographic shadowmap projection +#define SHADERPERMUTATION_DEFERREDLIGHTMAP (1u<<21) ///< (lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping +#define SHADERPERMUTATION_ALPHAKILL (1u<<22) ///< (deferredgeometry) discard pixel if diffuse texture alpha below 0.5, (generic) apply global alpha +#define SHADERPERMUTATION_REFLECTCUBE (1u<<23) ///< fake reflections using global cubemap (not HDRI light probe) +#define SHADERPERMUTATION_NORMALMAPSCROLLBLEND (1u<<24) ///< (water) counter-direction normalmaps scrolling +#define SHADERPERMUTATION_BOUNCEGRID (1u<<25) ///< (lightmap) use Texture_BounceGrid as an additional source of ambient light +#define SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL (1u<<26) ///< (lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standard 4-component +#define SHADERPERMUTATION_TRIPPY (1u<<27) ///< use trippy vertex shader effect +#define SHADERPERMUTATION_DEPTHRGB (1u<<28) ///< read/write depth values in RGB color coded format for older hardware without depth samplers +#define SHADERPERMUTATION_ALPHAGEN_VERTEX (1u<<29) ///< alphaGen vertex +#define SHADERPERMUTATION_SKELETAL (1u<<30) ///< (skeletal models) use skeletal matrices to deform vertices (gpu-skinning) +#define SHADERPERMUTATION_OCCLUDE (1u<<31) ///< use occlusion buffer for corona +#define SHADERPERMUTATION_COUNT 32u ///< size of shaderpermutationinfo array +// UBSan: unsigned literals because left shifting by 31 causes signed overflow, although it works as expected on x86. // 1.0f / N table extern float ixtable[4096]; @@ -236,9 +237,9 @@ r_viewport_type_t; typedef struct r_viewport_s { - matrix4x4_t cameramatrix; // from entity (transforms from camera entity to world) - matrix4x4_t viewmatrix; // actual matrix for rendering (transforms to viewspace) - matrix4x4_t projectmatrix; // actual projection matrix (transforms from viewspace to screen) + matrix4x4_t cameramatrix; ///< from entity (transforms from camera entity to world) + matrix4x4_t viewmatrix; ///< actual matrix for rendering (transforms to viewspace) + matrix4x4_t projectmatrix; ///< actual projection matrix (transforms from viewspace to screen) int x; int y; int z; @@ -246,7 +247,7 @@ typedef struct r_viewport_s int height; int depth; r_viewport_type_t type; - float screentodepth[2]; // used by deferred renderer to calculate linear depth from device depth coordinates + float screentodepth[2]; ///< used by deferred renderer to calculate linear depth from device depth coordinates } r_viewport_t; @@ -271,17 +272,17 @@ typedef struct r_refdef_view_s int numfrustumplanes; mplane_t frustum[6]; qbool useclipplane; - qbool usecustompvs; // uses r_refdef.viewcache.pvsbits as-is rather than computing it + qbool usecustompvs; ///< uses r_refdef.viewcache.pvsbits as-is rather than computing it mplane_t clipplane; float frustum_x, frustum_y; vec3_t frustumcorner[4]; - // if turned off it renders an ortho view + /// if turned off it renders an ortho view int useperspective; - // allows visibility culling based on the view origin (e.g. pvs and R_CanSeeBox) - // this is turned off by: - // r_trippy - // !r_refdef.view.useperspective - // (sometimes) r_refdef.view.useclipplane + /// allows visibility culling based on the view origin (e.g. pvs and R_CanSeeBox) + /// this is turned off by: + /// r_trippy + /// !r_refdef.view.useperspective + /// (sometimes) r_refdef.view.useclipplane int usevieworiginculling; float ortho_x, ortho_y; @@ -292,19 +293,19 @@ typedef struct r_refdef_view_s int width; int height; int depth; - r_viewport_t viewport; // note: if r_viewscale is used, the viewport.width and viewport.height may be less than width and height + r_viewport_t viewport; ///< note: if r_viewscale is used, the viewport.width and viewport.height may be less than width and height - // which color components to allow (for anaglyph glasses) + /// which color components to allow (for anaglyph glasses) int colormask[4]; - // global RGB color multiplier for rendering + /// global RGB color multiplier for rendering float colorscale; - // whether to call R_ClearScreen before rendering stuff + /// whether to call R_ClearScreen before rendering stuff qbool clear; - // if true, don't clear or do any post process effects (bloom, etc) + /// if true, don't clear or do any post process effects (bloom, etc) qbool isoverlay; - // if true, this is the MAIN view (which is, after CSQC, copied into the scene for use e.g. by r_speeds 1, showtex, prydon cursor) + /// if true, this is the MAIN view (which is, after CSQC, copied into the scene for use e.g. by r_speeds 1, showtex, prydon cursor) qbool ismain; // whether to draw r_showtris and such, this is only true for the main @@ -316,7 +317,7 @@ typedef struct r_refdef_view_s int cullface_front; int cullface_back; - // render quality (0 to 1) - affects r_drawparticles_drawdistance and others + /// render quality (0 to 1) - affects r_drawparticles_drawdistance and others float quality; } r_refdef_view_t; @@ -332,8 +333,8 @@ typedef struct r_refdef_viewcache_s // these properties are generated by R_View_Update() - // which entities are currently visible for this viewpoint - // (the used range is 0...r_refdef.scene.numentities) + /// which entities are currently visible for this viewpoint + /// (the used range is 0...r_refdef.scene.numentities) unsigned char *entityvisible; // flag arrays used for visibility checking on world model @@ -341,7 +342,7 @@ typedef struct r_refdef_viewcache_s unsigned char *world_pvsbits; unsigned char *world_leafvisible; unsigned char *world_surfacevisible; - // if true, the view is currently in a leaf without pvs data + /// if true, the view is currently in a leaf without pvs data qbool world_novis; } r_refdef_viewcache_t; @@ -349,24 +350,24 @@ r_refdef_viewcache_t; // TODO: really think about which fields should go into scene and which one should stay in refdef [1/7/2008 Black] // maybe also refactor some of the functions to support different setting sources (ie. fogenabled, etc.) for different scenes typedef struct r_refdef_scene_s { - // whether to call S_ExtraUpdate during render to reduce sound chop + /// whether to call S_ExtraUpdate during render to reduce sound chop qbool extraupdate; - // (client gameworld) time for rendering time based effects + /// (client gameworld) time for rendering time based effects double time; - // the world + /// the world entity_render_t *worldentity; - // same as worldentity->model + /// same as worldentity->model model_t *worldmodel; - // renderable entities (excluding world) + /// renderable entities (excluding world) entity_render_t **entities; int numentities; int maxentities; - // field of temporary entities that is reset each (client) frame + /// field of temporary entities that is reset each (client) frame entity_render_t *tempentities; int numtempentities; int maxtempentities; @@ -378,10 +379,10 @@ typedef struct r_refdef_scene_s { int numlights; // intensities for light styles right now, controls rtlights - float rtlightstylevalue[MAX_LIGHTSTYLES]; // float fraction of base light value + float rtlightstylevalue[MAX_LIGHTSTYLES]; ///< float fraction of base light value // 8.8bit fixed point intensities for light styles // controls intensity lightmap layers - unsigned short lightstylevalue[MAX_LIGHTSTYLES]; // 8.8 fraction of base light value + unsigned short lightstylevalue[MAX_LIGHTSTYLES]; ///< 8.8 fraction of base light value // adds brightness to the whole scene, separate from lightmapintensity // see CL_UpdateEntityShading diff --git a/sbar.c b/sbar.c index 7b914d84..1a0b4a90 100644 --- a/sbar.c +++ b/sbar.c @@ -891,7 +891,7 @@ static void Sbar_DrawInventory (void) // items for (i=0 ; i<6 ; i++) - if (cl.stats[STAT_ITEMS] & (1<<(17+i))) + if (cl.stats[STAT_ITEMS] & (1u<<(17+i))) { //MED 01/04/97 changed keys if (!(gamemode == GAME_HIPNOTIC || gamemode == GAME_QUOTH) || (i>1)) @@ -903,7 +903,7 @@ static void Sbar_DrawInventory (void) if (gamemode == GAME_HIPNOTIC || gamemode == GAME_QUOTH) { for (i=0 ; i<2 ; i++) - if (cl.stats[STAT_ITEMS] & (1<<(24+i))) + if (cl.stats[STAT_ITEMS] & (1u<<(24+i))) Sbar_DrawPic (288 + i*16, -16, hsb_items[i]); } @@ -911,14 +911,14 @@ static void Sbar_DrawInventory (void) { // new rogue items for (i=0 ; i<2 ; i++) - if (cl.stats[STAT_ITEMS] & (1<<(29+i))) + if (cl.stats[STAT_ITEMS] & (1u<<(29+i))) Sbar_DrawPic (288 + i*16, -16, rsb_items[i]); } else { // sigils for (i=0 ; i<4 ; i++) - if (cl.stats[STAT_ITEMS] & (1<<(28+i))) + if (cl.stats[STAT_ITEMS] & (1u<<(28+i))) Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]); } } -- 2.39.2