Simplify prediction code with the help from upstream SDK changes.
This commit is contained in:
parent
7d5c9e3e28
commit
7670300133
9 changed files with 27 additions and 172 deletions
|
@ -20,7 +20,8 @@ class CBaseDecor:CBaseEntity
|
|||
virtual void(string, string) SpawnKey;
|
||||
};
|
||||
|
||||
void CBaseDecor::Initialized(void)
|
||||
void
|
||||
CBaseDecor::Initialized(void)
|
||||
{
|
||||
setmodel(this, model);
|
||||
setorigin(this, origin);
|
||||
|
@ -28,7 +29,8 @@ void CBaseDecor::Initialized(void)
|
|||
drawmask = MASK_ENGINE;
|
||||
}
|
||||
|
||||
void CBaseDecor::SpawnKey(string strField, string strKey)
|
||||
void
|
||||
CBaseDecor::SpawnKey(string strField, string strKey)
|
||||
{
|
||||
switch (strField) {
|
||||
case "body":
|
||||
|
|
|
@ -19,7 +19,8 @@ class monster_human_bandit:CBaseNPC
|
|||
void(void) monster_human_bandit;
|
||||
};
|
||||
|
||||
void monster_human_bandit::monster_human_bandit(void)
|
||||
void
|
||||
monster_human_bandit::monster_human_bandit(void)
|
||||
{
|
||||
model = "models/bandit.mdl";
|
||||
base_mins = [-16,-16,0];
|
||||
|
|
|
@ -19,7 +19,8 @@ class monster_human_chopper:CBaseNPC
|
|||
void(void) monster_human_chopper;
|
||||
};
|
||||
|
||||
void monster_human_chopper::monster_human_chopper(void)
|
||||
void
|
||||
monster_human_chopper::monster_human_chopper(void)
|
||||
{
|
||||
model = "models/chopper.mdl";
|
||||
base_mins = [-16,-16,0];
|
||||
|
|
|
@ -19,7 +19,8 @@ class monster_human_demoman:CBaseNPC
|
|||
void(void) monster_human_demoman;
|
||||
};
|
||||
|
||||
void monster_human_demoman::monster_human_demoman(void)
|
||||
void
|
||||
monster_human_demoman::monster_human_demoman(void)
|
||||
{
|
||||
model = "models/demolitionman.mdl";
|
||||
base_mins = [-16,-16,0];
|
||||
|
|
|
@ -19,7 +19,8 @@ class monster_human_gunman:CBaseNPC
|
|||
void(void) monster_human_gunman;
|
||||
};
|
||||
|
||||
void monster_human_gunman::monster_human_gunman(void)
|
||||
void
|
||||
monster_human_gunman::monster_human_gunman(void)
|
||||
{
|
||||
model = "models/gunmantrooper.mdl";
|
||||
base_mins = [-16,-16,0];
|
||||
|
|
|
@ -19,7 +19,8 @@ class monster_human_unarmed:CBaseNPC
|
|||
void(void) monster_human_unarmed;
|
||||
};
|
||||
|
||||
void monster_human_unarmed::monster_human_unarmed(void)
|
||||
void
|
||||
monster_human_unarmed::monster_human_unarmed(void)
|
||||
{
|
||||
model = "models/gunmantrooper.mdl";
|
||||
base_mins = [-16,-16,0];
|
||||
|
|
|
@ -19,7 +19,8 @@ class monster_trainingbot:CBaseNPC
|
|||
void(void) monster_trainingbot;
|
||||
};
|
||||
|
||||
void monster_trainingbot::monster_trainingbot(void)
|
||||
void
|
||||
monster_trainingbot::monster_trainingbot(void)
|
||||
{
|
||||
model = "models/gunmantrooper.mdl";
|
||||
base_mins = [-16,-16,0];
|
||||
|
|
|
@ -91,7 +91,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
|
||||
|
@ -108,61 +108,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) {
|
||||
|
@ -226,6 +174,8 @@ so we can roll them back later.
|
|||
void
|
||||
player::PredictPreFrame(void)
|
||||
{
|
||||
base_player::PredictPreFrame();
|
||||
|
||||
ammo_battery_net = ammo_battery; // beamgun
|
||||
ammo_chem_net = ammo_chem; // chemicalgun
|
||||
ammo_rocket_net = ammo_rocket; // dml / grenades
|
||||
|
@ -271,6 +221,8 @@ Where we roll back our values to the ones last sent/verified by the server.
|
|||
void
|
||||
player::PredictPostFrame(void)
|
||||
{
|
||||
base_player::PredictPostFrame();
|
||||
|
||||
ammo_battery = ammo_battery_net; // beamgun
|
||||
ammo_chem = ammo_chem_net; // chemicalgun
|
||||
ammo_rocket = ammo_rocket_net; // dml / grenades
|
||||
|
@ -309,61 +261,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)
|
||||
|
@ -431,22 +329,6 @@ player::EvaluateEntity(void)
|
|||
if (dml_state_net == dml_state)
|
||||
SendFlags |= PLAYER_AMMO3;
|
||||
|
||||
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;
|
||||
|
||||
ammo_battery_net = ammo_battery;
|
||||
ammo_chem_net = ammo_chem;
|
||||
ammo_rocket_net = ammo_rocket;
|
||||
|
@ -505,43 +387,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);
|
||||
|
|
|
@ -419,7 +419,8 @@ w_gausspistol_hudback(player pl)
|
|||
return FALSE;
|
||||
}
|
||||
#else
|
||||
void CSEv_w_gp_setmode_i(int f)
|
||||
void
|
||||
CSEv_w_gp_setmode_i(int f)
|
||||
{
|
||||
player pl = (player)self;
|
||||
pl.a_ammo3 = f;
|
||||
|
|
Loading…
Reference in a new issue