Skip to content

Commit

Permalink
Merged pull request "Sync with Q2PRO: Client changes": NVIDIA#387
Browse files Browse the repository at this point in the history
  • Loading branch information
apanteleev committed Mar 26, 2024
2 parents 1c2fd65 + 0bafcae commit b9358bb
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 127 deletions.
3 changes: 2 additions & 1 deletion baseq2/q2rtx.menu
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ begin video
banner m_banner_video
pairs "renderer" vid_rtx opengl 0 rtx 1
values -s "use LEFT and RIGHT keys to select" "video mode" vid_fullscreen windowed $$vid_modelist
values "aspect ratio" cl_adjustfov 4:3 auto
values "fov scaling" cl_adjustfov vert- hor+
pairs "full screen display" vid_display $vid_displaylist
toggle "vertical sync" vid_vsync
pairs "FPS counter" scr_fps "off" 0 "show FPS" 1 "show FPS and resolution scale" 2
Expand Down Expand Up @@ -222,6 +222,7 @@ begin sound
range -p -f "%.0f%%" "music volume" ogg_volume 0 1 0.05
toggle "enable music" ogg_enable
toggle "shuffle tracks" ogg_shuffle
toggle "underwater effect" s_underwater
blank
values "ambient sounds" s_ambient "no" "yes" "only player's own"
values "chat beep" cl_chat_sound "disabled" "default" "alternative"
Expand Down
112 changes: 63 additions & 49 deletions src/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ typedef struct client_state_s {
int numWeaponModels;
} client_state_t;

extern client_state_t cl;
extern client_state_t cl;

/*
==================================================================
Expand Down Expand Up @@ -503,10 +503,10 @@ typedef struct client_static_s {
#endif
} client_static_t;

extern client_static_t cls;
extern client_static_t cls;

extern cmdbuf_t cl_cmdbuf;
extern char cl_cmdbuf_text[MAX_STRING_CHARS];
extern cmdbuf_t cl_cmdbuf;
extern char cl_cmdbuf_text[MAX_STRING_CHARS];

//=============================================================================

Expand All @@ -526,18 +526,18 @@ extern char cl_cmdbuf_text[MAX_STRING_CHARS];
//
// cvars
//
extern cvar_t *cl_gunalpha;
extern cvar_t *cl_gunscale;
extern cvar_t *cl_gun_x;
extern cvar_t *cl_gun_y;
extern cvar_t *cl_gun_z;
extern cvar_t *cl_predict;
extern cvar_t *cl_footsteps;
extern cvar_t *cl_noskins;
extern cvar_t *cl_kickangles;
extern cvar_t *cl_rollhack;
extern cvar_t *cl_noglow;
extern cvar_t *cl_nolerp;
extern cvar_t *cl_gunalpha;
extern cvar_t *cl_gunscale;
extern cvar_t *cl_gun_x;
extern cvar_t *cl_gun_y;
extern cvar_t *cl_gun_z;
extern cvar_t *cl_predict;
extern cvar_t *cl_footsteps;
extern cvar_t *cl_noskins;
extern cvar_t *cl_kickangles;
extern cvar_t *cl_rollhack;
extern cvar_t *cl_noglow;
extern cvar_t *cl_nolerp;

#if USE_DEBUG
#define SHOWNET(level, ...) \
Expand All @@ -549,57 +549,57 @@ extern cvar_t *cl_nolerp;
#define SHOWMISS(...) \
if (cl_showmiss->integer) \
Com_LPrintf(PRINT_DEVELOPER, __VA_ARGS__)
extern cvar_t *cl_shownet;
extern cvar_t *cl_showmiss;
extern cvar_t *cl_showclamp;
extern cvar_t *cl_shownet;
extern cvar_t *cl_showmiss;
extern cvar_t *cl_showclamp;
#else
#define SHOWNET(...)
#define SHOWCLAMP(...)
#define SHOWMISS(...)
#endif

extern cvar_t *cl_vwep;
extern cvar_t *cl_vwep;

extern cvar_t *cl_disable_particles;
extern cvar_t *cl_disable_explosions;
extern cvar_t *cl_explosion_sprites;
extern cvar_t *cl_explosion_frametime;
extern cvar_t *cl_dlight_hacks;
extern cvar_t *cl_disable_particles;
extern cvar_t *cl_disable_explosions;
extern cvar_t *cl_explosion_sprites;
extern cvar_t *cl_explosion_frametime;
extern cvar_t *cl_dlight_hacks;

extern cvar_t *cl_chat_notify;
extern cvar_t *cl_chat_sound;
extern cvar_t *cl_chat_filter;
extern cvar_t *cl_chat_notify;
extern cvar_t *cl_chat_sound;
extern cvar_t *cl_chat_filter;

extern cvar_t *cl_disconnectcmd;
extern cvar_t *cl_changemapcmd;
extern cvar_t *cl_beginmapcmd;
extern cvar_t *cl_disconnectcmd;
extern cvar_t *cl_changemapcmd;
extern cvar_t *cl_beginmapcmd;

extern cvar_t *cl_gibs;
extern cvar_t *cl_gibs;

#define CL_PLAYER_MODEL_DISABLED 0
#define CL_PLAYER_MODEL_ONLY_GUN 1
#define CL_PLAYER_MODEL_FIRST_PERSON 2
#define CL_PLAYER_MODEL_THIRD_PERSON 3

extern cvar_t *cl_player_model;
extern cvar_t *cl_thirdperson_angle;
extern cvar_t *cl_thirdperson_range;
extern cvar_t *cl_player_model;
extern cvar_t *cl_thirdperson_angle;
extern cvar_t *cl_thirdperson_range;

extern cvar_t *cl_async;
extern cvar_t *cl_async;

//
// userinfo
//
extern cvar_t *info_password;
extern cvar_t *info_spectator;
extern cvar_t *info_name;
extern cvar_t *info_skin;
extern cvar_t *info_rate;
extern cvar_t *info_fov;
extern cvar_t *info_msg;
extern cvar_t *info_hand;
extern cvar_t *info_gender;
extern cvar_t *info_uf;
extern cvar_t *info_password;
extern cvar_t *info_spectator;
extern cvar_t *info_name;
extern cvar_t *info_skin;
extern cvar_t *info_rate;
extern cvar_t *info_fov;
extern cvar_t *info_msg;
extern cvar_t *info_hand;
extern cvar_t *info_gender;
extern cvar_t *info_uf;

//
// models.c
Expand All @@ -612,6 +612,19 @@ extern vec3_t cl_testmodel_position;

//=============================================================================

static inline void CL_AdvanceValue(float *restrict val, float target, float speed)
{
if (*val < target) {
*val += speed * cls.frametime;
if (*val > target)
*val = target;
} else if (*val > target) {
*val -= speed * cls.frametime;
if (*val < target)
*val = target;
}
}

//
// main.c
//
Expand Down Expand Up @@ -743,14 +756,14 @@ void CL_CheckEntityPresent(int entnum, const char *what);

// the sound code makes callbacks to the client for entitiy position
// information, so entities can be dynamically re-spatialized
void CL_GetEntitySoundOrigin(int ent, vec3_t org);
void CL_GetEntitySoundOrigin(unsigned entnum, vec3_t org);


//
// view.c
//
extern int gun_frame;
extern qhandle_t gun_model;
extern int gun_frame;
extern qhandle_t gun_model;

void V_Init(void);
void V_Shutdown(void);
Expand Down Expand Up @@ -797,6 +810,7 @@ void CL_InitTEnts(void);
void CL_PredictAngles(void);
void CL_PredictMovement(void);
void CL_CheckPredictionError(void);
void CL_Trace(trace_t *tr, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int contentmask);


//
Expand Down
12 changes: 1 addition & 11 deletions src/client/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,17 +1028,7 @@ void Con_RunConsole(void)
return;
}

if (con.currentHeight > con.destHeight) {
con.currentHeight -= con_speed->value * cls.frametime;
if (con.currentHeight < con.destHeight) {
con.currentHeight = con.destHeight;
}
} else if (con.currentHeight < con.destHeight) {
con.currentHeight += con_speed->value * cls.frametime;
if (con.currentHeight > con.destHeight) {
con.currentHeight = con.destHeight;
}
}
CL_AdvanceValue(&con.currentHeight, con.destHeight, con_speed->value);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/client/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ static void CL_Record_f(void)

// send the serverdata
MSG_WriteByte(svc_serverdata);
MSG_WriteLong(PROTOCOL_VERSION_DEFAULT);
MSG_WriteLong(min(cls.serverProtocol, PROTOCOL_VERSION_DEFAULT));
MSG_WriteLong(cl.servercount);
MSG_WriteByte(1); // demos are always attract loops
MSG_WriteString(cl.gamedir);
Expand Down
38 changes: 16 additions & 22 deletions src/client/entities.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,8 @@ static void CL_AddPacketEntities(void)
#endif
}

if ((effects & EF_GIB) && !cl_gibs->integer) {
if ((effects & EF_GIB) && !cl_gibs->integer)
goto skip;
}

// create a new entity

Expand Down Expand Up @@ -652,7 +651,7 @@ static void CL_AddPacketEntities(void)
ent.alpha = 0.70f;

// render effects (fullbright, translucent, etc)
if ((effects & EF_COLOR_SHELL))
if (effects & EF_COLOR_SHELL)
ent.flags = 0; // renderfx go on color shell entity
else
ent.flags = renderfx;
Expand All @@ -678,11 +677,9 @@ static void CL_AddPacketEntities(void)
} else { // interpolate angles
LerpAngles(cent->prev.angles, cent->current.angles,
cl.lerpfrac, ent.angles);

// mimic original ref_gl "leaning" bug (uuugly!)
if (s1->modelindex == 255 && cl_rollhack->integer) {
if (s1->modelindex == 255 && cl_rollhack->integer)
ent.angles[ROLL] = -ent.angles[ROLL];
}
}

int base_entity_flags = 0;
Expand All @@ -697,12 +694,11 @@ static void CL_AddPacketEntities(void)
else if (effects & EF_TRACKERTRAIL)
V_AddLight(ent.origin, 225, -1.0f, -1.0f, -1.0f);

if (!cl.thirdPersonView)
{
if(cls.ref_type == REF_TYPE_VKPT)
base_entity_flags |= RF_VIEWERMODEL; // only draw from mirrors
else
goto skip;
if (!cl.thirdPersonView) {
if(cls.ref_type == REF_TYPE_VKPT)
base_entity_flags |= RF_VIEWERMODEL; // only draw from mirrors
else
goto skip;
}

// don't tilt the model - looks weird
Expand All @@ -719,9 +715,8 @@ static void CL_AddPacketEntities(void)
}

// if set to invisible, skip
if (!s1->modelindex) {
if (!s1->modelindex)
goto skip;
}

if (effects & EF_BFG) {
ent.flags |= RF_TRANSLUCENT;
Expand Down Expand Up @@ -843,9 +838,8 @@ static void CL_AddPacketEntities(void)
// add automatic particle trails
if (effects & ~EF_ROTATE) {
if (effects & EF_ROCKET) {
if (!(cl_disable_particles->integer & NOPART_ROCKET_TRAIL)) {
if (!(cl_disable_particles->integer & NOPART_ROCKET_TRAIL))
CL_RocketTrail(cent->lerp_origin, ent.origin, cent);
}
if (cl_dlight_hacks->integer & DLHACK_ROCKET_COLOR)
V_AddLight(ent.origin, 200, 1, 0.23f, 0);
else
Expand All @@ -866,9 +860,8 @@ static void CL_AddPacketEntities(void)
} else if (effects & EF_GIB) {
CL_DiminishingTrail(cent->lerp_origin, ent.origin, cent, effects);
} else if (effects & EF_GRENADE) {
if (!(cl_disable_particles->integer & NOPART_GRENADE_TRAIL)) {
if (!(cl_disable_particles->integer & NOPART_GRENADE_TRAIL))
CL_DiminishingTrail(cent->lerp_origin, ent.origin, cent, effects);
}
} else if (effects & EF_FLIES) {
CL_FlyEffect(cent, ent.origin);
} else if (effects & EF_BFG) {
Expand Down Expand Up @@ -916,9 +909,8 @@ static void CL_AddPacketEntities(void)
} else if (effects & EF_BLUEHYPERBLASTER) {
V_AddLight(ent.origin, 200, 0, 0, 1);
} else if (effects & EF_PLASMA) {
if (effects & EF_ANIM_ALLFAST) {
if (effects & EF_ANIM_ALLFAST)
CL_BlasterTrail(cent->lerp_origin, ent.origin);
}
V_AddLight(ent.origin, 130, 1, 0.5f, 0.5f);
}
}
Expand Down Expand Up @@ -1362,13 +1354,15 @@ CL_GetEntitySoundOrigin
Called to get the sound spatialization origin
===============
*/
void CL_GetEntitySoundOrigin(int entnum, vec3_t org)
void CL_GetEntitySoundOrigin(unsigned entnum, vec3_t org)
{
centity_t *ent;
mmodel_t *cm;
vec3_t mid;

Q_assert(entnum >= 0 && entnum < MAX_EDICTS);
if (entnum >= MAX_EDICTS)
Com_Error(ERR_DROP, "%s: bad entity", __func__);

if (!entnum || entnum == listener_entnum) {
// should this ever happen?
VectorCopy(listener_origin, org);
Expand Down
Loading

0 comments on commit b9358bb

Please sign in to comment.