Skip to content

Commit

Permalink
Fix CID 134399
Browse files Browse the repository at this point in the history
  • Loading branch information
TimePath authored and Kangz committed Feb 6, 2016
1 parent 1bdfe08 commit 31077a4
Showing 1 changed file with 28 additions and 32 deletions.
60 changes: 28 additions & 32 deletions daemon/src/common/cm/cm_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ];
Expand Down Expand Up @@ -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 )
{
Expand All @@ -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 );
Expand All @@ -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;
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 31077a4

Please sign in to comment.