diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c index 256708a2c..6f4b9498d 100644 --- a/code/cgame/cg_main.c +++ b/code/cgame/cg_main.c @@ -204,6 +204,25 @@ void CG_RegisterCvars(void) temp = cgi.Cvar_Get("sv_running", "0", 0); cgs.localServer = temp->integer; } +/* +=============== +CG_UseLargeLightmaps + +Added in 2.0 +Returns true if the standard BSP file should be used, false if the smaller lightmap BSP file should be used +=============== +*/ +qboolean CG_UseLargeLightmaps(const char* mapName) { + char buffer[MAX_QPATH]; + + Com_sprintf(buffer, sizeof(buffer), "maps/%s_sml.bsp", mapName); + + if (cgi.FS_ReadFile(buffer, NULL, qtrue) == -1) { + return qtrue; + } + + return cgi.Cvar_Get("r_largemap", "0", 0)->integer; +} /* ================ diff --git a/code/cgame/cg_servercmds.c b/code/cgame/cg_servercmds.c index bc978af1a..34608a1a5 100644 --- a/code/cgame/cg_servercmds.c +++ b/code/cgame/cg_servercmds.c @@ -190,8 +190,12 @@ void CG_ParseServerinfo(void) Q_strncpyz(map, mapname, sizeof(map)); } - Com_sprintf(cgs.mapname, sizeof(cgs.mapname), "maps/%s.bsp", map); - + if (CG_UseLargeLightmaps(mapname)) { + Com_sprintf(cgs.mapname, sizeof(cgs.mapname), "maps/%s.bsp", map); + } else { + Com_sprintf(cgs.mapname, sizeof(cgs.mapname), "maps/%s_sml.bsp", map); + } + // hide/show huds if (cgs.gametype) { cgi.Cmd_Execute(EXEC_NOW, "ui_addhud hud_timelimit\n"); diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp index 164548093..4914e4af2 100644 --- a/code/client/cl_cgame.cpp +++ b/code/client/cl_cgame.cpp @@ -923,7 +923,13 @@ void CL_InitCGame( void ) { // find the current mapname info = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ]; mapname = Info_ValueForKey( info, "mapname" ); - Com_sprintf( cl.mapname, sizeof( cl.mapname ), "maps/%s.bsp", mapname ); + + if (CL_UseLargeLightmap(mapname)) { + Com_sprintf(cl.mapname, sizeof(cl.mapname), "maps/%s.bsp", mapname); + } else { + // Added in 2.0 + Com_sprintf(cl.mapname, sizeof(cl.mapname), "maps/%s_sml.bsp", mapname); + } S_BeginRegistration(); CL_ShutdownCGame(); diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index 75642b442..c6e64332f 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -172,6 +172,26 @@ void CL_ServerStatusResponse( netadr_t from, msg_t *msg ); static qboolean cl_bCLSystemStarted = qfalse; +/* +=============== +CL_UseLargeLightmap + +Added in 2.0 +Returns true if the standard BSP file should be used, false if the smaller lightmap BSP file should be used +=============== +*/ +qboolean CL_UseLargeLightmap(const char* mapName) { + char buffer[MAX_QPATH]; + + Com_sprintf(buffer, sizeof(buffer), "maps/%s_sml.bsp", mapName); + + if (FS_ReadFileEx(buffer, NULL, qtrue) == -1) { + return qtrue; + } + + return Cvar_Get("r_largemap", "0", 0)->integer; +} + /* =============== CL_CDDialog diff --git a/code/client/cl_ui.cpp b/code/client/cl_ui.cpp index efb57d40d..1276e52de 100644 --- a/code/client/cl_ui.cpp +++ b/code/client/cl_ui.cpp @@ -5799,8 +5799,15 @@ void UI_BeginLoad(const char *pszMapName) loadName = "maps/"; loadName += pszMapName; + mapfile = loadName; loadName += ".min"; - mapfile = loadName + ".bsp"; + + if (CL_UseLargeLightmap(pszMapName)) { + mapfile += ".bsp"; + } else { + // Added in 2.0 + mapfile += "_sml.bsp"; + } if (UI_ArchiveLoadMapinfo(mapfile)) { cls.loading = SS_LOADING2; diff --git a/code/null/null_client.c b/code/null/null_client.c index b4d3394bc..1f92a26cc 100644 --- a/code/null/null_client.c +++ b/code/null/null_client.c @@ -129,3 +129,7 @@ qboolean CL_FinishedIntro( void ) { int R_CountTextureMemory() { return 0; } + +qboolean CL_UseLargeLightmap(const char* mapName) { + return qtrue; +} diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 5cc94fe02..dc8f53098 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -1217,6 +1217,9 @@ void CL_ForwardCommandToServer( const char *string ); // things like godmode, noclip, etc, are commands directed to the server, // so when they are typed in at the console, they will need to be forwarded. +qboolean CL_UseLargeLightmap(const char* mapName); +// returns true if the standard BSP file should be used + void CL_CDDialog( void ); // bring up the "need a cd to play" dialog diff --git a/code/renderergl1/tr_init.c b/code/renderergl1/tr_init.c index 78d34b55f..9d7bbeae1 100644 --- a/code/renderergl1/tr_init.c +++ b/code/renderergl1/tr_init.c @@ -102,6 +102,7 @@ cvar_t *r_depthbits; cvar_t *r_colorbits; cvar_t *r_stereo; cvar_t *r_primitives; +cvar_t *r_largemap; cvar_t *r_textureDetails; cvar_t *r_texturebits; @@ -1346,11 +1347,18 @@ void R_Register( void ) r_picmip = ri.Cvar_Get ("r_picmip", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_picmip_cap = ri.Cvar_Get ("r_picmip_cap", "0", CVAR_ARCHIVE | CVAR_LATCH ); + if (r_picmip->integer < r_picmip_cap->integer) { + ri.Cvar_Set("r_picmip", r_picmip_cap->integer); + } + + if (r_picmip->integer < 2) { + r_largemap = ri.Cvar_Get("r_largemap", "1", 0); + } else { + r_largemap = ri.Cvar_Get("r_largemap", "0", 0); + } + r_roundImagesDown = ri.Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_colorMipLevels = ri.Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH ); - if (r_picmip->integer < r_picmip_cap->integer) { - ri.Cvar_Set("r_picmip", r_picmip_cap->integer); - } AssertCvarRange( r_picmip, 0, 16, qtrue ); r_textureDetails = ri.Cvar_Get("r_textureDetails", "1", 33); r_texturebits = ri.Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/code/renderergl1/tr_local.h b/code/renderergl1/tr_local.h index b5d99f386..600203624 100644 --- a/code/renderergl1/tr_local.h +++ b/code/renderergl1/tr_local.h @@ -1451,6 +1451,7 @@ extern cvar_t *r_primitives; // "0" = based on compiled vertex array existance // "2" = glDrawElements triangles // "-1" = no drawing +extern cvar_t *r_largemap; extern cvar_t *r_inGameVideo; // controls whether in game video should be draw extern cvar_t *r_fastsky; // controls whether sky should be cleared or drawn extern cvar_t *r_fastdlights; diff --git a/code/server/sv_ccmds.c b/code/server/sv_ccmds.c index 1727a193c..0271f2045 100644 --- a/code/server/sv_ccmds.c +++ b/code/server/sv_ccmds.c @@ -193,7 +193,12 @@ static void SV_Map_f( void ) { // make sure the level exists before trying to change, so that // a typo at the server console won't end the game - Com_sprintf( expanded, sizeof( expanded ), "maps/%s.bsp", map ); + // Added in 2.0 + if ( CL_UseLargeLightmap( mapname ) ) { + Com_sprintf( expanded, sizeof( expanded ), "maps/%s.bsp", map ); + } else { + Com_sprintf( expanded, sizeof( expanded ), "maps/%s_sml.bsp", map ); + } if( FS_ReadFile( expanded, NULL ) == -1 ) { Com_Printf( "Can't find map %s\n", expanded ); return; diff --git a/code/server/sv_init.c b/code/server/sv_init.c index f8f2b61ea..ad8dfe602 100644 --- a/code/server/sv_init.c +++ b/code/server/sv_init.c @@ -697,7 +697,12 @@ void SV_SpawnServer( const char *server, qboolean loadgame, qboolean restart, qb char filename[ MAX_QPATH ]; TIKI_FreeAll(); - Com_sprintf( filename, sizeof( filename ), "maps/%s.bsp", mapname ); + if ( CL_UseLargeLightmap( mapname ) ) { + Com_sprintf( filename, sizeof( filename ), "maps/%s.bsp", mapname ); + } else { + // Added in 2.0 + Com_sprintf( filename, sizeof( filename ), "maps/%s_sml.bsp", mapname ); + } CM_LoadMap( filename, qfalse, &checksum ); // set checksum