115 lines
2.5 KiB
Plaintext
115 lines
2.5 KiB
Plaintext
/*
|
|
* Copyright (c) 2016-2022 Vera Visions LLC.
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
/* all potential SendFlags bits we can possibly send */
|
|
enumflags
|
|
{
|
|
PLAYER_AMMO1 = PLAYER_CUSTOMFIELDSTART,
|
|
PLAYER_AMMO2,
|
|
PLAYER_AMMO3,
|
|
PLAYER_UNUSED5,
|
|
PLAYER_UNUSED6,
|
|
PLAYER_UNUSED7,
|
|
PLAYER_UNUSED7,
|
|
PLAYER_UNUSED8
|
|
};
|
|
|
|
class player:NSClientPlayer
|
|
{
|
|
PREDICTED_INT(mode_tempstate)
|
|
|
|
#ifdef CLIENT
|
|
virtual void(float,float) ReceiveEntity;
|
|
virtual void(void) PredictPreFrame;
|
|
virtual void(void) PredictPostFrame;
|
|
#else
|
|
virtual void(void) EvaluateEntity;
|
|
virtual float(entity, float) SendEntity;
|
|
#endif
|
|
};
|
|
|
|
#ifdef CLIENT
|
|
/*
|
|
=================
|
|
player::ReceiveEntity
|
|
=================
|
|
*/
|
|
void
|
|
player::ReceiveEntity(float new, float fl)
|
|
{
|
|
NSClientPlayer::ReceiveEntity(new, fl);
|
|
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)
|
|
{
|
|
NSClientPlayer::PredictPreFrame();
|
|
}
|
|
|
|
/*
|
|
=================
|
|
player::PredictPostFrame
|
|
|
|
Where we roll back our values to the ones last sent/verified by the server.
|
|
=================
|
|
*/
|
|
void
|
|
player::PredictPostFrame(void)
|
|
{
|
|
NSClientPlayer::PredictPostFrame();
|
|
}
|
|
|
|
#else
|
|
void
|
|
player::EvaluateEntity(void)
|
|
{
|
|
NSClientPlayer::EvaluateEntity();
|
|
}
|
|
|
|
/*
|
|
=================
|
|
player::SendEntity
|
|
=================
|
|
*/
|
|
float
|
|
player::SendEntity(entity ePEnt, float fChanged)
|
|
{
|
|
/* don't broadcast invisible players */
|
|
if (IsFakeSpectator() && ePEnt != this)
|
|
return (0);
|
|
if (!GetModelindex() && ePEnt != this)
|
|
return (0);
|
|
|
|
fChanged = OptimiseChangedFlags(ePEnt, fChanged);
|
|
|
|
WriteByte(MSG_ENTITY, ENT_PLAYER);
|
|
WriteFloat(MSG_ENTITY, fChanged);
|
|
|
|
/* the generic client attributes */
|
|
NSClientPlayer::SendEntity(ePEnt, fChanged);
|
|
return (1);
|
|
}
|
|
#endif
|