From f8798d60846e1acff7c3240fb09e43dd3596b55d Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Tue, 9 Mar 2021 11:39:52 +0100 Subject: [PATCH] Base: Merge client/input.qc and server/input.qc into shared/input.qc, as it makes a lot more sense of prediction purposes --- base/src/client/progs.src | 2 - base/src/server/defs.h | 2 + .../predict.qc => server/flashlight.h} | 10 +- base/src/server/gamerules.qc | 91 ------------------- base/src/server/gamerules_multiplayer.qc | 1 - base/src/server/gamerules_singleplayer.qc | 1 - base/src/{client/input.qc => server/player.h} | 15 +-- base/src/server/player.qc | 86 +----------------- base/src/server/progs.src | 4 +- base/src/shared/include.src | 1 + base/src/{server => shared}/input.qc | 51 +++++------ base/src/shared/weapon_common.h | 5 + 12 files changed, 36 insertions(+), 233 deletions(-) rename base/src/{client/predict.qc => server/flashlight.h} (90%) rename base/src/{client/input.qc => server/player.h} (76%) rename base/src/{server => shared}/input.qc (86%) diff --git a/base/src/client/progs.src b/base/src/client/progs.src index f2cfadc8..add2b74d 100755 --- a/base/src/client/progs.src +++ b/base/src/client/progs.src @@ -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 */ diff --git a/base/src/server/defs.h b/base/src/server/defs.h index 88c34489..53eaf327 100644 --- a/base/src/server/defs.h +++ b/base/src/server/defs.h @@ -16,3 +16,5 @@ #include "gamerules.h" #include "items.h" +#include "flashlight.h" +#include "player.h" diff --git a/base/src/client/predict.qc b/base/src/server/flashlight.h similarity index 90% rename from base/src/client/predict.qc rename to base/src/server/flashlight.h index 5aea1382..d9ad0eff 100644 --- a/base/src/client/predict.qc +++ b/base/src/server/flashlight.h @@ -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); diff --git a/base/src/server/gamerules.qc b/base/src/server/gamerules.qc index c1f8dc4c..98463ef6 100644 --- a/base/src/server/gamerules.qc +++ b/base/src/server/gamerules.qc @@ -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 diff --git a/base/src/server/gamerules_multiplayer.qc b/base/src/server/gamerules_multiplayer.qc index 5f785a91..1ccb2fc8 100644 --- a/base/src/server/gamerules_multiplayer.qc +++ b/base/src/server/gamerules_multiplayer.qc @@ -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; diff --git a/base/src/server/gamerules_singleplayer.qc b/base/src/server/gamerules_singleplayer.qc index 1869779a..e131d908 100644 --- a/base/src/server/gamerules_singleplayer.qc +++ b/base/src/server/gamerules_singleplayer.qc @@ -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; diff --git a/base/src/client/input.qc b/base/src/server/player.h similarity index 76% rename from base/src/client/input.qc rename to base/src/server/player.h index 63e1d2d0..981c3e60 100644 --- a/base/src/client/input.qc +++ b/base/src/server/player.h @@ -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); diff --git a/base/src/server/player.qc b/base/src/server/player.qc index a11d2638..80fab744 100644 --- a/base/src/server/player.qc +++ b/base/src/server/player.qc @@ -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) { diff --git a/base/src/server/progs.src b/base/src/server/progs.src index b2a318e9..a078ad90 100755 --- a/base/src/server/progs.src +++ b/base/src/server/progs.src @@ -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 */ diff --git a/base/src/shared/include.src b/base/src/shared/include.src index 1fe9eb38..4e84be95 100644 --- a/base/src/shared/include.src +++ b/base/src/shared/include.src @@ -18,4 +18,5 @@ items.h weapons.h weapons.qc weapon_common.qc +input.qc #endlist diff --git a/base/src/server/input.qc b/base/src/shared/input.qc similarity index 86% rename from base/src/server/input.qc rename to base/src/shared/input.qc index 89d37cc5..e67a5c6f 100644 --- a/base/src/server/input.qc +++ b/base/src/shared/input.qc @@ -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; } diff --git a/base/src/shared/weapon_common.h b/base/src/shared/weapon_common.h index acb9acbc..e46654b4 100644 --- a/base/src/shared/weapon_common.h +++ b/base/src/shared/weapon_common.h @@ -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);