Base: Merge client/input.qc and server/input.qc into shared/input.qc, as

it makes a lot more sense of prediction purposes
This commit is contained in:
Marco Cawthorne 2021-03-09 11:39:52 +01:00
parent a062ff92a8
commit f8798d6084
12 changed files with 36 additions and 233 deletions

View file

@ -24,7 +24,6 @@ defs.h
/* mod specific functions */
../shared/include.src
predict.qc
init.qc
player.qc
entities.qc
@ -34,7 +33,6 @@ view.qc
hud.qc
hud_weaponselect.qc
scoreboard.qc
input.qc
modelevent.qc
/* global client/shared code */

View file

@ -16,3 +16,5 @@
#include "gamerules.h"
#include "items.h"
#include "flashlight.h"
#include "player.h"

View file

@ -14,12 +14,4 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void
GamePredict_PreFrame(player pl)
{
}
void
GamePredict_PostFrame(player pl)
{
}
void Flashlight_Toggle(void);

View file

@ -75,97 +75,6 @@ void
GameRules::PlayerPostFrame(base_player pl)
{
Animation_PlayerUpdate();
if (autocvar_sv_playerkeepalive)
pl.SendFlags |= PLAYER_KEEPALIVE;
if (pl.old_modelindex != pl.modelindex)
pl.SendFlags |= PLAYER_MODELINDEX;
if (pl.old_origin[0] != pl.origin[0])
pl.SendFlags |= PLAYER_ORIGIN;
if (pl.old_origin[1] != pl.origin[1])
pl.SendFlags |= PLAYER_ORIGIN;
if (pl.old_origin[2] != pl.origin[2])
pl.SendFlags |= PLAYER_ORIGIN_Z;
if (pl.old_angles[0] != pl.v_angle[0])
pl.SendFlags |= PLAYER_ANGLES_X;
if (pl.old_angles[1] != pl.angles[1])
pl.SendFlags |= PLAYER_ANGLES_Y;
if (pl.old_angles[2] != pl.angles[2])
pl.SendFlags |= PLAYER_ANGLES_Z;
if (pl.old_velocity[0] != pl.velocity[0])
pl.SendFlags |= PLAYER_VELOCITY;
if (pl.old_velocity[1] != pl.velocity[1])
pl.SendFlags |= PLAYER_VELOCITY;
if (pl.old_velocity[2] != pl.velocity[2])
pl.SendFlags |= PLAYER_VELOCITY_Z;
if (pl.old_flags != pl.flags)
pl.SendFlags |= PLAYER_FLAGS;
if (pl.old_gflags != pl.gflags)
pl.SendFlags |= PLAYER_FLAGS;
if (pl.old_activeweapon != pl.activeweapon)
pl.SendFlags |= PLAYER_WEAPON;
if (pl.old_items != pl.g_items)
pl.SendFlags |= PLAYER_ITEMS;
if (pl.old_health != pl.health)
pl.SendFlags |= PLAYER_HEALTH;
if (pl.old_armor != pl.armor)
pl.SendFlags |= PLAYER_ARMOR;
if (pl.old_movetype != pl.movetype)
pl.SendFlags |= PLAYER_MOVETYPE;
if (pl.old_viewofs != pl.view_ofs[2])
pl.SendFlags |= PLAYER_VIEWOFS;
if (pl.old_baseframe != pl.baseframe)
pl.SendFlags |= PLAYER_BASEFRAME;
if (pl.old_frame != pl.frame)
pl.SendFlags |= PLAYER_FRAME;
if (pl.old_a_ammo1 != pl.a_ammo1)
pl.SendFlags |= PLAYER_AMMO1;
if (pl.old_a_ammo2 != pl.a_ammo2)
pl.SendFlags |= PLAYER_AMMO2;
if (pl.old_a_ammo3 != pl.a_ammo3)
pl.SendFlags |= PLAYER_AMMO3;
pl.old_modelindex = pl.modelindex;
pl.old_origin = pl.origin;
pl.old_angles = pl.angles;
pl.old_angles[0] = pl.v_angle[0];
pl.old_velocity = pl.velocity;
pl.old_flags = pl.flags;
pl.old_gflags = pl.gflags;
pl.old_activeweapon = pl.activeweapon;
pl.old_items = pl.g_items;
pl.old_health = pl.health;
pl.old_armor = pl.armor;
pl.old_movetype = pl.movetype;
pl.old_viewofs = pl.view_ofs[2];
pl.old_baseframe = pl.baseframe;
pl.old_frame = pl.frame;
pl.old_a_ammo1 = pl.a_ammo1;
pl.old_a_ammo2 = pl.a_ammo2;
pl.old_a_ammo3 = pl.a_ammo3;
}
void

View file

@ -82,7 +82,6 @@ MultiplayerRules::PlayerSpawn(base_player pp)
pl.velocity = [0,0,0];
pl.gravity = __NULL__;
pl.frame = 1;
pl.SendEntity = Player_SendEntity;
pl.SendFlags = UPDATE_ALL;
pl.customphysics = Empty;
pl.iBleeds = TRUE;

View file

@ -48,7 +48,6 @@ SingleplayerRules::PlayerSpawn(base_player pl)
pl.velocity = [0,0,0];
pl.gravity = __NULL__;
pl.frame = 1;
pl.SendEntity = Player_SendEntity;
pl.SendFlags = UPDATE_ALL;
pl.customphysics = Empty;
pl.iBleeds = TRUE;

View file

@ -14,16 +14,5 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void
Game_Input(void)
{
if (input_buttons & INPUT_BUTTON0) {
Weapons_Primary();
} else if (input_buttons & INPUT_BUTTON4) {
Weapons_Reload();
} else if (input_buttons & INPUT_BUTTON3) {
Weapons_Secondary();
} else {
Weapons_Release();
}
}
void Player_UseDown(void);
void Player_UseUp(void);

View file

@ -52,7 +52,7 @@ void Player_UseDown(void)
if (trace_ent.PlayerUse) {
self.flags &= ~FL_USE_RELEASED;
UseWorkaround(trace_ent);
/* Some entities want to support Use spamming */
@ -76,90 +76,6 @@ void Player_UseUp(void) {
}
}
/*
=================
Player_SendEntity
=================
*/
float Player_SendEntity(entity ePEnt, float fChanged)
{
player pl = (player)self;
if (pl.health <= 0 && ePEnt != pl) {
return FALSE;
}
WriteByte(MSG_ENTITY, ENT_PLAYER);
WriteFloat(MSG_ENTITY, fChanged);
/* really trying to get our moneys worth with 23 bits of mantissa */
if (fChanged & PLAYER_MODELINDEX) {
WriteShort(MSG_ENTITY, pl.modelindex);
}
if (fChanged & PLAYER_ORIGIN) {
WriteCoord(MSG_ENTITY, pl.origin[0]);
WriteCoord(MSG_ENTITY, pl.origin[1]);
}
if (fChanged & PLAYER_ORIGIN_Z) {
WriteCoord(MSG_ENTITY, pl.origin[2]);
}
if (fChanged & PLAYER_ANGLES_X) {
WriteFloat(MSG_ENTITY, pl.v_angle[0]);
}
if (fChanged & PLAYER_ANGLES_Y) {
WriteFloat(MSG_ENTITY, pl.angles[1]);
}
if (fChanged & PLAYER_ANGLES_Z) {
WriteFloat(MSG_ENTITY, pl.angles[2]);
}
if (fChanged & PLAYER_VELOCITY) {
WriteCoord(MSG_ENTITY, pl.velocity[0]);
WriteCoord(MSG_ENTITY, pl.velocity[1]);
}
if (fChanged & PLAYER_VELOCITY_Z) {
WriteCoord(MSG_ENTITY, pl.velocity[2]);
}
if (fChanged & PLAYER_FLAGS) {
WriteFloat(MSG_ENTITY, pl.flags);
WriteFloat(MSG_ENTITY, pl.gflags);
}
if (fChanged & PLAYER_WEAPON) {
WriteByte(MSG_ENTITY, pl.activeweapon);
}
if (fChanged & PLAYER_ITEMS) {
WriteFloat(MSG_ENTITY, (__variant)pl.g_items);
}
if (fChanged & PLAYER_HEALTH) {
WriteByte(MSG_ENTITY, pl.health);
}
if (fChanged & PLAYER_ARMOR) {
WriteByte(MSG_ENTITY, pl.armor);
}
if (fChanged & PLAYER_MOVETYPE) {
WriteByte(MSG_ENTITY, pl.movetype);
}
if (fChanged & PLAYER_VIEWOFS) {
WriteFloat(MSG_ENTITY, pl.view_ofs[2]);
}
if (fChanged & PLAYER_BASEFRAME) {
WriteByte(MSG_ENTITY, pl.baseframe);
}
if (fChanged & PLAYER_FRAME) {
WriteByte(MSG_ENTITY, pl.frame);
}
if (fChanged & PLAYER_AMMO1) {
WriteByte(MSG_ENTITY, pl.a_ammo1);
}
if (fChanged & PLAYER_AMMO2) {
WriteByte(MSG_ENTITY, pl.a_ammo2);
}
if (fChanged & PLAYER_AMMO3) {
WriteByte(MSG_ENTITY, pl.a_ammo3);
}
return TRUE;
}
void Weapons_Draw(void);
void CSEv_PlayerSwitchWeapon_i(int w)
{

View file

@ -13,11 +13,12 @@
../../../src/server/defs.h
../../../src/gs-entbase/server.src
../../../src/gs-entbase/shared.src
../shared/include.src
/* mod specific header */
defs.h
../shared/include.src
/* include the botlib if desired (optional) */
../../../src/botlib/include.src
@ -34,7 +35,6 @@ items.qc
rules.qc
flashlight.qc
modelevent.qc
input.qc
spawn.qc
/* global server/shared code */

View file

@ -18,4 +18,5 @@ items.h
weapons.h
weapons.qc
weapon_common.qc
input.qc
#endlist

View file

@ -23,6 +23,7 @@ Handles impulse and whatnot
*/
void Game_Input(void)
{
#ifdef SERVER
CGameRules rules = (CGameRules)g_grMode;
if (rules.m_iIntermission) {
@ -30,6 +31,27 @@ void Game_Input(void)
return;
}
if (self.impulse == 100) {
Flashlight_Toggle();
}
if (input_buttons & INPUT_BUTTON5) {
Player_UseDown();
} else {
Player_UseUp();
}
if (cvar("sv_cheats") == 1) {
player pl = (player)self;
if (self.impulse == 101) {
pl.health = 100;
pl.armor = 100;
}
}
self.impulse = 0;
#endif
if (input_buttons & INPUT_BUTTON0) {
Weapons_Primary();
} else if (input_buttons & INPUT_BUTTON4) {
@ -39,33 +61,4 @@ void Game_Input(void)
} else {
Weapons_Release();
}
if (input_buttons & INPUT_BUTTON5) {
Player_UseDown();
} else {
Player_UseUp();
}
if (self.impulse == 100) {
Flashlight_Toggle();
}
if (cvar("sv_cheats") == 1) {
player pl = (player)self;
if (self.impulse == 101) {
pl.health = 100;
pl.armor = 100;
}
if (self.impulse == 102) {
// Respawn all the entities
for (entity a = world; (a = findfloat(a, ::identity, 1));) {
CBaseEntity caw = (CBaseEntity)a;
caw.Respawn();
}
bprint(PRINT_HIGH, "Respawning all map entities...\n");
}
}
self.impulse = 0;
}

View file

@ -40,6 +40,11 @@ typedef struct
void(int, vector, float) hudpic;
} weapon_t;
void Weapons_Primary(void);
void Weapons_Secondary(void);
void Weapons_Reload(void);
void Weapons_Release(void);
void Weapons_DrawCrosshair(void);
void Weapons_MakeVectors(void);
vector Weapons_GetCameraPos(void);