diff --git a/README.md b/README.md index 083b85033..9dda533f7 100644 --- a/README.md +++ b/README.md @@ -82,8 +82,8 @@ Note: with tranparency or some animations flags and properties. * If you like support some other maps type, create pull request for Mod_Load2QBSP function and provide a link to demo maps. -* Use `maptype 1` before load any Heretic 2 maps. Look to - [maptype_t](src/common/header/cmodel.h#L42) for more info. +* Use `maptype 1` before load any Heretic 2 maps, or place game data to `heretic2` directory. + Look to [maptype_t](src/common/header/cmodel.h#L42) for more info. Games: diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 833c0407c..da1f7ecae 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -967,8 +967,6 @@ CL_Shutdown(void) isdown = true; - CM_ModFreeAll(); - #ifdef USE_CURL CL_HTTP_Cleanup(true); #endif diff --git a/src/common/collision.c b/src/common/collision.c index c4bbbed59..4828210be 100644 --- a/src/common/collision.c +++ b/src/common/collision.c @@ -135,6 +135,7 @@ static cleaf_t *box_leaf; static cplane_t *box_planes; static cvar_t *map_noareas; static cvar_t *r_maptype; +static cvar_t *r_game; static int box_headnode; static int checkcount; static int floodvalid; @@ -1736,6 +1737,16 @@ CM_ModFree(model_t *cmod) memset(cmod, 0, sizeof(model_t)); } +void +CM_ModInit(void) +{ + memset(models, 0, sizeof(models)); + + map_noareas = Cvar_Get("map_noareas", "0", 0); + r_maptype = Cvar_Get("maptype", "0", CVAR_ARCHIVE); + r_game = Cvar_Get("game", "", CVAR_LATCH | CVAR_SERVERINFO); +} + void CM_ModFreeAll(void) { @@ -1769,6 +1780,11 @@ CM_LoadCachedMap(const char *name, model_t *mod) /* Can't detect will use provided */ maptype = r_maptype->value; + /* force heretic2 only if game is heretic2 */ + if (!strcmp(r_game->string, "heretic2") && maptype == map_quake2rr) + { + maptype = map_heretic2; + } cmod_base = Mod_Load2QBSP(name, (byte *)filebuf, filelen, &length, &maptype); header = (dheader_t *)cmod_base; @@ -1863,9 +1879,6 @@ CM_LoadMap(const char *name, qboolean clientload, unsigned *checksum) { int i, sec_start; - map_noareas = Cvar_Get("map_noareas", "0", 0); - r_maptype = Cvar_Get("maptype", "0", CVAR_ARCHIVE); - if (!name[0]) { memset(&empty_model, 0, sizeof(empty_model)); diff --git a/src/common/frame.c b/src/common/frame.c index 0bf06f59b..38e08ff72 100644 --- a/src/common/frame.c +++ b/src/common/frame.c @@ -358,6 +358,7 @@ Qcommon_Init(int argc, char **argv) // The filesystems needs to be initialized after the cvars. FS_InitFilesystem(); + CM_ModInit(); // Add and execute configuration files. Qcommon_ExecConfigs(true); @@ -830,6 +831,7 @@ Qcommon_Frame(int usec) void Qcommon_Shutdown(void) { + CM_ModFreeAll(); FS_ShutdownFilesystem(); Cvar_Fini(); diff --git a/src/common/header/common.h b/src/common/header/common.h index dc09ed338..3928fb3fe 100644 --- a/src/common/header/common.h +++ b/src/common/header/common.h @@ -642,6 +642,7 @@ cmodel_t *CM_InlineModel(const char *name); /* *1, *2, etc */ int CM_MapSurfacesNum(void); mapsurface_t* CM_MapSurfaces(int surfnum); +void CM_ModInit(void); void CM_ModFreeAll(void); int CM_NumClusters(void);