Skip to content

Commit

Permalink
Openjk update (#140)
Browse files Browse the repository at this point in the history
* [Shared] Replace CARET shift check when using cl_consoleUseScanCode with a check for cl_consoleShiftRequirement.

The cvar cl_consoleShiftRequirement matches the jk2mv mv_consoleShiftRequirement:
 - 0: no shift key required
 - 1: shift required to open the console
 - 2: shift required to open and close the console

(cherry picked from commit 1479067)

* [Shared] Draw console prompt even when renderer cmd queue overflows from too much text.

mvdevs/jk2mv@634e5b2

(cherry picked from commit ec944bb)

* [Shared] Add con_height cvar to set console height. Set to 0 to restore previous behaviour.

(cherry picked from commit c007dfd)

* render local entities as late as possible (JACoders#1200)

this should defer an overflow of refents occurring that would result in e.g. map models disappearing (light poles on mp/ffa5)
localents are a lower priority, we can afford to miss out on force push/grip effects in these cases

(cherry picked from commit 2d618a5)

* Remove whitespace/comment set but unused variable

---------

Co-authored-by: Daggolin <[email protected]>
Co-authored-by: razor <[email protected]>
  • Loading branch information
3 people authored Feb 19, 2024
1 parent 0cf63a0 commit b6f5ff5
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 37 deletions.
22 changes: 13 additions & 9 deletions codemp/cgame/cg_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ static void CG_CalcIdealThirdPersonViewLocation(void)
newThirdPersonRange = thirdPersonRange * thirdPersonRange / 176;
else
newThirdPersonRange = thirdPersonRange * thirdPersonRange / cg_zoomFov.integer;
}
}
else
{
if (cg_zoomFov.integer < 1)
Expand All @@ -410,7 +410,7 @@ static void CG_CalcIdealThirdPersonViewLocation(void)
} else {
newThirdPersonRange = thirdPersonRange;
}
}
}
//JAPRO - Clientside - Allow for +zoom - End

if (cg.snap && cg.snap->ps.m_iVehicleNum)
Expand Down Expand Up @@ -1095,18 +1095,18 @@ static void CG_OffsetFirstPersonView( void ) {
{
if (!(cgs.jcinfo & JAPRO_CINFO_SCREENSHAKE))
{
}
}
else if ( cg.damageTime ) {
ratio = cg.time - cg.damageTime;
if ( ratio < DAMAGE_DEFLECT_TIME )
if ( ratio < DAMAGE_DEFLECT_TIME )
{
ratio /= DAMAGE_DEFLECT_TIME;
angles[PITCH] += ratio * cg.v_dmg_pitch;
angles[ROLL] += ratio * cg.v_dmg_roll;
} else
} else
{
ratio = 1.0 - ( ratio - DAMAGE_DEFLECT_TIME ) / DAMAGE_RETURN_TIME;
if ( ratio > 0 )
if ( ratio > 0 )
{
angles[PITCH] += ratio * cg.v_dmg_pitch;
angles[ROLL] += ratio * cg.v_dmg_roll;
Expand Down Expand Up @@ -1390,7 +1390,7 @@ static qboolean CG_CalcFov( void ) {
fov_x = 176;
else
fov_x = cg_zoomFov.integer;
}
}
else
{
if (cg_zoomFov.integer < 1)
Expand Down Expand Up @@ -2536,7 +2536,7 @@ static QINLINE void CG_DoAsync( void ) {
//Need to decouple frames from kick i guess.

//If we are on kick 1, check to see if our cvar for it is above frames. If so , kick and increment kickcount.

//Increment
if (cg.numFKFrames > cg_fkDuration.integer) {
trap->SendConsoleCommand("-moveup\n");
Expand Down Expand Up @@ -3044,7 +3044,6 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
if ( !cg.hyperspace ) {
CG_AddPacketEntities(qfalse); // adter calcViewValues, so predicted player state is correct
CG_AddMarks();
CG_AddLocalEntities();
#if _NEWTRAILS
if (cg.drawingStrafeTrails) {
CG_AddAllStrafeTrails();
Expand All @@ -3064,6 +3063,11 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
if ( cg.testModelEntity.hModel ) {
CG_AddTestModel();
}

if ( !cg.hyperspace ) {
CG_AddLocalEntities();
}

cg.refdef.time = cg.time;
memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) );

Expand Down
19 changes: 10 additions & 9 deletions codemp/client/cl_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ cvar_t *con_autoclear;
cvar_t *con_notifywords;
cvar_t *con_notifyconnect;
cvar_t *con_notifyvote;
cvar_t *con_height;

#define DEFAULT_CONSOLE_WIDTH 78
#define TIMESTAMP_LENGTH 9
Expand Down Expand Up @@ -452,19 +453,19 @@ void Con_CheckResize (void)
else
{
float scale = (con_scale && con_scale->value > 0.0f) ? con_scale->value : 1.0f;

width = (cls.glconfig.vidWidth / (scale * SMALLCHAR_WIDTH)) - 2;

if (width == con.linewidth)
return;

con.charWidth = scale * SMALLCHAR_WIDTH;
con.charHeight = scale * SMALLCHAR_HEIGHT;

g_consoleField.widthInChars = width;
for (i = 0; i < COMMAND_HISTORY; i++) {
historyEditLines[i].widthInChars = width;

}

// on wide screens, we will center the text
Expand Down Expand Up @@ -542,6 +543,7 @@ void Con_Init (void) {
con_notifywords = Cvar_Get("con_notifywords", "0", CVAR_ARCHIVE, "Notifies you when defined words are mentioned");
con_notifyconnect = Cvar_Get("con_notifyconnect", "0", CVAR_ARCHIVE, "Notifies you when someone connects to the server");
con_notifyvote = Cvar_Get("con_notifyvote", "1", CVAR_ARCHIVE, "Notifies you when someone calls a vote");
con_height = Cvar_Get ("con_height", "0.5", CVAR_ARCHIVE_ND);

Field_Clear( &g_consoleField );
g_consoleField.widthInChars = DEFAULT_CONSOLE_WIDTH;
Expand Down Expand Up @@ -954,6 +956,8 @@ void Con_DrawSolidConsole( float frac ) {
(lines-(con.charHeight*2+con.charHeight/2)) + padding, JK_VERSION[x] );
}

// draw the input prompt, user text, and cursor if desired
Con_DrawInput ();

// Draw time and date
time(&rawtime);
Expand All @@ -968,9 +972,6 @@ void Con_DrawSolidConsole( float frac ) {
SCR_DrawSmallChar(cls.glconfig.vidWidth - (i - x) * con.charWidth, lines - (con.charHeight + con.charHeight / 2) + padding, ts[x]);
}

// draw the input prompt, user text, and cursor if desired
Con_DrawInput ();

// draw the text
con.vislines = lines;
rows = (lines-con.charWidth)/con.charWidth; // rows of text to draw
Expand Down Expand Up @@ -1102,7 +1103,7 @@ Scroll it up or down
void Con_RunConsole (void) {
// decide on the destination height of the console
if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE )
con.finalFrac = con.tempFrac; // visibility
con.finalFrac = (con_height->value != 0) ? con_height->value : con.tempFrac;
else
con.finalFrac = 0; // none visible

Expand Down
2 changes: 2 additions & 0 deletions codemp/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ cvar_t *cl_autolodscale;

cvar_t *cl_consoleKeys;
cvar_t *cl_consoleUseScanCode;
cvar_t *cl_consoleShiftRequirement;

cvar_t *cl_lanForcePackets;

Expand Down Expand Up @@ -3368,6 +3369,7 @@ void CL_Init( void ) {
// ~ and `, as keys and characters
cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60 0xb2", CVAR_ARCHIVE, "Which keys are used to toggle the console");
cl_consoleUseScanCode = Cvar_Get( "cl_consoleUseScanCode", "1", CVAR_ARCHIVE, "Use native console key detection" );
cl_consoleShiftRequirement = Cvar_Get( "cl_consoleShiftRequirement", "0", CVAR_ARCHIVE, "Require shift key to be pressed for native console key detection" );

cl_downloadName = Cvar_Get( "cl_downloadName", "", CVAR_INTERNAL );
cl_downloadPrompt = Cvar_Get( "cl_downloadPrompt", "1", CVAR_ARCHIVE, "Confirm pk3 downloads from the server" );
Expand Down
1 change: 1 addition & 0 deletions codemp/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ extern cvar_t *cl_inGameVideo;

extern cvar_t *cl_consoleKeys;
extern cvar_t *cl_consoleUseScanCode;
extern cvar_t *cl_consoleShiftRequirement;

extern cvar_t *cl_lanForcePackets;

Expand Down
22 changes: 11 additions & 11 deletions codemp/rd-vulkan/tr_ghoul2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,9 +905,9 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l

// model has only 1 LOD level, skip computations and bias
#ifdef RF_NOLOD
if ( currentModel->numLods < 2 || ent->e.renderfx & RF_NOLOD )
if ( currentModel->numLods < 2 || ent->e.renderfx & RF_NOLOD )
#else
if ( currentModel->numLods < 2 )
if ( currentModel->numLods < 2 )
#endif
return(0);

Expand All @@ -923,7 +923,7 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l
largestScale = ent->e.modelScale[2];
if (!largestScale)
largestScale = 1;

#if 0
float radius = Q_fabs(0.75 * largestScale * ent->e.radius);

Expand All @@ -938,14 +938,14 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l

projectedRadius = width / depth;

//if (projectedRadius > 1.0f)
//if (projectedRadius > 1.0f)
// projectedRadius = 1.0f;

if (projectedRadius != 0) {
lodscale = (r_lodscale->value + r_autolodscalevalue->value);
if (lodscale > 20)
if (lodscale > 20)
lodscale = 20;
else if (lodscale < 0)
else if (lodscale < 0)
lodscale = 0;

flod = 1.0f - projectedRadius * lodscale;
Expand All @@ -963,12 +963,12 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l

// we reduce the radius to make the LOD match other model types which use
// the actual bound box size
if ( projectedRadius != 0 )
if ( projectedRadius != 0 )
{
lodscale = (r_lodscale->value+r_autolodscalevalue->value);
if ( lodscale > 20 )
if ( lodscale > 20 )
{
lodscale = 20;
lodscale = 20;
}
else if ( lodscale < 0 )
{
Expand Down Expand Up @@ -3508,9 +3508,9 @@ static inline float G2_GetVertBoneWeightNotSlow( const mdxmVertex_t *pVert, cons
//This is a slightly mangled version of the same function from the sof2sp base.
//It provides a pretty significant performance increase over the existing one.
void RB_SurfaceGhoul(CRenderableSurface* surf)
{
{
mdxmSurface_t *surface;

#ifdef G2_PERFORMANCE_ANALYSIS
G2PerformanceTimer_RB_SurfaceGhoul.Start();
#endif
Expand Down
4 changes: 2 additions & 2 deletions codemp/rd-vulkan/vk_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,9 +1017,9 @@ void vk_refraction_extract( void ) {
VkImage srcImage;
VkImage dstImage;
VkImageLayout srcImageLayout;
VkAccessFlagBits srcImageAccess;
//VkAccessFlagBits srcImageAccess;

srcImageAccess = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
//srcImageAccess = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
srcImageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
srcImage = vk.color_image;
dstImage = vk.refraction_extract_image;
Expand Down
25 changes: 19 additions & 6 deletions shared/sdl/sdl_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,23 @@ static void IN_TranslateNumpad( SDL_Keysym *keysym, fakeAscii_t *key )
}
}

/*
===============
IN_ModTogglesConsole
===============
*/
static qboolean IN_ModTogglesConsole( int mod ) {
switch (cl_consoleShiftRequirement->integer) {
case 0:
return qtrue;
case 2:
return (qboolean)!!(mod & KMOD_SHIFT);
case 1:
default:
return (qboolean)((mod & KMOD_SHIFT) || (Key_GetCatcher() & KEYCATCH_CONSOLE));
}
}

/*
===============
IN_TranslateSDLToJKKey
Expand Down Expand Up @@ -379,11 +396,7 @@ static fakeAscii_t IN_TranslateSDLToJKKey( SDL_Keysym *keysym, qboolean down ) {
{
if ( keysym->scancode == SDL_SCANCODE_GRAVE )
{
SDL_Keycode translated = SDL_GetKeyFromScancode( SDL_SCANCODE_GRAVE );

if ( (translated != SDLK_CARET) || (translated == SDLK_CARET && (keysym->mod & KMOD_SHIFT)) )
{
// Console keys can't be bound or generate characters
if ( IN_ModTogglesConsole(keysym->mod) ) {
key = A_CONSOLE;
}
}
Expand Down Expand Up @@ -866,7 +879,7 @@ static void IN_ProcessEvents( int eventTime )
uint32_t utf32 = ConvertUTF8ToUTF32( c, &c );
if( utf32 != 0 )
{
if( IN_IsConsoleKey( A_NULL, utf32 ) )
if( IN_IsConsoleKey( A_NULL, utf32 ) && !cl_consoleUseScanCode->integer )
{
Sys_QueEvent( eventTime, SE_KEY, A_CONSOLE, qtrue, 0, NULL );
Sys_QueEvent( eventTime, SE_KEY, A_CONSOLE, qfalse, 0, NULL );
Expand Down

0 comments on commit b6f5ff5

Please sign in to comment.