2020-12-21 16:56:44 -08:00
|
|
|
/*
|
2021-02-27 17:31:27 -08:00
|
|
|
* Copyright (c) 2016-2021 Marco Hladik <marco@icculus.org>
|
2020-12-21 16:56:44 -08:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2021-02-27 17:31:27 -08:00
|
|
|
/* all potential SendFlags bits we can possibly send */
|
|
|
|
enumflags
|
|
|
|
{
|
|
|
|
PLAYER_KEEPALIVE,
|
|
|
|
PLAYER_MODELINDEX,
|
|
|
|
PLAYER_ORIGIN,
|
|
|
|
PLAYER_ORIGIN_Z,
|
|
|
|
PLAYER_ANGLES_X,
|
|
|
|
PLAYER_ANGLES_Y,
|
2021-05-20 07:01:07 -07:00
|
|
|
PLAYER_COLORMAP,
|
2021-02-27 17:31:27 -08:00
|
|
|
PLAYER_VELOCITY,
|
|
|
|
PLAYER_VELOCITY_Z,
|
|
|
|
PLAYER_FLAGS,
|
|
|
|
PLAYER_WEAPON,
|
|
|
|
PLAYER_ITEMS,
|
|
|
|
PLAYER_HEALTH,
|
|
|
|
PLAYER_ARMOR,
|
|
|
|
PLAYER_MOVETYPE,
|
|
|
|
PLAYER_VIEWOFS,
|
|
|
|
PLAYER_UNUSED1,
|
2021-05-08 08:44:16 -07:00
|
|
|
PLAYER_UNUSED2,
|
|
|
|
PLAYER_UNUSED3,
|
|
|
|
PLAYER_UNUSED4,
|
|
|
|
PLAYER_UNUSED5,
|
|
|
|
PLAYER_UNUSED6,
|
|
|
|
PLAYER_UNUSED7
|
2021-02-27 17:31:27 -08:00
|
|
|
};
|
|
|
|
|
2020-12-21 16:56:44 -08:00
|
|
|
noref int input_sequence;
|
|
|
|
class player:base_player
|
|
|
|
{
|
|
|
|
#ifdef CLIENT
|
|
|
|
/* External model */
|
|
|
|
entity p_model;
|
|
|
|
int p_hand_bone;
|
|
|
|
int p_model_bone;
|
|
|
|
float lastweapon;
|
|
|
|
|
|
|
|
virtual void(void) draw;
|
|
|
|
virtual float() predraw;
|
|
|
|
virtual void(void) postdraw;
|
2021-05-08 08:44:16 -07:00
|
|
|
virtual void(float,float) ReceiveEntity;
|
2021-02-27 17:31:27 -08:00
|
|
|
virtual void(void) PredictPreFrame;
|
|
|
|
virtual void(void) PredictPostFrame;
|
2020-12-21 16:56:44 -08:00
|
|
|
#else
|
2021-02-27 17:31:27 -08:00
|
|
|
virtual void(void) EvaluateEntity;
|
|
|
|
virtual float(entity, float) SendEntity;
|
2020-12-21 16:56:44 -08:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2021-02-27 17:31:27 -08:00
|
|
|
#ifdef CLIENT
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
player::ReceiveEntity
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void
|
2021-05-08 08:44:16 -07:00
|
|
|
player::ReceiveEntity(float new, float fl)
|
2021-02-27 17:31:27 -08:00
|
|
|
{
|
2021-05-08 08:44:16 -07:00
|
|
|
base_player::ReceiveEntity(new, fl);
|
2021-02-27 17:31:27 -08:00
|
|
|
setorigin(this, origin);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
player::PredictPostFrame
|
|
|
|
|
|
|
|
Save the last valid server values away in the _net variants of each field
|
|
|
|
so we can roll them back later.
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
player::PredictPreFrame(void)
|
|
|
|
{
|
2021-05-08 08:44:16 -07:00
|
|
|
base_player::PredictPreFrame();
|
2021-02-27 17:31:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
player::PredictPostFrame
|
|
|
|
|
|
|
|
Where we roll back our values to the ones last sent/verified by the server.
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
player::PredictPostFrame(void)
|
|
|
|
{
|
2021-05-08 08:44:16 -07:00
|
|
|
base_player::PredictPostFrame();
|
2021-02-27 17:31:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
void
|
|
|
|
player::EvaluateEntity(void)
|
|
|
|
{
|
2021-05-08 08:44:16 -07:00
|
|
|
base_player::EvaluateEntity();
|
2021-02-27 17:31:27 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
player::SendEntity
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
float
|
|
|
|
player::SendEntity(entity ePEnt, float fChanged)
|
|
|
|
{
|
2021-05-08 08:44:16 -07:00
|
|
|
/* remove our entity to other clients if we're dead */
|
2021-02-27 17:31:27 -08:00
|
|
|
if (health <= 0 && ePEnt != this) {
|
2021-05-09 23:14:10 -07:00
|
|
|
return (0);
|
2021-02-27 17:31:27 -08:00
|
|
|
}
|
|
|
|
|
2021-05-08 08:44:16 -07:00
|
|
|
/* target client isn't real, they have no client-side. abandon */
|
2021-02-27 17:31:27 -08:00
|
|
|
if (clienttype(ePEnt) != CLIENTTYPE_REAL) {
|
2021-05-09 23:14:10 -07:00
|
|
|
return (0);
|
2021-02-27 17:31:27 -08:00
|
|
|
}
|
|
|
|
|
2021-05-08 08:44:16 -07:00
|
|
|
/* other players don't need to know about these attributes */
|
2021-02-27 17:31:27 -08:00
|
|
|
if (ePEnt != self) {
|
|
|
|
fChanged &= ~PLAYER_ITEMS;
|
|
|
|
fChanged &= ~PLAYER_HEALTH;
|
|
|
|
fChanged &= ~PLAYER_ARMOR;
|
|
|
|
fChanged &= ~PLAYER_VIEWOFS;
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteByte(MSG_ENTITY, ENT_PLAYER);
|
|
|
|
WriteFloat(MSG_ENTITY, fChanged);
|
|
|
|
|
2021-05-08 08:44:16 -07:00
|
|
|
/* the generic client attributes */
|
|
|
|
base_player::SendEntity(ePEnt, fChanged);
|
2021-05-09 23:14:10 -07:00
|
|
|
return (1);
|
2021-02-27 17:31:27 -08:00
|
|
|
}
|
|
|
|
#endif
|