Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CVARS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ Client-Side

..

:Name: r_overBrightBitsJKA
:Values: Integer >= 0
:Default: "0"
:Description:
Overbright on maps recognized as made for Jedi Academy. These are
maps loaded from basejka or fs_assetspathjka directories and maps
with ojka_ prefix or "compatible jka" string in mv.info file

..

:Name: r_saberGlow
:Values: "0", "1"
:Default: "1"
Expand Down
4 changes: 4 additions & 0 deletions src/client/cl_cgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,10 @@ void CL_InitCGame( void ) {
mapname = Info_ValueForKey( info, "mapname" );
Com_sprintf( cl.mapname, sizeof( cl.mapname ), "maps/%s.bsp", mapname );

mapversion_t mapversion = CM_MapVersion(cl.mapname);
MV_SetCurrentMapVersion(mapversion);
Com_Printf("mapversion set to %s\n", MV_GetMapVersionString(mapversion));

// load the dll or bytecode
if ( cl_connectedToPureServer != 0 ) {
// if sv_pure is set we only allow qvms to be loaded
Expand Down
1 change: 1 addition & 0 deletions src/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ void CL_FlushMemory( qboolean disconnecting ) {

if (disconnecting && !com_sv_running->integer) {
MV_SetCurrentGameversion(VERSION_UNDEF);
MV_SetCurrentMapVersion(MAPVERSION_UNDEF);

FS_PureServerSetReferencedPaks("", "");
// change checksum feed so that next FS_ConditionalRestart()
Expand Down
3 changes: 2 additions & 1 deletion src/client/cl_scrn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ void MV_DrawConnectingInfo( void )
Com_sprintf(txtbuf, sizeof(txtbuf), "^1[ ^7JK2MV " JK2MV_VERSION " " PLATFORM_STRING " ^1]");
SCR_DrawStringExt(320 - SCR_Strlen(txtbuf) * 4, yPos + (line * 0), 8, txtbuf, g_color_table[7], qfalse);

Com_sprintf(txtbuf, sizeof(txtbuf), "Game-Version^1: ^71.%02d", (int)MV_GetCurrentGameversion());
const char *mapverstr = MV_GetMapVersionString(MV_GetCurrentMapVersion());
Com_sprintf(txtbuf, sizeof(txtbuf), "Game-Version^1: ^71.%02d Map-Version^1: ^7%s", (int)MV_GetCurrentGameversion(), mapverstr);
SCR_DrawStringExt((int)(320 - SCR_Strlen(txtbuf) * 3.5), yPos + (line * 1), 7, txtbuf, g_color_table[7], qfalse);
}

Expand Down
10 changes: 10 additions & 0 deletions src/qcommon/cm_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ void CM_FloodAreaConnections (void);
===============================================================================
*/

mapversion_t CM_MapVersion(const char *name) {
if (FS_ReadFileSkipJKA(name, NULL) != -1) {
return MAPVERSION_JK2;
} else if (FS_ReadFile(name, NULL) != -1) {
return MAPVERSION_JKA;
} else {
return MAPVERSION_UNDEF;
}
}

/*
=================
CMod_LoadShaders
Expand Down
2 changes: 2 additions & 0 deletions src/qcommon/cm_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ qboolean CM_AreasConnected( int area1, int area2 );

int CM_WriteAreaBits( byte *buffer, int area );

mapversion_t CM_MapVersion(const char *name);

// cm_tag.c
int CM_LerpTag( orientation_t *tag, clipHandle_t model, int startFrame, int endFrame,
float frac, const char *tagName );
Expand Down
22 changes: 22 additions & 0 deletions src/qcommon/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,7 @@ void Com_Init( char *commandLine ) {
// multiprotocol support
// startup will be UNDEFINED
MV_SetCurrentGameversion(VERSION_UNDEF);
MV_SetCurrentMapVersion(MAPVERSION_UNDEF);

// bk001129 - do this before anything else decides to push events
Com_InitPushEvent();
Expand Down Expand Up @@ -3051,6 +3052,27 @@ mvprotocol_t MV_GetCurrentProtocol() {
}
}

static mapversion_t mv_mapversion = MAPVERSION_UNDEF;

void MV_SetCurrentMapVersion(mapversion_t version) {
mv_mapversion = version;
}

mapversion_t MV_GetCurrentMapVersion() {
return mv_mapversion;
}

const char *MV_GetMapVersionString(mapversion_t mapversion) {
switch(mapversion) {
case MAPVERSION_UNDEF: return "Unknown"; break;
case MAPVERSION_JK2: return "JK2"; break;
case MAPVERSION_JKA: return "JKA"; break;
}

assert(0);
return "";
}

// for auto-complete (copied from OpenJK)
/*
=============================================================================
Expand Down
33 changes: 22 additions & 11 deletions src/qcommon/files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ enum {
PACKGVC_UNKNOWN = 0,
PACKGVC_1_02 = 1,
PACKGVC_1_03 = 2,
PACKGVC_1_04 = 4,
PACKGVC_1_04 = 4
};

typedef struct {
Expand Down Expand Up @@ -291,7 +291,7 @@ static const char *fs_serverReferencedPakNames[MAX_SEARCH_PATHS]; // pk3 names
char lastValidBase[MAX_OSPATH];
char lastValidGame[MAX_OSPATH];

qboolean FS_idPak(pack_t *pack);
qboolean FS_idPak(const pack_t *pack);
qboolean FS_IsInvalidWriteOSPath(const char *ospath);
qboolean FS_ContainsInvalidCharacters( const char *filename );

Expand Down Expand Up @@ -340,7 +340,7 @@ qboolean FS_Initialized() {
FS_PakIsPure
=================
*/
qboolean FS_PakIsPure( pack_t *pack ) {
qboolean FS_PakIsPure( const pack_t *pack ) {
int i;

// actually, I created a bypass for sv_pure here but since jk2 is opensource I really don't see a point in supporting pure
Expand Down Expand Up @@ -1227,7 +1227,6 @@ int FS_PakReadFile(pack_t *pak, const char *filename, char *buffer, int bufferle
return 0;
}


/*
===========
FS_FOpenFileRead
Expand Down Expand Up @@ -1322,15 +1321,16 @@ int FS_FOpenFileReadHash(const char *filename, fileHandle_t *file, qboolean uniq
!((search->pack->gvc & PACKGVC_1_02 && MV_GetCurrentGameversion() == VERSION_1_02) ||
(search->pack->gvc & PACKGVC_1_03 && MV_GetCurrentGameversion() == VERSION_1_03) ||
(search->pack->gvc & PACKGVC_1_04 && MV_GetCurrentGameversion() == VERSION_1_04) ||
(Q_stricmp(search->pack->pakGamename, BASEGAME) && search->pack->gvc == PACKGVC_UNKNOWN) ||
(search->pack->isJKA && MV_GetCurrentMapVersion() == MAPVERSION_JKA) ||
(search->pack->gvc & PACKGVC_UNKNOWN && Q_stricmp(search->pack->pakGamename, BASEGAME)) ||
(MV_GetCurrentGameversion() == VERSION_UNDEF))) {

// prevent loading unsupported qvm's
if (!Q_stricmp(filename, "vm/cgame.qvm") || !Q_stricmp(filename, "vm/ui.qvm") || !Q_stricmp(filename, "vm/jk2mpgame.qvm"))
continue;

// incompatible pk3
if (search->pack->gvc != PACKGVC_UNKNOWN && !FS_idPak(search->pack))
if (!(search->pack->gvc & PACKGVC_UNKNOWN) && !FS_idPak(search->pack))
continue;
}

Expand Down Expand Up @@ -2089,8 +2089,11 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename, qboolean ass
pack->gvc = PACKGVC_1_03;
} else if (!Q_stricmpn(basename, "o104_", 5)) {
pack->gvc = PACKGVC_1_04;
} else if (!Q_stricmpn(basename, "ojka_", 5) || !Q_stricmpn(basename, "dl_ojka_", 8)) {
pack->isJKA = qtrue;
}


// mv.info file in root directory of pk3 file
char cversion[128];
int cversionlen = FS_PakReadFile(pack, "mv.info", cversion, sizeof(cversion) - 1);
Expand All @@ -2113,6 +2116,10 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename, qboolean ass
if (Q_stristr(cversion, "compatible all")) {
pack->gvc = PACKGVC_1_02 | PACKGVC_1_03 | PACKGVC_1_04;
}

if (Q_stristr(cversion, "compatible jka")) {
pack->isJKA = qtrue;
}
}

// assets are hardcoded
Expand All @@ -2126,6 +2133,8 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename, qboolean ass
} else if (!Q_stricmp(pack->pakBasename, "assets5")) {
pack->gvc = PACKGVC_1_04;
}
} else {
pack->isJKA = qtrue;
}

return pack;
Expand Down Expand Up @@ -2252,11 +2261,12 @@ static const char **FS_ListFilteredFiles( const char *path, const char *extensio
!((search->pack->gvc & PACKGVC_1_02 && MV_GetCurrentGameversion() == VERSION_1_02) ||
(search->pack->gvc & PACKGVC_1_03 && MV_GetCurrentGameversion() == VERSION_1_03) ||
(search->pack->gvc & PACKGVC_1_04 && MV_GetCurrentGameversion() == VERSION_1_04) ||
(Q_stricmp(search->pack->pakGamename, BASEGAME) && search->pack->gvc == PACKGVC_UNKNOWN) ||
(search->pack->isJKA && MV_GetCurrentMapVersion() == MAPVERSION_JKA) ||
(search->pack->gvc & PACKGVC_UNKNOWN && Q_stricmp(search->pack->pakGamename, BASEGAME)) ||
(MV_GetCurrentGameversion() == VERSION_UNDEF))) {

// incompatible pk3
if (search->pack->gvc != PACKGVC_UNKNOWN && !FS_idPak(search->pack))
if (!(search->pack->gvc & PACKGVC_UNKNOWN) && !FS_idPak(search->pack))
continue;
}

Expand Down Expand Up @@ -2765,11 +2775,12 @@ void FS_Path_f( void ) {
Com_Printf ("Current search path:\n");
for (s = fs_searchpaths; s; s = s->next) {
if (s->pack) {
Com_Printf ("%s (%i files) [ %s%s%s%s]\n", s->pack->pakFilename, s->pack->numfiles,
Com_Printf ("%s (%i files) [ %s%s%s%s%s]\n", s->pack->pakFilename, s->pack->numfiles,
s->pack->gvc == PACKGVC_UNKNOWN ? "unknown " : "",
s->pack->gvc & PACKGVC_1_02 ? "1.02 " : "",
s->pack->gvc & PACKGVC_1_03 ? "1.03 " : "",
s->pack->gvc & PACKGVC_1_04 ? "1.04 " : "");
s->pack->gvc & PACKGVC_1_04 ? "1.04 " : "",
s->pack->isJKA ? "JKA " : "");

if ( fs_numServerPaks ) {
if ( !FS_PakIsPure(s->pack) ) {
Expand Down Expand Up @@ -3117,7 +3128,7 @@ qboolean FS_idPakPath(const char *pak, const char *base) {
return qfalse;
}

qboolean FS_idPak(pack_t *pak) {
qboolean FS_idPak(const pack_t *pak) {
char path[MAX_OSPATH];
Com_sprintf(path, sizeof(path), "%s/%s", pak->pakGamename, pak->pakBasename);

Expand Down
9 changes: 9 additions & 0 deletions src/qcommon/qcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -1056,9 +1056,18 @@ extern huffman_t clientHuffTables;
#define CL_ENCODE_START 12
#define CL_DECODE_START 4

typedef enum {
MAPVERSION_UNDEF,
MAPVERSION_JK2,
MAPVERSION_JKA
} mapversion_t;

void MV_SetCurrentGameversion(mvversion_t version);
mvversion_t MV_GetCurrentGameversion();
mvprotocol_t MV_GetCurrentProtocol();
void MV_SetCurrentMapVersion(mapversion_t version);
mapversion_t MV_GetCurrentMapVersion();
const char *MV_GetMapVersionString(mapversion_t mapversion);

#define MAX_SUBMODELS 256

Expand Down
6 changes: 5 additions & 1 deletion src/renderer/tr_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2645,7 +2645,11 @@ void R_SetColorMappings( void ) {
int shift;

// setup the overbright lighting
tr.overbrightBits = r_overBrightBits->integer;
if (tr.mapversion == MAPVERSION_JKA) {
tr.overbrightBits = r_overBrightBitsJKA->integer;
} else {
tr.overbrightBits = r_overBrightBits->integer;
}

if (r_gammamethod->integer == GAMMA_NONE)
{
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ cvar_t *r_lodCurveError;
cvar_t *r_customaspect;

cvar_t *r_overBrightBits;
cvar_t *r_overBrightBitsJKA;

cvar_t *r_debugSurface;
cvar_t *r_simpleMipMaps;
Expand Down Expand Up @@ -1074,6 +1075,7 @@ void R_Register( void )
r_texturebits = ri.Cvar_Get("r_texturebits", "0", CVAR_ARCHIVE | CVAR_GLOBAL | CVAR_LATCH);
r_texturebitslm = ri.Cvar_Get("r_texturebitslm", "0", CVAR_ARCHIVE | CVAR_GLOBAL | CVAR_LATCH);
r_overBrightBits = ri.Cvar_Get("r_overBrightBits", "1", CVAR_ARCHIVE | CVAR_GLOBAL | CVAR_LATCH);
r_overBrightBitsJKA = ri.Cvar_Get("r_overBrightBitsJKA", "0", CVAR_ARCHIVE | CVAR_GLOBAL | CVAR_LATCH);
r_intensity = ri.Cvar_Get("r_intensity", "1", CVAR_ARCHIVE | CVAR_GLOBAL | CVAR_LATCH);
r_aspectratio = ri.Cvar_Get("r_aspectratio", "-1", CVAR_ARCHIVE | CVAR_GLOBAL | CVAR_LATCH); // screen resolutions
r_customaspect = ri.Cvar_Get("r_customaspect", "1", CVAR_ARCHIVE | CVAR_GLOBAL | CVAR_LATCH);
Expand Down Expand Up @@ -1230,7 +1232,7 @@ Ghoul2 Insert End
R_Init
===============
*/
void R_Init( void ) {
void R_Init( mapversion_t mapversion ) {
int i;
byte *ptr;

Expand All @@ -1245,6 +1247,8 @@ void R_Init( void ) {

// Swap_Init();

tr.mapversion = mapversion;

#ifndef DEDICATED
Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) );
#endif
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ typedef struct {
// gamma correction
GLuint gammaVertexShader, gammaPixelShader;
GLuint gammaLUTImage;

mapversion_t mapversion;
} trGlobals_t;


Expand Down Expand Up @@ -1277,6 +1279,7 @@ extern cvar_t *r_skipBackEnd;
extern cvar_t *r_ignoreGLErrors;

extern cvar_t *r_overBrightBits;
extern cvar_t *r_overBrightBitsJKA;

extern cvar_t *r_debugSurface;
extern cvar_t *r_simpleMipMaps;
Expand Down Expand Up @@ -1419,7 +1422,7 @@ qboolean R_GetEntityToken( char *buffer, int size );

model_t *R_AllocModel( void );

void R_Init( void );
void R_Init( mapversion_t mapversion );
void R_LoadImage( const char *name, byte **pic, int *width, int *height );
image_t *R_FindImageFile( const char *name, qboolean mipmap, qboolean allowPicmip, qboolean allowTC, int glWrapClampMode );
image_t *R_FindImageFileNew( const char *name, const upload_t *upload, int glWrapClampMode );
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/tr_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name, qbo
*/
void RE_BeginRegistration( glconfig_t *glconfigOut ) {

R_Init();
R_Init(MV_GetCurrentMapVersion());

*glconfigOut = glConfig;

Expand Down
4 changes: 4 additions & 0 deletions src/server/sv_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ Ghoul2 Insert End
// clear the whole hunk because we're (re)loading the server
Hunk_Clear();

mapversion_t mapversion = CM_MapVersion(va("maps/%s.bsp", server));
MV_SetCurrentMapVersion(mapversion);
Com_Printf("mapversion set to %s\n", MV_GetMapVersionString(mapversion));

/*
Ghoul2 Insert Start
*/
Expand Down