mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-22 09:11:33 +00:00
common code: clean up code by cppcheck recomendations
This commit is contained in:
parent
10cc304778
commit
3039fe723d
11 changed files with 133 additions and 140 deletions
|
@ -288,6 +288,24 @@ Mod_LoadFrames_DKM2(dmdx_t *pheader, const byte *src, size_t inframesize, vec3_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Mod_LoadFixImages(const char* mod_name, dmdx_t *pheader, qboolean internal)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < pheader->num_skins; i++)
|
||||||
|
{
|
||||||
|
char *skin;
|
||||||
|
|
||||||
|
skin = (char *)pheader + pheader->ofs_skins + i * MAX_SKINNAME;
|
||||||
|
skin[MAX_SKINNAME - 1] = 0;
|
||||||
|
|
||||||
|
R_Printf(PRINT_DEVELOPER, "%s: %s #%d: Should load %s '%s'\n",
|
||||||
|
__func__, mod_name, i, internal ? "internal": "external", skin);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
Mod_LoadModel_MDL
|
Mod_LoadModel_MDL
|
||||||
|
@ -590,16 +608,7 @@ Mod_LoadModel_MDL(const char *mod_name, const void *buffer, int modfilelen,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
Mod_LoadFixImages(mod_name, pheader, true);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < pheader->num_skins; i++)
|
|
||||||
{
|
|
||||||
R_Printf(PRINT_DEVELOPER, "%s: %s #%d: Should load internal '%s'\n",
|
|
||||||
__func__, mod_name, i,
|
|
||||||
(char *)pheader + pheader->ofs_skins + i*MAX_SKINNAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*type = mod_alias;
|
*type = mod_alias;
|
||||||
|
|
||||||
|
@ -833,17 +842,7 @@ Mod_LoadModel_MD3(const char *mod_name, const void *buffer, int modfilelen,
|
||||||
}
|
}
|
||||||
free(vertx);
|
free(vertx);
|
||||||
|
|
||||||
/* TODO: make separate function */
|
Mod_LoadFixImages(mod_name, pheader, false);
|
||||||
for (i = 0; i < pheader->num_skins; i++)
|
|
||||||
{
|
|
||||||
char *skinname;
|
|
||||||
|
|
||||||
skinname = (char *)pheader + pheader->ofs_skins + i * MAX_SKINNAME;
|
|
||||||
skinname[MAX_SKINNAME - 1] = 0;
|
|
||||||
|
|
||||||
R_Printf(PRINT_DEVELOPER, "%s: %s #%d: Should load external '%s'\n",
|
|
||||||
__func__, mod_name, i, skinname);
|
|
||||||
}
|
|
||||||
|
|
||||||
*type = mod_alias;
|
*type = mod_alias;
|
||||||
|
|
||||||
|
@ -1017,16 +1016,7 @@ Mod_LoadModel_MD2(const char *mod_name, const void *buffer, int modfilelen,
|
||||||
memcpy((char *)pheader + pheader->ofs_skins, (char *)buffer + pinmodel.ofs_skins,
|
memcpy((char *)pheader + pheader->ofs_skins, (char *)buffer + pinmodel.ofs_skins,
|
||||||
pheader->num_skins * MAX_SKINNAME);
|
pheader->num_skins * MAX_SKINNAME);
|
||||||
|
|
||||||
for (i = 0; i < pheader->num_skins; i++)
|
Mod_LoadFixImages(mod_name, pheader, false);
|
||||||
{
|
|
||||||
char *skin;
|
|
||||||
|
|
||||||
skin = (char *)pheader + pheader->ofs_skins + i * MAX_SKINNAME;
|
|
||||||
skin[MAX_SKINNAME - 1] = 0;
|
|
||||||
|
|
||||||
R_Printf(PRINT_DEVELOPER, "%s: %s #%d: Should load external '%s'\n",
|
|
||||||
__func__, mod_name, i, skin);
|
|
||||||
}
|
|
||||||
|
|
||||||
*type = mod_alias;
|
*type = mod_alias;
|
||||||
|
|
||||||
|
@ -1357,16 +1347,7 @@ Mod_LoadModel_Flex(const char *mod_name, const void *buffer, int modfilelen,
|
||||||
src += size;
|
src += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
Mod_LoadFixImages(mod_name, pheader, false);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < pheader->num_skins; i++)
|
|
||||||
{
|
|
||||||
R_Printf(PRINT_DEVELOPER, "%s: %s #%d: Should load external '%s'\n",
|
|
||||||
__func__, mod_name, i,
|
|
||||||
(char *)pheader + pheader->ofs_skins + i * MAX_SKINNAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*type = mod_alias;
|
*type = mod_alias;
|
||||||
|
|
||||||
|
@ -1492,12 +1473,7 @@ Mod_LoadModel_DKM(const char *mod_name, const void *buffer, int modfilelen,
|
||||||
Mod_LoadDkmTriangleList(pheader,
|
Mod_LoadDkmTriangleList(pheader,
|
||||||
(dkmtriangle_t *)((byte *)buffer + header.ofs_tris));
|
(dkmtriangle_t *)((byte *)buffer + header.ofs_tris));
|
||||||
|
|
||||||
for (i = 0; i < pheader->num_skins; i++)
|
Mod_LoadFixImages(mod_name, pheader, false);
|
||||||
{
|
|
||||||
R_Printf(PRINT_DEVELOPER, "%s: %s #%d: Should load external '%s'\n",
|
|
||||||
__func__, mod_name, i,
|
|
||||||
(char *)pheader + pheader->ofs_skins + i * MAX_SKINNAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
*type = mod_alias;
|
*type = mod_alias;
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,7 @@ LoadPCX(const char *origname, byte **pic, byte **palette, int *width, int *heigh
|
||||||
void
|
void
|
||||||
GetPCXInfo(const char *origname, int *width, int *height)
|
GetPCXInfo(const char *origname, int *width, int *height)
|
||||||
{
|
{
|
||||||
pcx_t *pcx;
|
const pcx_t *pcx;
|
||||||
byte *raw;
|
byte *raw;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ GenerateColormap(const byte *palette, byte *out_colormap)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GetPCXPalette24to8(byte *d_8to24table, byte** d_16to8table)
|
GetPCXPalette24to8(const byte *d_8to24table, byte** d_16to8table)
|
||||||
{
|
{
|
||||||
unsigned char * table16to8;
|
unsigned char * table16to8;
|
||||||
char tablefile[] = "pics/16to8.dat";
|
char tablefile[] = "pics/16to8.dat";
|
||||||
|
@ -453,7 +453,6 @@ GetPCXPalette(byte **colormap, unsigned *d_8to24table)
|
||||||
{
|
{
|
||||||
char filename[] = "pics/colormap.pcx";
|
char filename[] = "pics/colormap.pcx";
|
||||||
byte *pal;
|
byte *pal;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* get the palette and colormap */
|
/* get the palette and colormap */
|
||||||
LoadPCX(filename, colormap, &pal, NULL, NULL);
|
LoadPCX(filename, colormap, &pal, NULL, NULL);
|
||||||
|
@ -502,11 +501,13 @@ GetPCXPalette(byte **colormap, unsigned *d_8to24table)
|
||||||
|
|
||||||
if (!*colormap || !pal)
|
if (!*colormap || !pal)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
R_Printf(PRINT_ALL, "%s: Couldn't load %s, use generated palette\n",
|
R_Printf(PRINT_ALL, "%s: Couldn't load %s, use generated palette\n",
|
||||||
__func__, filename);
|
__func__, filename);
|
||||||
|
|
||||||
/* palette r:2bit, g:3bit, b:3bit */
|
/* palette r:2bit, g:3bit, b:3bit */
|
||||||
for (i=0 ; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
unsigned v;
|
unsigned v;
|
||||||
|
|
||||||
|
@ -530,21 +531,25 @@ GetPCXPalette(byte **colormap, unsigned *d_8to24table)
|
||||||
GenerateColormap((const byte *)d_8to24table, *colormap);
|
GenerateColormap((const byte *)d_8to24table, *colormap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
for (i = 0; i < 256; i++)
|
|
||||||
{
|
{
|
||||||
unsigned v;
|
int i;
|
||||||
int r, g, b;
|
|
||||||
|
|
||||||
r = pal[i*3+0];
|
for (i = 0; i < 256; i++)
|
||||||
g = pal[i*3+1];
|
{
|
||||||
b = pal[i*3+2];
|
unsigned v;
|
||||||
|
int r, g, b;
|
||||||
|
|
||||||
v = (255U<<24) + (r<<0) + (g<<8) + (b<<16);
|
r = pal[i*3+0];
|
||||||
d_8to24table[i] = LittleLong(v);
|
g = pal[i*3+1];
|
||||||
|
b = pal[i*3+2];
|
||||||
|
|
||||||
|
v = (255U<<24) + (r<<0) + (g<<8) + (b<<16);
|
||||||
|
d_8to24table[i] = LittleLong(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
d_8to24table[255] &= LittleLong(0xffffff); // 255 is transparent
|
||||||
|
|
||||||
|
free(pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
d_8to24table[255] &= LittleLong(0xffffff); // 255 is transparent
|
|
||||||
|
|
||||||
free (pal);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ ResizeSTB(const byte *input_pixels, int input_width, int input_height,
|
||||||
void
|
void
|
||||||
SmoothColorImage(unsigned *dst, size_t size, size_t rstep)
|
SmoothColorImage(unsigned *dst, size_t size, size_t rstep)
|
||||||
{
|
{
|
||||||
unsigned *full_size;
|
const unsigned *full_size;
|
||||||
unsigned last_color;
|
unsigned last_color;
|
||||||
unsigned *last_diff;
|
unsigned *last_diff;
|
||||||
|
|
||||||
|
@ -253,7 +253,8 @@ scale2x(const byte *src, byte *dst, int width, int height)
|
||||||
{
|
{
|
||||||
const byte *in_buff = src;
|
const byte *in_buff = src;
|
||||||
byte *out_buff = dst;
|
byte *out_buff = dst;
|
||||||
byte *out_buff_full = dst + ((width * height) << 2);
|
const byte *out_buff_full = dst + ((width * height) << 2);
|
||||||
|
|
||||||
while (out_buff < out_buff_full)
|
while (out_buff < out_buff_full)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
@ -340,7 +341,8 @@ scale3x(const byte *src, byte *dst, int width, int height)
|
||||||
{
|
{
|
||||||
const byte *in_buff = src;
|
const byte *in_buff = src;
|
||||||
byte *out_buff = dst;
|
byte *out_buff = dst;
|
||||||
byte *out_buff_full = dst + ((width * height) * 9);
|
const byte *out_buff_full = dst + ((width * height) * 9);
|
||||||
|
|
||||||
while (out_buff < out_buff_full)
|
while (out_buff < out_buff_full)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
|
@ -61,7 +61,7 @@ R_TextureAnimation(const entity_t *currententity, const mtexinfo_t *tex)
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean
|
qboolean
|
||||||
R_AreaVisible(const byte *areabits, mleaf_t *pleaf)
|
R_AreaVisible(const byte *areabits, const mleaf_t *pleaf)
|
||||||
{
|
{
|
||||||
int area;
|
int area;
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ R_AreaVisible(const byte *areabits, mleaf_t *pleaf)
|
||||||
* Returns true if the box is completely outside the frustom
|
* Returns true if the box is completely outside the frustom
|
||||||
*/
|
*/
|
||||||
qboolean
|
qboolean
|
||||||
R_CullBox(vec3_t mins, vec3_t maxs, cplane_t *frustum)
|
R_CullBox(vec3_t mins, vec3_t maxs, const cplane_t *frustum)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ R_CullBox(vec3_t mins, vec3_t maxs, cplane_t *frustum)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
R_SignbitsForPlane(cplane_t *out)
|
R_SignbitsForPlane(const cplane_t *out)
|
||||||
{
|
{
|
||||||
int bits, j;
|
int bits, j;
|
||||||
|
|
||||||
|
@ -314,12 +314,13 @@ R_SubdividePolygon(int numverts, float *verts, msurface_t *warpface)
|
||||||
* can be done reasonably.
|
* can be done reasonably.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
R_SubdivideSurface(int *surfedges, mvertex_t *vertexes, medge_t *edges, msurface_t *fa)
|
R_SubdivideSurface(const int *surfedges, mvertex_t *vertexes, medge_t *edges,
|
||||||
|
msurface_t *fa)
|
||||||
{
|
{
|
||||||
|
const float *vec;
|
||||||
vec3_t verts[64];
|
vec3_t verts[64];
|
||||||
int numverts;
|
int numverts;
|
||||||
int i;
|
int i;
|
||||||
float *vec;
|
|
||||||
|
|
||||||
/* convert edges back to a normal polygon */
|
/* convert edges back to a normal polygon */
|
||||||
numverts = 0;
|
numverts = 0;
|
||||||
|
|
|
@ -31,7 +31,7 @@ LoadWalQ2(const char *origname, const char *name, const byte *data, size_t size,
|
||||||
imagetype_t type, loadimage_t load_image)
|
imagetype_t type, loadimage_t load_image)
|
||||||
{
|
{
|
||||||
int width, height, ofs;
|
int width, height, ofs;
|
||||||
miptex_t *mt;
|
const miptex_t *mt;
|
||||||
|
|
||||||
mt = (miptex_t *)data;
|
mt = (miptex_t *)data;
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ GetWalInfo(const char *origname, int *width, int *height)
|
||||||
|
|
||||||
if (size > sizeof(dkmtex_t) && *data == DKM_WAL_VERSION)
|
if (size > sizeof(dkmtex_t) && *data == DKM_WAL_VERSION)
|
||||||
{
|
{
|
||||||
dkmtex_t *mt;
|
const dkmtex_t *mt;
|
||||||
|
|
||||||
mt = (dkmtex_t *)data;
|
mt = (dkmtex_t *)data;
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ GetWalInfo(const char *origname, int *width, int *height)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
miptex_t *mt;
|
const miptex_t *mt;
|
||||||
|
|
||||||
mt = (miptex_t *)data;
|
mt = (miptex_t *)data;
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ extern struct image_s* LoadM32(const char *origname, const char *namewe, imagety
|
||||||
loadimage_t load_image);
|
loadimage_t load_image);
|
||||||
extern void FixFileExt(const char *origname, const char *ext, char *filename, size_t size);
|
extern void FixFileExt(const char *origname, const char *ext, char *filename, size_t size);
|
||||||
extern void GetPCXPalette(byte **colormap, unsigned *d_8to24table);
|
extern void GetPCXPalette(byte **colormap, unsigned *d_8to24table);
|
||||||
extern void GetPCXPalette24to8(byte *d_8to24table, byte** d_16to8table);
|
extern void GetPCXPalette24to8(const byte *d_8to24table, byte** d_16to8table);
|
||||||
extern void LoadPCX(const char *origname, byte **pic, byte **palette, int *width, int *height);
|
extern void LoadPCX(const char *origname, byte **pic, byte **palette, int *width, int *height);
|
||||||
extern void GetPCXInfo(const char *origname, int *width, int *height);
|
extern void GetPCXInfo(const char *origname, int *width, int *height);
|
||||||
extern void GetWalInfo(const char *name, int *width, int *height);
|
extern void GetWalInfo(const char *name, int *width, int *height);
|
||||||
|
@ -370,11 +370,11 @@ extern void R_PushDlights(refdef_t *r_newrefdef, mnode_t *nodes, int r_dlightfra
|
||||||
msurface_t *surfaces);
|
msurface_t *surfaces);
|
||||||
extern struct image_s *R_TextureAnimation(const entity_t *currententity,
|
extern struct image_s *R_TextureAnimation(const entity_t *currententity,
|
||||||
const mtexinfo_t *tex);
|
const mtexinfo_t *tex);
|
||||||
extern qboolean R_AreaVisible(const byte *areabits, mleaf_t *pleaf);
|
extern qboolean R_AreaVisible(const byte *areabits, const mleaf_t *pleaf);
|
||||||
extern qboolean R_CullBox(vec3_t mins, vec3_t maxs, cplane_t *frustum);
|
extern qboolean R_CullBox(vec3_t mins, vec3_t maxs, const cplane_t *frustum);
|
||||||
extern void R_SetFrustum(vec3_t vup, vec3_t vpn, vec3_t vright, vec3_t r_origin,
|
extern void R_SetFrustum(vec3_t vup, vec3_t vpn, vec3_t vright, vec3_t r_origin,
|
||||||
float fov_x, float fov_y, cplane_t *frustum);
|
float fov_x, float fov_y, cplane_t *frustum);
|
||||||
extern void R_SubdivideSurface(int *surfedges, mvertex_t *vertexes, medge_t *edges,
|
extern void R_SubdivideSurface(const int *surfedges, mvertex_t *vertexes, medge_t *edges,
|
||||||
msurface_t *fa);
|
msurface_t *fa);
|
||||||
|
|
||||||
/* Mesh logic */
|
/* Mesh logic */
|
||||||
|
|
|
@ -765,7 +765,7 @@ Cmd_RemoveCommand(const char *cmd_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean
|
qboolean
|
||||||
Cmd_Exists(char *cmd_name)
|
Cmd_Exists(const char *cmd_name)
|
||||||
{
|
{
|
||||||
cmd_function_t *cmd;
|
cmd_function_t *cmd;
|
||||||
|
|
||||||
|
|
|
@ -196,9 +196,7 @@ FloodArea_r(carea_t *area, int floodnum)
|
||||||
static void
|
static void
|
||||||
FloodAreaConnections(void)
|
FloodAreaConnections(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i, floodnum;
|
||||||
carea_t *area;
|
|
||||||
int floodnum;
|
|
||||||
|
|
||||||
/* all current floods are now invalid */
|
/* all current floods are now invalid */
|
||||||
floodvalid++;
|
floodvalid++;
|
||||||
|
@ -207,6 +205,8 @@ FloodAreaConnections(void)
|
||||||
/* area 0 is not used */
|
/* area 0 is not used */
|
||||||
for (i = 1; i < cmod->numareas; i++)
|
for (i = 1; i < cmod->numareas; i++)
|
||||||
{
|
{
|
||||||
|
carea_t *area;
|
||||||
|
|
||||||
area = &cmod->map_areas[i];
|
area = &cmod->map_areas[i];
|
||||||
|
|
||||||
if (area->floodvalid == floodvalid)
|
if (area->floodvalid == floodvalid)
|
||||||
|
@ -263,8 +263,6 @@ CM_AreasConnected(int area1, int area2)
|
||||||
int
|
int
|
||||||
CM_WriteAreaBits(byte *buffer, int area)
|
CM_WriteAreaBits(byte *buffer, int area)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int floodnum;
|
|
||||||
int bytes;
|
int bytes;
|
||||||
|
|
||||||
bytes = (cmod->numareas + 7) >> 3;
|
bytes = (cmod->numareas + 7) >> 3;
|
||||||
|
@ -274,9 +272,10 @@ CM_WriteAreaBits(byte *buffer, int area)
|
||||||
/* for debugging, send everything */
|
/* for debugging, send everything */
|
||||||
memset(buffer, 255, bytes);
|
memset(buffer, 255, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int floodnum, i;
|
||||||
|
|
||||||
memset(buffer, 0, bytes);
|
memset(buffer, 0, bytes);
|
||||||
|
|
||||||
floodnum = cmod->map_areas[area].floodnum;
|
floodnum = cmod->map_areas[area].floodnum;
|
||||||
|
@ -320,12 +319,13 @@ CM_ReadPortalState(fileHandle_t f)
|
||||||
qboolean
|
qboolean
|
||||||
CM_HeadnodeVisible(int nodenum, byte *visbits)
|
CM_HeadnodeVisible(int nodenum, byte *visbits)
|
||||||
{
|
{
|
||||||
int leafnum1;
|
const cnode_t *node;
|
||||||
int cluster;
|
|
||||||
cnode_t *node;
|
|
||||||
|
|
||||||
if (nodenum < 0)
|
if (nodenum < 0)
|
||||||
{
|
{
|
||||||
|
int leafnum1;
|
||||||
|
int cluster;
|
||||||
|
|
||||||
leafnum1 = -1 - nodenum;
|
leafnum1 = -1 - nodenum;
|
||||||
cluster = cmod->map_leafs[leafnum1].cluster;
|
cluster = cmod->map_leafs[leafnum1].cluster;
|
||||||
|
|
||||||
|
@ -359,11 +359,8 @@ CM_HeadnodeVisible(int nodenum, byte *visbits)
|
||||||
static void
|
static void
|
||||||
CM_InitBoxHull(void)
|
CM_InitBoxHull(void)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int side;
|
|
||||||
cnode_t *c;
|
|
||||||
cplane_t *p;
|
cplane_t *p;
|
||||||
cbrushside_t *s;
|
int i;
|
||||||
|
|
||||||
box_headnode = cmod->numnodes;
|
box_headnode = cmod->numnodes;
|
||||||
box_planes = &cmod->map_planes[cmod->numplanes];
|
box_planes = &cmod->map_planes[cmod->numplanes];
|
||||||
|
@ -391,6 +388,10 @@ CM_InitBoxHull(void)
|
||||||
|
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
|
cbrushside_t *s;
|
||||||
|
cnode_t *c;
|
||||||
|
int side;
|
||||||
|
|
||||||
side = i & 1;
|
side = i & 1;
|
||||||
|
|
||||||
/* brush sides */
|
/* brush sides */
|
||||||
|
@ -514,12 +515,12 @@ static void
|
||||||
CM_BoxLeafnums_r(int nodenum, vec3_t leaf_mins, vec3_t leaf_maxs,
|
CM_BoxLeafnums_r(int nodenum, vec3_t leaf_mins, vec3_t leaf_maxs,
|
||||||
int *leaf_list, int *leaf_count, int leaf_maxcount)
|
int *leaf_list, int *leaf_count, int leaf_maxcount)
|
||||||
{
|
{
|
||||||
cplane_t *plane;
|
|
||||||
cnode_t *node;
|
|
||||||
int s;
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
const cplane_t *plane;
|
||||||
|
cnode_t *node;
|
||||||
|
int s;
|
||||||
|
|
||||||
if (nodenum < 0)
|
if (nodenum < 0)
|
||||||
{
|
{
|
||||||
if ((*leaf_count) >= leaf_maxcount)
|
if ((*leaf_count) >= leaf_maxcount)
|
||||||
|
@ -544,12 +545,10 @@ CM_BoxLeafnums_r(int nodenum, vec3_t leaf_mins, vec3_t leaf_maxs,
|
||||||
{
|
{
|
||||||
nodenum = node->children[0];
|
nodenum = node->children[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (s == 2)
|
else if (s == 2)
|
||||||
{
|
{
|
||||||
nodenum = node->children[1];
|
nodenum = node->children[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* go down both */
|
/* go down both */
|
||||||
|
@ -651,17 +650,18 @@ CM_TransformedPointContents(vec3_t p, int headnode,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CM_ClipBoxToBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
CM_ClipBoxToBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
||||||
vec3_t p2, trace_t *trace, cbrush_t *brush)
|
vec3_t p2, trace_t *trace, const cbrush_t *brush)
|
||||||
{
|
{
|
||||||
int i, j;
|
|
||||||
cplane_t *plane, *clipplane;
|
|
||||||
float dist;
|
|
||||||
float enterfrac, leavefrac;
|
|
||||||
vec3_t ofs;
|
|
||||||
float d1, d2;
|
|
||||||
qboolean getout, startout;
|
|
||||||
float f;
|
|
||||||
cbrushside_t *side, *leadside;
|
cbrushside_t *side, *leadside;
|
||||||
|
float enterfrac, leavefrac;
|
||||||
|
const cplane_t *clipplane;
|
||||||
|
qboolean getout, startout;
|
||||||
|
cplane_t *plane;
|
||||||
|
float d1, d2;
|
||||||
|
float dist;
|
||||||
|
vec3_t ofs;
|
||||||
|
int i, j;
|
||||||
|
float f;
|
||||||
|
|
||||||
enterfrac = -1;
|
enterfrac = -1;
|
||||||
leavefrac = 1;
|
leavefrac = 1;
|
||||||
|
@ -808,13 +808,11 @@ CM_ClipBoxToBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CM_TestBoxInBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
CM_TestBoxInBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
||||||
trace_t *trace, cbrush_t *brush)
|
trace_t *trace, const cbrush_t *brush)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
cplane_t *plane;
|
cplane_t *plane;
|
||||||
float dist;
|
|
||||||
vec3_t ofs;
|
vec3_t ofs;
|
||||||
float d1;
|
|
||||||
cbrushside_t *side;
|
cbrushside_t *side;
|
||||||
|
|
||||||
if (!brush->numsides || !cmod->map_brushsides)
|
if (!brush->numsides || !cmod->map_brushsides)
|
||||||
|
@ -824,6 +822,8 @@ CM_TestBoxInBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
||||||
|
|
||||||
for (i = 0; i < brush->numsides; i++)
|
for (i = 0; i < brush->numsides; i++)
|
||||||
{
|
{
|
||||||
|
float d1, dist;
|
||||||
|
|
||||||
if (((brush->firstbrushside + i) < 0) ||
|
if (((brush->firstbrushside + i) < 0) ||
|
||||||
((brush->firstbrushside + i) >= (cmod->numbrushsides + EXTRA_LUMP_BRUSHSIDES)))
|
((brush->firstbrushside + i) >= (cmod->numbrushsides + EXTRA_LUMP_BRUSHSIDES)))
|
||||||
{
|
{
|
||||||
|
@ -844,7 +844,6 @@ CM_TestBoxInBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
||||||
{
|
{
|
||||||
ofs[j] = maxs[j];
|
ofs[j] = maxs[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ofs[j] = mins[j];
|
ofs[j] = mins[j];
|
||||||
|
@ -872,9 +871,8 @@ CM_TestBoxInBrush(vec3_t mins, vec3_t maxs, vec3_t p1,
|
||||||
static void
|
static void
|
||||||
CM_TraceToLeaf(int leafnum)
|
CM_TraceToLeaf(int leafnum)
|
||||||
{
|
{
|
||||||
int k, maxleaf, brushnum;
|
const cleaf_t *leaf;
|
||||||
cleaf_t *leaf;
|
int k, maxleaf;
|
||||||
cbrush_t *b;
|
|
||||||
|
|
||||||
if (leafnum >= (cmod->numleafs + EXTRA_LUMP_LEAFS) || leafnum < 0)
|
if (leafnum >= (cmod->numleafs + EXTRA_LUMP_LEAFS) || leafnum < 0)
|
||||||
{
|
{
|
||||||
|
@ -898,6 +896,9 @@ CM_TraceToLeaf(int leafnum)
|
||||||
/* trace line against all brushes in the leaf */
|
/* trace line against all brushes in the leaf */
|
||||||
for (k = 0; k < leaf->numleafbrushes; k++)
|
for (k = 0; k < leaf->numleafbrushes; k++)
|
||||||
{
|
{
|
||||||
|
int brushnum;
|
||||||
|
cbrush_t *b;
|
||||||
|
|
||||||
brushnum = cmod->map_leafbrushes[leaf->firstleafbrush + k];
|
brushnum = cmod->map_leafbrushes[leaf->firstleafbrush + k];
|
||||||
|
|
||||||
if (brushnum < 0 || brushnum >= (cmod->numbrushes + EXTRA_LUMP_BRUSHES))
|
if (brushnum < 0 || brushnum >= (cmod->numbrushes + EXTRA_LUMP_BRUSHES))
|
||||||
|
@ -932,9 +933,8 @@ CM_TraceToLeaf(int leafnum)
|
||||||
static void
|
static void
|
||||||
CM_TestInLeaf(int leafnum)
|
CM_TestInLeaf(int leafnum)
|
||||||
{
|
{
|
||||||
int k, maxleaf, brushnum;
|
const cleaf_t *leaf;
|
||||||
cleaf_t *leaf;
|
int k, maxleaf;
|
||||||
cbrush_t *b;
|
|
||||||
|
|
||||||
if (leafnum > (cmod->numleafs + EXTRA_LUMP_LEAFS) || leafnum < 0)
|
if (leafnum > (cmod->numleafs + EXTRA_LUMP_LEAFS) || leafnum < 0)
|
||||||
{
|
{
|
||||||
|
@ -958,6 +958,9 @@ CM_TestInLeaf(int leafnum)
|
||||||
/* trace line against all brushes in the leaf */
|
/* trace line against all brushes in the leaf */
|
||||||
for (k = 0; k < leaf->numleafbrushes; k++)
|
for (k = 0; k < leaf->numleafbrushes; k++)
|
||||||
{
|
{
|
||||||
|
int brushnum;
|
||||||
|
cbrush_t *b;
|
||||||
|
|
||||||
brushnum = cmod->map_leafbrushes[leaf->firstleafbrush + k];
|
brushnum = cmod->map_leafbrushes[leaf->firstleafbrush + k];
|
||||||
|
|
||||||
if (brushnum < 0 || brushnum >= (cmod->numbrushes + EXTRA_LUMP_BRUSHES))
|
if (brushnum < 0 || brushnum >= (cmod->numbrushes + EXTRA_LUMP_BRUSHES))
|
||||||
|
@ -1131,8 +1134,6 @@ trace_t
|
||||||
CM_BoxTrace(vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs,
|
CM_BoxTrace(vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs,
|
||||||
int headnode, int brushmask)
|
int headnode, int brushmask)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
checkcount++; /* for multi-check avoidance */
|
checkcount++; /* for multi-check avoidance */
|
||||||
|
|
||||||
#ifndef DEDICATED_ONLY
|
#ifndef DEDICATED_ONLY
|
||||||
|
@ -1212,9 +1213,10 @@ CM_BoxTrace(vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs,
|
||||||
{
|
{
|
||||||
VectorCopy(end, trace_trace.endpos);
|
VectorCopy(end, trace_trace.endpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
trace_trace.endpos[i] = start[i] + trace_trace.fraction *
|
trace_trace.endpos[i] = start[i] + trace_trace.fraction *
|
||||||
|
@ -1233,12 +1235,11 @@ trace_t
|
||||||
CM_TransformedBoxTrace(vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs,
|
CM_TransformedBoxTrace(vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs,
|
||||||
int headnode, int brushmask, vec3_t origin, vec3_t angles)
|
int headnode, int brushmask, vec3_t origin, vec3_t angles)
|
||||||
{
|
{
|
||||||
trace_t trace;
|
|
||||||
vec3_t start_l, end_l;
|
|
||||||
vec3_t a;
|
|
||||||
vec3_t forward, right, up;
|
vec3_t forward, right, up;
|
||||||
vec3_t temp;
|
vec3_t start_l, end_l;
|
||||||
qboolean rotated;
|
qboolean rotated;
|
||||||
|
trace_t trace;
|
||||||
|
vec3_t temp;
|
||||||
|
|
||||||
/* subtract origin offset */
|
/* subtract origin offset */
|
||||||
VectorSubtract(start, origin, start_l);
|
VectorSubtract(start, origin, start_l);
|
||||||
|
@ -1250,7 +1251,6 @@ CM_TransformedBoxTrace(vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs,
|
||||||
{
|
{
|
||||||
rotated = true;
|
rotated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rotated = false;
|
rotated = false;
|
||||||
|
@ -1276,6 +1276,8 @@ CM_TransformedBoxTrace(vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs,
|
||||||
|
|
||||||
if (rotated && (trace.fraction != 1.0))
|
if (rotated && (trace.fraction != 1.0))
|
||||||
{
|
{
|
||||||
|
vec3_t a;
|
||||||
|
|
||||||
VectorNegate(angles, a);
|
VectorNegate(angles, a);
|
||||||
AngleVectors(a, forward, right, up);
|
AngleVectors(a, forward, right, up);
|
||||||
|
|
||||||
|
@ -1804,8 +1806,8 @@ static void
|
||||||
CMod_LoadAreaPortals(const char *name, dareaportal_t **map_areaportals, qboolean **portalopen,
|
CMod_LoadAreaPortals(const char *name, dareaportal_t **map_areaportals, qboolean **portalopen,
|
||||||
int *numareaportals, const byte *cmod_base, const lump_t *l)
|
int *numareaportals, const byte *cmod_base, const lump_t *l)
|
||||||
{
|
{
|
||||||
|
const dareaportal_t *in;
|
||||||
dareaportal_t *out;
|
dareaportal_t *out;
|
||||||
dareaportal_t *in;
|
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
in = (void *)(cmod_base + l->fileofs);
|
in = (void *)(cmod_base + l->fileofs);
|
||||||
|
@ -1925,9 +1927,9 @@ static void
|
||||||
CM_LoadCachedMap(const char *name, model_t *mod)
|
CM_LoadCachedMap(const char *name, model_t *mod)
|
||||||
{
|
{
|
||||||
int i, length, hunkSize = 0;
|
int i, length, hunkSize = 0;
|
||||||
|
const byte *cmod_base;
|
||||||
dheader_t header;
|
dheader_t header;
|
||||||
unsigned *buf;
|
unsigned *buf;
|
||||||
byte *cmod_base;
|
|
||||||
|
|
||||||
length = FS_LoadFile(name, (void **)&buf);
|
length = FS_LoadFile(name, (void **)&buf);
|
||||||
|
|
||||||
|
|
|
@ -405,7 +405,7 @@ void Cmd_AddCommand(const char *cmd_name, xcommand_t function);
|
||||||
/* as a clc_stringcmd instead of executed locally */
|
/* as a clc_stringcmd instead of executed locally */
|
||||||
void Cmd_RemoveCommand(const char *cmd_name);
|
void Cmd_RemoveCommand(const char *cmd_name);
|
||||||
|
|
||||||
qboolean Cmd_Exists(char *cmd_name);
|
qboolean Cmd_Exists(const char *cmd_name);
|
||||||
|
|
||||||
/* used by the cvar code to check for cvar / command name overlap */
|
/* used by the cvar code to check for cvar / command name overlap */
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ void AngleVectors2(const vec3_t value1, vec3_t angles);
|
||||||
int BoxOnPlaneSide(const vec3_t emins, const vec3_t emaxs, const struct cplane_s *plane);
|
int BoxOnPlaneSide(const vec3_t emins, const vec3_t emaxs, const struct cplane_s *plane);
|
||||||
float anglemod(float a);
|
float anglemod(float a);
|
||||||
float Q_fabs(float f);
|
float Q_fabs(float f);
|
||||||
float LerpAngle(float a1, float a2, float frac);
|
float LerpAngle(float a2, float a1, float frac);
|
||||||
int BoxOnPlaneSide2(const vec3_t emins, const vec3_t emaxs, const struct cplane_s *p);
|
int BoxOnPlaneSide2(const vec3_t emins, const vec3_t emaxs, const struct cplane_s *p);
|
||||||
|
|
||||||
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
|
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
|
||||||
|
|
|
@ -133,7 +133,6 @@ AngleVectors(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
|
||||||
void
|
void
|
||||||
AngleVectors2(const vec3_t value1, vec3_t angles)
|
AngleVectors2(const vec3_t value1, vec3_t angles)
|
||||||
{
|
{
|
||||||
float forward;
|
|
||||||
float yaw, pitch;
|
float yaw, pitch;
|
||||||
|
|
||||||
if ((value1[1] == 0) && (value1[0] == 0))
|
if ((value1[1] == 0) && (value1[0] == 0))
|
||||||
|
@ -152,6 +151,8 @@ AngleVectors2(const vec3_t value1, vec3_t angles)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
float forward;
|
||||||
|
|
||||||
if (value1[0])
|
if (value1[0])
|
||||||
{
|
{
|
||||||
yaw = ((float)atan2(value1[1], value1[0]) * 180 / M_PI);
|
yaw = ((float)atan2(value1[1], value1[0]) * 180 / M_PI);
|
||||||
|
@ -470,10 +471,11 @@ void
|
||||||
AddPointToBounds(const vec3_t v, vec3_t mins, vec3_t maxs)
|
AddPointToBounds(const vec3_t v, vec3_t mins, vec3_t maxs)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
vec_t val;
|
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
vec_t val;
|
||||||
|
|
||||||
val = v[i];
|
val = v[i];
|
||||||
|
|
||||||
if (val < mins[i])
|
if (val < mins[i])
|
||||||
|
@ -502,13 +504,15 @@ VectorCompare(const vec3_t v1, const vec3_t v2)
|
||||||
vec_t
|
vec_t
|
||||||
VectorNormalize(vec3_t v)
|
VectorNormalize(vec3_t v)
|
||||||
{
|
{
|
||||||
float length, ilength;
|
float length;
|
||||||
|
|
||||||
length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
|
length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
|
||||||
length = (float)sqrt(length);
|
length = (float)sqrt(length);
|
||||||
|
|
||||||
if (length)
|
if (length)
|
||||||
{
|
{
|
||||||
|
float ilength;
|
||||||
|
|
||||||
ilength = 1 / length;
|
ilength = 1 / length;
|
||||||
v[0] *= ilength;
|
v[0] *= ilength;
|
||||||
v[1] *= ilength;
|
v[1] *= ilength;
|
||||||
|
@ -1033,10 +1037,12 @@ Q_stricmp(const char *s1, const char *s2)
|
||||||
int
|
int
|
||||||
Q_strncasecmp(const char *s1, const char *s2, int n)
|
Q_strncasecmp(const char *s1, const char *s2, int n)
|
||||||
{
|
{
|
||||||
int c1, c2;
|
int c1;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
int c2;
|
||||||
|
|
||||||
c1 = *s1++;
|
c1 = *s1++;
|
||||||
c2 = *s2++;
|
c2 = *s2++;
|
||||||
|
|
||||||
|
@ -1272,10 +1278,7 @@ Info_ValueForKey(char *s, const char *key)
|
||||||
void
|
void
|
||||||
Info_RemoveKey(char *s, const char *key)
|
Info_RemoveKey(char *s, const char *key)
|
||||||
{
|
{
|
||||||
char *start;
|
char pkey[512], value[512];
|
||||||
char pkey[512];
|
|
||||||
char value[512];
|
|
||||||
char *o;
|
|
||||||
|
|
||||||
if (strstr(key, "\\"))
|
if (strstr(key, "\\"))
|
||||||
{
|
{
|
||||||
|
@ -1284,6 +1287,8 @@ Info_RemoveKey(char *s, const char *key)
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
char *start, *o;
|
||||||
|
|
||||||
start = s;
|
start = s;
|
||||||
|
|
||||||
if (*s == '\\')
|
if (*s == '\\')
|
||||||
|
@ -1351,9 +1356,9 @@ Info_Validate(const char *s)
|
||||||
void
|
void
|
||||||
Info_SetValueForKey(char *s, const char *key, const char *value)
|
Info_SetValueForKey(char *s, const char *key, const char *value)
|
||||||
{
|
{
|
||||||
char newi[MAX_INFO_STRING], *v;
|
|
||||||
int c;
|
|
||||||
int maxsize = MAX_INFO_STRING;
|
int maxsize = MAX_INFO_STRING;
|
||||||
|
char newi[MAX_INFO_STRING];
|
||||||
|
const char *v;
|
||||||
|
|
||||||
if (!key)
|
if (!key)
|
||||||
{
|
{
|
||||||
|
@ -1405,6 +1410,8 @@ Info_SetValueForKey(char *s, const char *key, const char *value)
|
||||||
|
|
||||||
while (*v)
|
while (*v)
|
||||||
{
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
c = *v++;
|
c = *v++;
|
||||||
c &= 127; /* strip high bits */
|
c &= 127; /* strip high bits */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue