Skip to content

Commit

Permalink
Restored compatiblity with ioquake. Thanks to woho who suggested the …
Browse files Browse the repository at this point in the history
…solution here: bnoordhuis#6
  • Loading branch information
sago007 committed Jun 21, 2016
1 parent a3b7cd4 commit a358578
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 262 deletions.
27 changes: 15 additions & 12 deletions deps/qcommon/cm_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
Expand All @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#ifdef BSPC

#include "l_qfiles.h"
#include "../bspc/l_qfiles.h"

void SetPlaneSignbits (cplane_t *out) {
int bits, j;
Expand Down Expand Up @@ -138,7 +138,7 @@ void CMod_LoadSubmodels( lump_t *l ) {
Com_Error( ERR_DROP, "MAX_SUBMODELS exceeded" );
}

for ( i=0 ; i<count ; i++, in++, out++)
for ( i=0 ; i<count ; i++, in++)
{
out = &cm.cmodels[i];

Expand Down Expand Up @@ -567,7 +567,10 @@ Loads in the map and all submodels
==================
*/
void CM_LoadMap( const char *name, qboolean clientload, int *checksum ) {
int *buf;
union {
int *i;
void *v;
} buf;
int i;
dheader_t header;
int length;
Expand Down Expand Up @@ -606,29 +609,29 @@ void CM_LoadMap( const char *name, qboolean clientload, int *checksum ) {
// load the file
//
#ifndef BSPC
length = FS_ReadFile( name, (void **)&buf );
length = FS_ReadFile( name, &buf.v );
#else
length = LoadQuakeFile((quakefile_t *) name, (void **)&buf);
length = LoadQuakeFile((quakefile_t *) name, &buf.v);
#endif

if ( !buf ) {
if ( !buf.i ) {
Com_Error (ERR_DROP, "Couldn't load %s", name);
}

last_checksum = LittleLong (Com_BlockChecksum (buf, length));
last_checksum = LittleLong (Com_BlockChecksum (buf.i, length));
*checksum = last_checksum;

header = *(dheader_t *)buf;
header = *(dheader_t *)buf.i;
for (i=0 ; i<sizeof(dheader_t)/4 ; i++) {
((int *)&header)[i] = LittleLong ( ((int *)&header)[i]);
}

if ( header.version != BSP_VERSION && header.version != BSP_VERSION_QL ) {
if ( header.version != BSP_VERSION ) {
Com_Error (ERR_DROP, "CM_LoadMap: %s has wrong version number (%i should be %i)"
, name, header.version, BSP_VERSION );
}

cmod_base = (byte *)buf;
cmod_base = (byte *)buf.i;

// load into heap
CMod_LoadShaders( &header.lumps[LUMP_SHADERS] );
Expand All @@ -645,7 +648,7 @@ void CM_LoadMap( const char *name, qboolean clientload, int *checksum ) {
CMod_LoadPatches( &header.lumps[LUMP_SURFACES], &header.lumps[LUMP_DRAWVERTS] );

// we are NOT freeing the file, because it is cached for the ref
FS_FreeFile (buf);
FS_FreeFile (buf.v);

CM_InitBoxHull ();

Expand Down
Loading

0 comments on commit a358578

Please sign in to comment.