Skip to content

Commit

Permalink
Cleanup of client_weapons preprocessor
Browse files Browse the repository at this point in the history
-removed code referenced to client weapons because no longer needed.
~adjustments to downsample code, and restoring original water frustrum for release.
-removed warnings for missing commandmenu, textscheme and bitmap font.
  • Loading branch information
Magic-Nipples committed Aug 11, 2020
1 parent e655423 commit fa87f92
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 240 deletions.
6 changes: 3 additions & 3 deletions src/cl_dll/vgui_SchemeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ CSchemeManager::CSchemeManager( int xRes, int yRes )

if ( !pFile )
{
gEngfuncs.Con_DPrintf( "Unable to find *_textscheme.txt\n");
//gEngfuncs.Con_DPrintf( "Unable to find *_textscheme.txt\n"); //magic nipples - no missing textscheme warning
goto buildDefaultFont;
}

Expand Down Expand Up @@ -397,8 +397,8 @@ CSchemeManager::CSchemeManager( int xRes, int yRes )
{
sprintf(fontFilename, "gfx\\vgui\\fonts\\%d_%s.tga", m_xRes, m_pSchemeList[i].schemeName);
pFontData = gEngfuncs.COM_LoadFile( fontFilename, 5, &fontFileLength );
if(!pFontData)
gEngfuncs.Con_Printf("Missing bitmap font: %s\n", fontFilename);
//if(!pFontData)
//gEngfuncs.Con_Printf("Missing bitmap font: %s\n", fontFilename); //magic nipples - no more bitmap font warning
}

m_pSchemeList[i].font = new vgui::Font(
Expand Down
2 changes: 1 addition & 1 deletion src/cl_dll/vgui_TeamFortressViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ int TeamFortressViewport::CreateCommandMenu( char * menuFile, int direction, int
char *pfile = (char*)gEngfuncs.COM_LoadFile( menuFile, 5, NULL);
if (!pfile)
{
gEngfuncs.Con_DPrintf( "Unable to open %s\n", menuFile);
//gEngfuncs.Con_DPrintf( "Unable to open %s\n", menuFile); //magic nipples - disabled warning for missing command menu
SetCurrentCommandMenu( NULL );
return newIndex;
}
Expand Down
109 changes: 0 additions & 109 deletions src/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,67 +1492,7 @@ void RegisterEncoders( void )

int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
{
#if defined( CLIENT_WEAPONS )
int i;
weapon_data_t *item;
entvars_t *pev = &player->v;
CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev );
CBasePlayerWeapon *gun;

ItemInfo II;

memset( info, 0, 32 * sizeof( weapon_data_t ) );

if ( !pl )
return 1;

// go through all of the weapons and make a list of the ones to pack
for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ )
{
if ( pl->m_rgpPlayerItems[ i ] )
{
// there's a weapon here. Should I pack it?
CBasePlayerItem *pPlayerItem = pl->m_rgpPlayerItems[ i ];

while ( pPlayerItem )
{
gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr();
if ( gun && gun->UseDecrement() )
{
// Get The ID.
memset( &II, 0, sizeof( II ) );
gun->GetItemInfo( &II );

if ( II.iId >= 0 && II.iId < 32 )
{
item = &info[ II.iId ];

item->m_iId = II.iId;
item->m_iClip = gun->m_iClip;

item->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle, -0.001 );
item->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack, -0.001 );
item->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack, -0.001 );
item->m_fInReload = gun->m_fInReload;
item->m_fInSpecialReload = gun->m_fInSpecialReload;
item->fuser1 = max( gun->pev->fuser1, -0.001 );
item->fuser2 = gun->m_flStartThrow;
item->fuser3 = gun->m_flReleaseThrow;
item->iuser1 = gun->m_chargeReady;
item->iuser2 = gun->m_fInAttack;
item->iuser3 = gun->m_fireState;


// item->m_flPumpTime = max( gun->m_flPumpTime, -0.001 );
}
}
pPlayerItem = pPlayerItem->m_pNext;
}
}
}
#else
memset( info, 0, 32 * sizeof( weapon_data_t ) );
#endif
return 1;
}

Expand Down Expand Up @@ -1594,55 +1534,6 @@ void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clien
cd->weaponanim = ent->v.weaponanim;

cd->pushmsec = ent->v.pushmsec;

#if defined( CLIENT_WEAPONS )
if ( sendweapons )
{
entvars_t *pev = (entvars_t *)&ent->v;
CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev );

if ( pl )
{
cd->m_flNextAttack = pl->m_flNextAttack;
cd->fuser2 = pl->m_flNextAmmoBurn;
cd->fuser3 = pl->m_flAmmoStartCharge;
cd->vuser1.x = pl->ammo_9mm;
cd->vuser1.y = pl->ammo_357;
cd->vuser1.z = pl->ammo_argrens;
cd->ammo_nails = pl->ammo_bolts;
cd->ammo_shells = pl->ammo_buckshot;
cd->ammo_rockets = pl->ammo_rockets;
cd->ammo_cells = pl->ammo_uranium;
cd->vuser2.x = pl->ammo_hornets;


if ( pl->m_pActiveItem )
{
CBasePlayerWeapon *gun;
gun = (CBasePlayerWeapon *)pl->m_pActiveItem->GetWeaponPtr();
if ( gun && gun->UseDecrement() )
{
ItemInfo II;
memset( &II, 0, sizeof( II ) );
gun->GetItemInfo( &II );

cd->m_iId = II.iId;

cd->vuser3.z = gun->m_iSecondaryAmmoType;
cd->vuser4.x = gun->m_iPrimaryAmmoType;
cd->vuser4.y = pl->m_rgAmmo[gun->m_iPrimaryAmmoType];
cd->vuser4.z = pl->m_rgAmmo[gun->m_iSecondaryAmmoType];

if ( pl->m_pActiveItem->m_iId == WEAPON_RPG )
{
cd->vuser2.y = ( ( CRpg * )pl->m_pActiveItem)->m_fSpotActive;
cd->vuser2.z = ( ( CRpg * )pl->m_pActiveItem)->m_cActiveRockets;
}
}
}
}
}
#endif
}

/*
Expand Down
85 changes: 0 additions & 85 deletions src/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2571,73 +2571,7 @@ void CBasePlayer::PostThink()
m_afButtonLast = pev->button;

pt_end:
#if defined( CLIENT_WEAPONS )
// Decay timers on weapons
// go through all of the weapons and make a list of the ones to pack
for ( int i = 0 ; i < MAX_ITEM_TYPES ; i++ )
{
if ( m_rgpPlayerItems[ i ] )
{
CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[ i ];

while ( pPlayerItem )
{
CBasePlayerWeapon *gun;

gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr();

if ( gun && gun->UseDecrement() )
{
gun->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 );
gun->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 );

if ( gun->m_flTimeWeaponIdle != 1000 )
{
gun->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 );
}

if ( gun->pev->fuser1 != 1000 )
{
gun->pev->fuser1 = max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 );
}

// Only decrement if not flagged as NO_DECREMENT
// if ( gun->m_flPumpTime != 1000 )
// {
// gun->m_flPumpTime = max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 );
// }

}

pPlayerItem = pPlayerItem->m_pNext;
}
}
}

m_flNextAttack -= gpGlobals->frametime;
if ( m_flNextAttack < -0.001 )
m_flNextAttack = -0.001;

if ( m_flNextAmmoBurn != 1000 )
{
m_flNextAmmoBurn -= gpGlobals->frametime;

if ( m_flNextAmmoBurn < -0.001 )
m_flNextAmmoBurn = -0.001;
}

if ( m_flAmmoStartCharge != 1000 )
{
m_flAmmoStartCharge -= gpGlobals->frametime;

if ( m_flAmmoStartCharge < -0.001 )
m_flAmmoStartCharge = -0.001;
}


#else
return;
#endif
}


Expand Down Expand Up @@ -2971,13 +2905,6 @@ int CBasePlayer::Restore( CRestore &restore )

RenewItems();

#if defined( CLIENT_WEAPONS )
// HACK: This variable is saved/restored in CBaseMonster as a time variable, but we're using it
// as just a counter. Ideally, this needs its own variable that's saved as a plain float.
// Barring that, we clear it out here instead of using the incorrect restored time value.
m_flNextAttack = UTIL_WeaponTimeBase();
#endif

return status;
}

Expand Down Expand Up @@ -3751,14 +3678,8 @@ Called every frame by the player PreThink
*/
void CBasePlayer::ItemPreFrame()
{
#if defined( CLIENT_WEAPONS )
if ( m_flNextAttack > 0 )
#else
if ( gpGlobals->time < m_flNextAttack )
#endif
{
return;
}

if (!m_pActiveItem)
return;
Expand All @@ -3782,14 +3703,8 @@ void CBasePlayer::ItemPostFrame()
if ( m_pTank != NULL )
return;

#if defined( CLIENT_WEAPONS )
if ( m_flNextAttack > 0 )
#else
if ( gpGlobals->time < m_flNextAttack )
#endif
{
return;
}

ImpulseCommands();

Expand Down
19 changes: 0 additions & 19 deletions src/dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,9 @@ IMPLEMENT_SAVERESTORE( CBasePlayerItem, CBaseAnimating );

TYPEDESCRIPTION CBasePlayerWeapon::m_SaveData[] =
{
#if defined( CLIENT_WEAPONS )
DEFINE_FIELD( CBasePlayerWeapon, m_flNextPrimaryAttack, FIELD_FLOAT ),
DEFINE_FIELD( CBasePlayerWeapon, m_flNextSecondaryAttack, FIELD_FLOAT ),
DEFINE_FIELD( CBasePlayerWeapon, m_flTimeWeaponIdle, FIELD_FLOAT ),
#else // CLIENT_WEAPONS
DEFINE_FIELD( CBasePlayerWeapon, m_flNextPrimaryAttack, FIELD_TIME ),
DEFINE_FIELD( CBasePlayerWeapon, m_flNextSecondaryAttack, FIELD_TIME ),
DEFINE_FIELD( CBasePlayerWeapon, m_flTimeWeaponIdle, FIELD_TIME ),
#endif // CLIENT_WEAPONS
DEFINE_FIELD( CBasePlayerWeapon, m_iPrimaryAmmoType, FIELD_INTEGER ),
DEFINE_FIELD( CBasePlayerWeapon, m_iSecondaryAmmoType, FIELD_INTEGER ),
DEFINE_FIELD( CBasePlayerWeapon, m_iClip, FIELD_INTEGER ),
Expand Down Expand Up @@ -626,18 +620,10 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther )

BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted )
{
#if defined( CLIENT_WEAPONS )
if ( !isPredicted )
#else
if ( 1 )
#endif
{
return ( attack_time <= curtime ) ? TRUE : FALSE;
}
else
{
return ( attack_time <= 0.0 ) ? TRUE : FALSE;
}
}

void CBasePlayerWeapon::ItemPostFrame( void )
Expand Down Expand Up @@ -868,11 +854,6 @@ void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body )

m_pPlayer->pev->weaponanim = iAnim;

#if defined( CLIENT_WEAPONS )
if ( skiplocal && ENGINE_CANSKIP( m_pPlayer->edict() ) )
return;
#endif

MESSAGE_BEGIN( MSG_ONE, SVC_WEAPONANIM, NULL, m_pPlayer->pev );
WRITE_BYTE( iAnim ); // sequence number
WRITE_BYTE( pev->body ); // weaponmodel bodygroup.
Expand Down
27 changes: 9 additions & 18 deletions src/engine/client/gl_downsample.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ static void R_Bloom_InitEffectTexture(void)
if (r_downsample->value > 5.0f)
r_downsample->value = 5.0f;

if (cl.local.waterlevel >= 3)
/*if (cl.local.waterlevel >= 3)
{
DOWNSAMPLE_SIZE_X = screen_texture_width / (2.5);
DOWNSAMPLE_SIZE_Y = screen_texture_width / (2.5);
}
else
else*/
{
DOWNSAMPLE_SIZE_X = screen_texture_width / (r_downsample->value * 2);
DOWNSAMPLE_SIZE_Y = screen_texture_width / (r_downsample->value * 2);
DOWNSAMPLE_SIZE_Y = screen_texture_height / (r_downsample->value * 2);
}

r_sampleeffecttexture = GL_CreateTexture("*sampleeffecttexture", DOWNSAMPLE_SIZE_X, DOWNSAMPLE_SIZE_Y, NULL, TF_NEAREST);
Expand All @@ -84,17 +84,8 @@ R_Sampling_InitTextures
*/
static void R_Sampling_InitTextures(void)
{
if (GL_Support(GL_ARB_TEXTURE_NPOT_EXT))
{
screen_texture_width = glState.width;
screen_texture_height = glState.height;
}
else
{
// find closer power of 2 to screen size
for (screen_texture_width = 1; screen_texture_width < glState.width; screen_texture_width <<= 1);
for (screen_texture_height = 1; screen_texture_height < glState.height; screen_texture_height <<= 1);
}
screen_texture_width = glState.width;
screen_texture_height = glState.height;

// disable blooms if we can't handle a texture of that size
if (screen_texture_width > glConfig.max_2d_texture_size || screen_texture_height > glConfig.max_2d_texture_size)
Expand Down Expand Up @@ -139,7 +130,8 @@ void R_InitDownSampleTextures(void)
r_initsampletexture = r_sampleeffecttexture = 0;
r_samplebackuptexture = r_downsampletexture = 0;

if ((!r_downsample->value) && (cl.local.waterlevel < 3))
//if ((!r_downsample->value) && (cl.local.waterlevel < 3))
if (!r_downsample->value)
return;

R_Sampling_InitTextures();
Expand Down Expand Up @@ -252,7 +244,8 @@ R_DownSampling
*/
void R_DownSampling(void)
{
if ( (!r_downsample->value) && (cl.local.waterlevel < 3))
//if ( (!r_downsample->value) && (cl.local.waterlevel < 3))
if (!r_downsample->value)
return;

if (!DOWNSAMPLE_SIZE_X && !DOWNSAMPLE_SIZE_Y)
Expand All @@ -261,8 +254,6 @@ void R_DownSampling(void)
if (screen_texture_width < DOWNSAMPLE_SIZE_X || screen_texture_height < DOWNSAMPLE_SIZE_Y)
return;

//if ( cl.local.waterlevel <= 3 )

// set up full screen workspace
pglScissor(0, 0, glState.width, glState.height);
pglViewport(0, 0, glState.width, glState.height);
Expand Down
7 changes: 2 additions & 5 deletions src/engine/client/gl_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,8 @@ void R_SetupFrustum( void )

if( RP_NORMALPASS() && ( cl.local.waterlevel >= 3 )) //magic nipples - underwater view stretching
{
//RI.fov_x = atan(tan(DEG2RAD(RI.fov_x) / 2) * (0.97 + sin(cl.time * 4.5) * 0.23)) * 2 / (M_PI / 180.0); // :)
//RI.fov_y = atan(tan(DEG2RAD(RI.fov_y) / 2) * (1.03 - sin(cl.time * 5.5) * 0.23)) * 2 / (M_PI / 180.0); // :)

//RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97 + sin( cl.time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
//RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03 - sin( cl.time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97 + sin( cl.time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03 - sin( cl.time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
}

// build the transformation matrix for the given view angles
Expand Down

0 comments on commit fa87f92

Please sign in to comment.