Client: Allow base_player and spectator classes to override CSQC_Input_Frame

with a new method: ClientInputFrame.
This commit is contained in:
Marco Cawthorne 2022-01-31 15:31:07 -08:00
parent 419e89e861
commit e11465018f
Signed by: eukara
GPG key ID: C196CD8BA993248A
6 changed files with 90 additions and 53 deletions

View file

@ -510,58 +510,14 @@ CSQC_Input_Frame(void)
{
CSQC_UpdateSeat();
/* If we are inside a VGUI, don't let the client do stuff outside */
if (VGUI_Active()) {
input_impulse = 0;
input_buttons = 0;
return;
}
/* background maps have no input */
if (serverkeyfloat("background") == 1)
return;
if (pSeat->m_iInputAttack2 == TRUE) {
input_buttons |= INPUT_BUTTON3;
}
if (pSeat->m_iInputReload == TRUE) {
input_buttons |= INPUT_BUTTON4;
}
if (pSeat->m_iInputUse == TRUE) {
input_buttons |= INPUT_BUTTON5;
}
if (pSeat->m_iInputDuck == TRUE) {
input_buttons |= INPUT_BUTTON8;
}
/* The HUD needs more time */
if (pSeat->m_iHUDWeaponSelected) {
if ((input_buttons & INPUT_BUTTON0))
HUD_DrawWeaponSelect_Trigger();
else if ((input_buttons & INPUT_BUTTON3))
pSeat->m_iHUDWeaponSelected = pSeat->m_flHUDWeaponSelectTime = 0;
pSeat->m_flInputBlockTime = time + 0.2;
}
/* prevent accidental input packets */
if (pSeat->m_flInputBlockTime > time) {
input_buttons &= ~INPUT_BUTTON0;
input_buttons &= ~INPUT_BUTTON3;
pSeat->m_iInputAttack2 = FALSE;
return;
}
/* compat*/
if (input_impulse == 201) {
sendevent("Spraylogo", "");
}
if (pSeat->m_flCameraTime > time) {
/* TODO: Supress the changing of view_angles/input_angles. */
if (self.classname == "player") {
player pl;
pl = (player)pSeat->m_ePlayer;
pl.ClientInputFrame();
} else if (self.classname == "spectator") {
spectator spec;
spec = (spectator)pSeat->m_ePlayer;
pl.ClientInputFrame();
}
}

View file

@ -39,5 +39,4 @@ void Font_DrawField(vector vecOrigin, vector vecSize, string strText, font_s fnt
string Font_RGBtoHex(vector vecColor);
int Font_GetHeight(font_s);
float Font_GetStringWidth(string strText, float flColors, font_s fnt);
float Font_GetID(font_s fnt);

View file

@ -91,6 +91,7 @@ base_player:NSSurfacePropEntity
virtual void(float, float) ReceiveEntity;
virtual void(void) PredictPreFrame;
virtual void(void) PredictPostFrame;
virtual void(void) ClientInputFrame;
#else
int voted;

View file

@ -15,6 +15,71 @@
*/
#ifdef CLIENT
/*
=================
base_player::ClientInputFrame
This is basically CSQC_Input_Frame! So games can override this as they please.
=================
*/
void
base_player::ClientInputFrame(void)
{
/* If we are inside a VGUI, don't let the client do stuff outside */
if (VGUI_Active()) {
input_impulse = 0;
input_buttons = 0;
return;
}
/* background maps have no input */
if (serverkeyfloat("background") == 1)
return;
if (pSeat->m_iInputAttack2 == TRUE) {
input_buttons |= INPUT_BUTTON3;
}
if (pSeat->m_iInputReload == TRUE) {
input_buttons |= INPUT_BUTTON4;
}
if (pSeat->m_iInputUse == TRUE) {
input_buttons |= INPUT_BUTTON5;
}
if (pSeat->m_iInputDuck == TRUE) {
input_buttons |= INPUT_BUTTON8;
}
/* The HUD needs more time */
if (pSeat->m_iHUDWeaponSelected) {
if ((input_buttons & INPUT_BUTTON0))
HUD_DrawWeaponSelect_Trigger();
else if ((input_buttons & INPUT_BUTTON3))
pSeat->m_iHUDWeaponSelected = pSeat->m_flHUDWeaponSelectTime = 0;
pSeat->m_flInputBlockTime = time + 0.2;
}
/* prevent accidental input packets */
if (pSeat->m_flInputBlockTime > time) {
input_buttons &= ~INPUT_BUTTON0;
input_buttons &= ~INPUT_BUTTON3;
pSeat->m_iInputAttack2 = FALSE;
return;
}
/* compat*/
if (input_impulse == 201) {
sendevent("Spraylogo", "");
}
if (pSeat->m_flCameraTime > time) {
/* TODO: Supress the changing of view_angles/input_angles. */
}
}
/*
=================
base_player::ReceiveEntity

View file

@ -48,6 +48,7 @@ class spectator
virtual float(entity, float) SendEntity;
virtual void(void) RunClientCommand;
#else
virtual void(void) ClientInputFrame;
virtual void(float) ReceiveEntity;
virtual float(void) predraw;
#endif

View file

@ -85,6 +85,21 @@ spectator::RunClientCommand(void)
}
#else
void
spectator::ClientInputFrame(void)
{
/* If we are inside a VGUI, don't let the client do stuff outside */
if (VGUI_Active()) {
input_impulse = 0;
input_buttons = 0;
return;
}
/* background maps have no input */
if (serverkeyfloat("background") == 1)
return;
}
void
spectator::ReceiveEntity(float new)
{