Simplify prediction code with the help from upstream SDK changes.
This commit is contained in:
parent
b2f8e2cca6
commit
317a7e28b5
|
@ -21,7 +21,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;
|
||||
|
@ -41,7 +42,8 @@ void item_ammo::touch(void)
|
|||
}
|
||||
}
|
||||
|
||||
void item_ammo::Respawn(void)
|
||||
void
|
||||
item_ammo::Respawn(void)
|
||||
{
|
||||
solid = SOLID_TRIGGER;
|
||||
movetype = MOVETYPE_TOSS;
|
||||
|
@ -59,7 +61,8 @@ void item_ammo::Respawn(void)
|
|||
droptofloor();
|
||||
}
|
||||
|
||||
void item_ammo::item_ammo(void)
|
||||
void
|
||||
item_ammo::item_ammo(void)
|
||||
{
|
||||
m_oldModel = model;
|
||||
SetModel(m_oldModel);
|
||||
|
@ -71,13 +74,13 @@ void item_ammo::item_ammo(void)
|
|||
* A single ammo_bolts will provide 5 bolts.
|
||||
*/
|
||||
|
||||
class
|
||||
class
|
||||
ammo_bolts:item_ammo
|
||||
{
|
||||
void(void) ammo_bolts;
|
||||
};
|
||||
|
||||
void
|
||||
void
|
||||
ammo_bolts::ammo_bolts(void)
|
||||
{
|
||||
model = "models/w_crossbow_clip.mdl";
|
||||
|
@ -97,12 +100,14 @@ class ammo_nailclip:item_ammo
|
|||
virtual void(void) touch;
|
||||
};
|
||||
|
||||
void ammo_nailclip::ammo_nailclip(void)
|
||||
void
|
||||
ammo_nailclip::ammo_nailclip(void)
|
||||
{
|
||||
model = "models/w_nailclip.mdl";
|
||||
item_ammo::item_ammo();
|
||||
}
|
||||
void ammo_nailclip::touch(void)
|
||||
void
|
||||
ammo_nailclip::touch(void)
|
||||
{
|
||||
if not (other.flags & FL_CLIENT) {
|
||||
return;
|
||||
|
@ -130,7 +135,8 @@ class ammo_nailround:item_ammo
|
|||
virtual void(void) touch;
|
||||
};
|
||||
|
||||
void ammo_nailround::ammo_nailround(void)
|
||||
void
|
||||
ammo_nailround::ammo_nailround(void)
|
||||
{
|
||||
model = "models/w_nailround.mdl";
|
||||
item_ammo::item_ammo();
|
||||
|
@ -164,12 +170,15 @@ class ammo_xencandy:item_ammo
|
|||
virtual void(void) touch;
|
||||
};
|
||||
|
||||
void ammo_xencandy::ammo_xencandy(void)
|
||||
void
|
||||
ammo_xencandy::ammo_xencandy(void)
|
||||
{
|
||||
model = "models/w_xencandy.mdl";
|
||||
item_ammo::item_ammo();
|
||||
}
|
||||
void ammo_xencandy::touch(void)
|
||||
|
||||
void
|
||||
ammo_xencandy::touch(void)
|
||||
{
|
||||
if not (other.flags & FL_CLIENT) {
|
||||
return;
|
||||
|
|
|
@ -75,7 +75,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
|
||||
|
@ -92,61 +92,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) {
|
||||
|
@ -196,6 +144,8 @@ so we can roll them back later.
|
|||
void
|
||||
player::PredictPreFrame(void)
|
||||
{
|
||||
base_player::PredictPreFrame();
|
||||
|
||||
bradnailer_mag_net = bradnailer_mag;
|
||||
nailgun_mag_net = nailgun_mag;
|
||||
shotgun_mag_net = shotgun_mag;
|
||||
|
@ -226,6 +176,8 @@ Where we roll back our values to the ones last sent/verified by the server.
|
|||
void
|
||||
player::PredictPostFrame(void)
|
||||
{
|
||||
base_player::PredictPostFrame();
|
||||
|
||||
bradnailer_mag = bradnailer_mag_net;
|
||||
nailgun_mag = nailgun_mag_net;
|
||||
shotgun_mag = shotgun_mag_net;
|
||||
|
@ -250,61 +202,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;
|
||||
base_player::EvaluateEntity();
|
||||
|
||||
/* animation */
|
||||
if (anim_bottom_net != anim_bottom || anim_bottom_time != anim_bottom_time_net)
|
||||
|
@ -318,22 +216,6 @@ player::EvaluateEntity(void)
|
|||
anim_bottom_net = anim_bottom;
|
||||
anim_bottom_time_net = anim_bottom_time;
|
||||
|
||||
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;
|
||||
|
||||
if (bradnailer_mag_net != bradnailer_mag)
|
||||
SendFlags |= PLAYER_AMMO1;
|
||||
if (nailgun_mag_net != nailgun_mag)
|
||||
|
@ -401,43 +283,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);
|
||||
|
|
|
@ -41,23 +41,32 @@ enum
|
|||
RADIO_HOLSTER
|
||||
};
|
||||
|
||||
void w_pipebomb_updateammo(player pl)
|
||||
void
|
||||
w_pipebomb_updateammo(player pl)
|
||||
{
|
||||
w_satchel_updateammo(pl);
|
||||
}
|
||||
string w_pipebomb_wmodel(void)
|
||||
|
||||
string
|
||||
w_pipebomb_wmodel(void)
|
||||
{
|
||||
return "models/w_pipebomb.mdl";
|
||||
}
|
||||
string w_pipebomb_pmodel(void)
|
||||
|
||||
string
|
||||
w_pipebomb_pmodel(void)
|
||||
{
|
||||
return "models/p_pipebomb.mdl";
|
||||
}
|
||||
string w_pipebomb_deathmsg(void)
|
||||
|
||||
string
|
||||
w_pipebomb_deathmsg(void)
|
||||
{
|
||||
return "%s blew up %s with a pipebomb.";
|
||||
}
|
||||
void w_pipebomb_precache(void)
|
||||
|
||||
void
|
||||
w_pipebomb_precache(void)
|
||||
{
|
||||
#ifdef SERVER
|
||||
Sound_Precache("weapon_satchel.bounce");
|
||||
|
@ -68,12 +77,14 @@ void w_pipebomb_precache(void)
|
|||
precache_model("models/p_pipebomb.mdl");
|
||||
}
|
||||
|
||||
int w_pipebomb_pickup(int new, int startammo)
|
||||
int
|
||||
w_pipebomb_pickup(int new, int startammo)
|
||||
{
|
||||
return w_satchel_pickup(new, startammo);
|
||||
}
|
||||
|
||||
void w_pipebomb_draw(void)
|
||||
void
|
||||
w_pipebomb_draw(void)
|
||||
{
|
||||
Weapons_SetModel("models/v_pipebomb.mdl");
|
||||
Weapons_ViewAnimation(SATCHEL_DRAW);
|
||||
|
@ -83,13 +94,15 @@ void w_pipebomb_draw(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void w_pipebomb_holster(void)
|
||||
void
|
||||
w_pipebomb_holster(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#ifdef SERVER
|
||||
void s_pipebomb_drop(entity master, vector src, vector vel)
|
||||
void
|
||||
s_pipebomb_drop(entity master, vector src, vector vel)
|
||||
{
|
||||
static void s_pipebomb_touch(void)
|
||||
{
|
||||
|
@ -112,7 +125,9 @@ void s_pipebomb_drop(entity master, vector src, vector vel)
|
|||
setsize(satch, [-4,-4,-4], [4,4,4]);
|
||||
setorigin(satch, src);
|
||||
}
|
||||
void s_pipebomb_detonate(entity master)
|
||||
|
||||
void
|
||||
s_pipebomb_detonate(entity master)
|
||||
{
|
||||
for (entity b = world; (b = find(b, ::classname, "satchel"));) {
|
||||
if (b.owner == master) {
|
||||
|
@ -126,7 +141,8 @@ void s_pipebomb_detonate(entity master)
|
|||
}
|
||||
#endif
|
||||
|
||||
void w_pipebomb_primary(void)
|
||||
void
|
||||
w_pipebomb_primary(void)
|
||||
{
|
||||
player pl = (player)self;
|
||||
|
||||
|
@ -178,7 +194,9 @@ void w_pipebomb_primary(void)
|
|||
pl.w_attack_next = 1.0f;
|
||||
pl.w_idle_next = 1.0f;
|
||||
}
|
||||
void w_pipebomb_secondary(void)
|
||||
|
||||
void
|
||||
w_pipebomb_secondary(void)
|
||||
{
|
||||
player pl = (player)self;
|
||||
|
||||
|
@ -216,26 +234,33 @@ void w_pipebomb_secondary(void)
|
|||
pl.w_attack_next = 1.0f;
|
||||
pl.w_idle_next = 2.5f;
|
||||
}
|
||||
void w_pipebomb_reload(void)
|
||||
|
||||
void
|
||||
w_pipebomb_reload(void)
|
||||
{
|
||||
|
||||
}
|
||||
void w_pipebomb_release(void)
|
||||
|
||||
void
|
||||
w_pipebomb_release(void)
|
||||
{
|
||||
w_satchel_release();
|
||||
}
|
||||
|
||||
float w_pipebomb_aimanim(void)
|
||||
float
|
||||
w_pipebomb_aimanim(void)
|
||||
{
|
||||
return w_satchel_aimanim();
|
||||
}
|
||||
|
||||
void w_pipebomb_hud(void)
|
||||
void
|
||||
w_pipebomb_hud(void)
|
||||
{
|
||||
w_satchel_holster();
|
||||
}
|
||||
|
||||
void w_pipebomb_hudpic(int selected, vector pos, float a)
|
||||
void
|
||||
w_pipebomb_hudpic(int selected, vector pos, float a)
|
||||
{
|
||||
#ifdef CLIENT
|
||||
if (selected) {
|
||||
|
@ -270,7 +295,9 @@ weapon_t w_pipebomb =
|
|||
};
|
||||
|
||||
#ifdef SERVER
|
||||
void weapon_pipebomb(void) {
|
||||
void
|
||||
weapon_pipebomb(void)
|
||||
{
|
||||
Weapons_InitItem(WEAPON_SATCHEL);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,8 @@ enum
|
|||
SHOTTY_RELOAD_END
|
||||
};
|
||||
|
||||
void w_shotgun_precache(void)
|
||||
void
|
||||
w_shotgun_precache(void)
|
||||
{
|
||||
precache_model("models/v_shotgun.mdl");
|
||||
precache_model("models/w_shotgun.mdl");
|
||||
|
@ -44,26 +45,35 @@ void w_shotgun_precache(void)
|
|||
precache_sound("weapons/reload3.wav");
|
||||
precache_sound("weapons/scock1.wav");
|
||||
}
|
||||
void w_shotgun_updateammo(player pl)
|
||||
|
||||
void
|
||||
w_shotgun_updateammo(player pl)
|
||||
{
|
||||
#ifdef SERVER
|
||||
Weapons_UpdateAmmo(pl, pl.shotgun_mag, pl.ammo_buckshot, __NULL__);
|
||||
#endif
|
||||
}
|
||||
string w_shotgun_wmodel(void)
|
||||
|
||||
string
|
||||
w_shotgun_wmodel(void)
|
||||
{
|
||||
return "models/w_shotgun.mdl";
|
||||
}
|
||||
string w_shotgun_pmodel(void)
|
||||
|
||||
string
|
||||
w_shotgun_pmodel(void)
|
||||
{
|
||||
return "models/p_shotgun.mdl";
|
||||
}
|
||||
string w_shotgun_deathmsg(void)
|
||||
|
||||
string
|
||||
w_shotgun_deathmsg(void)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
int w_shotgun_pickup(int new, int startammo)
|
||||
int
|
||||
w_shotgun_pickup(int new, int startammo)
|
||||
{
|
||||
#ifdef SERVER
|
||||
player pl = (player)self;
|
||||
|
@ -81,7 +91,8 @@ int w_shotgun_pickup(int new, int startammo)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void w_shotgun_draw(void)
|
||||
void
|
||||
w_shotgun_draw(void)
|
||||
{
|
||||
Weapons_SetModel("models/v_shotgun.mdl");
|
||||
Weapons_ViewAnimation(SHOTGUN_DRAW);
|
||||
|
@ -91,11 +102,14 @@ void w_shotgun_draw(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void w_shotgun_holster(void)
|
||||
void
|
||||
w_shotgun_holster(void)
|
||||
{
|
||||
Weapons_ViewAnimation(SHOTGUN_HOLSTER);
|
||||
}
|
||||
void w_shotgun_primary(void)
|
||||
|
||||
void
|
||||
w_shotgun_primary(void)
|
||||
{
|
||||
player pl = (player)self;
|
||||
if (pl.w_attack_next) {
|
||||
|
@ -137,7 +151,9 @@ void w_shotgun_primary(void)
|
|||
pl.w_attack_next = 1.1f;
|
||||
pl.w_idle_next = 2.5f;
|
||||
}
|
||||
void w_shotgun_reload(void)
|
||||
|
||||
void
|
||||
w_shotgun_reload(void)
|
||||
{
|
||||
player pl = (player)self;
|
||||
#ifdef CLIENT
|
||||
|
@ -162,7 +178,9 @@ void w_shotgun_reload(void)
|
|||
pl.a_ammo3 = SHOTTY_RELOAD_START;
|
||||
pl.w_idle_next = 0.0f;
|
||||
}
|
||||
void w_shotgun_release(void)
|
||||
|
||||
void
|
||||
w_shotgun_release(void)
|
||||
{
|
||||
player pl = (player)self;
|
||||
|
||||
|
@ -221,7 +239,9 @@ void w_shotgun_release(void)
|
|||
pl.w_attack_next = 0.5f;
|
||||
}
|
||||
}
|
||||
void w_shotgun_crosshair(void)
|
||||
|
||||
void
|
||||
w_shotgun_crosshair(void)
|
||||
{
|
||||
#ifdef CLIENT
|
||||
static vector cross_pos;
|
||||
|
@ -234,12 +254,14 @@ void w_shotgun_crosshair(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
float w_shotgun_aimanim(void)
|
||||
float
|
||||
w_shotgun_aimanim(void)
|
||||
{
|
||||
return self.flags & FL_CROUCHING ? ANIM_CR_AIMSHOTGUN : ANIM_AIMSHOTGUN;
|
||||
}
|
||||
|
||||
void w_shotgun_hudpic(int s, vector pos, float a)
|
||||
void
|
||||
w_shotgun_hudpic(int s, vector pos, float a)
|
||||
{
|
||||
#ifdef CLIENT
|
||||
if (s) {
|
||||
|
@ -274,7 +296,9 @@ weapon_t w_shotgun =
|
|||
};
|
||||
|
||||
#ifdef SERVER
|
||||
void weapon_shotgun(void) {
|
||||
void
|
||||
weapon_shotgun(void)
|
||||
{
|
||||
Weapons_InitItem(WEAPON_SHOTGUN);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue