Simplify prediction code with the help from upstream changes.

This commit is contained in:
Marco Cawthorne 2021-05-08 17:45:24 +02:00
parent 9d27fa953d
commit e858860db2
15 changed files with 125 additions and 218 deletions

View File

@ -107,10 +107,10 @@ ClientGame_EventParse(float fHeader)
FX_BreakModel(count, vecPos, vSize, [0,0,0], fStyle);
break;
case EV_IMPACT:
int iType;
impactType_t iType;
vector vOrigin, vNormal;
iType = (int)readbyte();
iType = (impactType_t)readbyte();
vOrigin[0] = readcoord();
vOrigin[1] = readcoord();
vOrigin[2] = readcoord();

View File

@ -44,7 +44,7 @@ ClientGame_RendererRestart(string rstr)
FX_GibHuman_Init();
FX_Spark_Init();
FX_Impact_Init();
FX_Lego_Init();
FX_Lego_Init();
FX_Soda_Init();
precache_model("sprites/640_death.spr");

View File

@ -22,7 +22,8 @@ class item_ammo:CBaseEntity
virtual void(void) touch;
};
void item_ammo::touch(void)
void
item_ammo::touch(void)
{
if not (other.flags & FL_CLIENT) {
return;
@ -42,7 +43,8 @@ void item_ammo::touch(void)
}
}
void item_ammo::Respawn(void)
void
item_ammo::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_TOSS);
@ -52,11 +54,15 @@ void item_ammo::Respawn(void)
think = __NULL__;
nextthink = -1;
Sound_Play(this, CHAN_ITEM, "ammo.respawn");
if (time > 30.0f)
Sound_Play(this, CHAN_ITEM, "ammo.respawn");
droptofloor();
}
void item_ammo::item_ammo(void)
void
item_ammo::item_ammo(void)
{
m_oldModel = model;
SetModel(m_oldModel);
@ -77,14 +83,17 @@ class ammo_forks:item_ammo
virtual void(void) touch;
};
void ammo_forks::ammo_forks(void)
void
ammo_forks::ammo_forks(void)
{
model = "models/w_fork2.mdl";
item_ammo::item_ammo();
SetRenderMode(RM_FULLBRIGHT);
SetRenderAmt(1.0f);
}
void ammo_forks::touch(void)
void
ammo_forks::touch(void)
{
if not (other.flags & FL_CLIENT) {
return;
@ -113,14 +122,17 @@ class ammo_legoblocks:item_ammo
virtual void(void) touch;
};
void ammo_legoblocks::ammo_legoblocks(void)
void
ammo_legoblocks::ammo_legoblocks(void)
{
model = "models/legoblocks.mdl";
item_ammo::item_ammo();
SetRenderMode(RM_FULLBRIGHT);
SetRenderAmt(1.0f);
}
void ammo_legoblocks::touch(void)
void
ammo_legoblocks::touch(void)
{
if not (other.flags & FL_CLIENT) {
return;
@ -149,14 +161,17 @@ class ammo_sodacans:item_ammo
virtual void(void) touch;
};
void ammo_sodacans::ammo_sodacans(void)
void
ammo_sodacans::ammo_sodacans(void)
{
model = "models/nukacola.mdl";
item_ammo::item_ammo();
SetRenderMode(RM_FULLBRIGHT);
SetRenderAmt(1.0f);
}
void ammo_sodacans::touch(void)
void
ammo_sodacans::touch(void)
{
if not (other.flags & FL_CLIENT) {
return;

View File

@ -34,7 +34,8 @@ class info_runespawn:CBaseEntity
virtual void(void) touch;
};
void info_runespawn::touch(void)
void
info_runespawn::touch(void)
{
if (other.classname != "player") {
return;
@ -53,7 +54,8 @@ void info_runespawn::touch(void)
nextthink = time + 30.0f;
}
void info_runespawn::Respawn(void)
void
info_runespawn::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_NONE);
@ -73,7 +75,8 @@ void info_runespawn::Respawn(void)
Sound_Play(this, CHAN_ITEM, "item.respawn");
}
void info_runespawn::info_runespawn(void)
void
info_runespawn::info_runespawn(void)
{
Sound_Precache("item.armor");
Sound_Precache("item.respawn");

View File

@ -34,7 +34,8 @@ class item_battery:CBaseEntity
virtual void(void) touch;
};
void item_battery::touch(void)
void
item_battery::touch(void)
{
if (other.classname != "player") {
return;
@ -63,7 +64,8 @@ void item_battery::touch(void)
}
}
void item_battery::Respawn(void)
void
item_battery::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_NONE);
@ -80,7 +82,8 @@ void item_battery::Respawn(void)
Sound_Play(this, CHAN_ITEM, "item.respawn");
}
void item_battery::item_battery(void)
void
item_battery::item_battery(void)
{
Sound_Precache("item.armor");
Sound_Precache("item.respawn");

View File

@ -29,7 +29,8 @@ class item_healthkit:CBaseEntity
virtual void(void) touch;
};
void item_healthkit::touch(void)
void
item_healthkit::touch(void)
{
if (other.classname != "player") {
return;
@ -51,7 +52,8 @@ void item_healthkit::touch(void)
}
}
void item_healthkit::Respawn(void)
void
item_healthkit::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_NONE);
@ -68,7 +70,8 @@ void item_healthkit::Respawn(void)
Sound_Play(this, CHAN_ITEM, "item.respawn");
}
void item_healthkit::item_healthkit(void)
void
item_healthkit::item_healthkit(void)
{
Sound_Precache("item.health");
Sound_Precache("item.respawn");

View File

@ -31,7 +31,8 @@ class item_rune_haste:CBaseTrigger
virtual void(void) Respawn;
};
void item_rune_haste::touch(void)
void
item_rune_haste::touch(void)
{
if (other.classname != "player") {
return;
@ -66,7 +67,8 @@ void item_rune_haste::touch(void)
}
}
void item_rune_haste::Respawn(void)
void
item_rune_haste::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_NONE);
@ -79,7 +81,8 @@ void item_rune_haste::Respawn(void)
sound(this, CHAN_ITEM, "items/suitchargeok1.wav", 1, ATTN_NORM, 150);
}
void item_rune_haste::item_rune_haste(void)
void
item_rune_haste::item_rune_haste(void)
{
/* Powerups have a base model always visable */
entity base = spawn();

View File

@ -32,7 +32,8 @@ class item_rune_stalker:CBaseTrigger
virtual void(void) Respawn;
};
void item_rune_stalker::touch(void)
void
item_rune_stalker::touch(void)
{
if (other.classname != "player") {
return;
@ -68,7 +69,8 @@ void item_rune_stalker::touch(void)
}
}
void item_rune_stalker::Respawn(void)
void
item_rune_stalker::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetMovetype(MOVETYPE_TOSS);
@ -81,7 +83,8 @@ void item_rune_stalker::Respawn(void)
sound(this, CHAN_ITEM, "items/suitchargeok1.wav", 1, ATTN_NORM, 150);
}
void item_rune_stalker::item_rune_stalker(void)
void
item_rune_stalker::item_rune_stalker(void)
{
/* Powerups have a base model always visable */

View File

@ -29,7 +29,8 @@ class item_weaponbox:CBaseEntity
virtual void(player) setup;
};
void item_weaponbox::touch(void)
void
item_weaponbox::touch(void)
{
if (other.classname != "player") {
return;
@ -60,7 +61,8 @@ void item_weaponbox::touch(void)
remove(this);
}
void item_weaponbox::setup(player pl)
void
item_weaponbox::setup(player pl)
{
/* TODO: Should the magazine bits be transferred too? */
ammo_forks = pl.ammo_forks;
@ -72,7 +74,8 @@ void item_weaponbox::setup(player pl)
weapon_items = pl.g_items;
}
void item_weaponbox::item_weaponbox(void)
void
item_weaponbox::item_weaponbox(void)
{
SetModel("models/basket.mdl");
SetSize([-16,-16,0], [16,16,16]);
@ -80,7 +83,8 @@ void item_weaponbox::item_weaponbox(void)
SetMovetype(MOVETYPE_TOSS);
}
void weaponbox_spawn(player spawner)
void
weaponbox_spawn(player spawner)
{
item_weaponbox weaponbox = spawn(item_weaponbox);
weaponbox.SetOrigin(spawner.origin);

View File

@ -14,7 +14,8 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void item_pickup::touch(void)
void
item_pickup::touch(void)
{
if (other.classname != "player") {
return;
@ -44,19 +45,22 @@ void item_pickup::touch(void)
}
}
void item_pickup::SetItem(int i)
void
item_pickup::SetItem(int i)
{
id = i;
m_oldModel = Weapons_GetWorldmodel(id);
SetModel(m_oldModel);
}
void item_pickup::SetFloating(int i)
void
item_pickup::SetFloating(int i)
{
m_bFloating = rint(bound(0, m_bFloating, 1));
}
void item_pickup::Respawn(void)
void
item_pickup::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetOrigin(m_oldOrigin);
@ -84,7 +88,8 @@ void item_pickup::Respawn(void)
}
}
void item_pickup::item_pickup(void)
void
item_pickup::item_pickup(void)
{
Sound_Precache("item.respawn");
Sound_Precache("weapon.pickup");

View File

@ -20,7 +20,8 @@ Game_InitRules(void)
g_grMode = spawn(HHDMultiplayerRules);
}
void Game_Worldspawn(void)
void
Game_Worldspawn(void)
{
precache_model("models/player.mdl");
precache_model("models/w_weaponbox.mdl");

View File

@ -69,7 +69,7 @@ class player:base_player
virtual void(void) draw;
virtual float() predraw;
virtual void(void) postdraw;
virtual void(float) ReceiveEntity;
virtual void(float,float) ReceiveEntity;
virtual void(void) PredictPreFrame;
virtual void(void) PredictPostFrame;
#else
@ -88,61 +88,9 @@ player::ReceiveEntity
=================
*/
void
player::ReceiveEntity(float new)
player::ReceiveEntity(float new, float fl)
{
float fl;
/* seed for our prediction table */
sequence = servercommandframe;
fl = readfloat();
/* HACK: we need to make this more reliable */
if (fl == UPDATE_ALL) {
/* we respawned */
gravity = __NULL__;
}
if (fl & PLAYER_MODELINDEX)
modelindex = readshort();
if (fl & PLAYER_ORIGIN) {
origin[0] = readcoord();
origin[1] = readcoord();
}
if (fl & PLAYER_ORIGIN_Z)
origin[2] = readcoord();
if (fl & PLAYER_ANGLES_X)
pitch = readfloat();
if (fl & PLAYER_ANGLES_Y)
angles[1] = readfloat();
if (fl & PLAYER_ANGLES_Z)
angles[2] = readfloat();
if (fl & PLAYER_VELOCITY) {
velocity[0] = readcoord();
velocity[1] = readcoord();
}
if (fl & PLAYER_VELOCITY_Z)
velocity[2] = readcoord();
if (fl & PLAYER_FLAGS) {
flags = readfloat();
gflags = readfloat();
}
if (fl & PLAYER_WEAPON)
activeweapon = readbyte();
if (fl & PLAYER_ITEMS)
g_items = (__variant)readfloat();
if (fl & PLAYER_HEALTH)
health = readbyte();
if (fl & PLAYER_ARMOR)
armor = readbyte();
if (fl & PLAYER_MOVETYPE)
movetype = readbyte();
if (fl & PLAYER_VIEWOFS)
view_ofs[2] = readfloat();
base_player::ReceiveEntity(new, fl);
/* animation */
if (fl & PLAYER_TOPFRAME) {
@ -187,6 +135,8 @@ so we can roll them back later.
void
player::PredictPreFrame(void)
{
base_player::PredictPreFrame();
ammo_forks_net = ammo_forks;
ammo_knives_net = ammo_knives;
ammo_legogrenade_net = ammo_legogrenade;
@ -211,6 +161,8 @@ Where we roll back our values to the ones last sent/verified by the server.
void
player::PredictPostFrame(void)
{
base_player::PredictPostFrame();
ammo_forks = ammo_forks_net;
ammo_knives = ammo_knives_net;
ammo_legogrenade = ammo_legogrenade_net;
@ -229,77 +181,7 @@ player::PredictPostFrame(void)
void
player::EvaluateEntity(void)
{
SendFlags |= PLAYER_KEEPALIVE;
if (old_modelindex != modelindex)
SendFlags |= PLAYER_MODELINDEX;
if (old_origin[0] != origin[0])
SendFlags |= PLAYER_ORIGIN;
if (old_origin[1] != origin[1])
SendFlags |= PLAYER_ORIGIN;
if (old_origin[2] != origin[2])
SendFlags |= PLAYER_ORIGIN_Z;
if (old_angles[0] != v_angle[0])
SendFlags |= PLAYER_ANGLES_X;
if (old_angles[1] != angles[1])
SendFlags |= PLAYER_ANGLES_Y;
if (old_angles[2] != angles[2])
SendFlags |= PLAYER_ANGLES_Z;
if (old_velocity[0] != velocity[0])
SendFlags |= PLAYER_VELOCITY;
if (old_velocity[1] != velocity[1])
SendFlags |= PLAYER_VELOCITY;
if (old_velocity[2] != velocity[2])
SendFlags |= PLAYER_VELOCITY_Z;
if (old_flags != flags)
SendFlags |= PLAYER_FLAGS;
if (old_gflags != gflags)
SendFlags |= PLAYER_FLAGS;
if (old_activeweapon != activeweapon)
SendFlags |= PLAYER_WEAPON;
if (old_items != g_items)
SendFlags |= PLAYER_ITEMS;
if (old_health != health)
SendFlags |= PLAYER_HEALTH;
if (old_armor != armor)
SendFlags |= PLAYER_ARMOR;
if (old_movetype != movetype)
SendFlags |= PLAYER_MOVETYPE;
if (old_viewofs != view_ofs[2])
SendFlags |= PLAYER_VIEWOFS;
old_modelindex = modelindex;
old_origin = origin;
old_angles = angles;
old_angles[0] = v_angle[0];
old_velocity = velocity;
old_flags = flags;
old_gflags = gflags;
old_activeweapon = activeweapon;
old_items = g_items;
old_health = health;
old_armor = armor;
old_movetype = movetype;
old_viewofs = view_ofs[2];
old_baseframe = baseframe;
old_frame = frame;
base_player::EvaluateEntity();
if (ammo_forks_net == ammo_forks)
SendFlags |= PLAYER_AMMO2;
@ -363,43 +245,7 @@ player::SendEntity(entity ePEnt, float fChanged)
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, modelindex);
if (fChanged & PLAYER_ORIGIN) {
WriteCoord(MSG_ENTITY, origin[0]);
WriteCoord(MSG_ENTITY, origin[1]);
}
if (fChanged & PLAYER_ORIGIN_Z)
WriteCoord(MSG_ENTITY, origin[2]);
if (fChanged & PLAYER_ANGLES_X)
WriteFloat(MSG_ENTITY, v_angle[0]);
if (fChanged & PLAYER_ANGLES_Y)
WriteFloat(MSG_ENTITY, angles[1]);
if (fChanged & PLAYER_ANGLES_Z)
WriteFloat(MSG_ENTITY, angles[2]);
if (fChanged & PLAYER_VELOCITY) {
WriteCoord(MSG_ENTITY, velocity[0]);
WriteCoord(MSG_ENTITY, velocity[1]);
}
if (fChanged & PLAYER_VELOCITY_Z)
WriteCoord(MSG_ENTITY, velocity[2]);
if (fChanged & PLAYER_FLAGS) {
WriteFloat(MSG_ENTITY, flags);
WriteFloat(MSG_ENTITY, gflags);
}
if (fChanged & PLAYER_WEAPON)
WriteByte(MSG_ENTITY, activeweapon);
if (fChanged & PLAYER_ITEMS)
WriteFloat(MSG_ENTITY, (__variant)g_items);
if (fChanged & PLAYER_HEALTH)
WriteByte(MSG_ENTITY, bound(0, health, 255));
if (fChanged & PLAYER_ARMOR)
WriteByte(MSG_ENTITY, armor);
if (fChanged & PLAYER_MOVETYPE)
WriteByte(MSG_ENTITY, movetype);
if (fChanged & PLAYER_VIEWOFS)
WriteFloat(MSG_ENTITY, view_ofs[2]);
base_player::SendEntity(ePEnt, fChanged);
if (fChanged & PLAYER_TOPFRAME) {
WriteByte(MSG_ENTITY, anim_top);

View File

@ -21,7 +21,8 @@
.float waterlevel;
.float watertype;
float GamePMove_Maxspeed(player target)
float
GamePMove_Maxspeed(player target)
{
/* The Haste Rune doubles player speed */
if (target.g_items & 0x00001000i) {
@ -31,7 +32,8 @@ float GamePMove_Maxspeed(player target)
}
}
void GamePMove_Fall(player target, float impactspeed)
void
GamePMove_Fall(player target, float impactspeed)
{
if (impactspeed > 580) {
#ifdef SERVER
@ -43,7 +45,8 @@ void GamePMove_Fall(player target, float impactspeed)
}
}
void GamePMove_Jump(player target)
void
GamePMove_Jump(player target)
{
float flJumptimeDelta;
float flChainBonus;

View File

@ -219,7 +219,7 @@ w_hairspray_aimanim(void)
return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW;
}
void
void
w_hairspray_hudpic(int selected, vector pos, float a)
{
#ifdef CLIENT

View File

@ -32,7 +32,8 @@ enum
LEGO_HOLSTER
};
void w_lego_precache(void)
void
w_lego_precache(void)
{
#ifdef CLIENT
precache_model("sprites/hud_lego.spr");
@ -43,24 +44,33 @@ void w_lego_precache(void)
precache_model("models/lego2.mdl");
#endif
}
void w_lego_updateammo(player pl)
void
w_lego_updateammo(player pl)
{
Weapons_UpdateAmmo(pl, -1, pl.ammo_legogrenade, -1);
}
string w_lego_wmodel(void)
string
w_lego_wmodel(void)
{
return "models/w_lego.mdl";
}
string w_lego_pmodel(void)
string
w_lego_pmodel(void)
{
return "models/p_lego.mdl";
}
string w_lego_deathmsg(void)
string
w_lego_deathmsg(void)
{
return "";
}
int w_lego_pickup(int new, int startammo)
int
w_lego_pickup(int new, int startammo)
{
#ifdef SERVER
player pl = (player)self;
@ -75,7 +85,8 @@ int w_lego_pickup(int new, int startammo)
}
#ifdef SERVER
void w_lego_throw(void)
void
w_lego_throw(void)
{
static void WeaponLego_Throw_Touch(void) {
float dmg = Skill_GetValue("plr_hand_grenade", 150);
@ -116,7 +127,8 @@ void w_lego_throw(void)
}
#endif
void w_lego_draw(void)
void
w_lego_draw(void)
{
#ifdef CLIENT
Weapons_SetModel("models/v_lego.mdl");
@ -124,11 +136,14 @@ void w_lego_draw(void)
#endif
}
void w_lego_holster(void)
void
w_lego_holster(void)
{
}
void w_lego_primary(void)
void
w_lego_primary(void)
{
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
@ -160,7 +175,8 @@ void w_lego_primary(void)
pl.w_idle_next = 0.5f;
}
void w_lego_hud(void)
void
w_lego_hud(void)
{
#ifdef CLIENT
static vector cross_pos;
@ -190,7 +206,8 @@ void w_lego_hud(void)
#endif
}
void w_lego_release(void)
void
w_lego_release(void)
{
player pl = (player)self;
@ -268,7 +285,8 @@ weapon_t w_lego =
};
#ifdef SERVER
void weapon_lego(void)
void
weapon_lego(void)
{
Weapons_InitItem(WEAPON_LEGO);
/*item_pickup item = (item_pickup)self;