Server: Physics variables are now controlled via sv_ cvars like they
usually are in idTech, however we're now checking them every frame and updating the networked infokeys in question
This commit is contained in:
parent
6e38bac564
commit
fca8620cba
4 changed files with 47 additions and 16 deletions
|
@ -24,6 +24,8 @@ Called once every single frame.
|
|||
void
|
||||
StartFrame(void)
|
||||
{
|
||||
PMove_StartFrame();
|
||||
|
||||
/* For entity parenting to work, we need to go through and run on every
|
||||
* this method on every CBaseEntity class */
|
||||
for (entity a = world; (a = findfloat(a, ::identity, 1));) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
||||
* Copyright (c) 2016-2021 Marco Hladik <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -45,8 +45,6 @@ HLMaterials_Load(string filename)
|
|||
void
|
||||
HLMaterials_Init(void)
|
||||
{
|
||||
/* load materials.txt because someone thought this was the best idea */
|
||||
|
||||
hashMaterials = __NULL__;
|
||||
hashMaterials = hash_createtab(2, HASH_ADD);
|
||||
|
||||
|
@ -68,6 +66,6 @@ HLMaterials_Init(void)
|
|||
/* the way TW did it back in '03 */
|
||||
HLMaterials_Load(sprintf("maps/%s.mat", mapname));
|
||||
|
||||
/* the way TW did it back in '03 */
|
||||
/* Trinity does it this way */
|
||||
HLMaterials_Load(sprintf("maps/%s_materials.txt", mapname));
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ int trace_endcontentsi;
|
|||
.vector basevelocity;
|
||||
.entity groundentity;
|
||||
|
||||
#ifdef SERVER
|
||||
void PMove_StartFrame(void);
|
||||
#endif
|
||||
|
||||
void PMove_Init(void);
|
||||
int PMove_Contents(vector org);
|
||||
float PMove_Gravity(entity ent);
|
||||
|
|
|
@ -62,6 +62,18 @@
|
|||
#define PMOVE_STEP_RUNSPEED 220
|
||||
#endif
|
||||
|
||||
/* if they're undefined by a config, they'll be set by the game/mod default */
|
||||
var float autocvar_sv_stepheight = PMOVE_STEPHEIGHT;
|
||||
var float autocvar_sv_airstepheight = PMOVE_AIRSTEPHEIGHT;
|
||||
var float autocvar_sv_friction = PMOVE_FRICTION;
|
||||
var float autocvar_sv_edgefriction = PMOVE_EDGEFRICTION;
|
||||
var float autocvar_sv_stopspeed = PMOVE_STOPSPEED;
|
||||
var float autocvar_sv_gravity = PMOVE_GRAVITY;
|
||||
var float autocvar_sv_airaccelerate = PMOVE_AIRACCELERATE;
|
||||
var float autocvar_sv_wateraccelerate = PMOVE_WATERACCELERATE;
|
||||
var float autocvar_sv_accelerate = PMOVE_ACCELERATE;
|
||||
var float autocvar_sv_maxspeed = PMOVE_MAXSPEED;
|
||||
|
||||
/* FIXME: jumptime should use the time global, as time intervals are not
|
||||
* predictable - decrement it based upon input_timelength */
|
||||
|
||||
|
@ -72,20 +84,35 @@
|
|||
void
|
||||
PMove_Init(void)
|
||||
{
|
||||
#ifdef SERVER
|
||||
readcmd(sprintf("serverinfo phy_stepheight %d\n", PMOVE_STEPHEIGHT));
|
||||
readcmd(sprintf("serverinfo phy_airstepheight %d\n", PMOVE_AIRSTEPHEIGHT));
|
||||
readcmd(sprintf("serverinfo phy_friction %d\n", PMOVE_FRICTION));
|
||||
readcmd(sprintf("serverinfo phy_edgefriction %d\n", PMOVE_EDGEFRICTION));
|
||||
readcmd(sprintf("serverinfo phy_stopspeed %d\n", PMOVE_STOPSPEED));
|
||||
readcmd(sprintf("serverinfo phy_gravity %d\n", PMOVE_GRAVITY));
|
||||
readcmd(sprintf("serverinfo phy_airaccelerate %d\n", PMOVE_AIRACCELERATE));
|
||||
readcmd(sprintf("serverinfo phy_wateraccelerate %d\n", PMOVE_WATERACCELERATE));
|
||||
readcmd(sprintf("serverinfo phy_accelerate %d\n", PMOVE_ACCELERATE));
|
||||
readcmd(sprintf("serverinfo phy_maxspeed %d\n", PMOVE_MAXSPEED));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SERVER
|
||||
/* we need to network our changes everytime cvars are updated */
|
||||
void
|
||||
PMove_UpdateVar(string info, string cv)
|
||||
{
|
||||
float d = cvar(cv);
|
||||
if (serverkeyfloat(info) != d) {
|
||||
readcmd(sprintf("serverinfo %s %d\n", info, d));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PMove_StartFrame(void)
|
||||
{
|
||||
PMove_UpdateVar("phy_stepheight", "sv_stepheight");
|
||||
PMove_UpdateVar("phy_airstepheight", "sv_airstepheight");
|
||||
PMove_UpdateVar("phy_friction", "sv_friction");
|
||||
PMove_UpdateVar("phy_edgefriction", "sv_edgefriction");
|
||||
PMove_UpdateVar("phy_stopspeed", "sv_stopspeed");
|
||||
PMove_UpdateVar("phy_gravity", "sv_gravity");
|
||||
PMove_UpdateVar("phy_airaccelerate", "sv_airaccelerate");
|
||||
PMove_UpdateVar("phy_wateraccelerate", "sv_wateraccelerate");
|
||||
PMove_UpdateVar("phy_accelerate", "sv_accelerate");
|
||||
PMove_UpdateVar("phy_maxspeed", "sv_maxspeed");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* pointcontents reimplementation, only way we can effectively trace
|
||||
* against ladders and liquids that are defined in the game-logic.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue