Permalink
Browse files

Fix CID 134399

  • Loading branch information...
1 parent 1bdfe08 commit 31077a43a36c1485765c2c4ce3960be9e7ff1cb9 @TimePath TimePath committed with Kangz Jan 15, 2016
Showing with 28 additions and 32 deletions.
  1. +28 −32 daemon/src/common/cm/cm_load.cpp
@@ -50,8 +50,6 @@ clipMap_t cm;
int c_pointcontents;
int c_traces, c_brush_traces, c_patch_traces, c_trisoup_traces;
-byte *cmod_base;
-
cmodel_t box_model;
cplane_t *box_planes;
cbrush_t *box_brush;
@@ -94,7 +92,7 @@ void CM_FreeAll()
CMod_LoadShaders
=================
*/
-void CMod_LoadShaders( lump_t *l )
+void CMod_LoadShaders(const byte *const cmod_base, lump_t *l)
{
dshader_t *in, *out;
int i, count;
@@ -135,7 +133,7 @@ void CMod_LoadShaders( lump_t *l )
CMod_LoadSubmodels
=================
*/
-void CMod_LoadSubmodels( lump_t *l )
+void CMod_LoadSubmodels(const byte *const cmod_base, lump_t *l)
{
dmodel_t *in;
cmodel_t *out;
@@ -202,7 +200,7 @@ CMod_LoadNodes
=================
*/
-void CMod_LoadNodes( lump_t *l )
+void CMod_LoadNodes(const byte *const cmod_base, lump_t *l)
{
dnode_t *in;
int child;
@@ -264,7 +262,7 @@ CMod_LoadBrushes
=================
*/
-void CMod_LoadBrushes( lump_t *l )
+void CMod_LoadBrushes(const byte *const cmod_base, lump_t *l)
{
dbrush_t *in;
cbrush_t *out;
@@ -308,7 +306,7 @@ void CMod_LoadBrushes( lump_t *l )
CMod_LoadLeafs
=================
*/
-void CMod_LoadLeafs( lump_t *l )
+void CMod_LoadLeafs(const byte *const cmod_base, lump_t *l)
{
int i;
cLeaf_t *out;
@@ -363,7 +361,7 @@ void CMod_LoadLeafs( lump_t *l )
CMod_LoadPlanes
=================
*/
-void CMod_LoadPlanes( lump_t *l )
+void CMod_LoadPlanes(const byte *const cmod_base, lump_t *l)
{
int i, j;
cplane_t *out;
@@ -407,7 +405,7 @@ void CMod_LoadPlanes( lump_t *l )
CMod_LoadLeafBrushes
=================
*/
-void CMod_LoadLeafBrushes( lump_t *l )
+void CMod_LoadLeafBrushes(const byte *const cmod_base, lump_t *l)
{
int i;
int *out;
@@ -440,7 +438,7 @@ void CMod_LoadLeafBrushes( lump_t *l )
CMod_LoadLeafSurfaces
=================
*/
-void CMod_LoadLeafSurfaces( lump_t *l )
+void CMod_LoadLeafSurfaces(const byte *const cmod_base, lump_t *l)
{
int i;
int *out;
@@ -472,7 +470,7 @@ void CMod_LoadLeafSurfaces( lump_t *l )
CMod_LoadBrushSides
=================
*/
-void CMod_LoadBrushSides( lump_t *l )
+void CMod_LoadBrushSides(const byte *const cmod_base, lump_t *l)
{
int i;
cbrushside_t *out;
@@ -669,7 +667,7 @@ static void CMod_CreateBrushSideWindings()
CMod_LoadEntityString
=================
*/
-void CMod_LoadEntityString( lump_t *l )
+void CMod_LoadEntityString(const byte *const cmod_base, lump_t *l)
{
const char *p, *token;
char keyname[ MAX_TOKEN_CHARS ];
@@ -738,12 +736,9 @@ CMod_LoadVisibility
=================
*/
#define VIS_HEADER 8
-void CMod_LoadVisibility( lump_t *l )
+void CMod_LoadVisibility(const byte *const cmod_base, lump_t *l)
{
- int len;
- byte *buf;
-
- len = l->filelen;
+ int len = l->filelen;
if ( !len )
{
@@ -753,7 +748,7 @@ void CMod_LoadVisibility( lump_t *l )
return;
}
- buf = cmod_base + l->fileofs;
+ const byte *buf = cmod_base + l->fileofs;
cm.vised = true;
cm.visibility = ( byte * ) CM_Alloc( len - VIS_HEADER );
@@ -771,7 +766,7 @@ CMod_LoadSurfaces
*/
#define MAX_PATCH_SIZE 64
#define MAX_PATCH_VERTS ( MAX_PATCH_SIZE * MAX_PATCH_SIZE )
-void CMod_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexesLump )
+void CMod_LoadSurfaces(const byte *const cmod_base, lump_t *surfs, lump_t *verts, lump_t *indexesLump)
{
drawVert_t *dv, *dv_p;
dsurface_t *in;
@@ -951,21 +946,22 @@ void CM_LoadMap(Str::StringRef name)
name.c_str(), header.version, BSP_VERSION, BSP_VERSION_Q3 );
}
- cmod_base = ( byte * ) mapData.data();
+ const byte *const cmod_base = reinterpret_cast<const byte*>(mapData.data());
// load into heap
- CMod_LoadShaders( &header.lumps[ LUMP_SHADERS ] );
- CMod_LoadLeafs( &header.lumps[ LUMP_LEAFS ] );
- CMod_LoadLeafBrushes( &header.lumps[ LUMP_LEAFBRUSHES ] );
- CMod_LoadLeafSurfaces( &header.lumps[ LUMP_LEAFSURFACES ] );
- CMod_LoadPlanes( &header.lumps[ LUMP_PLANES ] );
- CMod_LoadBrushSides( &header.lumps[ LUMP_BRUSHSIDES ] );
- CMod_LoadBrushes( &header.lumps[ LUMP_BRUSHES ] );
- CMod_LoadSubmodels( &header.lumps[ LUMP_MODELS ] );
- CMod_LoadNodes( &header.lumps[ LUMP_NODES ] );
- CMod_LoadEntityString( &header.lumps[ LUMP_ENTITIES ] );
- CMod_LoadVisibility( &header.lumps[ LUMP_VISIBILITY ] );
- CMod_LoadSurfaces( &header.lumps[ LUMP_SURFACES ], &header.lumps[ LUMP_DRAWVERTS ], &header.lumps[ LUMP_DRAWINDEXES ] );
+ CMod_LoadShaders(cmod_base, &header.lumps[LUMP_SHADERS]);
+ CMod_LoadLeafs(cmod_base, &header.lumps[LUMP_LEAFS]);
+ CMod_LoadLeafBrushes(cmod_base, &header.lumps[LUMP_LEAFBRUSHES]);
+ CMod_LoadLeafSurfaces(cmod_base, &header.lumps[LUMP_LEAFSURFACES]);
+ CMod_LoadPlanes(cmod_base, &header.lumps[LUMP_PLANES]);
+ CMod_LoadBrushSides(cmod_base, &header.lumps[LUMP_BRUSHSIDES]);
+ CMod_LoadBrushes(cmod_base, &header.lumps[LUMP_BRUSHES]);
+ CMod_LoadSubmodels(cmod_base, &header.lumps[LUMP_MODELS]);
+ CMod_LoadNodes(cmod_base, &header.lumps[LUMP_NODES]);
+ CMod_LoadEntityString(cmod_base, &header.lumps[LUMP_ENTITIES]);
+ CMod_LoadVisibility(cmod_base, &header.lumps[LUMP_VISIBILITY]);
+ CMod_LoadSurfaces(cmod_base,
+ &header.lumps[LUMP_SURFACES], &header.lumps[LUMP_DRAWVERTS], &header.lumps[LUMP_DRAWINDEXES]);
CMod_CreateBrushSideWindings();

0 comments on commit 31077a4

Please sign in to comment.