Refactoring. Remove anti-invisible players, models will be checked by server

This commit is contained in:
a1batross 2016-08-07 22:49:24 +06:00
parent ee58844f3a
commit 3af732ebc1
9 changed files with 98 additions and 115 deletions

View File

@ -16,7 +16,7 @@ LOCAL_MODULE_FILENAME = libclient_hardfp
endif
LOCAL_CFLAGS += -fsigned-char -DCLIENT_DLL=1 -DCLIENT_WEAPONS=1
LOCAL_CPPFLAGS += -std=c++11
LOCAL_CPPFLAGS += -std=c++0x
SRCS := \
./cdll_int.cpp \
./demo.cpp \

View File

@ -50,12 +50,10 @@ Called when the DLL is first loaded.
*/
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
{
gEngfuncs = *pEnginefuncs;
if (iVersion != CLDLL_INTERFACE_VERSION)
return 0;
memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t));
gEngfuncs = *pEnginefuncs;
g_iXash = (int)CVAR_GET_FLOAT("build");

View File

@ -119,7 +119,8 @@ void EV_Fireglock18( event_args_t *args )
EV_EjectBrass(ShellOrigin, ShellVelocity, angles[ YAW ], g_iPShell, TE_BOUNCE_SHELL);
PLAY_EVENT_SOUND( (g_iWeaponFlags & WPNSTATE_GLOCK18_BURST_MODE) != 0 || g_bGlockBurstMode ? SOUNDS_NAME[0] : SOUNDS_NAME[1] );
PLAY_EVENT_SOUND( ((g_iWeaponFlags & WPNSTATE_GLOCK18_BURST_MODE) != 0 || g_bGlockBurstMode )
&& !g_bHoldingShield ? SOUNDS_NAME[0] : SOUNDS_NAME[1] );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );

View File

@ -59,6 +59,14 @@ int giDmgFlags[NUM_DMG_TYPES] =
DMG_HALLUC
};
enum
{
ATK_FRONT = 0,
ATK_RIGHT,
ATK_REAR,
ATK_LEFT
};
int CHudHealth::Init(void)
{
HOOK_MESSAGE(Health);
@ -102,32 +110,17 @@ int CHudHealth::VidInit(void)
{
m_hSprite = LoadSprite(PAIN_NAME);
m_vAttackPos[ATK_FRONT].x = ScreenWidth / 2 - SPR_Width( m_hSprite, 0 ) / 2;
m_vAttackPos[ATK_FRONT].y = ScreenHeight / 2 - SPR_Width( m_hSprite, 0 ) * 3;
for( int i = 0; i < 4; i++ )
{
m_vAttackPos[i].x = ScreenWidth / 2;
m_vAttackPos[i].y = ScreenHeight / 2;
m_vAttackPos[ATK_RIGHT].x = ScreenWidth / 2 + SPR_Width( m_hSprite, 1 ) * 2;
m_vAttackPos[ATK_RIGHT].y = ScreenHeight / 2 - SPR_Width( m_hSprite, 1 ) / 2;
if( i & 1 )
{
if( i & 2 )
m_vAttackPos[i].x -= SPR_Width( m_hSprite, i ) * 3;
else
m_vAttackPos[i].x += SPR_Width( m_hSprite, i ) * 2;
m_vAttackPos[ATK_REAR ].x = ScreenWidth / 2 - SPR_Width( m_hSprite, 2 ) / 2;
m_vAttackPos[ATK_REAR ].y = ScreenHeight / 2 + SPR_Width( m_hSprite, 2 ) * 2;
m_vAttackPos[i].y -= SPR_Height( m_hSprite, i ) / 2;
}
else
{
if( i & 2 )
m_vAttackPos[i].y += SPR_Height( m_hSprite, i ) * 2;
else
m_vAttackPos[i].y -= SPR_Height( m_hSprite, i ) * 3;
m_vAttackPos[i].x -= SPR_Width( m_hSprite, i ) / 2;
}
}
m_vAttackPos[ATK_LEFT ].x = ScreenWidth / 2 - SPR_Width( m_hSprite, 3 ) * 3;
m_vAttackPos[ATK_LEFT ].y = ScreenHeight / 2 - SPR_Width( m_hSprite, 3 ) / 2;
m_HUD_dmg_bio = gHUD.GetSpriteIndex( "dmg_bio" ) + 1;
@ -201,19 +194,47 @@ int CHudHealth:: MsgFunc_ScoreAttrib(const char *pszName, int iSize, void *pbuf
}
// Returns back a color from the
// Green <-> Yellow <-> Red ramp
void CHudHealth::GetPainColor( int &r, int &g, int &b )
void CHudHealth::GetPainColor( int &r, int &g, int &b, int &a )
{
#if 0
int iHealth = m_iHealth;
if (iHealth > 25)
iHealth -= 25;
else if ( iHealth < 0 )
iHealth = 0;
#if 0
g = iHealth * 255 / 100;
r = 255 - g;
b = 0;
#else
if( m_iHealth <= 15 )
{
a = 255; // If health is getting low, make it bright red
}
else
{
// Has health changed? Flash the health #
if (m_fFade)
{
m_fFade -= (gHUD.m_flTimeDelta * 20);
if (m_fFade <= 0)
{
m_fFade = 0;
a = MIN_ALPHA;
}
else
{
// Fade the health number back to dim
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
}
}
else
{
a = MIN_ALPHA;
}
}
if (m_iHealth > 25)
{
DrawUtils::UnpackRGB(r,g,b, RGB_YELLOWISH);
@ -246,27 +267,7 @@ void CHudHealth::DrawHealthBar( float flTime )
int a = 0, x, y;
int HealthWidth;
// Has health changed? Flash the health #
if (m_fFade)
{
m_fFade -= (gHUD.m_flTimeDelta * 20);
if (m_fFade <= 0)
{
a = MIN_ALPHA;
m_fFade = 0;
}
// Fade the health number back to dim
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
}
else
a = MIN_ALPHA;
// If health is getting low, make it bright red
if (m_iHealth <= 15)
a = 255;
GetPainColor( r, g, b );
GetPainColor( r, g, b, a );
DrawUtils::ScaleColors(r, g, b, a );
// Only draw health if we have the suit.
@ -317,11 +318,11 @@ void CHudHealth::CalcDamageDirection( Vector vecFrom )
if (side > EPSILON)
m_fAttack[0] = max(m_fAttack[0], side);
if (side < -EPSILON)
m_fAttack[1] = max(m_fAttack[1], side * -1 );
m_fAttack[1] = max(m_fAttack[1], -side );
if (front > EPSILON)
m_fAttack[2] = max(m_fAttack[2], front);
if (front < -EPSILON)
m_fAttack[3] = max(m_fAttack[3], front * -1 );
m_fAttack[3] = max(m_fAttack[3], -front );
}
}

View File

@ -30,9 +30,9 @@ extern void HUD_SetCmdBits( int bits );
int CHud::UpdateClientData(client_data_t *cdata, float time)
{
memcpy(m_vecOrigin, cdata->origin, sizeof(vec3_t));
memcpy(m_vecAngles, cdata->viewangles, sizeof(vec3_t));
m_vecOrigin = cdata->origin;
m_vecAngles = cdata->viewangles;
m_iKeyBits = CL_ButtonBits( 0 );
m_iWeaponBits = cdata->iWeaponBits;

View File

@ -95,10 +95,19 @@ inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int fl
extern float color[3]; // hud.cpp
// Gets the height & width of a sprite, at the specified frame
inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); }
inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); }
inline int SPR_Height( HSPRITE x, int f )
{
return gEngfuncs.pfnSPR_Height(x, f);
}
inline int SPR_Width( HSPRITE x, int f )
{
return gEngfuncs.pfnSPR_Width(x, f);
}
inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); }
inline client_textmessage_t *TextMessageGet( const char *pName )
{
return gEngfuncs.pfnTextMessageGet( pName );
}
inline void ConsolePrint( const char *string )
{

View File

@ -152,14 +152,14 @@ public:
return ret;
}
static inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)
static inline void UnpackRGB( int &r, int &g, int &b, const unsigned long ulRGB )
{
r = (ulRGB & 0xFF0000) >>16;
g = (ulRGB & 0xFF00) >> 8;
b = ulRGB & 0xFF;
}
static inline void ScaleColors( int &r, int &g, int &b, int a )
static inline void ScaleColors( int &r, int &g, int &b, const int a )
{
r *= a / 255.0f;
g *= a / 255.0f;

View File

@ -116,7 +116,7 @@ public:
int m_HUD_cross;
//float m_fAttackFront, m_fAttackRear, m_fAttackLeft, m_fAttackRight;
float m_fAttack[4];
void GetPainColor( int &r, int &g, int &b );
void GetPainColor(int &r, int &g, int &b , int &a);
float m_fFade;
private:
void DrawPain( float fTime );

View File

@ -477,13 +477,8 @@ void CGameStudioModelRenderer::CalculatePitchBlend(entity_state_t *pplayer)
void CGameStudioModelRenderer::CalculateYawBlend(entity_state_t *pplayer)
{
float dt;
float flYaw;
dt = (m_clTime - m_clOldTime);
dt = max(0.0, dt);
dt = min(1.0, dt);
StudioEstimateGait(pplayer);
flYaw = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw;
@ -511,10 +506,7 @@ void CGameStudioModelRenderer::CalculateYawBlend(entity_state_t *pplayer)
float blend_yaw = (flYaw / 90.0) * 128.0 + 127.0;
blend_yaw = min(255.0, blend_yaw);
blend_yaw = max(0.0, blend_yaw);
blend_yaw = 255.0 - blend_yaw;
blend_yaw = 255.0 - bound( 0.0, blend_yaw, 255.0 );
m_pCurrentEntity->curstate.blending[0] = (int)(blend_yaw);
m_pCurrentEntity->latched.prevblending[0] = m_pCurrentEntity->curstate.blending[0];
@ -531,21 +523,20 @@ void CGameStudioModelRenderer::CalculateYawBlend(entity_state_t *pplayer)
void CGameStudioModelRenderer::StudioProcessGait(entity_state_t *pplayer)
{
mstudioseqdesc_t *pseqdesc;
float dt;
CalculateYawBlend(pplayer);
CalculatePitchBlend(pplayer);
dt = (m_clTime - m_clOldTime);
dt = max(0.0, dt);
dt = min(1.0, dt);
pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + pplayer->gaitsequence;
if (pseqdesc->linearmovement[0] > 0)
m_pPlayerInfo->gaitframe += (m_flGaitMovement / pseqdesc->linearmovement[0]) * pseqdesc->numframes;
else
{
float dt = bound( 0.0, (m_clTime - m_clOldTime), 1.0 );
m_pPlayerInfo->gaitframe += pseqdesc->fps * dt * m_pCurrentEntity->curstate.framerate;
}
m_pPlayerInfo->gaitframe = m_pPlayerInfo->gaitframe - (int)(m_pPlayerInfo->gaitframe / pseqdesc->numframes) * pseqdesc->numframes;
@ -563,10 +554,10 @@ void CGameStudioModelRenderer::SavePlayerState(entity_state_t *pplayer)
st = &g_state;
VectorCopy(ent->curstate.angles, st->angles);
VectorCopy(ent->curstate.origin, st->origin);
st->angles = ent->curstate.angles;
st->origin = ent->curstate.origin;
VectorCopy(ent->angles, st->realangles);
st->realangles = ent->angles;
st->sequence = ent->curstate.sequence;
st->gaitsequence = pplayer->gaitsequence;
@ -672,8 +663,7 @@ void CGameStudioModelRenderer::SetupClientAnimation(entity_state_t *pplayer)
return;
curtime = gEngfuncs.GetClientTime();
dt = curtime - oldtime;
dt = min(1.0, max(0.0, dt));
dt = bound( 0.0, (curtime - oldtime), 1.0 );
oldtime = curtime;
st = &g_clientstate;
@ -701,9 +691,10 @@ void CGameStudioModelRenderer::SetupClientAnimation(entity_state_t *pplayer)
st->m_fSequenceLoops = ((GetSequenceFlags(pmodel, st) & STUDIO_LOOPING) != 0);
StudioFrameAdvance(st, fr, dt);
VectorCopy(st->realangles, ent->angles);
VectorCopy(st->angles, ent->curstate.angles);
VectorCopy(st->origin, ent->curstate.origin);
ent->angles = st->realangles;
ent->curstate.angles = st->angles;
ent->curstate.origin = st->origin;
ent->curstate.sequence = st->sequence;
pplayer->gaitsequence = st->gaitsequence;
@ -727,9 +718,10 @@ void CGameStudioModelRenderer::RestorePlayerState(entity_state_t *pplayer)
st = &g_clientstate;
VectorCopy(ent->curstate.angles, st->angles);
VectorCopy(ent->curstate.origin, st->origin);
VectorCopy(ent->angles, st->realangles);
st->angles = ent->curstate.angles;
st->origin = ent->curstate.origin;
st->realangles = ent->angles;
st->sequence = ent->curstate.sequence;
st->gaitsequence = pplayer->gaitsequence;
@ -744,9 +736,10 @@ void CGameStudioModelRenderer::RestorePlayerState(entity_state_t *pplayer)
st = &g_state;
VectorCopy(st->angles, ent->curstate.angles);
VectorCopy(st->origin, ent->curstate.origin);
VectorCopy(st->realangles, ent->angles);
ent->angles = st->realangles;
ent->curstate.angles = st->angles;
ent->curstate.origin = st->origin;
ent->curstate.sequence = st->sequence;
pplayer->gaitsequence = st->gaitsequence;
@ -785,7 +778,7 @@ int CGameStudioModelRenderer::StudioDrawPlayer(int flags, entity_state_t *pplaye
for( int i = 0; i < m_nCachedBones; i++ )
{
if( !stricmp(m_nCachedBoneNames[i], "Bip01 Spine3") )
if( !strcmp(m_nCachedBoneNames[i], "Bip01 Spine3") )
{
chestpos.x = m_rgCachedBoneTransform[i][0][3];
chestpos.y = m_rgCachedBoneTransform[i][1][3];
@ -833,7 +826,7 @@ int CGameStudioModelRenderer::_StudioDrawPlayer(int flags, entity_state_t *pplay
extra_player_info_t *pExtra = g_PlayerExtraInfo + pplayer->number;
if( gHUD.cl_minmodels && gHUD.cl_minmodels->value > 0.0f )
if( gHUD.cl_minmodels && gHUD.cl_minmodels->value )
{
int team = pExtra->teamnumber;
if( team == TEAM_TERRORIST )
@ -859,20 +852,6 @@ int CGameStudioModelRenderer::_StudioDrawPlayer(int flags, entity_state_t *pplay
else
{
m_pRenderModel = IEngineStudio.SetupPlayerModel( m_nPlayerIndex );
if( !m_pRenderModel ) // player have a unloadable shit in userinfo, so load appropriate to his team model
{
if( pExtra->teamnumber == TEAM_CT && pExtra->vip )
m_pRenderModel = gEngfuncs.CL_LoadModel( sPlayerModelFiles[3], NULL ); // vip
else if( pExtra->teamnumber == TEAM_CT )
m_pRenderModel = gEngfuncs.CL_LoadModel( sPlayerModelFiles[2], NULL ); // gign
else if( pExtra->teamnumber == TEAM_TERRORIST )
m_pRenderModel = gEngfuncs.CL_LoadModel( sPlayerModelFiles[1], NULL ); // leet
else
m_pRenderModel = gEngfuncs.CL_LoadModel( sPlayerModelFiles[0], NULL ); // player.mdl
// if we cannot load gign or leet model, player have a shit inside his gamedata, so we can't deal with it
}
}
if( !m_pRenderModel )
@ -898,18 +877,16 @@ int CGameStudioModelRenderer::_StudioDrawPlayer(int flags, entity_state_t *pplay
if (pplayer->gaitsequence)
{
vec3_t orig_angles;
vec3_t orig_angles(m_pCurrentEntity->angles);
m_pPlayerInfo = IEngineStudio.PlayerInfo(m_nPlayerIndex);
VectorCopy(m_pCurrentEntity->angles, orig_angles);
StudioProcessGait(pplayer);
m_pPlayerInfo->gaitsequence = pplayer->gaitsequence;
m_pPlayerInfo = NULL;
StudioSetUpTransform(0);
VectorCopy(orig_angles, m_pCurrentEntity->angles);
m_pCurrentEntity->angles = orig_angles;
}
else
{
@ -1040,15 +1017,12 @@ void CGameStudioModelRenderer::StudioFxTransform(cl_entity_t *ent, float transfo
if (axis == 1)
axis = 2;
VectorScale( transform[axis], gEngfuncs.pfnRandomFloat(1,1.484), transform[axis] );
VectorScale( transform[axis], gEngfuncs.pfnRandomFloat( 1, 1.484 ), transform[axis] );
}
else if (Com_RandomLong(0, 49) == 0)
{
float offset;
int axis = Com_RandomLong(0, 1);
if (axis == 1)
axis = 2;
offset = gEngfuncs.pfnRandomFloat(-10, 10);
transform[Com_RandomLong(0, 2)][3] += offset;
@ -1123,7 +1097,7 @@ int DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interfac
*ppinterface = &studio;
// Copy in engine helper functions
memcpy( &IEngineStudio, pstudio, sizeof( IEngineStudio ) );
IEngineStudio = *pstudio;
// Initialize local variables, etc.
R_StudioInit();