From 9e7debbb349346c363ef383ffc6139811d638d28 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 3 Jul 2016 18:39:55 +0500 Subject: [PATCH] Client format. --- cl_dll/ammo.cpp | 625 +++++++++--------- cl_dll/ammo.h | 5 +- cl_dll/ammo_secondary.cpp | 64 +- cl_dll/ammohistory.cpp | 95 ++- cl_dll/ammohistory.h | 20 +- cl_dll/battery.cpp | 65 +- cl_dll/camera.h | 7 +- cl_dll/cdll_int.cpp | 34 +- cl_dll/cl_dll.h | 2 +- cl_dll/cl_util.h | 105 ++- cl_dll/com_weapons.cpp | 48 +- cl_dll/com_weapons.h | 10 +- cl_dll/death.cpp | 113 ++-- cl_dll/demo.cpp | 53 +- cl_dll/demo.h | 3 +- cl_dll/entity.cpp | 313 +++++---- cl_dll/ev_common.cpp | 29 +- cl_dll/ev_hldm.cpp | 638 +++++++++--------- cl_dll/ev_hldm.h | 15 +- cl_dll/eventscripts.h | 4 +- cl_dll/flashlight.cpp | 81 ++- cl_dll/geiger.cpp | 75 ++- cl_dll/health.cpp | 283 ++++---- cl_dll/health.h | 29 +- cl_dll/hl/hl_baseentity.cpp | 338 +++++----- cl_dll/hl/hl_events.cpp | 41 +- cl_dll/hl/hl_objects.cpp | 23 +- cl_dll/hl/hl_weapons.cpp | 525 ++++++++------- cl_dll/hud.cpp | 192 +++--- cl_dll/hud.h | 169 +++-- cl_dll/hud_iface.h | 3 +- cl_dll/hud_msg.cpp | 39 +- cl_dll/hud_redraw.cpp | 186 +++--- cl_dll/hud_servers.cpp | 315 +++++---- cl_dll/hud_servers.h | 7 +- cl_dll/hud_servers_priv.h | 49 +- cl_dll/hud_spectator.cpp | 1216 +++++++++++++++++------------------ cl_dll/hud_spectator.h | 78 ++- cl_dll/hud_update.cpp | 12 +- cl_dll/in_camera.cpp | 453 +++++++------ cl_dll/in_defs.h | 4 +- cl_dll/input.cpp | 682 ++++++++++++-------- cl_dll/input_xash3d.cpp | 77 +-- cl_dll/inputw32.cpp | 492 +++++++------- cl_dll/kbutton.h | 7 +- cl_dll/menu.cpp | 61 +- cl_dll/message.cpp | 181 +++--- cl_dll/overview.cpp | 84 ++- cl_dll/overview.h | 5 +- cl_dll/parsemsg.cpp | 92 ++- cl_dll/saytext.cpp | 116 ++-- cl_dll/scoreboard.cpp | 216 +++---- cl_dll/soundsystem.cpp | 19 +- cl_dll/status_icons.cpp | 34 +- cl_dll/statusbar.cpp | 76 +-- cl_dll/studio_util.cpp | 117 ++-- cl_dll/studio_util.h | 15 +- cl_dll/text_message.cpp | 45 +- cl_dll/tf_defs.h | 74 +-- cl_dll/train.cpp | 33 +- cl_dll/tri.cpp | 12 +- cl_dll/util.cpp | 78 ++- cl_dll/util_vector.h | 87 +-- cl_dll/view.cpp | 1019 ++++++++++++++--------------- cl_dll/view.h | 3 +- 65 files changed, 4946 insertions(+), 5045 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index d55a9f5e..988bd6fa 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -38,49 +38,48 @@ WeaponsResource gWR; int g_weaponselect = 0; -void WeaponsResource :: LoadAllWeaponSprites( void ) +void WeaponsResource::LoadAllWeaponSprites( void ) { - for (int i = 0; i < MAX_WEAPONS; i++) + for( int i = 0; i < MAX_WEAPONS; i++ ) { - if ( rgWeapons[i].iId ) + if( rgWeapons[i].iId ) LoadWeaponSprites( &rgWeapons[i] ); } } -int WeaponsResource :: CountAmmo( int iId ) +int WeaponsResource::CountAmmo( int iId ) { - if ( iId < 0 ) + if( iId < 0 ) return 0; return riAmmo[iId]; } -int WeaponsResource :: HasAmmo( WEAPON *p ) +int WeaponsResource::HasAmmo( WEAPON *p ) { - if ( !p ) + if( !p ) return FALSE; // weapons with no max ammo can always be selected - if ( p->iMax1 == -1 ) + if( p->iMax1 == -1 ) return TRUE; - return (p->iAmmoType == -1) || p->iClip > 0 || CountAmmo(p->iAmmoType) - || CountAmmo(p->iAmmo2Type) || ( p->iFlags & WEAPON_FLAGS_SELECTONEMPTY ); + return ( p->iAmmoType == -1 ) || p->iClip > 0 || CountAmmo( p->iAmmoType ) + || CountAmmo( p->iAmmo2Type ) || ( p->iFlags & WEAPON_FLAGS_SELECTONEMPTY ); } - -void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon ) +void WeaponsResource::LoadWeaponSprites( WEAPON *pWeapon ) { int i, iRes; - if (ScreenWidth < 640) + if( ScreenWidth < 640 ) iRes = 320; else iRes = 640; char sz[128]; - if ( !pWeapon ) + if( !pWeapon ) return; memset( &pWeapon->rcActive, 0, sizeof(wrect_t) ); @@ -92,39 +91,39 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon ) pWeapon->hAmmo = 0; pWeapon->hAmmo2 = 0; - sprintf(sz, "sprites/%s.txt", pWeapon->szName); - client_sprite_t *pList = SPR_GetList(sz, &i); + sprintf( sz, "sprites/%s.txt", pWeapon->szName ); + client_sprite_t *pList = SPR_GetList( sz, &i ); - if (!pList) + if( !pList ) return; client_sprite_t *p; - + p = GetSpriteList( pList, "crosshair", iRes, i ); - if (p) + if( p ) { - sprintf(sz, "sprites/%s.spr", p->szSprite); - pWeapon->hCrosshair = SPR_Load(sz); + sprintf( sz, "sprites/%s.spr", p->szSprite ); + pWeapon->hCrosshair = SPR_Load( sz ); pWeapon->rcCrosshair = p->rc; } else pWeapon->hCrosshair = 0; - p = GetSpriteList(pList, "autoaim", iRes, i); - if (p) + p = GetSpriteList( pList, "autoaim", iRes, i ); + if( p ) { - sprintf(sz, "sprites/%s.spr", p->szSprite); - pWeapon->hAutoaim = SPR_Load(sz); + sprintf( sz, "sprites/%s.spr", p->szSprite ); + pWeapon->hAutoaim = SPR_Load( sz ); pWeapon->rcAutoaim = p->rc; } else pWeapon->hAutoaim = 0; p = GetSpriteList( pList, "zoom", iRes, i ); - if (p) + if( p ) { - sprintf(sz, "sprites/%s.spr", p->szSprite); - pWeapon->hZoomedCrosshair = SPR_Load(sz); + sprintf( sz, "sprites/%s.spr", p->szSprite ); + pWeapon->hZoomedCrosshair = SPR_Load( sz ); pWeapon->rcZoomedCrosshair = p->rc; } else @@ -133,11 +132,11 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon ) pWeapon->rcZoomedCrosshair = pWeapon->rcCrosshair; } - p = GetSpriteList(pList, "zoom_autoaim", iRes, i); - if (p) + p = GetSpriteList( pList, "zoom_autoaim", iRes, i ); + if( p ) { - sprintf(sz, "sprites/%s.spr", p->szSprite); - pWeapon->hZoomedAutoaim = SPR_Load(sz); + sprintf( sz, "sprites/%s.spr", p->szSprite ); + pWeapon->hZoomedAutoaim = SPR_Load( sz ); pWeapon->rcZoomedAutoaim = p->rc; } else @@ -146,11 +145,11 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon ) pWeapon->rcZoomedAutoaim = pWeapon->rcZoomedCrosshair; } - p = GetSpriteList(pList, "weapon", iRes, i); - if (p) + p = GetSpriteList( pList, "weapon", iRes, i ); + if( p ) { - sprintf(sz, "sprites/%s.spr", p->szSprite); - pWeapon->hInactive = SPR_Load(sz); + sprintf( sz, "sprites/%s.spr", p->szSprite ); + pWeapon->hInactive = SPR_Load( sz ); pWeapon->rcInactive = p->rc; gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); @@ -158,21 +157,21 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon ) else pWeapon->hInactive = 0; - p = GetSpriteList(pList, "weapon_s", iRes, i); - if (p) + p = GetSpriteList( pList, "weapon_s", iRes, i ); + if( p ) { - sprintf(sz, "sprites/%s.spr", p->szSprite); - pWeapon->hActive = SPR_Load(sz); + sprintf( sz, "sprites/%s.spr", p->szSprite ); + pWeapon->hActive = SPR_Load( sz ); pWeapon->rcActive = p->rc; } else pWeapon->hActive = 0; - p = GetSpriteList(pList, "ammo", iRes, i); - if (p) + p = GetSpriteList( pList, "ammo", iRes, i ); + if( p ) { - sprintf(sz, "sprites/%s.spr", p->szSprite); - pWeapon->hAmmo = SPR_Load(sz); + sprintf( sz, "sprites/%s.spr", p->szSprite ); + pWeapon->hAmmo = SPR_Load( sz ); pWeapon->rcAmmo = p->rc; gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); @@ -180,26 +179,25 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon ) else pWeapon->hAmmo = 0; - p = GetSpriteList(pList, "ammo2", iRes, i); - if (p) + p = GetSpriteList( pList, "ammo2", iRes, i ); + if( p ) { - sprintf(sz, "sprites/%s.spr", p->szSprite); - pWeapon->hAmmo2 = SPR_Load(sz); + sprintf( sz, "sprites/%s.spr", p->szSprite ); + pWeapon->hAmmo2 = SPR_Load( sz ); pWeapon->rcAmmo2 = p->rc; gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); } else pWeapon->hAmmo2 = 0; - } // Returns the first weapon for a given slot. -WEAPON *WeaponsResource :: GetFirstPos( int iSlot ) +WEAPON *WeaponsResource::GetFirstPos( int iSlot ) { WEAPON *pret = NULL; - for (int i = 0; i < MAX_WEAPON_POSITIONS; i++) + for( int i = 0; i < MAX_WEAPON_POSITIONS; i++ ) { if ( rgSlots[iSlot][i] && HasAmmo( rgSlots[iSlot][i] ) ) { @@ -211,46 +209,44 @@ WEAPON *WeaponsResource :: GetFirstPos( int iSlot ) return pret; } - -WEAPON* WeaponsResource :: GetNextActivePos( int iSlot, int iSlotPos ) +WEAPON* WeaponsResource::GetNextActivePos( int iSlot, int iSlotPos ) { if ( iSlotPos >= MAX_WEAPON_POSITIONS || iSlot >= MAX_WEAPON_SLOTS ) return NULL; - WEAPON *p = gWR.rgSlots[ iSlot ][ iSlotPos+1 ]; + WEAPON *p = gWR.rgSlots[iSlot][iSlotPos + 1]; - if ( !p || !gWR.HasAmmo(p) ) + if ( !p || !gWR.HasAmmo( p ) ) return GetNextActivePos( iSlot, iSlotPos + 1 ); return p; } - int giBucketHeight, giBucketWidth, giABHeight, giABWidth; // Ammo Bar width and height HSPRITE ghsprBuckets; // Sprite for top row of weapons menu -DECLARE_MESSAGE(m_Ammo, CurWeapon ) // Current weapon and clip -DECLARE_MESSAGE(m_Ammo, WeaponList) // new weapon type -DECLARE_MESSAGE(m_Ammo, AmmoX) // update known ammo type's count -DECLARE_MESSAGE(m_Ammo, AmmoPickup) // flashes an ammo pickup record -DECLARE_MESSAGE(m_Ammo, WeapPickup) // flashes a weapon pickup record -DECLARE_MESSAGE(m_Ammo, HideWeapon) // hides the weapon, ammo, and crosshair displays temporarily -DECLARE_MESSAGE(m_Ammo, ItemPickup) +DECLARE_MESSAGE( m_Ammo, CurWeapon ) // Current weapon and clip +DECLARE_MESSAGE( m_Ammo, WeaponList ) // new weapon type +DECLARE_MESSAGE( m_Ammo, AmmoX ) // update known ammo type's count +DECLARE_MESSAGE( m_Ammo, AmmoPickup ) // flashes an ammo pickup record +DECLARE_MESSAGE( m_Ammo, WeapPickup ) // flashes a weapon pickup record +DECLARE_MESSAGE( m_Ammo, HideWeapon ) // hides the weapon, ammo, and crosshair displays temporarily +DECLARE_MESSAGE( m_Ammo, ItemPickup ) -DECLARE_COMMAND(m_Ammo, Slot1) -DECLARE_COMMAND(m_Ammo, Slot2) -DECLARE_COMMAND(m_Ammo, Slot3) -DECLARE_COMMAND(m_Ammo, Slot4) -DECLARE_COMMAND(m_Ammo, Slot5) -DECLARE_COMMAND(m_Ammo, Slot6) -DECLARE_COMMAND(m_Ammo, Slot7) -DECLARE_COMMAND(m_Ammo, Slot8) -DECLARE_COMMAND(m_Ammo, Slot9) -DECLARE_COMMAND(m_Ammo, Slot10) -DECLARE_COMMAND(m_Ammo, Close) -DECLARE_COMMAND(m_Ammo, NextWeapon) -DECLARE_COMMAND(m_Ammo, PrevWeapon) +DECLARE_COMMAND( m_Ammo, Slot1 ) +DECLARE_COMMAND( m_Ammo, Slot2 ) +DECLARE_COMMAND( m_Ammo, Slot3 ) +DECLARE_COMMAND( m_Ammo, Slot4 ) +DECLARE_COMMAND( m_Ammo, Slot5 ) +DECLARE_COMMAND( m_Ammo, Slot6 ) +DECLARE_COMMAND( m_Ammo, Slot7 ) +DECLARE_COMMAND( m_Ammo, Slot8 ) +DECLARE_COMMAND( m_Ammo, Slot9 ) +DECLARE_COMMAND( m_Ammo, Slot10 ) +DECLARE_COMMAND( m_Ammo, Close ) +DECLARE_COMMAND( m_Ammo, NextWeapon ) +DECLARE_COMMAND( m_Ammo, PrevWeapon ) // width of ammo fonts #define AMMO_SMALL_WIDTH 10 @@ -258,31 +254,31 @@ DECLARE_COMMAND(m_Ammo, PrevWeapon) #define HISTORY_DRAW_TIME "5" -int CHudAmmo::Init(void) +int CHudAmmo::Init( void ) { - gHUD.AddHudElem(this); + gHUD.AddHudElem( this ); - HOOK_MESSAGE(CurWeapon); - HOOK_MESSAGE(WeaponList); - HOOK_MESSAGE(AmmoPickup); - HOOK_MESSAGE(WeapPickup); - HOOK_MESSAGE(ItemPickup); - HOOK_MESSAGE(HideWeapon); - HOOK_MESSAGE(AmmoX); + HOOK_MESSAGE( CurWeapon ); + HOOK_MESSAGE( WeaponList ); + HOOK_MESSAGE( AmmoPickup ); + HOOK_MESSAGE( WeapPickup ); + HOOK_MESSAGE( ItemPickup ); + HOOK_MESSAGE( HideWeapon ); + HOOK_MESSAGE( AmmoX ); - HOOK_COMMAND("slot1", Slot1); - HOOK_COMMAND("slot2", Slot2); - HOOK_COMMAND("slot3", Slot3); - HOOK_COMMAND("slot4", Slot4); - HOOK_COMMAND("slot5", Slot5); - HOOK_COMMAND("slot6", Slot6); - HOOK_COMMAND("slot7", Slot7); - HOOK_COMMAND("slot8", Slot8); - HOOK_COMMAND("slot9", Slot9); - HOOK_COMMAND("slot10", Slot10); - HOOK_COMMAND("cancelselect", Close); - HOOK_COMMAND("invnext", NextWeapon); - HOOK_COMMAND("invprev", PrevWeapon); + HOOK_COMMAND( "slot1", Slot1 ); + HOOK_COMMAND( "slot2", Slot2 ); + HOOK_COMMAND( "slot3", Slot3 ); + HOOK_COMMAND( "slot4", Slot4 ); + HOOK_COMMAND( "slot5", Slot5 ); + HOOK_COMMAND( "slot6", Slot6 ); + HOOK_COMMAND( "slot7", Slot7 ); + HOOK_COMMAND( "slot8", Slot8 ); + HOOK_COMMAND( "slot9", Slot9 ); + HOOK_COMMAND( "slot10", Slot10 ); + HOOK_COMMAND( "cancelselect", Close ); + HOOK_COMMAND( "invnext", NextWeapon ); + HOOK_COMMAND( "invprev", PrevWeapon ); Reset(); @@ -297,7 +293,7 @@ int CHudAmmo::Init(void) return 1; } -void CHudAmmo::Reset(void) +void CHudAmmo::Reset( void ) { m_fFade = 0; m_iFlags |= HUD_ACTIVE; //!!! @@ -308,26 +304,25 @@ void CHudAmmo::Reset(void) gWR.Reset(); gHR.Reset(); - // VidInit(); - + //VidInit(); } -int CHudAmmo::VidInit(void) +int CHudAmmo::VidInit( void ) { // Load sprites for buckets (top row of weapon menu) m_HUD_bucket0 = gHUD.GetSpriteIndex( "bucket1" ); m_HUD_selection = gHUD.GetSpriteIndex( "selection" ); - ghsprBuckets = gHUD.GetSprite(m_HUD_bucket0); - giBucketWidth = gHUD.GetSpriteRect(m_HUD_bucket0).right - gHUD.GetSpriteRect(m_HUD_bucket0).left; - giBucketHeight = gHUD.GetSpriteRect(m_HUD_bucket0).bottom - gHUD.GetSpriteRect(m_HUD_bucket0).top; + ghsprBuckets = gHUD.GetSprite( m_HUD_bucket0 ); + giBucketWidth = gHUD.GetSpriteRect( m_HUD_bucket0 ).right - gHUD.GetSpriteRect( m_HUD_bucket0 ).left; + giBucketHeight = gHUD.GetSpriteRect( m_HUD_bucket0 ).bottom - gHUD.GetSpriteRect( m_HUD_bucket0 ).top; - gHR.iHistoryGap = max( gHR.iHistoryGap, gHUD.GetSpriteRect(m_HUD_bucket0).bottom - gHUD.GetSpriteRect(m_HUD_bucket0).top); + gHR.iHistoryGap = max( gHR.iHistoryGap, gHUD.GetSpriteRect( m_HUD_bucket0 ).bottom - gHUD.GetSpriteRect( m_HUD_bucket0 ).top ); // If we've already loaded weapons, let's get new sprites gWR.LoadAllWeaponSprites(); - if (ScreenWidth >= 640) + if( ScreenWidth >= 640 ) { giABWidth = 20; giABHeight = 4; @@ -345,22 +340,22 @@ int CHudAmmo::VidInit(void) // Think: // Used for selection of weapon menu item. // -void CHudAmmo::Think(void) +void CHudAmmo::Think( void ) { - if ( gHUD.m_fPlayerDead ) + if( gHUD.m_fPlayerDead ) return; - if ( gHUD.m_iWeaponBits != gWR.iOldWeaponBits ) + if( gHUD.m_iWeaponBits != gWR.iOldWeaponBits ) { gWR.iOldWeaponBits = gHUD.m_iWeaponBits; - for (int i = MAX_WEAPONS-1; i > 0; i-- ) + for( int i = MAX_WEAPONS-1; i > 0; i-- ) { - WEAPON *p = gWR.GetWeapon(i); + WEAPON *p = gWR.GetWeapon( i ); - if ( p ) + if( p ) { - if ( gHUD.m_iWeaponBits & ( 1 << p->iId ) ) + if( gHUD.m_iWeaponBits & ( 1 << p->iId ) ) gWR.PickupWeapon( p ); else gWR.DropWeapon( p ); @@ -368,15 +363,15 @@ void CHudAmmo::Think(void) } } - if (!gpActiveSel) + if( !gpActiveSel ) return; // has the player selected one? - if (gHUD.m_iKeyBits & IN_ATTACK) + if( gHUD.m_iKeyBits & IN_ATTACK ) { - if (gpActiveSel != (WEAPON *)1) + if( gpActiveSel != (WEAPON *) 1 ) { - ServerCmd(gpActiveSel->szName); + ServerCmd( gpActiveSel->szName ); g_weaponselect = gpActiveSel->iId; } @@ -384,7 +379,7 @@ void CHudAmmo::Think(void) gpActiveSel = NULL; gHUD.m_iKeyBits &= ~IN_ATTACK; - PlaySound("common/wpn_select.wav", 1); + PlaySound( "common/wpn_select.wav", 1 ); } } @@ -392,17 +387,16 @@ void CHudAmmo::Think(void) // // Helper function to return a Ammo pointer from id // - -HSPRITE* WeaponsResource :: GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect ) +HSPRITE* WeaponsResource::GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect ) { - for ( int i = 0; i < MAX_WEAPONS; i++ ) + for( int i = 0; i < MAX_WEAPONS; i++ ) { - if ( rgWeapons[i].iAmmoType == iAmmoId ) + if( rgWeapons[i].iAmmoType == iAmmoId ) { rect = rgWeapons[i].rcAmmo; return &rgWeapons[i].hAmmo; } - else if ( rgWeapons[i].iAmmo2Type == iAmmoId ) + else if( rgWeapons[i].iAmmo2Type == iAmmoId ) { rect = rgWeapons[i].rcAmmo2; return &rgWeapons[i].hAmmo2; @@ -412,33 +406,32 @@ HSPRITE* WeaponsResource :: GetAmmoPicFromWeapon( int iAmmoId, wrect_t& rect ) return NULL; } - // Menu Selection Code - -void WeaponsResource :: SelectSlot( int iSlot, int fAdvance, int iDirection ) +void WeaponsResource::SelectSlot( int iSlot, int fAdvance, int iDirection ) { - if ( gHUD.m_Menu.m_fMenuDisplayed && (fAdvance == FALSE) && (iDirection == 1) ) - { // menu is overriding slot use commands + if( gHUD.m_Menu.m_fMenuDisplayed && ( fAdvance == FALSE ) && ( iDirection == 1 ) ) + { + // menu is overriding slot use commands gHUD.m_Menu.SelectMenuItem( iSlot + 1 ); // slots are one off the key numbers return; } - if ( iSlot > MAX_WEAPON_SLOTS ) + if( iSlot > MAX_WEAPON_SLOTS ) return; - if ( gHUD.m_fPlayerDead || gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) + if( gHUD.m_fPlayerDead || gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) return; - if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) )) + if ( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) return; - if ( ! ( gHUD.m_iWeaponBits & ~(1<<(WEAPON_SUIT)) )) + if( ! ( gHUD.m_iWeaponBits & ~( 1 << ( WEAPON_SUIT ) ) ) ) return; WEAPON *p = NULL; bool fastSwitch = CVAR_GET_FLOAT( "hud_fastswitch" ) != 0; - if ( (gpActiveSel == NULL) || (gpActiveSel == (WEAPON *)1) || (iSlot != gpActiveSel->iSlot) ) + if ( ( gpActiveSel == NULL ) || ( gpActiveSel == (WEAPON *) 1 ) || ( iSlot != gpActiveSel->iSlot ) ) { PlaySound( "common/wpn_hudon.wav", 1 ); p = GetFirstPos( iSlot ); @@ -449,7 +442,8 @@ void WeaponsResource :: SelectSlot( int iSlot, int fAdvance, int iDirection ) // but only if there is only one item in the bucket WEAPON *p2 = GetNextActivePos( p->iSlot, p->iSlotPos ); if ( !p2 ) - { // only one active item in bucket, so change directly to weapon + { + // only one active item in bucket, so change directly to weapon ServerCmd( p->szName ); g_weaponselect = p->iId; return; @@ -458,7 +452,7 @@ void WeaponsResource :: SelectSlot( int iSlot, int fAdvance, int iDirection ) } else { - PlaySound("common/wpn_moveselect.wav", 1); + PlaySound( "common/wpn_moveselect.wav", 1 ); if ( gpActiveSel ) p = GetNextActivePos( gpActiveSel->iSlot, gpActiveSel->iSlotPos ); if ( !p ) @@ -485,14 +479,14 @@ void WeaponsResource :: SelectSlot( int iSlot, int fAdvance, int iDirection ) // // AmmoX -- Update the count of a known type of ammo // -int CHudAmmo::MsgFunc_AmmoX(const char *pszName, int iSize, void *pbuf) +int CHudAmmo::MsgFunc_AmmoX( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); int iIndex = READ_BYTE(); int iCount = READ_BYTE(); - gWR.SetAmmo( iIndex, abs(iCount) ); + gWR.SetAmmo( iIndex, abs( iCount ) ); return 1; } @@ -504,7 +498,7 @@ int CHudAmmo::MsgFunc_AmmoPickup( const char *pszName, int iSize, void *pbuf ) int iCount = READ_BYTE(); // Add ammo to the history - gHR.AddToHistory( HISTSLOT_AMMO, iIndex, abs(iCount) ); + gHR.AddToHistory( HISTSLOT_AMMO, iIndex, abs( iCount ) ); return 1; } @@ -531,17 +525,16 @@ int CHudAmmo::MsgFunc_ItemPickup( const char *pszName, int iSize, void *pbuf ) return 1; } - int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); gHUD.m_iHideHUDDisplay = READ_BYTE(); - if (gEngfuncs.IsSpectateOnly()) + if( gEngfuncs.IsSpectateOnly() ) return 1; - if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) + if( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) { static wrect_t nullrc; gpActiveSel = NULL; @@ -561,7 +554,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) // counts are updated with AmmoX. Server assures that the Weapon ammo type // numbers match a real ammo type. // -int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf ) +int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) { static wrect_t nullrc; int fOnTarget = FALSE; @@ -573,21 +566,21 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf ) int iClip = READ_CHAR(); // detect if we're also on target - if ( iState > 1 ) + if( iState > 1 ) { fOnTarget = TRUE; } - if ( iId < 1 ) + if( iId < 1 ) { - SetCrosshair(0, nullrc, 0, 0, 0); + SetCrosshair( 0, nullrc, 0, 0, 0 ); return 0; } - if ( g_iUser1 != OBS_IN_EYE ) + if( g_iUser1 != OBS_IN_EYE ) { // Is player dead??? - if ((iId == -1) && (iClip == -1)) + if( ( iId == -1 ) && ( iClip == -1 ) ) { gHUD.m_fPlayerDead = TRUE; gpActiveSel = NULL; @@ -598,33 +591,34 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf ) WEAPON *pWeapon = gWR.GetWeapon( iId ); - if ( !pWeapon ) + if( !pWeapon ) return 0; - if ( iClip < -1 ) - pWeapon->iClip = abs(iClip); + if( iClip < -1 ) + pWeapon->iClip = abs( iClip ); else pWeapon->iClip = iClip; - - if ( iState == 0 ) // we're not the current weapon, so update no more + if( iState == 0 ) // we're not the current weapon, so update no more return 1; m_pWeapon = pWeapon; - if ( gHUD.m_iFOV >= 90 ) - { // normal crosshairs - if (fOnTarget && m_pWeapon->hAutoaim) - SetCrosshair(m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255); + if( gHUD.m_iFOV >= 90 ) + { + // normal crosshairs + if( fOnTarget && m_pWeapon->hAutoaim ) + SetCrosshair( m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255 ); else - SetCrosshair(m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255); + SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 ); } else - { // zoomed crosshairs - if (fOnTarget && m_pWeapon->hZoomedAutoaim) - SetCrosshair(m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255); + { + // zoomed crosshairs + if( fOnTarget && m_pWeapon->hZoomedAutoaim ) + SetCrosshair( m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255 ); else - SetCrosshair(m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255); + SetCrosshair( m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255 ); } @@ -637,7 +631,7 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf ) // // WeaponList -- Tells the hud about a new weapon type. // -int CHudAmmo::MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf ) +int CHudAmmo::MsgFunc_WeaponList( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); @@ -647,12 +641,12 @@ int CHudAmmo::MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf ) Weapon.iAmmoType = (int)READ_CHAR(); Weapon.iMax1 = READ_BYTE(); - if (Weapon.iMax1 == 255) + if( Weapon.iMax1 == 255 ) Weapon.iMax1 = -1; Weapon.iAmmo2Type = READ_CHAR(); Weapon.iMax2 = READ_BYTE(); - if (Weapon.iMax2 == 255) + if( Weapon.iMax2 == 255 ) Weapon.iMax2 = -1; Weapon.iSlot = READ_CHAR(); @@ -664,7 +658,6 @@ int CHudAmmo::MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf ) gWR.AddWeapon( &Weapon ); return 1; - } //------------------------------------------------------------------------ @@ -674,82 +667,82 @@ int CHudAmmo::MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf ) void CHudAmmo::SlotInput( int iSlot ) { // Let the Viewport use it first, for menus -// if ( gViewPort && gViewPort->SlotInput( iSlot ) ) +// if( gViewPort && gViewPort->SlotInput( iSlot ) ) // return; gWR.SelectSlot(iSlot, FALSE, 1); } -void CHudAmmo::UserCmd_Slot1(void) +void CHudAmmo::UserCmd_Slot1( void ) { SlotInput( 0 ); } -void CHudAmmo::UserCmd_Slot2(void) +void CHudAmmo::UserCmd_Slot2( void ) { SlotInput( 1 ); } -void CHudAmmo::UserCmd_Slot3(void) +void CHudAmmo::UserCmd_Slot3( void ) { SlotInput( 2 ); } -void CHudAmmo::UserCmd_Slot4(void) +void CHudAmmo::UserCmd_Slot4( void ) { SlotInput( 3 ); } -void CHudAmmo::UserCmd_Slot5(void) +void CHudAmmo::UserCmd_Slot5( void ) { SlotInput( 4 ); } -void CHudAmmo::UserCmd_Slot6(void) +void CHudAmmo::UserCmd_Slot6( void ) { SlotInput( 5 ); } -void CHudAmmo::UserCmd_Slot7(void) +void CHudAmmo::UserCmd_Slot7( void ) { SlotInput( 6 ); } -void CHudAmmo::UserCmd_Slot8(void) +void CHudAmmo::UserCmd_Slot8( void ) { SlotInput( 7 ); } -void CHudAmmo::UserCmd_Slot9(void) +void CHudAmmo::UserCmd_Slot9( void ) { SlotInput( 8 ); } -void CHudAmmo::UserCmd_Slot10(void) +void CHudAmmo::UserCmd_Slot10( void ) { SlotInput( 9 ); } -void CHudAmmo::UserCmd_Close(void) +void CHudAmmo::UserCmd_Close( void ) { - if (gpActiveSel) + if( gpActiveSel ) { gpLastSel = gpActiveSel; gpActiveSel = NULL; - PlaySound("common/wpn_hudoff.wav", 1); + PlaySound( "common/wpn_hudoff.wav", 1 ); } else - ClientCmd("escape"); + ClientCmd( "escape" ); } // Selects the next item in the weapon menu -void CHudAmmo::UserCmd_NextWeapon(void) +void CHudAmmo::UserCmd_NextWeapon( void ) { - if ( gHUD.m_fPlayerDead || (gHUD.m_iHideHUDDisplay & (HIDEHUD_WEAPONS | HIDEHUD_ALL)) ) + if( gHUD.m_fPlayerDead || ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) ) return; - if ( !gpActiveSel || gpActiveSel == (WEAPON*)1 ) + if( !gpActiveSel || gpActiveSel == (WEAPON*)1 ) gpActiveSel = m_pWeapon; int pos = 0; @@ -760,15 +753,15 @@ void CHudAmmo::UserCmd_NextWeapon(void) slot = gpActiveSel->iSlot; } - for ( int loop = 0; loop <= 1; loop++ ) + for( int loop = 0; loop <= 1; loop++ ) { - for ( ; slot < MAX_WEAPON_SLOTS; slot++ ) + for( ; slot < MAX_WEAPON_SLOTS; slot++ ) { - for ( ; pos < MAX_WEAPON_POSITIONS; pos++ ) + for( ; pos < MAX_WEAPON_POSITIONS; pos++ ) { WEAPON *wsp = gWR.GetWeaponSlot( slot, pos ); - if ( wsp && gWR.HasAmmo(wsp) ) + if( wsp && gWR.HasAmmo( wsp ) ) { gpActiveSel = wsp; return; @@ -785,109 +778,104 @@ void CHudAmmo::UserCmd_NextWeapon(void) } // Selects the previous item in the menu -void CHudAmmo::UserCmd_PrevWeapon(void) +void CHudAmmo::UserCmd_PrevWeapon( void ) { - if ( gHUD.m_fPlayerDead || (gHUD.m_iHideHUDDisplay & (HIDEHUD_WEAPONS | HIDEHUD_ALL)) ) + if( gHUD.m_fPlayerDead || ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) ) return; - if ( !gpActiveSel || gpActiveSel == (WEAPON*)1 ) + if( !gpActiveSel || gpActiveSel == (WEAPON*) 1 ) gpActiveSel = m_pWeapon; - int pos = MAX_WEAPON_POSITIONS-1; - int slot = MAX_WEAPON_SLOTS-1; - if ( gpActiveSel ) + int pos = MAX_WEAPON_POSITIONS - 1; + int slot = MAX_WEAPON_SLOTS - 1; + if( gpActiveSel ) { pos = gpActiveSel->iSlotPos - 1; slot = gpActiveSel->iSlot; } - for ( int loop = 0; loop <= 1; loop++ ) + for( int loop = 0; loop <= 1; loop++ ) { - for ( ; slot >= 0; slot-- ) + for( ; slot >= 0; slot-- ) { - for ( ; pos >= 0; pos-- ) + for( ; pos >= 0; pos-- ) { WEAPON *wsp = gWR.GetWeaponSlot( slot, pos ); - if ( wsp && gWR.HasAmmo(wsp) ) + if( wsp && gWR.HasAmmo( wsp ) ) { gpActiveSel = wsp; return; } } - pos = MAX_WEAPON_POSITIONS-1; + pos = MAX_WEAPON_POSITIONS - 1; } - slot = MAX_WEAPON_SLOTS-1; + slot = MAX_WEAPON_SLOTS - 1; } gpActiveSel = NULL; } - - //------------------------------------------------------------------------- // Drawing code //------------------------------------------------------------------------- - -int CHudAmmo::Draw(float flTime) +int CHudAmmo::Draw( float flTime ) { int a, x, y, r, g, b; int AmmoWidth; - if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) )) + if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) return 1; - if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) ) + if( ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) ) return 1; // Draw Weapon Menu - DrawWList(flTime); + DrawWList( flTime ); // Draw ammo pickup history gHR.DrawAmmoHistory( flTime ); - if (!(m_iFlags & HUD_ACTIVE)) + if( !( m_iFlags & HUD_ACTIVE ) ) return 0; - if (!m_pWeapon) + if( !m_pWeapon ) return 0; WEAPON *pw = m_pWeapon; // shorthand // SPR_Draw Ammo - if ((pw->iAmmoType < 0) && (pw->iAmmo2Type < 0)) + if( ( pw->iAmmoType < 0 ) && ( pw->iAmmo2Type < 0 ) ) return 0; - int iFlags = DHN_DRAWZERO; // draw 0 values - AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left; + AmmoWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; - a = (int) max( MIN_ALPHA, m_fFade ); + a = (int)max( MIN_ALPHA, m_fFade ); - if (m_fFade > 0) - m_fFade -= (gHUD.m_flTimeDelta * 20); + if( m_fFade > 0 ) + m_fFade -= ( gHUD.m_flTimeDelta * 20 ); - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB( r, g, b, RGB_YELLOWISH ); - ScaleColors(r, g, b, a ); + ScaleColors( r, g, b, a ); // Does this weapon have a clip? - y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight/2; + y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; // Does weapon have any ammo at all? - if (m_pWeapon->iAmmoType > 0) + if( m_pWeapon->iAmmoType > 0 ) { int iIconWidth = m_pWeapon->rcAmmo.right - m_pWeapon->rcAmmo.left; - - if (pw->iClip >= 0) + + if( pw->iClip >= 0 ) { // room for the number and the '|' and the current ammo - - x = ScreenWidth - (8 * AmmoWidth) - iIconWidth; - x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b); + x = ScreenWidth - ( 8 * AmmoWidth ) - iIconWidth; + x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b ); wrect_t rc; rc.top = 0; @@ -895,174 +883,163 @@ int CHudAmmo::Draw(float flTime) rc.right = AmmoWidth; rc.bottom = 100; - int iBarWidth = AmmoWidth/10; + int iBarWidth = AmmoWidth / 10; - x += AmmoWidth/2; + x += AmmoWidth / 2; - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB( r,g,b, RGB_YELLOWISH ); // draw the | bar - FillRGBA(x, y, iBarWidth, gHUD.m_iFontHeight, r, g, b, a); + FillRGBA( x, y, iBarWidth, gHUD.m_iFontHeight, r, g, b, a ); - x += iBarWidth + AmmoWidth/2;; + x += iBarWidth + AmmoWidth / 2; // GL Seems to need this - ScaleColors(r, g, b, a ); - x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b); - - + ScaleColors( r, g, b, a ); + x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmoType ), r, g, b ); } else { // SPR_Draw a bullets only line x = ScreenWidth - 4 * AmmoWidth - iIconWidth; - x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b); + x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmoType ), r, g, b ); } // Draw the ammo Icon - int iOffset = (m_pWeapon->rcAmmo.bottom - m_pWeapon->rcAmmo.top)/8; - SPR_Set(m_pWeapon->hAmmo, r, g, b); - SPR_DrawAdditive(0, x, y - iOffset, &m_pWeapon->rcAmmo); + int iOffset = ( m_pWeapon->rcAmmo.bottom - m_pWeapon->rcAmmo.top ) / 8; + SPR_Set( m_pWeapon->hAmmo, r, g, b ); + SPR_DrawAdditive( 0, x, y - iOffset, &m_pWeapon->rcAmmo ); } // Does weapon have seconday ammo? - if (pw->iAmmo2Type > 0) + if( pw->iAmmo2Type > 0 ) { int iIconWidth = m_pWeapon->rcAmmo2.right - m_pWeapon->rcAmmo2.left; // Do we have secondary ammo? - if ((pw->iAmmo2Type != 0) && (gWR.CountAmmo(pw->iAmmo2Type) > 0)) + if( ( pw->iAmmo2Type != 0 ) && ( gWR.CountAmmo( pw->iAmmo2Type ) > 0 ) ) { - y -= gHUD.m_iFontHeight + gHUD.m_iFontHeight/4; + y -= gHUD.m_iFontHeight + gHUD.m_iFontHeight / 4; x = ScreenWidth - 4 * AmmoWidth - iIconWidth; - x = gHUD.DrawHudNumber(x, y, iFlags|DHN_3DIGITS, gWR.CountAmmo(pw->iAmmo2Type), r, g, b); + x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmo2Type ), r, g, b ); // Draw the ammo Icon - SPR_Set(m_pWeapon->hAmmo2, r, g, b); - int iOffset = (m_pWeapon->rcAmmo2.bottom - m_pWeapon->rcAmmo2.top)/8; - SPR_DrawAdditive(0, x, y - iOffset, &m_pWeapon->rcAmmo2); + SPR_Set( m_pWeapon->hAmmo2, r, g, b ); + int iOffset = ( m_pWeapon->rcAmmo2.bottom - m_pWeapon->rcAmmo2.top) / 8; + SPR_DrawAdditive(0, x, y - iOffset, &m_pWeapon->rcAmmo2 ); } } return 1; } - // // Draws the ammo bar on the hud // -int DrawBar(int x, int y, int width, int height, float f) +int DrawBar( int x, int y, int width, int height, float f ) { int r, g, b; - if (f < 0) + if( f < 0 ) f = 0; - if (f > 1) + if( f > 1 ) f = 1; - if (f) + if( f ) { int w = f * width; // Always show at least one pixel if we have ammo. - if (w <= 0) + if( w <= 0 ) w = 1; - UnpackRGB(r, g, b, RGB_GREENISH); - FillRGBA(x, y, w, height, r, g, b, 255); + UnpackRGB( r, g, b, RGB_GREENISH ); + FillRGBA( x, y, w, height, r, g, b, 255 ); x += w; width -= w; } - UnpackRGB(r, g, b, RGB_YELLOWISH); + UnpackRGB( r, g, b, RGB_YELLOWISH ); - FillRGBA(x, y, width, height, r, g, b, 128); + FillRGBA( x, y, width, height, r, g, b, 128 ); - return (x + width); + return ( x + width ); } - - -void DrawAmmoBar(WEAPON *p, int x, int y, int width, int height) +void DrawAmmoBar( WEAPON *p, int x, int y, int width, int height ) { - if ( !p ) + if( !p ) return; - - if (p->iAmmoType != -1) + + if( p->iAmmoType != -1 ) { - if (!gWR.CountAmmo(p->iAmmoType)) + if( !gWR.CountAmmo( p->iAmmoType ) ) return; - float f = (float)gWR.CountAmmo(p->iAmmoType)/(float)p->iMax1; + float f = (float)gWR.CountAmmo( p->iAmmoType ) / (float)p->iMax1; - x = DrawBar(x, y, width, height, f); - + x = DrawBar( x, y, width, height, f ); // Do we have secondary ammo too? - - if (p->iAmmo2Type != -1) + if( p->iAmmo2Type != -1 ) { - f = (float)gWR.CountAmmo(p->iAmmo2Type)/(float)p->iMax2; + f = (float)gWR.CountAmmo( p->iAmmo2Type ) / (float)p->iMax2; x += 5; //!!! - DrawBar(x, y, width, height, f); + DrawBar( x, y, width, height, f ); } } } - - - // // Draw Weapon Menu // -int CHudAmmo::DrawWList(float flTime) +int CHudAmmo::DrawWList( float flTime ) { - int r,g,b,x,y,a,i; + int r, g, b, x, y, a, i; - if ( !gpActiveSel ) + if( !gpActiveSel ) return 0; int iActiveSlot; - if ( gpActiveSel == (WEAPON *)1 ) + if( gpActiveSel == (WEAPON *) 1 ) iActiveSlot = -1; // current slot has no weapons else iActiveSlot = gpActiveSel->iSlot; x = 10; //!!! y = 10; //!!! - // Ensure that there are available choices in the active slot - if ( iActiveSlot > 0 ) + if( iActiveSlot > 0 ) { - if ( !gWR.GetFirstPos( iActiveSlot ) ) + if( !gWR.GetFirstPos( iActiveSlot ) ) { - gpActiveSel = (WEAPON *)1; + gpActiveSel = (WEAPON *) 1; iActiveSlot = -1; } } - + // Draw top line - for ( i = 0; i < MAX_WEAPON_SLOTS; i++ ) + for( i = 0; i < MAX_WEAPON_SLOTS; i++ ) { int iWidth; - UnpackRGB(r,g,b, RGB_YELLOWISH); - - if ( iActiveSlot == i ) + UnpackRGB( r, g, b, RGB_YELLOWISH ); + + if( iActiveSlot == i ) a = 255; else a = 192; - ScaleColors(r, g, b, 255); - SPR_Set(gHUD.GetSprite(m_HUD_bucket0 + i), r, g, b ); + ScaleColors( r, g, b, 255 ); + SPR_Set( gHUD.GetSprite( m_HUD_bucket0 + i ), r, g, b ); // make active slot wide enough to accomodate gun pictures - if ( i == iActiveSlot ) + if( i == iActiveSlot ) { - WEAPON *p = gWR.GetFirstPos(iActiveSlot); - if ( p ) + WEAPON *p = gWR.GetFirstPos( iActiveSlot ); + if( p ) iWidth = p->rcActive.right - p->rcActive.left; else iWidth = giBucketWidth; @@ -1070,58 +1047,55 @@ int CHudAmmo::DrawWList(float flTime) else iWidth = giBucketWidth; - SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_bucket0 + i)); + SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_bucket0 + i ) ); x += iWidth + 5; } - a = 128; //!!! x = 10; // Draw all of the buckets - for (i = 0; i < MAX_WEAPON_SLOTS; i++) + for( i = 0; i < MAX_WEAPON_SLOTS; i++ ) { y = giBucketHeight + 10; // If this is the active slot, draw the bigger pictures, // otherwise just draw boxes - if ( i == iActiveSlot ) + if( i == iActiveSlot ) { WEAPON *p = gWR.GetFirstPos( i ); int iWidth = giBucketWidth; - if ( p ) + if( p ) iWidth = p->rcActive.right - p->rcActive.left; - for ( int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++ ) + for( int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++ ) { p = gWR.GetWeaponSlot( i, iPos ); - if ( !p || !p->iId ) + if( !p || !p->iId ) continue; - UnpackRGB( r,g,b, RGB_YELLOWISH ); - + UnpackRGB( r, g, b, RGB_YELLOWISH ); + // if active, then we must have ammo. - - if ( gpActiveSel == p ) + if( gpActiveSel == p ) { - SPR_Set(p->hActive, r, g, b ); - SPR_DrawAdditive(0, x, y, &p->rcActive); + SPR_Set( p->hActive, r, g, b ); + SPR_DrawAdditive( 0, x, y, &p->rcActive ); - SPR_Set(gHUD.GetSprite(m_HUD_selection), r, g, b ); - SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_selection)); + SPR_Set( gHUD.GetSprite( m_HUD_selection ), r, g, b ); + SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_selection ) ); } else { // Draw Weapon if Red if no ammo - - if ( gWR.HasAmmo(p) ) - ScaleColors(r, g, b, 192); + if( gWR.HasAmmo( p ) ) + ScaleColors( r, g, b, 192 ); else { - UnpackRGB(r,g,b, RGB_REDISH); - ScaleColors(r, g, b, 128); + UnpackRGB( r, g, b, RGB_REDISH ); + ScaleColors( r, g, b, 128 ); } SPR_Set( p->hInactive, r, g, b ); @@ -1129,36 +1103,33 @@ int CHudAmmo::DrawWList(float flTime) } // Draw Ammo Bar - - DrawAmmoBar(p, x + giABWidth/2, y, giABWidth, giABHeight); + DrawAmmoBar( p, x + giABWidth / 2, y, giABWidth, giABHeight ); y += p->rcActive.bottom - p->rcActive.top + 5; } x += iWidth + 5; - } else { // Draw Row of weapons. + UnpackRGB( r, g, b, RGB_YELLOWISH ); - UnpackRGB(r,g,b, RGB_YELLOWISH); - - for ( int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++ ) + for( int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++ ) { WEAPON *p = gWR.GetWeaponSlot( i, iPos ); - - if ( !p || !p->iId ) + + if( !p || !p->iId ) continue; - if ( gWR.HasAmmo(p) ) + if( gWR.HasAmmo( p ) ) { - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB( r, g, b, RGB_YELLOWISH ); a = 128; } else { - UnpackRGB(r,g,b, RGB_REDISH); + UnpackRGB( r, g, b, RGB_REDISH ); a = 96; } @@ -1169,13 +1140,11 @@ int CHudAmmo::DrawWList(float flTime) x += giBucketWidth + 5; } - } + } return 1; - } - /* ================================= GetSpriteList @@ -1184,17 +1153,17 @@ sprite name 'psz' and resolution 'iRes' in the given sprite list 'pList' iCount is the number of items in the pList ================================= */ -client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, int iRes, int iCount) +client_sprite_t *GetSpriteList( client_sprite_t *pList, const char *psz, int iRes, int iCount ) { - if (!pList) + if( !pList ) return NULL; int i = iCount; client_sprite_t *p = pList; - while(i--) + while( i-- ) { - if ((!strcmp(psz, p->szName)) && (p->iRes == iRes)) + if( ( !strcmp( psz, p->szName ) ) && ( p->iRes == iRes ) ) return p; p++; } diff --git a/cl_dll/ammo.h b/cl_dll/ammo.h index 5e44065a..9134681c 100644 --- a/cl_dll/ammo.h +++ b/cl_dll/ammo.h @@ -18,7 +18,6 @@ #define MAX_WEAPON_NAME 128 - #define WEAPON_FLAGS_SELECTONEMPTY 1 #define WEAPON_IS_ONTARGET 0x40 @@ -57,6 +56,4 @@ struct WEAPON }; typedef int AMMO; - - -#endif \ No newline at end of file +#endif diff --git a/cl_dll/ammo_secondary.cpp b/cl_dll/ammo_secondary.cpp index 8038c216..994350ed 100644 --- a/cl_dll/ammo_secondary.cpp +++ b/cl_dll/ammo_secondary.cpp @@ -27,7 +27,7 @@ DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoVal ) DECLARE_MESSAGE( m_AmmoSecondary, SecAmmoIcon ) -int CHudAmmoSecondary :: Init( void ) +int CHudAmmoSecondary::Init( void ) { HOOK_MESSAGE( SecAmmoVal ); HOOK_MESSAGE( SecAmmoIcon ); @@ -43,67 +43,68 @@ int CHudAmmoSecondary :: Init( void ) return 1; } -void CHudAmmoSecondary :: Reset( void ) +void CHudAmmoSecondary::Reset( void ) { m_fFade = 0; } -int CHudAmmoSecondary :: VidInit( void ) +int CHudAmmoSecondary::VidInit( void ) { return 1; } -int CHudAmmoSecondary :: Draw(float flTime) +int CHudAmmoSecondary::Draw( float flTime ) { - if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) ) + if ( ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) ) return 1; // draw secondary ammo icons above normal ammo readout int a, x, y, r, g, b, AmmoWidth; UnpackRGB( r, g, b, RGB_YELLOWISH ); - a = (int) max( MIN_ALPHA, m_fFade ); - if (m_fFade > 0) - m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons + a = (int)max( MIN_ALPHA, m_fFade ); + if( m_fFade > 0 ) + m_fFade -= ( gHUD.m_flTimeDelta * 20 ); // slowly lower alpha to fade out icons ScaleColors( r, g, b, a ); - AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left; + AmmoWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; - y = ScreenHeight - (gHUD.m_iFontHeight*4); // this is one font height higher than the weapon ammo values + y = ScreenHeight - ( gHUD.m_iFontHeight * 4 ); // this is one font height higher than the weapon ammo values x = ScreenWidth - AmmoWidth; - if ( m_HUD_ammoicon ) + if( m_HUD_ammoicon ) { // Draw the ammo icon - x -= (gHUD.GetSpriteRect(m_HUD_ammoicon).right - gHUD.GetSpriteRect(m_HUD_ammoicon).left); - y -= (gHUD.GetSpriteRect(m_HUD_ammoicon).top - gHUD.GetSpriteRect(m_HUD_ammoicon).bottom); + x -= ( gHUD.GetSpriteRect( m_HUD_ammoicon ).right - gHUD.GetSpriteRect( m_HUD_ammoicon ).left ); + y -= ( gHUD.GetSpriteRect( m_HUD_ammoicon ).top - gHUD.GetSpriteRect( m_HUD_ammoicon ).bottom ); - SPR_Set( gHUD.GetSprite(m_HUD_ammoicon), r, g, b ); - SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_ammoicon) ); + SPR_Set( gHUD.GetSprite( m_HUD_ammoicon ), r, g, b ); + SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_ammoicon ) ); } else - { // move the cursor by the '0' char instead, since we don't have an icon to work with + { + // move the cursor by the '0' char instead, since we don't have an icon to work with x -= AmmoWidth; - y -= (gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom); + y -= ( gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).top - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).bottom ); } // draw the ammo counts, in reverse order, from right to left - for ( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- ) + for( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- ) { - if ( m_iAmmoAmounts[i] < 0 ) + if( m_iAmmoAmounts[i] < 0 ) continue; // negative ammo amounts imply that they shouldn't be drawn // half a char gap between the ammo number and the previous pic - x -= (AmmoWidth / 2); + x -= ( AmmoWidth / 2 ); // draw the number, right-aligned - x -= (gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth); + x -= ( gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth ); gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b ); - if ( i != 0 ) + if( i != 0 ) { // draw the divider bar - x -= (AmmoWidth / 2); - FillRGBA(x, y, (AmmoWidth/10), gHUD.m_iFontHeight, r, g, b, a); + x -= ( AmmoWidth / 2 ); + FillRGBA( x, y, ( AmmoWidth/10 ), gHUD.m_iFontHeight, r, g, b, a ); } } @@ -113,7 +114,7 @@ int CHudAmmoSecondary :: Draw(float flTime) // Message handler for Secondary Ammo Value // accepts one value: // string: sprite name -int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf ) +int CHudAmmoSecondary::MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); m_HUD_ammoicon = gHUD.GetSpriteIndex( READ_STRING() ); @@ -126,12 +127,12 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoIcon( const char *pszName, int iSize, vo // takes two values: // byte: ammo index // byte: ammo value -int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf ) +int CHudAmmoSecondary::MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); int index = READ_BYTE(); - if ( index < 0 || index >= MAX_SEC_AMMO_VALUES ) + if( index < 0 || index >= MAX_SEC_AMMO_VALUES ) return 1; m_iAmmoAmounts[index] = READ_BYTE(); @@ -139,13 +140,14 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, voi // check to see if there is anything left to draw int count = 0; - for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ ) + for( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ ) { count += max( 0, m_iAmmoAmounts[i] ); } - if ( count == 0 ) - { // the ammo fields are all empty, so turn off this hud area + if( count == 0 ) + { + // the ammo fields are all empty, so turn off this hud area m_iFlags &= ~HUD_ACTIVE; return 1; } @@ -155,5 +157,3 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, voi return 1; } - - diff --git a/cl_dll/ammohistory.cpp b/cl_dll/ammohistory.cpp index 86e9cb09..4b1e6745 100644 --- a/cl_dll/ammohistory.cpp +++ b/cl_dll/ammohistory.cpp @@ -28,9 +28,9 @@ HistoryResource gHR; -#define AMMO_PICKUP_GAP (gHR.iHistoryGap+5) -#define AMMO_PICKUP_PICK_HEIGHT (32 + (gHR.iHistoryGap * 2)) -#define AMMO_PICKUP_HEIGHT_MAX (ScreenHeight - 100) +#define AMMO_PICKUP_GAP ( gHR.iHistoryGap + 5 ) +#define AMMO_PICKUP_PICK_HEIGHT ( 32 + ( gHR.iHistoryGap * 2 ) ) +#define AMMO_PICKUP_HEIGHT_MAX ( ScreenHeight - 100 ) #define MAX_ITEM_NAME 32 int HISTORY_DRAW_TIME = 5; @@ -43,13 +43,14 @@ struct ITEM_INFO wrect_t rect; }; -void HistoryResource :: AddToHistory( int iType, int iId, int iCount ) +void HistoryResource::AddToHistory( int iType, int iId, int iCount ) { - if ( iType == HISTSLOT_AMMO && !iCount ) + if( iType == HISTSLOT_AMMO && !iCount ) return; // no amount, so don't add - if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) ) - { // the pic would have to be drawn too high + if( ( ( ( AMMO_PICKUP_GAP * iCurrentHistorySlot ) + AMMO_PICKUP_PICK_HEIGHT ) > AMMO_PICKUP_HEIGHT_MAX ) || ( iCurrentHistorySlot >= MAX_HISTORY ) ) + { + // the pic would have to be drawn too high // so start from the bottom iCurrentHistorySlot = 0; } @@ -63,13 +64,14 @@ void HistoryResource :: AddToHistory( int iType, int iId, int iCount ) freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME; } -void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount ) +void HistoryResource::AddToHistory( int iType, const char *szName, int iCount ) { - if ( iType != HISTSLOT_ITEM ) + if( iType != HISTSLOT_ITEM ) return; - if ( (((AMMO_PICKUP_GAP * iCurrentHistorySlot) + AMMO_PICKUP_PICK_HEIGHT) > AMMO_PICKUP_HEIGHT_MAX) || (iCurrentHistorySlot >= MAX_HISTORY) ) - { // the pic would have to be drawn too high + if( ( ( ( AMMO_PICKUP_GAP * iCurrentHistorySlot ) + AMMO_PICKUP_PICK_HEIGHT ) > AMMO_PICKUP_HEIGHT_MAX ) || ( iCurrentHistorySlot >= MAX_HISTORY ) ) + { + // the pic would have to be drawn too high // so start from the bottom iCurrentHistorySlot = 0; } @@ -77,9 +79,8 @@ void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount HIST_ITEM *freeslot = &rgAmmoHistory[iCurrentHistorySlot++]; // default to just writing to the first slot // I am really unhappy with all the code in this file - int i = gHUD.GetSpriteIndex( szName ); - if ( i == -1 ) + if( i == -1 ) return; // unknown sprite name, don't add it to history freeslot->iId = i; @@ -90,12 +91,11 @@ void HistoryResource :: AddToHistory( int iType, const char *szName, int iCount freeslot->DisplayTime = gHUD.m_flTime + HISTORY_DRAW_TIME; } - -void HistoryResource :: CheckClearHistory( void ) +void HistoryResource::CheckClearHistory( void ) { - for ( int i = 0; i < MAX_HISTORY; i++ ) + for( int i = 0; i < MAX_HISTORY; i++ ) { - if ( rgAmmoHistory[i].type ) + if( rgAmmoHistory[i].type ) return; } @@ -105,79 +105,81 @@ void HistoryResource :: CheckClearHistory( void ) // // Draw Ammo pickup history // -int HistoryResource :: DrawAmmoHistory( float flTime ) +int HistoryResource::DrawAmmoHistory( float flTime ) { - for ( int i = 0; i < MAX_HISTORY; i++ ) + for( int i = 0; i < MAX_HISTORY; i++ ) { - if ( rgAmmoHistory[i].type ) + if( rgAmmoHistory[i].type ) { rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME ); - if ( rgAmmoHistory[i].DisplayTime <= flTime ) - { // pic drawing time has expired + if( rgAmmoHistory[i].DisplayTime <= flTime ) + { + // pic drawing time has expired memset( &rgAmmoHistory[i], 0, sizeof(HIST_ITEM) ); CheckClearHistory(); } - else if ( rgAmmoHistory[i].type == HISTSLOT_AMMO ) + else if( rgAmmoHistory[i].type == HISTSLOT_AMMO ) { wrect_t rcPic; HSPRITE *spr = gWR.GetAmmoPicFromWeapon( rgAmmoHistory[i].iId, rcPic ); int r, g, b; - UnpackRGB(r,g,b, RGB_YELLOWISH); - float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; - ScaleColors(r, g, b, min(scale, 255) ); + UnpackRGB( r, g, b, RGB_YELLOWISH ); + float scale = ( rgAmmoHistory[i].DisplayTime - flTime ) * 80; + ScaleColors( r, g, b, min( scale, 255 ) ); // Draw the pic int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int xpos = ScreenWidth - 24; - if ( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic - { // the dll has to make sure it has sent info the weapons you need + if( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic + { + // the dll has to make sure it has sent info the weapons you need SPR_Set( *spr, r, g, b ); SPR_DrawAdditive( 0, xpos, ypos, &rcPic ); } // do not draw black console string - if( !(( hud_textmode->value == 2 ) && ( scale < 200 )) ) + if( !( ( hud_textmode->value == 2 ) && ( scale < 200 ) ) ) // Draw the number gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b ); } - else if ( rgAmmoHistory[i].type == HISTSLOT_WEAP ) + else if( rgAmmoHistory[i].type == HISTSLOT_WEAP ) { WEAPON *weap = gWR.GetWeapon( rgAmmoHistory[i].iId ); - if ( !weap ) + if( !weap ) return 1; // we don't know about the weapon yet, so don't draw anything int r, g, b; - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB( r,g,b, RGB_YELLOWISH ); - if ( !gWR.HasAmmo( weap ) ) - UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red + if( !gWR.HasAmmo( weap ) ) + UnpackRGB( r, g, b, RGB_REDISH ); // if the weapon doesn't have ammo, display it as red - float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; - ScaleColors(r, g, b, min(scale, 255) ); + float scale = ( rgAmmoHistory[i].DisplayTime - flTime ) * 80; + ScaleColors( r, g, b, min( scale, 255 ) ); - int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); - int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left); + int ypos = ScreenHeight - ( AMMO_PICKUP_PICK_HEIGHT + ( AMMO_PICKUP_GAP * i ) ); + int xpos = ScreenWidth - ( weap->rcInactive.right - weap->rcInactive.left ); SPR_Set( weap->hInactive, r, g, b ); SPR_DrawAdditive( 0, xpos, ypos, &weap->rcInactive ); } - else if ( rgAmmoHistory[i].type == HISTSLOT_ITEM ) + else if( rgAmmoHistory[i].type == HISTSLOT_ITEM ) { int r, g, b; - if ( !rgAmmoHistory[i].iId ) + if( !rgAmmoHistory[i].iId ) continue; // sprite not loaded wrect_t rect = gHUD.GetSpriteRect( rgAmmoHistory[i].iId ); - UnpackRGB(r,g,b, RGB_YELLOWISH); - float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; - ScaleColors(r, g, b, min(scale, 255) ); + UnpackRGB( r, g, b, RGB_YELLOWISH ); + float scale = ( rgAmmoHistory[i].DisplayTime - flTime ) * 80; + ScaleColors( r, g, b, min( scale, 255 ) ); - int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); - int xpos = ScreenWidth - (rect.right - rect.left) - 10; + int ypos = ScreenHeight - ( AMMO_PICKUP_PICK_HEIGHT + ( AMMO_PICKUP_GAP * i ) ); + int xpos = ScreenWidth - ( rect.right - rect.left ) - 10; SPR_Set( gHUD.GetSprite( rgAmmoHistory[i].iId ), r, g, b ); SPR_DrawAdditive( 0, xpos, ypos, &rect ); @@ -185,8 +187,5 @@ int HistoryResource :: DrawAmmoHistory( float flTime ) } } - return 1; } - - diff --git a/cl_dll/ammohistory.h b/cl_dll/ammohistory.h index 3d7d5947..f1063ae1 100644 --- a/cl_dll/ammohistory.h +++ b/cl_dll/ammohistory.h @@ -26,8 +26,8 @@ private: WEAPON rgWeapons[MAX_WEAPONS]; // Weapons Array // counts of weapons * ammo - WEAPON* rgSlots[MAX_WEAPON_SLOTS+1][MAX_WEAPON_POSITIONS+1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there - int riAmmo[MAX_AMMO_TYPES]; // count of each ammo type + WEAPON* rgSlots[MAX_WEAPON_SLOTS + 1][MAX_WEAPON_POSITIONS + 1]; // The slots currently in use by weapons. The value is a pointer to the weapon; if it's NULL, no weapon is there + int riAmmo[MAX_AMMO_TYPES]; // count of each ammo type public: void Init( void ) @@ -49,25 +49,25 @@ public: WEAPON *GetWeapon( int iId ) { return &rgWeapons[iId]; } void AddWeapon( WEAPON *wp ) { - rgWeapons[ wp->iId ] = *wp; - LoadWeaponSprites( &rgWeapons[ wp->iId ] ); + rgWeapons[wp->iId] = *wp; + LoadWeaponSprites( &rgWeapons[wp->iId] ); } void PickupWeapon( WEAPON *wp ) { - rgSlots[ wp->iSlot ][ wp->iSlotPos ] = wp; + rgSlots[wp->iSlot][wp->iSlotPos] = wp; } void DropWeapon( WEAPON *wp ) { - rgSlots[ wp->iSlot ][ wp->iSlotPos ] = NULL; + rgSlots[wp->iSlot][wp->iSlotPos] = NULL; } void DropAllWeapons( void ) { - for ( int i = 0; i < MAX_WEAPONS; i++ ) + for( int i = 0; i < MAX_WEAPONS; i++ ) { - if ( rgWeapons[i].iId ) + if( rgWeapons[i].iId ) DropWeapon( &rgWeapons[i] ); } } @@ -94,7 +94,6 @@ public: extern WeaponsResource gWR; - #define MAX_HISTORY 12 enum { HISTSLOT_EMPTY, @@ -138,6 +137,3 @@ public: }; extern HistoryResource gHR; - - - diff --git a/cl_dll/battery.cpp b/cl_dll/battery.cpp index 4d08892d..2f26057f 100644 --- a/cl_dll/battery.cpp +++ b/cl_dll/battery.cpp @@ -25,23 +25,22 @@ #include #include -DECLARE_MESSAGE(m_Battery, Battery) +DECLARE_MESSAGE( m_Battery, Battery ) -int CHudBattery::Init(void) +int CHudBattery::Init( void ) { m_iBat = 0; m_fFade = 0; m_iFlags = 0; - HOOK_MESSAGE(Battery); + HOOK_MESSAGE( Battery ); - gHUD.AddHudElem(this); + gHUD.AddHudElem( this ); return 1; } - -int CHudBattery::VidInit(void) +int CHudBattery::VidInit( void ) { int HUD_suit_empty = gHUD.GetSpriteIndex( "suit_empty" ); int HUD_suit_full = gHUD.GetSpriteIndex( "suit_full" ); @@ -54,15 +53,14 @@ int CHudBattery::VidInit(void) return 1; } -int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf ) +int CHudBattery::MsgFunc_Battery( const char *pszName, int iSize, void *pbuf ) { m_iFlags |= HUD_ACTIVE; - BEGIN_READ( pbuf, iSize ); int x = READ_SHORT(); - if (x != m_iBat) + if( x != m_iBat ) { m_fFade = FADE_TIME; m_iBat = x; @@ -71,68 +69,65 @@ int CHudBattery:: MsgFunc_Battery(const char *pszName, int iSize, void *pbuf ) return 1; } - -int CHudBattery::Draw(float flTime) +int CHudBattery::Draw( float flTime ) { - if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) + if( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) return 1; int r, g, b, x, y, a; wrect_t rc; rc = *m_prc2; - rc.top += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1 + rc.top += m_iHeight * ( (float)( 100 - ( min( 100,m_iBat ) ) ) * 0.01 ); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1 - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB( r, g, b, RGB_YELLOWISH ); - if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) )) + if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) return 1; // Has health changed? Flash the health # - if (m_fFade) + if( m_fFade ) { - if (m_fFade > FADE_TIME) + if( m_fFade > FADE_TIME ) m_fFade = FADE_TIME; - m_fFade -= (gHUD.m_flTimeDelta * 20); - if (m_fFade <= 0) + m_fFade -= ( gHUD.m_flTimeDelta * 20 ); + if( m_fFade <= 0 ) { a = 128; m_fFade = 0; } // Fade the health number back to dim - - a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128; - + a = MIN_ALPHA + ( m_fFade / FADE_TIME ) * 128; } else a = MIN_ALPHA; - ScaleColors(r, g, b, a ); - - int iOffset = (m_prc1->bottom - m_prc1->top)/6; + ScaleColors( r, g, b, a ); + + int iOffset = ( m_prc1->bottom - m_prc1->top ) / 6; y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; - x = ScreenWidth/5; + x = ScreenWidth / 5; // make sure we have the right sprite handles - if ( !m_hSprite1 ) + if( !m_hSprite1 ) m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) ); - if ( !m_hSprite2 ) + if( !m_hSprite2 ) m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) ); - SPR_Set(m_hSprite1, r, g, b ); - SPR_DrawAdditive( 0, x, y - iOffset, m_prc1); + SPR_Set( m_hSprite1, r, g, b ); + SPR_DrawAdditive( 0, x, y - iOffset, m_prc1 ); - if (rc.bottom > rc.top) + if( rc.bottom > rc.top ) { - SPR_Set(m_hSprite2, r, g, b ); - SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc); + SPR_Set( m_hSprite2, r, g, b ); + SPR_DrawAdditive( 0, x, y - iOffset + ( rc.top - m_prc2->top ), &rc ); } - x += (m_prc1->right - m_prc1->left); - x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b); + x += ( m_prc1->right - m_prc1->left ); + x = gHUD.DrawHudNumber( x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b ); return 1; } diff --git a/cl_dll/camera.h b/cl_dll/camera.h index 08c87920..448b22ca 100644 --- a/cl_dll/camera.h +++ b/cl_dll/camera.h @@ -18,7 +18,6 @@ extern int cam_thirdperson; void CAM_Init( void ); void CAM_ClearStates( void ); -void CAM_StartMouseMove(void); -void CAM_EndMouseMove(void); - -#endif // _CAMERA_H_ +void CAM_StartMouseMove( void ); +void CAM_EndMouseMove( void ); +#endif // _CAMERA_H_ diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 80fdfe81..096548a1 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -32,7 +32,7 @@ extern "C" cl_enginefunc_t gEngfuncs; CHud gHUD; mobile_engfuncs_t *gMobileEngfuncs = NULL; -void InitInput (void); +void InitInput( void ); void EV_HookEvents( void ); void IN_Commands( void ); @@ -73,16 +73,16 @@ int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs ) { int iret = 0; - switch ( hullnumber ) + switch( hullnumber ) { case 0: // Normal player - mins = Vector(-16, -16, -36); - maxs = Vector(16, 16, 36); + mins = Vector( -16, -16, -36 ); + maxs = Vector( 16, 16, 36 ); iret = 1; break; case 1: // Crouched player - mins = Vector(-16, -16, -18 ); - maxs = Vector(16, 16, 18 ); + mins = Vector( -16, -16, -18 ); + maxs = Vector( 16, 16, 18 ); iret = 1; break; case 2: // Point based hull @@ -103,7 +103,7 @@ HUD_ConnectionlessPacket size of the response_buffer, so you must zero it out if you choose not to respond. ================================ */ -int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) +int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) { // Parse stuff from args int max_buffer_size = *response_buffer_size; @@ -136,17 +136,16 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion ) { gEngfuncs = *pEnginefuncs; - if (iVersion != CLDLL_INTERFACE_VERSION) + if( iVersion != CLDLL_INTERFACE_VERSION ) return 0; - memcpy(&gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t)); + memcpy( &gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t) ); EV_HookEvents(); return 1; } - /* ========================== HUD_VidInit @@ -180,7 +179,6 @@ void DLLEXPORT HUD_Init( void ) gHUD.Init(); } - /* ========================== HUD_Redraw @@ -197,7 +195,6 @@ int DLLEXPORT HUD_Redraw( float time, int intermission ) return 1; } - /* ========================== HUD_UpdateClientData @@ -211,11 +208,11 @@ returns 1 if anything has been changed, 0 otherwise. ========================== */ -int DLLEXPORT HUD_UpdateClientData(client_data_t *pcldata, float flTime ) +int DLLEXPORT HUD_UpdateClientData( client_data_t *pcldata, float flTime ) { IN_Commands(); - return gHUD.UpdateClientData(pcldata, flTime ); + return gHUD.UpdateClientData( pcldata, flTime ); } /* @@ -243,7 +240,6 @@ void DLLEXPORT HUD_Frame( double time ) { } - /* ========================== HUD_VoiceStatus @@ -252,7 +248,7 @@ Called when a player starts or stops talking. ========================== */ -void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking) +void DLLEXPORT HUD_VoiceStatus( int entindex, qboolean bTalking ) { } @@ -272,7 +268,7 @@ void DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf ) void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs ) { - if( gpMobileEngfuncs->version != MOBILITY_API_VERSION ) - return; - gMobileEngfuncs = gpMobileEngfuncs; + if( gpMobileEngfuncs->version != MOBILITY_API_VERSION ) + return; + gMobileEngfuncs = gpMobileEngfuncs; } diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index de1b5d4a..fda4b812 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -28,7 +28,7 @@ typedef unsigned char byte; typedef unsigned short word; typedef float vec_t; -typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf); +typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); #include "util_vector.h" diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index aa2cd853..8d9661b2 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -15,6 +15,7 @@ // // cl_util.h // + #include "exportdef.h" #include "cvardef.h" @@ -25,72 +26,70 @@ // Macros to hook function calls into the HUD object -#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg(#x, __MsgFunc_##x ); - -#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x(const char *pszName, int iSize, void *pbuf) \ - { \ - return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \ - } +#define HOOK_MESSAGE(x) gEngfuncs.pfnHookUserMsg( #x, __MsgFunc_##x ); +#define DECLARE_MESSAGE(y, x) int __MsgFunc_##x( const char *pszName, int iSize, void *pbuf ) \ + { \ + return gHUD.y.MsgFunc_##x(pszName, iSize, pbuf ); \ + } #define HOOK_COMMAND(x, y) gEngfuncs.pfnAddCommand( x, __CmdFunc_##y ); #define DECLARE_COMMAND(y, x) void __CmdFunc_##x( void ) \ - { \ - gHUD.y.UserCmd_##x( ); \ - } - + { \ + gHUD.y.UserCmd_##x( ); \ + } inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); } inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); } inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( (char*)cv, (char*)val, flags ); } -#define SPR_Load (*gEngfuncs.pfnSPR_Load) -#define SPR_Set (*gEngfuncs.pfnSPR_Set) -#define SPR_Frames (*gEngfuncs.pfnSPR_Frames) -#define SPR_GetList (*gEngfuncs.pfnSPR_GetList) +#define SPR_Load( *gEngfuncs.pfnSPR_Load ) +#define SPR_Set( *gEngfuncs.pfnSPR_Set ) +#define SPR_Frames( *gEngfuncs.pfnSPR_Frames ) +#define SPR_GetList( *gEngfuncs.pfnSPR_GetList ) // SPR_Draw draws a the current sprite as solid -#define SPR_Draw (*gEngfuncs.pfnSPR_Draw) -// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent) -#define SPR_DrawHoles (*gEngfuncs.pfnSPR_DrawHoles) +#define SPR_Draw( *gEngfuncs.pfnSPR_Draw ) +// SPR_DrawHoles draws the current sprites, with color index255 not drawn (transparent) +#define SPR_DrawHoles( *gEngfuncs.pfnSPR_DrawHoles ) // SPR_DrawAdditive adds the sprites RGB values to the background (additive transulency) -#define SPR_DrawAdditive (*gEngfuncs.pfnSPR_DrawAdditive) +#define SPR_DrawAdditive( *gEngfuncs.pfnSPR_DrawAdditive ) -// SPR_EnableScissor sets a clipping rect for HUD sprites. (0,0) is the top-left hand corner of the screen. -#define SPR_EnableScissor (*gEngfuncs.pfnSPR_EnableScissor) +// SPR_EnableScissor sets a clipping rect for HUD sprites. (0,0) is the top-left hand corner of the screen. +#define SPR_EnableScissor( *gEngfuncs.pfnSPR_EnableScissor ) // SPR_DisableScissor disables the clipping rect -#define SPR_DisableScissor (*gEngfuncs.pfnSPR_DisableScissor) +#define SPR_DisableScissor( *gEngfuncs.pfnSPR_DisableScissor ) // -#define FillRGBA (*gEngfuncs.pfnFillRGBA) - +#define FillRGBA( *gEngfuncs.pfnFillRGBA ) // ScreenHeight returns the height of the screen, in pixels -#define ScreenHeight (gHUD.m_scrinfo.iHeight) +#define ScreenHeight( gHUD.m_scrinfo.iHeight ) // ScreenWidth returns the width of the screen, in pixels -#define ScreenWidth (gHUD.m_scrinfo.iWidth) +#define ScreenWidth( gHUD.m_scrinfo.iWidth ) // Use this to set any co-ords in 640x480 space -#define XRES(x) ((int)(float(x) * ((float)ScreenWidth / 640.0f) + 0.5f)) -#define YRES(y) ((int)(float(y) * ((float)ScreenHeight / 480.0f) + 0.5f)) +#define XRES(x) ( (int)( float(x) * ( (float)ScreenWidth / 640.0f ) + 0.5f ) ) +#define YRES(y) ( (int)( float(y) * ( (float)ScreenHeight / 480.0f ) + 0.5f ) ) // use this to project world coordinates to screen coordinates -#define XPROJECT(x) ( (1.0f+(x))*ScreenWidth*0.5f ) -#define YPROJECT(y) ( (1.0f-(y))*ScreenHeight*0.5f ) +#define XPROJECT(x) ( ( 1.0f + (x) ) * ScreenWidth * 0.5f ) +#define YPROJECT(y) ( ( 1.0f - (y) ) * ScreenHeight * 0.5f ) -#define GetScreenInfo (*gEngfuncs.pfnGetScreenInfo) -#define ServerCmd (*gEngfuncs.pfnServerCmd) -#define ClientCmd (*gEngfuncs.pfnClientCmd) -#define SetCrosshair (*gEngfuncs.pfnSetCrosshair) -#define AngleVectors (*gEngfuncs.pfnAngleVectors) +#define GetScreenInfo( *gEngfuncs.pfnGetScreenInfo ) +#define ServerCmd( *gEngfuncs.pfnServerCmd ) +#define ClientCmd( *gEngfuncs.pfnClientCmd ) +#define SetCrosshair( *gEngfuncs.pfnSetCrosshair ) +#define AngleVectors( *gEngfuncs.pfnAngleVectors ) extern cvar_t *hud_textmode; extern float g_hud_text_color[3]; -inline void DrawSetTextColor(float r, float g, float b) +inline void DrawSetTextColor( float r, float g, float b ) { if( hud_textmode->value == 1 ) - g_hud_text_color[0]=r, g_hud_text_color[1] = g, g_hud_text_color[2] = b; + g_hud_text_color[0] = r, g_hud_text_color[1] = g, g_hud_text_color[2] = b; else gEngfuncs.pfnDrawSetTextColor( r, g, b ); } + // 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); } @@ -104,7 +103,7 @@ inline int TextMessageDrawChar( int x, int y, int number, int r, int g, in inline int DrawConsoleString( int x, int y, const char *string ) { if( hud_textmode->value == 1 ) - return gHUD.DrawHudString( x, y, 9999, (char*)string, 255*g_hud_text_color[0], 255*g_hud_text_color[1], 255*g_hud_text_color[2]); + return gHUD.DrawHudString( x, y, 9999, (char*)string, 255 * g_hud_text_color[0], 255 * g_hud_text_color[1], 255 * g_hud_text_color[2] ); return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string ); } @@ -120,7 +119,7 @@ inline int ConsoleStringLen( const char *string ) { int _width = 0, _height = 0; if( hud_textmode->value == 1 ) - return gHUD.DrawHudStringLen((char*)string); + return gHUD.DrawHudStringLen( (char*)string ); GetConsoleStringSize( string, &_width, &_height ); return _width; } @@ -136,7 +135,7 @@ inline void CenterPrint( const char *string ) } // returns the players name of entity no. -#define GetPlayerInfo (*gEngfuncs.pfnGetPlayerInfo) +#define GetPlayerInfo( *gEngfuncs.pfnGetPlayerInfo ) // sound functions inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } @@ -148,16 +147,16 @@ inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( void ScaleColors( int &r, int &g, int &b, int a ); -#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) -#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];} -#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];} -#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];} -inline void VectorClear(float *a) { a[0]=0.0;a[1]=0.0;a[2]=0.0;} -float Length(const float *v); -void VectorMA (const float *veca, float scale, const float *vecb, float *vecc); -void VectorScale (const float *in, float scale, float *out); -float VectorNormalize (float *v); -void VectorInverse ( float *v ); +#define DotProduct(x, y) ((x)[0] * (y)[0] + (x)[1] * (y)[1] + (x)[2] * (y)[2]) +#define VectorSubtract(a, b, c) { (c)[0] = (a)[0] - (b)[0]; (c)[1] = (a)[1] - (b)[1]; (c)[2] = (a)[2] - (b)[2]; } +#define VectorAdd(a, b, c) { (c)[0] = (a)[0] + (b)[0]; (c)[1] = (a)[1] + (b)[1]; (c)[2] = (a)[2] + (b)[2]; } +#define VectorCopy(a, b) { (b)[0] = (a)[0]; (b)[1] = (a)[1]; (b)[2] = (a)[2]; } +inline void VectorClear( float *a ) { a[0] = 0.0; a[1] = 0.0; a[2] = 0.0; } +float Length( const float *v ); +void VectorMA( const float *veca, float scale, const float *vecb, float *vecc ); +void VectorScale( const float *in, float scale, float *out ); +float VectorNormalize( float *v ); +void VectorInverse( float *v ); extern vec3_t vec3_origin; @@ -166,11 +165,11 @@ extern vec3_t vec3_origin; // disable 'truncation from 'const double' to 'float' warning message #pragma warning( disable: 4305 ) -inline void UnpackRGB(int &r, int &g, int &b, unsigned long ulRGB)\ +inline void UnpackRGB( int &r, int &g, int &b, unsigned long ulRGB )\ {\ - r = (ulRGB & 0xFF0000) >>16;\ - g = (ulRGB & 0xFF00) >> 8;\ + r = ( ulRGB & 0xFF0000 ) >> 16;\ + g = ( ulRGB & 0xFF00 ) >> 8;\ b = ulRGB & 0xFF;\ } -HSPRITE LoadSprite(const char *pszName); +HSPRITE LoadSprite( const char *pszName ); diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index df84daf8..3a3f0a6f 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -27,7 +27,7 @@ // g_runfuncs is true if this is the first time we've "predicated" a particular movement/firing // command. If it is 1, then we should play events/sounds etc., otherwise, we just will be // updating state info, but not firing events -int g_runfuncs = 0; +int g_runfuncs = 0; // During our weapon prediction processing, we'll need to reference some data that is part of // the final state passed into the postthink functionality. We'll set this pointer and then @@ -41,14 +41,14 @@ COM_Log Log debug messages to file ( appends ) ==================== */ -void COM_Log( char *pszFile, char *fmt, ...) +void COM_Log( char *pszFile, char *fmt, ... ) { va_list argptr; char string[1024]; FILE *fp; char *pfilename; - - if ( !pszFile ) + + if( !pszFile ) { pfilename = "c:\\hllog.txt"; } @@ -57,15 +57,15 @@ void COM_Log( char *pszFile, char *fmt, ...) pfilename = pszFile; } - va_start (argptr,fmt); - vsprintf (string, fmt,argptr); - va_end (argptr); + va_start( argptr, fmt ); + vsprintf( string, fmt, argptr ); + va_end( argptr ); fp = fopen( pfilename, "a+t"); - if (fp) + if( fp ) { - fprintf(fp, "%s", string); - fclose(fp); + fprintf( fp, "%s", string ); + fclose( fp ); } } @@ -83,7 +83,7 @@ Change weapon model animation void HUD_SendWeaponAnim( int iAnim, int body, int force ) { // Don't actually change it. - if ( !g_runfuncs && !force ) + if( !g_runfuncs && !force ) return; g_currentanim = iAnim; @@ -113,7 +113,7 @@ Play a sound, if we are seeing this command for the first time */ void HUD_PlaySound( char *sound, float volume ) { - if ( !g_runfuncs || !g_finalstate ) + if( !g_runfuncs || !g_finalstate ) return; gEngfuncs.pfnPlaySoundByNameAtLocation( sound, volume, (float *)&g_finalstate->playerstate.origin ); @@ -132,7 +132,7 @@ void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short event vec3_t org; vec3_t ang; - if ( !g_runfuncs || !g_finalstate ) + if( !g_runfuncs || !g_finalstate ) return; // Weapon prediction events are assumed to occur at the player's origin @@ -151,7 +151,6 @@ void HUD_SetMaxSpeed( const edict_t *ed, float speed ) { } - /* ===================== UTIL_WeaponTimeBase @@ -167,7 +166,7 @@ float UTIL_WeaponTimeBase( void ) static unsigned int glSeed = 0; -unsigned int seed_table[ 256 ] = +unsigned int seed_table[256] = { 28985, 27138, 26457, 9451, 17764, 10909, 28790, 8716, 6361, 4853, 17798, 21977, 19643, 20662, 10834, 20103, 27067, 28634, 18623, 25849, 8576, 26234, 23887, 18228, 32587, 4836, 3306, 1811, 3035, 24559, 18399, 315, @@ -188,16 +187,16 @@ unsigned int seed_table[ 256 ] = }; unsigned int U_Random( void ) -{ +{ glSeed *= 69069; - glSeed += seed_table[ glSeed & 0xff ]; - - return ( ++glSeed & 0x0fffffff ); + glSeed += seed_table[glSeed & 0xff]; + + return ( ++glSeed & 0x0fffffff ); } void U_Srand( unsigned int seed ) { - glSeed = seed_table[ seed & 0xff ]; + glSeed = seed_table[seed & 0xff]; } /* @@ -212,7 +211,7 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ) U_Srand( (int)seed + low + high ); range = high - low + 1; - if ( !(range - 1) ) + if( !( range - 1 ) ) { return low; } @@ -225,7 +224,7 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ) offset = rnum % range; - return (low + offset); + return ( low + offset ); } } @@ -236,7 +235,6 @@ UTIL_SharedRandomFloat */ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) { - // unsigned int range; U_Srand( (int)seed + *(int *)&low + *(int *)&high ); @@ -245,7 +243,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) U_Random(); range = high - low; - if ( !range ) + if( !range ) { return low; } @@ -258,7 +256,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) offset = (float)tensixrand / 65536.0; - return (low + offset * range ); + return ( low + offset * range ); } } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index c924d8b4..7e1fdd77 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -20,7 +20,7 @@ extern "C" void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed ); } -void COM_Log( char *pszFile, char *fmt, ...); +void COM_Log( char *pszFile, char *fmt, ... ); int CL_IsDead( void ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); @@ -34,9 +34,8 @@ void HUD_SetMaxSpeed( const struct edict_s *ed, float speed ); int stub_PrecacheModel( char* s ); int stub_PrecacheSound( char* s ); unsigned short stub_PrecacheEvent( int type, const char *s ); -const char *stub_NameForFunction ( unsigned long function ); -void stub_SetModel ( struct edict_s *e, const char *m ); - +const char *stub_NameForFunction( unsigned long function ); +void stub_SetModel( struct edict_s *e, const char *m ); extern cvar_t *cl_lw; @@ -44,5 +43,4 @@ extern int g_runfuncs; extern vec3_t v_angles; extern float g_lastFOV; extern struct local_state_s *g_finalstate; - -#endif \ No newline at end of file +#endif diff --git a/cl_dll/death.cpp b/cl_dll/death.cpp index 70c0393f..455dfd36 100644 --- a/cl_dll/death.cpp +++ b/cl_dll/death.cpp @@ -15,6 +15,7 @@ // // death notice // + #include "hud.h" #include "cl_util.h" #include "parsemsg.h" @@ -25,8 +26,8 @@ DECLARE_MESSAGE( m_DeathNotice, DeathMsg ) struct DeathNoticeItem { - char szKiller[MAX_PLAYER_NAME_LENGTH*2]; - char szVictim[MAX_PLAYER_NAME_LENGTH*2]; + char szKiller[MAX_PLAYER_NAME_LENGTH * 2]; + char szVictim[MAX_PLAYER_NAME_LENGTH * 2]; int iId; // the index number of the associated sprite int iSuicide; int iTeamKill; @@ -41,31 +42,30 @@ static int DEATHNOTICE_DISPLAY_TIME = 6; #define DEATHNOTICE_TOP 32 -DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ]; +DeathNoticeItem rgDeathNoticeList[MAX_DEATHNOTICES + 1]; float g_ColorBlue[3] = { 0.6, 0.8, 1.0 }; -float g_ColorRed[3] = { 1.0, 0.25, 0.25 }; +float g_ColorRed[3] = { 1.0, 0.25, 0.25 }; float g_ColorGreen[3] = { 0.6, 1.0, 0.6 }; float g_ColorYellow[3] = { 1.0, 0.7, 0.0 }; float g_ColorGrey[3] = { 0.8, 0.8, 0.8 }; float *GetClientColor( int clientIndex ) { - switch ( g_PlayerExtraInfo[clientIndex].teamnumber ) + switch( g_PlayerExtraInfo[clientIndex].teamnumber ) { case 1: return g_ColorBlue; case 2: return g_ColorRed; case 3: return g_ColorYellow; case 4: return g_ColorGreen; case 0: return g_ColorYellow; - - default : return g_ColorGrey; + default: return g_ColorGrey; } return NULL; } -int CHudDeathNotice :: Init( void ) +int CHudDeathNotice::Init( void ) { gHUD.AddHudElem( this ); @@ -76,33 +76,32 @@ int CHudDeathNotice :: Init( void ) return 1; } - -void CHudDeathNotice :: InitHUDData( void ) +void CHudDeathNotice::InitHUDData( void ) { memset( rgDeathNoticeList, 0, sizeof(rgDeathNoticeList) ); } - -int CHudDeathNotice :: VidInit( void ) +int CHudDeathNotice::VidInit( void ) { m_HUD_d_skull = gHUD.GetSpriteIndex( "d_skull" ); return 1; } -int CHudDeathNotice :: Draw( float flTime ) +int CHudDeathNotice::Draw( float flTime ) { int x, y, r, g, b; - for ( int i = 0; i < MAX_DEATHNOTICES; i++ ) + for( int i = 0; i < MAX_DEATHNOTICES; i++ ) { - if ( rgDeathNoticeList[i].iId == 0 ) + if( rgDeathNoticeList[i].iId == 0 ) break; // we've gone through them all - if ( rgDeathNoticeList[i].flDisplayTime < flTime ) - { // display time has expired + if( rgDeathNoticeList[i].flDisplayTime < flTime ) + { + // display time has expired // remove the current item from the list - memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) ); + memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i + 1], sizeof(DeathNoticeItem) * ( MAX_DEATHNOTICES - i ) ); i--; // continue on the next item; stop the counter getting incremented continue; } @@ -111,26 +110,26 @@ int CHudDeathNotice :: Draw( float flTime ) // Only draw if the viewport will let me // vgui dropped out - //if ( gViewPort && gViewPort->AllowedToPrintText() ) + //if( gViewPort && gViewPort->AllowedToPrintText() ) { // Draw the death notice - y = YRES(DEATHNOTICE_TOP) + 2 + (20 * i); //!!! + y = YRES( DEATHNOTICE_TOP ) + 2 + ( 20 * i ); //!!! - int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId; - x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); + int id = ( rgDeathNoticeList[i].iId == -1 ) ? m_HUD_d_skull : rgDeathNoticeList[i].iId; + x = ScreenWidth - ConsoleStringLen( rgDeathNoticeList[i].szVictim ) - ( gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left ); - if ( !rgDeathNoticeList[i].iSuicide ) + if( !rgDeathNoticeList[i].iSuicide ) { - x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) ); + x -= ( 5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) ); // Draw killers name - if ( rgDeathNoticeList[i].KillerColor ) + if( rgDeathNoticeList[i].KillerColor ) DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] ); x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller ); } - r = 255; g = 80; b = 0; - if ( rgDeathNoticeList[i].iTeamKill ) + r = 255; g = 80; b = 0; + if( rgDeathNoticeList[i].iTeamKill ) { r = 10; g = 240; b = 10; // display it in sickly green } @@ -139,12 +138,12 @@ int CHudDeathNotice :: Draw( float flTime ) SPR_Set( gHUD.GetSprite(id), r, g, b ); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) ); - x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); + x += ( gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left ); // Draw victims name (if it was a player that was killed) - if (rgDeathNoticeList[i].iNonPlayerKill == FALSE) + if( rgDeathNoticeList[i].iNonPlayerKill == FALSE ) { - if ( rgDeathNoticeList[i].VictimColor ) + if( rgDeathNoticeList[i].VictimColor ) DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] ); x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim ); } @@ -155,7 +154,7 @@ int CHudDeathNotice :: Draw( float flTime ) } // This message handler may be better off elsewhere -int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf ) +int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf ) { int i; m_iFlags |= HUD_ACTIVE; @@ -169,27 +168,27 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p strcpy( killedwith, "d_" ); strncat( killedwith, READ_STRING(), sizeof(killedwith) - strlen(killedwith) - 1 ); - gHUD.m_Spectator.DeathMessage(victim); + gHUD.m_Spectator.DeathMessage( victim ); - for ( i = 0; i < MAX_DEATHNOTICES; i++ ) + for( i = 0; i < MAX_DEATHNOTICES; i++ ) { - if ( rgDeathNoticeList[i].iId == 0 ) + if( rgDeathNoticeList[i].iId == 0 ) break; } - if ( i == MAX_DEATHNOTICES ) - { // move the rest of the list forward to make room for this item - memmove( rgDeathNoticeList, rgDeathNoticeList+1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES ); + if( i == MAX_DEATHNOTICES ) + { + // move the rest of the list forward to make room for this item + memmove( rgDeathNoticeList, rgDeathNoticeList + 1, sizeof(DeathNoticeItem) * MAX_DEATHNOTICES ); i = MAX_DEATHNOTICES - 1; } - //if (gViewPort) + //if(gViewPort) // gViewPort->GetAllPlayersInfo(); gHUD.m_Scoreboard.GetAllPlayersInfo(); - // Get the Killer's name - char *killer_name = g_PlayerInfoList[ killer ].name; - if ( !killer_name ) + char *killer_name = g_PlayerInfoList[killer].name; + if( !killer_name ) { killer_name = ""; rgDeathNoticeList[i].szKiller[0] = 0; @@ -198,14 +197,14 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p { rgDeathNoticeList[i].KillerColor = GetClientColor( killer ); strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH ); - rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH-1] = 0; + rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH - 1] = 0; } // Get the Victim's name char *victim_name = NULL; // If victim is -1, the killer killed a specific, non-player object (like a sentrygun) - if ( ((char)victim) != -1 ) - victim_name = g_PlayerInfoList[ victim ].name; + if ( ( (char)victim ) != -1 ) + victim_name = g_PlayerInfoList[victim].name; if ( !victim_name ) { victim_name = ""; @@ -215,16 +214,16 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p { rgDeathNoticeList[i].VictimColor = GetClientColor( victim ); strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH ); - rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH-1] = 0; + rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH - 1] = 0; } // Is it a non-player object kill? - if ( ((char)victim) == -1 ) + if ( ( (char)victim ) == -1 ) { rgDeathNoticeList[i].iNonPlayerKill = TRUE; // Store the object's name in the Victim slot (skip the d_ bit) - strcpy( rgDeathNoticeList[i].szVictim, killedwith+2 ); + strcpy( rgDeathNoticeList[i].szVictim, killedwith + 2 ); } else { @@ -243,7 +242,7 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p DEATHNOTICE_DISPLAY_TIME = CVAR_GET_FLOAT( "hud_deathnotice_time" ); rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME; - if (rgDeathNoticeList[i].iNonPlayerKill) + if( rgDeathNoticeList[i].iNonPlayerKill ) { ConsolePrint( rgDeathNoticeList[i].szKiller ); ConsolePrint( " killed a " ); @@ -253,11 +252,11 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p else { // record the death notice in the console - if ( rgDeathNoticeList[i].iSuicide ) + if( rgDeathNoticeList[i].iSuicide ) { ConsolePrint( rgDeathNoticeList[i].szVictim ); - if ( !strcmp( killedwith, "d_world" ) ) + if( !strcmp( killedwith, "d_world" ) ) { ConsolePrint( " died" ); } @@ -266,7 +265,7 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p ConsolePrint( " killed self" ); } } - else if ( rgDeathNoticeList[i].iTeamKill ) + else if( rgDeathNoticeList[i].iTeamKill ) { ConsolePrint( rgDeathNoticeList[i].szKiller ); ConsolePrint( " killed his teammate " ); @@ -279,17 +278,17 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p ConsolePrint( rgDeathNoticeList[i].szVictim ); } - if ( *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill ) + if( *killedwith && (*killedwith > 13 ) && strcmp( killedwith, "d_world" ) && !rgDeathNoticeList[i].iTeamKill ) { ConsolePrint( " with " ); // replace the code names with the 'real' names - if ( !strcmp( killedwith+2, "egon" ) ) + if( !strcmp( killedwith + 2, "egon" ) ) strcpy( killedwith, "d_gluon gun" ); - if ( !strcmp( killedwith+2, "gauss" ) ) + if ( !strcmp( killedwith + 2, "gauss" ) ) strcpy( killedwith, "d_tau cannon" ); - ConsolePrint( killedwith+2 ); // skip over the "d_" part + ConsolePrint( killedwith + 2 ); // skip over the "d_" part } ConsolePrint( "\n" ); @@ -297,7 +296,3 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p return 1; } - - - - diff --git a/cl_dll/demo.cpp b/cl_dll/demo.cpp index dfa7f8ef..f114ead0 100644 --- a/cl_dll/demo.cpp +++ b/cl_dll/demo.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "hud.h" #include "cl_util.h" #include "demo.h" @@ -41,14 +42,14 @@ Write some data to the demo stream void Demo_WriteBuffer( int type, int size, unsigned char *buffer ) { int pos = 0; - unsigned char buf[ 32 * 1024 ]; - *( int * )&buf[pos] = type; - pos+=sizeof( int ); + unsigned char buf[32 * 1024]; + *(int *)&buf[pos] = type; + pos += sizeof(int); memcpy( &buf[pos], buffer, size ); // Write full buffer out - gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof( int ), buf ); + gEngfuncs.pDemoAPI->WriteBuffer( size + sizeof(int), buf ); } /* @@ -63,36 +64,36 @@ void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer ) int type; int i = 0; - type = *( int * )buffer; - i += sizeof( int ); - switch ( type ) + type = *(int *)buffer; + i += sizeof(int); + switch( type ) { case TYPE_SNIPERDOT: - g_demosniper = *(int * )&buffer[ i ]; - i += sizeof( int ); + g_demosniper = *(int *)&buffer[i]; + i += sizeof(int); - if ( g_demosniper ) + if( g_demosniper ) { - g_demosniperdamage = *( int * )&buffer[ i ]; - i += sizeof( int ); + g_demosniperdamage = *(int *)&buffer[i]; + i += sizeof(int); - g_demosniperangles[ 0 ] = *(float *)&buffer[i]; - i += sizeof( float ); - g_demosniperangles[ 1 ] = *(float *)&buffer[i]; - i += sizeof( float ); - g_demosniperangles[ 2 ] = *(float *)&buffer[i]; - i += sizeof( float ); - g_demosniperorg[ 0 ] = *(float *)&buffer[i]; - i += sizeof( float ); - g_demosniperorg[ 1 ] = *(float *)&buffer[i]; - i += sizeof( float ); - g_demosniperorg[ 2 ] = *(float *)&buffer[i]; - i += sizeof( float ); + g_demosniperangles[0] = *(float *)&buffer[i]; + i += sizeof(float); + g_demosniperangles[1] = *(float *)&buffer[i]; + i += sizeof(float); + g_demosniperangles[2] = *(float *)&buffer[i]; + i += sizeof(float); + g_demosniperorg[0] = *(float *)&buffer[i]; + i += sizeof(float); + g_demosniperorg[1] = *(float *)&buffer[i]; + i += sizeof(float); + g_demosniperorg[2] = *(float *)&buffer[i]; + i += sizeof(float); } break; case TYPE_ZOOM: - g_demozoom = *(float * )&buffer[ i ]; - i += sizeof( float ); + g_demozoom = *(float *)&buffer[i]; + i += sizeof(float); break; default: gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" ); diff --git a/cl_dll/demo.h b/cl_dll/demo.h index 3163ef38..a0a1b30e 100644 --- a/cl_dll/demo.h +++ b/cl_dll/demo.h @@ -23,5 +23,4 @@ extern int g_demosniperdamage; extern float g_demosniperorg[3]; extern float g_demosniperangles[3]; extern float g_demozoom; - -#endif \ No newline at end of file +#endif diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 8dbdd383..07bd0ff3 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -20,14 +20,13 @@ #include "pmtrace.h" #include "pm_shared.h" - void Game_AddObjects( void ); extern vec3_t v_origin; int g_iAlive = 1; -extern "C" +extern "C" { int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname ); void DLLEXPORT HUD_CreateEntities( void ); @@ -47,7 +46,7 @@ HUD_AddEntity */ int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname ) { - switch ( type ) + switch( type ) { case ET_NORMAL: case ET_PLAYER: @@ -62,14 +61,13 @@ int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *mode // each frame every entity passes this function, so the overview hooks // it to filter the overview entities - if ( g_iUser1 ) + if( g_iUser1 ) { gHUD.m_Spectator.AddOverviewEntity( type, ent, modelname ); - if ( ( g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) && + if( ( g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) && ent->index == g_iUser2 ) return 0; // don't draw the player we are following in eye - } return 1; @@ -115,16 +113,16 @@ void DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct VectorCopy( src->velocity, dst->velocity ); - dst->frame = src->frame; + dst->frame = src->frame; dst->modelindex = src->modelindex; - dst->skin = src->skin; + dst->skin = src->skin; dst->effects = src->effects; dst->weaponmodel = src->weaponmodel; dst->movetype = src->movetype; dst->sequence = src->sequence; dst->animtime = src->animtime; - dst->solid = src->solid; + dst->solid = src->solid; dst->rendermode = src->rendermode; dst->renderamt = src->renderamt; @@ -134,10 +132,10 @@ void DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct dst->renderfx = src->renderfx; dst->framerate = src->framerate; - dst->body = src->body; + dst->body = src->body; - memcpy( &dst->controller[0], &src->controller[0], 4 * sizeof( byte ) ); - memcpy( &dst->blending[0], &src->blending[0], 2 * sizeof( byte ) ); + memcpy( &dst->controller[0], &src->controller[0], 4 * sizeof(byte) ); + memcpy( &dst->blending[0], &src->blending[0], 2 * sizeof(byte) ); VectorCopy( src->basevelocity, dst->basevelocity ); @@ -147,12 +145,12 @@ void DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct dst->spectator = src->spectator; dst->usehull = src->usehull; dst->playerclass = src->playerclass; - dst->team = src->team; + dst->team = src->team; dst->colormap = src->colormap; // Save off some data so other areas of the Client DLL can get to it cl_entity_t *player = gEngfuncs.GetLocalPlayer(); // Get the local player's index - if ( dst->number == player->index ) + if( dst->number == player->index ) { g_iPlayerClass = dst->playerclass; g_iTeamNumber = dst->team; @@ -173,7 +171,7 @@ Because we can predict an arbitrary number of frames before the server responds update is occupying. ========================= */ -void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd ) +void DLLEXPORT HUD_TxferPredictionData( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd ) { ps->oldbuttons = pps->oldbuttons; ps->flFallVelocity = pps->flFallVelocity; @@ -181,13 +179,13 @@ void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct ps->playerclass = pps->playerclass; pcd->viewmodel = ppcd->viewmodel; - pcd->m_iId = ppcd->m_iId; + pcd->m_iId = ppcd->m_iId; pcd->ammo_shells = ppcd->ammo_shells; pcd->ammo_nails = ppcd->ammo_nails; pcd->ammo_cells = ppcd->ammo_cells; pcd->ammo_rockets = ppcd->ammo_rockets; pcd->m_flNextAttack = ppcd->m_flNextAttack; - pcd->fov = ppcd->fov; + pcd->fov = ppcd->fov; pcd->weaponanim = ppcd->weaponanim; pcd->tfstate = ppcd->tfstate; pcd->maxspeed = ppcd->maxspeed; @@ -204,18 +202,17 @@ void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct // Duck prevention pcd->iuser3 = ppcd->iuser3; - if ( gEngfuncs.IsSpectateOnly() ) + if( gEngfuncs.IsSpectateOnly() ) { // in specator mode we tell the engine who we want to spectate and how // iuser3 is not used for duck prevention (since the spectator can't duck at all) pcd->iuser1 = g_iUser1; // observer mode pcd->iuser2 = g_iUser2; // first target pcd->iuser3 = g_iUser3; // second target - } // Fire prevention - pcd->iuser4 = ppcd->iuser4; + pcd->iuser4 = ppcd->iuser4; pcd->fuser2 = ppcd->fuser2; pcd->fuser3 = ppcd->fuser3; @@ -225,7 +222,7 @@ void DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct VectorCopy( ppcd->vuser3, pcd->vuser3 ); VectorCopy( ppcd->vuser4, pcd->vuser4 ); - memcpy( wd, pwd, 32 * sizeof( weapon_data_t ) ); + memcpy( wd, pwd, 32 * sizeof(weapon_data_t) ); } /* @@ -243,35 +240,33 @@ void MoveModel( void ) // Load it up with some bogus data player = gEngfuncs.GetLocalPlayer(); - if ( !player ) + if( !player ) return; mod = gEngfuncs.CL_LoadModel( "models/sentry3.mdl", &modelindex ); - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - for ( j = 0; j < 3; j++ ) + for( j = 0; j < 3; j++ ) { // Don't draw over ourself... - if ( ( i == 1 ) && ( j == 1 ) ) + if( ( i == 1 ) && ( j == 1 ) ) continue; - mymodel[ i * 3 + j ] = *player; + mymodel[i * 3 + j] = *player; - mymodel[ i * 3 + j ].player = 0; + mymodel[i * 3 + j].player = 0; - mymodel[ i * 3 + j ].model = mod; - mymodel[ i * 3 + j ].curstate.modelindex = modelindex; + mymodel[i * 3 + j].model = mod; + mymodel[i * 3 + j].curstate.modelindex = modelindex; - // Move it out a bit - mymodel[ i * 3 + j ].origin[0] = player->origin[0] + 50 * ( 1 - i ); - mymodel[ i * 3 + j ].origin[1] = player->origin[1] + 50 * ( 1 - j ); + // Move it out a bit + mymodel[i * 3 + j].origin[0] = player->origin[0] + 50 * ( 1 - i ); + mymodel[i * 3 + j].origin[1] = player->origin[1] + 50 * ( 1 - j ); - gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, &mymodel[i*3+j] ); + gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, &mymodel[i * 3 + j] ); } } - } - #endif //#define TRACE_TEST @@ -285,12 +280,12 @@ void TraceModel( void ) { cl_entity_t *ent; - if ( hitent <= 0 ) + if( hitent <= 0 ) return; // Load it up with some bogus data ent = gEngfuncs.GetEntityByIndex( hitent ); - if ( !ent ) + if( !ent ) return; hit = *ent; @@ -302,7 +297,6 @@ void TraceModel( void ) gEngfuncs.CL_CreateVisibleEntity( ET_NORMAL, &hit ); } - #endif */ @@ -311,9 +305,9 @@ void ParticleCallback( struct particle_s *particle, float frametime ) { int i; - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - particle->org[ i ] += particle->vel[ i ] * frametime; + particle->org[i] += particle->vel[i] * frametime; } } @@ -322,13 +316,13 @@ void Particles( void ) { static float lasttime; float curtime; - + curtime = gEngfuncs.GetClientTime(); - if ( ( curtime - lasttime ) < 2.0 ) + if( ( curtime - lasttime ) < 2.0 ) return; - if ( !color ) + if( !color ) { color = gEngfuncs.pfnRegisterVariable ( "color","255 0 0", 0 ); } @@ -339,20 +333,20 @@ void Particles( void ) particle_t *p; int i, j; - for ( i = 0; i < 1000; i++ ) + for( i = 0; i < 1000; i++ ) { int r, g, b; p = gEngfuncs.pEfxAPI->R_AllocParticle( ParticleCallback ); - if ( !p ) + if( !p ) break; - for ( j = 0; j < 3; j++ ) + for( j = 0; j < 3; j++ ) { - p->org[ j ] = v_origin[ j ] + gEngfuncs.pfnRandomFloat( -32.0, 32.0 );; - p->vel[ j ] = gEngfuncs.pfnRandomFloat( -100.0, 100.0 ); + p->org[j] = v_origin[j] + gEngfuncs.pfnRandomFloat( -32.0, 32.0 ); + p->vel[j] = gEngfuncs.pfnRandomFloat( -100.0, 100.0 ); } - if ( color ) + if( color ) { sscanf( color->string, "%i %i %i", &r, &g, &b ); } @@ -363,7 +357,7 @@ void Particles( void ) b = 0; } - p->color = gEngfuncs.pEfxAPI->R_LookupColor( r, g, b ); + p->color = gEngfuncs.pEfxAPI->R_LookupColor( r, g, b ); gEngfuncs.pEfxAPI->R_GetPackedColor( &p->packedColor, p->color ); // p->die is set to current time so all you have to do is add an additional time to it @@ -373,13 +367,13 @@ void Particles( void ) */ /* -void TempEntCallback ( struct tempent_s *ent, float frametime, float currenttime ) +void TempEntCallback( struct tempent_s *ent, float frametime, float currenttime ) { int i; - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - ent->entity.curstate.origin[ i ] += ent->entity.baseline.origin[ i ] * frametime; + ent->entity.curstate.origin[i] += ent->entity.baseline.origin[i] * frametime; } } @@ -387,10 +381,10 @@ void TempEnts( void ) { static float lasttime; float curtime; - + curtime = gEngfuncs.GetClientTime(); - if ( ( curtime - lasttime ) < 10.0 ) + if( ( curtime - lasttime ) < 10.0 ) return; lasttime = curtime; @@ -403,27 +397,27 @@ void TempEnts( void ) mod = gEngfuncs.CL_LoadModel( "sprites/laserdot.spr", &index ); - for ( i = 0; i < 100; i++ ) + for( i = 0; i < 100; i++ ) { - for ( j = 0; j < 3; j++ ) + for( j = 0; j < 3; j++ ) { - origin[ j ] = v_origin[ j ]; - if ( j != 2 ) + origin[j] = v_origin[j]; + if( j != 2 ) { - origin[ j ] += 75; + origin[j] += 75; } } p = gEngfuncs.pEfxAPI->CL_TentEntAllocCustom( (float *)&origin, mod, 0, TempEntCallback ); - if ( !p ) + if( !p ) break; - for ( j = 0; j < 3; j++ ) + for( j = 0; j < 3; j++ ) { - p->entity.curstate.origin[ j ] = origin[ j ]; + p->entity.curstate.origin[j] = origin[j]; // Store velocity in baseline origin - p->entity.baseline.origin[ j ] = gEngfuncs.pfnRandomFloat( -100, 100 ); + p->entity.baseline.origin[j] = gEngfuncs.pfnRandomFloat( -100, 100 ); } // p->die is set to current time so all you have to do is add an additional time to it @@ -433,9 +427,9 @@ void TempEnts( void ) */ #if defined( BEAM_TEST ) -// Note can't index beam[ 0 ] in Beam callback, so don't use that index +// Note can't index beam[0] in Beam callback, so don't use that index // Room for 1 beam ( 0 can't be used ) -static cl_entity_t beams[ 2 ]; +static cl_entity_t beams[2]; void BeamEndModel( void ) { @@ -445,21 +439,21 @@ void BeamEndModel( void ) // Load it up with some bogus data player = gEngfuncs.GetLocalPlayer(); - if ( !player ) + if( !player ) return; mod = gEngfuncs.CL_LoadModel( "models/sentry3.mdl", &modelindex ); - if ( !mod ) + if( !mod ) return; // Slot 1 - model = &beams[ 1 ]; + model = &beams[1]; *model = *player; model->player = 0; model->model = mod; model->curstate.modelindex = modelindex; - + // Move it out a bit model->origin[0] = player->origin[0] - 100; model->origin[1] = player->origin[1]; @@ -480,22 +474,22 @@ void Beams( void ) int index; BeamEndModel(); - - curtime = gEngfuncs.GetClientTime(); - float end[ 3 ]; - if ( ( curtime - lasttime ) < 10.0 ) + curtime = gEngfuncs.GetClientTime(); + float end[3]; + + if( ( curtime - lasttime ) < 10.0 ) return; mod = gEngfuncs.CL_LoadModel( "sprites/laserbeam.spr", &index ); - if ( !mod ) + if( !mod ) return; lasttime = curtime; - end [ 0 ] = v_origin.x + 100; - end [ 1 ] = v_origin.y + 100; - end [ 2 ] = v_origin.z; + end[0] = v_origin.x + 100; + end[1] = v_origin.y + 100; + end[2] = v_origin.z; BEAM *p1; p1 = gEngfuncs.pEfxAPI->R_BeamEntPoint( -1, end, index, @@ -519,7 +513,6 @@ void DLLEXPORT HUD_CreateEntities( void ) #if defined( TEST_IT ) MoveModel(); #endif - #if defined( TRACE_TEST ) TraceModel(); #endif @@ -530,11 +523,9 @@ void DLLEXPORT HUD_CreateEntities( void ) /* TempEnts(); */ - #if defined( BEAM_TEST ) Beams(); #endif - // Add in any game specific objects Game_AddObjects(); } @@ -552,19 +543,19 @@ void DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct switch( event->event ) { case 5001: - gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[0], atoi( event->options) ); + gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[0], atoi( event->options ) ); break; case 5011: - gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[1], atoi( event->options) ); + gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[1], atoi( event->options ) ); break; case 5021: - gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[2], atoi( event->options) ); + gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[2], atoi( event->options ) ); break; case 5031: - gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[3], atoi( event->options) ); + gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[3], atoi( event->options ) ); break; case 5002: - gEngfuncs.pEfxAPI->R_SparkEffect( (float *)&entity->attachment[0], atoi( event->options), -100, 100 ); + gEngfuncs.pEfxAPI->R_SparkEffect( (float *)&entity->attachment[0], atoi( event->options ), -100, 100 ); break; // Client side sound case 5004: @@ -610,19 +601,19 @@ void DLLEXPORT HUD_TempEntUpdate ( gEngfuncs.pEventAPI->EV_PushPMStates(); // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( -1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( -1 ); // !!!BUGBUG -- This needs to be time based - gTempEntFrame = (gTempEntFrame+1) & 31; + gTempEntFrame = ( gTempEntFrame + 1 ) & 31; pTemp = *ppTempEntActive; // !!! Don't simulate while paused.... This is sort of a hack, revisit. - if ( frametime <= 0 ) + if( frametime <= 0 ) { - while ( pTemp ) + while( pTemp ) { - if ( !(pTemp->flags & FTENT_NOMODEL ) ) + if( !( pTemp->flags & FTENT_NOMODEL ) ) { Callback_AddVisibleEntity( &pTemp->entity ); } @@ -637,7 +628,7 @@ void DLLEXPORT HUD_TempEntUpdate ( gravity = -frametime * cl_gravity; gravitySlow = gravity * 0.5; - while ( pTemp ) + while( pTemp ) { int active; @@ -645,25 +636,24 @@ void DLLEXPORT HUD_TempEntUpdate ( life = pTemp->die - client_time; pnext = pTemp->next; - if ( life < 0 ) + if( life < 0 ) { - if ( pTemp->flags & FTENT_FADEOUT ) + if( pTemp->flags & FTENT_FADEOUT ) { - if (pTemp->entity.curstate.rendermode == kRenderNormal) + if( pTemp->entity.curstate.rendermode == kRenderNormal) pTemp->entity.curstate.rendermode = kRenderTransTexture; pTemp->entity.curstate.renderamt = pTemp->entity.baseline.renderamt * ( 1 + life * pTemp->fadeSpeed ); - if ( pTemp->entity.curstate.renderamt <= 0 ) + if( pTemp->entity.curstate.renderamt <= 0 ) active = 0; - } else active = 0; } - if ( !active ) // Kill it + if( !active ) // Kill it { pTemp->next = *ppTempEntFree; *ppTempEntFree = pTemp; - if ( !pprev ) // Deleting at head of list + if( !pprev ) // Deleting at head of list *ppTempEntActive = pnext; else pprev->next = pnext; @@ -671,14 +661,14 @@ void DLLEXPORT HUD_TempEntUpdate ( else { pprev = pTemp; - + VectorCopy( pTemp->entity.origin, pTemp->entity.prevstate.origin ); - if ( pTemp->flags & FTENT_SPARKSHOWER ) + if( pTemp->flags & FTENT_SPARKSHOWER ) { // Adjust speed if it's time // Scale is next think time - if ( client_time > pTemp->entity.baseline.scale ) + if( client_time > pTemp->entity.baseline.scale ) { // Show Sparks gEngfuncs.pEfxAPI->R_SparkEffect( pTemp->entity.origin, 8, -200, 200 ); @@ -686,7 +676,7 @@ void DLLEXPORT HUD_TempEntUpdate ( // Reduce life pTemp->entity.baseline.framerate -= 0.1; - if ( pTemp->entity.baseline.framerate <= 0.0 ) + if( pTemp->entity.baseline.framerate <= 0.0 ) { pTemp->die = client_time; } @@ -700,7 +690,7 @@ void DLLEXPORT HUD_TempEntUpdate ( } } } - else if ( pTemp->flags & FTENT_PLYRATTACHMENT ) + else if( pTemp->flags & FTENT_PLYRATTACHMENT ) { cl_entity_t *pClient; @@ -708,16 +698,16 @@ void DLLEXPORT HUD_TempEntUpdate ( VectorAdd( pClient->origin, pTemp->tentOffset, pTemp->entity.origin ); } - else if ( pTemp->flags & FTENT_SINEWAVE ) + else if( pTemp->flags & FTENT_SINEWAVE ) { pTemp->x += pTemp->entity.baseline.origin[0] * frametime; pTemp->y += pTemp->entity.baseline.origin[1] * frametime; - pTemp->entity.origin[0] = pTemp->x + sin( pTemp->entity.baseline.origin[2] + client_time * pTemp->entity.prevstate.frame ) * (10*pTemp->entity.curstate.framerate); - pTemp->entity.origin[1] = pTemp->y + sin( pTemp->entity.baseline.origin[2] + fastFreq + 0.7 ) * (8*pTemp->entity.curstate.framerate); + pTemp->entity.origin[0] = pTemp->x + sin( pTemp->entity.baseline.origin[2] + client_time * pTemp->entity.prevstate.frame ) * ( 10 * pTemp->entity.curstate.framerate ); + pTemp->entity.origin[1] = pTemp->y + sin( pTemp->entity.baseline.origin[2] + fastFreq + 0.7 ) * ( 8 * pTemp->entity.curstate.framerate ); pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime; } - else if ( pTemp->flags & FTENT_SPIRAL ) + else if( pTemp->flags & FTENT_SPIRAL ) { float s, c; s = sin( pTemp->entity.baseline.origin[2] + fastFreq ); @@ -727,21 +717,20 @@ void DLLEXPORT HUD_TempEntUpdate ( pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)(size_t)pTemp ); pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime; } - else { - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) pTemp->entity.origin[i] += pTemp->entity.baseline.origin[i] * frametime; } - if ( pTemp->flags & FTENT_SPRANIMATE ) + if( pTemp->flags & FTENT_SPRANIMATE ) { pTemp->entity.curstate.frame += frametime * pTemp->entity.curstate.framerate; - if ( pTemp->entity.curstate.frame >= pTemp->frameMax ) + if( pTemp->entity.curstate.frame >= pTemp->frameMax ) { - pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)(pTemp->entity.curstate.frame); + pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)( pTemp->entity.curstate.frame ); - if ( !(pTemp->flags & FTENT_SPRANIMATELOOP) ) + if( !( pTemp->flags & FTENT_SPRANIMATELOOP ) ) { // this animating sprite isn't set to loop, so destroy it. pTemp->die = client_time; @@ -750,21 +739,21 @@ void DLLEXPORT HUD_TempEntUpdate ( } } } - else if ( pTemp->flags & FTENT_SPRCYCLE ) + else if( pTemp->flags & FTENT_SPRCYCLE ) { pTemp->entity.curstate.frame += frametime * 10; - if ( pTemp->entity.curstate.frame >= pTemp->frameMax ) + if( pTemp->entity.curstate.frame >= pTemp->frameMax ) { - pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)(pTemp->entity.curstate.frame); + pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)( pTemp->entity.curstate.frame ); } } // Experiment #if 0 - if ( pTemp->flags & FTENT_SCALE ) - pTemp->entity.curstate.framerate += 20.0 * (frametime / pTemp->entity.curstate.framerate); + if( pTemp->flags & FTENT_SCALE ) + pTemp->entity.curstate.framerate += 20.0 * ( frametime / pTemp->entity.curstate.framerate ); #endif - if ( pTemp->flags & FTENT_ROTATE ) + if( pTemp->flags & FTENT_ROTATE ) { pTemp->entity.angles[0] += pTemp->entity.baseline.angles[0] * frametime; pTemp->entity.angles[1] += pTemp->entity.baseline.angles[1] * frametime; @@ -773,98 +762,97 @@ void DLLEXPORT HUD_TempEntUpdate ( VectorCopy( pTemp->entity.angles, pTemp->entity.latched.prevangles ); } - if ( pTemp->flags & (FTENT_COLLIDEALL | FTENT_COLLIDEWORLD) ) + if( pTemp->flags & ( FTENT_COLLIDEALL | FTENT_COLLIDEWORLD ) ) { vec3_t traceNormal( 0.0f, 0.0f, 0.0f ); float traceFraction = 1; - if ( pTemp->flags & FTENT_COLLIDEALL ) + if( pTemp->flags & FTENT_COLLIDEALL ) { pmtrace_t pmtrace; physent_t *pe; - + gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX, -1, &pmtrace ); - - if ( pmtrace.fraction != 1 ) + if( pmtrace.fraction != 1 ) { pe = gEngfuncs.pEventAPI->EV_GetPhysent( pmtrace.ent ); - if ( !pmtrace.ent || ( pe->info != pTemp->clientIndex ) ) + if( !pmtrace.ent || ( pe->info != pTemp->clientIndex ) ) { traceFraction = pmtrace.fraction; VectorCopy( pmtrace.plane.normal, traceNormal ); - if ( pTemp->hitcallback ) + if( pTemp->hitcallback ) { (*pTemp->hitcallback)( pTemp, &pmtrace ); } } } } - else if ( pTemp->flags & FTENT_COLLIDEWORLD ) + else if( pTemp->flags & FTENT_COLLIDEWORLD ) { pmtrace_t pmtrace; - + gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX | PM_WORLD_ONLY, -1, &pmtrace ); + gEngfuncs.pEventAPI->EV_PlayerTrace( pTemp->entity.prevstate.origin, pTemp->entity.origin, PM_STUDIO_BOX | PM_WORLD_ONLY, -1, &pmtrace ); - if ( pmtrace.fraction != 1 ) + if( pmtrace.fraction != 1 ) { traceFraction = pmtrace.fraction; VectorCopy( pmtrace.plane.normal, traceNormal ); - if ( pTemp->flags & FTENT_SPARKSHOWER ) + if( pTemp->flags & FTENT_SPARKSHOWER ) { // Chop spark speeds a bit more // VectorScale( pTemp->entity.baseline.origin, 0.6, pTemp->entity.baseline.origin ); - if ( Length( pTemp->entity.baseline.origin ) < 10 ) + if( Length( pTemp->entity.baseline.origin ) < 10 ) { pTemp->entity.baseline.framerate = 0.0; } } - if ( pTemp->hitcallback ) + if( pTemp->hitcallback ) { (*pTemp->hitcallback)( pTemp, &pmtrace ); } } } - if ( traceFraction != 1 ) // Decent collision now, and damping works + if( traceFraction != 1 ) // Decent collision now, and damping works { float proj, damp; // Place at contact point - VectorMA( pTemp->entity.prevstate.origin, traceFraction*frametime, pTemp->entity.baseline.origin, pTemp->entity.origin ); + VectorMA( pTemp->entity.prevstate.origin, traceFraction * frametime, pTemp->entity.baseline.origin, pTemp->entity.origin ); // Damp velocity damp = pTemp->bounceFactor; - if ( pTemp->flags & (FTENT_GRAVITY|FTENT_SLOWGRAVITY) ) + if( pTemp->flags & ( FTENT_GRAVITY | FTENT_SLOWGRAVITY ) ) { damp *= 0.5; - if ( traceNormal[2] > 0.9 ) // Hit floor? + if( traceNormal[2] > 0.9 ) // Hit floor? { - if ( pTemp->entity.baseline.origin[2] <= 0 && pTemp->entity.baseline.origin[2] >= gravity*3 ) + if( pTemp->entity.baseline.origin[2] <= 0 && pTemp->entity.baseline.origin[2] >= gravity*3 ) { damp = 0; // Stop - pTemp->flags &= ~(FTENT_ROTATE|FTENT_GRAVITY|FTENT_SLOWGRAVITY|FTENT_COLLIDEWORLD|FTENT_SMOKETRAIL); + pTemp->flags &= ~( FTENT_ROTATE | FTENT_GRAVITY | FTENT_SLOWGRAVITY | FTENT_COLLIDEWORLD | FTENT_SMOKETRAIL); pTemp->entity.angles[0] = 0; pTemp->entity.angles[2] = 0; } } } - if (pTemp->hitSound) + if( pTemp->hitSound ) { - Callback_TempEntPlaySound(pTemp, damp); + Callback_TempEntPlaySound( pTemp, damp ); } - if (pTemp->flags & FTENT_COLLIDEKILL) + if( pTemp->flags & FTENT_COLLIDEKILL ) { // die on impact pTemp->flags &= ~FTENT_FADEOUT; @@ -873,16 +861,16 @@ void DLLEXPORT HUD_TempEntUpdate ( else { // Reflect velocity - if ( damp != 0 ) + if( damp != 0 ) { proj = DotProduct( pTemp->entity.baseline.origin, traceNormal ); - VectorMA( pTemp->entity.baseline.origin, -proj*2, traceNormal, pTemp->entity.baseline.origin ); + VectorMA( pTemp->entity.baseline.origin, -proj * 2, traceNormal, pTemp->entity.baseline.origin ); // Reflect rotation (fake) pTemp->entity.angles[1] = -pTemp->entity.angles[1]; } - if ( damp != 1 ) + if( damp != 1 ) { VectorScale( pTemp->entity.baseline.origin, damp, pTemp->entity.baseline.origin ); @@ -892,11 +880,10 @@ void DLLEXPORT HUD_TempEntUpdate ( } } - - if ( (pTemp->flags & FTENT_FLICKER) && gTempEntFrame == pTemp->entity.curstate.effects ) + if( ( pTemp->flags & FTENT_FLICKER ) && gTempEntFrame == pTemp->entity.curstate.effects ) { - dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight (0); - VectorCopy (pTemp->entity.origin, dl->origin); + dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight(0); + VectorCopy( pTemp->entity.origin, dl->origin ); dl->radius = 60; dl->color.r = 255; dl->color.g = 120; @@ -904,30 +891,30 @@ void DLLEXPORT HUD_TempEntUpdate ( dl->die = client_time + 0.01; } - if ( pTemp->flags & FTENT_SMOKETRAIL ) + if( pTemp->flags & FTENT_SMOKETRAIL ) { - gEngfuncs.pEfxAPI->R_RocketTrail (pTemp->entity.prevstate.origin, pTemp->entity.origin, 1); + gEngfuncs.pEfxAPI->R_RocketTrail( pTemp->entity.prevstate.origin, pTemp->entity.origin, 1 ); } - if ( pTemp->flags & FTENT_GRAVITY ) + if( pTemp->flags & FTENT_GRAVITY ) pTemp->entity.baseline.origin[2] += gravity; - else if ( pTemp->flags & FTENT_SLOWGRAVITY ) + else if( pTemp->flags & FTENT_SLOWGRAVITY ) pTemp->entity.baseline.origin[2] += gravitySlow; - if ( pTemp->flags & FTENT_CLIENTCUSTOM ) + if( pTemp->flags & FTENT_CLIENTCUSTOM ) { - if ( pTemp->callback ) + if( pTemp->callback ) { - ( *pTemp->callback )( pTemp, frametime, client_time ); + (*pTemp->callback)( pTemp, frametime, client_time ); } } // Cull to PVS (not frustum cull, just PVS) - if ( !(pTemp->flags & FTENT_NOMODEL ) ) + if( !( pTemp->flags & FTENT_NOMODEL ) ) { - if ( !Callback_AddVisibleEntity( &pTemp->entity ) ) + if( !Callback_AddVisibleEntity( &pTemp->entity ) ) { - if ( !(pTemp->flags & FTENT_PERSIST) ) + if( !( pTemp->flags & FTENT_PERSIST ) ) { pTemp->die = client_time; // If we can't draw it this frame, just dump it. pTemp->flags &= ~FTENT_FADEOUT; // Don't fade out, just die @@ -937,7 +924,6 @@ void DLLEXPORT HUD_TempEntUpdate ( } pTemp = pnext; } - finish: // Restore state info gEngfuncs.pEventAPI->EV_PopPMStates(); @@ -959,9 +945,9 @@ cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index ) #if defined( BEAM_TEST ) // None by default, you would return a valic pointer if you create a client side // beam and attach it to a client side entity. - if ( index > 0 && index <= 1 ) + if( index > 0 && index <= 1 ) { - return &beams[ index ]; + return &beams[index]; } else { @@ -971,4 +957,3 @@ cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index ) return NULL; #endif } - diff --git a/cl_dll/ev_common.cpp b/cl_dll/ev_common.cpp index e5826a49..ebba9cb2 100644 --- a/cl_dll/ev_common.cpp +++ b/cl_dll/ev_common.cpp @@ -13,6 +13,7 @@ * ****/ // shared event functions + #include "hud.h" #include "cl_util.h" #include "const.h" @@ -25,7 +26,7 @@ #include "event_api.h" #include "pm_shared.h" -#define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || (g_iUser1 && (gHUD.m_Spectator.m_pip->value == INSET_IN_EYE)) ) +#define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || ( g_iUser1 && ( gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) ) ) /* ================= GetEntity @@ -71,7 +72,7 @@ Is the entity's index in the player range? */ qboolean EV_IsPlayer( int idx ) { - if ( idx >= 1 && idx <= gEngfuncs.GetMaxClients() ) + if( idx >= 1 && idx <= gEngfuncs.GetMaxClients() ) return true; return false; @@ -87,8 +88,8 @@ Is the entity == the local player qboolean EV_IsLocal( int idx ) { // check if we are in some way in first person spec mode - if ( IS_FIRSTPERSON_SPEC ) - return (g_iUser2 == idx); + if( IS_FIRSTPERSON_SPEC ) + return ( g_iUser2 == idx ); else return gEngfuncs.pEventAPI->EV_IsLocal( idx - 1 ) ? true : false; } @@ -110,15 +111,15 @@ void EV_GetGunPosition( event_args_t *args, float *pos, float *origin ) VectorClear( view_ofs ); view_ofs[2] = DEFAULT_VIEWHEIGHT; - if ( EV_IsPlayer( idx ) ) + if( EV_IsPlayer( idx ) ) { // in spec mode use entity viewheigh, not own - if ( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC ) + if( EV_IsLocal( idx ) && !IS_FIRSTPERSON_SPEC ) { // Grab predicted result for local player gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); } - else if ( args->ducking == 1 ) + else if( args->ducking == 1 ) { view_ofs[2] = VEC_DUCK_VIEW; } @@ -162,13 +163,13 @@ void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, VectorClear( view_ofs ); view_ofs[2] = DEFAULT_VIEWHEIGHT; - if ( EV_IsPlayer( idx ) ) + if( EV_IsPlayer( idx ) ) { - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); } - else if ( args->ducking == 1 ) + else if( args->ducking == 1 ) { view_ofs[2] = VEC_DUCK_VIEW; } @@ -177,10 +178,10 @@ void EV_GetDefaultShellInfo( event_args_t *args, float *origin, float *velocity, fR = gEngfuncs.pfnRandomFloat( 50, 70 ); fU = gEngfuncs.pfnRandomFloat( 100, 150 ); - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { ShellVelocity[i] = velocity[i] + right[i] * fR + up[i] * fU + forward[i] * 25; - ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale; + ShellOrigin[i] = origin[i] + view_ofs[i] + up[i] * upScale + forward[i] * forwardScale + right[i] * rightScale; } } @@ -195,11 +196,11 @@ void EV_MuzzleFlash( void ) { // Add muzzle flash to current weapon model cl_entity_t *ent = GetViewEntity(); - if ( !ent ) + if( !ent ) { return; } // Or in the muzzle flash ent->curstate.effects |= EF_MUZZLEFLASH; -} \ No newline at end of file +} diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index bd20da95..a011ae4f 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "hud.h" #include "cl_util.h" #include "const.h" @@ -37,7 +38,7 @@ extern engine_studio_api_t IEngineStudio; -static int tracerCount[ 32 ]; +static int tracerCount[32]; extern "C" char PM_FindTextureType( char *name ); @@ -48,27 +49,25 @@ extern cvar_t *cl_lw; extern "C" { - // HLDM -void EV_FireGlock1( struct event_args_s *args ); -void EV_FireGlock2( struct event_args_s *args ); -void EV_FireShotGunSingle( struct event_args_s *args ); -void EV_FireShotGunDouble( struct event_args_s *args ); -void EV_FireMP5( struct event_args_s *args ); -void EV_FireMP52( struct event_args_s *args ); -void EV_FirePython( struct event_args_s *args ); -void EV_FireGauss( struct event_args_s *args ); -void EV_SpinGauss( struct event_args_s *args ); -void EV_Crowbar( struct event_args_s *args ); -void EV_FireCrossbow( struct event_args_s *args ); -void EV_FireCrossbow2( struct event_args_s *args ); -void EV_FireRpg( struct event_args_s *args ); -void EV_EgonFire( struct event_args_s *args ); -void EV_EgonStop( struct event_args_s *args ); -void EV_HornetGunFire( struct event_args_s *args ); -void EV_TripmineFire( struct event_args_s *args ); -void EV_SnarkFire( struct event_args_s *args ); - +void EV_FireGlock1( struct event_args_s *args ); +void EV_FireGlock2( struct event_args_s *args ); +void EV_FireShotGunSingle( struct event_args_s *args ); +void EV_FireShotGunDouble( struct event_args_s *args ); +void EV_FireMP5( struct event_args_s *args ); +void EV_FireMP52( struct event_args_s *args ); +void EV_FirePython( struct event_args_s *args ); +void EV_FireGauss( struct event_args_s *args ); +void EV_SpinGauss( struct event_args_s *args ); +void EV_Crowbar( struct event_args_s *args ); +void EV_FireCrossbow( struct event_args_s *args ); +void EV_FireCrossbow2( struct event_args_s *args ); +void EV_FireRpg( struct event_args_s *args ); +void EV_EgonFire( struct event_args_s *args ); +void EV_EgonStop( struct event_args_s *args ); +void EV_HornetGunFire( struct event_args_s *args ); +void EV_TripmineFire( struct event_args_s *args ); +void EV_SnarkFire( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); } @@ -100,96 +99,111 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v float fattn = ATTN_NORM; int entity; char *pTextureName; - char texname[ 64 ]; - char szbuffer[ 64 ]; + char texname[64]; + char szbuffer[64]; entity = gEngfuncs.pEventAPI->EV_IndexFromTrace( ptr ); // FIXME check if playtexture sounds movevar is set // - chTextureType = 0; // Player - if ( entity >= 1 && entity <= gEngfuncs.GetMaxClients() ) + if( entity >= 1 && entity <= gEngfuncs.GetMaxClients() ) { // hit body chTextureType = CHAR_TEX_FLESH; } - else if ( entity == 0 ) + else if( entity == 0 ) { // get texture from entity or world (world is ent(0)) pTextureName = (char *)gEngfuncs.pEventAPI->EV_TraceTexture( ptr->ent, vecSrc, vecEnd ); - + if ( pTextureName ) { strcpy( texname, pTextureName ); pTextureName = texname; // strip leading '-0' or '+0~' or '{' or '!' - if (*pTextureName == '-' || *pTextureName == '+') + if( *pTextureName == '-' || *pTextureName == '+' ) { pTextureName += 2; } - if (*pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ') + if( *pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ' ) { pTextureName++; } - + // '}}' strcpy( szbuffer, pTextureName ); - szbuffer[ CBTEXTURENAMEMAX - 1 ] = 0; - + szbuffer[CBTEXTURENAMEMAX - 1] = 0; + // get texture type - chTextureType = PM_FindTextureType( szbuffer ); + chTextureType = PM_FindTextureType( szbuffer ); } } switch (chTextureType) { default: - case CHAR_TEX_CONCRETE: fvol = 0.9; fvolbar = 0.6; + case CHAR_TEX_CONCRETE: + fvol = 0.9; + fvolbar = 0.6; rgsz[0] = "player/pl_step1.wav"; rgsz[1] = "player/pl_step2.wav"; cnt = 2; break; - case CHAR_TEX_METAL: fvol = 0.9; fvolbar = 0.3; + case CHAR_TEX_METAL: + fvol = 0.9; + fvolbar = 0.3; rgsz[0] = "player/pl_metal1.wav"; rgsz[1] = "player/pl_metal2.wav"; cnt = 2; break; - case CHAR_TEX_DIRT: fvol = 0.9; fvolbar = 0.1; + case CHAR_TEX_DIRT: + fvol = 0.9; + fvolbar = 0.1; rgsz[0] = "player/pl_dirt1.wav"; rgsz[1] = "player/pl_dirt2.wav"; rgsz[2] = "player/pl_dirt3.wav"; cnt = 3; break; - case CHAR_TEX_VENT: fvol = 0.5; fvolbar = 0.3; + case CHAR_TEX_VENT: + fvol = 0.5; + fvolbar = 0.3; rgsz[0] = "player/pl_duct1.wav"; rgsz[1] = "player/pl_duct1.wav"; cnt = 2; break; - case CHAR_TEX_GRATE: fvol = 0.9; fvolbar = 0.5; + case CHAR_TEX_GRATE: + fvol = 0.9; + fvolbar = 0.5; rgsz[0] = "player/pl_grate1.wav"; rgsz[1] = "player/pl_grate4.wav"; cnt = 2; break; - case CHAR_TEX_TILE: fvol = 0.8; fvolbar = 0.2; + case CHAR_TEX_TILE: + fvol = 0.8; + fvolbar = 0.2; rgsz[0] = "player/pl_tile1.wav"; rgsz[1] = "player/pl_tile3.wav"; rgsz[2] = "player/pl_tile2.wav"; rgsz[3] = "player/pl_tile4.wav"; cnt = 4; break; - case CHAR_TEX_SLOSH: fvol = 0.9; fvolbar = 0.0; + case CHAR_TEX_SLOSH: + fvol = 0.9; + fvolbar = 0.0; rgsz[0] = "player/pl_slosh1.wav"; rgsz[1] = "player/pl_slosh3.wav"; rgsz[2] = "player/pl_slosh2.wav"; rgsz[3] = "player/pl_slosh4.wav"; cnt = 4; break; - case CHAR_TEX_WOOD: fvol = 0.9; fvolbar = 0.2; + case CHAR_TEX_WOOD: + fvol = 0.9; + fvolbar = 0.2; rgsz[0] = "debris/wood1.wav"; rgsz[1] = "debris/wood2.wav"; rgsz[2] = "debris/wood3.wav"; @@ -197,16 +211,18 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v break; case CHAR_TEX_GLASS: case CHAR_TEX_COMPUTER: - fvol = 0.8; fvolbar = 0.2; + fvol = 0.8; + fvolbar = 0.2; rgsz[0] = "debris/glass1.wav"; rgsz[1] = "debris/glass2.wav"; rgsz[2] = "debris/glass3.wav"; cnt = 3; break; case CHAR_TEX_FLESH: - if (iBulletType == BULLET_PLAYER_CROWBAR) + if( iBulletType == BULLET_PLAYER_CROWBAR ) return 0.0; // crowbar already makes this sound - fvol = 1.0; fvolbar = 0.2; + fvol = 1.0; + fvolbar = 0.2; rgsz[0] = "weapons/bullet_hit1.wav"; rgsz[1] = "weapons/bullet_hit2.wav"; fattn = 1.0; @@ -215,21 +231,21 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v } // play material hit sound - gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, rgsz[gEngfuncs.pfnRandomLong(0,cnt-1)], fvol, fattn, 0, 96 + gEngfuncs.pfnRandomLong(0,0xf) ); + gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, rgsz[gEngfuncs.pfnRandomLong( 0, cnt - 1 )], fvol, fattn, 0, 96 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); return fvolbar; } char *EV_HLDM_DamageDecal( physent_t *pe ) { - static char decalname[ 32 ]; + static char decalname[32]; int idx; - if ( pe->classnumber == 1 ) + if( pe->classnumber == 1 ) { idx = gEngfuncs.pfnRandomLong( 0, 2 ); sprintf( decalname, "{break%i", idx + 1 ); } - else if ( pe->rendermode != kRenderNormal ) + else if( pe->rendermode != kRenderNormal ) { sprintf( decalname, "{bproof1" ); } @@ -248,28 +264,38 @@ void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName ) gEngfuncs.pEfxAPI->R_BulletImpactParticles( pTrace->endpos ); - iRand = gEngfuncs.pfnRandomLong(0,0x7FFF); - if ( iRand < (0x7fff/2) )// not every bullet makes a sound. + iRand = gEngfuncs.pfnRandomLong( 0, 0x7FFF ); + if( iRand < ( 0x7fff / 2 ) )// not every bullet makes a sound. { - switch( iRand % 5) + switch( iRand % 5 ) { - case 0: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 2: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 4: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric5.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); + break; + case 1: + gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); + break; + case 2: + gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); + break; + case 3: + gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); + break; + case 4: + gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric5.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); + break; } } pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent ); // Only decal brush models such as the world etc. - if ( decalName && decalName[0] && pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) ) + if( decalName && decalName[0] && pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) ) { - if ( CVAR_GET_FLOAT( "r_decals" ) ) + if( CVAR_GET_FLOAT( "r_decals" ) ) { - gEngfuncs.pEfxAPI->R_DecalShoot( - gEngfuncs.pEfxAPI->Draw_DecalIndex( gEngfuncs.pEfxAPI->Draw_DecalIndexFromName( decalName ) ), + gEngfuncs.pEfxAPI->R_DecalShoot( + gEngfuncs.pEfxAPI->Draw_DecalIndex( gEngfuncs.pEfxAPI->Draw_DecalIndexFromName( decalName ) ), gEngfuncs.pEventAPI->EV_IndexFromTrace( pTrace ), 0, pTrace->endpos, 0 ); } } @@ -281,7 +307,7 @@ void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType ) pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent ); - if ( pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP )) + if( pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) ) { switch( iBulletType ) { @@ -305,26 +331,26 @@ int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, flo int i; qboolean player = idx >= 1 && idx <= gEngfuncs.GetMaxClients() ? true : false; - if ( iTracerFreq != 0 && ( (*tracerCount)++ % iTracerFreq) == 0 ) + if( iTracerFreq != 0 && ( (*tracerCount)++ % iTracerFreq ) == 0 ) { vec3_t vecTracerSrc; - if ( player ) + if( player ) { vec3_t offset( 0, 0, -4 ); // adjust tracer position for player - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - vecTracerSrc[ i ] = vecSrc[ i ] + offset[ i ] + right[ i ] * 2 + forward[ i ] * 16; + vecTracerSrc[i] = vecSrc[i] + offset[i] + right[i] * 2 + forward[i] * 16; } } else { VectorCopy( vecSrc, vecTracerSrc ); } - - if ( iTracerFreq != 1 ) // guns that always trace also always decal + + if( iTracerFreq != 1 ) // guns that always trace also always decal tracer = 1; switch( iBulletType ) @@ -342,7 +368,6 @@ int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, flo return tracer; } - /* ================ FireBullets @@ -356,44 +381,43 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int pmtrace_t tr; int iShot; int tracer; - - for ( iShot = 1; iShot <= cShots; iShot++ ) + + for( iShot = 1; iShot <= cShots; iShot++ ) { vec3_t vecDir, vecEnd; - float x, y, z; - //We randomize for the Shotgun. - if ( iBulletType == BULLET_PLAYER_BUCKSHOT ) - { - do { - x = gEngfuncs.pfnRandomFloat(-0.5,0.5) + gEngfuncs.pfnRandomFloat(-0.5,0.5); - y = gEngfuncs.pfnRandomFloat(-0.5,0.5) + gEngfuncs.pfnRandomFloat(-0.5,0.5); - z = x*x+y*y; - } while (z > 1); - for ( i = 0 ; i < 3; i++ ) + //We randomize for the Shotgun. + if( iBulletType == BULLET_PLAYER_BUCKSHOT ) + { + do{ + x = gEngfuncs.pfnRandomFloat( -0.5, 0.5 ) + gEngfuncs.pfnRandomFloat( -0.5, 0.5 ); + y = gEngfuncs.pfnRandomFloat( -0.5, 0.5 ) + gEngfuncs.pfnRandomFloat( -0.5, 0.5 ); + z = x * x + y * y; + }while( z > 1 ); + + for( i = 0 ; i < 3; i++ ) { - vecDir[i] = vecDirShooting[i] + x * flSpreadX * right[ i ] + y * flSpreadY * up [ i ]; - vecEnd[i] = vecSrc[ i ] + flDistance * vecDir[ i ]; + vecDir[i] = vecDirShooting[i] + x * flSpreadX * right[i] + y * flSpreadY * up [i]; + vecEnd[i] = vecSrc[i] + flDistance * vecDir[i]; } }//But other guns already have their spread randomized in the synched spread. else { - - for ( i = 0 ; i < 3; i++ ) + for( i = 0 ; i < 3; i++ ) { - vecDir[i] = vecDirShooting[i] + flSpreadX * right[ i ] + flSpreadY * up [ i ]; - vecEnd[i] = vecSrc[ i ] + flDistance * vecDir[ i ]; + vecDir[i] = vecDirShooting[i] + flSpreadX * right[i] + flSpreadY * up [i]; + vecEnd[i] = vecSrc[i] + flDistance * vecDir[i]; } } gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); - + // Store off the old count gEngfuncs.pEventAPI->EV_PushPMStates(); - + // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr ); @@ -401,37 +425,29 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int tracer = EV_HLDM_CheckTracer( idx, vecSrc, tr.endpos, forward, right, iBulletType, iTracerFreq, tracerCount ); // do damage, paint decals - if ( tr.fraction != 1.0 ) + if( tr.fraction != 1.0 ) { - switch(iBulletType) + switch( iBulletType ) { default: - case BULLET_PLAYER_9MM: - + case BULLET_PLAYER_9MM: EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); EV_HLDM_DecalGunshot( &tr, iBulletType ); - - break; - case BULLET_PLAYER_MP5: - - if ( !tracer ) + break; + case BULLET_PLAYER_MP5: + if( !tracer ) { EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); EV_HLDM_DecalGunshot( &tr, iBulletType ); } break; case BULLET_PLAYER_BUCKSHOT: - EV_HLDM_DecalGunshot( &tr, iBulletType ); - break; case BULLET_PLAYER_357: - EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); EV_HLDM_DecalGunshot( &tr, iBulletType ); - break; - } } @@ -455,7 +471,7 @@ void EV_FireGlock1( event_args_t *args ) int shell; vec3_t vecSrc, vecAiming; vec3_t up, right, forward; - + idx = args->entindex; VectorCopy( args->origin, origin ); VectorCopy( args->angles, angles ); @@ -464,9 +480,9 @@ void EV_FireGlock1( event_args_t *args ) empty = args->bparam1; AngleVectors( angles, forward, right, up ); - shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/shell.mdl");// brass shell + shell = gEngfuncs.pEventAPI->EV_FindModelIndex( "models/shell.mdl" );// brass shell - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { EV_MuzzleFlash(); gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 2 ); @@ -476,12 +492,12 @@ void EV_FireGlock1( event_args_t *args ) EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); - EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL ); + EV_EjectBrass( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/pl_gun3.wav", gEngfuncs.pfnRandomFloat(0.92, 1.0), ATTN_NORM, 0, 98 + gEngfuncs.pfnRandomLong( 0, 3 ) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/pl_gun3.wav", gEngfuncs.pfnRandomFloat( 0.92, 1.0 ), ATTN_NORM, 0, 98 + gEngfuncs.pfnRandomLong( 0, 3 ) ); EV_GetGunPosition( args, vecSrc, origin ); - + VectorCopy( forward, vecAiming ); EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, 0, args->fparam1, args->fparam2 ); @@ -493,7 +509,7 @@ void EV_FireGlock2( event_args_t *args ) vec3_t origin; vec3_t angles; vec3_t velocity; - + vec3_t ShellVelocity; vec3_t ShellOrigin; int shell; @@ -510,7 +526,7 @@ void EV_FireGlock2( event_args_t *args ) shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/shell.mdl");// brass shell - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { // Add muzzle flash to current weapon model EV_MuzzleFlash(); @@ -521,16 +537,15 @@ void EV_FireGlock2( event_args_t *args ) EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); - EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL ); + EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/pl_gun3.wav", gEngfuncs.pfnRandomFloat(0.92, 1.0), ATTN_NORM, 0, 98 + gEngfuncs.pfnRandomLong( 0, 3 ) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/pl_gun3.wav", gEngfuncs.pfnRandomFloat( 0.92, 1.0 ), ATTN_NORM, 0, 98 + gEngfuncs.pfnRandomLong( 0, 3 ) ); EV_GetGunPosition( args, vecSrc, origin ); - + VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &tracerCount[idx-1], args->fparam1, args->fparam2 ); - + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); } //====================== // GLOCK END @@ -562,9 +577,9 @@ void EV_FireShotGunDouble( event_args_t *args ) AngleVectors( angles, forward, right, up ); - shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/shotgunshell.mdl");// brass shell + shell = gEngfuncs.pEventAPI->EV_FindModelIndex("models/shotgunshell.mdl");// brass shell - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { // Add muzzle flash to current weapon model EV_MuzzleFlash(); @@ -572,25 +587,25 @@ void EV_FireShotGunDouble( event_args_t *args ) V_PunchAxis( 0, -10.0 ); } - for ( j = 0; j < 2; j++ ) + for( j = 0; j < 2; j++ ) { EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 32, -12, 6 ); - EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHOTSHELL ); + EV_EjectBrass( ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHOTSHELL ); } - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/dbarrel1.wav", gEngfuncs.pfnRandomFloat(0.98, 1.0), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/dbarrel1.wav", gEngfuncs.pfnRandomFloat( 0.98, 1.0 ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); EV_GetGunPosition( args, vecSrc, origin ); VectorCopy( forward, vecAiming ); - if ( gEngfuncs.GetMaxClients() > 1 ) + if( gEngfuncs.GetMaxClients() > 1 ) { - EV_HLDM_FireBullets( idx, forward, right, up, 8, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx-1], 0.17365, 0.04362 ); + EV_HLDM_FireBullets( idx, forward, right, up, 8, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.17365, 0.04362 ); } else { - EV_HLDM_FireBullets( idx, forward, right, up, 12, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx-1], 0.08716, 0.08716 ); + EV_HLDM_FireBullets( idx, forward, right, up, 12, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 ); } } @@ -600,7 +615,7 @@ void EV_FireShotGunSingle( event_args_t *args ) vec3_t origin; vec3_t angles; vec3_t velocity; - + vec3_t ShellVelocity; vec3_t ShellOrigin; int shell; @@ -616,9 +631,9 @@ void EV_FireShotGunSingle( event_args_t *args ) AngleVectors( angles, forward, right, up ); - shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/shotgunshell.mdl");// brass shell + shell = gEngfuncs.pEventAPI->EV_FindModelIndex("models/shotgunshell.mdl");// brass shell - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { // Add muzzle flash to current weapon model EV_MuzzleFlash(); @@ -629,20 +644,20 @@ void EV_FireShotGunSingle( event_args_t *args ) EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 32, -12, 6 ); - EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHOTSHELL ); + EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHOTSHELL ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/sbarrel1.wav", gEngfuncs.pfnRandomFloat(0.95, 1.0), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/sbarrel1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); EV_GetGunPosition( args, vecSrc, origin ); VectorCopy( forward, vecAiming ); - if ( gEngfuncs.GetMaxClients() > 1 ) + if( gEngfuncs.GetMaxClients() > 1 ) { - EV_HLDM_FireBullets( idx, forward, right, up, 4, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx-1], 0.08716, 0.04362 ); + EV_HLDM_FireBullets( idx, forward, right, up, 4, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.04362 ); } else { - EV_HLDM_FireBullets( idx, forward, right, up, 6, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx-1], 0.08716, 0.08716 ); + EV_HLDM_FireBullets( idx, forward, right, up, 6, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 ); } } //====================== @@ -673,20 +688,20 @@ void EV_FireMP5( event_args_t *args ) AngleVectors( angles, forward, right, up ); - shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/shell.mdl");// brass shell - - if ( EV_IsLocal( idx ) ) + shell = gEngfuncs.pEventAPI->EV_FindModelIndex("models/shell.mdl");// brass shell + + if( EV_IsLocal( idx ) ) { // Add muzzle flash to current weapon model EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_FIRE1 + gEngfuncs.pfnRandomLong(0,2), 2 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_FIRE1 + gEngfuncs.pfnRandomLong( 0, 2 ), 2 ); V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( -2, 2 ) ); } EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); - EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHELL ); + EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL ); switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) { @@ -701,13 +716,13 @@ void EV_FireMP5( event_args_t *args ) EV_GetGunPosition( args, vecSrc, origin ); VectorCopy( forward, vecAiming ); - if ( gEngfuncs.GetMaxClients() > 1 ) + if( gEngfuncs.GetMaxClients() > 1 ) { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &tracerCount[idx-1], args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); } else { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &tracerCount[idx-1], args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); } } @@ -717,16 +732,16 @@ void EV_FireMP52( event_args_t *args ) { int idx; vec3_t origin; - + idx = args->entindex; VectorCopy( args->origin, origin ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_LAUNCH, 2 ); V_PunchAxis( 0, -10 ); } - + switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) { case 0: @@ -763,7 +778,7 @@ void EV_FirePython( event_args_t *args ) AngleVectors( angles, forward, right, up ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { // Python uses different body in multiplayer versus single player int multiplayer = gEngfuncs.GetMaxClients() == 1 ? 0 : 1; @@ -778,15 +793,15 @@ void EV_FirePython( event_args_t *args ) switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) { case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/357_shot1.wav", gEngfuncs.pfnRandomFloat(0.8, 0.9), ATTN_NORM, 0, PITCH_NORM ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/357_shot1.wav", gEngfuncs.pfnRandomFloat( 0.8, 0.9 ), ATTN_NORM, 0, PITCH_NORM ); break; case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/357_shot2.wav", gEngfuncs.pfnRandomFloat(0.8, 0.9), ATTN_NORM, 0, PITCH_NORM ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/357_shot2.wav", gEngfuncs.pfnRandomFloat( 0.8, 0.9 ), ATTN_NORM, 0, PITCH_NORM ); break; } EV_GetGunPosition( args, vecSrc, origin ); - + VectorCopy( forward, vecAiming ); EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_357, 0, 0, args->fparam1, args->fparam2 ); @@ -799,7 +814,7 @@ void EV_FirePython( event_args_t *args ) //====================== // GAUSS START //====================== -#define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch +#define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch void EV_SpinGauss( event_args_t *args ) { @@ -854,10 +869,10 @@ void EV_FireGauss( event_args_t *args ) edict_t *pentIgnore; pmtrace_t tr, beam_tr; float flMaxFrac = 1.0; - int nTotal = 0; + int nTotal = 0; int fHasPunched = 0; int fFirstBeam = 1; - int nMaxHits = 10; + int nMaxHits = 10; physent_t *pEntity; int m_iBeam, m_iGlow, m_iBalls; vec3_t up, right, forward; @@ -867,35 +882,34 @@ void EV_FireGauss( event_args_t *args ) VectorCopy( args->angles, angles ); VectorCopy( args->velocity, velocity ); - if ( args->bparam2 ) + if( args->bparam2 ) { EV_StopPreviousGauss( idx ); return; } -// Con_Printf( "Firing gauss with %f\n", flDamage ); + //Con_Printf( "Firing gauss with %f\n", flDamage ); EV_GetGunPosition( args, vecSrc, origin ); m_iBeam = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/smoke.spr" ); m_iBalls = m_iGlow = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/hotglow.spr" ); - + AngleVectors( angles, forward, right, up ); VectorMA( vecSrc, 8192, forward, vecDest ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { V_PunchAxis( 0, -2.0 ); gEngfuncs.pEventAPI->EV_WeaponAnimation( GAUSS_FIRE2, 2 ); - if ( m_fPrimaryFire == false ) - g_flApplyVel = flDamage; - + if( m_fPrimaryFire == false ) + g_flApplyVel = flDamage; } - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/gauss2.wav", 0.5 + flDamage * (1.0 / 400.0), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/gauss2.wav", 0.5 + flDamage * ( 1.0 / 400.0 ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); - while (flDamage > 10 && nMaxHits > 0) + while( flDamage > 10 && nMaxHits > 0 ) { nMaxHits--; @@ -905,19 +919,19 @@ void EV_FireGauss( event_args_t *args ) gEngfuncs.pEventAPI->EV_PushPMStates(); // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecDest, PM_STUDIO_BOX, -1, &tr ); gEngfuncs.pEventAPI->EV_PopPMStates(); - if ( tr.allsolid ) + if( tr.allsolid ) break; - if (fFirstBeam) + if( fFirstBeam ) { - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { // Add muzzle flash to current weapon model EV_MuzzleFlash(); @@ -959,10 +973,10 @@ void EV_FireGauss( event_args_t *args ) } pEntity = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent ); - if ( pEntity == NULL ) + if( pEntity == NULL ) break; - if ( pEntity->solid == SOLID_BSP ) + if( pEntity->solid == SOLID_BSP ) { float n; @@ -970,16 +984,16 @@ void EV_FireGauss( event_args_t *args ) n = -DotProduct( tr.plane.normal, forward ); - if (n < 0.5) // 60 degrees + if( n < 0.5 ) // 60 degrees { // ALERT( at_console, "reflect %f\n", n ); // reflect vec3_t r; - + VectorMA( forward, 2.0 * n, tr.plane.normal, r ); flMaxFrac = flMaxFrac - tr.fraction; - + VectorCopy( r, forward ); VectorMA( tr.endpos, 8.0, forward, vecSrc ); @@ -994,13 +1008,12 @@ void EV_FireGauss( event_args_t *args ) 255, 100 ); // lose energy - if ( n == 0 ) + if( n == 0 ) { n = 0.1; } - - flDamage = flDamage * (1 - n); + flDamage = flDamage * ( 1 - n ); } else { @@ -1010,14 +1023,14 @@ void EV_FireGauss( event_args_t *args ) gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 1.0, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0, 6.0, FTENT_FADEOUT ); // limit it to one hole punch - if (fHasPunched) + if( fHasPunched ) { break; } fHasPunched = 1; // try punching through wall if secondary attack (primary is incapable of breaking through) - if ( !m_fPrimaryFire ) + if( !m_fPrimaryFire ) { vec3_t start; @@ -1025,29 +1038,28 @@ void EV_FireGauss( event_args_t *args ) // Store off the old count gEngfuncs.pEventAPI->EV_PushPMStates(); - + // Now add in all of the players. gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( start, vecDest, PM_STUDIO_BOX, -1, &beam_tr ); - if ( !beam_tr.allsolid ) + if( !beam_tr.allsolid ) { vec3_t delta; float n; // trace backwards to find exit point - gEngfuncs.pEventAPI->EV_PlayerTrace( beam_tr.endpos, tr.endpos, PM_STUDIO_BOX, -1, &beam_tr ); VectorSubtract( beam_tr.endpos, tr.endpos, delta ); - + n = Length( delta ); - if (n < flDamage) + if(n < flDamage) { - if (n == 0) + if(n == 0) n = 1; flDamage -= n; @@ -1060,20 +1072,20 @@ void EV_FireGauss( event_args_t *args ) } //////////////////////////////////// WHAT TO DO HERE - // CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); + // CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); EV_HLDM_DecalGunshot( &beam_tr, BULLET_MONSTER_12MM ); - + gEngfuncs.pEfxAPI->R_TempSprite( beam_tr.endpos, vec3_origin, 0.1, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0, 6.0, FTENT_FADEOUT ); - + // balls { vec3_t fwd; VectorSubtract( beam_tr.endpos, forward, fwd ); - gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, beam_tr.endpos, fwd, m_iBalls, (int)(flDamage * 0.3), 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 200, + gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, beam_tr.endpos, fwd, m_iBalls, (int)( flDamage * 0.3 ), 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 200, 255, 40 ); } - + VectorAdd( beam_tr.endpos, forward, vecSrc ); } } @@ -1086,12 +1098,11 @@ void EV_FireGauss( event_args_t *args ) } else { - if ( m_fPrimaryFire ) + if( m_fPrimaryFire ) { // slug doesn't punch through ever with primary // fire, so leave a little glowy bit and make some balls gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, 200.0 / 255.0, 0.3, FTENT_FADEOUT ); - { vec3_t fwd; VectorAdd( tr.endpos, tr.plane.normal, fwd ); @@ -1117,8 +1128,8 @@ void EV_FireGauss( event_args_t *args ) //====================== // CROWBAR START //====================== - -enum crowbar_e { +enum crowbar_e +{ CROWBAR_IDLE = 0, CROWBAR_DRAW, CROWBAR_HOLSTER, @@ -1145,20 +1156,23 @@ void EV_Crowbar( event_args_t *args ) VectorCopy( args->origin, origin ); //Play Swing sound - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/cbar_miss1.wav", 1, ATTN_NORM, 0, PITCH_NORM); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/cbar_miss1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 ); switch( (g_iSwing++) % 3 ) { case 0: - gEngfuncs.pEventAPI->EV_WeaponAnimation ( CROWBAR_ATTACK1MISS, 1 ); break; + gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 ); + break; case 1: - gEngfuncs.pEventAPI->EV_WeaponAnimation ( CROWBAR_ATTACK2MISS, 1 ); break; + gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK2MISS, 1 ); + break; case 2: - gEngfuncs.pEventAPI->EV_WeaponAnimation ( CROWBAR_ATTACK3MISS, 1 ); break; + gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK3MISS, 1 ); + break; } } } @@ -1169,7 +1183,8 @@ void EV_Crowbar( event_args_t *args ) //====================== // CROSSBOW START //====================== -enum crossbow_e { +enum crossbow_e +{ CROSSBOW_IDLE1 = 0, // full CROSSBOW_IDLE2, // empty CROSSBOW_FIDGET1, // full @@ -1189,7 +1204,7 @@ enum crossbow_e { // This function is used to correct the origin and angles // of the bolt, so it looks like it's stuck on the wall. //===================== -void EV_BoltCallback ( struct tempent_s *ent, float frametime, float currenttime ) +void EV_BoltCallback( struct tempent_s *ent, float frametime, float currenttime ) { ent->entity.origin = ent->entity.baseline.vuser1; ent->entity.angles = ent->entity.baseline.vuser2; @@ -1211,21 +1226,21 @@ void EV_FireCrossbow2( event_args_t *args ) VectorCopy( args->angles, angles ); VectorCopy( args->velocity, velocity ); - + AngleVectors( angles, forward, right, up ); EV_GetGunPosition( args, vecSrc, origin ); VectorMA( vecSrc, 8192, forward, vecEnd ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xbow_fire1.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong(0,0xF) ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat(0.95, 1.0), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong(0,0xF) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xbow_fire1.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { - if ( args->iparam1 ) + if( args->iparam1 ) gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 1 ); - else if ( args->iparam2 ) + else if( args->iparam2 ) gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 1 ); } @@ -1236,30 +1251,32 @@ void EV_FireCrossbow2( event_args_t *args ) gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr ); - + //We hit something - if ( tr.fraction < 1.0 ) + if( tr.fraction < 1.0 ) { physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent ); //Not the world, let's assume we hit something organic ( dog, cat, uncle joe, etc ). - if ( pe->solid != SOLID_BSP ) + if( pe->solid != SOLID_BSP ) { - switch( gEngfuncs.pfnRandomLong(0,1) ) + switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) { case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, tr.endpos, CHAN_BODY, "weapons/xbow_hitbod1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); break; + gEngfuncs.pEventAPI->EV_PlaySound( idx, tr.endpos, CHAN_BODY, "weapons/xbow_hitbod1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + break; case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, tr.endpos, CHAN_BODY, "weapons/xbow_hitbod2.wav", 1, ATTN_NORM, 0, PITCH_NORM ); break; + gEngfuncs.pEventAPI->EV_PlaySound( idx, tr.endpos, CHAN_BODY, "weapons/xbow_hitbod2.wav", 1, ATTN_NORM, 0, PITCH_NORM ); + break; } } //Stick to world but don't stick to glass, it might break and leave the bolt floating. It can still stick to other non-transparent breakables though. - else if ( pe->rendermode == kRenderNormal ) + else if( pe->rendermode == kRenderNormal ) { - gEngfuncs.pEventAPI->EV_PlaySound( 0, tr.endpos, CHAN_BODY, "weapons/xbow_hit1.wav", gEngfuncs.pfnRandomFloat(0.95, 1.0), ATTN_NORM, 0, PITCH_NORM ); - + gEngfuncs.pEventAPI->EV_PlaySound( 0, tr.endpos, CHAN_BODY, "weapons/xbow_hit1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, PITCH_NORM ); + //Not underwater, do some sparks... - if ( gEngfuncs.PM_PointContents( tr.endpos, NULL ) != CONTENTS_WATER) + if( gEngfuncs.PM_PointContents( tr.endpos, NULL ) != CONTENTS_WATER ) gEngfuncs.pEfxAPI->R_SparkShower( tr.endpos ); vec3_t vBoltAngles; @@ -1267,9 +1284,9 @@ void EV_FireCrossbow2( event_args_t *args ) VectorAngles( forward, vBoltAngles ); - TEMPENTITY *bolt = gEngfuncs.pEfxAPI->R_TempModel( tr.endpos - forward * 10, Vector( 0, 0, 0), vBoltAngles , 5, iModelIndex, TE_BOUNCE_NULL ); - - if ( bolt ) + TEMPENTITY *bolt = gEngfuncs.pEfxAPI->R_TempModel( tr.endpos - forward * 10, Vector( 0, 0, 0 ), vBoltAngles , 5, iModelIndex, TE_BOUNCE_NULL ); + + if( bolt ) { bolt->flags |= ( FTENT_CLIENTCUSTOM ); //So it calls the callback function. bolt->entity.baseline.vuser1 = tr.endpos - forward * 10; // Pull out a little bit @@ -1290,14 +1307,14 @@ void EV_FireCrossbow( event_args_t *args ) idx = args->entindex; VectorCopy( args->origin, origin ); - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xbow_fire1.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong(0,0xF) ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat(0.95, 1.0), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong(0,0xF) ); + + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xbow_fire1.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); //Only play the weapon anims if I shot it. - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { - if ( args->iparam1 ) + if( args->iparam1 ) gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 1 ); else if ( args->iparam2 ) gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 1 ); @@ -1312,7 +1329,8 @@ void EV_FireCrossbow( event_args_t *args ) //====================== // RPG START //====================== -enum rpg_e { +enum rpg_e +{ RPG_IDLE = 0, RPG_FIDGET, RPG_RELOAD, // to reload @@ -1332,15 +1350,15 @@ void EV_FireRpg( event_args_t *args ) idx = args->entindex; VectorCopy( args->origin, origin ); - + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/rocketfire1.wav", 0.9, ATTN_NORM, 0, PITCH_NORM ); gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/glauncher.wav", 0.7, ATTN_NORM, 0, PITCH_NORM ); //Only play the weapon anims if I shot it. - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2, 1 ); - + V_PunchAxis( 0, -5.0 ); } } @@ -1351,7 +1369,8 @@ void EV_FireRpg( event_args_t *args ) //====================== // EGON END //====================== -enum egon_e { +enum egon_e +{ EGON_IDLE1 = 0, EGON_FIDGET1, EGON_ALTFIREON, @@ -1368,8 +1387,17 @@ enum egon_e { int g_fireAnims1[] = { EGON_FIRE1, EGON_FIRE2, EGON_FIRE3, EGON_FIRE4 }; int g_fireAnims2[] = { EGON_ALTFIRECYCLE }; -enum EGON_FIRESTATE { FIRE_OFF, FIRE_CHARGE }; -enum EGON_FIREMODE { FIRE_NARROW, FIRE_WIDE}; +enum EGON_FIRESTATE +{ + FIRE_OFF, + FIRE_CHARGE +}; + +enum EGON_FIREMODE +{ + FIRE_NARROW, + FIRE_WIDE +}; #define EGON_PRIMARY_VOLUME 450 #define EGON_BEAM_SPRITE "sprites/xbeam1.spr" @@ -1378,7 +1406,7 @@ enum EGON_FIREMODE { FIRE_NARROW, FIRE_WIDE}; #define EGON_SOUND_RUN "weapons/egon_run3.wav" #define EGON_SOUND_STARTUP "weapons/egon_windup2.wav" -#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) +#define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) ) BEAM *pBeam; BEAM *pBeam2; @@ -1394,50 +1422,49 @@ void EV_EgonFire( event_args_t *args ) iFireMode = args->iparam2; int iStartup = args->bparam1; - - if ( iStartup ) + if( iStartup ) { - if ( iFireMode == FIRE_WIDE ) + if( iFireMode == FIRE_WIDE ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, EGON_SOUND_STARTUP, 0.98, ATTN_NORM, 0, 125 ); else gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, EGON_SOUND_STARTUP, 0.9, ATTN_NORM, 0, 100 ); } else { - if ( iFireMode == FIRE_WIDE ) + if( iFireMode == FIRE_WIDE ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, EGON_SOUND_RUN, 0.98, ATTN_NORM, 0, 125 ); else gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, EGON_SOUND_RUN, 0.9, ATTN_NORM, 0, 100 ); } //Only play the weapon anims if I shot it. - if ( EV_IsLocal( idx ) ) - gEngfuncs.pEventAPI->EV_WeaponAnimation ( g_fireAnims1[ gEngfuncs.pfnRandomLong( 0, 3 ) ], 1 ); + if( EV_IsLocal( idx ) ) + gEngfuncs.pEventAPI->EV_WeaponAnimation ( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 ); - if ( iStartup == 1 && EV_IsLocal( idx ) && !pBeam && !pBeam2 && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction. + if( iStartup == 1 && EV_IsLocal( idx ) && !pBeam && !pBeam2 && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction. { vec3_t vecSrc, vecEnd, origin, angles, forward, right, up; pmtrace_t tr; cl_entity_t *pl = gEngfuncs.GetEntityByIndex( idx ); - if ( pl ) + if( pl ) { VectorCopy( gHUD.m_vecAngles, angles ); - + AngleVectors( angles, forward, right, up ); EV_GetGunPosition( args, vecSrc, pl->origin ); VectorMA( vecSrc, 2048, forward, vecEnd ); - gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); - + gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); + // Store off the old count gEngfuncs.pEventAPI->EV_PushPMStates(); - + // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr ); @@ -1450,19 +1477,18 @@ void EV_EgonFire( event_args_t *args ) float g = 50.0f; float b = 125.0f; - if ( IEngineStudio.IsHardware() ) + if( IEngineStudio.IsHardware() ) { r /= 100.0f; g /= 100.0f; } - - - pBeam = gEngfuncs.pEfxAPI->R_BeamEntPoint ( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 3.5, 0.2, 0.7, 55, 0, 0, r, g, b ); - if ( pBeam ) + pBeam = gEngfuncs.pEfxAPI->R_BeamEntPoint( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 3.5, 0.2, 0.7, 55, 0, 0, r, g, b ); + + if( pBeam ) pBeam->flags |= ( FBEAM_SINENOISE ); - - pBeam2 = gEngfuncs.pEfxAPI->R_BeamEntPoint ( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 5.0, 0.08, 0.7, 25, 0, 0, r, g, b ); + + pBeam2 = gEngfuncs.pEfxAPI->R_BeamEntPoint( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 5.0, 0.08, 0.7, 25, 0, 0, r, g, b ); } } } @@ -1473,23 +1499,22 @@ void EV_EgonStop( event_args_t *args ) vec3_t origin; idx = args->entindex; - VectorCopy ( args->origin, origin ); + VectorCopy( args->origin, origin ); gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EGON_SOUND_RUN ); - - if ( args->iparam1 ) + + if( args->iparam1 ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, EGON_SOUND_OFF, 0.98, ATTN_NORM, 0, 100 ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { - if ( pBeam ) + if( pBeam ) { pBeam->die = 0.0; pBeam = NULL; } - - - if ( pBeam2 ) + + if( pBeam2 ) { pBeam2->die = 0.0; pBeam2 = NULL; @@ -1503,7 +1528,8 @@ void EV_EgonStop( event_args_t *args ) //====================== // HORNET START //====================== -enum hgun_e { +enum hgun_e +{ HGUN_IDLE1 = 0, HGUN_FIDGETSWAY, HGUN_FIDGETSHAKE, @@ -1523,17 +1549,23 @@ void EV_HornetGunFire( event_args_t *args ) iFireMode = args->iparam1; //Only play the weapon anims if I shot it. - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { - V_PunchAxis( 0, gEngfuncs.pfnRandomLong ( 0, 2 ) ); - gEngfuncs.pEventAPI->EV_WeaponAnimation ( HGUN_SHOOT, 1 ); + V_PunchAxis( 0, gEngfuncs.pfnRandomLong( 0, 2 ) ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( HGUN_SHOOT, 1 ); } - switch ( gEngfuncs.pfnRandomLong ( 0 , 2 ) ) + switch( gEngfuncs.pfnRandomLong( 0 , 2 ) ) { - case 0: gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire1.wav", 1, ATTN_NORM, 0, 100 ); break; - case 1: gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire2.wav", 1, ATTN_NORM, 0, 100 ); break; - case 2: gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire3.wav", 1, ATTN_NORM, 0, 100 ); break; + case 0: + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire1.wav", 1, ATTN_NORM, 0, 100 ); + break; + case 1: + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire2.wav", 1, ATTN_NORM, 0, 100 ); + break; + case 2: + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire3.wav", 1, ATTN_NORM, 0, 100 ); + break; } } //====================== @@ -1543,7 +1575,8 @@ void EV_HornetGunFire( event_args_t *args ) //====================== // TRIPMINE START //====================== -enum tripmine_e { +enum tripmine_e +{ TRIPMINE_IDLE1 = 0, TRIPMINE_IDLE2, TRIPMINE_ARM1, @@ -1567,9 +1600,9 @@ void EV_TripmineFire( event_args_t *args ) VectorCopy( args->origin, vecSrc ); VectorCopy( args->angles, angles ); - AngleVectors ( angles, forward, NULL, NULL ); - - if ( !EV_IsLocal ( idx ) ) + AngleVectors( angles, forward, NULL, NULL ); + + if( !EV_IsLocal ( idx ) ) return; // Grab predicted result for local player @@ -1586,7 +1619,7 @@ void EV_TripmineFire( event_args_t *args ) gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecSrc + forward * 128, PM_NORMAL, -1, &tr ); //Hit something solid - if ( tr.fraction < 1.0 ) + if( tr.fraction < 1.0 ) gEngfuncs.pEventAPI->EV_WeaponAnimation ( TRIPMINE_DRAW, 0 ); gEngfuncs.pEventAPI->EV_PopPMStates(); @@ -1598,7 +1631,8 @@ void EV_TripmineFire( event_args_t *args ) //====================== // SQUEAK START //====================== -enum squeak_e { +enum squeak_e +{ SQUEAK_IDLE1 = 0, SQUEAK_FIDGETFIT, SQUEAK_FIDGETNIP, @@ -1607,8 +1641,8 @@ enum squeak_e { SQUEAK_THROW }; -#define VEC_HULL_MIN Vector(-16, -16, -36) -#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18 ) +#define VEC_HULL_MIN Vector( -16, -16, -36 ) +#define VEC_DUCK_HULL_MIN Vector( -16, -16, -18 ) void EV_SnarkFire( event_args_t *args ) { @@ -1620,26 +1654,26 @@ void EV_SnarkFire( event_args_t *args ) VectorCopy( args->origin, vecSrc ); VectorCopy( args->angles, angles ); - AngleVectors ( angles, forward, NULL, NULL ); - - if ( !EV_IsLocal ( idx ) ) + AngleVectors( angles, forward, NULL, NULL ); + + if( !EV_IsLocal ( idx ) ) return; - - if ( args->ducking ) + + if( args->ducking ) vecSrc = vecSrc - ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN ); - + // Store off the old count gEngfuncs.pEventAPI->EV_PushPMStates(); // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc + forward * 20, vecSrc + forward * 64, PM_NORMAL, -1, &tr ); //Find space to drop the thing. - if ( tr.allsolid == 0 && tr.startsolid == 0 && tr.fraction > 0.25 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation ( SQUEAK_THROW, 0 ); - + if( tr.allsolid == 0 && tr.startsolid == 0 && tr.fraction > 0.25 ) + gEngfuncs.pEventAPI->EV_WeaponAnimation( SQUEAK_THROW, 0 ); + gEngfuncs.pEventAPI->EV_PopPMStates(); } //====================== @@ -1656,35 +1690,47 @@ void EV_TrainPitchAdjust( event_args_t *args ) float m_flVolume; int pitch; int stop; - - char sz[ 256 ]; + + char sz[256]; idx = args->entindex; - + VectorCopy( args->origin, origin ); us_params = (unsigned short)args->iparam1; - stop = args->bparam1; + stop = args->bparam1; - m_flVolume = (float)(us_params & 0x003f)/40.0; - noise = (int)(((us_params) >> 12 ) & 0x0007); - pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) ); + m_flVolume = (float)( us_params & 0x003f ) / 40.0; + noise = (int)( ( ( us_params ) >> 12 ) & 0x0007 ); + pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) ); - switch ( noise ) + switch( noise ) { - case 1: strcpy( sz, "plats/ttrain1.wav"); break; - case 2: strcpy( sz, "plats/ttrain2.wav"); break; - case 3: strcpy( sz, "plats/ttrain3.wav"); break; - case 4: strcpy( sz, "plats/ttrain4.wav"); break; - case 5: strcpy( sz, "plats/ttrain6.wav"); break; - case 6: strcpy( sz, "plats/ttrain7.wav"); break; + case 1: + strcpy( sz, "plats/ttrain1.wav" ); + break; + case 2: + strcpy( sz, "plats/ttrain2.wav" ); + break; + case 3: + strcpy( sz, "plats/ttrain3.wav" ); + break; + case 4: + strcpy( sz, "plats/ttrain4.wav"); + break; + case 5: + strcpy( sz, "plats/ttrain6.wav"); + break; + case 6: + strcpy( sz, "plats/ttrain7.wav"); + break; default: // no sound strcpy( sz, "" ); return; } - if ( stop ) + if( stop ) { gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz ); } diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index 57c99216..bff43b1e 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -21,9 +21,10 @@ typedef enum BULLET_MONSTER_9MM, BULLET_MONSTER_MP5, BULLET_MONSTER_12MM -} Bullet; +}Bullet; -enum glock_e { +enum glock_e +{ GLOCK_IDLE1 = 0, GLOCK_IDLE2, GLOCK_IDLE3, @@ -36,7 +37,8 @@ enum glock_e { GLOCK_ADD_SILENCER }; -enum shotgun_e { +enum shotgun_e +{ SHOTGUN_IDLE = 0, SHOTGUN_FIRE, SHOTGUN_FIRE2, @@ -61,7 +63,8 @@ enum mp5_e MP5_FIRE3 }; -enum python_e { +enum python_e +{ PYTHON_IDLE1 = 0, PYTHON_FIDGET, PYTHON_FIRE1, @@ -75,7 +78,8 @@ enum python_e { #define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging #define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged -enum gauss_e { +enum gauss_e +{ GAUSS_IDLE = 0, GAUSS_IDLE2, GAUSS_FIDGET, @@ -91,5 +95,4 @@ void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName ); void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType ); int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount ); void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int cShots, float *vecSrc, float *vecDirShooting, float flDistance, int iBulletType, int iTracerFreq, int *tracerCount, float flSpreadX, float flSpreadY ); - #endif // EV_HLDMH diff --git a/cl_dll/eventscripts.h b/cl_dll/eventscripts.h index 5c4677a2..c052805d 100644 --- a/cl_dll/eventscripts.h +++ b/cl_dll/eventscripts.h @@ -55,8 +55,8 @@ #define DMG_AIMED (1 << 28) // Does Hit location damage #define DMG_WALLPIERCING (1 << 29) // Blast Damages ents through walls -#define DMG_CALTROP (1<<30) -#define DMG_HALLUC (1<<31) +#define DMG_CALTROP (1 << 30) +#define DMG_HALLUC (1 << 31) // Some of these are HL/TFC specific? void EV_EjectBrass( float *origin, float *velocity, float rotation, int model, int soundtype ); diff --git a/cl_dll/flashlight.cpp b/cl_dll/flashlight.cpp index ac011a5c..8b8a8d0e 100644 --- a/cl_dll/flashlight.cpp +++ b/cl_dll/flashlight.cpp @@ -25,76 +25,71 @@ #include #include - - -DECLARE_MESSAGE(m_Flash, FlashBat) -DECLARE_MESSAGE(m_Flash, Flashlight) +DECLARE_MESSAGE( m_Flash, FlashBat ) +DECLARE_MESSAGE( m_Flash, Flashlight ) #define BAT_NAME "sprites/%d_Flashlight.spr" -int CHudFlashlight::Init(void) +int CHudFlashlight::Init( void ) { m_fFade = 0; m_fOn = 0; - HOOK_MESSAGE(Flashlight); - HOOK_MESSAGE(FlashBat); + HOOK_MESSAGE( Flashlight ); + HOOK_MESSAGE( FlashBat ); m_iFlags |= HUD_ACTIVE; - gHUD.AddHudElem(this); + gHUD.AddHudElem( this ); return 1; } -void CHudFlashlight::Reset(void) +void CHudFlashlight::Reset( void ) { m_fFade = 0; m_fOn = 0; } -int CHudFlashlight::VidInit(void) +int CHudFlashlight::VidInit( void ) { int HUD_flash_empty = gHUD.GetSpriteIndex( "flash_empty" ); int HUD_flash_full = gHUD.GetSpriteIndex( "flash_full" ); int HUD_flash_beam = gHUD.GetSpriteIndex( "flash_beam" ); - m_hSprite1 = gHUD.GetSprite(HUD_flash_empty); - m_hSprite2 = gHUD.GetSprite(HUD_flash_full); - m_hBeam = gHUD.GetSprite(HUD_flash_beam); - m_prc1 = &gHUD.GetSpriteRect(HUD_flash_empty); - m_prc2 = &gHUD.GetSpriteRect(HUD_flash_full); + m_hSprite1 = gHUD.GetSprite( HUD_flash_empty ); + m_hSprite2 = gHUD.GetSprite( HUD_flash_full ); + m_hBeam = gHUD.GetSprite( HUD_flash_beam ); + m_prc1 = &gHUD.GetSpriteRect( HUD_flash_empty ); + m_prc2 = &gHUD.GetSpriteRect( HUD_flash_full ); m_prcBeam = &gHUD.GetSpriteRect(HUD_flash_beam); m_iWidth = m_prc2->right - m_prc2->left; return 1; } -int CHudFlashlight:: MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf ) +int CHudFlashlight::MsgFunc_FlashBat( const char *pszName, int iSize, void *pbuf ) { - - BEGIN_READ( pbuf, iSize ); int x = READ_BYTE(); m_iBat = x; - m_flBat = ((float)x)/100.0; + m_flBat = ( (float)x ) / 100.0; return 1; } -int CHudFlashlight:: MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf ) +int CHudFlashlight::MsgFunc_Flashlight( const char *pszName, int iSize, void *pbuf ) { - BEGIN_READ( pbuf, iSize ); m_fOn = READ_BYTE(); int x = READ_BYTE(); m_iBat = x; - m_flBat = ((float)x)/100.0; + m_flBat = ( (float)x ) / 100.0; return 1; } -int CHudFlashlight::Draw(float flTime) +int CHudFlashlight::Draw( float flTime ) { static bool show = ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) ); if( show != !( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) ) ) @@ -105,54 +100,54 @@ int CHudFlashlight::Draw(float flTime) gMobileEngfuncs->pfnTouchHideButtons( "flashlight", !show ); } } - if ( !show ) + if( !show ) return 1; int r, g, b, x, y, a; wrect_t rc; - if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) )) + if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) return 1; - if (m_fOn) + if( m_fOn ) a = 225; else a = MIN_ALPHA; - if (m_flBat < 0.20) - UnpackRGB(r,g,b, RGB_REDISH); + if( m_flBat < 0.20 ) + UnpackRGB( r,g,b, RGB_REDISH ); else - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB( r,g,b, RGB_YELLOWISH ); - ScaleColors(r, g, b, a); + ScaleColors( r, g, b, a ); - y = (m_prc1->bottom - m_prc2->top)/2; - x = ScreenWidth - m_iWidth - m_iWidth/2 ; + y = ( m_prc1->bottom - m_prc2->top ) / 2; + x = ScreenWidth - m_iWidth - m_iWidth / 2 ; // Draw the flashlight casing - SPR_Set(m_hSprite1, r, g, b ); - SPR_DrawAdditive( 0, x, y, m_prc1); + SPR_Set( m_hSprite1, r, g, b ); + SPR_DrawAdditive( 0, x, y, m_prc1 ); - if ( m_fOn ) - { // draw the flashlight beam - x = ScreenWidth - m_iWidth/2; + if( m_fOn ) + { + // draw the flashlight beam + x = ScreenWidth - m_iWidth / 2; SPR_Set( m_hBeam, r, g, b ); SPR_DrawAdditive( 0, x, y, m_prcBeam ); } // draw the flashlight energy level - x = ScreenWidth - m_iWidth - m_iWidth/2 ; - int iOffset = m_iWidth * (1.0 - m_flBat); - if (iOffset < m_iWidth) + x = ScreenWidth - m_iWidth - m_iWidth / 2; + int iOffset = m_iWidth * ( 1.0 - m_flBat ); + if( iOffset < m_iWidth ) { rc = *m_prc2; rc.left += iOffset; - SPR_Set(m_hSprite2, r, g, b ); - SPR_DrawAdditive( 0, x + iOffset, y, &rc); + SPR_Set( m_hSprite2, r, g, b ); + SPR_DrawAdditive( 0, x + iOffset, y, &rc ); } - return 1; } diff --git a/cl_dll/geiger.cpp b/cl_dll/geiger.cpp index 4e5e5991..7ccaf1d3 100644 --- a/cl_dll/geiger.cpp +++ b/cl_dll/geiger.cpp @@ -26,28 +26,28 @@ #include "parsemsg.h" -DECLARE_MESSAGE(m_Geiger, Geiger ) +DECLARE_MESSAGE( m_Geiger, Geiger ) -int CHudGeiger::Init(void) +int CHudGeiger::Init( void ) { HOOK_MESSAGE( Geiger ); m_iGeigerRange = 0; m_iFlags = 0; - gHUD.AddHudElem(this); + gHUD.AddHudElem( this ); srand( (unsigned)time( NULL ) ); return 1; } -int CHudGeiger::VidInit(void) +int CHudGeiger::VidInit( void ) { return 1; } -int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf) +int CHudGeiger::MsgFunc_Geiger( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); @@ -55,101 +55,101 @@ int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf) // update geiger data m_iGeigerRange = READ_BYTE(); m_iGeigerRange = m_iGeigerRange << 2; - + m_iFlags |= HUD_ACTIVE; return 1; } -int CHudGeiger::Draw (float flTime) +int CHudGeiger::Draw( float flTime ) { int pct; float flvol = 0.0f; int rg[3]; int i; - - if (m_iGeigerRange < 1000 && m_iGeigerRange > 0) + + if( m_iGeigerRange < 1000 && m_iGeigerRange > 0 ) { // peicewise linear is better than continuous formula for this - if (m_iGeigerRange > 800) + if( m_iGeigerRange > 800 ) { - pct = 0; //Con_Printf ( "range > 800\n"); + pct = 0; //Con_Printf( "range > 800\n" ); } - else if (m_iGeigerRange > 600) + else if( m_iGeigerRange > 600 ) { pct = 2; - flvol = 0.4; //Con_Printf ( "range > 600\n"); + flvol = 0.4; //Con_Printf( "range > 600\n" ); rg[0] = 1; rg[1] = 1; i = 2; } - else if (m_iGeigerRange > 500) + else if( m_iGeigerRange > 500 ) { pct = 4; - flvol = 0.5; //Con_Printf ( "range > 500\n"); + flvol = 0.5; //Con_Printf( "range > 500\n" ); rg[0] = 1; rg[1] = 2; i = 2; } - else if (m_iGeigerRange > 400) + else if( m_iGeigerRange > 400 ) { pct = 8; - flvol = 0.6; //Con_Printf ( "range > 400\n"); + flvol = 0.6; //Con_Printf( "range > 400\n" ); rg[0] = 1; rg[1] = 2; rg[2] = 3; i = 3; } - else if (m_iGeigerRange > 300) + else if( m_iGeigerRange > 300 ) { pct = 8; - flvol = 0.7; //Con_Printf ( "range > 300\n"); + flvol = 0.7; //Con_Printf( "range > 300\n" ); rg[0] = 2; rg[1] = 3; rg[2] = 4; i = 3; } - else if (m_iGeigerRange > 200) + else if( m_iGeigerRange > 200 ) { pct = 28; - flvol = 0.78; //Con_Printf ( "range > 200\n"); + flvol = 0.78; //Con_Printf( "range > 200\n" ); rg[0] = 2; rg[1] = 3; rg[2] = 4; i = 3; } - else if (m_iGeigerRange > 150) + else if( m_iGeigerRange > 150 ) { pct = 40; - flvol = 0.80; //Con_Printf ( "range > 150\n"); + flvol = 0.80; //Con_Printf( "range > 150\n" ); rg[0] = 3; rg[1] = 4; rg[2] = 5; i = 3; } - else if (m_iGeigerRange > 100) + else if( m_iGeigerRange > 100 ) { pct = 60; - flvol = 0.85; //Con_Printf ( "range > 100\n"); + flvol = 0.85; //Con_Printf( "range > 100\n" ); rg[0] = 3; rg[1] = 4; rg[2] = 5; i = 3; } - else if (m_iGeigerRange > 75) + else if( m_iGeigerRange > 75 ) { pct = 80; - flvol = 0.9; //Con_Printf ( "range > 75\n"); + flvol = 0.9; //Con_Printf( "range > 75\n" ); //gflGeigerDelay = cl.time + GEIGERDELAY * 0.75; rg[0] = 4; rg[1] = 5; rg[2] = 6; i = 3; } - else if (m_iGeigerRange > 50) + else if( m_iGeigerRange > 50 ) { pct = 90; - flvol = 0.95; //Con_Printf ( "range > 50\n"); + flvol = 0.95; //Con_Printf( "range > 50\n" ); rg[0] = 5; rg[1] = 6; i = 2; @@ -157,26 +157,25 @@ int CHudGeiger::Draw (float flTime) else { pct = 95; - flvol = 1.0; //Con_Printf ( "range < 50\n"); + flvol = 1.0; //Con_Printf( "range < 50\n" ); rg[0] = 5; rg[1] = 6; i = 2; } - flvol = (flvol * ((rand() & 127)) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5); + flvol = ( flvol * ( (rand() & 127) ) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5); - if ((rand() & 127) < pct || (rand() & 127) < pct) + if( ( rand() & 127 ) < pct || ( rand() & 127 ) < pct ) { - //S_StartDynamicSound (-1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100); + //S_StartDynamicSound( -1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100 ); char sz[256]; - + int j = rand() & 1; - if (i > 2) + if( i > 2 ) j += rand() & 1; - sprintf(sz, "player/geiger%d.wav", j + 1); - PlaySound(sz, flvol); - + sprintf( sz, "player/geiger%d.wav", j + 1 ); + PlaySound( sz, flvol ); } } diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index c73b0f5c..4a567665 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -29,15 +29,15 @@ #include "mobility_int.h" -DECLARE_MESSAGE(m_Health, Health ) -DECLARE_MESSAGE(m_Health, Damage ) +DECLARE_MESSAGE( m_Health, Health ) +DECLARE_MESSAGE( m_Health, Damage ) #define PAIN_NAME "sprites/%d_pain.spr" #define DAMAGE_NAME "sprites/%d_dmg.spr" int giDmgHeight, giDmgWidth; -int giDmgFlags[NUM_DMG_TYPES] = +int giDmgFlags[NUM_DMG_TYPES] = { DMG_POISON, DMG_ACID, @@ -53,10 +53,10 @@ int giDmgFlags[NUM_DMG_TYPES] = DMG_HALLUC }; -int CHudHealth::Init(void) +int CHudHealth::Init( void ) { - HOOK_MESSAGE(Health); - HOOK_MESSAGE(Damage); + HOOK_MESSAGE( Health ); + HOOK_MESSAGE( Damage ); m_iHealth = 100; m_fFade = 0; m_iFlags = 0; @@ -65,10 +65,9 @@ int CHudHealth::Init(void) giDmgHeight = 0; giDmgWidth = 0; - memset(m_dmg, 0, sizeof(DAMAGE_IMAGE) * NUM_DMG_TYPES); + memset( m_dmg, 0, sizeof(DAMAGE_IMAGE) * NUM_DMG_TYPES ); - - gHUD.AddHudElem(this); + gHUD.AddHudElem( this ); return 1; } @@ -77,28 +76,28 @@ void CHudHealth::Reset( void ) // make sure the pain compass is cleared when the player respawns m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0; - // force all the flashing damage icons to expire m_bitsDamage = 0; - for ( int i = 0; i < NUM_DMG_TYPES; i++ ) + for( int i = 0; i < NUM_DMG_TYPES; i++ ) { m_dmg[i].fExpire = 0; } } -int CHudHealth::VidInit(void) +int CHudHealth::VidInit( void ) { m_hSprite = 0; m_HUD_dmg_bio = gHUD.GetSpriteIndex( "dmg_bio" ) + 1; m_HUD_cross = gHUD.GetSpriteIndex( "cross" ); - giDmgHeight = gHUD.GetSpriteRect(m_HUD_dmg_bio).right - gHUD.GetSpriteRect(m_HUD_dmg_bio).left; - giDmgWidth = gHUD.GetSpriteRect(m_HUD_dmg_bio).bottom - gHUD.GetSpriteRect(m_HUD_dmg_bio).top; + giDmgHeight = gHUD.GetSpriteRect( m_HUD_dmg_bio ).right - gHUD.GetSpriteRect( m_HUD_dmg_bio ).left; + giDmgWidth = gHUD.GetSpriteRect( m_HUD_dmg_bio ).bottom - gHUD.GetSpriteRect( m_HUD_dmg_bio ).top; + return 1; } -int CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf ) +int CHudHealth::MsgFunc_Health( const char *pszName, int iSize, void *pbuf ) { // TODO: update local health data BEGIN_READ( pbuf, iSize ); @@ -107,7 +106,7 @@ int CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf ) m_iFlags |= HUD_ACTIVE; // Only update the fade if we've changed health - if (x != m_iHealth) + if( x != m_iHealth ) { m_fFade = FADE_TIME; m_iHealth = x; @@ -116,8 +115,7 @@ int CHudHealth:: MsgFunc_Health(const char *pszName, int iSize, void *pbuf ) return 1; } - -int CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf ) +int CHudHealth::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); @@ -127,47 +125,47 @@ int CHudHealth:: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf ) vec3_t vecFrom; - for ( int i = 0 ; i < 3 ; i++) + for ( int i = 0; i < 3; i++ ) vecFrom[i] = READ_COORD(); - UpdateTiles(gHUD.m_flTime, bitsDamage); + UpdateTiles( gHUD.m_flTime, bitsDamage ); // Actually took damage? - if ( damageTaken > 0 || armor > 0 ) + if( damageTaken > 0 || armor > 0 ) { - CalcDamageDirection(vecFrom); + CalcDamageDirection( vecFrom ); if( gMobileEngfuncs && damageTaken > 0 ) { - float time = damageTaken * 4.0f; + float time = damageTaken * 4.0f; - if( time > 200.0f ) time = 200.0f; - gMobileEngfuncs->pfnVibrate( time, 0 ); + if( time > 200.0f ) + time = 200.0f; + gMobileEngfuncs->pfnVibrate( time, 0 ); } } return 1; } - // Returns back a color from the // Green <-> Yellow <-> Red ramp void CHudHealth::GetPainColor( int &r, int &g, int &b ) { int iHealth = m_iHealth; - if (iHealth > 25) + if( iHealth > 25 ) iHealth -= 25; - else if ( iHealth < 0 ) + else if( iHealth < 0 ) iHealth = 0; #if 0 g = iHealth * 255 / 100; r = 255 - g; b = 0; #else - if (m_iHealth > 25) + if( m_iHealth > 25 ) { - UnpackRGB(r,g,b, RGB_YELLOWISH); + UnpackRGB( r, g, b, RGB_YELLOWISH ); } else { @@ -175,135 +173,131 @@ void CHudHealth::GetPainColor( int &r, int &g, int &b ) g = 0; b = 0; } -#endif +#endif } -int CHudHealth::Draw(float flTime) +int CHudHealth::Draw( float flTime ) { int r, g, b; int a = 0, x, y; int HealthWidth; - if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() ) + if( ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH ) || gEngfuncs.IsSpectateOnly() ) return 1; - if ( !m_hSprite ) - m_hSprite = LoadSprite(PAIN_NAME); - + if( !m_hSprite ) + m_hSprite = LoadSprite( PAIN_NAME ); + // Has health changed? Flash the health # - if (m_fFade) + if( m_fFade ) { - m_fFade -= (gHUD.m_flTimeDelta * 20); - if (m_fFade <= 0) + 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; - + 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) + if( m_iHealth <= 15 ) a = 255; - + GetPainColor( r, g, b ); - ScaleColors(r, g, b, a ); + ScaleColors( r, g, b, a ); // Only draw health if we have the suit. - if (gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT))) + if( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) { - HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left; - int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left; + HealthWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; + int CrossWidth = gHUD.GetSpriteRect( m_HUD_cross ).right - gHUD.GetSpriteRect( m_HUD_cross ).left; y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; - x = CrossWidth /2; + x = CrossWidth / 2; - SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b); - SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross)); + SPR_Set( gHUD.GetSprite( m_HUD_cross ), r, g, b ); + SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_cross ) ); x = CrossWidth + HealthWidth / 2; - x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b); + x = gHUD.DrawHudNumber( x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b ); - x += HealthWidth/2; + x += HealthWidth / 2; int iHeight = gHUD.m_iFontHeight; - int iWidth = HealthWidth/10; - FillRGBA(x, y, iWidth, iHeight, 255, 160, 0, a); + int iWidth = HealthWidth / 10; + FillRGBA( x, y, iWidth, iHeight, 255, 160, 0, a ); } - DrawDamage(flTime); - return DrawPain(flTime); + DrawDamage( flTime ); + return DrawPain( flTime ); } -void CHudHealth::CalcDamageDirection(vec3_t vecFrom) +void CHudHealth::CalcDamageDirection( vec3_t vecFrom ) { vec3_t forward, right, up; float side, front; vec3_t vecOrigin, vecAngles; - if (!vecFrom[0] && !vecFrom[1] && !vecFrom[2]) + if( !vecFrom[0] && !vecFrom[1] && !vecFrom[2] ) { m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 0; return; } + memcpy( vecOrigin, gHUD.m_vecOrigin, sizeof(vec3_t) ); + memcpy( vecAngles, gHUD.m_vecAngles, sizeof(vec3_t) ); - memcpy(vecOrigin, gHUD.m_vecOrigin, sizeof(vec3_t)); - memcpy(vecAngles, gHUD.m_vecAngles, sizeof(vec3_t)); - - - VectorSubtract (vecFrom, vecOrigin, vecFrom); + VectorSubtract( vecFrom, vecOrigin, vecFrom ); float flDistToTarget = vecFrom.Length(); vecFrom = vecFrom.Normalize(); - AngleVectors (vecAngles, forward, right, up); + AngleVectors( vecAngles, forward, right, up ); - front = DotProduct (vecFrom, right); - side = DotProduct (vecFrom, forward); + front = DotProduct( vecFrom, right ); + side = DotProduct( vecFrom, forward ); - if (flDistToTarget <= 50) + if( flDistToTarget <= 50 ) { m_fAttackFront = m_fAttackRear = m_fAttackRight = m_fAttackLeft = 1; } else { - if (side > 0) + if( side > 0 ) { - if (side > 0.3) - m_fAttackFront = max(m_fAttackFront, side); + if( side > 0.3 ) + m_fAttackFront = max( m_fAttackFront, side ); } else { - float f = fabs(side); - if (f > 0.3) - m_fAttackRear = max(m_fAttackRear, f); + float f = fabs( side ); + if( f > 0.3 ) + m_fAttackRear = max( m_fAttackRear, f ); } - if (front > 0) + if( front > 0 ) { - if (front > 0.3) - m_fAttackRight = max(m_fAttackRight, front); + if( front > 0.3 ) + m_fAttackRight = max( m_fAttackRight, front ); } else { - float f = fabs(front); - if (f > 0.3) - m_fAttackLeft = max(m_fAttackLeft, f); + float f = fabs( front ); + if( f > 0.3 ) + m_fAttackLeft = max( m_fAttackLeft, f ); } } } -int CHudHealth::DrawPain(float flTime) +int CHudHealth::DrawPain( float flTime ) { - if (!(m_fAttackFront || m_fAttackRear || m_fAttackLeft || m_fAttackRight)) + if( !( m_fAttackFront || m_fAttackRear || m_fAttackLeft || m_fAttackRight) ) return 1; int r, g, b; @@ -313,60 +307,62 @@ int CHudHealth::DrawPain(float flTime) a = 255; // max brightness until then float fFade = gHUD.m_flTimeDelta * 2; - - // SPR_Draw top - if (m_fAttackFront > 0.4) - { - GetPainColor(r,g,b); - shade = a * max( m_fAttackFront, 0.5 ); - ScaleColors(r, g, b, shade); - SPR_Set(m_hSprite, r, g, b ); - x = ScreenWidth/2 - SPR_Width(m_hSprite, 0)/2; - y = ScreenHeight/2 - SPR_Height(m_hSprite,0) * 3; - SPR_DrawAdditive(0, x, y, NULL); + // SPR_Draw top + if( m_fAttackFront > 0.4 ) + { + GetPainColor( r, g, b ); + shade = a * max( m_fAttackFront, 0.5 ); + ScaleColors( r, g, b, shade ); + SPR_Set( m_hSprite, r, g, b ); + + x = ScreenWidth / 2 - SPR_Width( m_hSprite, 0 ) / 2; + y = ScreenHeight / 2 - SPR_Height( m_hSprite, 0 ) * 3; + SPR_DrawAdditive( 0, x, y, NULL ); m_fAttackFront = max( 0, m_fAttackFront - fFade ); } else m_fAttackFront = 0; - if (m_fAttackRight > 0.4) + if( m_fAttackRight > 0.4 ) { - GetPainColor(r,g,b); + GetPainColor( r, g, b ); shade = a * max( m_fAttackRight, 0.5 ); - ScaleColors(r, g, b, shade); - SPR_Set(m_hSprite, r, g, b ); + ScaleColors( r, g, b, shade ); + SPR_Set( m_hSprite, r, g, b ); - x = ScreenWidth/2 + SPR_Width(m_hSprite, 1) * 2; - y = ScreenHeight/2 - SPR_Height(m_hSprite,1)/2; - SPR_DrawAdditive(1, x, y, NULL); + x = ScreenWidth / 2 + SPR_Width( m_hSprite, 1 ) * 2; + y = ScreenHeight / 2 - SPR_Height( m_hSprite,1 ) / 2; + SPR_DrawAdditive( 1, x, y, NULL ); m_fAttackRight = max( 0, m_fAttackRight - fFade ); - } else + } + else m_fAttackRight = 0; - if (m_fAttackRear > 0.4) + if( m_fAttackRear > 0.4 ) { - GetPainColor(r,g,b); + GetPainColor( r, g, b ); shade = a * max( m_fAttackRear, 0.5 ); - ScaleColors(r, g, b, shade); - SPR_Set(m_hSprite, r, g, b ); + ScaleColors( r, g, b, shade ); + SPR_Set( m_hSprite, r, g, b ); - x = ScreenWidth/2 - SPR_Width(m_hSprite, 2)/2; - y = ScreenHeight/2 + SPR_Height(m_hSprite,2) * 2; - SPR_DrawAdditive(2, x, y, NULL); + x = ScreenWidth / 2 - SPR_Width( m_hSprite, 2 ) / 2; + y = ScreenHeight / 2 + SPR_Height( m_hSprite, 2 ) * 2; + SPR_DrawAdditive( 2, x, y, NULL ); m_fAttackRear = max( 0, m_fAttackRear - fFade ); - } else + } + else m_fAttackRear = 0; - if (m_fAttackLeft > 0.4) + if( m_fAttackLeft > 0.4 ) { - GetPainColor(r,g,b); + GetPainColor( r, g, b ); shade = a * max( m_fAttackLeft, 0.5 ); - ScaleColors(r, g, b, shade); - SPR_Set(m_hSprite, r, g, b ); + ScaleColors( r, g, b, shade ); + SPR_Set( m_hSprite, r, g, b ); - x = ScreenWidth/2 - SPR_Width(m_hSprite, 3) * 3; - y = ScreenHeight/2 - SPR_Height(m_hSprite,3)/2; - SPR_DrawAdditive(3, x, y, NULL); + x = ScreenWidth / 2 - SPR_Width( m_hSprite, 3 ) * 3; + y = ScreenHeight / 2 - SPR_Height( m_hSprite,3 ) / 2; + SPR_DrawAdditive( 3, x, y, NULL ); m_fAttackLeft = max( 0, m_fAttackLeft - fFade ); } else @@ -375,7 +371,7 @@ int CHudHealth::DrawPain(float flTime) return 1; } -int CHudHealth::DrawDamage(float flTime) +int CHudHealth::DrawDamage( float flTime ) { int i, r, g, b, a; DAMAGE_IMAGE *pdmg; @@ -383,14 +379,14 @@ int CHudHealth::DrawDamage(float flTime) if (!m_bitsDamage) return 1; - UnpackRGB(r,g,b, RGB_YELLOWISH); - - a = (int)( fabs(sin(flTime*2)) * 256.0); + UnpackRGB( r, g, b, RGB_YELLOWISH ); - ScaleColors(r, g, b, a); + a = (int)( fabs( sin( flTime * 2 ) ) * 256.0); + + ScaleColors( r, g, b, a ); // Draw all the items - for (i = 0; i < NUM_DMG_TYPES; i++) + for( i = 0; i < NUM_DMG_TYPES; i++ ) { if (m_bitsDamage & giDmgFlags[i]) { @@ -400,17 +396,16 @@ int CHudHealth::DrawDamage(float flTime) } } - // check for bits that should be expired - for ( i = 0; i < NUM_DMG_TYPES; i++ ) + for( i = 0; i < NUM_DMG_TYPES; i++ ) { - pdmg = &m_dmg[i]; - - if ( m_bitsDamage & giDmgFlags[i] ) + if( m_bitsDamage & giDmgFlags[i] ) { + pdmg = &m_dmg[i]; + pdmg->fExpire = min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire ); - if ( pdmg->fExpire <= flTime // when the time has expired + if( pdmg->fExpire <= flTime // when the time has expired && a < 40 ) // and the flash is at the low point of the cycle { pdmg->fExpire = 0; @@ -419,10 +414,10 @@ int CHudHealth::DrawDamage(float flTime) pdmg->x = pdmg->y = 0; // move everyone above down - for (int j = 0; j < NUM_DMG_TYPES; j++) + for( int j = 0; j < NUM_DMG_TYPES; j++ ) { pdmg = &m_dmg[j]; - if ((pdmg->y) && (pdmg->y < y)) + if( ( pdmg->y ) && ( pdmg->y < y ) ) pdmg->y += giDmgHeight; } @@ -434,49 +429,47 @@ int CHudHealth::DrawDamage(float flTime) return 1; } - -void CHudHealth::UpdateTiles(float flTime, long bitsDamage) +void CHudHealth::UpdateTiles( float flTime, long bitsDamage ) { DAMAGE_IMAGE *pdmg; // Which types are new? long bitsOn = ~m_bitsDamage & bitsDamage; - - for (int i = 0; i < NUM_DMG_TYPES; i++) + + for( int i = 0; i < NUM_DMG_TYPES; i++ ) { pdmg = &m_dmg[i]; // Is this one already on? - if (m_bitsDamage & giDmgFlags[i]) + if( m_bitsDamage & giDmgFlags[i] ) { pdmg->fExpire = flTime + DMG_IMAGE_LIFE; // extend the duration - if (!pdmg->fBaseline) + if( !pdmg->fBaseline ) pdmg->fBaseline = flTime; } // Are we just turning it on? - if (bitsOn & giDmgFlags[i]) + if( bitsOn & giDmgFlags[i] ) { // put this one at the bottom - pdmg->x = giDmgWidth/8; + pdmg->x = giDmgWidth / 8; pdmg->y = ScreenHeight - giDmgHeight * 2; pdmg->fExpire=flTime + DMG_IMAGE_LIFE; - + // move everyone else up - for (int j = 0; j < NUM_DMG_TYPES; j++) + for( int j = 0; j < NUM_DMG_TYPES; j++ ) { - if (j == i) + if( j == i ) continue; pdmg = &m_dmg[j]; - if (pdmg->y) + if( pdmg->y ) pdmg->y -= giDmgHeight; - } pdmg = &m_dmg[i]; - } - } + } + } // damage bits are only turned on here; they are turned off when the draw time has expired (in DrawDamage()) m_bitsDamage |= bitsDamage; diff --git a/cl_dll/health.h b/cl_dll/health.h index 067db4b4..132b9cb4 100644 --- a/cl_dll/health.h +++ b/cl_dll/health.h @@ -23,6 +23,7 @@ #define DMG_IMAGE_NERVE 5 #define DMG_IMAGE_RAD 6 #define DMG_IMAGE_SHOCK 7 + //tf defines #define DMG_IMAGE_CALTROP 8 #define DMG_IMAGE_TRANQ 9 @@ -46,12 +47,10 @@ #define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death #define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death. - // time-based damage //mask off TF-specific stuff too #define DMG_TIMEBASED (~(0xff003fff)) // mask for time-based damage - #define DMG_DROWN (1 << 14) // Drowning #define DMG_FIRSTTIMEBASED DMG_DROWN @@ -78,35 +77,33 @@ // TF Healing Additions for TakeHealth #define DMG_IGNORE_MAXHEALTH DMG_IGNITE + // TF Redefines since we never use the originals #define DMG_NAIL DMG_SLASH #define DMG_NOT_SELF DMG_FREEZE - #define DMG_TRANQ DMG_MORTAR #define DMG_CONCUSS DMG_SONIC - - typedef struct { float fExpire; float fBaseline; int x, y; -} DAMAGE_IMAGE; +}DAMAGE_IMAGE; // //----------------------------------------------------- // -class CHudHealth: public CHudBase +class CHudHealth : public CHudBase { public: virtual int Init( void ); virtual int VidInit( void ); - virtual int Draw(float fTime); + virtual int Draw( float fTime ); virtual void Reset( void ); - int MsgFunc_Health(const char *pszName, int iSize, void *pbuf); - int MsgFunc_Damage(const char *pszName, int iSize, void *pbuf); + int MsgFunc_Health( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_Damage( const char *pszName, int iSize, void *pbuf ); int m_iHealth; int m_HUD_dmg_bio; int m_HUD_cross; @@ -119,9 +116,9 @@ private: HSPRITE m_hDamage; DAMAGE_IMAGE m_dmg[NUM_DMG_TYPES]; - int m_bitsDamage; - int DrawPain(float fTime); - int DrawDamage(float fTime); - void CalcDamageDirection(vec3_t vecFrom); - void UpdateTiles(float fTime, long bits); -}; + int m_bitsDamage; + int DrawPain( float fTime ); + int DrawDamage( float fTime ); + void CalcDamageDirection( vec3_t vecFrom ); + void UpdateTiles( float fTime, long bits ); +}; diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index 17a2d1ab..655272d4 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -21,6 +21,7 @@ This file contains "stubs" of class member implementations so that we can predic add in the functionality you need. ========================== */ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -34,11 +35,11 @@ This file contains "stubs" of class member implementations so that we can predic const Vector g_vecZero = Vector( 0, 0, 0 ); int gmsgWeapPickup = 0; enginefuncs_t g_engfuncs; -globalvars_t *gpGlobals; +globalvars_t *gpGlobals; ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS]; -void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch) { } +void EMIT_SOUND_DYN( edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch ) { } // CBaseEntity Stubs int CBaseEntity :: TakeHealth( float flHealth, int bitsDamageType ) { return 1; } @@ -47,17 +48,17 @@ CBaseEntity *CBaseEntity::GetNextTarget( void ) { return NULL; } int CBaseEntity::Save( CSave &save ) { return 1; } int CBaseEntity::Restore( CRestore &restore ) { return 1; } void CBaseEntity::SetObjectCollisionBox( void ) { } -int CBaseEntity :: Intersects( CBaseEntity *pOther ) { return 0; } +int CBaseEntity :: Intersects( CBaseEntity *pOther ) { return 0; } void CBaseEntity :: MakeDormant( void ) { } int CBaseEntity :: IsDormant( void ) { return 0; } BOOL CBaseEntity :: IsInWorld( void ) { return TRUE; } int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; } -int CBaseEntity :: DamageDecal( int bitsDamageType ) { return -1; } +int CBaseEntity :: DamageDecal( int bitsDamageType ) { return -1; } CBaseEntity * CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } void CBaseEntity::SUB_Remove( void ) { } // CBaseDelay Stubs -void CBaseDelay :: KeyValue( struct KeyValueData_s * ) { } +void CBaseDelay::KeyValue( struct KeyValueData_s * ) { } int CBaseDelay::Restore( class CRestore & ) { return 1; } int CBaseDelay::Save( class CSave & ) { return 1; } @@ -67,7 +68,7 @@ int CBaseAnimating::Save( class CSave & ) { return 1; } // DEBUG Stubs edict_t *DBG_EntOfVars( const entvars_t *pev ) { return NULL; } -void DBG_AssertFunction(BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage) { } +void DBG_AssertFunction( BOOL fExpr, const char *szExpr, const char *szFile, int szLine, const char *szMessage) { } // UTIL_* Stubs void UTIL_PrecacheOther( const char *szClassname ) { } @@ -85,7 +86,7 @@ void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const c // CBaseToggle Stubs int CBaseToggle::Restore( class CRestore & ) { return 1; } int CBaseToggle::Save( class CSave & ) { return 1; } -void CBaseToggle :: KeyValue( struct KeyValueData_s * ) { } +void CBaseToggle::KeyValue( struct KeyValueData_s * ) { } // CGrenade Stubs void CGrenade::BounceSound( void ) { } @@ -93,12 +94,12 @@ void CGrenade::Explode( Vector, Vector ) { } void CGrenade::Explode( TraceResult *, int ) { } void CGrenade::Killed( entvars_t *, int ) { } void CGrenade::Spawn( void ) { } -CGrenade * CGrenade:: ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ){ return 0; } +CGrenade *CGrenade::ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ){ return 0; } CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ){ return 0; } void CGrenade::DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ){ } void UTIL_Remove( CBaseEntity *pEntity ){ } -struct skilldata_t gSkillData; +struct skilldata_t gSkillData; void UTIL_SetSize( entvars_t *pev, const Vector &vecMin, const Vector &vecMax ){ } CBaseEntity *UTIL_FindEntityInSphere( CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius ){ return 0;} @@ -108,140 +109,139 @@ void CBeam::PointEntInit( const Vector &start, int endIndex ) { } CBeam *CBeam::BeamCreate( const char *pSpriteName, int width ) { return NULL; } void CSprite::Expand( float scaleSpeed, float fadeSpeed ) { } - -CBaseEntity* CBaseMonster :: CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) { return NULL; } -void CBaseMonster :: Eat ( float flFullDuration ) { } -BOOL CBaseMonster :: FShouldEat ( void ) { return TRUE; } -void CBaseMonster :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { } -void CBaseMonster :: BarnacleVictimReleased ( void ) { } -void CBaseMonster :: Listen ( void ) { } -float CBaseMonster :: FLSoundVolume ( CSound *pSound ) { return 0.0; } -BOOL CBaseMonster :: FValidateHintType ( short sHint ) { return FALSE; } -void CBaseMonster :: Look ( int iDistance ) { } -int CBaseMonster :: ISoundMask ( void ) { return 0; } -CSound* CBaseMonster :: PBestSound ( void ) { return NULL; } -CSound* CBaseMonster :: PBestScent ( void ) { return NULL; } -float CBaseAnimating :: StudioFrameAdvance ( float flInterval ) { return 0.0; } -void CBaseMonster :: MonsterThink ( void ) { } -void CBaseMonster :: MonsterUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { } -int CBaseMonster :: IgnoreConditions ( void ) { return 0; } -void CBaseMonster :: RouteClear ( void ) { } -void CBaseMonster :: RouteNew ( void ) { } -BOOL CBaseMonster :: FRouteClear ( void ) { return FALSE; } -BOOL CBaseMonster :: FRefreshRoute ( void ) { return 0; } +CBaseEntity* CBaseMonster::CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ) { return NULL; } +void CBaseMonster::Eat( float flFullDuration ) { } +BOOL CBaseMonster::FShouldEat( void ) { return TRUE; } +void CBaseMonster::BarnacleVictimBitten( entvars_t *pevBarnacle ) { } +void CBaseMonster::BarnacleVictimReleased( void ) { } +void CBaseMonster::Listen( void ) { } +float CBaseMonster::FLSoundVolume( CSound *pSound ) { return 0.0; } +BOOL CBaseMonster::FValidateHintType( short sHint ) { return FALSE; } +void CBaseMonster::Look( int iDistance ) { } +int CBaseMonster::ISoundMask( void ) { return 0; } +CSound *CBaseMonster::PBestSound( void ) { return NULL; } +CSound *CBaseMonster::PBestScent( void ) { return NULL; } +float CBaseAnimating::StudioFrameAdvance( float flInterval ) { return 0.0; } +void CBaseMonster::MonsterThink( void ) { } +void CBaseMonster::MonsterUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { } +int CBaseMonster::IgnoreConditions( void ) { return 0; } +void CBaseMonster::RouteClear( void ) { } +void CBaseMonster::RouteNew( void ) { } +BOOL CBaseMonster::FRouteClear( void ) { return FALSE; } +BOOL CBaseMonster::FRefreshRoute( void ) { return 0; } BOOL CBaseMonster::MoveToEnemy( Activity movementAct, float waitTime ) { return FALSE; } BOOL CBaseMonster::MoveToLocation( Activity movementAct, float waitTime, const Vector &goal ) { return FALSE; } BOOL CBaseMonster::MoveToTarget( Activity movementAct, float waitTime ) { return FALSE; } BOOL CBaseMonster::MoveToNode( Activity movementAct, float waitTime, const Vector &goal ) { return FALSE; } int ShouldSimplify( int routeType ) { return TRUE; } -void CBaseMonster :: RouteSimplify( CBaseEntity *pTargetEnt ) { } -BOOL CBaseMonster :: FBecomeProne ( void ) { return TRUE; } -BOOL CBaseMonster :: CheckRangeAttack1 ( float flDot, float flDist ) { return FALSE; } -BOOL CBaseMonster :: CheckRangeAttack2 ( float flDot, float flDist ) { return FALSE; } -BOOL CBaseMonster :: CheckMeleeAttack1 ( float flDot, float flDist ) { return FALSE; } -BOOL CBaseMonster :: CheckMeleeAttack2 ( float flDot, float flDist ) { return FALSE; } -void CBaseMonster :: CheckAttacks ( CBaseEntity *pTarget, float flDist ) { } -BOOL CBaseMonster :: FCanCheckAttacks ( void ) { return FALSE; } -int CBaseMonster :: CheckEnemy ( CBaseEntity *pEnemy ) { return 0; } -void CBaseMonster :: PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { } -BOOL CBaseMonster :: PopEnemy( ) { return FALSE; } -void CBaseMonster :: SetActivity ( Activity NewActivity ) { } -void CBaseMonster :: SetSequenceByName ( char *szSequence ) { } -int CBaseMonster :: CheckLocalMove ( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { return 0; } -float CBaseMonster :: OpenDoorAndWait( entvars_t *pevDoor ) { return 0.0; } -void CBaseMonster :: AdvanceRoute ( float distance ) { } -int CBaseMonster :: RouteClassify( int iMoveFlag ) { return 0; } -BOOL CBaseMonster :: BuildRoute ( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ) { return FALSE; } -void CBaseMonster :: InsertWaypoint ( Vector vecLocation, int afMoveFlags ) { } -BOOL CBaseMonster :: FTriangulate ( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ) { return FALSE; } -void CBaseMonster :: Move ( float flInterval ) { } -BOOL CBaseMonster:: ShouldAdvanceRoute( float flWaypointDist ) { return FALSE; } +void CBaseMonster::RouteSimplify( CBaseEntity *pTargetEnt ) { } +BOOL CBaseMonster::FBecomeProne( void ) { return TRUE; } +BOOL CBaseMonster::CheckRangeAttack1( float flDot, float flDist ) { return FALSE; } +BOOL CBaseMonster::CheckRangeAttack2( float flDot, float flDist ) { return FALSE; } +BOOL CBaseMonster::CheckMeleeAttack1( float flDot, float flDist ) { return FALSE; } +BOOL CBaseMonster::CheckMeleeAttack2( float flDot, float flDist ) { return FALSE; } +void CBaseMonster::CheckAttacks( CBaseEntity *pTarget, float flDist ) { } +BOOL CBaseMonster::FCanCheckAttacks( void ) { return FALSE; } +int CBaseMonster::CheckEnemy( CBaseEntity *pEnemy ) { return 0; } +void CBaseMonster::PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { } +BOOL CBaseMonster::PopEnemy() { return FALSE; } +void CBaseMonster::SetActivity( Activity NewActivity ) { } +void CBaseMonster::SetSequenceByName( char *szSequence ) { } +int CBaseMonster::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { return 0; } +float CBaseMonster::OpenDoorAndWait( entvars_t *pevDoor ) { return 0.0; } +void CBaseMonster::AdvanceRoute( float distance ) { } +int CBaseMonster::RouteClassify( int iMoveFlag ) { return 0; } +BOOL CBaseMonster::BuildRoute( const Vector &vecGoal, int iMoveFlag, CBaseEntity *pTarget ) { return FALSE; } +void CBaseMonster::InsertWaypoint( Vector vecLocation, int afMoveFlags ) { } +BOOL CBaseMonster::FTriangulate( const Vector &vecStart , const Vector &vecEnd, float flDist, CBaseEntity *pTargetEnt, Vector *pApex ) { return FALSE; } +void CBaseMonster::Move( float flInterval ) { } +BOOL CBaseMonster::ShouldAdvanceRoute( float flWaypointDist ) { return FALSE; } void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, float flInterval ) { } -void CBaseMonster :: MonsterInit ( void ) { } -void CBaseMonster :: MonsterInitThink ( void ) { } -void CBaseMonster :: StartMonster ( void ) { } -void CBaseMonster :: MovementComplete( void ) { } +void CBaseMonster::MonsterInit( void ) { } +void CBaseMonster::MonsterInitThink( void ) { } +void CBaseMonster::StartMonster( void ) { } +void CBaseMonster::MovementComplete( void ) { } int CBaseMonster::TaskIsRunning( void ) { return 0; } -int CBaseMonster::IRelationship ( CBaseEntity *pTarget ) { return 0; } -BOOL CBaseMonster :: FindCover ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; } -BOOL CBaseMonster :: BuildNearestRoute ( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; } -CBaseEntity *CBaseMonster :: BestVisibleEnemy ( void ) { return NULL; } -BOOL CBaseMonster :: FInViewCone ( CBaseEntity *pEntity ) { return FALSE; } -BOOL CBaseMonster :: FInViewCone ( Vector *pOrigin ) { return FALSE; } -BOOL CBaseEntity :: FVisible ( CBaseEntity *pEntity ) { return FALSE; } -BOOL CBaseEntity :: FVisible ( const Vector &vecOrigin ) { return FALSE; } -void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { } -float CBaseMonster::FlYawDiff ( void ) { return 0.0; } -float CBaseMonster::ChangeYaw ( int yawSpeed ) { return 0; } -float CBaseMonster::VecToYaw ( Vector vecDir ) { return 0.0; } -int CBaseAnimating :: LookupActivity ( int activity ) { return 0; } -int CBaseAnimating :: LookupActivityHeaviest ( int activity ) { return 0; } -void CBaseMonster :: SetEyePosition ( void ) { } -int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; } -void CBaseAnimating :: ResetSequenceInfo ( ) { } -BOOL CBaseAnimating :: GetSequenceFlags( ) { return FALSE; } -void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { } -void CBaseMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) { } -float CBaseAnimating :: SetBoneController ( int iController, float flValue ) { return 0.0; } -void CBaseAnimating :: InitBoneControllers ( void ) { } -float CBaseAnimating :: SetBlending ( int iBlender, float flValue ) { return 0; } -void CBaseAnimating :: GetBonePosition ( int iBone, Vector &origin, Vector &angles ) { } -void CBaseAnimating :: GetAttachment ( int iAttachment, Vector &origin, Vector &angles ) { } -int CBaseAnimating :: FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { return -1; } -void CBaseAnimating :: GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { } -void CBaseAnimating :: SetBodygroup( int iGroup, int iValue ) { } -int CBaseAnimating :: GetBodygroup( int iGroup ) { return 0; } -Vector CBaseMonster :: GetGunPosition( void ) { return g_vecZero; } -void CBaseEntity::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } -void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ) { } -void CBaseEntity :: TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { } -void CBaseMonster :: MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ) { } -BOOL CBaseMonster :: FGetNodeRoute ( Vector vecDest ) { return TRUE; } -int CBaseMonster :: FindHintNode ( void ) { return NO_NODE; } +int CBaseMonster::IRelationship( CBaseEntity *pTarget ) { return 0; } +BOOL CBaseMonster::FindCover( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; } +BOOL CBaseMonster::BuildNearestRoute( Vector vecThreat, Vector vecViewOffset, float flMinDist, float flMaxDist ) { return FALSE; } +CBaseEntity *CBaseMonster::BestVisibleEnemy( void ) { return NULL; } +BOOL CBaseMonster::FInViewCone( CBaseEntity *pEntity ) { return FALSE; } +BOOL CBaseMonster::FInViewCone( Vector *pOrigin ) { return FALSE; } +BOOL CBaseEntity::FVisible( CBaseEntity *pEntity ) { return FALSE; } +BOOL CBaseEntity::FVisible( const Vector &vecOrigin ) { return FALSE; } +void CBaseMonster::MakeIdealYaw( Vector vecTarget ) { } +float CBaseMonster::FlYawDiff( void ) { return 0.0; } +float CBaseMonster::ChangeYaw( int yawSpeed ) { return 0; } +float CBaseMonster::VecToYaw( Vector vecDir ) { return 0.0; } +int CBaseAnimating::LookupActivity( int activity ) { return 0; } +int CBaseAnimating::LookupActivityHeaviest( int activity ) { return 0; } +void CBaseMonster::SetEyePosition( void ) { } +int CBaseAnimating::LookupSequence( const char *label ) { return 0; } +void CBaseAnimating::ResetSequenceInfo() { } +BOOL CBaseAnimating::GetSequenceFlags() { return FALSE; } +void CBaseAnimating::DispatchAnimEvents( float flInterval ) { } +void CBaseMonster::HandleAnimEvent( MonsterEvent_t *pEvent ) { } +float CBaseAnimating::SetBoneController ( int iController, float flValue ) { return 0.0; } +void CBaseAnimating::InitBoneControllers ( void ) { } +float CBaseAnimating::SetBlending( int iBlender, float flValue ) { return 0; } +void CBaseAnimating::GetBonePosition( int iBone, Vector &origin, Vector &angles ) { } +void CBaseAnimating::GetAttachment( int iAttachment, Vector &origin, Vector &angles ) { } +int CBaseAnimating::FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ) { return -1; } +void CBaseAnimating::GetAutomovement( Vector &origin, Vector &angles, float flInterval ) { } +void CBaseAnimating::SetBodygroup( int iGroup, int iValue ) { } +int CBaseAnimating::GetBodygroup( int iGroup ) { return 0; } +Vector CBaseMonster::GetGunPosition( void ) { return g_vecZero; } +void CBaseEntity::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { } +void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ) { } +void CBaseEntity::TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { } +void CBaseMonster::MakeDamageBloodDecal( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ) { } +BOOL CBaseMonster::FGetNodeRoute( Vector vecDest ) { return TRUE; } +int CBaseMonster::FindHintNode( void ) { return NO_NODE; } void CBaseMonster::ReportAIState( void ) { } -void CBaseMonster :: KeyValue( KeyValueData *pkvd ) { } -BOOL CBaseMonster :: FCheckAITrigger ( void ) { return FALSE; } -int CBaseMonster :: CanPlaySequence( BOOL fDisregardMonsterState, int interruptLevel ) { return FALSE; } -BOOL CBaseMonster :: FindLateralCover ( const Vector &vecThreat, const Vector &vecViewOffset ) { return FALSE; } -Vector CBaseMonster :: ShootAtEnemy( const Vector &shootOrigin ) { return g_vecZero; } -BOOL CBaseMonster :: FacingIdeal( void ) { return FALSE; } -BOOL CBaseMonster :: FCanActiveIdle ( void ) { return FALSE; } +void CBaseMonster::KeyValue( KeyValueData *pkvd ) { } +BOOL CBaseMonster::FCheckAITrigger( void ) { return FALSE; } +int CBaseMonster::CanPlaySequence( BOOL fDisregardMonsterState, int interruptLevel ) { return FALSE; } +BOOL CBaseMonster::FindLateralCover( const Vector &vecThreat, const Vector &vecViewOffset ) { return FALSE; } +Vector CBaseMonster::ShootAtEnemy( const Vector &shootOrigin ) { return g_vecZero; } +BOOL CBaseMonster::FacingIdeal( void ) { return FALSE; } +BOOL CBaseMonster::FCanActiveIdle( void ) { return FALSE; } void CBaseMonster::PlaySentence( const char *pszSentence, float duration, float volume, float attenuation ) { } void CBaseMonster::PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ) { } void CBaseMonster::SentenceStop( void ) { } void CBaseMonster::CorpseFallThink( void ) { } -void CBaseMonster :: MonsterInitDead( void ) { } -BOOL CBaseMonster :: BBoxFlat ( void ) { return TRUE; } -BOOL CBaseMonster :: GetEnemy ( void ) { return FALSE; } -void CBaseMonster :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } -CBaseEntity* CBaseMonster :: DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; } -BOOL CBaseMonster :: ShouldFadeOnDeath( void ) { return FALSE; } -void CBaseMonster :: RadiusDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } -void CBaseMonster :: RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } +void CBaseMonster::MonsterInitDead( void ) { } +BOOL CBaseMonster::BBoxFlat( void ) { return TRUE; } +BOOL CBaseMonster::GetEnemy( void ) { return FALSE; } +void CBaseMonster::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } +CBaseEntity* CBaseMonster::DropItem( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; } +BOOL CBaseMonster::ShouldFadeOnDeath( void ) { return FALSE; } +void CBaseMonster::RadiusDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } +void CBaseMonster::RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } void CBaseMonster::FadeMonster( void ) { } -void CBaseMonster :: GibMonster( void ) { } -BOOL CBaseMonster :: HasHumanGibs( void ) { return FALSE; } -BOOL CBaseMonster :: HasAlienGibs( void ) { return FALSE; } -Activity CBaseMonster :: GetDeathActivity ( void ) { return ACT_DIE_HEADSHOT; } -MONSTERSTATE CBaseMonster :: GetIdealState ( void ) { return MONSTERSTATE_ALERT; } -Schedule_t* CBaseMonster :: GetScheduleOfType ( int Type ) { return NULL; } -Schedule_t *CBaseMonster :: GetSchedule ( void ) { return NULL; } -void CBaseMonster :: RunTask ( Task_t *pTask ) { } -void CBaseMonster :: StartTask ( Task_t *pTask ) { } +void CBaseMonster::GibMonster( void ) { } +BOOL CBaseMonster::HasHumanGibs( void ) { return FALSE; } +BOOL CBaseMonster::HasAlienGibs( void ) { return FALSE; } +Activity CBaseMonster::GetDeathActivity( void ) { return ACT_DIE_HEADSHOT; } +MONSTERSTATE CBaseMonster::GetIdealState( void ) { return MONSTERSTATE_ALERT; } +Schedule_t* CBaseMonster::GetScheduleOfType( int Type ) { return NULL; } +Schedule_t *CBaseMonster::GetSchedule( void ) { return NULL; } +void CBaseMonster::RunTask( Task_t *pTask ) { } +void CBaseMonster::StartTask( Task_t *pTask ) { } Schedule_t *CBaseMonster::ScheduleFromName( const char *pName ) { return NULL;} void CBaseMonster::BecomeDead( void ) {} -void CBaseMonster :: RunAI ( void ) {} -void CBaseMonster :: Killed( entvars_t *pevAttacker, int iGib ) {} -int CBaseMonster :: TakeHealth (float flHealth, int bitsDamageType) { return 0; } -int CBaseMonster :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; } +void CBaseMonster::RunAI( void ) {} +void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) {} +int CBaseMonster::TakeHealth(float flHealth, int bitsDamageType) { return 0; } +int CBaseMonster::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; } int CBaseMonster::Restore( class CRestore & ) { return 1; } int CBaseMonster::Save( class CSave & ) { return 1; } -int TrainSpeed(int iSpeed, int iMax) { return 0; } -void CBasePlayer :: DeathSound( void ) { } -int CBasePlayer :: TakeHealth( float flHealth, int bitsDamageType ) { return 0; } -void CBasePlayer :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } -int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; } +int TrainSpeed( int iSpeed, int iMax ) { return 0; } +void CBasePlayer::DeathSound( void ) { } +int CBasePlayer::TakeHealth( float flHealth, int bitsDamageType ) { return 0; } +void CBasePlayer::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } +int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { return 0; } void CBasePlayer::PackDeadPlayerItems( void ) { } void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { } void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) { } @@ -250,77 +250,77 @@ BOOL CBasePlayer::IsOnLadder( void ) { return FALSE; } void CBasePlayer::PlayerDeathThink(void) { } void CBasePlayer::StartDeathCam( void ) { } void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) { } -void CBasePlayer::PlayerUse ( void ) { } +void CBasePlayer::PlayerUse( void ) { } void CBasePlayer::Jump() { } -void CBasePlayer::Duck( ) { } -int CBasePlayer::Classify ( void ) { return 0; } +void CBasePlayer::Duck() { } +int CBasePlayer::Classify( void ) { return 0; } void CBasePlayer::PreThink(void) { } void CBasePlayer::CheckTimeBasedDamage() { } -void CBasePlayer :: UpdateGeigerCounter( void ) { } +void CBasePlayer::UpdateGeigerCounter( void ) { } void CBasePlayer::CheckSuitUpdate() { } void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { } -void CBasePlayer :: UpdatePlayerSound ( void ) { } +void CBasePlayer::UpdatePlayerSound ( void ) { } void CBasePlayer::PostThink() { } -void CBasePlayer :: Precache( void ) { } +void CBasePlayer::Precache( void ) { } int CBasePlayer::Save( CSave &save ) { return 0; } -void CBasePlayer::RenewItems(void) { } +void CBasePlayer::RenewItems( void ) { } int CBasePlayer::Restore( CRestore &restore ) { return 0; } void CBasePlayer::SelectNextItem( int iItem ) { } BOOL CBasePlayer::HasWeapons( void ) { return FALSE; } void CBasePlayer::SelectPrevItem( int iItem ) { } CBaseEntity *FindEntityForward( CBaseEntity *pMe ) { return NULL; } -BOOL CBasePlayer :: FlashlightIsOn( void ) { return FALSE; } -void CBasePlayer :: FlashlightTurnOn( void ) { } -void CBasePlayer :: FlashlightTurnOff( void ) { } -void CBasePlayer :: ForceClientDllUpdate( void ) { } -void CBasePlayer::ImpulseCommands( ) { } +BOOL CBasePlayer::FlashlightIsOn( void ) { return FALSE; } +void CBasePlayer::FlashlightTurnOn( void ) { } +void CBasePlayer::FlashlightTurnOff( void ) { } +void CBasePlayer::ForceClientDllUpdate( void ) { } +void CBasePlayer::ImpulseCommands() { } void CBasePlayer::CheatImpulseCommands( int iImpulse ) { } int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; } int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; } void CBasePlayer::ItemPreFrame() { } void CBasePlayer::ItemPostFrame() { } int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; } -int CBasePlayer::GetAmmoIndex(const char *psz) { return -1; } +int CBasePlayer::GetAmmoIndex( const char *psz ) { return -1; } void CBasePlayer::SendAmmoUpdate(void) { } -void CBasePlayer :: UpdateClientData( void ) { } -BOOL CBasePlayer :: FBecomeProne ( void ) { return TRUE; } -void CBasePlayer :: BarnacleVictimBitten ( entvars_t *pevBarnacle ) { } -void CBasePlayer :: BarnacleVictimReleased ( void ) { } -int CBasePlayer :: Illumination( void ) { return 0; } -void CBasePlayer :: EnableControl(BOOL fControl) { } -Vector CBasePlayer :: GetAutoaimVector( float flDelta ) { return g_vecZero; } -Vector CBasePlayer :: AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; } -void CBasePlayer :: ResetAutoaim( ) { } -void CBasePlayer :: SetCustomDecalFrames( int nFrames ) { } -int CBasePlayer :: GetCustomDecalFrames( void ) { return -1; } -void CBasePlayer::DropPlayerItem ( char *pszItemName ) { } +void CBasePlayer::UpdateClientData( void ) { } +BOOL CBasePlayer::FBecomeProne( void ) { return TRUE; } +void CBasePlayer::BarnacleVictimBitten( entvars_t *pevBarnacle ) { } +void CBasePlayer::BarnacleVictimReleased( void ) { } +int CBasePlayer::Illumination( void ) { return 0; } +void CBasePlayer::EnableControl( BOOL fControl ) { } +Vector CBasePlayer::GetAutoaimVector( float flDelta ) { return g_vecZero; } +Vector CBasePlayer::AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ) { return g_vecZero; } +void CBasePlayer::ResetAutoaim() { } +void CBasePlayer::SetCustomDecalFrames( int nFrames ) { } +int CBasePlayer::GetCustomDecalFrames( void ) { return -1; } +void CBasePlayer::DropPlayerItem( char *pszItemName ) { } BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; } -BOOL CBasePlayer :: SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; } -Vector CBasePlayer :: GetGunPosition( void ) { return g_vecZero; } +BOOL CBasePlayer::SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; } +Vector CBasePlayer::GetGunPosition( void ) { return g_vecZero; } const char *CBasePlayer::TeamID( void ) { return ""; } -int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax ) { return 0; } +int CBasePlayer::GiveAmmo( int iCount, char *szName, int iMax ) { return 0; } void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { } void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { } -void ClearMultiDamage(void) { } -void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) { } +void ClearMultiDamage( void ) { } +void ApplyMultiDamage( entvars_t *pevInflictor, entvars_t *pevAttacker ) { } void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) { } -void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) { } +void SpawnBlood( Vector vecSpot, int bloodColor, float flDamage ) { } int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { return 0; } void DecalGunshot( TraceResult *pTrace, int iBulletType ) { } -void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { } +void EjectBrass( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { } void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) { } int CBasePlayerItem::Restore( class CRestore & ) { return 1; } int CBasePlayerItem::Save( class CSave & ) { return 1; } int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; } int CBasePlayerWeapon::Save( class CSave & ) { return 1; } -void CBasePlayerItem :: SetObjectCollisionBox( void ) { } -void CBasePlayerItem :: FallInit( void ) { } -void CBasePlayerItem::FallThink ( void ) { } +void CBasePlayerItem::SetObjectCollisionBox( void ) { } +void CBasePlayerItem::FallInit( void ) { } +void CBasePlayerItem::FallThink( void ) { } void CBasePlayerItem::Materialize( void ) { } void CBasePlayerItem::AttemptToMaterialize( void ) { } -void CBasePlayerItem :: CheckRespawn ( void ) { } -CBaseEntity* CBasePlayerItem::Respawn( void ) { return NULL; } +void CBasePlayerItem::CheckRespawn( void ) { } +CBaseEntity *CBasePlayerItem::Respawn( void ) { return NULL; } void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { } void CBasePlayerItem::DestroyItem( void ) { } int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) { return TRUE; } @@ -331,17 +331,17 @@ void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { } int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; } int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; } int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; } -BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; } -BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return TRUE; } -BOOL CBasePlayerWeapon :: IsUseable( void ) { return TRUE; } +BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; } +BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return TRUE; } +BOOL CBasePlayerWeapon::IsUseable( void ) { return TRUE; } int CBasePlayerWeapon::PrimaryAmmoIndex( void ) { return -1; } -int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; } +int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; } void CBasePlayerAmmo::Spawn( void ) { } CBaseEntity* CBasePlayerAmmo::Respawn( void ) { return this; } void CBasePlayerAmmo::Materialize( void ) { } -void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther ) { } +void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) { } int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { return 0; } int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { return 0; } void CBasePlayerWeapon::RetireWeapon( void ) { } -void CSoundEnt::InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {} -void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){} \ No newline at end of file +void CSoundEnt::InsertSound( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) {} +void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){} diff --git a/cl_dll/hl/hl_events.cpp b/cl_dll/hl/hl_events.cpp index 7e9c730b..c79279dd 100644 --- a/cl_dll/hl/hl_events.cpp +++ b/cl_dll/hl/hl_events.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "../hud.h" #include "../cl_util.h" #include "event_api.h" @@ -38,8 +39,6 @@ void EV_HornetGunFire( struct event_args_s *args ); void EV_TripmineFire( struct event_args_s *args ); void EV_SnarkFire( struct event_args_s *args ); - - void EV_TrainPitchAdjust( struct event_args_s *args ); } @@ -58,23 +57,23 @@ That was what we were going to do, but we ran out of time...oh well. */ void Game_HookEvents( void ) { - gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 ); - gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 ); - gEngfuncs.pfnHookEvent( "events/shotgun1.sc", EV_FireShotGunSingle ); - gEngfuncs.pfnHookEvent( "events/shotgun2.sc", EV_FireShotGunDouble ); - gEngfuncs.pfnHookEvent( "events/mp5.sc", EV_FireMP5 ); - gEngfuncs.pfnHookEvent( "events/mp52.sc", EV_FireMP52 ); - gEngfuncs.pfnHookEvent( "events/python.sc", EV_FirePython ); - gEngfuncs.pfnHookEvent( "events/gauss.sc", EV_FireGauss ); - gEngfuncs.pfnHookEvent( "events/gaussspin.sc", EV_SpinGauss ); - gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust ); - gEngfuncs.pfnHookEvent( "events/crowbar.sc", EV_Crowbar ); - gEngfuncs.pfnHookEvent( "events/crossbow1.sc", EV_FireCrossbow ); - gEngfuncs.pfnHookEvent( "events/crossbow2.sc", EV_FireCrossbow2 ); - gEngfuncs.pfnHookEvent( "events/rpg.sc", EV_FireRpg ); - gEngfuncs.pfnHookEvent( "events/egon_fire.sc", EV_EgonFire ); - gEngfuncs.pfnHookEvent( "events/egon_stop.sc", EV_EgonStop ); - gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire ); - gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire ); - gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire ); + gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 ); + gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 ); + gEngfuncs.pfnHookEvent( "events/shotgun1.sc", EV_FireShotGunSingle ); + gEngfuncs.pfnHookEvent( "events/shotgun2.sc", EV_FireShotGunDouble ); + gEngfuncs.pfnHookEvent( "events/mp5.sc", EV_FireMP5 ); + gEngfuncs.pfnHookEvent( "events/mp52.sc", EV_FireMP52 ); + gEngfuncs.pfnHookEvent( "events/python.sc", EV_FirePython ); + gEngfuncs.pfnHookEvent( "events/gauss.sc", EV_FireGauss ); + gEngfuncs.pfnHookEvent( "events/gaussspin.sc", EV_SpinGauss ); + gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust ); + gEngfuncs.pfnHookEvent( "events/crowbar.sc", EV_Crowbar ); + gEngfuncs.pfnHookEvent( "events/crossbow1.sc", EV_FireCrossbow ); + gEngfuncs.pfnHookEvent( "events/crossbow2.sc", EV_FireCrossbow2 ); + gEngfuncs.pfnHookEvent( "events/rpg.sc", EV_FireRpg ); + gEngfuncs.pfnHookEvent( "events/egon_fire.sc", EV_EgonFire ); + gEngfuncs.pfnHookEvent( "events/egon_stop.sc", EV_EgonStop ); + gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire ); + gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire ); + gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire ); } diff --git a/cl_dll/hl/hl_objects.cpp b/cl_dll/hl/hl_objects.cpp index e61db884..b51ee693 100644 --- a/cl_dll/hl/hl_objects.cpp +++ b/cl_dll/hl/hl_objects.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "../hud.h" #include "../cl_util.h" #include "../demo.h" @@ -30,7 +31,7 @@ extern BEAM *pBeam; extern BEAM *pBeam2; void HUD_GetLastOrg( float *org ); -void UpdateBeams ( void ) +void UpdateBeams( void ) { vec3_t forward, vecSrc, vecEnd, origin, angles, right, up; vec3_t view_ofs; @@ -47,32 +48,32 @@ void UpdateBeams ( void ) AngleVectors( angles, forward, right, up ); VectorCopy( origin, vecSrc ); - + VectorMA( vecSrc, 2048, forward, vecEnd ); gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); - + // Store off the old count gEngfuncs.pEventAPI->EV_PushPMStates(); - + // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr ); gEngfuncs.pEventAPI->EV_PopPMStates(); - if ( pBeam ) + if( pBeam ) { pBeam->target = tr.endpos; - pBeam->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. + pBeam->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. } - - if ( pBeam2 ) + + if( pBeam2 ) { pBeam2->target = tr.endpos; - pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. + pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. } } @@ -85,6 +86,6 @@ Add game specific, client-side objects here */ void Game_AddObjects( void ) { - if ( pBeam && pBeam2 ) + if( pBeam && pBeam2 ) UpdateBeams(); } diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 193c9d49..c712b76f 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ + #include "extdll.h" #include "util.h" #include "cbase.h" @@ -35,19 +36,19 @@ extern globalvars_t *gpGlobals; extern int g_iUser1; // Pool of client side entities/entvars_t -static entvars_t ev[ 32 ]; -static int num_ents = 0; +static entvars_t ev[32]; +static int num_ents = 0; // The entity we'll use to represent the local client -static CBasePlayer player; +static CBasePlayer player; // Local version of game .dll global variables ( time, etc. ) -static globalvars_t Globals; +static globalvars_t Globals; -static CBasePlayerWeapon *g_pWpns[ 32 ]; +static CBasePlayerWeapon *g_pWpns[32]; float g_flApplyVel = 0.0; -int g_irunninggausspred = 0; +int g_irunninggausspred = 0; vec3_t previousorigin; @@ -67,7 +68,6 @@ CSatchel g_Satchel; CTripmine g_Tripmine; CSqueak g_Snark; - /* ====================== AlertMessage @@ -77,12 +77,12 @@ Print debug messages to console */ void AlertMessage( ALERT_TYPE atype, char *szFmt, ... ) { - va_list argptr; - static char string[1024]; - - va_start (argptr, szFmt); - vsprintf (string, szFmt,argptr); - va_end (argptr); + va_list argptr; + static char string[1024]; + + va_start( argptr, szFmt ); + vsprintf( string, szFmt, argptr ); + va_end( argptr ); gEngfuncs.Con_Printf( "cl: " ); gEngfuncs.Con_Printf( string ); @@ -90,12 +90,13 @@ void AlertMessage( ALERT_TYPE atype, char *szFmt, ... ) //Returns if it's multiplayer. //Mostly used by the client side weapons. -bool bIsMultiplayer ( void ) +bool bIsMultiplayer( void ) { return gEngfuncs.GetMaxClients() == 1 ? 0 : 1; } + //Just loads a v_ model. -void LoadVModel ( char *szViewModel, CBasePlayer *m_pPlayer ) +void LoadVModel( char *szViewModel, CBasePlayer *m_pPlayer ) { gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel ); } @@ -110,50 +111,49 @@ we set up the m_pPlayer field. */ void HUD_PrepEntity( CBaseEntity *pEntity, CBasePlayer *pWeaponOwner ) { - memset( &ev[ num_ents ], 0, sizeof( entvars_t ) ); - pEntity->pev = &ev[ num_ents++ ]; + memset( &ev[num_ents], 0, sizeof(entvars_t) ); + pEntity->pev = &ev[num_ents++]; pEntity->Precache(); pEntity->Spawn(); - if ( pWeaponOwner ) + if( pWeaponOwner ) { ItemInfo info; - - ((CBasePlayerWeapon *)pEntity)->m_pPlayer = pWeaponOwner; - - ((CBasePlayerWeapon *)pEntity)->GetItemInfo( &info ); - g_pWpns[ info.iId ] = (CBasePlayerWeapon *)pEntity; + ( (CBasePlayerWeapon *)pEntity )->m_pPlayer = pWeaponOwner; + + ( (CBasePlayerWeapon *)pEntity )->GetItemInfo( &info ); + + g_pWpns[info.iId] = (CBasePlayerWeapon *)pEntity; } } /* ===================== -CBaseEntity :: Killed +CBaseEntity::Killed If weapons code "kills" an entity, just set its effects to EF_NODRAW ===================== */ -void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib ) +void CBaseEntity::Killed( entvars_t *pevAttacker, int iGib ) { pev->effects |= EF_NODRAW; } /* ===================== -CBasePlayerWeapon :: DefaultReload +CBasePlayerWeapon::DefaultReload ===================== */ -BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay, int body ) +BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, int body ) { - - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; - int j = min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + int j = min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); - if (j == 0) + if( j == 0 ) return FALSE; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + fDelay; @@ -169,32 +169,32 @@ BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay, /* ===================== -CBasePlayerWeapon :: CanDeploy +CBasePlayerWeapon::CanDeploy ===================== */ -BOOL CBasePlayerWeapon :: CanDeploy( void ) +BOOL CBasePlayerWeapon::CanDeploy( void ) { BOOL bHasAmmo = 0; - if ( !pszAmmo1() ) + if( !pszAmmo1() ) { // this weapon doesn't use ammo, can always deploy. return TRUE; } - if ( pszAmmo1() ) + if( pszAmmo1() ) { - bHasAmmo |= (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] != 0); + bHasAmmo |= ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] != 0 ); } - if ( pszAmmo2() ) + if( pszAmmo2() ) { - bHasAmmo |= (m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] != 0); + bHasAmmo |= ( m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] != 0 ); } - if (m_iClip > 0) + if( m_iClip > 0 ) { bHasAmmo |= 1; } - if (!bHasAmmo) + if( !bHasAmmo ) { return FALSE; } @@ -204,17 +204,17 @@ BOOL CBasePlayerWeapon :: CanDeploy( void ) /* ===================== -CBasePlayerWeapon :: DefaultDeploy +CBasePlayerWeapon::DefaultDeploy ===================== */ -BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal, int body ) +BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal, int body ) { - if ( !CanDeploy() ) + if( !CanDeploy() ) return FALSE; gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel ); - + SendWeaponAnim( iAnim, skiplocal, body ); g_irunninggausspred = false; @@ -225,13 +225,13 @@ BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel, /* ===================== -CBasePlayerWeapon :: PlayEmptySound +CBasePlayerWeapon::PlayEmptySound ===================== */ -BOOL CBasePlayerWeapon :: PlayEmptySound( void ) +BOOL CBasePlayerWeapon::PlayEmptySound( void ) { - if (m_iPlayEmptySound) + if( m_iPlayEmptySound ) { HUD_PlaySound( "weapons/357_cock1.wav", 0.8 ); m_iPlayEmptySound = 0; @@ -242,11 +242,11 @@ BOOL CBasePlayerWeapon :: PlayEmptySound( void ) /* ===================== -CBasePlayerWeapon :: ResetEmptySound +CBasePlayerWeapon::ResetEmptySound ===================== */ -void CBasePlayerWeapon :: ResetEmptySound( void ) +void CBasePlayerWeapon::ResetEmptySound( void ) { m_iPlayEmptySound = 1; } @@ -275,7 +275,7 @@ Animate weapon model void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body ) { m_pPlayer->pev->weaponanim = iAnim; - + HUD_SendWeaponAnim( iAnim, body, 0 ); } @@ -290,16 +290,16 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD { float x, y, z; - for ( ULONG iShot = 1; iShot <= cShots; iShot++ ) + for( ULONG iShot = 1; iShot <= cShots; iShot++ ) { - if ( pevAttacker == NULL ) + if( pevAttacker == NULL ) { // get circular gaussian spread do { - x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); - y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5); - z = x*x+y*y; - } while (z > 1); + x = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + y = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + z = x * x + y * y; + } while( z > 1 ); } else { @@ -308,11 +308,10 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5, 0.5 ); y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 ); z = x * x + y * y; - } - + } } - return Vector ( x * vecSpread.x, y * vecSpread.y, 0.0 ); + return Vector( x * vecSpread.x, y * vecSpread.y, 0.0 ); } /* @@ -324,24 +323,24 @@ Handles weapon firing, reloading, etc. */ void CBasePlayerWeapon::ItemPostFrame( void ) { - if ((m_fInReload) && (m_pPlayer->m_flNextAttack <= 0.0)) + if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= 0.0 ) ) { #if 0 // FIXME, need ammo on client to make this work right // complete the reload. - int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); // Add them to the clip m_iClip += j; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j; -#else +#else m_iClip += 10; #endif m_fInReload = FALSE; } - if ((m_pPlayer->pev->button & IN_ATTACK2) && (m_flNextSecondaryAttack <= 0.0)) + if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && ( m_flNextSecondaryAttack <= 0.0 ) ) { - if ( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) + if( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) { m_fFireOnEmpty = TRUE; } @@ -349,28 +348,27 @@ void CBasePlayerWeapon::ItemPostFrame( void ) SecondaryAttack(); m_pPlayer->pev->button &= ~IN_ATTACK2; } - else if ((m_pPlayer->pev->button & IN_ATTACK) && (m_flNextPrimaryAttack <= 0.0)) + else if( ( m_pPlayer->pev->button & IN_ATTACK ) && ( m_flNextPrimaryAttack <= 0.0 ) ) { - if ( (m_iClip == 0 && pszAmmo1()) || (iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) ) + if( ( m_iClip == 0 && pszAmmo1() ) || ( iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) ) { m_fFireOnEmpty = TRUE; } PrimaryAttack(); } - else if ( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) + else if( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) { // reload when reload is pressed, or if no buttons are down and weapon is empty. Reload(); } - else if ( !(m_pPlayer->pev->button & (IN_ATTACK|IN_ATTACK2) ) ) + else if( !( m_pPlayer->pev->button & ( IN_ATTACK | IN_ATTACK2 ) ) ) { // no fire buttons down - m_fFireOnEmpty = FALSE; // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing - if ( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < 0.0 ) + if( m_iClip == 0 && !( iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack < 0.0 ) { Reload(); return; @@ -379,9 +377,9 @@ void CBasePlayerWeapon::ItemPostFrame( void ) WeaponIdle( ); return; } - + // catch all - if ( ShouldWeaponIdle() ) + if( ShouldWeaponIdle() ) { WeaponIdle(); } @@ -394,29 +392,28 @@ CBasePlayer::SelectItem Switch weapons ===================== */ -void CBasePlayer::SelectItem(const char *pstr) +void CBasePlayer::SelectItem( const char *pstr ) { - if (!pstr) + if( !pstr ) return; CBasePlayerItem *pItem = NULL; - if (!pItem) + if( !pItem ) return; - - if (pItem == m_pActiveItem) + if( pItem == m_pActiveItem ) return; - if (m_pActiveItem) - m_pActiveItem->Holster( ); - + if( m_pActiveItem ) + m_pActiveItem->Holster(); + m_pLastItem = m_pActiveItem; m_pActiveItem = pItem; - if (m_pActiveItem) + if( m_pActiveItem ) { - m_pActiveItem->Deploy( ); + m_pActiveItem->Deploy(); } } @@ -426,21 +423,21 @@ CBasePlayer::SelectLastItem ===================== */ -void CBasePlayer::SelectLastItem(void) +void CBasePlayer::SelectLastItem( void ) { - if (!m_pLastItem) + if( !m_pLastItem ) { return; } - if ( m_pActiveItem && !m_pActiveItem->CanHolster() ) + if( m_pActiveItem && !m_pActiveItem->CanHolster() ) { return; } - if (m_pActiveItem) - m_pActiveItem->Holster( ); - + if( m_pActiveItem ) + m_pActiveItem->Holster(); + CBasePlayerItem *pTemp = m_pActiveItem; m_pActiveItem = m_pLastItem; m_pLastItem = pTemp; @@ -456,9 +453,9 @@ CBasePlayer::Killed void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) { // Holster weapon immediately, to allow it to cleanup - if ( m_pActiveItem ) - m_pActiveItem->Holster( ); - + if( m_pActiveItem ) + m_pActiveItem->Holster(); + g_irunninggausspred = false; } @@ -470,7 +467,7 @@ CBasePlayer::Spawn */ void CBasePlayer::Spawn( void ) { - if (m_pActiveItem) + if( m_pActiveItem ) m_pActiveItem->Deploy( ); g_irunninggausspred = false; @@ -485,7 +482,7 @@ Don't actually trace, but act like the trace didn't hit anything. */ void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr ) { - memset( ptr, 0, sizeof( *ptr ) ); + memset( ptr, 0, sizeof(*ptr) ); ptr->flFraction = 1.0; } @@ -501,10 +498,10 @@ void UTIL_ParticleBox( CBasePlayer *player, float *mins, float *maxs, float life int i; vec3_t mmin, mmax; - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - mmin[ i ] = player->pev->origin[ i ] + mins[ i ]; - mmax[ i ] = player->pev->origin[ i ] + maxs[ i ]; + mmin[i] = player->pev->origin[i] + mins[i]; + mmax[i] = player->pev->origin[i] + maxs[i]; } gEngfuncs.pEfxAPI->R_ParticleBox( (float *)&mmin, (float *)&mmax, 5.0, 0, 255, 0 ); @@ -523,7 +520,7 @@ void UTIL_ParticleBoxes( void ) physent_t *pe; cl_entity_t *player; vec3_t mins, maxs; - + gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); // Store off the old count @@ -533,13 +530,13 @@ void UTIL_ParticleBoxes( void ) // Now add in all of the players. gEngfuncs.pEventAPI->EV_SetSolidPlayers ( player->index - 1 ); - for ( idx = 1; idx < 100; idx++ ) + for( idx = 1; idx < 100; idx++ ) { pe = gEngfuncs.pEventAPI->EV_GetPhysent( idx ); - if ( !pe ) + if( !pe ) break; - if ( pe->info >= 1 && pe->info <= gEngfuncs.GetMaxClients() ) + if( pe->info >= 1 && pe->info <= gEngfuncs.GetMaxClients() ) { mins = pe->origin + pe->mins; maxs = pe->origin + pe->maxs; @@ -575,16 +572,15 @@ void CBasePlayerWeapon::PrintState( void ) COM_Log( "c:\\hl.log", "%.4f ", gpGlobals->time ); COM_Log( "c:\\hl.log", "%.4f ", m_pPlayer->m_flNextAttack ); COM_Log( "c:\\hl.log", "%.4f ", m_flNextPrimaryAttack ); - COM_Log( "c:\\hl.log", "%.4f ", m_flTimeWeaponIdle - gpGlobals->time); + COM_Log( "c:\\hl.log", "%.4f ", m_flTimeWeaponIdle - gpGlobals->time ); COM_Log( "c:\\hl.log", "%i ", m_iClip ); } int RandomLong( int a, int b ) { - return gEngfuncs.pfnRandomLong(a, b); + return gEngfuncs.pfnRandomLong( a, b ); } - /* ===================== HUD_InitClientWeapons @@ -595,7 +591,7 @@ Set up weapons, player and functions needed to run weapons code client-side. void HUD_InitClientWeapons( void ) { static int initialized = 0; - if ( initialized ) + if( initialized ) return; initialized = 1; @@ -607,40 +603,40 @@ void HUD_InitClientWeapons( void ) gpGlobals->time = gEngfuncs.GetClientTime(); // Fake functions - g_engfuncs.pfnPrecacheModel = stub_PrecacheModel; - g_engfuncs.pfnPrecacheSound = stub_PrecacheSound; - g_engfuncs.pfnPrecacheEvent = stub_PrecacheEvent; - g_engfuncs.pfnNameForFunction = stub_NameForFunction; - g_engfuncs.pfnSetModel = stub_SetModel; + g_engfuncs.pfnPrecacheModel = stub_PrecacheModel; + g_engfuncs.pfnPrecacheSound = stub_PrecacheSound; + g_engfuncs.pfnPrecacheEvent = stub_PrecacheEvent; + g_engfuncs.pfnNameForFunction = stub_NameForFunction; + g_engfuncs.pfnSetModel = stub_SetModel; g_engfuncs.pfnSetClientMaxspeed = HUD_SetMaxSpeed; // Handled locally - g_engfuncs.pfnPlaybackEvent = HUD_PlaybackEvent; - g_engfuncs.pfnAlertMessage = AlertMessage; + g_engfuncs.pfnPlaybackEvent = HUD_PlaybackEvent; + g_engfuncs.pfnAlertMessage = AlertMessage; // Pass through to engine - g_engfuncs.pfnPrecacheEvent = gEngfuncs.pfnPrecacheEvent; - g_engfuncs.pfnRandomFloat = gEngfuncs.pfnRandomFloat; - g_engfuncs.pfnRandomLong = gEngfuncs.pfnRandomLong; + g_engfuncs.pfnPrecacheEvent = gEngfuncs.pfnPrecacheEvent; + g_engfuncs.pfnRandomFloat = gEngfuncs.pfnRandomFloat; + g_engfuncs.pfnRandomLong = gEngfuncs.pfnRandomLong; // Allocate a slot for the local player - HUD_PrepEntity( &player , NULL ); + HUD_PrepEntity( &player, NULL ); // Allocate slot(s) for each weapon that we are going to be predicting - HUD_PrepEntity( &g_Glock , &player ); - HUD_PrepEntity( &g_Crowbar , &player ); - HUD_PrepEntity( &g_Python , &player ); - HUD_PrepEntity( &g_Mp5 , &player ); - HUD_PrepEntity( &g_Crossbow , &player ); - HUD_PrepEntity( &g_Shotgun , &player ); - HUD_PrepEntity( &g_Rpg , &player ); - HUD_PrepEntity( &g_Gauss , &player ); - HUD_PrepEntity( &g_Egon , &player ); - HUD_PrepEntity( &g_HGun , &player ); - HUD_PrepEntity( &g_HandGren , &player ); - HUD_PrepEntity( &g_Satchel , &player ); - HUD_PrepEntity( &g_Tripmine , &player ); - HUD_PrepEntity( &g_Snark , &player ); + HUD_PrepEntity( &g_Glock, &player ); + HUD_PrepEntity( &g_Crowbar, &player ); + HUD_PrepEntity( &g_Python, &player ); + HUD_PrepEntity( &g_Mp5, &player ); + HUD_PrepEntity( &g_Crossbow, &player ); + HUD_PrepEntity( &g_Shotgun, &player ); + HUD_PrepEntity( &g_Rpg, &player ); + HUD_PrepEntity( &g_Gauss, &player ); + HUD_PrepEntity( &g_Egon, &player ); + HUD_PrepEntity( &g_HGun, &player ); + HUD_PrepEntity( &g_HandGren, &player ); + HUD_PrepEntity( &g_Satchel, &player ); + HUD_PrepEntity( &g_Tripmine, &player ); + HUD_PrepEntity( &g_Snark, &player ); } /* @@ -653,9 +649,9 @@ Retruns the last position that we stored for egon beam endpoint. void HUD_GetLastOrg( float *org ) { int i; - + // Return last origin - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { org[i] = previousorigin[i]; } @@ -671,11 +667,11 @@ Remember our exact predicted origin so we can draw the egon to the right positio void HUD_SetLastOrg( void ) { int i; - + // Offset final origin by view_offset - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - previousorigin[i] = g_finalstate->playerstate.origin[i] + g_finalstate->client.view_ofs[ i ]; + previousorigin[i] = g_finalstate->playerstate.origin[i] + g_finalstate->client.view_ofs[i]; } } @@ -695,69 +691,56 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm weapon_data_t nulldata, *pfrom, *pto; static int lasthealth; - memset( &nulldata, 0, sizeof( nulldata ) ); + memset( &nulldata, 0, sizeof(nulldata) ); - HUD_InitClientWeapons(); + HUD_InitClientWeapons(); // Get current clock gpGlobals->time = time; // Fill in data based on selected weapon // FIXME, make this a method in each weapon? where you pass in an entity_state_t *? - switch ( from->client.m_iId ) + switch( from->client.m_iId ) { case WEAPON_CROWBAR: pWeapon = &g_Crowbar; break; - case WEAPON_GLOCK: pWeapon = &g_Glock; break; - case WEAPON_PYTHON: pWeapon = &g_Python; break; - case WEAPON_MP5: pWeapon = &g_Mp5; break; - case WEAPON_CROSSBOW: pWeapon = &g_Crossbow; break; - case WEAPON_SHOTGUN: pWeapon = &g_Shotgun; break; - case WEAPON_RPG: pWeapon = &g_Rpg; break; - case WEAPON_GAUSS: pWeapon = &g_Gauss; break; - case WEAPON_EGON: pWeapon = &g_Egon; break; - case WEAPON_HORNETGUN: pWeapon = &g_HGun; break; - case WEAPON_HANDGRENADE: pWeapon = &g_HandGren; break; - case WEAPON_SATCHEL: pWeapon = &g_Satchel; break; - case WEAPON_TRIPMINE: pWeapon = &g_Tripmine; break; - case WEAPON_SNARK: pWeapon = &g_Snark; break; @@ -770,14 +753,13 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm // If we are running events/etc. go ahead and see if we // managed to die between last frame and this one // If so, run the appropriate player killed or spawn function - if ( g_runfuncs ) + if( g_runfuncs ) { - if ( to->client.health <= 0 && lasthealth > 0 ) + if( to->client.health <= 0 && lasthealth > 0 ) { player.Killed( NULL, 0 ); - } - else if ( to->client.health > 0 && lasthealth <= 0 ) + else if( to->client.health > 0 && lasthealth <= 0 ) { player.Spawn(); } @@ -786,37 +768,37 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm } // We are not predicting the current weapon, just bow out here. - if ( !pWeapon ) + if( !pWeapon ) return; - for ( i = 0; i < 32; i++ ) + for( i = 0; i < 32; i++ ) { - pCurrent = g_pWpns[ i ]; - if ( !pCurrent ) + pCurrent = g_pWpns[i]; + if( !pCurrent ) { continue; } - pfrom = &from->weapondata[ i ]; - - pCurrent->m_fInReload = pfrom->m_fInReload; - pCurrent->m_fInSpecialReload = pfrom->m_fInSpecialReload; -// pCurrent->m_flPumpTime = pfrom->m_flPumpTime; - pCurrent->m_iClip = pfrom->m_iClip; + pfrom = &from->weapondata[i]; + + pCurrent->m_fInReload = pfrom->m_fInReload; + pCurrent->m_fInSpecialReload = pfrom->m_fInSpecialReload; + //pCurrent->m_flPumpTime = pfrom->m_flPumpTime; + pCurrent->m_iClip = pfrom->m_iClip; pCurrent->m_flNextPrimaryAttack = pfrom->m_flNextPrimaryAttack; pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack; - pCurrent->m_flTimeWeaponIdle = pfrom->m_flTimeWeaponIdle; - pCurrent->pev->fuser1 = pfrom->fuser1; - pCurrent->m_flStartThrow = pfrom->fuser2; - pCurrent->m_flReleaseThrow = pfrom->fuser3; - pCurrent->m_chargeReady = pfrom->iuser1; - pCurrent->m_fInAttack = pfrom->iuser2; - pCurrent->m_fireState = pfrom->iuser3; + pCurrent->m_flTimeWeaponIdle = pfrom->m_flTimeWeaponIdle; + pCurrent->pev->fuser1 = pfrom->fuser1; + pCurrent->m_flStartThrow = pfrom->fuser2; + pCurrent->m_flReleaseThrow = pfrom->fuser3; + pCurrent->m_chargeReady = pfrom->iuser1; + pCurrent->m_fInAttack = pfrom->iuser2; + pCurrent->m_fireState = pfrom->iuser3; - pCurrent->m_iSecondaryAmmoType = (int)from->client.vuser3[ 2 ]; - pCurrent->m_iPrimaryAmmoType = (int)from->client.vuser4[ 0 ]; - player.m_rgAmmo[ pCurrent->m_iPrimaryAmmoType ] = (int)from->client.vuser4[ 1 ]; - player.m_rgAmmo[ pCurrent->m_iSecondaryAmmoType ] = (int)from->client.vuser4[ 2 ]; + pCurrent->m_iSecondaryAmmoType = (int)from->client.vuser3[2]; + pCurrent->m_iPrimaryAmmoType = (int)from->client.vuser4[0]; + player.m_rgAmmo[pCurrent->m_iPrimaryAmmoType] = (int)from->client.vuser4[1]; + player.m_rgAmmo[pCurrent->m_iSecondaryAmmoType] = (int)from->client.vuser4[2]; } // For random weapon events, use this seed to seed random # generator @@ -826,13 +808,13 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm player.m_afButtonLast = from->playerstate.oldbuttons; // Which buttsons chave changed - buttonsChanged = (player.m_afButtonLast ^ cmd->buttons); // These buttons have changed this frame - + buttonsChanged = ( player.m_afButtonLast ^ cmd->buttons ); // These buttons have changed this frame + // Debounced button codes for pressed/released // The changed ones still down are "pressed" player.m_afButtonPressed = buttonsChanged & cmd->buttons; // The ones not down are "released" - player.m_afButtonReleased = buttonsChanged & (~cmd->buttons); + player.m_afButtonReleased = buttonsChanged & ( ~cmd->buttons ); // Set player variables that weapons code might check/alter player.pev->button = cmd->buttons; @@ -842,7 +824,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm player.pev->deadflag = from->client.deadflag; player.pev->waterlevel = from->client.waterlevel; - player.pev->maxspeed = from->client.maxspeed; + player.pev->maxspeed = from->client.maxspeed; player.pev->fov = from->client.fov; player.pev->weaponanim = from->client.weaponanim; player.pev->viewmodel = from->client.viewmodel; @@ -851,62 +833,61 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm player.m_flAmmoStartCharge = from->client.fuser3; //Stores all our ammo info, so the client side weapons can use them. - player.ammo_9mm = (int)from->client.vuser1[0]; - player.ammo_357 = (int)from->client.vuser1[1]; - player.ammo_argrens = (int)from->client.vuser1[2]; - player.ammo_bolts = (int)from->client.ammo_nails; //is an int anyways... - player.ammo_buckshot = (int)from->client.ammo_shells; - player.ammo_uranium = (int)from->client.ammo_cells; - player.ammo_hornets = (int)from->client.vuser2[0]; - player.ammo_rockets = (int)from->client.ammo_rockets; + player.ammo_9mm = (int)from->client.vuser1[0]; + player.ammo_357 = (int)from->client.vuser1[1]; + player.ammo_argrens = (int)from->client.vuser1[2]; + player.ammo_bolts = (int)from->client.ammo_nails; //is an int anyways... + player.ammo_buckshot = (int)from->client.ammo_shells; + player.ammo_uranium = (int)from->client.ammo_cells; + player.ammo_hornets = (int)from->client.vuser2[0]; + player.ammo_rockets = (int)from->client.ammo_rockets; - // Point to current weapon object - if ( from->client.m_iId ) + if( from->client.m_iId ) { - player.m_pActiveItem = g_pWpns[ from->client.m_iId ]; + player.m_pActiveItem = g_pWpns[from->client.m_iId]; } - if ( player.m_pActiveItem->m_iId == WEAPON_RPG ) + if( player.m_pActiveItem->m_iId == WEAPON_RPG ) { - ( ( CRpg * )player.m_pActiveItem)->m_fSpotActive = (int)from->client.vuser2[ 1 ]; - ( ( CRpg * )player.m_pActiveItem)->m_cActiveRockets = (int)from->client.vuser2[ 2 ]; + ( (CRpg *)player.m_pActiveItem )->m_fSpotActive = (int)from->client.vuser2[1]; + ( (CRpg *)player.m_pActiveItem )->m_cActiveRockets = (int)from->client.vuser2[2]; } - + // Don't go firing anything if we have died. // Or if we don't have a weapon model deployed - if ( ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) && + if( ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) && !CL_IsDead() && player.pev->viewmodel && !g_iUser1 ) { - if ( player.m_flNextAttack <= 0 ) + if( player.m_flNextAttack <= 0 ) { pWeapon->ItemPostFrame(); } } // Assume that we are not going to switch weapons - to->client.m_iId = from->client.m_iId; + to->client.m_iId = from->client.m_iId; // Now see if we issued a changeweapon command ( and we're not dead ) - if ( cmd->weaponselect && ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) ) + if( cmd->weaponselect && ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) ) { // Switched to a different weapon? - if ( from->weapondata[ cmd->weaponselect ].m_iId == cmd->weaponselect ) + if( from->weapondata[cmd->weaponselect].m_iId == cmd->weaponselect ) { - CBasePlayerWeapon *pNew = g_pWpns[ cmd->weaponselect ]; - if ( pNew && ( pNew != pWeapon ) ) + CBasePlayerWeapon *pNew = g_pWpns[cmd->weaponselect]; + if( pNew && ( pNew != pWeapon ) ) { // Put away old weapon - if (player.m_pActiveItem) - player.m_pActiveItem->Holster( ); - + if( player.m_pActiveItem ) + player.m_pActiveItem->Holster(); + player.m_pLastItem = player.m_pActiveItem; player.m_pActiveItem = pNew; // Deploy new weapon - if (player.m_pActiveItem) + if( player.m_pActiveItem ) { - player.m_pActiveItem->Deploy( ); + player.m_pActiveItem->Deploy(); } // Update weapon id so we can predict things correctly. @@ -916,121 +897,121 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm } // Copy in results of prediction code - to->client.viewmodel = player.pev->viewmodel; - to->client.fov = player.pev->fov; - to->client.weaponanim = player.pev->weaponanim; - to->client.m_flNextAttack = player.m_flNextAttack; - to->client.fuser2 = player.m_flNextAmmoBurn; - to->client.fuser3 = player.m_flAmmoStartCharge; - to->client.maxspeed = player.pev->maxspeed; + to->client.viewmodel = player.pev->viewmodel; + to->client.fov = player.pev->fov; + to->client.weaponanim = player.pev->weaponanim; + to->client.m_flNextAttack = player.m_flNextAttack; + to->client.fuser2 = player.m_flNextAmmoBurn; + to->client.fuser3 = player.m_flAmmoStartCharge; + to->client.maxspeed = player.pev->maxspeed; //HL Weapons - to->client.vuser1[0] = player.ammo_9mm; - to->client.vuser1[1] = player.ammo_357; - to->client.vuser1[2] = player.ammo_argrens; + to->client.vuser1[0] = player.ammo_9mm; + to->client.vuser1[1] = player.ammo_357; + to->client.vuser1[2] = player.ammo_argrens; - to->client.ammo_nails = player.ammo_bolts; - to->client.ammo_shells = player.ammo_buckshot; - to->client.ammo_cells = player.ammo_uranium; - to->client.vuser2[0] = player.ammo_hornets; - to->client.ammo_rockets = player.ammo_rockets; + to->client.ammo_nails = player.ammo_bolts; + to->client.ammo_shells = player.ammo_buckshot; + to->client.ammo_cells = player.ammo_uranium; + to->client.vuser2[0] = player.ammo_hornets; + to->client.ammo_rockets = player.ammo_rockets; - if ( player.m_pActiveItem->m_iId == WEAPON_RPG ) + if( player.m_pActiveItem->m_iId == WEAPON_RPG ) { - from->client.vuser2[ 1 ] = ( ( CRpg * )player.m_pActiveItem)->m_fSpotActive; - from->client.vuser2[ 2 ] = ( ( CRpg * )player.m_pActiveItem)->m_cActiveRockets; + from->client.vuser2[1] = ( (CRpg *)player.m_pActiveItem)->m_fSpotActive; + from->client.vuser2[2] = ( (CRpg *)player.m_pActiveItem)->m_cActiveRockets; } // Make sure that weapon animation matches what the game .dll is telling us // over the wire ( fixes some animation glitches ) - if ( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) ) + if( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) ) { int body = 2; //Pop the model to body 0. - if ( pWeapon == &g_Tripmine ) + if( pWeapon == &g_Tripmine ) body = 0; //Show laser sight/scope combo - if ( pWeapon == &g_Python && bIsMultiplayer() ) + if( pWeapon == &g_Python && bIsMultiplayer() ) body = 1; - + // Force a fixed anim down to viewmodel HUD_SendWeaponAnim( to->client.weaponanim, body, 1 ); } - for ( i = 0; i < 32; i++ ) + for( i = 0; i < 32; i++ ) { - pCurrent = g_pWpns[ i ]; + pCurrent = g_pWpns[i]; - pto = &to->weapondata[ i ]; + pto = &to->weapondata[i]; - if ( !pCurrent ) + if( !pCurrent ) { - memset( pto, 0, sizeof( weapon_data_t ) ); + memset( pto, 0, sizeof(weapon_data_t) ); continue; } - - pto->m_fInReload = pCurrent->m_fInReload; - pto->m_fInSpecialReload = pCurrent->m_fInSpecialReload; -// pto->m_flPumpTime = pCurrent->m_flPumpTime; - pto->m_iClip = pCurrent->m_iClip; - pto->m_flNextPrimaryAttack = pCurrent->m_flNextPrimaryAttack; - pto->m_flNextSecondaryAttack = pCurrent->m_flNextSecondaryAttack; - pto->m_flTimeWeaponIdle = pCurrent->m_flTimeWeaponIdle; - pto->fuser1 = pCurrent->pev->fuser1; - pto->fuser2 = pCurrent->m_flStartThrow; - pto->fuser3 = pCurrent->m_flReleaseThrow; - pto->iuser1 = pCurrent->m_chargeReady; - pto->iuser2 = pCurrent->m_fInAttack; - pto->iuser3 = pCurrent->m_fireState; + + pto->m_fInReload = pCurrent->m_fInReload; + pto->m_fInSpecialReload = pCurrent->m_fInSpecialReload; + //pto->m_flPumpTime = pCurrent->m_flPumpTime; + pto->m_iClip = pCurrent->m_iClip; + pto->m_flNextPrimaryAttack = pCurrent->m_flNextPrimaryAttack; + pto->m_flNextSecondaryAttack = pCurrent->m_flNextSecondaryAttack; + pto->m_flTimeWeaponIdle = pCurrent->m_flTimeWeaponIdle; + pto->fuser1 = pCurrent->pev->fuser1; + pto->fuser2 = pCurrent->m_flStartThrow; + pto->fuser3 = pCurrent->m_flReleaseThrow; + pto->iuser1 = pCurrent->m_chargeReady; + pto->iuser2 = pCurrent->m_fInAttack; + pto->iuser3 = pCurrent->m_fireState; // Decrement weapon counters, server does this at same time ( during post think, after doing everything else ) - pto->m_flNextReload -= cmd->msec / 1000.0; - pto->m_fNextAimBonus -= cmd->msec / 1000.0; - pto->m_flNextPrimaryAttack -= cmd->msec / 1000.0; - pto->m_flNextSecondaryAttack -= cmd->msec / 1000.0; - pto->m_flTimeWeaponIdle -= cmd->msec / 1000.0; - pto->fuser1 -= cmd->msec / 1000.0; + pto->m_flNextReload -= cmd->msec / 1000.0; + pto->m_fNextAimBonus -= cmd->msec / 1000.0; + pto->m_flNextPrimaryAttack -= cmd->msec / 1000.0; + pto->m_flNextSecondaryAttack -= cmd->msec / 1000.0; + pto->m_flTimeWeaponIdle -= cmd->msec / 1000.0; + pto->fuser1 -= cmd->msec / 1000.0; - to->client.vuser3[2] = pCurrent->m_iSecondaryAmmoType; - to->client.vuser4[0] = pCurrent->m_iPrimaryAmmoType; - to->client.vuser4[1] = player.m_rgAmmo[ pCurrent->m_iPrimaryAmmoType ]; - to->client.vuser4[2] = player.m_rgAmmo[ pCurrent->m_iSecondaryAmmoType ]; + to->client.vuser3[2] = pCurrent->m_iSecondaryAmmoType; + to->client.vuser4[0] = pCurrent->m_iPrimaryAmmoType; + to->client.vuser4[1] = player.m_rgAmmo[pCurrent->m_iPrimaryAmmoType]; + to->client.vuser4[2] = player.m_rgAmmo[pCurrent->m_iSecondaryAmmoType]; -/* if ( pto->m_flPumpTime != -9999 ) +/* if( pto->m_flPumpTime != -9999 ) { pto->m_flPumpTime -= cmd->msec / 1000.0; - if ( pto->m_flPumpTime < -0.001 ) + if( pto->m_flPumpTime < -0.001 ) pto->m_flPumpTime = -0.001; }*/ - if ( pto->m_fNextAimBonus < -1.0 ) + if( pto->m_fNextAimBonus < -1.0 ) { pto->m_fNextAimBonus = -1.0; } - if ( pto->m_flNextPrimaryAttack < -1.0 ) + if( pto->m_flNextPrimaryAttack < -1.0 ) { pto->m_flNextPrimaryAttack = -1.0; } - if ( pto->m_flNextSecondaryAttack < -0.001 ) + if( pto->m_flNextSecondaryAttack < -0.001 ) { pto->m_flNextSecondaryAttack = -0.001; } - if ( pto->m_flTimeWeaponIdle < -0.001 ) + if( pto->m_flTimeWeaponIdle < -0.001 ) { pto->m_flTimeWeaponIdle = -0.001; } - if ( pto->m_flNextReload < -0.001 ) + if( pto->m_flNextReload < -0.001 ) { pto->m_flNextReload = -0.001; } - if ( pto->fuser1 < -0.001 ) + if( pto->fuser1 < -0.001 ) { pto->fuser1 = -0.001; } @@ -1038,19 +1019,19 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm // m_flNextAttack is now part of the weapons, but is part of the player instead to->client.m_flNextAttack -= cmd->msec / 1000.0; - if ( to->client.m_flNextAttack < -0.001 ) + if( to->client.m_flNextAttack < -0.001 ) { to->client.m_flNextAttack = -0.001; } to->client.fuser2 -= cmd->msec / 1000.0; - if ( to->client.fuser2 < -0.001 ) + if( to->client.fuser2 < -0.001 ) { to->client.fuser2 = -0.001; } - + to->client.fuser3 -= cmd->msec / 1000.0; - if ( to->client.fuser3 < -0.001 ) + if( to->client.fuser3 < -0.001 ) { to->client.fuser3 = -0.001; } @@ -1078,7 +1059,7 @@ void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s g_runfuncs = runfuncs; #if defined( CLIENT_WEAPONS ) - if ( cl_lw && cl_lw->value ) + if( cl_lw && cl_lw->value ) { HUD_WeaponsPostThink( from, to, cmd, time, random_seed ); } @@ -1088,14 +1069,14 @@ void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s to->client.fov = g_lastFOV; } - if ( g_irunninggausspred == 1 ) + if( g_irunninggausspred == 1 ) { Vector forward; gEngfuncs.pfnAngleVectors( v_angles, forward, NULL, NULL ); to->client.velocity = to->client.velocity - forward * g_flApplyVel * 5; g_irunninggausspred = false; } - + // All games can use FOV state g_lastFOV = to->client.fov; } diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 8fdc3992..0f3b45bc 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -25,71 +25,69 @@ #include "parsemsg.h" #include "hud_servers.h" - #include "demo.h" #include "demo_api.h" cvar_t *hud_textmode; float g_hud_text_color[3]; - -extern client_sprite_t *GetSpriteList(client_sprite_t *pList, const char *psz, int iRes, int iCount); +extern client_sprite_t *GetSpriteList( client_sprite_t *pList, const char *psz, int iRes, int iCount ); extern cvar_t *sensitivity; cvar_t *cl_lw = NULL; -void ShutdownInput (void); +void ShutdownInput( void ); -//DECLARE_MESSAGE(m_Logo, Logo) -int __MsgFunc_Logo(const char *pszName, int iSize, void *pbuf) +//DECLARE_MESSAGE( m_Logo, Logo ) +int __MsgFunc_Logo( const char *pszName, int iSize, void *pbuf ) { - return gHUD.MsgFunc_Logo(pszName, iSize, pbuf ); + return gHUD.MsgFunc_Logo( pszName, iSize, pbuf ); } -//DECLARE_MESSAGE(m_Logo, Logo) -int __MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf) +//DECLARE_MESSAGE( m_Logo, Logo ) +int __MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf ) { - return gHUD.MsgFunc_ResetHUD(pszName, iSize, pbuf ); + return gHUD.MsgFunc_ResetHUD( pszName, iSize, pbuf ); } -int __MsgFunc_InitHUD(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) { gHUD.MsgFunc_InitHUD( pszName, iSize, pbuf ); return 1; } -int __MsgFunc_ViewMode(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf ) { gHUD.MsgFunc_ViewMode( pszName, iSize, pbuf ); return 1; } -int __MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ) { return gHUD.MsgFunc_SetFOV( pszName, iSize, pbuf ); } -int __MsgFunc_Concuss(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ) { return gHUD.MsgFunc_Concuss( pszName, iSize, pbuf ); } -int __MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf ) +int __MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ) { return gHUD.MsgFunc_GameMode( pszName, iSize, pbuf ); } // TFFree Command Menu -void __CmdFunc_OpenCommandMenu(void) +void __CmdFunc_OpenCommandMenu( void ) { } // TFC "special" command -void __CmdFunc_InputPlayerSpecial(void) +void __CmdFunc_InputPlayerSpecial( void ) { } -void __CmdFunc_CloseCommandMenu(void) +void __CmdFunc_CloseCommandMenu( void ) { } @@ -102,59 +100,58 @@ void __CmdFunc_ToggleServerBrowser( void ) } // TFFree Command Menu Message Handlers -int __MsgFunc_ValClass(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_ValClass( const char *pszName, int iSize, void *pbuf ) { return 0; } -int __MsgFunc_TeamNames(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_TeamNames( const char *pszName, int iSize, void *pbuf ) { return 0; } -int __MsgFunc_Feign(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_Feign( const char *pszName, int iSize, void *pbuf ) { return 0; } -int __MsgFunc_Detpack(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_Detpack( const char *pszName, int iSize, void *pbuf ) { return 0; } -int __MsgFunc_VGUIMenu(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf ) { return 0; } -int __MsgFunc_BuildSt(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_BuildSt( const char *pszName, int iSize, void *pbuf ) { return 0; } -int __MsgFunc_RandomPC(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_RandomPC( const char *pszName, int iSize, void *pbuf ) { return 0; } -int __MsgFunc_ServerName(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_ServerName( const char *pszName, int iSize, void *pbuf ) { return 0; } - -int __MsgFunc_Spectator(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_Spectator( const char *pszName, int iSize, void *pbuf ) { return 0; } -int __MsgFunc_AllowSpec(const char *pszName, int iSize, void *pbuf) +int __MsgFunc_AllowSpec( const char *pszName, int iSize, void *pbuf ) { return 0; } // This is called every time the DLL is loaded -void CHud :: Init( void ) +void CHud::Init( void ) { HOOK_MESSAGE( Logo ); HOOK_MESSAGE( ResetHUD ); @@ -201,7 +198,7 @@ void CHud :: Init( void ) m_pSpriteList = NULL; // Clear any old HUD list - if ( m_pHudList ) + if( m_pHudList ) { HUDLIST *pList; while ( m_pHudList ) @@ -235,22 +232,21 @@ void CHud :: Init( void ) m_Menu.Init(); - - MsgFunc_ResetHUD(0, 0, NULL ); + MsgFunc_ResetHUD( 0, 0, NULL ); } // CHud destructor // cleans up memory allocated for m_rg* arrays -CHud :: ~CHud() +CHud::~CHud() { - delete [] m_rghSprites; - delete [] m_rgrcRects; - delete [] m_rgszSpriteNames; + delete[] m_rghSprites; + delete[] m_rgrcRects; + delete[] m_rgszSpriteNames; - if ( m_pHudList ) + if( m_pHudList ) { HUDLIST *pList; - while ( m_pHudList ) + while( m_pHudList ) { pList = m_pHudList; m_pHudList = m_pHudList->pNext; @@ -258,59 +254,57 @@ CHud :: ~CHud() } m_pHudList = NULL; } - - } // GetSpriteIndex() // searches through the sprite list loaded from hud.txt for a name matching SpriteName // returns an index into the gHUD.m_rghSprites[] array // returns 0 if sprite not found -int CHud :: GetSpriteIndex( const char *SpriteName ) +int CHud::GetSpriteIndex( const char *SpriteName ) { // look through the loaded sprite name list for SpriteName - for ( int i = 0; i < m_iSpriteCount; i++ ) + for( int i = 0; i < m_iSpriteCount; i++ ) { - if ( strncmp( SpriteName, m_rgszSpriteNames + (i * MAX_SPRITE_NAME_LENGTH), MAX_SPRITE_NAME_LENGTH ) == 0 ) + if( strncmp( SpriteName, m_rgszSpriteNames + ( i * MAX_SPRITE_NAME_LENGTH), MAX_SPRITE_NAME_LENGTH ) == 0 ) return i; } return -1; // invalid sprite } -void CHud :: VidInit( void ) +void CHud::VidInit( void ) { int j; m_scrinfo.iSize = sizeof(m_scrinfo); - GetScreenInfo(&m_scrinfo); + GetScreenInfo( &m_scrinfo ); // ---------- // Load Sprites // --------- -// m_hsprFont = LoadSprite("sprites/%d_font.spr"); - + //m_hsprFont = LoadSprite("sprites/%d_font.spr"); + m_hsprLogo = 0; m_hsprCursor = 0; - if (ScreenWidth < 640) + if( ScreenWidth < 640 ) m_iRes = 320; else m_iRes = 640; // Only load this once - if ( !m_pSpriteList ) + if( !m_pSpriteList ) { // we need to load the hud.txt, and all sprites within - m_pSpriteList = SPR_GetList("sprites/hud.txt", &m_iSpriteCountAllRes); + m_pSpriteList = SPR_GetList( "sprites/hud.txt", &m_iSpriteCountAllRes ); - if (m_pSpriteList) + if( m_pSpriteList ) { // count the number of sprites of the appropriate res m_iSpriteCount = 0; client_sprite_t *p = m_pSpriteList; - for ( j = 0; j < m_iSpriteCountAllRes; j++ ) + for( j = 0; j < m_iSpriteCountAllRes; j++ ) { - if ( p->iRes == m_iRes ) + if( p->iRes == m_iRes ) m_iSpriteCount++; p++; } @@ -322,13 +316,13 @@ void CHud :: VidInit( void ) p = m_pSpriteList; int index = 0; - for ( j = 0; j < m_iSpriteCountAllRes; j++ ) + for( j = 0; j < m_iSpriteCountAllRes; j++ ) { - if ( p->iRes == m_iRes ) + if( p->iRes == m_iRes ) { char sz[256]; - sprintf(sz, "sprites/%s.spr", p->szSprite); - m_rghSprites[index] = SPR_Load(sz); + sprintf( sz, "sprites/%s.spr", p->szSprite ); + m_rghSprites[index] = SPR_Load( sz ); m_rgrcRects[index] = p->rc; strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH ); @@ -347,16 +341,16 @@ void CHud :: VidInit( void ) // count the number of sprites of the appropriate res m_iSpriteCount = 0; - for ( j = 0; j < m_iSpriteCountAllRes; j++ ) + for( j = 0; j < m_iSpriteCountAllRes; j++ ) { - if ( p->iRes == m_iRes ) + if( p->iRes == m_iRes ) m_iSpriteCount++; p++; } - delete [] m_rghSprites; - delete [] m_rgrcRects; - delete [] m_rgszSpriteNames; + delete[] m_rghSprites; + delete[] m_rgrcRects; + delete[] m_rgszSpriteNames; // allocated memory for sprite handle arrays m_rghSprites = new HSPRITE[m_iSpriteCount]; @@ -365,13 +359,13 @@ void CHud :: VidInit( void ) p = m_pSpriteList; int index = 0; - for ( j = 0; j < m_iSpriteCountAllRes; j++ ) + for( j = 0; j < m_iSpriteCountAllRes; j++ ) { - if ( p->iRes == m_iRes ) + if( p->iRes == m_iRes ) { char sz[256]; sprintf( sz, "sprites/%s.spr", p->szSprite ); - m_rghSprites[index] = SPR_Load(sz); + m_rghSprites[index] = SPR_Load( sz ); m_rgrcRects[index] = p->rc; strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH ); @@ -404,10 +398,9 @@ void CHud :: VidInit( void ) m_StatusIcons.VidInit(); m_Scoreboard.VidInit(); m_MOTD.VidInit(); - } -int CHud::MsgFunc_Logo(const char *pszName, int iSize, void *pbuf) +int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); @@ -425,29 +418,28 @@ COM_FileBase ============ */ // Extracts the base name of a file (no path, no extension, assumes '/' as path separator) -void COM_FileBase ( const char *in, char *out) +void COM_FileBase ( const char *in, char *out ) { int len, start, end; len = strlen( in ); - + // scan backward for '.' end = len - 1; - while ( end && in[end] != '.' && in[end] != '/' && in[end] != '\\' ) + while( end && in[end] != '.' && in[end] != '/' && in[end] != '\\' ) end--; - - if ( in[end] != '.' ) // no '.', copy to end - end = len-1; + + if( in[end] != '.' ) // no '.', copy to end + end = len - 1; else end--; // Found ',', copy to left of '.' - // Scan backward for '/' - start = len-1; - while ( start >= 0 && in[start] != '/' && in[start] != '\\' ) + start = len - 1; + while( start >= 0 && in[start] != '/' && in[start] != '\\' ) start--; - if ( in[start] != '/' && in[start] != '\\' ) + if( in[start] != '/' && in[start] != '\\' ) start = 0; else start++; @@ -457,6 +449,7 @@ void COM_FileBase ( const char *in, char *out) // Copy partial string strncpy( out, &in[start], len ); + // Terminate it out[len] = 0; } @@ -470,13 +463,13 @@ HUD_IsGame int HUD_IsGame( const char *game ) { const char *gamedir; - char gd[ 1024 ]; + char gd[1024]; gamedir = gEngfuncs.pfnGetGameDirectory(); - if ( gamedir && gamedir[0] ) + if( gamedir && gamedir[0] ) { COM_FileBase( gamedir, gd ); - if ( !stricmp( gd, game ) ) + if( !stricmp( gd, game ) ) return 1; } return 0; @@ -491,27 +484,27 @@ Returns last FOV */ float HUD_GetFOV( void ) { - if ( gEngfuncs.pDemoAPI->IsRecording() ) + if( gEngfuncs.pDemoAPI->IsRecording() ) { // Write it int i = 0; - unsigned char buf[ 100 ]; + unsigned char buf[100]; // Active - *( float * )&buf[ i ] = g_lastFOV; - i += sizeof( float ); + *(float *)&buf[i] = g_lastFOV; + i += sizeof(float); Demo_WriteBuffer( TYPE_ZOOM, i, buf ); } - if ( gEngfuncs.pDemoAPI->IsPlayingback() ) + if( gEngfuncs.pDemoAPI->IsPlayingback() ) { g_lastFOV = g_demozoom; } return g_lastFOV; } -int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf) +int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); @@ -519,12 +512,12 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf) int def_fov = CVAR_GET_FLOAT( "default_fov" ); //Weapon prediction already takes care of changing the fog. ( g_lastFOV ). - if ( cl_lw && cl_lw->value ) + if( cl_lw && cl_lw->value ) return 1; g_lastFOV = newfov; - if ( newfov == 0 ) + if( newfov == 0 ) { m_iFOV = def_fov; } @@ -536,7 +529,7 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf) // the clients fov is actually set in the client data update section of the hud // Set a new sensitivity - if ( m_iFOV == def_fov ) + if( m_iFOV == def_fov ) { // reset to saved sensitivity m_flMouseSensitivity = 0; @@ -550,24 +543,23 @@ int CHud::MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf) return 1; } - -void CHud::AddHudElem(CHudBase *phudelem) +void CHud::AddHudElem( CHudBase *phudelem ) { HUDLIST *pdl, *ptemp; -//phudelem->Think(); + //phudelem->Think(); - if (!phudelem) + if( !phudelem ) return; - pdl = (HUDLIST *)malloc(sizeof(HUDLIST)); - if (!pdl) + pdl = (HUDLIST *)malloc( sizeof(HUDLIST) ); + if( !pdl ) return; - memset(pdl, 0, sizeof(HUDLIST)); + memset( pdl, 0, sizeof(HUDLIST) ); pdl->p = phudelem; - if (!m_pHudList) + if( !m_pHudList ) { m_pHudList = pdl; return; @@ -575,7 +567,7 @@ void CHud::AddHudElem(CHudBase *phudelem) ptemp = m_pHudList; - while (ptemp->pNext) + while( ptemp->pNext ) ptemp = ptemp->pNext; ptemp->pNext = pdl; @@ -585,5 +577,3 @@ float CHud::GetSensitivity( void ) { return m_flMouseSensitivity; } - - diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 73423c0d..ec236003 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -20,7 +20,6 @@ // CHud handles the message, calculation, and drawing the HUD // - #define RGB_YELLOWISH 0x00FFA000 //255,160,0 #define RGB_REDISH 0x00FF1010 //255,160,0 #define RGB_GREENISH 0x0000A000 //0,160,0 @@ -36,7 +35,8 @@ #define HUDELEM_ACTIVE 1 -typedef struct { +typedef struct +{ int x, y; } POSITION; @@ -47,13 +47,13 @@ enum MAX_TEAM_NAME = 16 }; -typedef struct { - unsigned char r,g,b,a; +typedef struct +{ + unsigned char r, g, b, a; } RGBA; typedef struct cvar_s cvar_t; - #define HUD_ACTIVE 1 #define HUD_INTERMISSION 2 @@ -71,42 +71,39 @@ public: int m_type; int m_iFlags; // active, moving, virtual ~CHudBase() {} - virtual int Init( void ) {return 0;} - virtual int VidInit( void ) {return 0;} - virtual int Draw(float flTime) {return 0;} - virtual void Think(void) {return;} - virtual void Reset(void) {return;} + virtual int Init( void ) { return 0; } + virtual int VidInit( void ) { return 0; } + virtual int Draw( float flTime ) { return 0; } + virtual void Think( void ) { return; } + virtual void Reset( void ) { return; } virtual void InitHUDData( void ) {} // called every time a server is connected to - }; -struct HUDLIST { +struct HUDLIST +{ CHudBase *p; HUDLIST *pNext; }; - - // //----------------------------------------------------- #include "hud_spectator.h" - // //----------------------------------------------------- // -class CHudAmmo: public CHudBase +class CHudAmmo : public CHudBase { public: int Init( void ); int VidInit( void ); - int Draw(float flTime); - void Think(void); - void Reset(void); - int DrawWList(float flTime); - int MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf); - int MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf); - int MsgFunc_AmmoX(const char *pszName, int iSize, void *pbuf); + int Draw( float flTime ); + void Think( void ); + void Reset( void ); + int DrawWList( float flTime ); + int MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_WeaponList( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_AmmoX( const char *pszName, int iSize, void *pbuf ); int MsgFunc_AmmoPickup( const char *pszName, int iSize, void *pbuf ); int MsgFunc_WeapPickup( const char *pszName, int iSize, void *pbuf ); int MsgFunc_ItemPickup( const char *pszName, int iSize, void *pbuf ); @@ -131,16 +128,14 @@ private: float m_fFade; RGBA m_rgba; WEAPON *m_pWeapon; - int m_HUD_bucket0; + int m_HUD_bucket0; int m_HUD_selection; - }; // //----------------------------------------------------- // - -class CHudAmmoSecondary: public CHudBase +class CHudAmmoSecondary : public CHudBase { public: int Init( void ); @@ -176,29 +171,27 @@ class CHudGeiger: public CHudBase public: int Init( void ); int VidInit( void ); - int Draw(float flTime); - int MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf); + int Draw( float flTime ); + int MsgFunc_Geiger( const char *pszName, int iSize, void *pbuf ); private: int m_iGeigerRange; - }; // //----------------------------------------------------- // -class CHudTrain: public CHudBase +class CHudTrain : public CHudBase { public: int Init( void ); int VidInit( void ); - int Draw(float flTime); - int MsgFunc_Train(const char *pszName, int iSize, void *pbuf); + int Draw( float flTime ); + int MsgFunc_Train( const char *pszName, int iSize, void *pbuf ); private: HSPRITE m_hSprite; int m_iPos; - }; // @@ -206,7 +199,6 @@ private: // // REMOVED: Vgui has replaced this. // - class CHudMOTD : public CHudBase { public: @@ -223,14 +215,13 @@ public: protected: static int MOTD_DISPLAY_TIME; - char m_szMOTD[ MAX_MOTD_LENGTH ]; - + char m_szMOTD[MAX_MOTD_LENGTH]; + int m_iLines; int m_iMaxLength; }; - -class CHudScoreboard: public CHudBase +class CHudScoreboard : public CHudBase { public: int Init( void ); @@ -257,7 +248,6 @@ public: void GetAllPlayersInfo( void ); }; - // //----------------------------------------------------- // @@ -274,7 +264,8 @@ public: int MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf ); protected: - enum { + enum + { MAX_STATUSTEXT_LENGTH = 128, MAX_STATUSBAR_VALUES = 8, MAX_STATUSBAR_LINES = 2 @@ -296,7 +287,7 @@ protected: // REMOVED: Vgui has replaced this. // /* -class CHudScoreboard: public CHudBase +class CHudScoreboard : public CHudBase { public: int Init( void ); @@ -319,13 +310,13 @@ public: int m_iShowscoresHeld; void GetAllPlayersInfo( void ); + private: struct cvar_s *cl_showpacketloss; - }; */ -struct extra_player_info_t +struct extra_player_info_t { short frags; short deaths; @@ -334,7 +325,7 @@ struct extra_player_info_t char teamname[MAX_TEAM_NAME]; }; -struct team_info_t +struct team_info_t { char name[MAX_TEAM_NAME]; short frags; @@ -348,11 +339,10 @@ struct team_info_t int teamnumber; }; -extern hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine -extern extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll -extern team_info_t g_TeamInfo[MAX_TEAMS+1]; -extern int g_IsSpectator[MAX_PLAYERS+1]; - +extern hud_player_info_t g_PlayerInfoList[MAX_PLAYERS + 1]; // player info from the engine +extern extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS + 1]; // additional player info sent directly to the client dll +extern team_info_t g_TeamInfo[MAX_TEAMS + 1]; +extern int g_IsSpectator[MAX_PLAYERS + 1]; // //----------------------------------------------------- @@ -404,10 +394,9 @@ public: int MsgFunc_SayText( const char *pszName, int iSize, void *pbuf ); void SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex = -1 ); void EnsureTextFitsInOneLineAndWrapIfHaveTo( int line ); -friend class CHudSpectator; + friend class CHudSpectator; private: - struct cvar_s * m_HUD_saytext; struct cvar_s * m_HUD_saytext_time; }; @@ -415,25 +404,24 @@ private: // //----------------------------------------------------- // -class CHudBattery: public CHudBase +class CHudBattery : public CHudBase { public: int Init( void ); int VidInit( void ); - int Draw(float flTime); - int MsgFunc_Battery(const char *pszName, int iSize, void *pbuf ); + int Draw( float flTime ); + int MsgFunc_Battery( const char *pszName, int iSize, void *pbuf ); private: HSPRITE m_hSprite1; HSPRITE m_hSprite2; wrect_t *m_prc1; wrect_t *m_prc2; - int m_iBat; + int m_iBat; float m_fFade; - int m_iHeight; // width of the battery innards + int m_iHeight; // width of the battery innards }; - // //----------------------------------------------------- // @@ -442,11 +430,11 @@ class CHudFlashlight: public CHudBase public: int Init( void ); int VidInit( void ); - int Draw(float flTime); + int Draw( float flTime ); void Reset( void ); - int MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf ); - int MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf ); - + int MsgFunc_Flashlight( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_FlashBat( const char *pszName, int iSize, void *pbuf ); + private: HSPRITE m_hSprite1; HSPRITE m_hSprite2; @@ -455,10 +443,10 @@ private: wrect_t *m_prc2; wrect_t *m_prcBeam; float m_flBat; - int m_iBat; - int m_fOn; + int m_iBat; + int m_fOn; float m_fFade; - int m_iWidth; // width of the battery innards + int m_iWidth; // width of the battery innards }; // @@ -486,31 +474,31 @@ struct message_parms_t //----------------------------------------------------- // -class CHudTextMessage: public CHudBase +class CHudTextMessage : public CHudBase { public: int Init( void ); static char *LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ); static char *BufferedLocaliseTextString( const char *msg ); char *LookupString( const char *msg_name, int *msg_dest = NULL ); - int MsgFunc_TextMsg(const char *pszName, int iSize, void *pbuf); + int MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf ); }; // //----------------------------------------------------- // -class CHudMessage: public CHudBase +class CHudMessage : public CHudBase { public: int Init( void ); int VidInit( void ); - int Draw(float flTime); - int MsgFunc_HudText(const char *pszName, int iSize, void *pbuf); - int MsgFunc_GameTitle(const char *pszName, int iSize, void *pbuf); + int Draw( float flTime ); + int MsgFunc_HudText( const char *pszName, int iSize, void *pbuf ); + int MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf ); float FadeBlend( float fadein, float fadeout, float hold, float localTime ); - int XPosition( float x, int width, int lineWidth ); + int XPosition( float x, int width, int lineWidth ); int YPosition( float y, int height ); void MessageAdd( const char *pName, float time ); @@ -536,16 +524,17 @@ private: // #define MAX_SPRITE_NAME_LENGTH 24 -class CHudStatusIcons: public CHudBase +class CHudStatusIcons : public CHudBase { public: int Init( void ); int VidInit( void ); void Reset( void ); - int Draw(float flTime); - int MsgFunc_StatusIcon(const char *pszName, int iSize, void *pbuf); + int Draw( float flTime ); + int MsgFunc_StatusIcon( const char *pszName, int iSize, void *pbuf ); - enum { + enum + { MAX_ICONSPRITENAME_LENGTH = MAX_SPRITE_NAME_LENGTH, MAX_ICONSPRITES = 4 }; @@ -556,7 +545,6 @@ public: void DisableIcon( char *pszIconName ); private: - typedef struct { char szSpriteName[MAX_ICONSPRITENAME_LENGTH]; @@ -566,13 +554,11 @@ private: } icon_sprite_t; icon_sprite_t m_IconList[MAX_ICONSPRITES]; - }; // //----------------------------------------------------- // - class CHud { private: @@ -586,7 +572,6 @@ private: int m_iConcussionEffect; public: - HSPRITE m_hsprCursor; float m_flTime; // the current client time float m_fOldTime; // the time at which the HUD was last redrawn @@ -602,13 +587,13 @@ public: cvar_t *m_pCvarDraw; int m_iFontHeight; - int DrawHudNumber(int x, int y, int iFlags, int iNumber, int r, int g, int b ); - int DrawHudString(int x, int y, int iMaxX, char *szString, int r, int g, int b ); + int DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b ); + int DrawHudString( int x, int y, int iMaxX, char *szString, int r, int g, int b ); int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ); int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b ); - int GetNumWidth(int iNumber, int iFlags); + int GetNumWidth( int iNumber, int iFlags ); int DrawHudStringLen( char *szIt ); - void DrawDarkRectangle( int x, int y, int wide, int tall); + void DrawDarkRectangle( int x, int y, int wide, int tall ); private: // the memory for these arrays are allocated in the first call to CHud::VidInit(), when the hud.txt and associated sprites are loaded. @@ -621,7 +606,7 @@ private: public: HSPRITE GetSprite( int index ) { - return (index < 0) ? 0 : m_rghSprites[index]; + return ( index < 0 ) ? 0 : m_rghSprites[index]; } wrect_t& GetSpriteRect( int index ) @@ -659,13 +644,13 @@ public: ~CHud(); // destructor, frees allocated memory // user messages - int _cdecl MsgFunc_Damage(const char *pszName, int iSize, void *pbuf ); - int _cdecl MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf ); - int _cdecl MsgFunc_Logo(const char *pszName, int iSize, void *pbuf); - int _cdecl MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf); + int _cdecl MsgFunc_Damage( const char *pszName, int iSize, void *pbuf ); + int _cdecl MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ); + int _cdecl MsgFunc_Logo( const char *pszName, int iSize, void *pbuf ); + int _cdecl MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf ); void _cdecl MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ); void _cdecl MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf ); - int _cdecl MsgFunc_SetFOV(const char *pszName, int iSize, void *pbuf); + int _cdecl MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ); // Screen information @@ -680,10 +665,9 @@ public: int m_iNoConsolePrint; - void AddHudElem(CHudBase *p); + void AddHudElem( CHudBase *p ); float GetSensitivity(); - }; extern CHud gHUD; @@ -693,4 +677,3 @@ extern int g_iTeamNumber; extern int g_iUser1; extern int g_iUser2; extern int g_iUser3; - diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index 9b7e189a..a7a05e7e 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -11,9 +11,8 @@ #include "exportdef.h" -typedef int (*pfnUserMsgHook)(const char *pszName, int iSize, void *pbuf); +typedef int (*pfnUserMsgHook)( const char *pszName, int iSize, void *pbuf ); #include "wrect.h" #include "../engine/cdll_int.h" extern cl_enginefunc_t gEngfuncs; - #endif diff --git a/cl_dll/hud_msg.cpp b/cl_dll/hud_msg.cpp index 4051b401..47f8bc92 100644 --- a/cl_dll/hud_msg.cpp +++ b/cl_dll/hud_msg.cpp @@ -28,16 +28,16 @@ extern BEAM *pBeam2; /// USER-DEFINED SERVER MESSAGE HANDLERS -int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf ) +int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf ) { ASSERT( iSize == 0 ); // clear all hud data HUDLIST *pList = m_pHudList; - while ( pList ) + while( pList ) { - if ( pList->p ) + if( pList->p ) pList->p->Reset(); pList = pList->pNext; } @@ -51,21 +51,21 @@ int CHud :: MsgFunc_ResetHUD(const char *pszName, int iSize, void *pbuf ) return 1; } -void CAM_ToFirstPerson(void); +void CAM_ToFirstPerson( void ); -void CHud :: MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf ) +void CHud::MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf ) { CAM_ToFirstPerson(); } -void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) +void CHud::MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) { // prepare all hud data HUDLIST *pList = m_pHudList; - while (pList) + while( pList ) { - if ( pList->p ) + if( pList->p ) pList->p->InitHUDData(); pList = pList->pNext; } @@ -74,8 +74,7 @@ void CHud :: MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) pBeam = pBeam2 = NULL; } - -int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf ) +int CHud::MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); m_Teamplay = READ_BYTE(); @@ -83,38 +82,36 @@ int CHud :: MsgFunc_GameMode(const char *pszName, int iSize, void *pbuf ) return 1; } - -int CHud :: MsgFunc_Damage(const char *pszName, int iSize, void *pbuf ) +int CHud::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf ) { int armor, blood; Vector from; int i; float count; - + BEGIN_READ( pbuf, iSize ); armor = READ_BYTE(); blood = READ_BYTE(); - for (i=0 ; i<3 ; i++) + for( i = 0; i < 3; i++) from[i] = READ_COORD(); - count = (blood * 0.5) + (armor * 0.5); + count = ( blood * 0.5 ) + ( armor * 0.5 ); - if (count < 10) + if( count < 10 ) count = 10; // TODO: kick viewangles, show damage visually - return 1; } -int CHud :: MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ) +int CHud::MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); m_iConcussionEffect = READ_BYTE(); - if (m_iConcussionEffect) - this->m_StatusIcons.EnableIcon("dmg_concuss",255,160,0); + if( m_iConcussionEffect ) + this->m_StatusIcons.EnableIcon( "dmg_concuss", 255, 160, 0 ); else - this->m_StatusIcons.DisableIcon("dmg_concuss"); + this->m_StatusIcons.DisableIcon( "dmg_concuss" ); return 1; } diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index bacd4026..aed98455 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -20,17 +20,15 @@ #include "cl_util.h" //#include "triangleapi.h" - #define MAX_LOGO_FRAMES 56 -int grgLogoFrame[MAX_LOGO_FRAMES] = +int grgLogoFrame[MAX_LOGO_FRAMES] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13, 13, 13, 13, 13, 12, 11, 10, 9, 8, 14, 15, 16, 17, 18, 19, 20, 20, 20, 20, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 29, 29, 29, 29, 29, 28, 27, 26, 25, 24, 30, 31 }; - extern int g_iVisibleMouse; float HUD_GetFOV( void ); @@ -38,20 +36,20 @@ float HUD_GetFOV( void ); extern cvar_t *sensitivity; // Think -void CHud::Think(void) +void CHud::Think( void ) { int newfov; HUDLIST *pList = m_pHudList; - while (pList) + while( pList ) { - if (pList->p->m_iFlags & HUD_ACTIVE) + if( pList->p->m_iFlags & HUD_ACTIVE ) pList->p->Think(); pList = pList->pNext; } newfov = HUD_GetFOV(); - if ( newfov == 0 ) + if( newfov == 0 ) { m_iFOV = default_fov->value; } @@ -61,22 +59,22 @@ void CHud::Think(void) } // the clients fov is actually set in the client data update section of the hud - // Set a new sensitivity - if ( m_iFOV == default_fov->value ) - { + if( m_iFOV == default_fov->value ) + { // reset to saved sensitivity m_flMouseSensitivity = 0; } else - { + { // set a new sensitivity that is proportional to the change from the FOV default m_flMouseSensitivity = sensitivity->value * ((float)newfov / (float)default_fov->value) * CVAR_GET_FLOAT("zoom_sensitivity_ratio"); } // think about default fov - if ( m_iFOV == 0 ) - { // only let players adjust up in fov, and only if they are not overriden by something else + if( m_iFOV == 0 ) + { + // only let players adjust up in fov, and only if they are not overriden by something else m_iFOV = max( default_fov->value, 90 ); } } @@ -84,21 +82,20 @@ void CHud::Think(void) // Redraw // step through the local data, placing the appropriate graphics & text as appropriate // returns 1 if they've changed, 0 otherwise -int CHud :: Redraw( float flTime, int intermission ) +int CHud::Redraw( float flTime, int intermission ) { m_fOldTime = m_flTime; // save time of previous redraw m_flTime = flTime; m_flTimeDelta = (double)m_flTime - m_fOldTime; static float m_flShotTime = 0; - + // Clock was reset, reset delta - if ( m_flTimeDelta < 0 ) + if( m_flTimeDelta < 0 ) m_flTimeDelta = 0; - - if (m_flShotTime && m_flShotTime < flTime) + if( m_flShotTime && m_flShotTime < flTime ) { - gEngfuncs.pfnClientCmd("snapshot\n"); + gEngfuncs.pfnClientCmd( "snapshot\n" ); m_flShotTime = 0; } @@ -106,21 +103,22 @@ int CHud :: Redraw( float flTime, int intermission ) // if no redrawing is necessary // return 0; - - if ( m_pCvarDraw->value ) + + if( m_pCvarDraw->value ) { HUDLIST *pList = m_pHudList; - while (pList) + while( pList ) { - if ( !intermission ) + if( !intermission ) { - if ( (pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL) ) - pList->p->Draw(flTime); + if ( ( pList->p->m_iFlags & HUD_ACTIVE ) && !( m_iHideHUDDisplay & HIDEHUD_ALL ) ) + pList->p->Draw( flTime ); } else - { // it's an intermission, so only draw hud elements that are set to draw during intermissions - if ( pList->p->m_iFlags & HUD_INTERMISSION ) + { + // it's an intermission, so only draw hud elements that are set to draw during intermissions + if( pList->p->m_iFlags & HUD_INTERMISSION ) pList->p->Draw( flTime ); } @@ -129,43 +127,43 @@ int CHud :: Redraw( float flTime, int intermission ) } // are we in demo mode? do we need to draw the logo in the top corner? - if (m_iLogo) + if( m_iLogo ) { int x, y, i; - if (m_hsprLogo == 0) - m_hsprLogo = LoadSprite("sprites/%d_logo.spr"); + if( m_hsprLogo == 0 ) + m_hsprLogo = LoadSprite( "sprites/%d_logo.spr" ); - SPR_Set(m_hsprLogo, 250, 250, 250 ); - - x = SPR_Width(m_hsprLogo, 0); + SPR_Set( m_hsprLogo, 250, 250, 250 ); + + x = SPR_Width( m_hsprLogo, 0 ); x = ScreenWidth - x; - y = SPR_Height(m_hsprLogo, 0)/2; + y = SPR_Height( m_hsprLogo, 0 ) / 2; // Draw the logo at 20 fps - int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES; + int iFrame = (int)( flTime * 20 ) % MAX_LOGO_FRAMES; i = grgLogoFrame[iFrame] - 1; - SPR_DrawAdditive(i, x, y, NULL); + SPR_DrawAdditive( i, x, y, NULL ); } /* - if ( g_iVisibleMouse ) + if( g_iVisibleMouse ) { void IN_GetMousePos( int *mx, int *my ); int mx, my; IN_GetMousePos( &mx, &my ); - - if (m_hsprCursor == 0) + + if( m_hsprCursor == 0 ) { char sz[256]; sprintf( sz, "sprites/cursor.spr" ); m_hsprCursor = SPR_Load( sz ); } - SPR_Set(m_hsprCursor, 250, 250, 250 ); - + SPR_Set( m_hsprCursor, 250, 250, 250 ); + // Draw the logo at 20 fps SPR_DrawAdditive( 0, mx, my, NULL ); } @@ -177,9 +175,9 @@ int CHud :: Redraw( float flTime, int intermission ) void ScaleColors( int &r, int &g, int &b, int a ) { float x = (float)a / 255; - r = (int)(r * x); - g = (int)(g * x); - b = (int)(b * x); + r = (int)( r * x ); + g = (int)( g * x ); + b = (int)( b * x ); } const unsigned char colors[8][3] = @@ -194,11 +192,11 @@ const unsigned char colors[8][3] = {240, 180, 24} }; -int CHud :: DrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ) +int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ) { if( hud_textmode->value == 2 ) { - gEngfuncs.pfnDrawSetTextColor( r/255.0, g/255.0, b/255.0 ); + gEngfuncs.pfnDrawSetTextColor( r / 255.0, g / 255.0, b / 255.0 ); return gEngfuncs.pfnDrawConsoleString( xpos, ypos, (char*) szIt ); } @@ -206,18 +204,18 @@ int CHud :: DrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int TextMessageDrawChar( 0, 0, 0, 0, 0, 0 ); // draw the string until we hit the null character or a newline character - for ( ; *szIt != 0 && *szIt != '\n'; szIt++ ) + for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) { - int w = gHUD.m_scrinfo.charWidths[ 'M' ]; - if ( xpos + w > iMaxX ) + int w = gHUD.m_scrinfo.charWidths['M']; + if( xpos + w > iMaxX ) return xpos; - if( (*szIt == '^') && (*(szIt + 1) >= '0') && (*(szIt + 1) <= '7') ) + if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') ) { szIt++; - r = colors[ *szIt - '0' ][0]; - g = colors[ *szIt - '0' ][1]; - b = colors[ *szIt - '0' ][2]; - if( !*(++szIt)) + r = colors[*szIt - '0'][0]; + g = colors[*szIt - '0'][1]; + b = colors[*szIt - '0'][2]; + if( !*(++szIt) ) return xpos; } int c = (unsigned int)(unsigned char)*szIt; @@ -228,67 +226,65 @@ int CHud :: DrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int return xpos; } -int CHud :: DrawHudStringLen( char *szIt ) +int CHud::DrawHudStringLen( char *szIt ) { int l = 0; - for ( ; *szIt != 0 && *szIt != '\n'; szIt++ ) + for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) { - l += gHUD.m_scrinfo.charWidths[ (unsigned char)*szIt ]; + l += gHUD.m_scrinfo.charWidths[(unsigned char)*szIt]; } return l; } - -int CHud :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b ) +int CHud::DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b ) { char szString[32]; sprintf( szString, "%d", iNumber ); return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b ); - } // draws a string from right to left (right-aligned) -int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ) +int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ) { // find the end of the string for( char *szIt = szString; *szIt != 0; szIt++ ) - xpos -= gHUD.m_scrinfo.charWidths[ (unsigned char) *szIt ]; + xpos -= gHUD.m_scrinfo.charWidths[(unsigned char)*szIt]; if( xpos < iMinX ) xpos = iMinX; DrawHudString( xpos, ypos, gHUD.m_scrinfo.iWidth, szString, r, g, b ); return xpos; } -int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b) +int CHud::DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b ) { - int iWidth = GetSpriteRect(m_HUD_number_0).right - GetSpriteRect(m_HUD_number_0).left; + int iWidth = GetSpriteRect( m_HUD_number_0 ).right - GetSpriteRect( m_HUD_number_0 ).left; int k; - if (iNumber > 0) + if( iNumber > 0 ) { // SPR_Draw 100's - if (iNumber >= 100) + if( iNumber >= 100 ) { - k = iNumber/100; - SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b ); - SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k)); + k = iNumber / 100; + SPR_Set( GetSprite( m_HUD_number_0 + k ), r, g, b ); + SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 + k ) ); x += iWidth; } - else if (iFlags & (DHN_3DIGITS)) + else if( iFlags & ( DHN_3DIGITS ) ) { //SPR_DrawAdditive( 0, x, y, &rc ); x += iWidth; } // SPR_Draw 10's - if (iNumber >= 10) + if( iNumber >= 10 ) { - k = (iNumber % 100)/10; - SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b ); - SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0 + k)); + k = ( iNumber % 100 ) / 10; + SPR_Set( GetSprite( m_HUD_number_0 + k ), r, g, b ); + SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 + k ) ); x += iWidth; } - else if (iFlags & (DHN_3DIGITS | DHN_2DIGITS)) + else if( iFlags & ( DHN_3DIGITS | DHN_2DIGITS ) ) { //SPR_DrawAdditive( 0, x, y, &rc ); x += iWidth; @@ -296,70 +292,66 @@ int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, // SPR_Draw ones k = iNumber % 10; - SPR_Set(GetSprite(m_HUD_number_0 + k), r, g, b ); - SPR_DrawAdditive(0, x, y, &GetSpriteRect(m_HUD_number_0 + k)); + SPR_Set( GetSprite( m_HUD_number_0 + k ), r, g, b ); + SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 + k ) ); x += iWidth; - } - else if (iFlags & DHN_DRAWZERO) + } + else if( iFlags & DHN_DRAWZERO ) { - SPR_Set(GetSprite(m_HUD_number_0), r, g, b ); + SPR_Set( GetSprite( m_HUD_number_0 ), r, g, b ); // SPR_Draw 100's - if (iFlags & (DHN_3DIGITS)) + if( iFlags & ( DHN_3DIGITS ) ) { //SPR_DrawAdditive( 0, x, y, &rc ); x += iWidth; } - if (iFlags & (DHN_3DIGITS | DHN_2DIGITS)) + if( iFlags & ( DHN_3DIGITS | DHN_2DIGITS ) ) { //SPR_DrawAdditive( 0, x, y, &rc ); x += iWidth; } // SPR_Draw ones - - SPR_DrawAdditive( 0, x, y, &GetSpriteRect(m_HUD_number_0)); + SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 ) ); x += iWidth; } return x; } - int CHud::GetNumWidth( int iNumber, int iFlags ) { - if (iFlags & (DHN_3DIGITS)) + if( iFlags & ( DHN_3DIGITS ) ) return 3; - if (iFlags & (DHN_2DIGITS)) + if( iFlags & ( DHN_2DIGITS ) ) return 2; - if (iNumber <= 0) + if( iNumber <= 0 ) { - if (iFlags & (DHN_DRAWZERO)) + if( iFlags & ( DHN_DRAWZERO ) ) return 1; else return 0; } - if (iNumber < 10) + if( iNumber < 10 ) return 1; - if (iNumber < 100) + if( iNumber < 100 ) return 2; return 3; - } - void CHud::DrawDarkRectangle( int x, int y, int wide, int tall ) { //gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture ); gEngfuncs.pfnFillRGBABlend( x, y, wide, tall, 0, 0, 0, 255 * 0.6 ); - FillRGBA( x+1, y, wide-1, 1, 255, 140, 0, 255 ); - FillRGBA( x, y, 1, tall-1, 255, 140, 0, 255 ); - FillRGBA( x+wide-1, y+1, 1, tall-1, 255, 140, 0, 255 ); - FillRGBA( x, y+tall-1, wide-1, 1, 255, 140, 0, 255 ); + FillRGBA( x + 1, y, wide - 1, 1, 255, 140, 0, 255 ); + FillRGBA( x, y, 1, tall - 1, 255, 140, 0, 255 ); + FillRGBA( x + wide - 1, y + 1, 1, tall - 1, 255, 140, 0, 255 ); + FillRGBA( x, y + tall - 1, wide - 1, 1, 255, 140, 0, 255 ); } diff --git a/cl_dll/hud_servers.cpp b/cl_dll/hud_servers.cpp index 7a5a1475..3cdab827 100644 --- a/cl_dll/hud_servers.cpp +++ b/cl_dll/hud_servers.cpp @@ -39,7 +39,7 @@ Callback from engine */ void NET_CALLBACK ListResponse( struct net_response_s *response ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->ListResponse( response ); } @@ -54,7 +54,7 @@ Callback from engine */ void NET_CALLBACK ServerResponse( struct net_response_s *response ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->ServerResponse( response ); } @@ -69,7 +69,7 @@ Callback from engine */ void NET_CALLBACK PingResponse( struct net_response_s *response ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->PingResponse( response ); } @@ -84,11 +84,12 @@ Callback from engine */ void NET_CALLBACK RulesResponse( struct net_response_s *response ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->RulesResponse( response ); } } + /* =================== PlayersResponse @@ -98,11 +99,12 @@ Callback from engine */ void NET_CALLBACK PlayersResponse( struct net_response_s *response ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->PlayersResponse( response ); } } + /* =================== ListResponse @@ -115,20 +117,20 @@ void CHudServers::ListResponse( struct net_response_s *response ) request_t *p; int c = 0; - if ( !( response->error == NET_SUCCESS ) ) + if( !( response->error == NET_SUCCESS ) ) return; - if ( response->type != NETAPI_REQUEST_SERVERLIST ) + if( response->type != NETAPI_REQUEST_SERVERLIST ) return; - if ( response->response ) + if( response->response ) { list = ( request_t * ) response->response; while ( list ) { c++; - //if ( c < 40 ) + //if( c < 40 ) { // Copy from parsed stuff p = new request_t; @@ -161,23 +163,23 @@ void CHudServers::ServerResponse( struct net_response_s *response ) request_t *p; server_t *browser; int len; - char sz[ 32 ]; + char sz[32]; // Remove from active list p = FindRequest( response->context, m_pActiveList ); - if ( p ) + if( p ) { RemoveServerFromList( &m_pActiveList, p ); m_nActiveQueries--; } - - if ( response->error != NET_SUCCESS ) + + if( response->error != NET_SUCCESS ) return; - + switch ( response->type ) { case NETAPI_REQUEST_DETAILS: - if ( response->response ) + if( response->response ) { szresponse = (char *)response->response; len = strlen( szresponse ) + 100 + 1; @@ -185,13 +187,13 @@ void CHudServers::ServerResponse( struct net_response_s *response ) browser = new server_t; browser->remote_address = response->remote_address; - browser->info = new char[ len ]; + browser->info = new char[len]; browser->ping = (int)( 1000.0 * response->ping ); strcpy( browser->info, szresponse ); NET_API->SetValueForKey( browser->info, "address", gEngfuncs.pNetAPI->AdrToString( &response->remote_address ), len ); NET_API->SetValueForKey( browser->info, "ping", sz, len ); - + AddServer( &m_pServers, browser ); } break; @@ -208,12 +210,12 @@ PingResponse */ void CHudServers::PingResponse( struct net_response_s *response ) { - char sz[ 32 ]; + char sz[32]; - if ( response->error != NET_SUCCESS ) + if( response->error != NET_SUCCESS ) return; - switch ( response->type ) + switch( response->type ) { case NETAPI_REQUEST_PING: sprintf( sz, "%.2f", 1000.0 * response->ping ); @@ -235,13 +237,13 @@ void CHudServers::RulesResponse( struct net_response_s *response ) { char *szresponse; - if ( response->error != NET_SUCCESS ) + if( response->error != NET_SUCCESS ) return; - switch ( response->type ) + switch( response->type ) { case NETAPI_REQUEST_RULES: - if ( response->response ) + if( response->response ) { szresponse = (char *)response->response; @@ -263,13 +265,13 @@ void CHudServers::PlayersResponse( struct net_response_s *response ) { char *szresponse; - if ( response->error != NET_SUCCESS ) + if( response->error != NET_SUCCESS ) return; - - switch ( response->type ) + + switch( response->type ) { case NETAPI_REQUEST_PLAYERS: - if ( response->response ) + if( response->response ) { szresponse = (char *)response->response; @@ -288,24 +290,24 @@ CompareServers Return 1 if p1 is "less than" p2, 0 otherwise =================== */ -int CHudServers::CompareServers( server_t *p1, server_t *p2 ) +int CHudServers::CompareServers( server_t *p1, server_t *p2 ) { const char *n1, *n2; - if ( p1->ping < p2->ping ) + if( p1->ping < p2->ping ) return 1; - if ( p1->ping == p2->ping ) + if( p1->ping == p2->ping ) { // Pings equal, sort by second key: hostname - if ( p1->info && p2->info ) + if( p1->info && p2->info ) { n1 = NET_API->ValueForKey( p1->info, "hostname" ); n2 = NET_API->ValueForKey( p2->info, "hostname" ); - if ( n1 && n2 ) + if( n1 && n2 ) { - if ( stricmp( n1, n2 ) < 0 ) + if( stricmp( n1, n2 ) < 0 ) return 1; } } @@ -322,9 +324,9 @@ AddServer */ void CHudServers::AddServer( server_t **ppList, server_t *p ) { -server_t *list; + server_t *list; - if ( !ppList || ! p ) + if( !ppList || ! p ) return; m_nServerCount++; @@ -333,7 +335,7 @@ server_t *list; list = *ppList; // Head of list? - if ( !list ) + if( !list ) { p->next = NULL; *ppList = p; @@ -341,17 +343,17 @@ server_t *list; } // Put on head of list - if ( CompareServers( p, list ) ) + if( CompareServers( p, list ) ) { p->next = *ppList; *ppList = p; } else { - while ( list->next ) + while( list->next ) { // Insert before list next - if ( CompareServers( p, list->next ) ) + if( CompareServers( p, list->next ) ) { p->next = list->next->next; list->next = p; @@ -377,15 +379,15 @@ void CHudServers::Think( double time ) { m_fElapsed += time; - if ( !m_nRequesting ) + if( !m_nRequesting ) return; - if ( !m_nQuerying ) + if( !m_nQuerying ) return; QueryThink(); - if ( ServerListSize() > 0 ) + if( ServerListSize() > 0 ) return; m_dStarted = 0.0; @@ -405,25 +407,25 @@ void CHudServers::QueryThink( void ) { request_t *p; - if ( !m_nRequesting || m_nDone ) + if( !m_nRequesting || m_nDone ) return; - if ( !m_nQuerying ) + if( !m_nQuerying ) return; - if ( m_nActiveQueries > MAX_QUERIES ) + if( m_nActiveQueries > MAX_QUERIES ) return; // Nothing left - if ( !m_pServerList ) + if( !m_pServerList ) return; - while ( 1 ) + while( 1 ) { p = m_pServerList; // No more in list? - if ( !p ) + if( !p ) break; // Move to next @@ -443,7 +445,7 @@ void CHudServers::QueryThink( void ) m_pActiveList = p; // Too many active? - if ( m_nActiveQueries > MAX_QUERIES ) + if( m_nActiveQueries > MAX_QUERIES ) break; } } @@ -455,20 +457,20 @@ ServerListSize # of servers in active query and in pending to be queried lists ================== */ -int CHudServers::ServerListSize( void ) +int CHudServers::ServerListSize( void ) { int c = 0; request_t *p; p = m_pServerList; - while ( p ) + while( p ) { c++; p = p->next; } p = m_pActiveList; - while ( p ) + while( p ) { c++; p = p->next; @@ -488,9 +490,9 @@ CHudServers::request_t *CHudServers::FindRequest( int context, request_t *pList { request_t *p; p = pList; - while ( p ) + while( p ) { - if ( context == p->context ) + if( context == p->context ) return p; p = p->next; @@ -510,14 +512,14 @@ void CHudServers::RemoveServerFromList( request_t **ppList, request_t *item ) request_t *p, *n; request_t *newlist = NULL; - if ( !ppList ) + if( !ppList ) return; p = *ppList; - while ( p ) + while( p ) { n = p->next; - if ( p != item ) + if( p != item ) { p->next = newlist; newlist = p; @@ -537,11 +539,11 @@ void CHudServers::ClearRequestList( request_t **ppList ) { request_t *p, *n; - if ( !ppList ) + if( !ppList ) return; p = *ppList; - while ( p ) + while( p ) { n = p->next; delete p; @@ -560,11 +562,11 @@ void CHudServers::ClearServerList( server_t **ppList ) { server_t *p, *n; - if ( !ppList ) + if( !ppList ) return; p = *ppList; - while ( p ) + while( p ) { n = p->next; delete[] p->info; @@ -585,11 +587,11 @@ int CompareField( CHudServers::server_t *p1, CHudServers::server_t *p2, const ch fv1 = atof( sz1 ); fv2 = atof( sz2 ); - if ( fv1 && fv2 ) + if( fv1 && fv2 ) { - if ( fv1 > fv2 ) + if( fv1 > fv2 ) return iSortOrder; - else if ( fv1 < fv2 ) + else if( fv1 < fv2 ) return -iSortOrder; else return 0; @@ -601,7 +603,7 @@ int CompareField( CHudServers::server_t *p1, CHudServers::server_t *p2, const ch int CALLBACK ServerListCompareFunc( CHudServers::server_t *p1, CHudServers::server_t *p2, const char *fieldname ) { - if (!p1 || !p2) // No meaningful comparison + if(!p1 || !p2) // No meaningful comparison return 0; int iSortOrder = 1; @@ -613,8 +615,8 @@ int CALLBACK ServerListCompareFunc( CHudServers::server_t *p1, CHudServers::serv return retval; } -static char g_fieldname[ 256 ]; -int __cdecl FnServerCompare(const void *elem1, const void *elem2 ) +static char g_fieldname[256]; +int __cdecl FnServerCompare( const void *elem1, const void *elem2 ) { CHudServers::server_t *list1, *list2; @@ -628,7 +630,7 @@ void CHudServers::SortServers( const char *fieldname ) { server_t *p; // Create a list - if ( !m_pServers ) + if( !m_pServers ) return; strcpy( g_fieldname, fieldname ); @@ -637,7 +639,7 @@ void CHudServers::SortServers( const char *fieldname ) int c = 0; p = m_pServers; - while ( p ) + while( p ) { c++; p = p->next; @@ -645,21 +647,21 @@ void CHudServers::SortServers( const char *fieldname ) server_t **pSortArray; - pSortArray = new server_t *[ c ]; - memset( pSortArray, 0, c * sizeof( server_t * ) ); + pSortArray = new server_t *[c]; + memset( pSortArray, 0, c * sizeof(server_t*) ); // Now copy the list into the pSortArray: p = m_pServers; i = 0; - while ( p ) + while( p ) { - pSortArray[ i++ ] = p; + pSortArray[i++] = p; p = p->next; } // Now do that actual sorting. size_t nCount = c; - size_t nSize = sizeof( server_t * ); + size_t nSize = sizeof(server_t*); qsort( pSortArray, @@ -670,11 +672,11 @@ void CHudServers::SortServers( const char *fieldname ) // Now rebuild the list. m_pServers = pSortArray[0]; - for ( i = 0; i < c - 1; i++ ) + for( i = 0; i < c - 1; i++ ) { - pSortArray[ i ]->next = pSortArray[ i + 1 ]; + pSortArray[i]->next = pSortArray[i + 1]; } - pSortArray[ c - 1 ]->next = NULL; + pSortArray[c - 1]->next = NULL; // Clean Up. delete[] pSortArray; @@ -693,9 +695,9 @@ CHudServers::server_t *CHudServers::GetServer( int server ) server_t *p; p = m_pServers; - while ( p ) + while( p ) { - if ( c == server ) + if( c == server ) return p; c++; @@ -714,7 +716,7 @@ Return info ( key/value ) string for particular server char *CHudServers::GetServerInfo( int server ) { server_t *p = GetServer( server ); - if ( p ) + if( p ) { return p->info; } @@ -731,8 +733,8 @@ Kill all pending requests in engine void CHudServers::CancelRequest( void ) { m_nRequesting = 0; - m_nQuerying = 0; - m_nDone = 1; + m_nQuerying = 0; + m_nDone = 1; NET_API->CancelAllRequests(); } @@ -747,16 +749,16 @@ Loads the master server addresses from file and into the passed in array int CHudServers::LoadMasterAddresses( int maxservers, int *count, netadr_t *padr ) { int i; - char szMaster[ 256 ]; + char szMaster[256]; char szMasterFile[256]; char *pbuffer = NULL; char *pstart = NULL ; netadr_t adr; char szAdr[64]; - int nPort; - int nCount = 0; + int nPort; + int nCount = 0; bool bIgnore; - int nDefaultPort; + int nDefaultPort; // Assume default master and master file strcpy( szMaster, VALVE_MASTER_ADDRESS ); // IP:PORT string @@ -764,30 +766,30 @@ int CHudServers::LoadMasterAddresses( int maxservers, int *count, netadr_t *padr // See if there is a command line override i = gEngfuncs.CheckParm( "-comm", &pstart ); - if ( i && pstart ) + if( i && pstart ) { - strcpy (szMasterFile, pstart ); + strcpy( szMasterFile, pstart ); } // Read them in from proper file pbuffer = (char *)gEngfuncs.COM_LoadFile( szMasterFile, 5, NULL ); // Use malloc - if ( !pbuffer ) + if( !pbuffer ) { goto finish_master; } pstart = pbuffer; - while ( nCount < maxservers ) + while( nCount < maxservers ) { pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); - if ( strlen(m_szToken) <= 0) + if( strlen( m_szToken ) <= 0) break; bIgnore = true; - if ( !stricmp( m_szToken, "Master" ) ) + if( !stricmp( m_szToken, "Master" ) ) { nDefaultPort = PORT_MASTER; bIgnore = FALSE; @@ -795,74 +797,72 @@ int CHudServers::LoadMasterAddresses( int maxservers, int *count, netadr_t *padr // Now parse all addresses between { } pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); - if ( strlen(m_szToken) <= 0 ) + if( strlen( m_szToken ) <= 0 ) break; - if ( stricmp ( m_szToken, "{" ) ) + if( stricmp( m_szToken, "{" ) ) break; // Parse addresses until we get to "}" - while ( nCount < maxservers ) + while( nCount < maxservers ) { char base[256]; // Now parse all addresses between { } pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); - if (strlen(m_szToken) <= 0) + if( strlen( m_szToken ) <= 0 ) break; - if ( !stricmp ( m_szToken, "}" ) ) + if( !stricmp ( m_szToken, "}" ) ) break; - + sprintf( base, "%s", m_szToken ); pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); - if (strlen(m_szToken) <= 0) + if( strlen( m_szToken ) <= 0 ) break; - if ( stricmp( m_szToken, ":" ) ) + if( stricmp( m_szToken, ":" ) ) break; pstart = gEngfuncs.COM_ParseFile( pstart, m_szToken ); - - if (strlen(m_szToken) <= 0) + + if( strlen( m_szToken ) <= 0 ) break; - nPort = atoi ( m_szToken ); - if ( !nPort ) + nPort = atoi( m_szToken ); + if( !nPort ) nPort = nDefaultPort; sprintf( szAdr, "%s:%i", base, nPort ); // Can we resolve it any better - if ( !NET_API->StringToAdr( szAdr, &adr ) ) + if( !NET_API->StringToAdr( szAdr, &adr ) ) bIgnore = true; - if ( !bIgnore ) + if( !bIgnore ) { - padr[ nCount++ ] = adr; + padr[nCount++] = adr; } } } - finish_master: - if ( !nCount ) + if( !nCount ) { sprintf( szMaster, VALVE_MASTER_ADDRESS ); // IP:PORT string // Convert to netadr_t - if ( NET_API->StringToAdr ( szMaster, &adr ) ) + if( NET_API->StringToAdr( szMaster, &adr ) ) { - - padr[ nCount++ ] = adr; + padr[nCount++] = adr; } } *count = nCount; - if ( pbuffer ) + if( pbuffer ) { gEngfuncs.COM_FreeFile( pbuffer ); } @@ -879,14 +879,14 @@ Request list of game servers from master */ void CHudServers::RequestList( void ) { - m_nRequesting = 1; - m_nDone = 0; - m_dStarted = m_fElapsed; + m_nRequesting = 1; + m_nDone = 0; + m_dStarted = m_fElapsed; int count = 0; netadr_t adr; - if ( !LoadMasterAddresses( 1, &count, &adr ) ) + if( !LoadMasterAddresses( 1, &count, &adr ) ) { gEngfuncs.Con_DPrintf( "SendRequest: Unable to read master server addresses\n" ); return; @@ -910,14 +910,14 @@ void CHudServers::RequestList( void ) void CHudServers::RequestBroadcastList( int clearpending ) { - m_nRequesting = 1; - m_nDone = 0; - m_dStarted = m_fElapsed; + m_nRequesting = 1; + m_nDone = 0; + m_dStarted = m_fElapsed; - netadr_t adr; - memset( &adr, 0, sizeof( adr ) ); + netadr_t adr; + memset( &adr, 0, sizeof(adr) ); - if ( clearpending ) + if( clearpending ) { ClearRequestList( &m_pActiveList ); ClearRequestList( &m_pServerList ); @@ -932,7 +932,7 @@ void CHudServers::RequestBroadcastList( int clearpending ) // Make sure networking system has started. NET_API->InitNetworking(); - if ( clearpending ) + if( clearpending ) { // Kill off left overs if any NET_API->CancelAllRequests(); @@ -952,9 +952,9 @@ void CHudServers::RequestBroadcastList( int clearpending ) void CHudServers::ServerPing( int server ) { server_t *p; - + p = GetServer( server ); - if ( !p ) + if( !p ) return; // Make sure networking system has started. @@ -967,9 +967,9 @@ void CHudServers::ServerPing( int server ) void CHudServers::ServerRules( int server ) { server_t *p; - + p = GetServer( server ); - if ( !p ) + if( !p ) return; // Make sure networking system has started. @@ -982,9 +982,9 @@ void CHudServers::ServerRules( int server ) void CHudServers::ServerPlayers( int server ) { server_t *p; - + p = GetServer( server ); - if ( !p ) + if( !p ) return; // Make sure networking system has started. @@ -999,7 +999,6 @@ int CHudServers::isQuerying() return m_nRequesting ? 1 : 0; } - /* =================== GetServerCount @@ -1021,16 +1020,15 @@ CHudServers CHudServers::CHudServers( void ) { m_nRequesting = 0; - m_dStarted = 0.0; - m_nDone = 0; + m_dStarted = 0.0; + m_nDone = 0; m_pServerList = NULL; - m_pServers = NULL; + m_pServers = NULL; m_pActiveList = NULL; - m_nQuerying = 0; + m_nQuerying = 0; m_nActiveQueries = 0; - - m_fElapsed = 0.0; + m_fElapsed = 0.0; m_pPingRequest = NULL; m_pRulesRequest = NULL; @@ -1051,20 +1049,19 @@ CHudServers::~CHudServers( void ) m_nServerCount = 0; - if ( m_pPingRequest ) + if( m_pPingRequest ) { delete m_pPingRequest; m_pPingRequest = NULL; - } - - if ( m_pRulesRequest ) + + if( m_pRulesRequest ) { delete m_pRulesRequest; m_pRulesRequest = NULL; } - if ( m_pPlayersRequest ) + if( m_pPlayersRequest ) { delete m_pPlayersRequest; m_pPlayersRequest = NULL; @@ -1083,18 +1080,18 @@ ServersGetCount =================== */ -int ServersGetCount( void ) +int ServersGetCount( void ) { - if ( g_pServers ) + if( g_pServers ) { return g_pServers->GetServerCount(); } return 0; } -int ServersIsQuerying( void ) +int ServersIsQuerying( void ) { - if ( g_pServers ) + if( g_pServers ) { return g_pServers->isQuerying(); } @@ -1109,17 +1106,17 @@ ServersGetInfo */ const char *ServersGetInfo( int server ) { - if ( g_pServers ) + if( g_pServers ) { return g_pServers->GetServerInfo( server ); } - + return NULL; } void SortServers( const char *fieldname ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->SortServers( fieldname ); } @@ -1133,7 +1130,7 @@ ServersShutdown */ void ServersShutdown( void ) { - if ( g_pServers ) + if( g_pServers ) { delete g_pServers; g_pServers = NULL; @@ -1150,7 +1147,7 @@ void ServersInit( void ) { // Kill any previous instance ServersShutdown(); - + g_pServers = new CHudServers(); } @@ -1162,7 +1159,7 @@ ServersThink */ void ServersThink( double time ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->Think( time ); } @@ -1176,7 +1173,7 @@ ServersCancel */ void ServersCancel( void ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->CancelRequest(); } @@ -1191,7 +1188,7 @@ ServersList */ void ServersList( void ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->RequestList(); } @@ -1199,7 +1196,7 @@ void ServersList( void ) void BroadcastServersList( int clearpending ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->RequestBroadcastList( clearpending ); } @@ -1207,7 +1204,7 @@ void BroadcastServersList( int clearpending ) void ServerPing( int server ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->ServerPing( server ); } @@ -1215,7 +1212,7 @@ void ServerPing( int server ) void ServerRules( int server ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->ServerRules( server ); } @@ -1223,8 +1220,8 @@ void ServerRules( int server ) void ServerPlayers( int server ) { - if ( g_pServers ) + if( g_pServers ) { g_pServers->ServerPlayers( server ); } -} \ No newline at end of file +} diff --git a/cl_dll/hud_servers.h b/cl_dll/hud_servers.h index 01e94425..33fb72a5 100644 --- a/cl_dll/hud_servers.h +++ b/cl_dll/hud_servers.h @@ -33,9 +33,8 @@ void ServerPing( int server ); void ServerRules( int server ); void ServerPlayers( int server ); -int ServersGetCount( void ); +int ServersGetCount( void ); const char *ServersGetInfo( int server ); -int ServersIsQuerying( void ); +int ServersIsQuerying( void ); void SortServers( const char *fieldname ); - -#endif // HUD_SERVERSH \ No newline at end of file +#endif // HUD_SERVERSH diff --git a/cl_dll/hud_servers_priv.h b/cl_dll/hud_servers_priv.h index 73692f46..d26b3655 100644 --- a/cl_dll/hud_servers_priv.h +++ b/cl_dll/hud_servers_priv.h @@ -17,16 +17,16 @@ public: typedef struct request_s { struct request_s *next; - netadr_t remote_address; - int context; + netadr_t remote_address; + int context; } request_t; typedef struct server_s { - struct server_s *next; - netadr_t remote_address; - char *info; - int ping; + struct server_s *next; + netadr_t remote_address; + char *info; + int ping; } server_t; CHudServers(); @@ -34,9 +34,9 @@ public: void Think( double time ); void QueryThink( void ); - int isQuerying( void ); + int isQuerying( void ); - int LoadMasterAddresses( int maxservers, int *count, netadr_t *padr ); + int LoadMasterAddresses( int maxservers, int *count, netadr_t *padr ); void RequestList( void ); void RequestBroadcastList( int clearpending ); @@ -47,7 +47,7 @@ public: void CancelRequest( void ); - int CompareServers( server_t *p1, server_t *p2 ); + int CompareServers( server_t *p1, server_t *p2 ); void ClearServerList( server_t **ppList ); void ClearRequestList( request_t **ppList ); @@ -58,9 +58,9 @@ public: request_t *FindRequest( int context, request_t *pList ); - int ServerListSize( void ); + int ServerListSize( void ); char *GetServerInfo( int server ); - int GetServerCount( void ); + int GetServerCount( void ); void SortServers( const char *fieldname ); void ListResponse( struct net_response_s *response ); @@ -73,26 +73,25 @@ private: server_t *GetServer( int server ); // - char m_szToken[ 1024 ]; - int m_nRequesting; - int m_nDone; + char m_szToken[1024]; + int m_nRequesting; + int m_nDone; - double m_dStarted; + double m_dStarted; request_t *m_pServerList; request_t *m_pActiveList; - server_t *m_pServers; + server_t *m_pServers; - int m_nServerCount; + int m_nServerCount; - int m_nActiveQueries; - int m_nQuerying; - double m_fElapsed; + int m_nActiveQueries; + int m_nQuerying; + double m_fElapsed; - request_t *m_pPingRequest; - request_t *m_pRulesRequest; - request_t *m_pPlayersRequest; + request_t *m_pPingRequest; + request_t *m_pRulesRequest; + request_t *m_pPlayersRequest; }; - -#endif // HUD_SERVERS_PRIVH \ No newline at end of file +#endif // HUD_SERVERS_PRIVH diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index 019c71e9..91e8fa37 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -24,17 +24,15 @@ #include "studio_util.h" #include "screenfade.h" - #pragma warning(disable: 4244) extern "C" int iJumpSpectator; extern "C" float vJumpOrigin[3]; extern "C" float vJumpAngles[3]; - -extern void V_GetInEyePos(int entity, float * origin, float * angles ); +extern void V_GetInEyePos( int entity, float * origin, float * angles ); extern void V_ResetChaseCam(); -extern void V_GetChasePos(int target, float * cl_angles, float * origin, float * angles); +extern void V_GetChasePos( int target, float * cl_angles, float * origin, float * angles ); extern void VectorAngles( const float *forward, float *angles ); extern "C" void NormalizeAngles( float *angles ); extern float * GetClientColor( int clientIndex ); @@ -44,53 +42,50 @@ extern vec3_t v_angles; // last view angle extern vec3_t v_cl_angles; // last client/mouse angle extern vec3_t v_sim_org; // last sim origin -void SpectatorMode(void) +void SpectatorMode( void ) { - - - if ( gEngfuncs.Cmd_Argc() <= 1 ) + if( gEngfuncs.Cmd_Argc() <= 1 ) { gEngfuncs.Con_Printf( "usage: spec_mode
[]\n" ); return; } // SetModes() will decide if command is executed on server or local - if ( gEngfuncs.Cmd_Argc() == 2 ) - gHUD.m_Spectator.SetModes( atoi( gEngfuncs.Cmd_Argv(1) ), -1 ); + if( gEngfuncs.Cmd_Argc() == 2 ) + gHUD.m_Spectator.SetModes( atoi( gEngfuncs.Cmd_Argv( 1 ) ), -1 ); else if ( gEngfuncs.Cmd_Argc() == 3 ) - gHUD.m_Spectator.SetModes( atoi( gEngfuncs.Cmd_Argv(1) ), atoi( gEngfuncs.Cmd_Argv(2) ) ); + gHUD.m_Spectator.SetModes( atoi( gEngfuncs.Cmd_Argv( 1 ) ), atoi( gEngfuncs.Cmd_Argv( 2 ) ) ); } -void SpectatorSpray(void) +void SpectatorSpray( void ) { vec3_t forward; char string[128]; - if ( !gEngfuncs.IsSpectateOnly() ) + if( !gEngfuncs.IsSpectateOnly() ) return; - AngleVectors(v_angles,forward,NULL,NULL); - VectorScale(forward, 128, forward); - VectorAdd(forward, v_origin, forward); + AngleVectors( v_angles, forward, NULL, NULL ); + VectorScale( forward, 128, forward ); + VectorAdd( forward, v_origin, forward ); pmtrace_t * trace = gEngfuncs.PM_TraceLine( v_origin, forward, PM_TRACELINE_PHYSENTSONLY, 2, -1 ); - if ( trace->fraction != 1.0 ) + if( trace->fraction != 1.0 ) { - sprintf(string, "drc_spray %.2f %.2f %.2f %i", + sprintf( string, "drc_spray %.2f %.2f %.2f %i", trace->endpos[0], trace->endpos[1], trace->endpos[2], trace->ent ); - gEngfuncs.pfnServerCmd(string); + gEngfuncs.pfnServerCmd( string ); } - } -void SpectatorHelp(void) +void SpectatorHelp( void ) { { char *text = CHudTextMessage::BufferedLocaliseTextString( "#Spec_Help_Text" ); - - if ( text ) + + if( text ) { - while ( *text ) + while( *text ) { - if ( *text != 13 ) + if( *text != 13 ) gEngfuncs.Con_Printf( "%c", *text ); text++; } @@ -100,12 +95,11 @@ void SpectatorHelp(void) void SpectatorMenu( void ) { - if ( gEngfuncs.Cmd_Argc() <= 1 ) + if( gEngfuncs.Cmd_Argc() <= 1 ) { gEngfuncs.Con_Printf( "usage: spec_menu <0|1>\n" ); return; } - } void ToggleScores( void ) @@ -117,45 +111,43 @@ void ToggleScores( void ) //----------------------------------------------------------------------------- int CHudSpectator::Init() { - gHUD.AddHudElem(this); + gHUD.AddHudElem( this ); m_iFlags |= HUD_ACTIVE; m_flNextObserverInput = 0.0f; - m_zoomDelta = 0.0f; + m_zoomDelta = 0.0f; m_moveDelta = 0.0f; - m_chatEnabled = (gHUD.m_SayText.m_HUD_saytext->value!=0); - iJumpSpectator = 0; + m_chatEnabled = ( gHUD.m_SayText.m_HUD_saytext->value != 0 ); + iJumpSpectator = 0; - memset( &m_OverviewData, 0, sizeof(m_OverviewData)); - memset( &m_OverviewEntities, 0, sizeof(m_OverviewEntities)); + memset( &m_OverviewData, 0, sizeof(m_OverviewData) ); + memset( &m_OverviewEntities, 0, sizeof(m_OverviewEntities) ); m_lastPrimaryObject = m_lastSecondaryObject = 0; - gEngfuncs.pfnAddCommand ("spec_mode", SpectatorMode ); - gEngfuncs.pfnAddCommand ("spec_decal", SpectatorSpray ); - gEngfuncs.pfnAddCommand ("spec_help", SpectatorHelp ); - gEngfuncs.pfnAddCommand ("spec_menu", SpectatorMenu ); - gEngfuncs.pfnAddCommand ("togglescores", ToggleScores ); + gEngfuncs.pfnAddCommand( "spec_mode", SpectatorMode ); + gEngfuncs.pfnAddCommand( "spec_decal", SpectatorSpray ); + gEngfuncs.pfnAddCommand( "spec_help", SpectatorHelp ); + gEngfuncs.pfnAddCommand( "spec_menu", SpectatorMenu ); + gEngfuncs.pfnAddCommand( "togglescores", ToggleScores ); - m_drawnames = gEngfuncs.pfnRegisterVariable("spec_drawnames","1",0); - m_drawcone = gEngfuncs.pfnRegisterVariable("spec_drawcone","1",0); - m_drawstatus = gEngfuncs.pfnRegisterVariable("spec_drawstatus","1",0); - m_autoDirector = gEngfuncs.pfnRegisterVariable("spec_autodirector","1",0); - m_pip = gEngfuncs.pfnRegisterVariable("spec_pip","1",0); + m_drawnames = gEngfuncs.pfnRegisterVariable( "spec_drawnames", "1", 0 ); + m_drawcone = gEngfuncs.pfnRegisterVariable( "spec_drawcone", "1", 0 ); + m_drawstatus = gEngfuncs.pfnRegisterVariable( "spec_drawstatus", "1", 0 ); + m_autoDirector = gEngfuncs.pfnRegisterVariable( "spec_autodirector", "1", 0 ); + m_pip = gEngfuncs.pfnRegisterVariable( "spec_pip", "1", 0 ); - if ( !m_drawnames || !m_drawcone || !m_drawstatus || !m_autoDirector || !m_pip) + if( !m_drawnames || !m_drawcone || !m_drawstatus || !m_autoDirector || !m_pip ) { - gEngfuncs.Con_Printf("ERROR! Couldn't register all spectator variables.\n"); + gEngfuncs.Con_Printf( "ERROR! Couldn't register all spectator variables.\n" ); return 0; } return 1; } - //----------------------------------------------------------------------------- // UTIL_StringToVector originally from ..\dlls\util.cpp, slightly changed //----------------------------------------------------------------------------- - void UTIL_StringToVector( float * pVector, const char *pString ) { char *pstr, *pfront, tempString[128]; @@ -163,179 +155,175 @@ void UTIL_StringToVector( float * pVector, const char *pString ) strcpy( tempString, pString ); pstr = pfront = tempString; - - for ( j = 0; j < 3; j++ ) + + for( j = 0; j < 3; j++ ) { pVector[j] = atof( pfront ); - - while ( *pstr && *pstr != ' ' ) + + while( *pstr && *pstr != ' ' ) pstr++; - if (!*pstr) + if( !( *pstr ) ) break; pstr++; pfront = pstr; } - if (j < 2) + if( j < 2 ) { - for (j = j+1;j < 3; j++) + for( j = j + 1;j < 3; j++ ) pVector[j] = 0; } } -int UTIL_FindEntityInMap(char * name, float * origin, float * angle) +int UTIL_FindEntityInMap( char * name, float * origin, float * angle ) { - int n,found = 0; + int n, found = 0; char keyname[256]; char token[2048]; cl_entity_t * pEnt = gEngfuncs.GetEntityByIndex( 0 ); // get world model - if ( !pEnt ) return 0; + if( !pEnt ) + return 0; - if ( !pEnt->model ) return 0; + if( !pEnt->model ) + return 0; char * data = pEnt->model->entities; - while (data) + while( data ) { - data = gEngfuncs.COM_ParseFile(data, token); - - if ( (token[0] == '}') || (token[0]==0) ) + data = gEngfuncs.COM_ParseFile( data, token ); + + if( ( token[0] == '}' ) || ( token[0] == 0 ) ) break; - if (!data) + if( !data ) { - gEngfuncs.Con_DPrintf("UTIL_FindEntityInMap: EOF without closing brace\n"); + gEngfuncs.Con_DPrintf( "UTIL_FindEntityInMap: EOF without closing brace\n" ); return 0; } - if (token[0] != '{') + if( token[0] != '{' ) { - gEngfuncs.Con_DPrintf("UTIL_FindEntityInMap: expected {\n"); + gEngfuncs.Con_DPrintf( "UTIL_FindEntityInMap: expected {\n" ); return 0; } - // we parse the first { now parse entities properties - - while ( 1 ) + // we parse the first { now parse entities properties + while( 1 ) { // parse key - data = gEngfuncs.COM_ParseFile(data, token); - if (token[0] == '}') + data = gEngfuncs.COM_ParseFile( data, token ); + if( token[0] == '}' ) break; // finish parsing this entity - if (!data) - { - gEngfuncs.Con_DPrintf("UTIL_FindEntityInMap: EOF without closing brace\n"); + if( !data ) + { + gEngfuncs.Con_DPrintf( "UTIL_FindEntityInMap: EOF without closing brace\n" ); return 0; - }; - - strcpy (keyname, token); + } + + strcpy( keyname, token ); // another hack to fix keynames with trailing spaces - n = strlen(keyname); - while (n && keyname[n-1] == ' ') + n = strlen( keyname ); + while( n && keyname[n - 1] == ' ' ) { - keyname[n-1] = 0; + keyname[n - 1] = 0; n--; } - + // parse value - data = gEngfuncs.COM_ParseFile(data, token); - if (!data) - { - gEngfuncs.Con_DPrintf("UTIL_FindEntityInMap: EOF without closing brace\n"); - return 0; - }; - - if (token[0] == '}') + data = gEngfuncs.COM_ParseFile( data, token ); + if( !data ) { - gEngfuncs.Con_DPrintf("UTIL_FindEntityInMap: closing brace without data"); + gEngfuncs.Con_DPrintf( "UTIL_FindEntityInMap: EOF without closing brace\n" ); + return 0; + } + + if( token[0] == '}' ) + { + gEngfuncs.Con_DPrintf( "UTIL_FindEntityInMap: closing brace without data" ); return 0; } - if (!strcmp(keyname,"classname")) + if( !strcmp( keyname, "classname" ) ) { - if (!strcmp(token, name )) + if( !strcmp( token, name ) ) { found = 1; // thats our entity } - }; + } if( !strcmp( keyname, "angle" ) ) { float y = atof( token ); - - if (y >= 0) + + if( y >= 0 ) { angle[0] = 0.0f; angle[1] = y; } - else if ((int)y == -1) + else if( (int)y == -1 ) { angle[0] = -90.0f; - angle[1] = 0.0f;; + angle[1] = 0.0f;; } else { angle[0] = 90.0f; - angle[1] = 0.0f; + angle[1] = 0.0f; } - angle[2] = 0.0f; + angle[2] = 0.0f; } if( !strcmp( keyname, "angles" ) ) { - UTIL_StringToVector(angle, token); + UTIL_StringToVector( angle, token ); } - - if (!strcmp(keyname,"origin")) - { - UTIL_StringToVector(origin, token); - }; - + if( !strcmp( keyname, "origin" ) ) + { + UTIL_StringToVector( origin, token ); + } } // while (1) - if (found) + if( found ) return 1; - } return 0; // we search all entities, but didn't found the correct - } //----------------------------------------------------------------------------- // SetSpectatorStartPosition(): // Get valid map position and 'beam' spectator to this position //----------------------------------------------------------------------------- - void CHudSpectator::SetSpectatorStartPosition() { // search for info_player start - if ( UTIL_FindEntityInMap( "trigger_camera", m_cameraOrigin, m_cameraAngles ) ) + if( UTIL_FindEntityInMap( "trigger_camera", m_cameraOrigin, m_cameraAngles ) ) iJumpSpectator = 1; - else if ( UTIL_FindEntityInMap( "info_player_start", m_cameraOrigin, m_cameraAngles ) ) + else if( UTIL_FindEntityInMap( "info_player_start", m_cameraOrigin, m_cameraAngles ) ) iJumpSpectator = 1; - else if ( UTIL_FindEntityInMap( "info_player_deathmatch", m_cameraOrigin, m_cameraAngles ) ) + else if( UTIL_FindEntityInMap( "info_player_deathmatch", m_cameraOrigin, m_cameraAngles ) ) iJumpSpectator = 1; - else if ( UTIL_FindEntityInMap( "info_player_coop", m_cameraOrigin, m_cameraAngles ) ) + else if( UTIL_FindEntityInMap( "info_player_coop", m_cameraOrigin, m_cameraAngles ) ) iJumpSpectator = 1; else { // jump to 0,0,0 if no better position was found - VectorCopy(vec3_origin, m_cameraOrigin); - VectorCopy(vec3_origin, m_cameraAngles); + VectorCopy( vec3_origin, m_cameraOrigin ); + VectorCopy( vec3_origin, m_cameraAngles ); } - - VectorCopy(m_cameraOrigin, vJumpOrigin); - VectorCopy(m_cameraAngles, vJumpAngles); + + VectorCopy( m_cameraOrigin, vJumpOrigin ); + VectorCopy( m_cameraAngles, vJumpAngles ); iJumpSpectator = 1; // jump anyway } @@ -345,15 +333,15 @@ void CHudSpectator::SetSpectatorStartPosition() //----------------------------------------------------------------------------- int CHudSpectator::VidInit() { - m_hsprPlayer = SPR_Load("sprites/iplayer.spr"); - m_hsprPlayerBlue = SPR_Load("sprites/iplayerblue.spr"); - m_hsprPlayerRed = SPR_Load("sprites/iplayerred.spr"); - m_hsprPlayerDead = SPR_Load("sprites/iplayerdead.spr"); - m_hsprUnkownMap = SPR_Load("sprites/tile.spr"); - m_hsprBeam = SPR_Load("sprites/laserbeam.spr"); - m_hsprCamera = SPR_Load("sprites/camera.spr"); - m_hCrosshair = SPR_Load("sprites/crosshairs.spr"); - + m_hsprPlayer = SPR_Load( "sprites/iplayer.spr" ); + m_hsprPlayerBlue = SPR_Load( "sprites/iplayerblue.spr" ); + m_hsprPlayerRed = SPR_Load( "sprites/iplayerred.spr" ); + m_hsprPlayerDead = SPR_Load( "sprites/iplayerdead.spr" ); + m_hsprUnkownMap = SPR_Load( "sprites/tile.spr" ); + m_hsprBeam = SPR_Load( "sprites/laserbeam.spr" ); + m_hsprCamera = SPR_Load( "sprites/camera.spr" ); + m_hCrosshair = SPR_Load( "sprites/crosshairs.spr" ); + return 1; } @@ -362,7 +350,7 @@ int CHudSpectator::VidInit() // Input : flTime - // intermission - //----------------------------------------------------------------------------- -int CHudSpectator::Draw(float flTime) +int CHudSpectator::Draw( float flTime ) { int lx; @@ -370,215 +358,192 @@ int CHudSpectator::Draw(float flTime) float * color; // draw only in spectator mode - if ( !g_iUser1 ) + if( !g_iUser1 ) return 0; // if user pressed zoom, aplly changes - if ( (m_zoomDelta != 0.0f) && ( g_iUser1 == OBS_MAP_FREE ) ) + if( ( m_zoomDelta != 0.0f ) && ( g_iUser1 == OBS_MAP_FREE ) ) { m_mapZoom += m_zoomDelta; - if ( m_mapZoom > 3.0f ) + if( m_mapZoom > 3.0f ) m_mapZoom = 3.0f; - if ( m_mapZoom < 0.5f ) + if( m_mapZoom < 0.5f ) m_mapZoom = 0.5f; } // if user moves in map mode, change map origin - if ( (m_moveDelta != 0.0f) && (g_iUser1 != OBS_ROAMING) ) + if( ( m_moveDelta != 0.0f ) && ( g_iUser1 != OBS_ROAMING ) ) { - vec3_t right; - AngleVectors(v_angles, NULL, right, NULL); - VectorNormalize(right); - VectorScale(right, m_moveDelta, right ); + vec3_t right; + AngleVectors( v_angles, NULL, right, NULL ); + VectorNormalize( right ); + VectorScale( right, m_moveDelta, right ); VectorAdd( m_mapOrigin, right, m_mapOrigin ) - } - + // Only draw the icon names only if map mode is in Main Mode - if ( g_iUser1 < OBS_MAP_FREE ) + if( g_iUser1 < OBS_MAP_FREE ) return 1; - - if ( !m_drawnames->value ) + + if( !m_drawnames->value ) return 1; - + // make sure we have player info //gViewPort->GetAllPlayersInfo(); gHUD.m_Scoreboard.GetAllPlayersInfo(); - - // loop through all the players and draw additional infos to their sprites on the map - for (int i = 0; i < MAX_PLAYERS; i++) + for( int i = 0; i < MAX_PLAYERS; i++ ) { - - if ( m_vPlayerPos[i][2]<0 ) // marked as invisible ? + if( m_vPlayerPos[i][2] < 0 ) // marked as invisible ? continue; - + // check if name would be in inset window - if ( m_pip->value != INSET_OFF ) + if( m_pip->value != INSET_OFF ) { - if ( m_vPlayerPos[i][0] > XRES( m_OverviewData.insetWindowX ) && + if( m_vPlayerPos[i][0] > XRES( m_OverviewData.insetWindowX ) && m_vPlayerPos[i][1] > YRES( m_OverviewData.insetWindowY ) && m_vPlayerPos[i][0] < XRES( m_OverviewData.insetWindowX + m_OverviewData.insetWindowWidth ) && - m_vPlayerPos[i][1] < YRES( m_OverviewData.insetWindowY + m_OverviewData.insetWindowHeight) - ) continue; + m_vPlayerPos[i][1] < YRES( m_OverviewData.insetWindowY + m_OverviewData.insetWindowHeight) ) + continue; } - color = GetClientColor( i+1 ); + color = GetClientColor( i + 1 ); // draw the players name and health underneath - sprintf(string, "%s", g_PlayerInfoList[i+1].name ); - - lx = strlen(string)*3; // 3 is avg. character length :) + sprintf( string, "%s", g_PlayerInfoList[i + 1].name ); + + lx = strlen( string ) * 3; // 3 is avg. character length :) DrawSetTextColor( color[0], color[1], color[2] ); - DrawConsoleString( m_vPlayerPos[i][0]-lx,m_vPlayerPos[i][1], string); - + DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string ); } return 1; } - void CHudSpectator::DirectorMessage( int iSize, void *pbuf ) { - float value; - char * string; + float value; + char *string; BEGIN_READ( pbuf, iSize ); int cmd = READ_BYTE(); - - switch ( cmd ) // director command byte - { - case DRC_CMD_START : - // now we have to do some things clientside, since the proxy doesn't know our mod - g_iPlayerClass = 0; - g_iTeamNumber = 0; - // fake a InitHUD & ResetHUD message - gHUD.MsgFunc_InitHUD(NULL,0, NULL); - gHUD.MsgFunc_ResetHUD(NULL, 0, NULL); + switch( cmd ) // director command byte + { + case DRC_CMD_START: + // now we have to do some things clientside, since the proxy doesn't know our mod + g_iPlayerClass = 0; + g_iTeamNumber = 0; + + // fake a InitHUD & ResetHUD message + gHUD.MsgFunc_InitHUD( NULL, 0, NULL ); + gHUD.MsgFunc_ResetHUD( NULL, 0, NULL ); + break; + case DRC_CMD_EVENT: + m_lastPrimaryObject = READ_WORD(); + m_lastSecondaryObject = READ_WORD(); + m_iObserverFlags = READ_LONG(); - break; + if( m_autoDirector->value ) + { + if( ( g_iUser2 != m_lastPrimaryObject) || ( g_iUser3 != m_lastSecondaryObject ) ) + V_ResetChaseCam(); - case DRC_CMD_EVENT : - m_lastPrimaryObject = READ_WORD(); - m_lastSecondaryObject = READ_WORD(); - m_iObserverFlags = READ_LONG(); - - if ( m_autoDirector->value ) - { - if ( (g_iUser2 != m_lastPrimaryObject) || (g_iUser3 != m_lastSecondaryObject) ) - V_ResetChaseCam(); + g_iUser2 = m_lastPrimaryObject; + g_iUser3 = m_lastSecondaryObject; + } - g_iUser2 = m_lastPrimaryObject; - g_iUser3 = m_lastSecondaryObject; - } + // gEngfuncs.Con_Printf( "Director Camera: %i %i\n", firstObject, secondObject ); + break; + case DRC_CMD_MODE: + if( m_autoDirector->value ) + { + SetModes( READ_BYTE(), -1 ); + } + break; + case DRC_CMD_CAMERA: + if( m_autoDirector->value ) + { + vJumpOrigin[0] = READ_COORD(); // position + vJumpOrigin[1] = READ_COORD(); + vJumpOrigin[2] = READ_COORD(); - // gEngfuncs.Con_Printf("Director Camera: %i %i\n", firstObject, secondObject); - break; + vJumpAngles[0] = READ_COORD(); // view angle + vJumpAngles[1] = READ_COORD(); + vJumpAngles[2] = READ_COORD(); - case DRC_CMD_MODE : - if ( m_autoDirector->value ) - { - SetModes( READ_BYTE(), -1 ); - } - break; - - case DRC_CMD_CAMERA : - if ( m_autoDirector->value ) - { - vJumpOrigin[0] = READ_COORD(); // position - vJumpOrigin[1] = READ_COORD(); - vJumpOrigin[2] = READ_COORD(); - - vJumpAngles[0] = READ_COORD(); // view angle - vJumpAngles[1] = READ_COORD(); - vJumpAngles[2] = READ_COORD(); - - gEngfuncs.SetViewAngles( vJumpAngles ); - - iJumpSpectator = 1; - } - break; + gEngfuncs.SetViewAngles( vJumpAngles ); + iJumpSpectator = 1; + } + break; case DRC_CMD_MESSAGE: - { - client_textmessage_t * msg = &m_HUDMessages[m_lastHudMessage]; + { + client_textmessage_t * msg = &m_HUDMessages[m_lastHudMessage]; + + msg->effect = READ_BYTE(); // effect + + UnpackRGB( (int&)msg->r1, (int&)msg->g1, (int&)msg->b1, READ_LONG() ); // color + msg->r2 = msg->r1; + msg->g2 = msg->g1; + msg->b2 = msg->b1; + msg->a2 = msg->a1 = 0xFF; // not transparent + + msg->x = READ_FLOAT(); // x pos + msg->y = READ_FLOAT(); // y pos - msg->effect = READ_BYTE(); // effect + msg->fadein = READ_FLOAT(); // fadein + msg->fadeout = READ_FLOAT(); // fadeout + msg->holdtime = READ_FLOAT(); // holdtime + msg->fxtime = READ_FLOAT(); // fxtime; - UnpackRGB( (int&)msg->r1, (int&)msg->g1, (int&)msg->b1, READ_LONG() ); // color - msg->r2 = msg->r1; - msg->g2 = msg->g1; - msg->b2 = msg->b1; - msg->a2 = msg->a1 = 0xFF; // not transparent - - msg->x = READ_FLOAT(); // x pos - msg->y = READ_FLOAT(); // y pos - - msg->fadein = READ_FLOAT(); // fadein - msg->fadeout = READ_FLOAT(); // fadeout - msg->holdtime = READ_FLOAT(); // holdtime - msg->fxtime = READ_FLOAT(); // fxtime; + strncpy( m_HUDMessageText[m_lastHudMessage], READ_STRING(), 128 ); + m_HUDMessageText[m_lastHudMessage][127] = 0; // text - strncpy( m_HUDMessageText[m_lastHudMessage], READ_STRING(), 128 ); - m_HUDMessageText[m_lastHudMessage][127]=0; // text - - msg->pMessage = m_HUDMessageText[m_lastHudMessage]; - msg->pName = "HUD_MESSAGE"; - - gHUD.m_Message.MessageAdd( msg ); - - m_lastHudMessage++; - m_lastHudMessage %= MAX_SPEC_HUD_MESSAGES; - - } - - break; - - case DRC_CMD_SOUND : - string = READ_STRING(); - value = READ_FLOAT(); - - // gEngfuncs.Con_Printf("DRC_CMD_FX_SOUND: %s %.2f\n", string, value ); - gEngfuncs.pEventAPI->EV_PlaySound(0, v_origin, CHAN_BODY, string, value, ATTN_NORM, 0, PITCH_NORM ); - - break; - - case DRC_CMD_TIMESCALE : - value = READ_FLOAT(); - break; + msg->pMessage = m_HUDMessageText[m_lastHudMessage]; + msg->pName = "HUD_MESSAGE"; + gHUD.m_Message.MessageAdd( msg ); + m_lastHudMessage++; + m_lastHudMessage %= MAX_SPEC_HUD_MESSAGES; + } + break; + case DRC_CMD_SOUND: + string = READ_STRING(); + value = READ_FLOAT(); + // gEngfuncs.Con_Printf("DRC_CMD_FX_SOUND: %s %.2f\n", string, value ); + gEngfuncs.pEventAPI->EV_PlaySound( 0, v_origin, CHAN_BODY, string, value, ATTN_NORM, 0, PITCH_NORM ); + break; + case DRC_CMD_TIMESCALE: + value = READ_FLOAT(); + break; case DRC_CMD_STATUS: - READ_LONG(); // total number of spectator slots - m_iSpectatorNumber = READ_LONG(); // total number of spectator - READ_WORD(); // total number of relay proxies - - break; - + READ_LONG(); // total number of spectator slots + m_iSpectatorNumber = READ_LONG(); // total number of spectator + READ_WORD(); // total number of relay proxies + break; case DRC_CMD_BANNER: - // gEngfuncs.Con_DPrintf("GUI: Banner %s\n",READ_STRING() ); // name of banner tga eg gfx/temp/7454562234563475.tga - break; - - case DRC_CMD_FADE: - break; - + // gEngfuncs.Con_DPrintf( "GUI: Banner %s\n",READ_STRING() ); // name of banner tga eg gfx/temp/7454562234563475.tga + break; + case DRC_CMD_FADE: + break; case DRC_CMD_STUFFTEXT: - ClientCmd( READ_STRING() ); - break; - - default : gEngfuncs.Con_DPrintf("CHudSpectator::DirectorMessage: unknown command %i.\n", cmd ); + ClientCmd( READ_STRING() ); + break; + default: + gEngfuncs.Con_DPrintf( "CHudSpectator::DirectorMessage: unknown command %i.\n", cmd ); } } -void CHudSpectator::FindNextPlayer(bool bReverse) +void CHudSpectator::FindNextPlayer( bool bReverse ) { // MOD AUTHORS: Modify the logic of this function if you want to restrict the observer to watching // only a subset of the players. e.g. Make it check the target's team. @@ -587,23 +552,23 @@ void CHudSpectator::FindNextPlayer(bool bReverse) cl_entity_t * pEnt = NULL; // if we are NOT in HLTV mode, spectator targets are set on server - if ( !gEngfuncs.IsSpectateOnly() ) + if( !gEngfuncs.IsSpectateOnly() ) { char cmdstring[32]; // forward command to server - sprintf(cmdstring,"follownext %i",bReverse?1:0); - gEngfuncs.pfnServerCmd(cmdstring); + sprintf( cmdstring, "follownext %i", bReverse ? 1 : 0 ); + gEngfuncs.pfnServerCmd( cmdstring ); return; } - - if ( g_iUser2 ) + + if( g_iUser2 ) iStart = g_iUser2; else iStart = 1; g_iUser2 = 0; - int iCurrent = iStart; + int iCurrent = iStart; int iDir = bReverse ? -1 : 1; @@ -611,43 +576,39 @@ void CHudSpectator::FindNextPlayer(bool bReverse) //gViewPort->GetAllPlayersInfo(); gHUD.m_Scoreboard.GetAllPlayersInfo(); - - do { iCurrent += iDir; // Loop through the clients - if (iCurrent > MAX_PLAYERS) + if( iCurrent > MAX_PLAYERS ) iCurrent = 1; - if (iCurrent < 1) + if( iCurrent < 1 ) iCurrent = MAX_PLAYERS; pEnt = gEngfuncs.GetEntityByIndex( iCurrent ); - if ( !IsActivePlayer( pEnt ) ) + if( !IsActivePlayer( pEnt ) ) continue; // MOD AUTHORS: Add checks on target here. - g_iUser2 = iCurrent; break; - - } while ( iCurrent != iStart ); + } while( iCurrent != iStart ); // Did we find a target? - if ( !g_iUser2 ) + if( !g_iUser2 ) { gEngfuncs.Con_DPrintf( "No observer targets.\n" ); // take save camera position - VectorCopy(m_cameraOrigin, vJumpOrigin); - VectorCopy(m_cameraAngles, vJumpAngles); + VectorCopy( m_cameraOrigin, vJumpOrigin ); + VectorCopy( m_cameraAngles, vJumpAngles ); } else { // use new entity position for roaming - VectorCopy ( pEnt->origin, vJumpOrigin ); - VectorCopy ( pEnt->angles, vJumpAngles ); + VectorCopy( pEnt->origin, vJumpOrigin ); + VectorCopy( pEnt->angles, vJumpAngles ); } iJumpSpectator = 1; } @@ -656,93 +617,87 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed ) { double time = gEngfuncs.GetClientTime(); - int newMainMode = g_iUser1; - int newInsetMode = m_pip->value; + int newMainMode = g_iUser1; + int newInsetMode = m_pip->value; - // gEngfuncs.Con_Printf(" HandleButtons:%i\n", ButtonPressed ); + // gEngfuncs.Con_Printf( " HandleButtons:%i\n", ButtonPressed ); //Not in intermission. - if ( gHUD.m_iIntermission ) + if( gHUD.m_iIntermission ) return; - if ( !g_iUser1 ) + if( !g_iUser1 ) return; // dont do anything if not in spectator mode // don't handle buttons during normal demo playback - if ( gEngfuncs.pDemoAPI->IsPlayingback() && !gEngfuncs.IsSpectateOnly() ) + if( gEngfuncs.pDemoAPI->IsPlayingback() && !gEngfuncs.IsSpectateOnly() ) return; // Slow down mouse clicks. - if ( m_flNextObserverInput > time ) + if( m_flNextObserverInput > time ) return; // enable spectator screen - //if ( ButtonPressed & IN_DUCK ) - // gViewPort->m_pSpectatorPanel->ShowMenu(!gViewPort->m_pSpectatorPanel->m_menuVisible); + //if( ButtonPressed & IN_DUCK ) + // gViewPort->m_pSpectatorPanel->ShowMenu( !gViewPort->m_pSpectatorPanel->m_menuVisible ); // 'Use' changes inset window mode - if ( ButtonPressed & IN_USE ) + if( ButtonPressed & IN_USE ) { - newInsetMode = ToggleInset(true); + newInsetMode = ToggleInset( true ); } // if not in HLTV mode, buttons are handled server side - if ( gEngfuncs.IsSpectateOnly() ) + if( gEngfuncs.IsSpectateOnly() ) { // changing target or chase mode not in overviewmode without inset window // Jump changes main window modes - if ( ButtonPressed & IN_JUMP ) + if( ButtonPressed & IN_JUMP ) { - if ( g_iUser1 == OBS_CHASE_LOCKED ) + if( g_iUser1 == OBS_CHASE_LOCKED ) newMainMode = OBS_CHASE_FREE; - - else if ( g_iUser1 == OBS_CHASE_FREE ) + else if( g_iUser1 == OBS_CHASE_FREE ) newMainMode = OBS_IN_EYE; - - else if ( g_iUser1 == OBS_IN_EYE ) + else if( g_iUser1 == OBS_IN_EYE ) newMainMode = OBS_ROAMING; - - else if ( g_iUser1 == OBS_ROAMING ) + else if( g_iUser1 == OBS_ROAMING ) newMainMode = OBS_MAP_FREE; - - else if ( g_iUser1 == OBS_MAP_FREE ) + else if( g_iUser1 == OBS_MAP_FREE ) newMainMode = OBS_MAP_CHASE; - else newMainMode = OBS_CHASE_FREE; // don't use OBS_CHASE_LOCKED anymore } // Attack moves to the next player - if ( ButtonPressed & (IN_ATTACK | IN_ATTACK2) ) + if( ButtonPressed & ( IN_ATTACK | IN_ATTACK2 ) ) { - FindNextPlayer( (ButtonPressed & IN_ATTACK2) ? true:false ); + FindNextPlayer( ( ButtonPressed & IN_ATTACK2 ) ? true : false ); - if ( g_iUser1 == OBS_ROAMING ) + if( g_iUser1 == OBS_ROAMING ) { gEngfuncs.SetViewAngles( vJumpAngles ); iJumpSpectator = 1; - } // lease directed mode if player want to see another player m_autoDirector->value = 0.0f; } } - SetModes(newMainMode, newInsetMode); + SetModes( newMainMode, newInsetMode ); - if ( g_iUser1 == OBS_MAP_FREE ) + if( g_iUser1 == OBS_MAP_FREE ) { - if ( ButtonPressed & IN_FORWARD ) - m_zoomDelta = 0.01f; + if( ButtonPressed & IN_FORWARD ) + m_zoomDelta = 0.01f; - if ( ButtonPressed & IN_BACK ) + if( ButtonPressed & IN_BACK ) m_zoomDelta = -0.01f; - - if ( ButtonPressed & IN_MOVELEFT ) + + if( ButtonPressed & IN_MOVELEFT ) m_moveDelta = -12.0f; - if ( ButtonPressed & IN_MOVERIGHT ) - m_moveDelta = 12.0f; + if( ButtonPressed & IN_MOVERIGHT ) + m_moveDelta = 12.0f; } m_flNextObserverInput = time + 0.2; @@ -750,131 +705,129 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed ) void CHudSpectator::HandleButtonsUp( int ButtonPressed ) { - - if ( ButtonPressed & (IN_FORWARD | IN_BACK) ) + if( ButtonPressed & ( IN_FORWARD | IN_BACK ) ) m_zoomDelta = 0.0f; - - if ( ButtonPressed & (IN_MOVELEFT | IN_MOVERIGHT) ) + + if( ButtonPressed & ( IN_MOVELEFT | IN_MOVERIGHT ) ) m_moveDelta = 0.0f; } -void CHudSpectator::SetModes(int iNewMainMode, int iNewInsetMode) +void CHudSpectator::SetModes( int iNewMainMode, int iNewInsetMode ) { // if value == -1 keep old value - if ( iNewMainMode == -1 ) + if( iNewMainMode == -1 ) iNewMainMode = g_iUser1; - if ( iNewInsetMode == -1 ) + if( iNewInsetMode == -1 ) iNewInsetMode = m_pip->value; // inset mode is handled only clients side m_pip->value = iNewInsetMode; - - if ( iNewMainMode < OBS_CHASE_LOCKED || iNewMainMode > OBS_MAP_CHASE ) + + if( iNewMainMode < OBS_CHASE_LOCKED || iNewMainMode > OBS_MAP_CHASE ) { - gEngfuncs.Con_Printf("Invalid spectator mode.\n"); + gEngfuncs.Con_Printf( "Invalid spectator mode.\n" ); return; } - + // main modes ettings will override inset window settings - if ( iNewMainMode != g_iUser1 ) + if( iNewMainMode != g_iUser1 ) { // if we are NOT in HLTV mode, main spectator mode is set on server - if ( !gEngfuncs.IsSpectateOnly() ) + if( !gEngfuncs.IsSpectateOnly() ) { return; } - if ( !g_iUser2 && (iNewMainMode !=OBS_ROAMING ) ) // make sure we have a target + if( !g_iUser2 && ( iNewMainMode != OBS_ROAMING ) ) // make sure we have a target { // choose last Director object if still available - if ( IsActivePlayer( gEngfuncs.GetEntityByIndex( m_lastPrimaryObject ) ) ) + if( IsActivePlayer( gEngfuncs.GetEntityByIndex( m_lastPrimaryObject ) ) ) { g_iUser2 = m_lastPrimaryObject; g_iUser3 = m_lastSecondaryObject; } else - FindNextPlayer(false); // find any target + FindNextPlayer( false ); // find any target } - switch ( iNewMainMode ) + switch( iNewMainMode ) { - case OBS_CHASE_LOCKED: g_iUser1 = OBS_CHASE_LOCKED; - break; - - case OBS_CHASE_FREE : g_iUser1 = OBS_CHASE_FREE; - break; - - case OBS_ROAMING : // jump to current vJumpOrigin/angle - g_iUser1 = OBS_ROAMING; - if ( g_iUser2 ) - { - V_GetChasePos( g_iUser2, v_cl_angles, vJumpOrigin, vJumpAngles ); - gEngfuncs.SetViewAngles( vJumpAngles ); - iJumpSpectator = 1; - } - break; - - case OBS_IN_EYE : g_iUser1 = OBS_IN_EYE; - break; - - case OBS_MAP_FREE : g_iUser1 = OBS_MAP_FREE; - // reset user values - m_mapZoom = m_OverviewData.zoom; - m_mapOrigin = m_OverviewData.origin; - break; - - case OBS_MAP_CHASE : g_iUser1 = OBS_MAP_CHASE; - // reset user values - m_mapZoom = m_OverviewData.zoom; - m_mapOrigin = m_OverviewData.origin; - break; + case OBS_CHASE_LOCKED: + g_iUser1 = OBS_CHASE_LOCKED; + break; + case OBS_CHASE_FREE: + g_iUser1 = OBS_CHASE_FREE; + break; + case OBS_ROAMING: // jump to current vJumpOrigin/angle + g_iUser1 = OBS_ROAMING; + if( g_iUser2 ) + { + V_GetChasePos( g_iUser2, v_cl_angles, vJumpOrigin, vJumpAngles ); + gEngfuncs.SetViewAngles( vJumpAngles ); + iJumpSpectator = 1; + } + break; + case OBS_IN_EYE: + g_iUser1 = OBS_IN_EYE; + break; + case OBS_MAP_FREE: + g_iUser1 = OBS_MAP_FREE; + // reset user values + m_mapZoom = m_OverviewData.zoom; + m_mapOrigin = m_OverviewData.origin; + break; + case OBS_MAP_CHASE: + g_iUser1 = OBS_MAP_CHASE; + // reset user values + m_mapZoom = m_OverviewData.zoom; + m_mapOrigin = m_OverviewData.origin; + break; } - if ( (g_iUser1 == OBS_IN_EYE) || (g_iUser1 == OBS_ROAMING) ) + if( ( g_iUser1 == OBS_IN_EYE ) || ( g_iUser1 == OBS_ROAMING ) ) { - m_crosshairRect.left = 24; - m_crosshairRect.top = 0; - m_crosshairRect.right = 48; + m_crosshairRect.left = 24; + m_crosshairRect.top = 0; + m_crosshairRect.right = 48; m_crosshairRect.bottom = 24; - + SetCrosshair( m_hCrosshair, m_crosshairRect, 255, 255, 255 ); } else { - memset( &m_crosshairRect,0,sizeof(m_crosshairRect) ); + memset( &m_crosshairRect, 0, sizeof(m_crosshairRect) ); SetCrosshair( 0, m_crosshairRect, 0, 0, 0 ); - } + } char string[128]; - sprintf(string, "#Spec_Mode%d", g_iUser1 ); - sprintf(string, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( string )); - gHUD.m_TextMessage.MsgFunc_TextMsg(NULL, strlen(string)+1, string ); + sprintf( string, "#Spec_Mode%d", g_iUser1 ); + sprintf( string, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( string ) ); + gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( string ) + 1, string ); } } -bool CHudSpectator::IsActivePlayer(cl_entity_t * ent) +bool CHudSpectator::IsActivePlayer( cl_entity_t *ent ) { - return ( ent && - ent->player && + return ( ent && + ent->player && ent->curstate.solid != SOLID_NOT && ent != gEngfuncs.GetLocalPlayer() && g_PlayerInfoList[ent->index].name != NULL ); } - -bool CHudSpectator::ParseOverviewFile( ) +bool CHudSpectator::ParseOverviewFile() { char filename[255] = { 0 }; char levelname[255] = { 0 }; char token[1024] = { 0 }; float height; - + char *pfile = NULL; - memset( &m_OverviewData, 0, sizeof(m_OverviewData)); + memset( &m_OverviewData, 0, sizeof(m_OverviewData) ); // fill in standrd values m_OverviewData.insetWindowX = 4; // upper left corner @@ -884,137 +837,129 @@ bool CHudSpectator::ParseOverviewFile( ) m_OverviewData.origin[0] = 0.0f; m_OverviewData.origin[1] = 0.0f; m_OverviewData.origin[2] = 0.0f; - m_OverviewData.zoom = 1.0f; + m_OverviewData.zoom = 1.0f; m_OverviewData.layers = 0; m_OverviewData.layersHeights[0] = 0.0f; strcpy( m_OverviewData.map, gEngfuncs.pfnGetLevelName() ); - if ( strlen( m_OverviewData.map ) == 0 ) + if( strlen( m_OverviewData.map ) == 0 ) return false; // not active yet - strcpy(levelname, m_OverviewData.map + 5); - levelname[strlen(levelname)-4] = 0; - - sprintf(filename, "overviews/%s.txt", levelname ); + strcpy( levelname, m_OverviewData.map + 5 ); + levelname[strlen( levelname ) - 4] = 0; - pfile = (char *)gEngfuncs.COM_LoadFile( filename, 5, NULL); + sprintf( filename, "overviews/%s.txt", levelname ); - if (!pfile) + pfile = (char *)gEngfuncs.COM_LoadFile( filename, 5, NULL ); + + if( !pfile ) { - gEngfuncs.Con_DPrintf("Couldn't open file %s. Using default values for overiew mode.\n", filename ); + gEngfuncs.Con_DPrintf( "Couldn't open file %s. Using default values for overiew mode.\n", filename ); return false; } - - - while (true) - { - pfile = gEngfuncs.COM_ParseFile(pfile, token); - if (!pfile) + while( true ) + { + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + + if( !pfile ) break; - if ( !stricmp( token, "global" ) ) + if( !stricmp( token, "global" ) ) { // parse the global data - pfile = gEngfuncs.COM_ParseFile(pfile, token); - if ( stricmp( token, "{" ) ) + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + if( stricmp( token, "{" ) ) { - gEngfuncs.Con_Printf("Error parsing overview file %s. (expected { )\n", filename ); + gEngfuncs.Con_Printf( "Error parsing overview file %s. (expected { )\n", filename ); return false; } - pfile = gEngfuncs.COM_ParseFile(pfile,token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); - while (stricmp( token, "}") ) + while( stricmp( token, "}") ) { - if ( !stricmp( token, "zoom" ) ) + if( !stricmp( token, "zoom" ) ) { - pfile = gEngfuncs.COM_ParseFile(pfile,token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); m_OverviewData.zoom = atof( token ); } - else if ( !stricmp( token, "origin" ) ) + else if( !stricmp( token, "origin" ) ) { - pfile = gEngfuncs.COM_ParseFile(pfile, token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); m_OverviewData.origin[0] = atof( token ); - pfile = gEngfuncs.COM_ParseFile(pfile,token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); m_OverviewData.origin[1] = atof( token ); - pfile = gEngfuncs.COM_ParseFile(pfile, token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); m_OverviewData.origin[2] = atof( token ); } - else if ( !stricmp( token, "rotated" ) ) + else if( !stricmp( token, "rotated" ) ) { - pfile = gEngfuncs.COM_ParseFile(pfile,token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); m_OverviewData.rotated = atoi( token ); } - else if ( !stricmp( token, "inset" ) ) + else if( !stricmp( token, "inset" ) ) { - pfile = gEngfuncs.COM_ParseFile(pfile,token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); m_OverviewData.insetWindowX = atof( token ); - pfile = gEngfuncs.COM_ParseFile(pfile,token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); m_OverviewData.insetWindowY = atof( token ); - pfile = gEngfuncs.COM_ParseFile(pfile,token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); m_OverviewData.insetWindowWidth = atof( token ); - pfile = gEngfuncs.COM_ParseFile(pfile,token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); m_OverviewData.insetWindowHeight = atof( token ); - } else { - gEngfuncs.Con_Printf("Error parsing overview file %s. (%s unkown)\n", filename, token ); + gEngfuncs.Con_Printf( "Error parsing overview file %s. (%s unkown)\n", filename, token ); return false; } - pfile = gEngfuncs.COM_ParseFile(pfile,token); // parse next token - + pfile = gEngfuncs.COM_ParseFile( pfile, token ); // parse next token } } - else if ( !stricmp( token, "layer" ) ) + else if( !stricmp( token, "layer" ) ) { // parse a layer data - - if ( m_OverviewData.layers == OVERVIEW_MAX_LAYERS ) + if( m_OverviewData.layers == OVERVIEW_MAX_LAYERS ) { - gEngfuncs.Con_Printf("Error parsing overview file %s. ( too many layers )\n", filename ); + gEngfuncs.Con_Printf( "Error parsing overview file %s. ( too many layers )\n", filename ); return false; } - pfile = gEngfuncs.COM_ParseFile(pfile,token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); - - if ( stricmp( token, "{" ) ) + if( stricmp( token, "{" ) ) { - gEngfuncs.Con_Printf("Error parsing overview file %s. (expected { )\n", filename ); + gEngfuncs.Con_Printf( "Error parsing overview file %s. (expected { )\n", filename ); return false; } - pfile = gEngfuncs.COM_ParseFile(pfile,token); + pfile = gEngfuncs.COM_ParseFile( pfile, token ); - while (stricmp( token, "}") ) + while( stricmp( token, "}") ) { - if ( !stricmp( token, "image" ) ) + if( !stricmp( token, "image" ) ) { - pfile = gEngfuncs.COM_ParseFile(pfile,token); - strcpy(m_OverviewData.layersImages[ m_OverviewData.layers ], token); - - + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + strcpy( m_OverviewData.layersImages[m_OverviewData.layers], token ); } else if ( !stricmp( token, "height" ) ) { - pfile = gEngfuncs.COM_ParseFile(pfile,token); - height = atof(token); - m_OverviewData.layersHeights[ m_OverviewData.layers ] = height; + pfile = gEngfuncs.COM_ParseFile( pfile, token ); + height = atof( token ); + m_OverviewData.layersHeights[m_OverviewData.layers] = height; } else { - gEngfuncs.Con_Printf("Error parsing overview file %s. (%s unkown)\n", filename, token ); + gEngfuncs.Con_Printf( "Error parsing overview file %s. (%s unkown)\n", filename, token ); return false; } - pfile = gEngfuncs.COM_ParseFile(pfile,token); // parse next token + pfile = gEngfuncs.COM_ParseFile( pfile, token ); // parse next token } m_OverviewData.layers++; - } } @@ -1024,13 +969,12 @@ bool CHudSpectator::ParseOverviewFile( ) m_mapOrigin = m_OverviewData.origin; return true; - } void CHudSpectator::LoadMapSprites() { // right now only support for one map layer - if (m_OverviewData.layers > 0 ) + if( m_OverviewData.layers > 0 ) { m_MapSprite = gEngfuncs.LoadMapSprite( m_OverviewData.layersImages[0] ); } @@ -1040,8 +984,8 @@ void CHudSpectator::LoadMapSprites() void CHudSpectator::DrawOverviewLayer() { - float screenaspect, xs, ys, xStep, yStep, x,y,z; - int ix,iy,i,xTiles,yTiles,frame; + float screenaspect, xs, ys, xStep, yStep, x, y, z; + int ix, iy, i, xTiles, yTiles, frame; qboolean hasMapImage = m_MapSprite?TRUE:FALSE; model_t * dummySprite = (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprUnkownMap); @@ -1059,261 +1003,250 @@ void CHudSpectator::DrawOverviewLayer() yTiles = 6; } - - screenaspect = 4.0f/3.0f; - + screenaspect = 4.0f / 3.0f; xs = m_OverviewData.origin[0]; ys = m_OverviewData.origin[1]; z = ( 90.0f - v_angles[0] ) / 90.0f; z *= m_OverviewData.layersHeights[0]; // gOverviewData.z_min - 32; - // i = r_overviewTexture + ( layer*OVERVIEW_X_TILES*OVERVIEW_Y_TILES ); + // i = r_overviewTexture + ( layer * OVERVIEW_X_TILES * OVERVIEW_Y_TILES ); gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture ); gEngfuncs.pTriAPI->CullFace( TRI_NONE ); gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 ); frame = 0; - // rotated view ? - if ( m_OverviewData.rotated ) + if( m_OverviewData.rotated ) { - xStep = (2*4096.0f / m_OverviewData.zoom ) / xTiles; - yStep = -(2*4096.0f / (m_OverviewData.zoom* screenaspect) ) / yTiles; + xStep = ( 2 * 4096.0f / m_OverviewData.zoom ) / xTiles; + yStep = -( 2 * 4096.0f / ( m_OverviewData.zoom* screenaspect ) ) / yTiles; - y = ys + (4096.0f / (m_OverviewData.zoom * screenaspect)); + y = ys + ( 4096.0f / ( m_OverviewData.zoom * screenaspect ) ); - for (iy = 0; iy < yTiles; iy++) + for( iy = 0; iy < yTiles; iy++ ) { - x = xs - (4096.0f / (m_OverviewData.zoom)); + x = xs - ( 4096.0f / (m_OverviewData.zoom ) ); - for (ix = 0; ix < xTiles; ix++) + for( ix = 0; ix < xTiles; ix++ ) { - if (hasMapImage) + if( hasMapImage ) gEngfuncs.pTriAPI->SpriteTexture( m_MapSprite, frame ); else gEngfuncs.pTriAPI->SpriteTexture( dummySprite, 0 ); gEngfuncs.pTriAPI->Begin( TRI_QUADS ); gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); - gEngfuncs.pTriAPI->Vertex3f (x, y, z); + gEngfuncs.pTriAPI->Vertex3f( x, y, z ); gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); - gEngfuncs.pTriAPI->Vertex3f (x+xStep ,y, z); + gEngfuncs.pTriAPI->Vertex3f( x + xStep, y, z); gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); - gEngfuncs.pTriAPI->Vertex3f (x+xStep, y+yStep, z); + gEngfuncs.pTriAPI->Vertex3f( x + xStep, y + yStep, z ); gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); - gEngfuncs.pTriAPI->Vertex3f (x, y+yStep, z); + gEngfuncs.pTriAPI->Vertex3f( x, y + yStep, z); gEngfuncs.pTriAPI->End(); frame++; - x+= xStep; + x += xStep; } - y+=yStep; + y += yStep; } } else { - xStep = -(2*4096.0f / m_OverviewData.zoom ) / xTiles; - yStep = -(2*4096.0f / (m_OverviewData.zoom* screenaspect) ) / yTiles; + xStep = -( 2 * 4096.0f / m_OverviewData.zoom ) / xTiles; + yStep = -( 2 * 4096.0f / ( m_OverviewData.zoom* screenaspect ) ) / yTiles; - - x = xs + (4096.0f / (m_OverviewData.zoom * screenaspect )); + x = xs + ( 4096.0f / ( m_OverviewData.zoom * screenaspect ) ); - - - for (ix = 0; ix < yTiles; ix++) + for( ix = 0; ix < yTiles; ix++ ) { - - y = ys + (4096.0f / (m_OverviewData.zoom)); - - for (iy = 0; iy < xTiles; iy++) + y = ys + ( 4096.0f / ( m_OverviewData.zoom ) ); + + for( iy = 0; iy < xTiles; iy++ ) { - if (hasMapImage) + if( hasMapImage ) gEngfuncs.pTriAPI->SpriteTexture( m_MapSprite, frame ); else gEngfuncs.pTriAPI->SpriteTexture( dummySprite, 0 ); gEngfuncs.pTriAPI->Begin( TRI_QUADS ); gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); - gEngfuncs.pTriAPI->Vertex3f (x, y, z); + gEngfuncs.pTriAPI->Vertex3f( x, y, z ); gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); - gEngfuncs.pTriAPI->Vertex3f (x+xStep ,y, z); + gEngfuncs.pTriAPI->Vertex3f( x + xStep, y, z); gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); - gEngfuncs.pTriAPI->Vertex3f (x+xStep, y+yStep, z); + gEngfuncs.pTriAPI->Vertex3f( x + xStep, y + yStep, z ); gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); - gEngfuncs.pTriAPI->Vertex3f (x, y+yStep, z); + gEngfuncs.pTriAPI->Vertex3f( x, y + yStep, z ); gEngfuncs.pTriAPI->End(); frame++; - - y+=yStep; + + y += yStep; } - x+= xStep; - + x += xStep; } } } void CHudSpectator::DrawOverviewEntities() { - int i,ir,ig,ib; + int i, ir, ig, ib; struct model_s *hSpriteModel; vec3_t origin, angles, point, forward, right, left, up, world, screen, offset; - float x,y,z, r,g,b, sizeScale = 4.0f; + float x, y, z, r, g, b, sizeScale = 4.0f; cl_entity_t * ent; float rmatrix[3][4]; // transformation matrix - - float zScale = (90.0f - v_angles[0] ) / 90.0f; - + + float zScale = ( 90.0f - v_angles[0] ) / 90.0f; z = m_OverviewData.layersHeights[0] * zScale; // get yellow/brown HUD color - UnpackRGB(ir,ig,ib, RGB_YELLOWISH); - r = (float)ir/255.0f; - g = (float)ig/255.0f; - b = (float)ib/255.0f; - + UnpackRGB( ir, ig, ib, RGB_YELLOWISH ); + r = (float)ir / 255.0f; + g = (float)ig / 255.0f; + b = (float)ib / 255.0f; + gEngfuncs.pTriAPI->CullFace( TRI_NONE ); - for (i=0; i < MAX_PLAYERS; i++ ) + for( i = 0; i < MAX_PLAYERS; i++ ) m_vPlayerPos[i][2] = -1; // mark as invisible // draw all players - for (i=0 ; i < MAX_OVERVIEW_ENTITIES ; i++) + for( i = 0; i < MAX_OVERVIEW_ENTITIES; i++ ) { - if ( !m_OverviewEntities[i].hSprite ) + if( !m_OverviewEntities[i].hSprite ) continue; hSpriteModel = (struct model_s *)gEngfuncs.GetSpritePointer( m_OverviewEntities[i].hSprite ); ent = m_OverviewEntities[i].entity; - + gEngfuncs.pTriAPI->SpriteTexture( hSpriteModel, 0 ); gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture ); // see R_DrawSpriteModel // draws players sprite + AngleVectors( ent->angles, right, up, NULL ); - AngleVectors(ent->angles, right, up, NULL ); - - VectorCopy(ent->origin,origin); + VectorCopy( ent->origin,origin ); gEngfuncs.pTriAPI->Begin( TRI_QUADS ); gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 ); - - gEngfuncs.pTriAPI->TexCoord2f (1, 0); - VectorMA (origin, 16.0f * sizeScale, up, point); - VectorMA (point, 16.0f * sizeScale, right, point); + + gEngfuncs.pTriAPI->TexCoord2f(1, 0); + VectorMA( origin, 16.0f * sizeScale, up, point ); + VectorMA( point, 16.0f * sizeScale, right, point ); point[2] *= zScale; - gEngfuncs.pTriAPI->Vertex3fv (point); + gEngfuncs.pTriAPI->Vertex3fv( point ); - gEngfuncs.pTriAPI->TexCoord2f (0, 0); - - VectorMA (origin, 16.0f * sizeScale, up, point); - VectorMA (point, -16.0f * sizeScale, right, point); + gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); + + VectorMA( origin, 16.0f * sizeScale, up, point ); + VectorMA( point, -16.0f * sizeScale, right, point ); point[2] *= zScale; - gEngfuncs.pTriAPI->Vertex3fv (point); + gEngfuncs.pTriAPI->Vertex3fv( point ); - gEngfuncs.pTriAPI->TexCoord2f (0,1); - VectorMA (origin, -16.0f * sizeScale, up, point); - VectorMA (point, -16.0f * sizeScale, right, point); + gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); + VectorMA( origin, -16.0f * sizeScale, up, point ); + VectorMA( point, -16.0f * sizeScale, right, point ); point[2] *= zScale; - gEngfuncs.pTriAPI->Vertex3fv (point); + gEngfuncs.pTriAPI->Vertex3fv( point ); - gEngfuncs.pTriAPI->TexCoord2f (1,1); - VectorMA (origin, -16.0f * sizeScale, up, point); - VectorMA (point, 16.0f * sizeScale, right, point); + gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); + VectorMA( origin, -16.0f * sizeScale, up, point ); + VectorMA( point, 16.0f * sizeScale, right, point ); point[2] *= zScale; - gEngfuncs.pTriAPI->Vertex3fv (point); + gEngfuncs.pTriAPI->Vertex3fv( point ); - gEngfuncs.pTriAPI->End (); + gEngfuncs.pTriAPI->End(); - - if ( !ent->player) + if( !ent->player ) continue; + // draw line under player icons origin[2] *= zScale; gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); - + hSpriteModel = (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprBeam ); gEngfuncs.pTriAPI->SpriteTexture( hSpriteModel, 0 ); - - gEngfuncs.pTriAPI->Color4f(r, g, b, 0.3); - gEngfuncs.pTriAPI->Begin ( TRI_QUADS ); - gEngfuncs.pTriAPI->TexCoord2f (1, 0); - gEngfuncs.pTriAPI->Vertex3f (origin[0]+4, origin[1]+4, origin[2]-zScale); - gEngfuncs.pTriAPI->TexCoord2f (0, 0); - gEngfuncs.pTriAPI->Vertex3f (origin[0]-4, origin[1]-4, origin[2]-zScale); - gEngfuncs.pTriAPI->TexCoord2f (0, 1); - gEngfuncs.pTriAPI->Vertex3f (origin[0]-4, origin[1]-4,z); - gEngfuncs.pTriAPI->TexCoord2f (1, 1); - gEngfuncs.pTriAPI->Vertex3f (origin[0]+4, origin[1]+4,z); - gEngfuncs.pTriAPI->End (); + gEngfuncs.pTriAPI->Color4f( r, g, b, 0.3 ); - gEngfuncs.pTriAPI->Begin ( TRI_QUADS ); - gEngfuncs.pTriAPI->TexCoord2f (1, 0); - gEngfuncs.pTriAPI->Vertex3f (origin[0]-4, origin[1]+4, origin[2]-zScale); - gEngfuncs.pTriAPI->TexCoord2f (0, 0); - gEngfuncs.pTriAPI->Vertex3f (origin[0]+4, origin[1]-4, origin[2]-zScale); - gEngfuncs.pTriAPI->TexCoord2f (0, 1); - gEngfuncs.pTriAPI->Vertex3f (origin[0]+4, origin[1]-4,z); - gEngfuncs.pTriAPI->TexCoord2f (1, 1); - gEngfuncs.pTriAPI->Vertex3f (origin[0]-4, origin[1]+4,z); - gEngfuncs.pTriAPI->End (); + gEngfuncs.pTriAPI->Begin( TRI_QUADS ); + gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] + 4, origin[2] - zScale ); + gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] - 4, origin[2] - zScale ); + gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] - 4, z ); + gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] + 4, z ); + gEngfuncs.pTriAPI->End(); + + gEngfuncs.pTriAPI->Begin( TRI_QUADS ); + gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] + 4, origin[2] - zScale ); + gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] - 4, origin[2] - zScale ); + gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] - 4, z ); + gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); + gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] + 4, z ); + gEngfuncs.pTriAPI->End(); // calculate screen position for name and infromation in hud::draw() - if ( gEngfuncs.pTriAPI->WorldToScreen(origin,screen) ) + if( gEngfuncs.pTriAPI->WorldToScreen( origin, screen ) ) continue; // object is behind viewer - screen[0] = XPROJECT(screen[0]); - screen[1] = YPROJECT(screen[1]); + screen[0] = XPROJECT( screen[0] ); + screen[1] = YPROJECT( screen[1] ); screen[2] = 0.0f; // calculate some offset under the icon - origin[0]+=32.0f; - origin[1]+=32.0f; - - gEngfuncs.pTriAPI->WorldToScreen(origin,offset); + origin[0] += 32.0f; + origin[1] += 32.0f; - offset[0] = XPROJECT(offset[0]); - offset[1] = YPROJECT(offset[1]); + gEngfuncs.pTriAPI->WorldToScreen( origin, offset ); + + offset[0] = XPROJECT( offset[0] ); + offset[1] = YPROJECT( offset[1] ); offset[2] = 0.0f; - - VectorSubtract(offset, screen, offset ); + + VectorSubtract( offset, screen, offset ); int playerNum = ent->index - 1; m_vPlayerPos[playerNum][0] = screen[0]; - m_vPlayerPos[playerNum][1] = screen[1] + Length(offset); + m_vPlayerPos[playerNum][1] = screen[1] + Length( offset ); m_vPlayerPos[playerNum][2] = 1; // mark player as visible } - if ( !m_pip->value || !m_drawcone->value ) + if( !m_pip->value || !m_drawcone->value ) return; // get current camera position and angle - - if ( m_pip->value == INSET_IN_EYE || g_iUser1 == OBS_IN_EYE ) - { + if( m_pip->value == INSET_IN_EYE || g_iUser1 == OBS_IN_EYE ) + { V_GetInEyePos( g_iUser2, origin, angles ); } - else if ( m_pip->value == INSET_CHASE_FREE || g_iUser1 == OBS_CHASE_FREE ) + else if( m_pip->value == INSET_CHASE_FREE || g_iUser1 == OBS_CHASE_FREE ) { V_GetChasePos( g_iUser2, v_cl_angles, origin, angles ); } - else if ( g_iUser1 == OBS_ROAMING ) + else if( g_iUser1 == OBS_ROAMING ) { VectorCopy( v_sim_org, origin ); VectorCopy( v_cl_angles, angles ); @@ -1321,9 +1254,7 @@ void CHudSpectator::DrawOverviewEntities() else V_GetChasePos( g_iUser2, NULL, origin, angles ); - // draw camera sprite - x = origin[0]; y = origin[1]; z = origin[2]; @@ -1333,39 +1264,35 @@ void CHudSpectator::DrawOverviewEntities() hSpriteModel = (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprCamera ); gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); gEngfuncs.pTriAPI->SpriteTexture( hSpriteModel, 0 ); - - + gEngfuncs.pTriAPI->Color4f( r, g, b, 1.0 ); - AngleVectors(angles, forward, NULL, NULL ); - VectorScale (forward, 512.0f, forward); - - offset[0] = 0.0f; - offset[1] = 45.0f; - offset[2] = 0.0f; + AngleVectors( angles, forward, NULL, NULL ); + VectorScale( forward, 512.0f, forward ); - AngleMatrix(offset, rmatrix ); - VectorTransform(forward, rmatrix , right ); + offset[0] = 0.0f; + offset[1] = 45.0f; + offset[2] = 0.0f; + + AngleMatrix( offset, rmatrix ); + VectorTransform( forward, rmatrix, right ); offset[1]= -45.0f; - AngleMatrix(offset, rmatrix ); - VectorTransform(forward, rmatrix , left ); + AngleMatrix( offset, rmatrix ); + VectorTransform( forward, rmatrix , left ); - gEngfuncs.pTriAPI->Begin (TRI_TRIANGLES); + gEngfuncs.pTriAPI->Begin( TRI_TRIANGLES ); gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); - gEngfuncs.pTriAPI->Vertex3f (x+right[0], y+right[1], (z+right[2]) * zScale); + gEngfuncs.pTriAPI->Vertex3f( x + right[0], y + right[1], ( z + right[2] ) * zScale); gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); - gEngfuncs.pTriAPI->Vertex3f (x, y, z * zScale); - + gEngfuncs.pTriAPI->Vertex3f( x, y, z * zScale ); + gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); - gEngfuncs.pTriAPI->Vertex3f (x+left[0], y+left[1], (z+left[2]) * zScale); + gEngfuncs.pTriAPI->Vertex3f( x + left[0], y + left[1], ( z + left[2] ) * zScale ); gEngfuncs.pTriAPI->End (); - } - - void CHudSpectator::DrawOverview() { // draw only in sepctator mode @@ -1373,7 +1300,7 @@ void CHudSpectator::DrawOverview() return; // Only draw the overview if Map Mode is selected for this view - if ( m_iDrawCycle == 0 && ( (g_iUser1 != OBS_MAP_FREE) && (g_iUser1 != OBS_MAP_CHASE) ) ) + if( m_iDrawCycle == 0 && ( ( g_iUser1 != OBS_MAP_FREE ) && ( g_iUser1 != OBS_MAP_CHASE ) ) ) return; if ( m_iDrawCycle == 1 && m_pip->value < INSET_MAP_FREE ) @@ -1383,17 +1310,18 @@ void CHudSpectator::DrawOverview() DrawOverviewEntities(); CheckOverviewEntities(); } + void CHudSpectator::CheckOverviewEntities() { double time = gEngfuncs.GetClientTime(); // removes old entities from list - for ( int i = 0; i< MAX_OVERVIEW_ENTITIES; i++ ) + for( int i = 0; i < MAX_OVERVIEW_ENTITIES; i++ ) { // remove entity from list if it is too old - if ( m_OverviewEntities[i].killTime < time ) + if( m_OverviewEntities[i].killTime < time ) { - memset( &m_OverviewEntities[i], 0, sizeof (overviewEntity_t) ); + memset( &m_OverviewEntities[i], 0, sizeof(overviewEntity_t) ); } } } @@ -1403,49 +1331,55 @@ bool CHudSpectator::AddOverviewEntity( int type, struct cl_entity_s *ent, const HSPRITE hSprite = 0; double duration = -1.0f; // duration -1 means show it only this frame; - if ( !ent ) + if( !ent ) return false; - if ( type == ET_PLAYER ) + if( type == ET_PLAYER ) { - if ( ent->curstate.solid != SOLID_NOT) + if( ent->curstate.solid != SOLID_NOT) { switch ( g_PlayerExtraInfo[ent->index].teamnumber ) { // blue and red teams are swapped in CS and TFC - case 1 : hSprite = m_hsprPlayerBlue; break; - case 2 : hSprite = m_hsprPlayerRed; break; - default : hSprite = m_hsprPlayer; break; + case 1: + hSprite = m_hsprPlayerBlue; + break; + case 2: + hSprite = m_hsprPlayerRed; + break; + default: + hSprite = m_hsprPlayer; + break; } } else return false; // it's an spectator } - else if (type == ET_NORMAL) + else if( type == ET_NORMAL ) { return false; } else - return false; + return false; - return AddOverviewEntityToList(hSprite, ent, gEngfuncs.GetClientTime() + duration ); + return AddOverviewEntityToList( hSprite, ent, gEngfuncs.GetClientTime() + duration ); } -void CHudSpectator::DeathMessage(int victim) +void CHudSpectator::DeathMessage( int victim ) { // find out where the victim is - cl_entity_t *pl = gEngfuncs.GetEntityByIndex(victim); + cl_entity_t *pl = gEngfuncs.GetEntityByIndex( victim ); - if (pl && pl->player) + if( pl && pl->player ) AddOverviewEntityToList(m_hsprPlayerDead, pl, gEngfuncs.GetClientTime() + 2.0f ); } bool CHudSpectator::AddOverviewEntityToList(HSPRITE sprite, cl_entity_t *ent, double killTime) { - for ( int i = 0; i< MAX_OVERVIEW_ENTITIES; i++ ) + for( int i = 0; i < MAX_OVERVIEW_ENTITIES; i++ ) { // find empty entity slot - if ( m_OverviewEntities[i].entity == NULL) + if( m_OverviewEntities[i].entity == NULL) { m_OverviewEntities[i].entity = ent; m_OverviewEntities[i].hSprite = sprite; @@ -1456,93 +1390,91 @@ bool CHudSpectator::AddOverviewEntityToList(HSPRITE sprite, cl_entity_t *ent, do return false; // maximum overview entities reached } + void CHudSpectator::CheckSettings() { // disallow same inset mode as main mode: - m_pip->value = (int)m_pip->value; - if ( ( g_iUser1 < OBS_MAP_FREE ) && ( m_pip->value == INSET_CHASE_FREE || m_pip->value == INSET_IN_EYE ) ) + if( ( g_iUser1 < OBS_MAP_FREE ) && ( m_pip->value == INSET_CHASE_FREE || m_pip->value == INSET_IN_EYE ) ) { // otherwise both would show in World picures m_pip->value = INSET_MAP_FREE; } - if ( ( g_iUser1 >= OBS_MAP_FREE ) && ( m_pip->value >= INSET_MAP_FREE ) ) + if( ( g_iUser1 >= OBS_MAP_FREE ) && ( m_pip->value >= INSET_MAP_FREE ) ) { // both would show map views m_pip->value = INSET_CHASE_FREE; } // disble in intermission screen - if ( gHUD.m_iIntermission ) + if( gHUD.m_iIntermission ) m_pip->value = INSET_OFF; // check chat mode - if ( m_chatEnabled != (gHUD.m_SayText.m_HUD_saytext->value!=0) ) + if( m_chatEnabled != (gHUD.m_SayText.m_HUD_saytext->value != 0) ) { // hud_saytext changed - m_chatEnabled = (gHUD.m_SayText.m_HUD_saytext->value!=0); + m_chatEnabled = ( gHUD.m_SayText.m_HUD_saytext->value != 0 ); - if ( gEngfuncs.IsSpectateOnly() ) + if( gEngfuncs.IsSpectateOnly() ) { // tell proxy our new chat mode char chatcmd[32]; - sprintf(chatcmd, "ignoremsg %i", m_chatEnabled?0:1 ); - gEngfuncs.pfnServerCmd(chatcmd); + sprintf( chatcmd, "ignoremsg %i", m_chatEnabled ? 0 : 1 ); + gEngfuncs.pfnServerCmd( chatcmd ); } } // HL/TFC has no oberserver corsshair, so set it client side - if ( (g_iUser1 == OBS_IN_EYE) || (g_iUser1 == OBS_ROAMING) ) + if( ( g_iUser1 == OBS_IN_EYE ) || ( g_iUser1 == OBS_ROAMING ) ) { - m_crosshairRect.left = 24; - m_crosshairRect.top = 0; - m_crosshairRect.right = 48; + m_crosshairRect.left = 24; + m_crosshairRect.top = 0; + m_crosshairRect.right = 48; m_crosshairRect.bottom = 24; SetCrosshair( m_hCrosshair, m_crosshairRect, 255, 255, 255 ); } else { - memset( &m_crosshairRect,0,sizeof(m_crosshairRect) ); + memset( &m_crosshairRect, 0, sizeof(m_crosshairRect) ); SetCrosshair( 0, m_crosshairRect, 0, 0, 0 ); - } - - + } // if we are a real player on server don't allow inset window // in First Person mode since this is our resticted forcecamera mode 2 // team number 3 = SPECTATOR see player.h - if ( ( (g_iTeamNumber == 1) || (g_iTeamNumber == 2)) && (g_iUser1 == OBS_IN_EYE) ) + if( ( ( g_iTeamNumber == 1 ) || ( g_iTeamNumber == 2 ) ) && ( g_iUser1 == OBS_IN_EYE ) ) m_pip->value = INSET_OFF; // draw small border around inset view, adjust upper black bar } -int CHudSpectator::ToggleInset(bool allowOff) +int CHudSpectator::ToggleInset( bool allowOff ) { int newInsetMode = (int)m_pip->value + 1; - if ( g_iUser1 < OBS_MAP_FREE ) + if( g_iUser1 < OBS_MAP_FREE ) { - if ( newInsetMode > INSET_MAP_CHASE ) + if( newInsetMode > INSET_MAP_CHASE ) { - if (allowOff) + if( allowOff ) newInsetMode = INSET_OFF; else newInsetMode = INSET_MAP_FREE; } - if ( newInsetMode == INSET_CHASE_FREE ) + if( newInsetMode == INSET_CHASE_FREE ) newInsetMode = INSET_MAP_FREE; } else { - if ( newInsetMode > INSET_IN_EYE ) + if( newInsetMode > INSET_IN_EYE ) { - if (allowOff) + if( allowOff ) newInsetMode = INSET_OFF; else newInsetMode = INSET_CHASE_FREE; @@ -1551,17 +1483,18 @@ int CHudSpectator::ToggleInset(bool allowOff) return newInsetMode; } + void CHudSpectator::Reset() { // Reset HUD - if ( strcmp( m_OverviewData.map, gEngfuncs.pfnGetLevelName() ) ) + if( strcmp( m_OverviewData.map, gEngfuncs.pfnGetLevelName() ) ) { // update level overview if level changed ParseOverviewFile(); LoadMapSprites(); } - memset( &m_OverviewEntities, 0, sizeof(m_OverviewEntities)); + memset( &m_OverviewEntities, 0, sizeof(m_OverviewEntities) ); SetSpectatorStartPosition(); } @@ -1572,13 +1505,13 @@ void CHudSpectator::InitHUDData() m_flNextObserverInput = 0.0f; m_lastHudMessage = 0; m_iSpectatorNumber = 0; - iJumpSpectator = 0; + iJumpSpectator = 0; g_iUser1 = g_iUser2 = 0; memset( &m_OverviewData, 0, sizeof(m_OverviewData)); memset( &m_OverviewEntities, 0, sizeof(m_OverviewEntities)); - if ( gEngfuncs.IsSpectateOnly() || gEngfuncs.pDemoAPI->IsPlayingback() ) + if( gEngfuncs.IsSpectateOnly() || gEngfuncs.pDemoAPI->IsPlayingback() ) m_autoDirector->value = 1.0f; else m_autoDirector->value = 0.0f; @@ -1590,6 +1523,5 @@ void CHudSpectator::InitHUDData() g_iUser2 = 0; // fake not target until first camera command // reset HUD FOV - gHUD.m_iFOV = CVAR_GET_FLOAT("default_fov"); + gHUD.m_iFOV = CVAR_GET_FLOAT( "default_fov" ); } - diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 11c7c34c..f60353db 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -11,17 +11,13 @@ #include "cl_entity.h" - - -#define INSET_OFF 0 +#define INSET_OFF 0 #define INSET_CHASE_FREE 1 #define INSET_IN_EYE 2 #define INSET_MAP_FREE 3 #define INSET_MAP_CHASE 4 -#define MAX_SPEC_HUD_MESSAGES 8 - - +#define MAX_SPEC_HUD_MESSAGES 8 #define OVERVIEW_TILE_SIZE 128 // don't change this #define OVERVIEW_MAX_LAYERS 1 @@ -30,23 +26,24 @@ // Purpose: Handles the drawing of the spectator stuff (camera & top-down map and all the things on it ) //----------------------------------------------------------------------------- -typedef struct overviewInfo_s { +typedef struct overviewInfo_s +{ char map[64]; // cl.levelname or empty vec3_t origin; // center of map float zoom; // zoom of map images - int layers; // how may layers do we have + int layers; // how may layers do we have float layersHeights[OVERVIEW_MAX_LAYERS]; char layersImages[OVERVIEW_MAX_LAYERS][255]; qboolean rotated; // are map images rotated (90 degrees) ? - - int insetWindowX; - int insetWindowY; - int insetWindowHeight; - int insetWindowWidth; + + int insetWindowX; + int insetWindowY; + int insetWindowHeight; + int insetWindowWidth; } overviewInfo_t; -typedef struct overviewEntity_s { - +typedef struct overviewEntity_s +{ HSPRITE hSprite; struct cl_entity_s * entity; double killTime; @@ -58,11 +55,11 @@ class CHudSpectator : public CHudBase { public: void Reset(); - int ToggleInset(bool allowOff); + int ToggleInset( bool allowOff ); void CheckSettings(); void InitHUDData( void ); - bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime); - void DeathMessage(int victim); + bool AddOverviewEntityToList( HSPRITE sprite, cl_entity_t * ent, double killTime ); + void DeathMessage( int victim ); bool AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname ); void CheckOverviewEntities(); void DrawOverview(); @@ -71,42 +68,40 @@ public: void DrawOverviewLayer(); void LoadMapSprites(); bool ParseOverviewFile(); - bool IsActivePlayer(cl_entity_t * ent); - void SetModes(int iMainMode, int iInsetMode); - void HandleButtonsDown(int ButtonPressed); - void HandleButtonsUp(int ButtonPressed); + bool IsActivePlayer( cl_entity_t * ent ); + void SetModes( int iMainMode, int iInsetMode ); + void HandleButtonsDown( int ButtonPressed ); + void HandleButtonsUp( int ButtonPressed ); void FindNextPlayer( bool bReverse ); void DirectorMessage( int iSize, void *pbuf ); void SetSpectatorStartPosition(); int Init(); int VidInit(); - int Draw(float flTime); + int Draw( float flTime ); int m_iDrawCycle; - client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES]; - char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128]; - int m_lastHudMessage; + client_textmessage_t m_HUDMessages[MAX_SPEC_HUD_MESSAGES]; + char m_HUDMessageText[MAX_SPEC_HUD_MESSAGES][128]; + int m_lastHudMessage; overviewInfo_t m_OverviewData; overviewEntity_t m_OverviewEntities[MAX_OVERVIEW_ENTITIES]; - int m_iObserverFlags; - int m_iSpectatorNumber; - - float m_mapZoom; // zoom the user currently uses - vec3_t m_mapOrigin; // origin where user rotates around - cvar_t * m_drawnames; - cvar_t * m_drawcone; - cvar_t * m_drawstatus; - cvar_t * m_autoDirector; - cvar_t * m_pip; - + int m_iObserverFlags; + int m_iSpectatorNumber; + + float m_mapZoom; // zoom the user currently uses + vec3_t m_mapOrigin; // origin where user rotates around + cvar_t *m_drawnames; + cvar_t *m_drawcone; + cvar_t *m_drawstatus; + cvar_t *m_autoDirector; + cvar_t *m_pip; qboolean m_chatEnabled; vec3_t m_cameraOrigin; // a help camera vec3_t m_cameraAngles; // and it's angles - private: vec3_t m_vPlayerPos[MAX_PLAYERS]; HSPRITE m_hsprPlayerBlue; @@ -121,12 +116,11 @@ private: wrect_t m_crosshairRect; - struct model_s * m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame + struct model_s *m_MapSprite; // each layer image is saved in one sprite, where each tile is a sprite frame float m_flNextObserverInput; float m_zoomDelta; float m_moveDelta; - int m_lastPrimaryObject; - int m_lastSecondaryObject; + int m_lastPrimaryObject; + int m_lastSecondaryObject; }; - #endif // SPECTATOR_H diff --git a/cl_dll/hud_update.cpp b/cl_dll/hud_update.cpp index 9facc8c7..cecbb625 100644 --- a/cl_dll/hud_update.cpp +++ b/cl_dll/hud_update.cpp @@ -29,11 +29,11 @@ extern float v_idlescale; float in_fov; extern void HUD_SetCmdBits( int bits ); -int CHud::UpdateClientData(client_data_t *cdata, float time) +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)); - + memcpy( m_vecOrigin, cdata->origin, sizeof(vec3_t) ); + memcpy( m_vecAngles, cdata->viewangles, sizeof(vec3_t) ); + m_iKeyBits = CL_ButtonBits( 0 ); m_iWeaponBits = cdata->iWeaponBits; @@ -42,7 +42,7 @@ int CHud::UpdateClientData(client_data_t *cdata, float time) Think(); cdata->fov = m_iFOV; - + v_idlescale = m_iConcussionEffect; CL_ResetButtonBits( m_iKeyBits ); @@ -50,5 +50,3 @@ int CHud::UpdateClientData(client_data_t *cdata, float time) // return 1 if in anything in the client_data struct has been changed, 0 otherwise return 1; } - - diff --git a/cl_dll/in_camera.cpp b/cl_dll/in_camera.cpp index fb6a6735..92051afe 100644 --- a/cl_dll/in_camera.cpp +++ b/cl_dll/in_camera.cpp @@ -15,10 +15,9 @@ #include "camera.h" #include "in_defs.h" +float CL_KeyState( kbutton_t *key ); -float CL_KeyState (kbutton_t *key); - -extern "C" +extern "C" { void DLLEXPORT CAM_Think( void ); int DLLEXPORT CL_IsThirdPerson( void ); @@ -66,15 +65,14 @@ cvar_t *c_mindistance; // pitch, yaw, dist vec3_t cam_ofs; - // In third person int cam_thirdperson; int cam_mousemove; //true if we are moving the cam with the mouse, False if not -int iMouseInUse=0; +int iMouseInUse = 0; int cam_distancemove; extern int mouse_x, mouse_y; //used to determine what the current x and y values are int cam_old_mouse_x, cam_old_mouse_y; //holds the last ticks mouse movement -POINT cam_mouse; +POINT cam_mouse; //-------------------------------------------------- Local Variables static kbutton_t cam_pitchup, cam_pitchdown, cam_yawleft, cam_yawright; @@ -87,7 +85,6 @@ void CAM_ToFirstPerson(void); void CAM_StartDistance(void); void CAM_EndDistance(void); - //-------------------------------------------------- Local Functions float MoveToward( float cur, float goal, float maxspeed ) @@ -118,7 +115,6 @@ float MoveToward( float cur, float goal, float maxspeed ) } } - // bring cur back into range if( cur < 0 ) cur += 360.0; @@ -128,7 +124,6 @@ float MoveToward( float cur, float goal, float maxspeed ) return cur; } - //-------------------------------------------------- Gobal Functions typedef struct @@ -138,12 +133,12 @@ typedef struct vec3_t mins2, maxs2; // size when clipping against mosnters float *start, *end; trace_t trace; - int type; + int type; edict_t *passedict; qboolean monsterclip; } moveclip_t; -extern trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); +extern trace_t SV_ClipMoveToEntity( edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end ); void DLLEXPORT CAM_Think( void ) { @@ -158,16 +153,14 @@ void DLLEXPORT CAM_Think( void ) #endif vec3_t viewangles; - switch( (int) cam_command->value ) + switch( (int)cam_command->value ) { case CAM_COMMAND_TOTHIRDPERSON: CAM_ToThirdPerson(); break; - case CAM_COMMAND_TOFIRSTPERSON: CAM_ToFirstPerson(); break; - case CAM_COMMAND_NONE: default: break; @@ -175,113 +168,108 @@ void DLLEXPORT CAM_Think( void ) if( !cam_thirdperson ) return; - #ifdef LATER - if ( cam_contain->value ) + if( cam_contain->value ) { gEngfuncs.GetClientOrigin( origin ); ext[0] = ext[1] = ext[2] = 0.0; } #endif - - camAngles[ PITCH ] = cam_idealpitch->value; - camAngles[ YAW ] = cam_idealyaw->value; + camAngles[PITCH] = cam_idealpitch->value; + camAngles[YAW] = cam_idealyaw->value; dist = cam_idealdist->value; + // //movement of the camera with the mouse // - if (cam_mousemove) + if( cam_mousemove ) { - //get windows cursor position - GetCursorPos (&cam_mouse); + //get windows cursor position + GetCursorPos( &cam_mouse ); + //check for X delta values and adjust accordingly //eventually adjust YAW based on amount of movement - //don't do any movement of the cam using YAW/PITCH if we are zooming in/out the camera - if (!cam_distancemove) - { - - //keep the camera within certain limits around the player (ie avoid certain bad viewing angles) - if (cam_mouse.x>gEngfuncs.GetWindowCenterX()) + //don't do any movement of the cam using YAW/PITCH if we are zooming in/out the camera + if( !cam_distancemove ) { - //if ((camAngles[YAW]>=225.0)||(camAngles[YAW]<135.0)) - if (camAngles[YAW]value) + //keep the camera within certain limits around the player (ie avoid certain bad viewing angles) + if( cam_mouse.x>gEngfuncs.GetWindowCenterX() ) { - camAngles[ YAW ] += (CAM_ANGLE_MOVE)*((cam_mouse.x-gEngfuncs.GetWindowCenterX())/2); + //if( ( camAngles[YAW] >= 225.0 ) || ( camAngles[YAW] < 135.0 ) ) + if( camAngles[YAW] < c_maxyaw->value ) + { + camAngles[YAW] += CAM_ANGLE_MOVE * ( ( cam_mouse.x - gEngfuncs.GetWindowCenterX() ) / 2 ); + } + if( camAngles[YAW] > c_maxyaw->value ) + { + camAngles[YAW] = c_maxyaw->value; + } } - if (camAngles[YAW]>c_maxyaw->value) + else if( cam_mouse.xvalue; + //if( ( camAngles[YAW] <= 135.0 ) || ( camAngles[YAW] > 225.0 ) ) + if( camAngles[YAW] > c_minyaw->value ) + { + camAngles[YAW] -= CAM_ANGLE_MOVE * ( ( gEngfuncs.GetWindowCenterX() - cam_mouse.x ) / 2 ); + } + if( camAngles[YAW] < c_minyaw->value ) + { + camAngles[YAW] = c_minyaw->value; + } } - } - else if (cam_mouse.x225.0)) - if (camAngles[YAW]>c_minyaw->value) - { - camAngles[ YAW ] -= (CAM_ANGLE_MOVE)* ((gEngfuncs.GetWindowCenterX()-cam_mouse.x)/2); - - } - if (camAngles[YAW]value) - { - camAngles[YAW]=c_minyaw->value; - - } - } - //check for y delta values and adjust accordingly - //eventually adjust PITCH based on amount of movement - //also make sure camera is within bounds - if (cam_mouse.y>gEngfuncs.GetWindowCenterY()) - { - if(camAngles[PITCH]value) + //check for y delta values and adjust accordingly + //eventually adjust PITCH based on amount of movement + //also make sure camera is within bounds + if( cam_mouse.y>gEngfuncs.GetWindowCenterY() ) { - camAngles[PITCH] +=(CAM_ANGLE_MOVE)* ((cam_mouse.y-gEngfuncs.GetWindowCenterY())/2); + if( camAngles[PITCH] < c_maxpitch->value ) + { + camAngles[PITCH] += CAM_ANGLE_MOVE * ( ( cam_mouse.y - gEngfuncs.GetWindowCenterY() ) / 2 ); + } + if( camAngles[PITCH] > c_maxpitch->value ) + { + camAngles[PITCH] = c_maxpitch->value; + } } - if (camAngles[PITCH]>c_maxpitch->value) + else if( cam_mouse.yvalue; + if( camAngles[PITCH] > c_minpitch->value ) + { + camAngles[PITCH] -= CAM_ANGLE_MOVE * ( ( gEngfuncs.GetWindowCenterY() - cam_mouse.y ) / 2 ); + } + if( camAngles[PITCH] < c_minpitch->value ) + { + camAngles[PITCH] = c_minpitch->value; + } } - } - else if (cam_mouse.yc_minpitch->value) - { - camAngles[PITCH] -= (CAM_ANGLE_MOVE)*((gEngfuncs.GetWindowCenterY()-cam_mouse.y)/2); - } - if (camAngles[PITCH]value) - { - camAngles[PITCH]=c_minpitch->value; - } - } - //set old mouse coordinates to current mouse coordinates - //since we are done with the mouse - - if ( ( flSensitivity = gHUD.GetSensitivity() ) != 0 ) - { - cam_old_mouse_x=cam_mouse.x*flSensitivity; - cam_old_mouse_y=cam_mouse.y*flSensitivity; + //set old mouse coordinates to current mouse coordinates + //since we are done with the mouse + if( ( flSensitivity = gHUD.GetSensitivity() ) != 0 ) + { + cam_old_mouse_x = cam_mouse.x * flSensitivity; + cam_old_mouse_y = cam_mouse.y * flSensitivity; + } + else + { + cam_old_mouse_x = cam_mouse.x; + cam_old_mouse_y = cam_mouse.y; + } + SetCursorPos( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() ); } - else - { - cam_old_mouse_x=cam_mouse.x; - cam_old_mouse_y=cam_mouse.y; - } - SetCursorPos (gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY()); - } } //Nathan code here if( CL_KeyState( &cam_pitchup ) ) - camAngles[ PITCH ] += CAM_ANGLE_DELTA; + camAngles[PITCH] += CAM_ANGLE_DELTA; else if( CL_KeyState( &cam_pitchdown ) ) - camAngles[ PITCH ] -= CAM_ANGLE_DELTA; + camAngles[PITCH] -= CAM_ANGLE_DELTA; if( CL_KeyState( &cam_yawleft ) ) - camAngles[ YAW ] -= CAM_ANGLE_DELTA; + camAngles[YAW] -= CAM_ANGLE_DELTA; else if( CL_KeyState( &cam_yawright ) ) - camAngles[ YAW ] += CAM_ANGLE_DELTA; + camAngles[YAW] += CAM_ANGLE_DELTA; if( CL_KeyState( &cam_in ) ) { @@ -289,44 +277,43 @@ void DLLEXPORT CAM_Think( void ) if( dist < CAM_MIN_DIST ) { // If we go back into first person, reset the angle - camAngles[ PITCH ] = 0; - camAngles[ YAW ] = 0; + camAngles[PITCH] = 0; + camAngles[YAW] = 0; dist = CAM_MIN_DIST; } - } else if( CL_KeyState( &cam_out ) ) dist += CAM_DIST_DELTA; - if (cam_distancemove) + if( cam_distancemove ) { - if (cam_mouse.y>gEngfuncs.GetWindowCenterY()) + if( cam_mouse.y > gEngfuncs.GetWindowCenterY() ) { - if(distvalue) + if( dist < c_maxdistance->value ) { - dist +=CAM_DIST_DELTA * ((cam_mouse.y-gEngfuncs.GetWindowCenterY())/2); + dist += CAM_DIST_DELTA * ( ( cam_mouse.y - gEngfuncs.GetWindowCenterY() ) / 2); } - if (dist>c_maxdistance->value) + if( dist > c_maxdistance->value ) { - dist=c_maxdistance->value; + dist = c_maxdistance->value; } } - else if (cam_mouse.yc_mindistance->value) + if( dist > c_mindistance->value ) { - dist -= (CAM_DIST_DELTA)*((gEngfuncs.GetWindowCenterY()-cam_mouse.y)/2); + dist -= CAM_DIST_DELTA * ( ( gEngfuncs.GetWindowCenterY() - cam_mouse.y ) / 2 ); } - if (distvalue) + if ( dist < c_mindistance->value ) { - dist=c_mindistance->value; + dist = c_mindistance->value; } } //set old mouse coordinates to current mouse coordinates //since we are done with the mouse - cam_old_mouse_x=cam_mouse.x*gHUD.GetSensitivity(); - cam_old_mouse_y=cam_mouse.y*gHUD.GetSensitivity(); - SetCursorPos (gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY()); + cam_old_mouse_x = cam_mouse.x * gHUD.GetSensitivity(); + cam_old_mouse_y = cam_mouse.y * gHUD.GetSensitivity(); + SetCursorPos( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() ); } #ifdef LATER if( cam_contain->value ) @@ -334,17 +321,17 @@ void DLLEXPORT CAM_Think( void ) // check new ideal VectorCopy( origin, pnt ); AngleVectors( camAngles, camForward, camRight, camUp ); - for (i=0 ; i<3 ; i++) - pnt[i] += -dist*camForward[i]; + for( i = 0; i < 3; i++ ) + pnt[i] += -dist * camForward[i]; // check line from r_refdef.vieworg to pnt - memset ( &clip, 0, sizeof ( moveclip_t ) ); + memset( &clip, 0, sizeof(moveclip_t) ); clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt ); if( clip.trace.fraction == 1.0 ) { // update ideal - cam_idealpitch->value = camAngles[ PITCH ]; - cam_idealyaw->value = camAngles[ YAW ]; + cam_idealpitch->value = camAngles[PITCH]; + cam_idealyaw->value = camAngles[YAW]; cam_idealdist->value = dist; } } @@ -352,8 +339,8 @@ void DLLEXPORT CAM_Think( void ) #endif { // update ideal - cam_idealpitch->value = camAngles[ PITCH ]; - cam_idealyaw->value = camAngles[ YAW ]; + cam_idealpitch->value = camAngles[PITCH]; + cam_idealyaw->value = camAngles[YAW]; cam_idealdist->value = dist; } @@ -364,91 +351,136 @@ void DLLEXPORT CAM_Think( void ) if( cam_snapto->value ) { - camAngles[ YAW ] = cam_idealyaw->value + viewangles[ YAW ]; - camAngles[ PITCH ] = cam_idealpitch->value + viewangles[ PITCH ]; - camAngles[ 2 ] = cam_idealdist->value; + camAngles[YAW] = cam_idealyaw->value + viewangles[YAW]; + camAngles[PITCH] = cam_idealpitch->value + viewangles[PITCH]; + camAngles[2] = cam_idealdist->value; } else { - if( camAngles[ YAW ] - viewangles[ YAW ] != cam_idealyaw->value ) - camAngles[ YAW ] = MoveToward( camAngles[ YAW ], cam_idealyaw->value + viewangles[ YAW ], CAM_ANGLE_SPEED ); + if( camAngles[YAW] - viewangles[YAW] != cam_idealyaw->value ) + camAngles[YAW] = MoveToward( camAngles[YAW], cam_idealyaw->value + viewangles[YAW], CAM_ANGLE_SPEED ); - if( camAngles[ PITCH ] - viewangles[ PITCH ] != cam_idealpitch->value ) - camAngles[ PITCH ] = MoveToward( camAngles[ PITCH ], cam_idealpitch->value + viewangles[ PITCH ], CAM_ANGLE_SPEED ); + if( camAngles[PITCH] - viewangles[PITCH] != cam_idealpitch->value ) + camAngles[PITCH] = MoveToward( camAngles[PITCH], cam_idealpitch->value + viewangles[PITCH], CAM_ANGLE_SPEED ); - if( fabs( camAngles[ 2 ] - cam_idealdist->value ) < 2.0 ) - camAngles[ 2 ] = cam_idealdist->value; + if( fabs( camAngles[2] - cam_idealdist->value ) < 2.0 ) + camAngles[2] = cam_idealdist->value; else - camAngles[ 2 ] += ( cam_idealdist->value - camAngles[ 2 ] ) / 4.0; + camAngles[2] += ( cam_idealdist->value - camAngles[2] ) / 4.0; } #ifdef LATER if( cam_contain->value ) { // Test new position - dist = camAngles[ ROLL ]; - camAngles[ ROLL ] = 0; + dist = camAngles[ROLL]; + camAngles[ROLL] = 0; VectorCopy( origin, pnt ); AngleVectors( camAngles, camForward, camRight, camUp ); - for (i=0 ; i<3 ; i++) - pnt[i] += -dist*camForward[i]; + for( i = 0; i < 3; i++ ) + pnt[i] += -dist * camForward[i]; // check line from r_refdef.vieworg to pnt - memset ( &clip, 0, sizeof ( moveclip_t ) ); + memset( &clip, 0, sizeof(moveclip_t) ); ext[0] = ext[1] = ext[2] = 0.0; clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt ); if( clip.trace.fraction != 1.0 ) return; } #endif - cam_ofs[ 0 ] = camAngles[ 0 ]; - cam_ofs[ 1 ] = camAngles[ 1 ]; - cam_ofs[ 2 ] = dist; + cam_ofs[0] = camAngles[0]; + cam_ofs[1] = camAngles[1]; + cam_ofs[2] = dist; } -extern void KeyDown (kbutton_t *b); // HACK -extern void KeyUp (kbutton_t *b); // HACK +extern void KeyDown( kbutton_t *b ); // HACK +extern void KeyUp( kbutton_t *b ); // HACK -void CAM_PitchUpDown(void) { KeyDown( &cam_pitchup ); } -void CAM_PitchUpUp(void) { KeyUp( &cam_pitchup ); } -void CAM_PitchDownDown(void) { KeyDown( &cam_pitchdown ); } -void CAM_PitchDownUp(void) { KeyUp( &cam_pitchdown ); } -void CAM_YawLeftDown(void) { KeyDown( &cam_yawleft ); } -void CAM_YawLeftUp(void) { KeyUp( &cam_yawleft ); } -void CAM_YawRightDown(void) { KeyDown( &cam_yawright ); } -void CAM_YawRightUp(void) { KeyUp( &cam_yawright ); } -void CAM_InDown(void) { KeyDown( &cam_in ); } -void CAM_InUp(void) { KeyUp( &cam_in ); } -void CAM_OutDown(void) { KeyDown( &cam_out ); } -void CAM_OutUp(void) { KeyUp( &cam_out ); } +void CAM_PitchUpDown( void ) +{ + KeyDown( &cam_pitchup ); +} -void CAM_ToThirdPerson(void) -{ +void CAM_PitchUpUp( void ) +{ + KeyUp( &cam_pitchup ); +} + +void CAM_PitchDownDown( void ) +{ + KeyDown( &cam_pitchdown ); +} + +void CAM_PitchDownUp( void ) +{ + KeyUp( &cam_pitchdown ); +} + +void CAM_YawLeftDown( void ) +{ + KeyDown( &cam_yawleft ); +} + +void CAM_YawLeftUp( void ) +{ + KeyUp( &cam_yawleft ); +} + +void CAM_YawRightDown( void ) +{ + KeyDown( &cam_yawright ); +} + +void CAM_YawRightUp( void ) +{ + KeyUp( &cam_yawright ); +} + +void CAM_InDown( void ) +{ + KeyDown( &cam_in ); +} + +void CAM_InUp( void ) +{ + KeyUp( &cam_in ); +} + +void CAM_OutDown( void ) +{ + KeyDown( &cam_out ); +} + +void CAM_OutUp( void ) +{ + KeyUp( &cam_out ); +} + +void CAM_ToThirdPerson( void ) +{ vec3_t viewangles; - #if !defined( _DEBUG ) - if ( gEngfuncs.GetMaxClients() > 1 ) + if( gEngfuncs.GetMaxClients() > 1 ) { // no thirdperson in multiplayer. return; } #endif - gEngfuncs.GetViewAngles( (float *)viewangles ); if( !cam_thirdperson ) { cam_thirdperson = 1; - - cam_ofs[ YAW ] = viewangles[ YAW ]; - cam_ofs[ PITCH ] = viewangles[ PITCH ]; - cam_ofs[ 2 ] = CAM_MIN_DIST; + + cam_ofs[YAW] = viewangles[YAW]; + cam_ofs[PITCH] = viewangles[PITCH]; + cam_ofs[2] = CAM_MIN_DIST; } gEngfuncs.Cvar_SetValue( "cam_command", 0 ); } -void CAM_ToFirstPerson(void) +void CAM_ToFirstPerson( void ) { cam_thirdperson = 0; @@ -482,19 +514,19 @@ void CAM_Init( void ) gEngfuncs.pfnAddCommand( "-camdistance", CAM_EndDistance ); gEngfuncs.pfnAddCommand( "snapto", CAM_ToggleSnapto ); - cam_command = gEngfuncs.pfnRegisterVariable ( "cam_command", "0", 0 ); // tells camera to go to thirdperson - cam_snapto = gEngfuncs.pfnRegisterVariable ( "cam_snapto", "0", 0 ); // snap to thirdperson view - cam_idealyaw = gEngfuncs.pfnRegisterVariable ( "cam_idealyaw", "90", 0 ); // thirdperson yaw - cam_idealpitch = gEngfuncs.pfnRegisterVariable ( "cam_idealpitch", "0", 0 ); // thirperson pitch - cam_idealdist = gEngfuncs.pfnRegisterVariable ( "cam_idealdist", "64", 0 ); // thirdperson distance - cam_contain = gEngfuncs.pfnRegisterVariable ( "cam_contain", "0", 0 ); // contain camera to world + cam_command = gEngfuncs.pfnRegisterVariable( "cam_command", "0", 0 ); // tells camera to go to thirdperson + cam_snapto = gEngfuncs.pfnRegisterVariable( "cam_snapto", "0", 0 ); // snap to thirdperson view + cam_idealyaw = gEngfuncs.pfnRegisterVariable( "cam_idealyaw", "90", 0 ); // thirdperson yaw + cam_idealpitch = gEngfuncs.pfnRegisterVariable( "cam_idealpitch", "0", 0 ); // thirperson pitch + cam_idealdist = gEngfuncs.pfnRegisterVariable( "cam_idealdist", "64", 0 ); // thirdperson distance + cam_contain = gEngfuncs.pfnRegisterVariable( "cam_contain", "0", 0 ); // contain camera to world - c_maxpitch = gEngfuncs.pfnRegisterVariable ( "c_maxpitch", "90.0", 0 ); - c_minpitch = gEngfuncs.pfnRegisterVariable ( "c_minpitch", "0.0", 0 ); - c_maxyaw = gEngfuncs.pfnRegisterVariable ( "c_maxyaw", "135.0", 0 ); - c_minyaw = gEngfuncs.pfnRegisterVariable ( "c_minyaw", "-135.0", 0 ); - c_maxdistance = gEngfuncs.pfnRegisterVariable ( "c_maxdistance", "200.0", 0 ); - c_mindistance = gEngfuncs.pfnRegisterVariable ( "c_mindistance", "30.0", 0 ); + c_maxpitch = gEngfuncs.pfnRegisterVariable( "c_maxpitch", "90.0", 0 ); + c_minpitch = gEngfuncs.pfnRegisterVariable( "c_minpitch", "0.0", 0 ); + c_maxyaw = gEngfuncs.pfnRegisterVariable( "c_maxyaw", "135.0", 0 ); + c_minyaw = gEngfuncs.pfnRegisterVariable( "c_minyaw", "-135.0", 0 ); + c_maxdistance = gEngfuncs.pfnRegisterVariable( "c_maxdistance", "200.0", 0 ); + c_mindistance = gEngfuncs.pfnRegisterVariable( "c_mindistance", "30.0", 0 ); } void CAM_ClearStates( void ) @@ -517,101 +549,100 @@ void CAM_ClearStates( void ) cam_snapto->value = 0; cam_distancemove = 0; - cam_ofs[ 0 ] = 0.0; - cam_ofs[ 1 ] = 0.0; - cam_ofs[ 2 ] = CAM_MIN_DIST; + cam_ofs[0] = 0.0; + cam_ofs[1] = 0.0; + cam_ofs[2] = CAM_MIN_DIST; - cam_idealpitch->value = viewangles[ PITCH ]; - cam_idealyaw->value = viewangles[ YAW ]; + cam_idealpitch->value = viewangles[PITCH]; + cam_idealyaw->value = viewangles[YAW]; cam_idealdist->value = CAM_MIN_DIST; } -void CAM_StartMouseMove(void) +void CAM_StartMouseMove( void ) { float flSensitivity; - + //only move the cam with mouse if we are in third person. - if (cam_thirdperson) + if( cam_thirdperson ) { //set appropriate flags and initialize the old mouse position //variables for mouse camera movement - if (!cam_mousemove) + if( !cam_mousemove ) { - cam_mousemove=1; - iMouseInUse=1; - GetCursorPos (&cam_mouse); + cam_mousemove = 1; + iMouseInUse = 1; + GetCursorPos( &cam_mouse ); - if ( ( flSensitivity = gHUD.GetSensitivity() ) != 0 ) + if( ( flSensitivity = gHUD.GetSensitivity() ) != 0 ) { - cam_old_mouse_x=cam_mouse.x*flSensitivity; - cam_old_mouse_y=cam_mouse.y*flSensitivity; + cam_old_mouse_x = cam_mouse.x * flSensitivity; + cam_old_mouse_y = cam_mouse.y * flSensitivity; } else { - cam_old_mouse_x=cam_mouse.x; - cam_old_mouse_y=cam_mouse.y; + cam_old_mouse_x = cam_mouse.x; + cam_old_mouse_y = cam_mouse.y; } } } //we are not in 3rd person view..therefore do not allow camera movement else { - cam_mousemove=0; - iMouseInUse=0; + cam_mousemove = 0; + iMouseInUse = 0; } } //the key has been released for camera movement //tell the engine that mouse camera movement is off -void CAM_EndMouseMove(void) +void CAM_EndMouseMove( void ) { - cam_mousemove=0; - iMouseInUse=0; + cam_mousemove = 0; + iMouseInUse = 0; } - //---------------------------------------------------------- //routines to start the process of moving the cam in or out //using the mouse //---------------------------------------------------------- -void CAM_StartDistance(void) +void CAM_StartDistance( void ) { //only move the cam with mouse if we are in third person. - if (cam_thirdperson) + if( cam_thirdperson ) { - //set appropriate flags and initialize the old mouse position - //variables for mouse camera movement - if (!cam_distancemove) - { - cam_distancemove=1; - cam_mousemove=1; - iMouseInUse=1; - GetCursorPos (&cam_mouse); - cam_old_mouse_x=cam_mouse.x*gHUD.GetSensitivity(); - cam_old_mouse_y=cam_mouse.y*gHUD.GetSensitivity(); - } + //set appropriate flags and initialize the old mouse position + //variables for mouse camera movement + if( !cam_distancemove ) + { + cam_distancemove = 1; + cam_mousemove = 1; + iMouseInUse = 1; + GetCursorPos( &cam_mouse ); + cam_old_mouse_x = cam_mouse.x * gHUD.GetSensitivity(); + cam_old_mouse_y = cam_mouse.y * gHUD.GetSensitivity(); + } } //we are not in 3rd person view..therefore do not allow camera movement else - { - cam_distancemove=0; - cam_mousemove=0; - iMouseInUse=0; + { + cam_distancemove = 0; + cam_mousemove = 0; + iMouseInUse = 0; } } //the key has been released for camera movement //tell the engine that mouse camera movement is off -void CAM_EndDistance(void) +void CAM_EndDistance( void ) { - cam_distancemove=0; - cam_mousemove=0; - iMouseInUse=0; + cam_distancemove = 0; + cam_mousemove = 0; + iMouseInUse = 0; } int DLLEXPORT CL_IsThirdPerson( void ) { - return (cam_thirdperson ? 1 : 0) || (g_iUser1 && (g_iUser2 == gEngfuncs.GetLocalPlayer()->index) ); + return ( cam_thirdperson ? 1 : 0 ) || ( g_iUser1 && ( g_iUser2 == gEngfuncs.GetLocalPlayer()->index ) ); } void DLLEXPORT CL_CameraOffset( float *ofs ) diff --git a/cl_dll/in_defs.h b/cl_dll/in_defs.h index c48cf373..a8c6423d 100644 --- a/cl_dll/in_defs.h +++ b/cl_dll/in_defs.h @@ -19,12 +19,12 @@ #ifdef _WIN32 #include #else -typedef struct point_s{ +typedef struct point_s +{ int x; int y; } POINT; #define GetCursorPos(x) #define SetCursorPos(x,y) #endif - #endif diff --git a/cl_dll/input.cpp b/cl_dll/input.cpp index 8c2a6a3b..fd1ef7da 100644 --- a/cl_dll/input.cpp +++ b/cl_dll/input.cpp @@ -11,6 +11,7 @@ // Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All // rights reserved. + #include "hud.h" #include "cl_util.h" #include "camera.h" @@ -30,7 +31,7 @@ extern "C" extern "C" { struct kbutton_s DLLEXPORT *KB_Find( const char *name ); - void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active ); + void DLLEXPORT CL_CreateMove( float frametime, struct usercmd_s *cmd, int active ); void DLLEXPORT HUD_Shutdown( void ); int DLLEXPORT HUD_Key_Event( int eventcode, int keynum, const char *pszCurrentBinding ); } @@ -43,8 +44,8 @@ extern cl_enginefunc_t gEngfuncs; // Defined in pm_math.c extern "C" float anglemod( float a ); -void IN_Init (void); -void IN_Move ( float frametime, usercmd_t *cmd); +void IN_Init( void ); +void IN_Move( float frametime, usercmd_t *cmd ); void IN_Shutdown( void ); void V_Init( void ); void VectorAngles( const float *forward, float *angles ); @@ -53,8 +54,8 @@ int CL_ButtonBits( int ); // xxx need client dll function to get and clear impuse extern cvar_t *in_joystick; -int in_impulse = 0; -int in_cancel = 0; +int in_impulse = 0; +int in_cancel = 0; cvar_t *m_pitch; cvar_t *m_yaw; @@ -74,6 +75,7 @@ cvar_t *cl_yawspeed; cvar_t *cl_pitchspeed; cvar_t *cl_anglespeedkey; cvar_t *cl_vsmoothing; + /* =============================================================================== @@ -95,7 +97,6 @@ state bit 2 is edge triggered on the down to up transition =============================================================================== */ - kbutton_t in_mlook; kbutton_t in_klook; kbutton_t in_jlook; @@ -142,39 +143,39 @@ NOTE: Only works for text with +word in it. */ int KB_ConvertString( char *in, char **ppout ) { - char sz[ 4096 ]; - char binding[ 64 ]; + char sz[4096]; + char binding[64]; char *p; char *pOut; char *pEnd; const char *pBinding; - if ( !ppout ) + if( !ppout ) return 0; *ppout = NULL; p = in; pOut = sz; - while ( *p ) + while( *p ) { - if ( *p == '+' ) + if( *p == '+' ) { pEnd = binding; - while ( *p && ( isalnum( *p ) || ( pEnd == binding ) ) && ( ( pEnd - binding ) < 63 ) ) + while( *p && ( isalnum( *p ) || ( pEnd == binding ) ) && ( ( pEnd - binding ) < 63 ) ) { *pEnd++ = *p++; } - *pEnd = '\0'; + *pEnd = '\0'; pBinding = NULL; - if ( strlen( binding + 1 ) > 0 ) + if( strlen( binding + 1 ) > 0 ) { // See if there is a binding for binding? pBinding = gEngfuncs.Key_LookupBinding( binding + 1 ); } - if ( pBinding ) + if( pBinding ) { *pOut++ = '['; pEnd = (char *)pBinding; @@ -184,12 +185,12 @@ int KB_ConvertString( char *in, char **ppout ) pEnd = binding; } - while ( *pEnd ) + while( *pEnd ) { *pOut++ = *pEnd++; } - if ( pBinding ) + if( pBinding ) { *pOut++ = ']'; } @@ -202,7 +203,7 @@ int KB_ConvertString( char *in, char **ppout ) *pOut = '\0'; - pOut = ( char * )malloc( strlen( sz ) + 1 ); + pOut = (char *)malloc( strlen( sz ) + 1 ); strcpy( pOut, sz ); *ppout = pOut; @@ -220,9 +221,9 @@ struct kbutton_s DLLEXPORT *KB_Find( const char *name ) { kblist_t *p; p = g_kbkeys; - while ( p ) + while( p ) { - if ( !stricmp( name, p->name ) ) + if( !stricmp( name, p->name ) ) return p->pkey; p = p->next; @@ -243,12 +244,12 @@ void KB_Add( const char *name, kbutton_t *pkb ) kbutton_t *kb; kb = KB_Find( name ); - - if ( kb ) + + if( kb ) return; - p = ( kblist_t * )malloc( sizeof( kblist_t ) ); - memset( p, 0, sizeof( *p ) ); + p = (kblist_t *)malloc( sizeof(kblist_t) ); + memset( p, 0, sizeof(*p) ); strcpy( p->name, name ); p->pkey = pkb; @@ -284,7 +285,7 @@ void KB_Shutdown( void ) { kblist_t *p, *n; p = g_kbkeys; - while ( p ) + while( p ) { n = p->next; free( p ); @@ -298,31 +299,31 @@ void KB_Shutdown( void ) KeyDown ============ */ -void KeyDown (kbutton_t *b) +void KeyDown( kbutton_t *b ) { - int k; + int k; char *c; - c = gEngfuncs.Cmd_Argv(1); - if (c[0]) - k = atoi(c); + c = gEngfuncs.Cmd_Argv( 1 ); + if( c[0] ) + k = atoi( c ); else k = -1; // typed manually at the console for continuous down - if (k == b->down[0] || k == b->down[1]) + if( k == b->down[0] || k == b->down[1] ) return; // repeating key - if (!b->down[0]) + if( !b->down[0] ) b->down[0] = k; - else if (!b->down[1]) + else if( !b->down[1] ) b->down[1] = k; else { - gEngfuncs.Con_DPrintf ("Three keys down for a button '%c' '%c' '%c'!\n", b->down[0], b->down[1], c); + gEngfuncs.Con_DPrintf( "Three keys down for a button '%c' '%c' '%c'!\n", b->down[0], b->down[1], c ); return; } - if (b->state & 1) + if( b->state & 1 ) return; // still down b->state |= 1 + 2; // down + impulse down } @@ -332,34 +333,35 @@ void KeyDown (kbutton_t *b) KeyUp ============ */ -void KeyUp (kbutton_t *b) +void KeyUp( kbutton_t *b ) { - int k; + int k; char *c; - c = gEngfuncs.Cmd_Argv(1); - if (c[0]) + c = gEngfuncs.Cmd_Argv( 1 ); + if( c[0] ) k = atoi(c); else - { // typed manually at the console, assume for unsticking, so clear all + { + // typed manually at the console, assume for unsticking, so clear all b->down[0] = b->down[1] = 0; b->state = 4; // impulse up return; } - if (b->down[0] == k) + if( b->down[0] == k ) b->down[0] = 0; - else if (b->down[1] == k) + else if( b->down[1] == k ) b->down[1] = 0; else return; // key up without coresponding down (menu pass through) - if (b->down[0] || b->down[1]) + if( b->down[0] || b->down[1] ) { - //Con_Printf ("Keys down for button: '%c' '%c' '%c' (%d,%d,%d)!\n", b->down[0], b->down[1], c, b->down[0], b->down[1], c); + //Con_Printf ( "Keys down for button: '%c' '%c' '%c' (%d,%d,%d)!\n", b->down[0], b->down[1], c, b->down[0], b->down[1], c ); return; // some other key is still holding it down } - if (!(b->state & 1)) + if( !( b->state & 1 ) ) return; // still up (this should not happen) b->state &= ~1; // now up @@ -374,154 +376,283 @@ Return 1 to allow engine to process the key, otherwise, act on it as needed ============ */ int DLLEXPORT HUD_Key_Event( int down, int keynum, const char *pszCurrentBinding ) -{ - +{ return 1; } -void IN_BreakDown( void ) { KeyDown( &in_break ); } -void IN_BreakUp( void ) { KeyUp( &in_break ); } -void IN_KLookDown (void) {KeyDown(&in_klook);} -void IN_KLookUp (void) {KeyUp(&in_klook);} -void IN_JLookDown (void) {KeyDown(&in_jlook);} -void IN_JLookUp (void) {KeyUp(&in_jlook);} -void IN_MLookDown (void) {KeyDown(&in_mlook);} -void IN_UpDown(void) {KeyDown(&in_up);} -void IN_UpUp(void) {KeyUp(&in_up);} -void IN_DownDown(void) {KeyDown(&in_down);} -void IN_DownUp(void) {KeyUp(&in_down);} -void IN_LeftDown(void) {KeyDown(&in_left);} -void IN_LeftUp(void) {KeyUp(&in_left);} -void IN_RightDown(void) {KeyDown(&in_right);} -void IN_RightUp(void) {KeyUp(&in_right);} - -void IN_ForwardDown(void) +void IN_BreakDown( void ) { - KeyDown(&in_forward); + KeyDown( &in_break ); +} + +void IN_BreakUp( void ) +{ + KeyUp( &in_break ); +} + +void IN_KLookDown( void ) +{ + KeyDown( &in_klook ); +} + +void IN_KLookUp( void ) +{ + KeyUp( &in_klook ); +} + +void IN_JLookDown( void ) +{ + KeyDown( &in_jlook ); +} + +void IN_JLookUp( void ) +{ + KeyUp( &in_jlook ); +} + +void IN_MLookDown( void ) +{ + KeyDown( &in_mlook ); +} + +void IN_UpDown( void ) +{ + KeyDown( &in_up ); +} + +void IN_UpUp( void ) +{ + KeyUp( &in_up ); +} + +void IN_DownDown( void ) +{ + KeyDown( &in_down ); +} + +void IN_DownUp( void ) +{ + KeyUp( &in_down ); +} + +void IN_LeftDown( void ) +{ + KeyDown( &in_left ); +} + +void IN_LeftUp( void ) +{ + KeyUp( &in_left ); +} + +void IN_RightDown( void ) +{ + KeyDown( &in_right ); +} + +void IN_RightUp( void ) +{ + KeyUp( &in_right ); +} + +void IN_ForwardDown( void ) +{ + KeyDown( &in_forward ); gHUD.m_Spectator.HandleButtonsDown( IN_FORWARD ); } -void IN_ForwardUp(void) +void IN_ForwardUp( void ) { - KeyUp(&in_forward); + KeyUp( &in_forward ); gHUD.m_Spectator.HandleButtonsUp( IN_FORWARD ); } -void IN_BackDown(void) +void IN_BackDown( void ) { - KeyDown(&in_back); + KeyDown( &in_back ); gHUD.m_Spectator.HandleButtonsDown( IN_BACK ); } -void IN_BackUp(void) +void IN_BackUp( void ) { - KeyUp(&in_back); + KeyUp( &in_back ); gHUD.m_Spectator.HandleButtonsUp( IN_BACK ); } -void IN_LookupDown(void) {KeyDown(&in_lookup);} -void IN_LookupUp(void) {KeyUp(&in_lookup);} -void IN_LookdownDown(void) {KeyDown(&in_lookdown);} -void IN_LookdownUp(void) {KeyUp(&in_lookdown);} -void IN_MoveleftDown(void) + +void IN_LookupDown( void ) { - KeyDown(&in_moveleft); + KeyDown( &in_lookup ); +} + +void IN_LookupUp( void ) +{ + KeyUp( &in_lookup ); +} + +void IN_LookdownDown( void ) +{ + KeyDown( &in_lookdown ); +} + +void IN_LookdownUp( void ) +{ + KeyUp( &in_lookdown ); +} + +void IN_MoveleftDown( void ) +{ + KeyDown( &in_moveleft ); gHUD.m_Spectator.HandleButtonsDown( IN_MOVELEFT ); } -void IN_MoveleftUp(void) +void IN_MoveleftUp( void ) { - KeyUp(&in_moveleft); + KeyUp( &in_moveleft ); gHUD.m_Spectator.HandleButtonsUp( IN_MOVELEFT ); } -void IN_MoverightDown(void) +void IN_MoverightDown( void ) { - KeyDown(&in_moveright); + KeyDown( &in_moveright ); gHUD.m_Spectator.HandleButtonsDown( IN_MOVERIGHT ); } -void IN_MoverightUp(void) +void IN_MoverightUp( void ) { - KeyUp(&in_moveright); + KeyUp( &in_moveright ); gHUD.m_Spectator.HandleButtonsUp( IN_MOVERIGHT ); } -void IN_SpeedDown(void) {KeyDown(&in_speed);} -void IN_SpeedUp(void) {KeyUp(&in_speed);} -void IN_StrafeDown(void) {KeyDown(&in_strafe);} -void IN_StrafeUp(void) {KeyUp(&in_strafe);} + +void IN_SpeedDown( void ) +{ + KeyDown( &in_speed ); +} + +void IN_SpeedUp( void ) +{ + KeyUp( &in_speed ); +} + +void IN_StrafeDown( void ) +{ + KeyDown( &in_strafe ); +} + +void IN_StrafeUp( void ) +{ + KeyUp( &in_strafe ); +} // needs capture by hud/vgui also -extern void __CmdFunc_InputPlayerSpecial(void); +extern void __CmdFunc_InputPlayerSpecial( void ); -void IN_Attack2Down(void) +void IN_Attack2Down( void ) { - KeyDown(&in_attack2); + KeyDown( &in_attack2 ); gHUD.m_Spectator.HandleButtonsDown( IN_ATTACK2 ); } -void IN_Attack2Up(void) {KeyUp(&in_attack2);} -void IN_UseDown (void) +void IN_Attack2Up( void ) { - KeyDown(&in_use); + KeyUp( &in_attack2 ); +} + +void IN_UseDown( void ) +{ + KeyDown( &in_use ); gHUD.m_Spectator.HandleButtonsDown( IN_USE ); } -void IN_UseUp (void) {KeyUp(&in_use);} -void IN_JumpDown (void) +void IN_UseUp( void ) { - KeyDown(&in_jump); + KeyUp( &in_use ); +} +void IN_JumpDown( void ) +{ + KeyDown( &in_jump ); gHUD.m_Spectator.HandleButtonsDown( IN_JUMP ); - } -void IN_JumpUp (void) {KeyUp(&in_jump);} -void IN_DuckDown(void) + +void IN_JumpUp( void ) { - KeyDown(&in_duck); - gHUD.m_Spectator.HandleButtonsDown( IN_DUCK ); - + KeyUp( &in_jump ); } -void IN_DuckUp(void) {KeyUp(&in_duck);} -void IN_ReloadDown(void) {KeyDown(&in_reload);} -void IN_ReloadUp(void) {KeyUp(&in_reload);} -void IN_Alt1Down(void) {KeyDown(&in_alt1);} -void IN_Alt1Up(void) {KeyUp(&in_alt1);} -void IN_GraphDown(void) {KeyDown(&in_graph);} -void IN_GraphUp(void) {KeyUp(&in_graph);} -void IN_AttackDown(void) +void IN_DuckDown( void ) +{ + KeyDown( &in_duck ); + gHUD.m_Spectator.HandleButtonsDown( IN_DUCK ); +} + +void IN_DuckUp( void ) +{ + KeyUp( &in_duck ); +} + +void IN_ReloadDown( void ) +{ + KeyDown( &in_reload ); +} + +void IN_ReloadUp( void ) +{ + KeyUp( &in_reload ); +} + +void IN_Alt1Down( void ) +{ + KeyDown( &in_alt1 ); +} + +void IN_Alt1Up( void ) +{ + KeyUp( &in_alt1 ); +} + +void IN_GraphDown( void ) +{ + KeyDown( &in_graph ); +} + +void IN_GraphUp( void ) +{ + KeyUp( &in_graph ); +} + +void IN_AttackDown( void ) { KeyDown( &in_attack ); gHUD.m_Spectator.HandleButtonsDown( IN_ATTACK ); } -void IN_AttackUp(void) +void IN_AttackUp( void ) { KeyUp( &in_attack ); in_cancel = 0; } // Special handling -void IN_Cancel(void) +void IN_Cancel( void ) { in_cancel = 1; } -void IN_Impulse (void) +void IN_Impulse( void ) { - in_impulse = atoi( gEngfuncs.Cmd_Argv(1) ); + in_impulse = atoi( gEngfuncs.Cmd_Argv( 1 ) ); } -void IN_ScoreDown(void) +void IN_ScoreDown( void ) { - KeyDown(&in_score); + KeyDown( &in_score ); } -void IN_ScoreUp(void) +void IN_ScoreUp( void ) { - KeyUp(&in_score); + KeyUp( &in_score ); } -void IN_MLookUp (void) +void IN_MLookUp( void ) { KeyUp( &in_mlook ); } @@ -536,36 +667,36 @@ Returns 0.25 if a key was pressed and released during the frame, 1.0 if held for the entire time =============== */ -float CL_KeyState (kbutton_t *key) +float CL_KeyState( kbutton_t *key ) { float val = 0.0; - int impulsedown, impulseup, down; - + int impulsedown, impulseup, down; + impulsedown = key->state & 2; - impulseup = key->state & 4; - down = key->state & 1; - - if ( impulsedown && !impulseup ) + impulseup = key->state & 4; + down = key->state & 1; + + if( impulsedown && !impulseup ) { // pressed and held this frame? val = down ? 0.5 : 0.0; } - if ( impulseup && !impulsedown ) + if( impulseup && !impulsedown ) { // released this frame? val = down ? 0.0 : 0.0; } - if ( !impulsedown && !impulseup ) + if( !impulsedown && !impulseup ) { // held the entire frame? val = down ? 1.0 : 0.0; } - if ( impulsedown && impulseup ) + if( impulsedown && impulseup ) { - if ( down ) + if( down ) { // released and re-pressed this frame val = 0.75; @@ -589,12 +720,12 @@ CL_AdjustAngles Moves the local angle positions ================ */ -void CL_AdjustAngles ( float frametime, float *viewangles ) +void CL_AdjustAngles( float frametime, float *viewangles ) { - float speed; - float up, down; - - if (in_speed.state & 1) + float speed; + float up, down; + + if( in_speed.state & 1 ) { speed = frametime * cl_anglespeedkey->value; } @@ -603,32 +734,33 @@ void CL_AdjustAngles ( float frametime, float *viewangles ) speed = frametime; } - if (!(in_strafe.state & 1)) + if( !( in_strafe.state & 1 ) ) { - viewangles[YAW] -= speed*cl_yawspeed->value*CL_KeyState (&in_right); - viewangles[YAW] += speed*cl_yawspeed->value*CL_KeyState (&in_left); - viewangles[YAW] = anglemod(viewangles[YAW]); + viewangles[YAW] -= speed * cl_yawspeed->value * CL_KeyState( &in_right ); + viewangles[YAW] += speed * cl_yawspeed->value * CL_KeyState( &in_left ); + viewangles[YAW] = anglemod( viewangles[YAW] ); } - if (in_klook.state & 1) - { - viewangles[PITCH] -= speed*cl_pitchspeed->value * CL_KeyState (&in_forward); - viewangles[PITCH] += speed*cl_pitchspeed->value * CL_KeyState (&in_back); - } - - up = CL_KeyState (&in_lookup); - down = CL_KeyState(&in_lookdown); - - viewangles[PITCH] -= speed*cl_pitchspeed->value * up; - viewangles[PITCH] += speed*cl_pitchspeed->value * down; - if (viewangles[PITCH] > cl_pitchdown->value) + if( in_klook.state & 1 ) + { + viewangles[PITCH] -= speed * cl_pitchspeed->value * CL_KeyState( &in_forward ); + viewangles[PITCH] += speed * cl_pitchspeed->value * CL_KeyState( &in_back ); + } + + up = CL_KeyState( &in_lookup ); + down = CL_KeyState( &in_lookdown ); + + viewangles[PITCH] -= speed * cl_pitchspeed->value * up; + viewangles[PITCH] += speed * cl_pitchspeed->value * down; + + if( viewangles[PITCH] > cl_pitchdown->value ) viewangles[PITCH] = cl_pitchdown->value; - if (viewangles[PITCH] < -cl_pitchup->value) + if( viewangles[PITCH] < -cl_pitchup->value ) viewangles[PITCH] = -cl_pitchup->value; - if (viewangles[ROLL] > 50) + if( viewangles[ROLL] > 50 ) viewangles[ROLL] = 50; - if (viewangles[ROLL] < -50) + if( viewangles[ROLL] < -50 ) viewangles[ROLL] = -50; } @@ -641,44 +773,44 @@ if active == 1 then we are 1) not playing back demos ( where our commands are ig 2 ) we have finished signing on to server ================ */ -void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active ) -{ +void DLLEXPORT CL_CreateMove( float frametime, struct usercmd_s *cmd, int active ) +{ float spd; vec3_t viewangles; static vec3_t oldangles; - if ( active ) + if( active ) { - //memset( viewangles, 0, sizeof( vec3_t ) ); - //viewangles[ 0 ] = viewangles[ 1 ] = viewangles[ 2 ] = 0.0; + //memset( viewangles, 0, sizeof(vec3_t) ); + //viewangles[0] = viewangles[1] = viewangles[2] = 0.0; gEngfuncs.GetViewAngles( (float *)viewangles ); - CL_AdjustAngles ( frametime, viewangles ); + CL_AdjustAngles( frametime, viewangles ); + + memset( cmd, 0, sizeof(*cmd) ); - memset (cmd, 0, sizeof(*cmd)); - gEngfuncs.SetViewAngles( (float *)viewangles ); - if ( in_strafe.state & 1 ) + if( in_strafe.state & 1 ) { - cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_right); - cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_left); + cmd->sidemove += cl_sidespeed->value * CL_KeyState( &in_right ); + cmd->sidemove -= cl_sidespeed->value * CL_KeyState( &in_left ); } - cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_moveright); - cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_moveleft); + cmd->sidemove += cl_sidespeed->value * CL_KeyState( &in_moveright ); + cmd->sidemove -= cl_sidespeed->value * CL_KeyState( &in_moveleft ); - cmd->upmove += cl_upspeed->value * CL_KeyState (&in_up); - cmd->upmove -= cl_upspeed->value * CL_KeyState (&in_down); + cmd->upmove += cl_upspeed->value * CL_KeyState( &in_up ); + cmd->upmove -= cl_upspeed->value * CL_KeyState( &in_down ); - if ( !(in_klook.state & 1 ) ) + if( !(in_klook.state & 1 ) ) { - cmd->forwardmove += cl_forwardspeed->value * CL_KeyState (&in_forward); - cmd->forwardmove -= cl_backspeed->value * CL_KeyState (&in_back); - } + cmd->forwardmove += cl_forwardspeed->value * CL_KeyState( &in_forward ); + cmd->forwardmove -= cl_backspeed->value * CL_KeyState( &in_back ); + } // adjust for speed key - if ( in_speed.state & 1 ) + if( in_speed.state & 1 ) { cmd->forwardmove *= cl_movespeedkey->value; cmd->sidemove *= cl_movespeedkey->value; @@ -687,12 +819,12 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ // clip to maxspeed spd = gEngfuncs.GetClientMaxspeed(); - if ( spd != 0.0 ) + if( spd != 0.0 ) { // scale the 3 speeds so that the total velocity is not > cl.maxspeed - float fmov = sqrt( (cmd->forwardmove*cmd->forwardmove) + (cmd->sidemove*cmd->sidemove) + (cmd->upmove*cmd->upmove) ); + float fmov = sqrt( ( cmd->forwardmove * cmd->forwardmove ) + ( cmd->sidemove * cmd->sidemove ) + ( cmd->upmove * cmd->upmove ) ); - if ( fmov > spd ) + if( fmov > spd ) { float fratio = spd / fmov; cmd->forwardmove *= fratio; @@ -702,7 +834,7 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ } // Allow mice and other controllers to add their inputs - IN_Move ( frametime, cmd ); + IN_Move( frametime, cmd ); } cmd->impulse = in_impulse; @@ -715,15 +847,14 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ // cmd->buttons = CL_ButtonBits( 1 ); - // Using joystick? - if ( in_joystick->value ) + if( in_joystick->value ) { - if ( cmd->forwardmove > 0 ) + if( cmd->forwardmove > 0 ) { cmd->buttons |= IN_FORWARD; } - else if ( cmd->forwardmove < 0 ) + else if( cmd->forwardmove < 0 ) { cmd->buttons |= IN_BACK; } @@ -732,7 +863,7 @@ void DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int activ gEngfuncs.GetViewAngles( (float *)viewangles ); // Set current view angles. - if ( g_iAlive ) + if( g_iAlive ) { VectorCopy( viewangles, cmd->viewangles ); VectorCopy( viewangles, oldangles ); @@ -751,7 +882,7 @@ CL_IsDead Returns 1 if health is <= 0 ============ */ -int CL_IsDead( void ) +int CL_IsDead( void ) { return ( gHUD.m_Health.m_iHealth <= 0 ) ? 1 : 0; } @@ -768,92 +899,91 @@ int CL_ButtonBits( int bResetState ) { int bits = 0; - if ( in_attack.state & 3 ) + if( in_attack.state & 3 ) { - if(gHUD.m_MOTD.m_bShow) + if( gHUD.m_MOTD.m_bShow ) gHUD.m_MOTD.Reset(); else bits |= IN_ATTACK; } - - if (in_duck.state & 3) + if( in_duck.state & 3 ) { bits |= IN_DUCK; } - - if (in_jump.state & 3) + + if( in_jump.state & 3 ) { bits |= IN_JUMP; } - if ( in_forward.state & 3 ) + if( in_forward.state & 3 ) { bits |= IN_FORWARD; } - - if (in_back.state & 3) + + if( in_back.state & 3 ) { bits |= IN_BACK; } - if (in_use.state & 3) + if( in_use.state & 3 ) { bits |= IN_USE; } - if (in_cancel) + if( in_cancel ) { bits |= IN_CANCEL; } - if ( in_left.state & 3 ) + if( in_left.state & 3 ) { bits |= IN_LEFT; } - if (in_right.state & 3) + if( in_right.state & 3 ) { bits |= IN_RIGHT; } - - if ( in_moveleft.state & 3 ) + + if( in_moveleft.state & 3 ) { bits |= IN_MOVELEFT; } - if (in_moveright.state & 3) + if( in_moveright.state & 3 ) { bits |= IN_MOVERIGHT; } - if (in_attack2.state & 3) + if( in_attack2.state & 3 ) { bits |= IN_ATTACK2; } - if (in_reload.state & 3) + if( in_reload.state & 3 ) { bits |= IN_RELOAD; } - if (in_alt1.state & 3) + if( in_alt1.state & 3 ) { bits |= IN_ALT1; } - if ( in_score.state & 3 ) + if( in_score.state & 3 ) { bits |= IN_SCORE; } // Dead or in intermission? Shore scoreboard, too - if ( CL_IsDead() || gHUD.m_iIntermission ) + if( CL_IsDead() || gHUD.m_iIntermission ) { bits |= IN_SCORE; } - if ( bResetState ) + if( bResetState ) { in_attack.state &= ~2; in_duck.state &= ~2; @@ -885,10 +1015,10 @@ void CL_ResetButtonBits( int bits ) int bitsNew = CL_ButtonBits( 0 ) ^ bits; // Has the attack button been changed - if ( bitsNew & IN_ATTACK ) + if( bitsNew & IN_ATTACK ) { // Was it pressed? or let go? - if ( bits & IN_ATTACK ) + if( bits & IN_ATTACK ) { KeyDown( &in_attack ); } @@ -905,77 +1035,77 @@ void CL_ResetButtonBits( int bits ) InitInput ============ */ -void InitInput (void) +void InitInput( void ) { - gEngfuncs.pfnAddCommand ("+moveup",IN_UpDown); - gEngfuncs.pfnAddCommand ("-moveup",IN_UpUp); - gEngfuncs.pfnAddCommand ("+movedown",IN_DownDown); - gEngfuncs.pfnAddCommand ("-movedown",IN_DownUp); - gEngfuncs.pfnAddCommand ("+left",IN_LeftDown); - gEngfuncs.pfnAddCommand ("-left",IN_LeftUp); - gEngfuncs.pfnAddCommand ("+right",IN_RightDown); - gEngfuncs.pfnAddCommand ("-right",IN_RightUp); - gEngfuncs.pfnAddCommand ("+forward",IN_ForwardDown); - gEngfuncs.pfnAddCommand ("-forward",IN_ForwardUp); - gEngfuncs.pfnAddCommand ("+back",IN_BackDown); - gEngfuncs.pfnAddCommand ("-back",IN_BackUp); - gEngfuncs.pfnAddCommand ("+lookup", IN_LookupDown); - gEngfuncs.pfnAddCommand ("-lookup", IN_LookupUp); - gEngfuncs.pfnAddCommand ("+lookdown", IN_LookdownDown); - gEngfuncs.pfnAddCommand ("-lookdown", IN_LookdownUp); - gEngfuncs.pfnAddCommand ("+strafe", IN_StrafeDown); - gEngfuncs.pfnAddCommand ("-strafe", IN_StrafeUp); - gEngfuncs.pfnAddCommand ("+moveleft", IN_MoveleftDown); - gEngfuncs.pfnAddCommand ("-moveleft", IN_MoveleftUp); - gEngfuncs.pfnAddCommand ("+moveright", IN_MoverightDown); - gEngfuncs.pfnAddCommand ("-moveright", IN_MoverightUp); - gEngfuncs.pfnAddCommand ("+speed", IN_SpeedDown); - gEngfuncs.pfnAddCommand ("-speed", IN_SpeedUp); - gEngfuncs.pfnAddCommand ("+attack", IN_AttackDown); - gEngfuncs.pfnAddCommand ("-attack", IN_AttackUp); - gEngfuncs.pfnAddCommand ("+attack2", IN_Attack2Down); - gEngfuncs.pfnAddCommand ("-attack2", IN_Attack2Up); - gEngfuncs.pfnAddCommand ("+use", IN_UseDown); - gEngfuncs.pfnAddCommand ("-use", IN_UseUp); - gEngfuncs.pfnAddCommand ("+jump", IN_JumpDown); - gEngfuncs.pfnAddCommand ("-jump", IN_JumpUp); - gEngfuncs.pfnAddCommand ("impulse", IN_Impulse); - gEngfuncs.pfnAddCommand ("+klook", IN_KLookDown); - gEngfuncs.pfnAddCommand ("-klook", IN_KLookUp); - gEngfuncs.pfnAddCommand ("+mlook", IN_MLookDown); - gEngfuncs.pfnAddCommand ("-mlook", IN_MLookUp); - gEngfuncs.pfnAddCommand ("+jlook", IN_JLookDown); - gEngfuncs.pfnAddCommand ("-jlook", IN_JLookUp); - gEngfuncs.pfnAddCommand ("+duck", IN_DuckDown); - gEngfuncs.pfnAddCommand ("-duck", IN_DuckUp); - gEngfuncs.pfnAddCommand ("+reload", IN_ReloadDown); - gEngfuncs.pfnAddCommand ("-reload", IN_ReloadUp); - gEngfuncs.pfnAddCommand ("+alt1", IN_Alt1Down); - gEngfuncs.pfnAddCommand ("-alt1", IN_Alt1Up); - gEngfuncs.pfnAddCommand ("+graph", IN_GraphDown); - gEngfuncs.pfnAddCommand ("-graph", IN_GraphUp); - gEngfuncs.pfnAddCommand ("+break",IN_BreakDown); - gEngfuncs.pfnAddCommand ("-break",IN_BreakUp); + gEngfuncs.pfnAddCommand( "+moveup", IN_UpDown ); + gEngfuncs.pfnAddCommand( "-moveup", IN_UpUp ); + gEngfuncs.pfnAddCommand( "+movedown", IN_DownDown ); + gEngfuncs.pfnAddCommand( "-movedown", IN_DownUp ); + gEngfuncs.pfnAddCommand( "+left", IN_LeftDown ); + gEngfuncs.pfnAddCommand( "-left", IN_LeftUp ); + gEngfuncs.pfnAddCommand( "+right", IN_RightDown ); + gEngfuncs.pfnAddCommand( "-right", IN_RightUp ); + gEngfuncs.pfnAddCommand( "+forward", IN_ForwardDown ); + gEngfuncs.pfnAddCommand( "-forward", IN_ForwardUp ); + gEngfuncs.pfnAddCommand( "+back", IN_BackDown ); + gEngfuncs.pfnAddCommand( "-back", IN_BackUp ); + gEngfuncs.pfnAddCommand( "+lookup", IN_LookupDown ); + gEngfuncs.pfnAddCommand( "-lookup", IN_LookupUp ); + gEngfuncs.pfnAddCommand( "+lookdown", IN_LookdownDown ); + gEngfuncs.pfnAddCommand( "-lookdown", IN_LookdownUp ); + gEngfuncs.pfnAddCommand( "+strafe", IN_StrafeDown ); + gEngfuncs.pfnAddCommand( "-strafe", IN_StrafeUp ); + gEngfuncs.pfnAddCommand( "+moveleft", IN_MoveleftDown ); + gEngfuncs.pfnAddCommand( "-moveleft", IN_MoveleftUp ); + gEngfuncs.pfnAddCommand( "+moveright", IN_MoverightDown ); + gEngfuncs.pfnAddCommand( "-moveright", IN_MoverightUp ); + gEngfuncs.pfnAddCommand( "+speed", IN_SpeedDown ); + gEngfuncs.pfnAddCommand( "-speed", IN_SpeedUp ); + gEngfuncs.pfnAddCommand( "+attack", IN_AttackDown ); + gEngfuncs.pfnAddCommand( "-attack", IN_AttackUp ); + gEngfuncs.pfnAddCommand( "+attack2", IN_Attack2Down ); + gEngfuncs.pfnAddCommand( "-attack2", IN_Attack2Up ); + gEngfuncs.pfnAddCommand( "+use", IN_UseDown ); + gEngfuncs.pfnAddCommand( "-use", IN_UseUp ); + gEngfuncs.pfnAddCommand( "+jump", IN_JumpDown ); + gEngfuncs.pfnAddCommand( "-jump", IN_JumpUp ); + gEngfuncs.pfnAddCommand( "impulse", IN_Impulse ); + gEngfuncs.pfnAddCommand( "+klook", IN_KLookDown ); + gEngfuncs.pfnAddCommand( "-klook", IN_KLookUp ); + gEngfuncs.pfnAddCommand( "+mlook", IN_MLookDown ); + gEngfuncs.pfnAddCommand( "-mlook", IN_MLookUp ); + gEngfuncs.pfnAddCommand( "+jlook", IN_JLookDown ); + gEngfuncs.pfnAddCommand( "-jlook", IN_JLookUp ); + gEngfuncs.pfnAddCommand( "+duck", IN_DuckDown ); + gEngfuncs.pfnAddCommand( "-duck", IN_DuckUp ); + gEngfuncs.pfnAddCommand( "+reload", IN_ReloadDown ); + gEngfuncs.pfnAddCommand( "-reload", IN_ReloadUp ); + gEngfuncs.pfnAddCommand( "+alt1", IN_Alt1Down ); + gEngfuncs.pfnAddCommand( "-alt1", IN_Alt1Up ); + gEngfuncs.pfnAddCommand( "+graph", IN_GraphDown ); + gEngfuncs.pfnAddCommand( "-graph", IN_GraphUp ); + gEngfuncs.pfnAddCommand( "+break", IN_BreakDown ); + gEngfuncs.pfnAddCommand( "-break", IN_BreakUp ); - lookstrafe = gEngfuncs.pfnRegisterVariable ( "lookstrafe", "0", FCVAR_ARCHIVE ); - lookspring = gEngfuncs.pfnRegisterVariable ( "lookspring", "0", FCVAR_ARCHIVE ); - cl_anglespeedkey = gEngfuncs.pfnRegisterVariable ( "cl_anglespeedkey", "0.67", 0 ); - cl_yawspeed = gEngfuncs.pfnRegisterVariable ( "cl_yawspeed", "210", 0 ); - cl_pitchspeed = gEngfuncs.pfnRegisterVariable ( "cl_pitchspeed", "225", 0 ); - cl_upspeed = gEngfuncs.pfnRegisterVariable ( "cl_upspeed", "320", 0 ); - cl_forwardspeed = gEngfuncs.pfnRegisterVariable ( "cl_forwardspeed", "400", FCVAR_ARCHIVE ); - cl_backspeed = gEngfuncs.pfnRegisterVariable ( "cl_backspeed", "400", FCVAR_ARCHIVE ); - cl_sidespeed = gEngfuncs.pfnRegisterVariable ( "cl_sidespeed", "400", 0 ); - cl_movespeedkey = gEngfuncs.pfnRegisterVariable ( "cl_movespeedkey", "0.3", 0 ); - cl_pitchup = gEngfuncs.pfnRegisterVariable ( "cl_pitchup", "89", 0 ); - cl_pitchdown = gEngfuncs.pfnRegisterVariable ( "cl_pitchdown", "89", 0 ); + lookstrafe = gEngfuncs.pfnRegisterVariable( "lookstrafe", "0", FCVAR_ARCHIVE ); + lookspring = gEngfuncs.pfnRegisterVariable( "lookspring", "0", FCVAR_ARCHIVE ); + cl_anglespeedkey = gEngfuncs.pfnRegisterVariable( "cl_anglespeedkey", "0.67", 0 ); + cl_yawspeed = gEngfuncs.pfnRegisterVariable( "cl_yawspeed", "210", 0 ); + cl_pitchspeed = gEngfuncs.pfnRegisterVariable( "cl_pitchspeed", "225", 0 ); + cl_upspeed = gEngfuncs.pfnRegisterVariable( "cl_upspeed", "320", 0 ); + cl_forwardspeed = gEngfuncs.pfnRegisterVariable( "cl_forwardspeed", "400", FCVAR_ARCHIVE ); + cl_backspeed = gEngfuncs.pfnRegisterVariable( "cl_backspeed", "400", FCVAR_ARCHIVE ); + cl_sidespeed = gEngfuncs.pfnRegisterVariable( "cl_sidespeed", "400", 0 ); + cl_movespeedkey = gEngfuncs.pfnRegisterVariable( "cl_movespeedkey", "0.3", 0 ); + cl_pitchup = gEngfuncs.pfnRegisterVariable( "cl_pitchup", "89", 0 ); + cl_pitchdown = gEngfuncs.pfnRegisterVariable( "cl_pitchdown", "89", 0 ); - cl_vsmoothing = gEngfuncs.pfnRegisterVariable ( "cl_vsmoothing", "0.05", FCVAR_ARCHIVE ); + cl_vsmoothing = gEngfuncs.pfnRegisterVariable( "cl_vsmoothing", "0.05", FCVAR_ARCHIVE ); - m_pitch = gEngfuncs.pfnRegisterVariable ( "m_pitch","0.022", FCVAR_ARCHIVE ); - m_yaw = gEngfuncs.pfnRegisterVariable ( "m_yaw","0.022", FCVAR_ARCHIVE ); - m_forward = gEngfuncs.pfnRegisterVariable ( "m_forward","1", FCVAR_ARCHIVE ); - m_side = gEngfuncs.pfnRegisterVariable ( "m_side","0.8", FCVAR_ARCHIVE ); + m_pitch = gEngfuncs.pfnRegisterVariable( "m_pitch","0.022", FCVAR_ARCHIVE ); + m_yaw = gEngfuncs.pfnRegisterVariable( "m_yaw","0.022", FCVAR_ARCHIVE ); + m_forward = gEngfuncs.pfnRegisterVariable( "m_forward","1", FCVAR_ARCHIVE ); + m_side = gEngfuncs.pfnRegisterVariable( "m_side","0.8", FCVAR_ARCHIVE ); // Initialize third person camera controls. CAM_Init(); @@ -992,7 +1122,7 @@ void InitInput (void) ShutdownInput ============ */ -void ShutdownInput (void) +void ShutdownInput( void ) { IN_Shutdown(); KB_Shutdown(); diff --git a/cl_dll/input_xash3d.cpp b/cl_dll/input_xash3d.cpp index dd621d19..93a7eefb 100644 --- a/cl_dll/input_xash3d.cpp +++ b/cl_dll/input_xash3d.cpp @@ -91,47 +91,46 @@ void IN_ToggleButtons( float forwardmove, float sidemove ) } } - if ( forwardmove > 0.7 && !( moveflags & F )) + if( forwardmove > 0.7 && !( moveflags & F ) ) { moveflags |= F; in_forward.state |= BUTTON_DOWN; } - if ( forwardmove < 0.7 && ( moveflags & F )) + if( forwardmove < 0.7 && ( moveflags & F ) ) { moveflags &= ~F; in_forward.state &= ~BUTTON_DOWN; } - if ( forwardmove < -0.7 && !( moveflags & B )) + if( forwardmove < -0.7 && !( moveflags & B ) ) { moveflags |= B; in_back.state |= BUTTON_DOWN; } - if ( forwardmove > -0.7 && ( moveflags & B )) + if( forwardmove > -0.7 && ( moveflags & B ) ) { moveflags &= ~B; in_back.state &= ~BUTTON_DOWN; } - if ( sidemove > 0.9 && !( moveflags & R )) + if( sidemove > 0.9 && !( moveflags & R ) ) { moveflags |= R; in_moveright.state |= BUTTON_DOWN; } - if ( sidemove < 0.9 && ( moveflags & R )) + if( sidemove < 0.9 && ( moveflags & R ) ) { moveflags &= ~R; in_moveright.state &= ~BUTTON_DOWN; } - if ( sidemove < -0.9 && !( moveflags & L )) + if( sidemove < -0.9 && !( moveflags & L ) ) { moveflags |= L; in_moveleft.state |= BUTTON_DOWN; } - if ( sidemove > -0.9 && ( moveflags & L )) + if( sidemove > -0.9 && ( moveflags & L ) ) { moveflags &= ~L; in_moveleft.state &= ~BUTTON_DOWN; } - } void IN_ClientMoveEvent( float forwardmove, float sidemove ) @@ -148,15 +147,17 @@ void IN_ClientLookEvent( float relyaw, float relpitch ) rel_yaw += relyaw; rel_pitch += relpitch; } + // Rotate camera and add move values to usercmd void IN_Move( float frametime, usercmd_t *cmd ) { Vector viewangles; gEngfuncs.GetViewAngles( viewangles ); bool fLadder = false; - if( cl_laddermode->value !=2 ) fLadder = gEngfuncs.GetLocalPlayer()->curstate.movetype == MOVETYPE_FLY; - //if(ac_forwardmove || ac_sidemove) - //gEngfuncs.Con_Printf("Move: %f %f %f %f\n", ac_forwardmove, ac_sidemove, rel_pitch, rel_yaw); + if( cl_laddermode->value != 2 ) + fLadder = gEngfuncs.GetLocalPlayer()->curstate.movetype == MOVETYPE_FLY; + //if( ac_forwardmove || ac_sidemove ) + //gEngfuncs.Con_Printf( "Move: %f %f %f %f\n", ac_forwardmove, ac_sidemove, rel_pitch, rel_yaw ); #if 0 if( in_mlook.state & 1 ) { @@ -183,30 +184,31 @@ void IN_Move( float frametime, usercmd_t *cmd ) viewangles[YAW] -= ac_sidemove * 5; ac_sidemove = 0; } - if(gHUD.m_MOTD.m_bShow) + if( gHUD.m_MOTD.m_bShow ) gHUD.m_MOTD.scroll += rel_pitch; else viewangles[PITCH] += rel_pitch; - if (viewangles[PITCH] > cl_pitchdown->value) + if( viewangles[PITCH] > cl_pitchdown->value ) viewangles[PITCH] = cl_pitchdown->value; - if (viewangles[PITCH] < -cl_pitchup->value) + if( viewangles[PITCH] < -cl_pitchup->value ) viewangles[PITCH] = -cl_pitchup->value; } float rgfl[3]; viewangles.CopyToArray( rgfl ); gEngfuncs.SetViewAngles( rgfl ); - + if( ac_movecount ) { IN_ToggleButtons( ac_forwardmove / ac_movecount, ac_sidemove / ac_movecount ); - if( ac_forwardmove ) cmd->forwardmove = ac_forwardmove * cl_forwardspeed->value / ac_movecount; - if( ac_sidemove ) cmd->sidemove = ac_sidemove * cl_sidespeed->value / ac_movecount; - if (in_speed.state & 1) + if( ac_forwardmove ) + cmd->forwardmove = ac_forwardmove * cl_forwardspeed->value / ac_movecount; + if( ac_sidemove ) + cmd->sidemove = ac_sidemove * cl_sidespeed->value / ac_movecount; + if(in_speed.state & 1) { cmd->forwardmove *= cl_movespeedkey->value; cmd->sidemove *= cl_movespeedkey->value; } - } ac_sidemove = ac_forwardmove = rel_pitch = rel_yaw = 0; @@ -219,55 +221,56 @@ extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) // perform button actions for( int i = 0; i < 5; i++ ) { - if(( mstate & (1 << i)) && !( mouse_oldbuttonstate & (1 << i))) + if( ( mstate & ( 1 << i ) ) && !( mouse_oldbuttonstate & ( 1 << i ) ) ) { gEngfuncs.Key_Event( K_MOUSE1 + i, 1 ); } - if( !( mstate & (1 << i)) && ( mouse_oldbuttonstate & (1 << i))) + if( !( mstate & ( 1 << i ) ) && ( mouse_oldbuttonstate & ( 1 << i ) ) ) { gEngfuncs.Key_Event( K_MOUSE1 + i, 0 ); } } - + mouse_oldbuttonstate = mstate; } // Stubs -extern "C" void DLLEXPORT IN_ClearStates ( void ) +extern "C" void DLLEXPORT IN_ClearStates( void ) { - //gEngfuncs.Con_Printf("IN_ClearStates\n"); + //gEngfuncs.Con_Printf( "IN_ClearStates\n" ); } -extern "C" void DLLEXPORT IN_ActivateMouse ( void ) +extern "C" void DLLEXPORT IN_ActivateMouse( void ) { - //gEngfuncs.Con_Printf("IN_ActivateMouse\n"); + //gEngfuncs.Con_Printf( "IN_ActivateMouse\n" ); } -extern "C" void DLLEXPORT IN_DeactivateMouse ( void ) +extern "C" void DLLEXPORT IN_DeactivateMouse( void ) { - //gEngfuncs.Con_Printf("IN_DeactivateMouse\n"); + //gEngfuncs.Con_Printf( "IN_DeactivateMouse\n" ); } -extern "C" void DLLEXPORT IN_Accumulate ( void ) +extern "C" void DLLEXPORT IN_Accumulate( void ) { - //gEngfuncs.Con_Printf("IN_Accumulate\n"); + //gEngfuncs.Con_Printf( "IN_Accumulate\n" ); } -void IN_Commands ( void ) +void IN_Commands( void ) { - //gEngfuncs.Con_Printf("IN_Commands\n"); + //gEngfuncs.Con_Printf( "IN_Commands\n" ); } -void IN_Shutdown ( void ) +void IN_Shutdown( void ) { } + // Register cvars and reset data void IN_Init( void ) { - sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity", "3", FCVAR_ARCHIVE ); - in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick", "0", FCVAR_ARCHIVE ); - cl_laddermode = gEngfuncs.pfnRegisterVariable ( "cl_laddermode", "2", FCVAR_ARCHIVE ); + sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity", "3", FCVAR_ARCHIVE ); + in_joystick = gEngfuncs.pfnRegisterVariable( "joystick", "0", FCVAR_ARCHIVE ); + cl_laddermode = gEngfuncs.pfnRegisterVariable( "cl_laddermode", "2", FCVAR_ARCHIVE ); ac_forwardmove = ac_sidemove = rel_yaw = rel_pitch = 0; } diff --git a/cl_dll/inputw32.cpp b/cl_dll/inputw32.cpp index 33144a8b..5c8210fa 100644 --- a/cl_dll/inputw32.cpp +++ b/cl_dll/inputw32.cpp @@ -24,30 +24,30 @@ #define MOUSE_BUTTON_COUNT 5 // Set this to 1 to show mouse cursor. Experimental -int g_iVisibleMouse = 0; +int g_iVisibleMouse = 0; extern "C" { void DLLEXPORT IN_ActivateMouse( void ); void DLLEXPORT IN_DeactivateMouse( void ); - void DLLEXPORT IN_MouseEvent (int mstate); - void DLLEXPORT IN_Accumulate (void); - void DLLEXPORT IN_ClearStates (void); + void DLLEXPORT IN_MouseEvent( int mstate ); + void DLLEXPORT IN_Accumulate( void ); + void DLLEXPORT IN_ClearStates( void ); } extern cl_enginefunc_t gEngfuncs; extern int iMouseInUse; -extern kbutton_t in_strafe; -extern kbutton_t in_mlook; -extern kbutton_t in_speed; -extern kbutton_t in_jlook; +extern kbutton_t in_strafe; +extern kbutton_t in_mlook; +extern kbutton_t in_speed; +extern kbutton_t in_jlook; -extern cvar_t *m_pitch; -extern cvar_t *m_yaw; -extern cvar_t *m_forward; -extern cvar_t *m_side; +extern cvar_t *m_pitch; +extern cvar_t *m_yaw; +extern cvar_t *m_forward; +extern cvar_t *m_side; extern cvar_t *lookstrafe; extern cvar_t *lookspring; @@ -60,26 +60,26 @@ extern cvar_t *cl_pitchspeed; extern cvar_t *cl_movespeedkey; // mouse variables -cvar_t *m_filter; -cvar_t *sensitivity; +cvar_t *m_filter; +cvar_t *sensitivity; -int mouse_buttons; -int mouse_oldbuttonstate; -POINT current_pos; -int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum; +int mouse_buttons; +int mouse_oldbuttonstate; +POINT current_pos; +int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum; -static int restore_spi; -static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; -static int mouseactive; -int mouseinitialized; -static int mouseparmsvalid; -static int mouseshowtoggle = 1; +static int restore_spi; +static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; +static int mouseactive; +int mouseinitialized; +static int mouseparmsvalid; +static int mouseshowtoggle = 1; // joystick defines and variables // where should defines be moved? #define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick #define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball -#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V +#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V #define JOY_AXIS_X 0 #define JOY_AXIS_Y 1 #define JOY_AXIS_Z 2 @@ -106,57 +106,57 @@ DWORD dwAxisFlags[JOY_MAX_AXES] = JOY_RETURNV }; -DWORD dwAxisMap[ JOY_MAX_AXES ]; -DWORD dwControlMap[ JOY_MAX_AXES ]; -PDWORD pdwRawValue[ JOY_MAX_AXES ]; +DWORD dwAxisMap[JOY_MAX_AXES]; +DWORD dwControlMap[JOY_MAX_AXES]; +PDWORD pdwRawValue[JOY_MAX_AXES]; // none of these cvars are saved over a session // this means that advanced controller configuration needs to be executed // each time. this avoids any problems with getting back to a default usage // or when changing from one controller to another. this way at least something // works. -cvar_t *in_joystick; -cvar_t *joy_name; -cvar_t *joy_advanced; -cvar_t *joy_advaxisx; -cvar_t *joy_advaxisy; -cvar_t *joy_advaxisz; -cvar_t *joy_advaxisr; -cvar_t *joy_advaxisu; -cvar_t *joy_advaxisv; -cvar_t *joy_forwardthreshold; -cvar_t *joy_sidethreshold; -cvar_t *joy_pitchthreshold; -cvar_t *joy_yawthreshold; -cvar_t *joy_forwardsensitivity; -cvar_t *joy_sidesensitivity; -cvar_t *joy_pitchsensitivity; -cvar_t *joy_yawsensitivity; -cvar_t *joy_wwhack1; -cvar_t *joy_wwhack2; +cvar_t *in_joystick; +cvar_t *joy_name; +cvar_t *joy_advanced; +cvar_t *joy_advaxisx; +cvar_t *joy_advaxisy; +cvar_t *joy_advaxisz; +cvar_t *joy_advaxisr; +cvar_t *joy_advaxisu; +cvar_t *joy_advaxisv; +cvar_t *joy_forwardthreshold; +cvar_t *joy_sidethreshold; +cvar_t *joy_pitchthreshold; +cvar_t *joy_yawthreshold; +cvar_t *joy_forwardsensitivity; +cvar_t *joy_sidesensitivity; +cvar_t *joy_pitchsensitivity; +cvar_t *joy_yawsensitivity; +cvar_t *joy_wwhack1; +cvar_t *joy_wwhack2; -int joy_avail, joy_advancedinit, joy_haspov; -DWORD joy_oldbuttonstate, joy_oldpovstate; +int joy_avail, joy_advancedinit, joy_haspov; +DWORD joy_oldbuttonstate, joy_oldpovstate; -int joy_id; -DWORD joy_flags; -DWORD joy_numbuttons; +int joy_id; +DWORD joy_flags; +DWORD joy_numbuttons; -static JOYINFOEX ji; +static JOYINFOEX ji; /* =========== Force_CenterView_f =========== */ -void Force_CenterView_f (void) +void Force_CenterView_f( void ) { vec3_t viewangles; - if (!iMouseInUse) + if( !iMouseInUse ) { gEngfuncs.GetViewAngles( (float *)viewangles ); - viewangles[PITCH] = 0; + viewangles[PITCH] = 0; gEngfuncs.SetViewAngles( (float *)viewangles ); } } @@ -166,12 +166,12 @@ void Force_CenterView_f (void) IN_ActivateMouse =========== */ -void DLLEXPORT IN_ActivateMouse (void) +void DLLEXPORT IN_ActivateMouse( void ) { - if (mouseinitialized) + if( mouseinitialized ) { - if (mouseparmsvalid) - restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0); + if( mouseparmsvalid ) + restore_spi = SystemParametersInfo( SPI_SETMOUSE, 0, newmouseparms, 0 ); mouseactive = 1; } } @@ -181,13 +181,12 @@ void DLLEXPORT IN_ActivateMouse (void) IN_DeactivateMouse =========== */ -void DLLEXPORT IN_DeactivateMouse (void) +void DLLEXPORT IN_DeactivateMouse( void ) { - if (mouseinitialized) + if( mouseinitialized ) { - if (restore_spi) - SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); - + if( restore_spi ) + SystemParametersInfo( SPI_SETMOUSE, 0, originalmouseparms, 0 ); mouseactive = 0; } } @@ -197,26 +196,26 @@ void DLLEXPORT IN_DeactivateMouse (void) IN_StartupMouse =========== */ -void IN_StartupMouse (void) +void IN_StartupMouse( void ) { - if ( gEngfuncs.CheckParm ("-nomouse", NULL ) ) - return; + if( gEngfuncs.CheckParm( "-nomouse", NULL ) ) + return; mouseinitialized = 1; - mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0); + mouseparmsvalid = SystemParametersInfo( SPI_GETMOUSE, 0, originalmouseparms, 0 ); - if (mouseparmsvalid) + if( mouseparmsvalid ) { - if ( gEngfuncs.CheckParm ("-noforcemspd", NULL ) ) + if( gEngfuncs.CheckParm( "-noforcemspd", NULL ) ) newmouseparms[2] = originalmouseparms[2]; - if ( gEngfuncs.CheckParm ("-noforcemaccel", NULL ) ) + if( gEngfuncs.CheckParm( "-noforcemaccel", NULL ) ) { newmouseparms[0] = originalmouseparms[0]; newmouseparms[1] = originalmouseparms[1]; } - if ( gEngfuncs.CheckParm ("-noforcemparms", NULL ) ) + if( gEngfuncs.CheckParm( "-noforcemparms", NULL ) ) { newmouseparms[0] = originalmouseparms[0]; newmouseparms[1] = originalmouseparms[1]; @@ -232,7 +231,7 @@ void IN_StartupMouse (void) IN_Shutdown =========== */ -void IN_Shutdown (void) +void IN_Shutdown( void ) { IN_DeactivateMouse (); } @@ -258,7 +257,7 @@ FIXME: Call through to engine? */ void IN_ResetMouse( void ) { - SetCursorPos ( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() ); + SetCursorPos ( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() ); } /* @@ -266,29 +265,29 @@ void IN_ResetMouse( void ) IN_MouseEvent =========== */ -void DLLEXPORT IN_MouseEvent (int mstate) +void DLLEXPORT IN_MouseEvent( int mstate ) { - int i; + int i; - if ( iMouseInUse || g_iVisibleMouse ) + if( iMouseInUse || g_iVisibleMouse ) return; // perform button actions - for (i=0 ; ivalue) + if( m_filter->value ) { - mouse_x = (mx + old_mouse_x) * 0.5; - mouse_y = (my + old_mouse_y) * 0.5; + mouse_x = ( mx + old_mouse_x ) * 0.5; + mouse_y = ( my + old_mouse_y ) * 0.5; } else { @@ -330,7 +329,7 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd) old_mouse_x = mx; old_mouse_y = my; - if ( gHUD.GetSensitivity() != 0 ) + if( gHUD.GetSensitivity() != 0 ) { mouse_x *= gHUD.GetSensitivity(); mouse_y *= gHUD.GetSensitivity(); @@ -342,22 +341,22 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd) } // add mouse X/Y movement to cmd - if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) )) + if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_mlook.state & 1 ) ) ) cmd->sidemove += m_side->value * mouse_x; else viewangles[YAW] -= m_yaw->value * mouse_x; - if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) + if( ( in_mlook.state & 1 ) && !( in_strafe.state & 1 ) ) { viewangles[PITCH] += m_pitch->value * mouse_y; - if (viewangles[PITCH] > cl_pitchdown->value) + if( viewangles[PITCH] > cl_pitchdown->value ) viewangles[PITCH] = cl_pitchdown->value; - if (viewangles[PITCH] < -cl_pitchup->value) + if( viewangles[PITCH] < -cl_pitchup->value ) viewangles[PITCH] = -cl_pitchup->value; } else { - if ((in_strafe.state & 1) && gEngfuncs.IsNoClipping() ) + if( ( in_strafe.state & 1 ) && gEngfuncs.IsNoClipping() ) { cmd->upmove -= m_forward->value * mouse_y; } @@ -368,7 +367,7 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd) } // if the mouse has moved, force it to the center, so there's room to move - if ( mx || my ) + if( mx || my ) { IN_ResetMouse(); } @@ -394,14 +393,14 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd) IN_Accumulate =========== */ -void DLLEXPORT IN_Accumulate (void) +void DLLEXPORT IN_Accumulate( void ) { //only accumulate mouse if we are not moving the camera with the mouse - if ( !iMouseInUse && !g_iVisibleMouse ) + if( !iMouseInUse && !g_iVisibleMouse ) { - if (mouseactive) - { - GetCursorPos (¤t_pos); + if( mouseactive ) + { + GetCursorPos( ¤t_pos ); mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); @@ -410,7 +409,6 @@ void DLLEXPORT IN_Accumulate (void) IN_ResetMouse(); } } - } /* @@ -418,9 +416,9 @@ void DLLEXPORT IN_Accumulate (void) IN_ClearStates =================== */ -void DLLEXPORT IN_ClearStates (void) +void DLLEXPORT IN_ClearStates( void ) { - if ( !mouseactive ) + if( !mouseactive ) return; mx_accum = 0; @@ -433,50 +431,50 @@ void DLLEXPORT IN_ClearStates (void) IN_StartupJoystick =============== */ -void IN_StartupJoystick (void) +void IN_StartupJoystick( void ) { - int numdevs; - JOYCAPS jc; - MMRESULT mmr; - - // assume no joystick + int numdevs; + JOYCAPS jc; + MMRESULT mmr; + + // assume no joystick joy_avail = 0; // abort startup if user requests no joystick - if ( gEngfuncs.CheckParm ("-nojoy", NULL ) ) - return; - + if( gEngfuncs.CheckParm( "-nojoy", NULL ) ) + return; + // verify joystick driver is present - if ((numdevs = joyGetNumDevs ()) == 0) + if( ( numdevs = joyGetNumDevs() ) == 0 ) { - gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); + gEngfuncs.Con_DPrintf( "joystick not found -- driver not present\n\n" ); return; } // cycle through the joystick ids for the first valid one - for (joy_id=0 ; joy_idvalue == 0.0) + if( joy_advanced->value == 0.0 ) { // default joystick initialization // 2 axes only with joystick control @@ -554,134 +549,130 @@ void Joy_AdvancedUpdate_f (void) } else { - if ( strcmp ( joy_name->string, "joystick") != 0 ) + if( strcmp( joy_name->string, "joystick" ) != 0 ) { // notify user of advanced controller - gEngfuncs.Con_Printf ("\n%s configured\n\n", joy_name->string); + gEngfuncs.Con_Printf( "\n%s configured\n\n", joy_name->string ); } // advanced initialization here // data supplied by user via joy_axisn cvars - dwTemp = (DWORD) joy_advaxisx->value; + dwTemp = (DWORD)joy_advaxisx->value; dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f; dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD) joy_advaxisy->value; + dwTemp = (DWORD)joy_advaxisy->value; dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f; dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD) joy_advaxisz->value; + dwTemp = (DWORD)joy_advaxisz->value; dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f; dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD) joy_advaxisr->value; + dwTemp = (DWORD)joy_advaxisr->value; dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f; dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD) joy_advaxisu->value; + dwTemp = (DWORD)joy_advaxisu->value; dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f; dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD) joy_advaxisv->value; + dwTemp = (DWORD)joy_advaxisv->value; dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f; dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; } // compute the axes to collect from DirectInput joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV; - for (i = 0; i < JOY_MAX_AXES; i++) + for( i = 0; i < JOY_MAX_AXES; i++ ) { - if (dwAxisMap[i] != AxisNada) + if( dwAxisMap[i] != AxisNada ) { joy_flags |= dwAxisFlags[i]; } } } - /* =========== IN_Commands =========== */ -void IN_Commands (void) +void IN_Commands( void ) { - int i, key_index; - DWORD buttonstate, povstate; + int i, key_index; + DWORD buttonstate, povstate; - if (!joy_avail) + if( !joy_avail ) { return; } - // loop through the joystick buttons // key a joystick event or auxillary event for higher number buttons for each state change buttonstate = ji.dwButtons; - for (i=0 ; i < (int)joy_numbuttons ; i++) + for( i = 0; i < (int)joy_numbuttons; i++ ) { - if ( (buttonstate & (1<value != 0.0) + if( joy_wwhack1->value != 0.0 ) { ji.dwUpos += 100; } @@ -692,28 +683,26 @@ int IN_ReadJoystick (void) // read error occurred // turning off the joystick seems too harsh for 1 read error,\ // but what should be done? - // Con_Printf ("IN_ReadJoystick: no response\n"); + // Con_Printf( "IN_ReadJoystick: no response\n" ); // joy_avail = 0; return 0; } } - /* =========== IN_JoyMove =========== */ -void IN_JoyMove ( float frametime, usercmd_t *cmd ) +void IN_JoyMove( float frametime, usercmd_t *cmd ) { - float speed, aspeed; - float fAxisValue, fTemp; - int i; + float speed, aspeed; + float fAxisValue, fTemp; + int i; vec3_t viewangles; gEngfuncs.GetViewAngles( (float *)viewangles ); - // complete initialization if first time in // this is needed as cvars are not available at initialization time if( joy_advancedinit != 1 ) @@ -723,18 +712,18 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) } // verify joystick is available and that the user wants to use it - if (!joy_avail || !in_joystick->value) + if( !joy_avail || !in_joystick->value ) { return; } - + // collect the joystick data, if possible - if (IN_ReadJoystick () != 1) + if( IN_ReadJoystick () != 1 ) { return; } - if (in_speed.state & 1) + if( in_speed.state & 1 ) speed = cl_movespeedkey->value; else speed = 1; @@ -742,126 +731,121 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) aspeed = speed * frametime; // loop through the axes - for (i = 0; i < JOY_MAX_AXES; i++) + for( i = 0; i < JOY_MAX_AXES; i++ ) { // get the floating point zero-centered, potentially-inverted data for the current axis fAxisValue = (float) *pdwRawValue[i]; // move centerpoint to zero fAxisValue -= 32768.0; - if (joy_wwhack2->value != 0.0) + if( joy_wwhack2->value != 0.0 ) { - if (dwAxisMap[i] == AxisTurn) + if( dwAxisMap[i] == AxisTurn ) { // this is a special formula for the Logitech WingMan Warrior // y=ax^b; where a = 300 and b = 1.3 // also x values are in increments of 800 (so this is factored out) // then bounds check result to level out excessively high spin rates - fTemp = 300.0 * pow(abs(fAxisValue) / 800.0, 1.3); - if (fTemp > 14000.0) + fTemp = 300.0 * pow( abs( fAxisValue ) / 800.0, 1.3 ); + if( fTemp > 14000.0 ) fTemp = 14000.0; // restore direction information - fAxisValue = (fAxisValue > 0.0) ? fTemp : -fTemp; + fAxisValue = ( fAxisValue > 0.0 ) ? fTemp : -fTemp; } } - // convert range from -32768..32767 to -1..1 + // convert range from -32768..32767 to -1..1 fAxisValue /= 32768.0; - switch (dwAxisMap[i]) + switch( dwAxisMap[i] ) { case AxisForward: - if ((joy_advanced->value == 0.0) && (in_jlook.state & 1)) + if( ( joy_advanced->value == 0.0 ) && ( in_jlook.state & 1 ) ) { // user wants forward control to become look control - if (fabs(fAxisValue) > joy_pitchthreshold->value) - { + if( fabs( fAxisValue ) > joy_pitchthreshold->value ) + { // if mouse invert is on, invert the joystick pitch value // only absolute control support here (joy_advanced is 0) - if (m_pitch->value < 0.0) + if( m_pitch->value < 0.0 ) { - viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + viewangles[PITCH] -= ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; } else { - viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; } } } else { // user wants forward control to be forward control - if (fabs(fAxisValue) > joy_forwardthreshold->value) + if( fabs( fAxisValue ) > joy_forwardthreshold->value ) { - cmd->forwardmove += (fAxisValue * joy_forwardsensitivity->value) * speed * cl_forwardspeed->value; + cmd->forwardmove += ( fAxisValue * joy_forwardsensitivity->value ) * speed * cl_forwardspeed->value; } } break; - case AxisSide: - if (fabs(fAxisValue) > joy_sidethreshold->value) + if( fabs( fAxisValue ) > joy_sidethreshold->value ) { - cmd->sidemove += (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; + cmd->sidemove += ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value; } break; - case AxisTurn: - if ((in_strafe.state & 1) || (lookstrafe->value && (in_jlook.state & 1))) + if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_jlook.state & 1 ) ) ) { // user wants turn control to become side control - if (fabs(fAxisValue) > joy_sidethreshold->value) + if( fabs( fAxisValue ) > joy_sidethreshold->value ) { - cmd->sidemove -= (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; + cmd->sidemove -= ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value; } } else { // user wants turn control to be turn control - if (fabs(fAxisValue) > joy_yawthreshold->value) + if( fabs( fAxisValue ) > joy_yawthreshold->value ) { - if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) + if( dwControlMap[i] == JOY_ABSOLUTE_AXIS ) { - viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * aspeed * cl_yawspeed->value; + viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * aspeed * cl_yawspeed->value; } else { - viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * speed * 180.0; + viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * speed * 180.0; } } } break; - case AxisLook: - if (in_jlook.state & 1) + if( in_jlook.state & 1 ) { - if (fabs(fAxisValue) > joy_pitchthreshold->value) + if( fabs( fAxisValue ) > joy_pitchthreshold->value ) { // pitch movement detected and pitch movement desired by user - if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) + if( dwControlMap[i] == JOY_ABSOLUTE_AXIS ) { - viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; } else { - viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * speed * 180.0; + viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * speed * 180.0; } } } break; - default: break; } } // bounds check pitch - if (viewangles[PITCH] > cl_pitchdown->value) + if( viewangles[PITCH] > cl_pitchdown->value ) viewangles[PITCH] = cl_pitchdown->value; - if (viewangles[PITCH] < -cl_pitchup->value) + if( viewangles[PITCH] < -cl_pitchup->value ) viewangles[PITCH] = -cl_pitchup->value; gEngfuncs.SetViewAngles( (float *)viewangles ); - } /* @@ -869,14 +853,14 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) IN_Move =========== */ -void IN_Move ( float frametime, usercmd_t *cmd) +void IN_Move( float frametime, usercmd_t *cmd ) { - if ( !iMouseInUse && mouseactive ) + if( !iMouseInUse && mouseactive ) { - IN_MouseMove ( frametime, cmd); + IN_MouseMove( frametime, cmd ); } - IN_JoyMove ( frametime, cmd); + IN_JoyMove( frametime, cmd ); } /* @@ -884,30 +868,30 @@ void IN_Move ( float frametime, usercmd_t *cmd) IN_Init =========== */ -void IN_Init (void) +void IN_Init( void ) { - m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); - sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. + m_filter = gEngfuncs.pfnRegisterVariable( "m_filter","0", FCVAR_ARCHIVE ); + sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. - in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick","0", FCVAR_ARCHIVE ); - joy_name = gEngfuncs.pfnRegisterVariable ( "joyname", "joystick", 0 ); - joy_advanced = gEngfuncs.pfnRegisterVariable ( "joyadvanced", "0", 0 ); - joy_advaxisx = gEngfuncs.pfnRegisterVariable ( "joyadvaxisx", "0", 0 ); - joy_advaxisy = gEngfuncs.pfnRegisterVariable ( "joyadvaxisy", "0", 0 ); - joy_advaxisz = gEngfuncs.pfnRegisterVariable ( "joyadvaxisz", "0", 0 ); - joy_advaxisr = gEngfuncs.pfnRegisterVariable ( "joyadvaxisr", "0", 0 ); - joy_advaxisu = gEngfuncs.pfnRegisterVariable ( "joyadvaxisu", "0", 0 ); - joy_advaxisv = gEngfuncs.pfnRegisterVariable ( "joyadvaxisv", "0", 0 ); - joy_forwardthreshold = gEngfuncs.pfnRegisterVariable ( "joyforwardthreshold", "0.15", 0 ); - joy_sidethreshold = gEngfuncs.pfnRegisterVariable ( "joysidethreshold", "0.15", 0 ); - joy_pitchthreshold = gEngfuncs.pfnRegisterVariable ( "joypitchthreshold", "0.15", 0 ); - joy_yawthreshold = gEngfuncs.pfnRegisterVariable ( "joyyawthreshold", "0.15", 0 ); - joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable ( "joyforwardsensitivity", "-1.0", 0 ); - joy_sidesensitivity = gEngfuncs.pfnRegisterVariable ( "joysidesensitivity", "-1.0", 0 ); - joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable ( "joypitchsensitivity", "1.0", 0 ); - joy_yawsensitivity = gEngfuncs.pfnRegisterVariable ( "joyyawsensitivity", "-1.0", 0 ); - joy_wwhack1 = gEngfuncs.pfnRegisterVariable ( "joywwhack1", "0.0", 0 ); - joy_wwhack2 = gEngfuncs.pfnRegisterVariable ( "joywwhack2", "0.0", 0 ); + in_joystick = gEngfuncs.pfnRegisterVariable( "joystick","0", FCVAR_ARCHIVE ); + joy_name = gEngfuncs.pfnRegisterVariable( "joyname", "joystick", 0 ); + joy_advanced = gEngfuncs.pfnRegisterVariable( "joyadvanced", "0", 0 ); + joy_advaxisx = gEngfuncs.pfnRegisterVariable( "joyadvaxisx", "0", 0 ); + joy_advaxisy = gEngfuncs.pfnRegisterVariable( "joyadvaxisy", "0", 0 ); + joy_advaxisz = gEngfuncs.pfnRegisterVariable( "joyadvaxisz", "0", 0 ); + joy_advaxisr = gEngfuncs.pfnRegisterVariable( "joyadvaxisr", "0", 0 ); + joy_advaxisu = gEngfuncs.pfnRegisterVariable( "joyadvaxisu", "0", 0 ); + joy_advaxisv = gEngfuncs.pfnRegisterVariable( "joyadvaxisv", "0", 0 ); + joy_forwardthreshold = gEngfuncs.pfnRegisterVariable( "joyforwardthreshold", "0.15", 0 ); + joy_sidethreshold = gEngfuncs.pfnRegisterVariable( "joysidethreshold", "0.15", 0 ); + joy_pitchthreshold = gEngfuncs.pfnRegisterVariable( "joypitchthreshold", "0.15", 0 ); + joy_yawthreshold = gEngfuncs.pfnRegisterVariable( "joyyawthreshold", "0.15", 0 ); + joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable( "joyforwardsensitivity", "-1.0", 0 ); + joy_sidesensitivity = gEngfuncs.pfnRegisterVariable( "joysidesensitivity", "-1.0", 0 ); + joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable( "joypitchsensitivity", "1.0", 0 ); + joy_yawsensitivity = gEngfuncs.pfnRegisterVariable( "joyyawsensitivity", "-1.0", 0 ); + joy_wwhack1 = gEngfuncs.pfnRegisterVariable( "joywwhack1", "0.0", 0 ); + joy_wwhack2 = gEngfuncs.pfnRegisterVariable( "joywwhack2", "0.0", 0 ); gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); diff --git a/cl_dll/kbutton.h b/cl_dll/kbutton.h index 23cd8acc..29accdf5 100644 --- a/cl_dll/kbutton.h +++ b/cl_dll/kbutton.h @@ -11,8 +11,7 @@ typedef struct kbutton_s { - int down[2]; // key nums holding it down - int state; // low bit is down state + int down[2]; // key nums holding it down + int state; // low bit is down state } kbutton_t; - -#endif // !KBUTTONH \ No newline at end of file +#endif // !KBUTTONH diff --git a/cl_dll/menu.cpp b/cl_dll/menu.cpp index 2ed362fb..5f710a33 100644 --- a/cl_dll/menu.cpp +++ b/cl_dll/menu.cpp @@ -17,6 +17,7 @@ // // generic menu handler // + #include "hud.h" #include "cl_util.h" #include "parsemsg.h" @@ -31,7 +32,7 @@ int KB_ConvertString( char *in, char **ppout ); DECLARE_MESSAGE( m_Menu, ShowMenu ) -int CHudMenu :: Init( void ) +int CHudMenu::Init( void ) { gHUD.AddHudElem( this ); @@ -42,33 +43,34 @@ int CHudMenu :: Init( void ) return 1; } -void CHudMenu :: InitHUDData( void ) +void CHudMenu::InitHUDData( void ) { m_fMenuDisplayed = 0; m_bitsValidSlots = 0; Reset(); } -void CHudMenu :: Reset( void ) +void CHudMenu::Reset( void ) { g_szPrelocalisedMenuString[0] = 0; m_fWaitingForMore = FALSE; } -int CHudMenu :: VidInit( void ) +int CHudMenu::VidInit( void ) { return 1; } -int CHudMenu :: Draw( float flTime ) +int CHudMenu::Draw( float flTime ) { int i; // check for if menu is set to disappear - if ( m_flShutoffTime > 0 ) + if( m_flShutoffTime > 0 ) { - if ( m_flShutoffTime <= gHUD.m_flTime ) - { // times up, shutoff + if( m_flShutoffTime <= gHUD.m_flTime ) + { + // times up, shutoff m_fMenuDisplayed = 0; m_iFlags &= ~HUD_ACTIVE; return 1; @@ -76,43 +78,39 @@ int CHudMenu :: Draw( float flTime ) } // don't draw the menu if the scoreboard is being shown - - - // draw the menu, along the left-hand side of the screen - // count the number of newlines int nlc = 0; - for ( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ ) + for( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ ) { if ( g_szMenuString[i] == '\n' ) nlc++; } // center it - int y = (ScreenHeight/2) - ((nlc/2)*12) - 40; // make sure it is above the say text + int y = ( ScreenHeight / 2 ) - ( ( nlc / 2 ) * 12 ) - 40; // make sure it is above the say text int x = 20; i = 0; - while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' ) + while( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' ) { gHUD.DrawHudString( x, y, 320, g_szMenuString + i, 255, 255, 255 ); y += 12; - while ( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' ) + while( i < MAX_MENU_STRING && g_szMenuString[i] != '\0' && g_szMenuString[i] != '\n' ) i++; - if ( g_szMenuString[i] == '\n' ) + if( g_szMenuString[i] == '\n' ) i++; } - + return 1; } // selects an item from the menu -void CHudMenu :: SelectMenuItem( int menu_item ) +void CHudMenu::SelectMenuItem( int menu_item ) { // if menu_item is in a valid slot, send a menuselect command to the server - if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) ) + if( ( menu_item > 0 ) && ( m_bitsValidSlots & ( 1 << ( menu_item - 1 ) ) ) ) { char szbuf[32]; sprintf( szbuf, "menuselect %d\n", menu_item ); @@ -124,7 +122,6 @@ void CHudMenu :: SelectMenuItem( int menu_item ) } } - // Message handler for ShowMenu message // takes four values: // short: a bitfield of keys that are valid input @@ -132,7 +129,7 @@ void CHudMenu :: SelectMenuItem( int menu_item ) // byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, FALSE if it's the last string // string: menu string to display // if this message is never received, then scores will simply be the combined totals of the players. -int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) +int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) { char *temp = NULL; @@ -142,29 +139,31 @@ int CHudMenu :: MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) int DisplayTime = READ_CHAR(); int NeedMore = READ_BYTE(); - if ( DisplayTime > 0 ) + if( DisplayTime > 0 ) m_flShutoffTime = DisplayTime + gHUD.m_flTime; else m_flShutoffTime = -1; - if ( m_bitsValidSlots ) + if( m_bitsValidSlots ) { - if ( !m_fWaitingForMore ) // this is the start of a new menu + if( !m_fWaitingForMore ) // this is the start of a new menu { strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING ); } else - { // append to the current menu string - strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen(g_szPrelocalisedMenuString) ); + { + // append to the current menu string + strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen( g_szPrelocalisedMenuString ) ); } - g_szPrelocalisedMenuString[MAX_MENU_STRING-1] = 0; // ensure null termination (strncat/strncpy does not) + g_szPrelocalisedMenuString[MAX_MENU_STRING - 1] = 0; // ensure null termination (strncat/strncpy does not) - if ( !NeedMore ) - { // we have the whole string, so we can localise it now + if( !NeedMore ) + { + // we have the whole string, so we can localise it now strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) ); // Swap in characters - if ( KB_ConvertString( g_szMenuString, &temp ) ) + if( KB_ConvertString( g_szMenuString, &temp ) ) { strcpy( g_szMenuString, temp ); free( temp ); diff --git a/cl_dll/message.cpp b/cl_dll/message.cpp index bb93bb5a..a9c706ec 100644 --- a/cl_dll/message.cpp +++ b/cl_dll/message.cpp @@ -32,12 +32,12 @@ client_textmessage_t g_pCustomMessage; char *g_pCustomName = "Custom"; char g_pCustomText[1024]; -int CHudMessage::Init(void) +int CHudMessage::Init( void ) { HOOK_MESSAGE( HudText ); HOOK_MESSAGE( GameTitle ); - gHUD.AddHudElem(this); + gHUD.AddHudElem( this ); Reset(); @@ -52,33 +52,31 @@ int CHudMessage::VidInit( void ) return 1; } - void CHudMessage::Reset( void ) { - memset( m_pMessages, 0, sizeof( m_pMessages[0] ) * maxHUDMessages ); - memset( m_startTime, 0, sizeof( m_startTime[0] ) * maxHUDMessages ); - + memset( m_pMessages, 0, sizeof(m_pMessages[0]) * maxHUDMessages ); + memset( m_startTime, 0, sizeof(m_startTime[0]) * maxHUDMessages ); + m_gameTitleTime = 0; m_pGameTitle = NULL; } - float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float localTime ) { float fadeTime = fadein + hold; float fadeBlend; - if ( localTime < 0 ) + if( localTime < 0 ) return 0; - if ( localTime < fadein ) + if( localTime < fadein ) { - fadeBlend = 1 - ((fadein - localTime) / fadein); + fadeBlend = 1 - ( ( fadein - localTime ) / fadein ); } - else if ( localTime > fadeTime ) + else if( localTime > fadeTime ) { - if ( fadeout > 0 ) - fadeBlend = 1 - ((localTime - fadeTime) / fadeout); + if( fadeout > 0 ) + fadeBlend = 1 - ( ( localTime - fadeTime ) / fadeout ); else fadeBlend = 0; } @@ -89,42 +87,41 @@ float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float loc } -int CHudMessage::XPosition( float x, int width, int totalWidth ) +int CHudMessage::XPosition( float x, int width, int totalWidth ) { int xPos; - if ( x == -1 ) + if( x == -1 ) { - xPos = (ScreenWidth - width) / 2; + xPos = ( ScreenWidth - width ) / 2; } else { - if ( x < 0 ) - xPos = (1.0 + x) * ScreenWidth - totalWidth; // Alight right + if( x < 0 ) + xPos = ( 1.0 + x ) * ScreenWidth - totalWidth; // Alight right else xPos = x * ScreenWidth; } - if ( xPos + width > ScreenWidth ) + if( xPos + width > ScreenWidth ) xPos = ScreenWidth - width; - else if ( xPos < 0 ) + else if( xPos < 0 ) xPos = 0; return xPos; } - int CHudMessage::YPosition( float y, int height ) { int yPos; - if ( y == -1 ) // Centered? - yPos = (ScreenHeight - height) * 0.5; + if( y == -1 ) // Centered? + yPos = ( ScreenHeight - height ) * 0.5; else { // Alight bottom? if ( y < 0 ) - yPos = (1.0 + y) * ScreenHeight - height; // Alight bottom + yPos = ( 1.0 + y ) * ScreenHeight - height; // Alight bottom else // align top yPos = y * ScreenHeight; } @@ -137,7 +134,6 @@ int CHudMessage::YPosition( float y, int height ) return yPos; } - void CHudMessage::MessageScanNextChar( void ) { int srcRed, srcGreen, srcBlue, destRed = 0, destGreen = 0, destBlue = 0; @@ -156,10 +152,9 @@ void CHudMessage::MessageScanNextChar( void ) destRed = destGreen = destBlue = 0; blend = m_parms.fadeBlend; break; - case 2: m_parms.charTime += m_parms.pMessage->fadein; - if ( m_parms.charTime > m_parms.time ) + if( m_parms.charTime > m_parms.time ) { srcRed = srcGreen = srcBlue = 0; blend = 0; // pure source @@ -185,23 +180,22 @@ void CHudMessage::MessageScanNextChar( void ) } break; } - if ( blend > 255 ) + if( blend > 255 ) blend = 255; - else if ( blend < 0 ) + else if( blend < 0 ) blend = 0; - m_parms.r = ((srcRed * (255-blend)) + (destRed * blend)) >> 8; - m_parms.g = ((srcGreen * (255-blend)) + (destGreen * blend)) >> 8; - m_parms.b = ((srcBlue * (255-blend)) + (destBlue * blend)) >> 8; + m_parms.r = ( ( srcRed * ( 255 - blend ) ) + ( destRed * blend ) ) >> 8; + m_parms.g = ( ( srcGreen * (255 - blend ) ) + ( destGreen * blend ) ) >> 8; + m_parms.b = ( ( srcBlue * ( 255 - blend ) ) + ( destBlue * blend ) ) >> 8; - if ( m_parms.pMessage->effect == 1 && m_parms.charTime != 0 ) + if( m_parms.pMessage->effect == 1 && m_parms.charTime != 0 ) { - if ( m_parms.x >= 0 && m_parms.y >= 0 && (m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ]) <= ScreenWidth ) + if( m_parms.x >= 0 && m_parms.y >= 0 && ( m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text] ) <= ScreenWidth ) TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2 ); } } - void CHudMessage::MessageScanStart( void ) { switch( m_parms.pMessage->effect ) @@ -212,14 +206,14 @@ void CHudMessage::MessageScanStart( void ) m_parms.fadeTime = m_parms.pMessage->fadein + m_parms.pMessage->holdtime; - if ( m_parms.time < m_parms.pMessage->fadein ) + if( m_parms.time < m_parms.pMessage->fadein ) { - m_parms.fadeBlend = ((m_parms.pMessage->fadein - m_parms.time) * (1.0/m_parms.pMessage->fadein) * 255); + m_parms.fadeBlend = ( ( m_parms.pMessage->fadein - m_parms.time ) * ( 1.0 / m_parms.pMessage->fadein ) * 255 ); } - else if ( m_parms.time > m_parms.fadeTime ) + else if( m_parms.time > m_parms.fadeTime ) { - if ( m_parms.pMessage->fadeout > 0 ) - m_parms.fadeBlend = (((m_parms.time - m_parms.fadeTime) / m_parms.pMessage->fadeout) * 255); + if( m_parms.pMessage->fadeout > 0 ) + m_parms.fadeBlend = ( ( ( m_parms.time - m_parms.fadeTime ) / m_parms.pMessage->fadeout) * 255); else m_parms.fadeBlend = 255; // Pure dest (off) } @@ -227,15 +221,14 @@ void CHudMessage::MessageScanStart( void ) m_parms.fadeBlend = 0; // Pure source (on) m_parms.charTime = 0; - if ( m_parms.pMessage->effect == 1 && (rand()%100) < 10 ) + if( m_parms.pMessage->effect == 1 && ( rand() % 100 ) < 10 ) m_parms.charTime = 1; break; - case 2: m_parms.fadeTime = (m_parms.pMessage->fadein * m_parms.length) + m_parms.pMessage->holdtime; if ( m_parms.time > m_parms.fadeTime && m_parms.pMessage->fadeout > 0 ) - m_parms.fadeBlend = (((m_parms.time - m_parms.fadeTime) / m_parms.pMessage->fadeout) * 255); + m_parms.fadeBlend = ( ( ( m_parms.time - m_parms.fadeTime ) / m_parms.pMessage->fadeout ) * 255 ); else m_parms.fadeBlend = 0; break; @@ -257,12 +250,12 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) length = 0; width = 0; m_parms.totalWidth = 0; - while ( *pText ) + while( *pText ) { - if ( *pText == '\n' ) + if( *pText == '\n' ) { m_parms.lines++; - if ( width > m_parms.totalWidth ) + if( width > m_parms.totalWidth ) m_parms.totalWidth = width; width = 0; } @@ -272,8 +265,7 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) length++; } m_parms.length = length; - m_parms.totalHeight = (m_parms.lines * gHUD.m_scrinfo.iCharHeight); - + m_parms.totalHeight = ( m_parms.lines * gHUD.m_scrinfo.iCharHeight ); m_parms.y = YPosition( pMessage->y, m_parms.totalHeight ); pText = pMessage->pMessage; @@ -282,11 +274,11 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) MessageScanStart(); - for ( i = 0; i < m_parms.lines; i++ ) + for( i = 0; i < m_parms.lines; i++ ) { m_parms.lineLength = 0; m_parms.width = 0; - while ( *pText && *pText != '\n' ) + while( *pText && *pText != '\n' ) { unsigned char c = *pText; line[m_parms.lineLength] = c; @@ -299,13 +291,13 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) m_parms.x = XPosition( pMessage->x, m_parms.width, m_parms.totalWidth ); - for ( j = 0; j < m_parms.lineLength; j++ ) + for( j = 0; j < m_parms.lineLength; j++ ) { m_parms.text = line[j]; - int next = m_parms.x + gHUD.m_scrinfo.charWidths[ m_parms.text ]; + int next = m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text]; MessageScanNextChar(); - - if ( m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth ) + + if( m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth ) TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.r, m_parms.g, m_parms.b ); m_parms.x = next; } @@ -314,7 +306,6 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) } } - int CHudMessage::Draw( float fTime ) { int i, drawn; @@ -323,53 +314,52 @@ int CHudMessage::Draw( float fTime ) drawn = 0; - if ( m_gameTitleTime > 0 ) + if( m_gameTitleTime > 0 ) { float localTime = gHUD.m_flTime - m_gameTitleTime; float brightness; // Maybe timer isn't set yet - if ( m_gameTitleTime > gHUD.m_flTime ) + if( m_gameTitleTime > gHUD.m_flTime ) m_gameTitleTime = gHUD.m_flTime; - if ( localTime > (m_pGameTitle->fadein + m_pGameTitle->holdtime + m_pGameTitle->fadeout) ) + if( localTime > ( m_pGameTitle->fadein + m_pGameTitle->holdtime + m_pGameTitle->fadeout ) ) m_gameTitleTime = 0; else { brightness = FadeBlend( m_pGameTitle->fadein, m_pGameTitle->fadeout, m_pGameTitle->holdtime, localTime ); - int halfWidth = gHUD.GetSpriteRect(m_HUD_title_half).right - gHUD.GetSpriteRect(m_HUD_title_half).left; - int fullWidth = halfWidth + gHUD.GetSpriteRect(m_HUD_title_life).right - gHUD.GetSpriteRect(m_HUD_title_life).left; - int fullHeight = gHUD.GetSpriteRect(m_HUD_title_half).bottom - gHUD.GetSpriteRect(m_HUD_title_half).top; + int halfWidth = gHUD.GetSpriteRect( m_HUD_title_half ).right - gHUD.GetSpriteRect( m_HUD_title_half ).left; + int fullWidth = halfWidth + gHUD.GetSpriteRect( m_HUD_title_life ).right - gHUD.GetSpriteRect( m_HUD_title_life ).left; + int fullHeight = gHUD.GetSpriteRect( m_HUD_title_half ).bottom - gHUD.GetSpriteRect( m_HUD_title_half ).top; int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth ); int y = YPosition( m_pGameTitle->y, fullHeight ); + SPR_Set( gHUD.GetSprite( m_HUD_title_half ), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 ); + SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_title_half ) ); - SPR_Set( gHUD.GetSprite(m_HUD_title_half), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 ); - SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_title_half) ); - - SPR_Set( gHUD.GetSprite(m_HUD_title_life), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 ); - SPR_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect(m_HUD_title_life) ); + SPR_Set( gHUD.GetSprite( m_HUD_title_life ), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 ); + SPR_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect( m_HUD_title_life ) ); drawn = 1; } } // Fixup level transitions - for ( i = 0; i < maxHUDMessages; i++ ) + for( i = 0; i < maxHUDMessages; i++ ) { // Assume m_parms.time contains last time - if ( m_pMessages[i] ) + if( m_pMessages[i] ) { pMessage = m_pMessages[i]; - if ( m_startTime[i] > gHUD.m_flTime ) + if( m_startTime[i] > gHUD.m_flTime ) m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2; // Server takes 0.2 seconds to spawn, adjust for this } } - for ( i = 0; i < maxHUDMessages; i++ ) + for( i = 0; i < maxHUDMessages; i++ ) { - if ( m_pMessages[i] ) + if( m_pMessages[i] ) { pMessage = m_pMessages[i]; @@ -380,14 +370,14 @@ int CHudMessage::Draw( float fTime ) case 1: endTime = m_startTime[i] + pMessage->fadein + pMessage->fadeout + pMessage->holdtime; break; - + // Fade in is per character in scanning messages case 2: - endTime = m_startTime[i] + (pMessage->fadein * strlen( pMessage->pMessage )) + pMessage->fadeout + pMessage->holdtime; + endTime = m_startTime[i] + ( pMessage->fadein * strlen( pMessage->pMessage ) ) + pMessage->fadeout + pMessage->holdtime; break; } - if ( fTime <= endTime ) + if( fTime <= endTime ) { float messageTime = fTime - m_startTime[i]; @@ -410,29 +400,28 @@ int CHudMessage::Draw( float fTime ) // Remember the time -- to fix up level transitions m_parms.time = gHUD.m_flTime; // Don't call until we get another message - if ( !drawn ) + if( !drawn ) m_iFlags &= ~HUD_ACTIVE; return 1; } - void CHudMessage::MessageAdd( const char *pName, float time ) { - int i,j; + int i, j; client_textmessage_t *tempMessage; - for ( i = 0; i < maxHUDMessages; i++ ) + for( i = 0; i < maxHUDMessages; i++ ) { - if ( !m_pMessages[i] ) + if( !m_pMessages[i] ) { // Trim off a leading # if it's there - if ( pName[0] == '#' ) - tempMessage = TextMessageGet( pName+1 ); + if( pName[0] == '#' ) + tempMessage = TextMessageGet( pName + 1 ); else tempMessage = TextMessageGet( pName ); // If we couldnt find it in the titles.txt, just create it - if ( !tempMessage ) + if( !tempMessage ) { g_pCustomMessage.effect = 2; g_pCustomMessage.r1 = g_pCustomMessage.g1 = g_pCustomMessage.b1 = g_pCustomMessage.a1 = 100; @@ -453,18 +442,18 @@ void CHudMessage::MessageAdd( const char *pName, float time ) tempMessage = &g_pCustomMessage; } - for ( j = 0; j < maxHUDMessages; j++ ) + for( j = 0; j < maxHUDMessages; j++ ) { - if ( m_pMessages[j] ) + if( m_pMessages[j] ) { // is this message already in the list - if ( !strcmp( tempMessage->pMessage, m_pMessages[j]->pMessage ) ) + if( !strcmp( tempMessage->pMessage, m_pMessages[j]->pMessage ) ) { return; } // get rid of any other messages in same location (only one displays at a time) - if ( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001 ) + if( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001 ) { if ( fabs( tempMessage->x - m_pMessages[j]->x ) < 0.0001 ) { @@ -481,7 +470,6 @@ void CHudMessage::MessageAdd( const char *pName, float time ) } } - int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); @@ -489,48 +477,47 @@ int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf ) char *pString = READ_STRING(); MessageAdd( pString, gHUD.m_flTime ); + // Remember the time -- to fix up level transitions m_parms.time = gHUD.m_flTime; // Turn on drawing - if ( !(m_iFlags & HUD_ACTIVE) ) + if( !( m_iFlags & HUD_ACTIVE ) ) m_iFlags |= HUD_ACTIVE; return 1; } - int CHudMessage::MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf ) { m_pGameTitle = TextMessageGet( "GAMETITLE" ); - if ( m_pGameTitle != NULL ) + if( m_pGameTitle != NULL ) { m_gameTitleTime = gHUD.m_flTime; // Turn on drawing - if ( !(m_iFlags & HUD_ACTIVE) ) + if( !( m_iFlags & HUD_ACTIVE ) ) m_iFlags |= HUD_ACTIVE; } return 1; } -void CHudMessage::MessageAdd(client_textmessage_t * newMessage ) +void CHudMessage::MessageAdd( client_textmessage_t * newMessage ) { m_parms.time = gHUD.m_flTime; // Turn on drawing - if ( !(m_iFlags & HUD_ACTIVE) ) + if( !( m_iFlags & HUD_ACTIVE ) ) m_iFlags |= HUD_ACTIVE; - - for ( int i = 0; i < maxHUDMessages; i++ ) + + for( int i = 0; i < maxHUDMessages; i++ ) { - if ( !m_pMessages[i] ) + if( !m_pMessages[i] ) { m_pMessages[i] = newMessage; m_startTime[i] = gHUD.m_flTime; return; } } - } diff --git a/cl_dll/overview.cpp b/cl_dll/overview.cpp index 04f1a984..881812f7 100644 --- a/cl_dll/overview.cpp +++ b/cl_dll/overview.cpp @@ -34,8 +34,8 @@ int CHudOverview::Init() //----------------------------------------------------------------------------- int CHudOverview::VidInit() { - m_hsprPlayer = gEngfuncs.pfnSPR_Load("sprites/ring.spr"); - m_hsprViewcone = gEngfuncs.pfnSPR_Load("sprites/camera.spr"); + m_hsprPlayer = gEngfuncs.pfnSPR_Load( "sprites/ring.spr" ); + m_hsprViewcone = gEngfuncs.pfnSPR_Load( "sprites/camera.spr" ); return 1; } @@ -45,42 +45,42 @@ int CHudOverview::VidInit() // Input : flTime - // intermission - //----------------------------------------------------------------------------- -int CHudOverview::Draw(float flTime) +int CHudOverview::Draw( float flTime ) { #if 0 // only draw in overview mode - if (!gEngfuncs.Overview_GetOverviewState()) + if( !gEngfuncs.Overview_GetOverviewState() ) return 1; // make sure we have player info -// gViewPort->GetAllPlayersInfo(); + //gViewPort->GetAllPlayersInfo(); gHUD.m_Scoreboard.GetAllPlayersInfo(); // calculate player size on the overview int x1, y1, x2, y2; - float v0[3]={0,0,0}, v1[3]={64,64,0}; - gEngfuncs.Overview_WorldToScreen(v0, &x1, &y1); - gEngfuncs.Overview_WorldToScreen(v1, &x2, &y2); - float scale = abs(x2 - x1); + float v0[3] = { 0.0f }, v1[3] = { 64.0f, 64.0f }; + gEngfuncs.Overview_WorldToScreen( v0, &x1, &y1 ); + gEngfuncs.Overview_WorldToScreen( v1, &x2, &y2 ); + float scale = abs( x2 - x1 ); // loop through all the players and draw them on the map - for (int i = 1; i < MAX_PLAYERS; i++) + for( int i = 1; i < MAX_PLAYERS; i++ ) { - cl_entity_t *pl = gEngfuncs.GetEntityByIndex(i); + cl_entity_t *pl = gEngfuncs.GetEntityByIndex( i ); - if (pl && pl->player && pl->curstate.health > 0 && pl->curstate.solid != SOLID_NOT) + if( pl && pl->player && pl->curstate.health > 0 && pl->curstate.solid != SOLID_NOT ) { int x, y, z = 0; - float v[3]={pl->origin[0], pl->origin[1], 0}; - gEngfuncs.Overview_WorldToScreen(v, &x, &y); + float v[3] = { pl->origin[0], pl->origin[1], 0 }; + gEngfuncs.Overview_WorldToScreen( v, &x, &y ); // hack in some team colors float r, g, bc; - if (g_PlayerExtraInfo[i].teamnumber == 1) + if( g_PlayerExtraInfo[i].teamnumber == 1 ) { r = 0.0f; g = 0.0f; bc = 1.0f; } - else if (g_PlayerExtraInfo[i].teamnumber == 2) + else if( g_PlayerExtraInfo[i].teamnumber == 2 ) { r = 1.0f; g = 0.0f; bc = 0.0f; } @@ -91,50 +91,50 @@ int CHudOverview::Draw(float flTime) } // set the current texture - gEngfuncs.pTriAPI->SpriteTexture((struct model_s *)gEngfuncs.GetSpritePointer(m_hsprPlayer), 0); + gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprPlayer ), 0 ); // additive render mode - gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd); + gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); // no culling - gEngfuncs.pTriAPI->CullFace(TRI_NONE); + gEngfuncs.pTriAPI->CullFace( TRI_NONE ); // draw a square - gEngfuncs.pTriAPI->Begin(TRI_QUADS); + gEngfuncs.pTriAPI->Begin( TRI_QUADS ); // set the color to be that of the team - gEngfuncs.pTriAPI->Color4f(r, g, bc, 1.0f); + gEngfuncs.pTriAPI->Color4f( r, g, bc, 1.0f ); // calculate rotational matrix vec3_t a, b, angles; float rmatrix[3][4]; // transformation matrix - VectorCopy(pl->angles, angles); + VectorCopy( pl->angles, angles ); angles[0] = 0.0f; angles[1] += 90.f; angles[1] = -angles[1]; angles[2] = 0.0f; - AngleMatrix(angles, rmatrix); + AngleMatrix( angles, rmatrix ); a[2] = 0; a[0] = -scale; a[1] = -scale; - VectorTransform(a, rmatrix , b ); + VectorTransform( a, rmatrix, b ); gEngfuncs.pTriAPI->TexCoord2f( 0, 0 ); - gEngfuncs.pTriAPI->Vertex3f(x + b[0], y + b[1], z); + gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); - a[0]=-scale; a[1] = scale; - VectorTransform(a, rmatrix , b ); + a[0] = -scale; a[1] = scale; + VectorTransform( a, rmatrix, b ); gEngfuncs.pTriAPI->TexCoord2f( 0, 1 ); - gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z); - - a[0]=scale; a[1] = scale; - VectorTransform(a, rmatrix , b ); - gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); - gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z); + gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); - a[0]=scale; a[1] = -scale; - VectorTransform(a, rmatrix , b ); + a[0] = scale; a[1] = scale; + VectorTransform( a, rmatrix, b ); + gEngfuncs.pTriAPI->TexCoord2f( 1, 1 ); + gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); + + a[0] = scale; a[1] = -scale; + VectorTransform( a, rmatrix, b ); gEngfuncs.pTriAPI->TexCoord2f( 1, 0 ); - gEngfuncs.pTriAPI->Vertex3f (x + b[0], y + b[1], z); + gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z ); // finish up gEngfuncs.pTriAPI->End(); @@ -142,11 +142,10 @@ int CHudOverview::Draw(float flTime) // draw the players name and health underneath char string[256]; - sprintf(string, "%s (%i%%)", g_PlayerInfoList[i].name, pl->curstate.health); - DrawConsoleString(x, y + (1.1 * scale), string); + sprintf( string, "%s (%i%%)", g_PlayerInfoList[i].name, pl->curstate.health ); + DrawConsoleString( x, y + ( 1.1 * scale ), string ); } } - #endif return 1; } @@ -156,8 +155,7 @@ int CHudOverview::Draw(float flTime) //----------------------------------------------------------------------------- void CHudOverview::InitHUDData() { -// this block would force the spectator view to be on -// gEngfuncs.Overview_SetDrawOverview( 1 ); -// gEngfuncs.Overview_SetDrawInset( 0 ); + //this block would force the spectator view to be on + //gEngfuncs.Overview_SetDrawOverview( 1 ); + //gEngfuncs.Overview_SetDrawInset( 0 ); } - diff --git a/cl_dll/overview.h b/cl_dll/overview.h index 4de9ae75..6748760b 100644 --- a/cl_dll/overview.h +++ b/cl_dll/overview.h @@ -9,7 +9,6 @@ #define OVERVIEW_H #pragma once - //----------------------------------------------------------------------------- // Purpose: Handles the drawing of the top-down map and all the things on it //----------------------------------------------------------------------------- @@ -19,13 +18,11 @@ public: int Init(); int VidInit(); - int Draw(float flTime); + int Draw( float flTime ); void InitHUDData( void ); private: HSPRITE m_hsprPlayer; HSPRITE m_hsprViewcone; }; - - #endif // OVERVIEW_H diff --git a/cl_dll/parsemsg.cpp b/cl_dll/parsemsg.cpp index f242ff0d..4e58a161 100644 --- a/cl_dll/parsemsg.cpp +++ b/cl_dll/parsemsg.cpp @@ -15,6 +15,7 @@ // // parsemsg.cpp // + typedef unsigned char byte; #define true 1 @@ -31,28 +32,27 @@ void BEGIN_READ( void *buf, int size ) gpBuf = (byte*)buf; } - int READ_CHAR( void ) { - int c; - - if (giRead + 1 > giSize) + int c; + + if( giRead + 1 > giSize ) { giBadRead = true; return -1; } - + c = (signed char)gpBuf[giRead]; giRead++; - + return c; } int READ_BYTE( void ) { - int c; - - if (giRead+1 > giSize) + int c; + + if( giRead + 1 > giSize ) { giBadRead = true; return -1; @@ -66,18 +66,18 @@ int READ_BYTE( void ) int READ_SHORT( void ) { - int c; - - if (giRead+2 > giSize) + int c; + + if( giRead + 2 > giSize ) { giBadRead = true; return -1; } - - c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) ); - + + c = (short)( gpBuf[giRead] + ( gpBuf[giRead + 1] << 8 ) ); + giRead += 2; - + return c; } @@ -86,21 +86,20 @@ int READ_WORD( void ) return READ_SHORT(); } - int READ_LONG( void ) { - int c; - - if (giRead+4 > giSize) + int c; + + if( giRead + 4 > giSize ) { giBadRead = true; return -1; } - - c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24); - + + c = gpBuf[giRead] + ( gpBuf[giRead + 1] << 8 ) + ( gpBuf[giRead + 2] << 16 ) + ( gpBuf[giRead + 3] << 24 ); + giRead += 4; - + return c; } @@ -108,59 +107,58 @@ float READ_FLOAT( void ) { union { - byte b[4]; - float f; - int l; + byte b[4]; + float f; + int l; } dat; - - dat.b[0] = gpBuf[giRead]; - dat.b[1] = gpBuf[giRead+1]; - dat.b[2] = gpBuf[giRead+2]; - dat.b[3] = gpBuf[giRead+3]; - giRead += 4; - -// dat.l = LittleLong (dat.l); - return dat.f; + dat.b[0] = gpBuf[giRead]; + dat.b[1] = gpBuf[giRead + 1]; + dat.b[2] = gpBuf[giRead + 2]; + dat.b[3] = gpBuf[giRead + 3]; + giRead += 4; + + //dat.l = LittleLong( dat.l ); + + return dat.f; } char* READ_STRING( void ) { - static char string[2048]; - int l,c; + static char string[2048]; + int l, c; string[0] = 0; l = 0; do { - if ( giRead+1 > giSize ) + if( giRead+1 > giSize ) break; // no more characters c = READ_BYTE(); - if (c == -1 || c == 0) + if( c == -1 || c == 0 ) break; string[l] = c; l++; - } while (l < sizeof(string)-1); - + }while( l < sizeof(string) - 1 ); + string[l] = 0; - + return string; } float READ_COORD( void ) { - return (float)(READ_SHORT() * (1.0/8)); + return (float)( READ_SHORT() * ( 1.0 / 8 ) ); } float READ_ANGLE( void ) { - return (float)(READ_CHAR() * (360.0/256)); + return (float)( READ_CHAR() * ( 360.0 / 256 ) ); } float READ_HIRESANGLE( void ) { - return (float)(READ_SHORT() * (360.0/65536)); + return (float)( READ_SHORT() * ( 360.0 / 65536 ) ); } - diff --git a/cl_dll/saytext.cpp b/cl_dll/saytext.cpp index 2f785b83..8f2e2520 100644 --- a/cl_dll/saytext.cpp +++ b/cl_dll/saytext.cpp @@ -25,7 +25,6 @@ #include #include - extern float *GetClientColor( int clientIndex ); #define MAX_LINES 5 @@ -36,9 +35,9 @@ extern float *GetClientColor( int clientIndex ); #define LINE_START 10 static float SCROLL_SPEED = 5; -static char g_szLineBuffer[ MAX_LINES + 1 ][ MAX_CHARS_PER_LINE ]; -static float *g_pflNameColors[ MAX_LINES + 1 ]; -static int g_iNameLengths[ MAX_LINES + 1 ]; +static char g_szLineBuffer[MAX_LINES + 1][MAX_CHARS_PER_LINE]; +static float *g_pflNameColors[MAX_LINES + 1]; +static int g_iNameLengths[MAX_LINES + 1]; static float flScrollTime = 0; // the time at which the lines next scroll up static int Y_START = 0; @@ -46,7 +45,7 @@ static int line_height = 0; DECLARE_MESSAGE( m_SayText, SayText ) -int CHudSayText :: Init( void ) +int CHudSayText::Init( void ) { gHUD.AddHudElem( this ); @@ -54,7 +53,7 @@ int CHudSayText :: Init( void ) InitHUDData(); - m_HUD_saytext = gEngfuncs.pfnRegisterVariable( "hud_saytext", "1", 0 ); + m_HUD_saytext = gEngfuncs.pfnRegisterVariable( "hud_saytext", "1", 0 ); m_HUD_saytext_time = gEngfuncs.pfnRegisterVariable( "hud_saytext_time", "5", 0 ); m_iFlags |= HUD_INTERMISSION; // is always drawn during an intermission @@ -62,20 +61,18 @@ int CHudSayText :: Init( void ) return 1; } - -void CHudSayText :: InitHUDData( void ) +void CHudSayText::InitHUDData( void ) { memset( g_szLineBuffer, 0, sizeof g_szLineBuffer ); memset( g_pflNameColors, 0, sizeof g_pflNameColors ); memset( g_iNameLengths, 0, sizeof g_iNameLengths ); } -int CHudSayText :: VidInit( void ) +int CHudSayText::VidInit( void ) { return 1; } - int ScrollTextUp( void ) { ConsolePrint( g_szLineBuffer[0] ); // move the first line into the console buffer @@ -85,7 +82,7 @@ int ScrollTextUp( void ) memmove( &g_iNameLengths[0], &g_iNameLengths[1], sizeof(g_iNameLengths) - sizeof(g_iNameLengths[0]) ); g_szLineBuffer[MAX_LINES-1][0] = 0; - if ( g_szLineBuffer[0][0] == ' ' ) // also scroll up following lines + if( g_szLineBuffer[0][0] == ' ' ) // also scroll up following lines { g_szLineBuffer[0][0] = 2; return 1 + ScrollTextUp(); @@ -94,7 +91,7 @@ int ScrollTextUp( void ) return 1; } -int CHudSayText :: Draw( float flTime ) +int CHudSayText::Draw( float flTime ) { int y = Y_START; @@ -104,32 +101,33 @@ int CHudSayText :: Draw( float flTime ) // make sure the scrolltime is within reasonable bounds, to guard against the clock being reset flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value ); - if ( flScrollTime <= flTime ) + if( flScrollTime <= flTime ) { - if ( *g_szLineBuffer[0] ) + if( *g_szLineBuffer[0] ) { flScrollTime = flTime + m_HUD_saytext_time->value; // push the console up ScrollTextUp(); } else - { // buffer is empty, just disable drawing of this section + { + // buffer is empty, just disable drawing of this section m_iFlags &= ~HUD_ACTIVE; } } - for ( int i = 0; i < MAX_LINES; i++ ) + for( int i = 0; i < MAX_LINES; i++ ) { - if ( *g_szLineBuffer[i] ) + if( *g_szLineBuffer[i] ) { - if ( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] ) + if( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] ) { // it's a saytext string - static char buf[MAX_PLAYER_NAME_LENGTH+32]; + static char buf[MAX_PLAYER_NAME_LENGTH + 32]; // draw the first x characters in the player color - strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+32) ); - buf[ min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+31) ] = 0; + strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 32 ) ); + buf[min( g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 31 )] = 0; DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] ); int x = DrawConsoleString( LINE_START, y, buf ); @@ -146,32 +144,31 @@ int CHudSayText :: Draw( float flTime ) y += line_height; } - return 1; } -int CHudSayText :: MsgFunc_SayText( const char *pszName, int iSize, void *pbuf ) +int CHudSayText::MsgFunc_SayText( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); int client_index = READ_BYTE(); // the client who spoke the message SayTextPrint( READ_STRING(), iSize - 1, client_index ); - + return 1; } -void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex ) +void CHudSayText::SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex ) { int i; ConsolePrint( pszBuf ); // find an empty string slot - for ( i = 0; i < MAX_LINES; i++ ) + for( i = 0; i < MAX_LINES; i++ ) { - if ( ! *g_szLineBuffer[i] ) + if( !( *g_szLineBuffer[i] ) ) break; } - if ( i == MAX_LINES ) + if( i == MAX_LINES ) { // force scroll buffer up ScrollTextUp(); @@ -182,30 +179,30 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn g_pflNameColors[i] = NULL; // if it's a say message, search for the players name in the string - if ( *pszBuf == 2 && clientIndex > 0 ) + if( *pszBuf == 2 && clientIndex > 0 ) { GetPlayerInfo( clientIndex, &g_PlayerInfoList[clientIndex] ); const char *pName = g_PlayerInfoList[clientIndex].name; - if ( pName ) + if( pName ) { const char *nameInString = strstr( pszBuf, pName ); - if ( nameInString ) + if( nameInString ) { - g_iNameLengths[i] = strlen( pName ) + (nameInString - pszBuf); + g_iNameLengths[i] = strlen( pName ) + ( nameInString - pszBuf ); g_pflNameColors[i] = GetClientColor( clientIndex ); } } } - strncpy( g_szLineBuffer[i], pszBuf, max(iBufSize -1, MAX_CHARS_PER_LINE-1) ); + strncpy( g_szLineBuffer[i], pszBuf, max( iBufSize - 1, MAX_CHARS_PER_LINE - 1 ) ); // make sure the text fits in one line EnsureTextFitsInOneLineAndWrapIfHaveTo( i ); // Set scroll time - if ( i == 0 ) + if( i == 0 ) { flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value; } @@ -213,56 +210,57 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn m_iFlags |= HUD_ACTIVE; PlaySound( "misc/talk.wav", 1 ); - if ( ScreenHeight >= 480 ) + if( ScreenHeight >= 480 ) Y_START = ScreenHeight - 60; else Y_START = ScreenHeight - 45; - Y_START -= (line_height * (MAX_LINES+1)); - + Y_START -= ( line_height * ( MAX_LINES + 1 ) ); } -void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line ) +void CHudSayText::EnsureTextFitsInOneLineAndWrapIfHaveTo( int line ) { int line_width = 0; GetConsoleStringSize( g_szLineBuffer[line], &line_width, &line_height ); - if ( (line_width + LINE_START) > MAX_LINE_WIDTH ) - { // string is too long to fit on line + if( ( line_width + LINE_START ) > MAX_LINE_WIDTH ) + { + // string is too long to fit on line // scan the string until we find what word is too long, and wrap the end of the sentence after the word int length = LINE_START; int tmp_len = 0; char *last_break = NULL; - for ( char *x = g_szLineBuffer[line]; *x != 0; x++ ) + for( char *x = g_szLineBuffer[line]; *x != 0; x++ ) { // check for a color change, if so skip past it - if ( x[0] == '/' && x[1] == '(' ) + if( x[0] == '/' && x[1] == '(' ) { x += 2; // skip forward until past mode specifier while ( *x != 0 && *x != ')' ) x++; - if ( *x != 0 ) + if( *x != 0 ) x++; - if ( *x == 0 ) + if( *x == 0 ) break; } char buf[2]; buf[1] = 0; - if ( *x == ' ' && x != g_szLineBuffer[line] ) // store each line break, except for the very first character + if( *x == ' ' && x != g_szLineBuffer[line] ) // store each line break, except for the very first character last_break = x; buf[0] = *x; // get the length of the current character GetConsoleStringSize( buf, &tmp_len, &line_height ); length += tmp_len; - if ( length > MAX_LINE_WIDTH ) - { // needs to be broken up - if ( !last_break ) - last_break = x-1; + if( length > MAX_LINE_WIDTH ) + { + // needs to be broken up + if( !last_break ) + last_break = x - 1; x = last_break; @@ -270,33 +268,33 @@ void CHudSayText :: EnsureTextFitsInOneLineAndWrapIfHaveTo( int line ) int j; do { - for ( j = 0; j < MAX_LINES; j++ ) + for( j = 0; j < MAX_LINES; j++ ) { - if ( ! *g_szLineBuffer[j] ) + if( !( *g_szLineBuffer[j] ) ) break; } - if ( j == MAX_LINES ) + if( j == MAX_LINES ) { // need to make more room to display text, scroll stuff up then fix the pointers int linesmoved = ScrollTextUp(); line -= linesmoved; - last_break = last_break - (sizeof(g_szLineBuffer[0]) * linesmoved); + last_break = last_break - ( sizeof(g_szLineBuffer[0]) * linesmoved ); } } - while ( j == MAX_LINES ); + while( j == MAX_LINES ); // copy remaining string into next buffer, making sure it starts with a space character - if ( (char)*last_break == (char)' ' ) + if( (char)*last_break == (char)' ' ) { - int linelen = strlen(g_szLineBuffer[j]); - int remaininglen = strlen(last_break); + int linelen = strlen( g_szLineBuffer[j] ); + int remaininglen = strlen( last_break ); - if ( (linelen - remaininglen) <= MAX_CHARS_PER_LINE ) + if( ( linelen - remaininglen ) <= MAX_CHARS_PER_LINE ) strcat( g_szLineBuffer[j], last_break ); } else { - if ( (strlen(g_szLineBuffer[j]) - strlen(last_break) - 2) < MAX_CHARS_PER_LINE ) + if ( ( strlen( g_szLineBuffer[j] ) - strlen( last_break ) - 2 ) < MAX_CHARS_PER_LINE ) { strcat( g_szLineBuffer[j], " " ); strcat( g_szLineBuffer[j], last_break ); diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index adcbb3e7..62d140e1 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -27,9 +27,9 @@ #include cvar_t *cl_showpacketloss; -hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine -extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll -team_info_t g_TeamInfo[MAX_TEAMS+1]; +hud_player_info_t g_PlayerInfoList[MAX_PLAYERS + 1]; // player info from the engine +extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS + 1]; // additional player info sent directly to the client dll +team_info_t g_TeamInfo[MAX_TEAMS + 1]; int g_iUser1; int g_iUser2; int g_iUser3; @@ -45,7 +45,7 @@ DECLARE_MESSAGE( m_Scoreboard, ScoreInfo ) DECLARE_MESSAGE( m_Scoreboard, TeamInfo ) DECLARE_MESSAGE( m_Scoreboard, TeamScore ) -int CHudScoreboard :: Init( void ) +int CHudScoreboard::Init( void ) { gHUD.AddHudElem( this ); @@ -64,14 +64,13 @@ int CHudScoreboard :: Init( void ) return 1; } - -int CHudScoreboard :: VidInit( void ) +int CHudScoreboard::VidInit( void ) { // Load sprites here return 1; } -void CHudScoreboard :: InitHUDData( void ) +void CHudScoreboard::InitHUDData( void ) { memset( g_PlayerExtraInfo, 0, sizeof g_PlayerExtraInfo ); m_iLastKilledBy = 0; @@ -104,20 +103,19 @@ We have a minimum width of 1-320 - we could have the field widths scale with it? #define PL_RANGE_MAX 375 int SCOREBOARD_WIDTH = 320; - // Y positions #define ROW_GAP 13 #define ROW_RANGE_MIN 15 -#define ROW_RANGE_MAX ( ScreenHeight - 50 ) +#define ROW_RANGE_MAX( ScreenHeight - 50 ) -int CHudScoreboard :: Draw( float fTime ) +int CHudScoreboard::Draw( float fTime ) { int i, j, can_show_packetloss = 0; int FAR_RIGHT; gHUD.m_iNoConsolePrint &= ~( 1 << 0 ); - if ( !m_iShowscoresHeld && gHUD.m_Health.m_iHealth > 0 && !gHUD.m_iIntermission ) + if( !m_iShowscoresHeld && gHUD.m_Health.m_iHealth > 0 && !gHUD.m_iIntermission ) return 1; gHUD.m_iNoConsolePrint |= 1 << 0; @@ -125,7 +123,7 @@ int CHudScoreboard :: Draw( float fTime ) GetAllPlayersInfo(); // Packetloss removed on Kelly 'shipping nazi' Bailey's orders - if ( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) ) + if( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) ) { can_show_packetloss = 1; SCOREBOARD_WIDTH = 400; @@ -138,16 +136,16 @@ int CHudScoreboard :: Draw( float fTime ) // just sort the list on the fly // list is sorted first by frags, then by deaths float list_slot = 0; - int xpos_rel = (ScreenWidth - SCOREBOARD_WIDTH) / 2; + int xpos_rel = ( ScreenWidth - SCOREBOARD_WIDTH ) / 2; // print the heading line - int ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP); - int xpos = NAME_RANGE_MIN + xpos_rel; + int ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP ); + int xpos = NAME_RANGE_MIN + xpos_rel; FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; FAR_RIGHT += 5; - gHUD.DrawDarkRectangle(xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX); - if ( !gHUD.m_Teamplay ) + gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); + if( !gHUD.m_Teamplay ) gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); else gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 ); @@ -157,20 +155,19 @@ int CHudScoreboard :: Draw( float fTime ) gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 ); gHUD.DrawHudString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 ); - if ( can_show_packetloss ) + if( can_show_packetloss ) { gHUD.DrawHudString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 ); } - list_slot += 1.2; - ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP); + ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP ); xpos = NAME_RANGE_MIN + xpos_rel; - FillRGBA( xpos - 4, ypos, FAR_RIGHT -2, 1, 255, 140, 0, 255); // draw the seperator line - + FillRGBA( xpos - 4, ypos, FAR_RIGHT -2, 1, 255, 140, 0, 255 ); // draw the seperator line + list_slot += 0.8; - if ( !gHUD.m_Teamplay ) + if( !gHUD.m_Teamplay ) { // it's not teamplay, so just draw a simple player list DrawPlayers( xpos_rel, list_slot ); @@ -178,32 +175,32 @@ int CHudScoreboard :: Draw( float fTime ) } // clear out team scores - for ( i = 1; i <= m_iNumTeams; i++ ) + for( i = 1; i <= m_iNumTeams; i++ ) { - if ( !g_TeamInfo[i].scores_overriden ) + if( !g_TeamInfo[i].scores_overriden ) g_TeamInfo[i].frags = g_TeamInfo[i].deaths = 0; g_TeamInfo[i].ping = g_TeamInfo[i].packetloss = 0; } // recalc the team scores, then draw them - for ( i = 1; i < MAX_PLAYERS; i++ ) + for( i = 1; i < MAX_PLAYERS; i++ ) { - //if ( g_PlayerInfoList[i].name == NULL ) + //if( g_PlayerInfoList[i].name == NULL ) // continue; // empty player slot, skip - if ( g_PlayerExtraInfo[i].teamname[0] == 0 ) + if( g_PlayerExtraInfo[i].teamname[0] == 0 ) continue; // skip over players who are not in a team // find what team this player is in - for ( j = 1; j <= m_iNumTeams; j++ ) + for( j = 1; j <= m_iNumTeams; j++ ) { - if ( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) ) + if( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) ) break; } - if ( j > m_iNumTeams ) // player is not in a team, skip to the next guy + if( j > m_iNumTeams ) // player is not in a team, skip to the next guy continue; - if ( !g_TeamInfo[j].scores_overriden ) + if( !g_TeamInfo[j].scores_overriden ) { g_TeamInfo[j].frags += g_PlayerExtraInfo[i].frags; g_TeamInfo[j].deaths += g_PlayerExtraInfo[i].deaths; @@ -212,18 +209,18 @@ int CHudScoreboard :: Draw( float fTime ) g_TeamInfo[j].ping += g_PlayerInfoList[i].ping; g_TeamInfo[j].packetloss += g_PlayerInfoList[i].packetloss; - if ( g_PlayerInfoList[i].thisplayer ) + if( g_PlayerInfoList[i].thisplayer ) g_TeamInfo[j].ownteam = TRUE; else g_TeamInfo[j].ownteam = FALSE; } // find team ping/packetloss averages - for ( i = 1; i <= m_iNumTeams; i++ ) + for( i = 1; i <= m_iNumTeams; i++ ) { g_TeamInfo[i].already_drawn = FALSE; - if ( g_TeamInfo[i].players > 0 ) + if( g_TeamInfo[i].players > 0 ) { g_TeamInfo[i].ping /= g_TeamInfo[i].players; // use the average ping of all the players in the team as the teams ping g_TeamInfo[i].packetloss /= g_TeamInfo[i].players; // use the average ping of all the players in the team as the teams ping @@ -231,19 +228,19 @@ int CHudScoreboard :: Draw( float fTime ) } // Draw the teams - while ( 1 ) + while( 1 ) { int highest_frags = -99999; int lowest_deaths = 99999; int best_team = 0; - for ( i = 1; i <= m_iNumTeams; i++ ) + for( i = 1; i <= m_iNumTeams; i++ ) { - if ( g_TeamInfo[i].players < 0 ) + if( g_TeamInfo[i].players < 0 ) continue; - if ( !g_TeamInfo[i].already_drawn && g_TeamInfo[i].frags >= highest_frags ) + if( !g_TeamInfo[i].already_drawn && g_TeamInfo[i].frags >= highest_frags ) { - if ( g_TeamInfo[i].frags > highest_frags || g_TeamInfo[i].deaths < lowest_deaths ) + if( g_TeamInfo[i].frags > highest_frags || g_TeamInfo[i].deaths < lowest_deaths ) { best_team = i; lowest_deaths = g_TeamInfo[i].deaths; @@ -253,22 +250,22 @@ int CHudScoreboard :: Draw( float fTime ) } // draw the best team on the scoreboard - if ( !best_team ) + if( !best_team ) break; // draw out the best team team_info_t *team_info = &g_TeamInfo[best_team]; - ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP); + ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP ); // check we haven't drawn too far down - if ( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border + if( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border break; xpos = NAME_RANGE_MIN + xpos_rel; int r = 255, g = 225, b = 55; // draw the stuff kinda yellowish - - if ( team_info->ownteam ) // if it is their team, draw the background different color + + if( team_info->ownteam ) // if it is their team, draw the background different color { // overlay the background in blue, then draw the score text over it FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); @@ -293,15 +290,15 @@ int CHudScoreboard :: Draw( float fTime ) // draw ping & packetloss static char buf[64]; sprintf( buf, "%d", team_info->ping ); - xpos = ((PING_RANGE_MAX - PING_RANGE_MIN) / 2) + PING_RANGE_MIN + xpos_rel + 25; + xpos = ( ( PING_RANGE_MAX - PING_RANGE_MIN ) / 2) + PING_RANGE_MIN + xpos_rel + 25; UnpackRGB( r, g, b, RGB_YELLOWISH ); gHUD.DrawHudStringReverse( xpos, ypos, xpos - 50, buf, r, g, b ); - // Packetloss removed on Kelly 'shipping nazi' Bailey's orders - if ( can_show_packetloss ) + // Packetloss removed on Kelly 'shipping nazi' Bailey's orders + if( can_show_packetloss ) { - xpos = ((PL_RANGE_MAX - PL_RANGE_MIN) / 2) + PL_RANGE_MIN + xpos_rel + 25; - + xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2) + PL_RANGE_MIN + xpos_rel + 25; + sprintf( buf, " %d", team_info->packetloss ); gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b ); } @@ -319,15 +316,17 @@ int CHudScoreboard :: Draw( float fTime ) return 1; } + extern float *GetClientColor( int client ); + // returns the ypos where it finishes drawing -int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset, char *team ) +int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, char *team ) { int can_show_packetloss = 0; int FAR_RIGHT; // Packetloss removed on Kelly 'shipping nazi' Bailey's orders - if ( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) ) + if( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) ) { can_show_packetloss = 1; SCOREBOARD_WIDTH = 400; @@ -341,20 +340,21 @@ int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset FAR_RIGHT += 5; // draw the players, in order, and restricted to team if set - while ( 1 ) + while( 1 ) { // Find the top ranking player - int highest_frags = -99999; int lowest_deaths = 99999; + int highest_frags = -99999; + int lowest_deaths = 99999; int best_player = 0; - for ( int i = 1; i < MAX_PLAYERS; i++ ) + for( int i = 1; i < MAX_PLAYERS; i++ ) { - if ( g_PlayerInfoList[i].name && g_PlayerExtraInfo[i].frags >= highest_frags ) + if( g_PlayerInfoList[i].name && g_PlayerExtraInfo[i].frags >= highest_frags ) { - if ( !(team && stricmp(g_PlayerExtraInfo[i].teamname, team)) ) // make sure it is the specified team + if( !( team && stricmp( g_PlayerExtraInfo[i].teamname, team ) ) ) // make sure it is the specified team { extra_player_info_t *pl_info = &g_PlayerExtraInfo[i]; - if ( pl_info->frags > highest_frags || pl_info->deaths < lowest_deaths ) + if( pl_info->frags > highest_frags || pl_info->deaths < lowest_deaths ) { best_player = i; lowest_deaths = pl_info->deaths; @@ -364,34 +364,36 @@ int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset } } - if ( !best_player ) + if( !best_player ) break; // draw out the best player hud_player_info_t *pl_info = &g_PlayerInfoList[best_player]; - int ypos = ROW_RANGE_MIN + (list_slot * ROW_GAP); + int ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP ); // check we haven't drawn too far down - if ( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border + if( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border break; int xpos = NAME_RANGE_MIN + xpos_rel; int r = 255, g = 255, b = 255; float *colors = GetClientColor( best_player ); r *= colors[0], g *= colors[1], b *= colors[2]; - if ( best_player == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime ) + if( best_player == m_iLastKilledBy && m_fLastKillTime && m_fLastKillTime > gHUD.m_flTime ) { - if ( pl_info->thisplayer ) - { // green is the suicide color? i wish this could do grey... + if( pl_info->thisplayer ) + { + // green is the suicide color? i wish this could do grey... FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 ); } else - { // Highlight the killers name - overlay the background in red, then draw the score text over it - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ((float)15 * (float)(m_fLastKillTime - gHUD.m_flTime)) ); + { + // Highlight the killers name - overlay the background in red, then draw the score text over it + FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ( (float)15 * (float)( m_fLastKillTime - gHUD.m_flTime ) ) ); } } - else if ( pl_info->thisplayer ) // if it is their name, draw it a different color + else if( pl_info->thisplayer ) // if it is their name, draw it a different color { // overlay the background in blue, then draw the score text over it FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); @@ -415,13 +417,13 @@ int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset // draw ping & packetloss static char buf[64]; sprintf( buf, "%d", g_PlayerInfoList[best_player].ping ); - xpos = ((PING_RANGE_MAX - PING_RANGE_MIN) / 2) + PING_RANGE_MIN + xpos_rel + 25; + xpos = ( ( PING_RANGE_MAX - PING_RANGE_MIN ) / 2 ) + PING_RANGE_MIN + xpos_rel + 25; gHUD.DrawHudStringReverse( xpos, ypos, xpos - 50, buf, r, g, b ); // Packetloss removed on Kelly 'shipping nazi' Bailey's orders - if ( can_show_packetloss ) + if( can_show_packetloss ) { - if ( g_PlayerInfoList[best_player].packetloss >= 63 ) + if( g_PlayerInfoList[best_player].packetloss >= 63 ) { UnpackRGB( r, g, b, RGB_REDISH ); sprintf( buf, " !!!!" ); @@ -431,11 +433,11 @@ int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset sprintf( buf, " %d", g_PlayerInfoList[best_player].packetloss ); } - xpos = ((PL_RANGE_MAX - PL_RANGE_MIN) / 2) + PL_RANGE_MIN + xpos_rel + 25; - + xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2 ) + PL_RANGE_MIN + xpos_rel + 25; + gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b ); } - + pl_info->name = NULL; // set the name to be NULL, so this client won't get drawn again list_slot++; } @@ -443,19 +445,18 @@ int CHudScoreboard :: DrawPlayers( int xpos_rel, float list_slot, int nameoffset return list_slot; } - -void CHudScoreboard :: GetAllPlayersInfo( void ) +void CHudScoreboard::GetAllPlayersInfo( void ) { - for ( int i = 1; i < MAX_PLAYERS; i++ ) + for( int i = 1; i < MAX_PLAYERS; i++ ) { GetPlayerInfo( i, &g_PlayerInfoList[i] ); - if ( g_PlayerInfoList[i].thisplayer ) + if( g_PlayerInfoList[i].thisplayer ) m_iPlayerNum = i; // !!!HACK: this should be initialized elsewhere... maybe gotten from the engine } } -int CHudScoreboard :: MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf ) +int CHudScoreboard::MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf ) { m_iFlags |= HUD_ACTIVE; @@ -466,7 +467,7 @@ int CHudScoreboard :: MsgFunc_ScoreInfo( const char *pszName, int iSize, void *p short playerclass = READ_SHORT(); short teamnumber = READ_SHORT(); - if ( cl > 0 && cl <= MAX_PLAYERS ) + if( cl > 0 && cl <= MAX_PLAYERS ) { g_PlayerExtraInfo[cl].frags = frags; g_PlayerExtraInfo[cl].deaths = deaths; @@ -483,21 +484,21 @@ int CHudScoreboard :: MsgFunc_ScoreInfo( const char *pszName, int iSize, void *p // accepts two values: // byte: client number // string: client team name -int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf ) +int CHudScoreboard::MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf ) { int i, j; BEGIN_READ( pbuf, iSize ); short cl = READ_BYTE(); - - if ( cl > 0 && cl <= MAX_PLAYERS ) - { // set the players team + + if( cl > 0 && cl <= MAX_PLAYERS ) + { + // set the players team strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME ); } // rebuild the list of teams - // clear out player counts from teams - for ( i = 1; i <= m_iNumTeams; i++ ) + for( i = 1; i <= m_iNumTeams; i++ ) { g_TeamInfo[i].players = 0; } @@ -505,30 +506,31 @@ int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pb // rebuild the team list GetAllPlayersInfo(); m_iNumTeams = 0; - for ( i = 1; i < MAX_PLAYERS; i++ ) + for( i = 1; i < MAX_PLAYERS; i++ ) { //if ( g_PlayerInfoList[i].name == NULL ) // continue; - if ( g_PlayerExtraInfo[i].teamname[0] == 0 ) + if( g_PlayerExtraInfo[i].teamname[0] == 0 ) continue; // skip over players who are not in a team // is this player in an existing team? - for ( j = 1; j <= m_iNumTeams; j++ ) + for( j = 1; j <= m_iNumTeams; j++ ) { - if ( g_TeamInfo[j].name[0] == '\0' ) + if( g_TeamInfo[j].name[0] == '\0' ) break; - if ( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) ) + if( !stricmp( g_PlayerExtraInfo[i].teamname, g_TeamInfo[j].name ) ) break; } - if ( j > m_iNumTeams ) - { // they aren't in a listed team, so make a new one + if( j > m_iNumTeams ) + { + // they aren't in a listed team, so make a new one // search through for an empty team slot - for ( j = 1; j <= m_iNumTeams; j++ ) + for( j = 1; j <= m_iNumTeams; j++ ) { - if ( g_TeamInfo[j].name[0] == '\0' ) + if( g_TeamInfo[j].name[0] == '\0' ) break; } m_iNumTeams = max( j, m_iNumTeams ); @@ -541,9 +543,9 @@ int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pb } // clear out any empty teams - for ( i = 1; i <= m_iNumTeams; i++ ) + for( i = 1; i <= m_iNumTeams; i++ ) { - if ( g_TeamInfo[i].players < 1 ) + if( g_TeamInfo[i].players < 1 ) memset( &g_TeamInfo[i], 0, sizeof(team_info_t) ); } @@ -556,50 +558,48 @@ int CHudScoreboard :: MsgFunc_TeamInfo( const char *pszName, int iSize, void *pb // short: teams kills // short: teams deaths // if this message is never received, then scores will simply be the combined totals of the players. -int CHudScoreboard :: MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf ) +int CHudScoreboard::MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); char *TeamName = READ_STRING(); int i; // find the team matching the name - for ( i = 1; i <= m_iNumTeams; i++ ) + for( i = 1; i <= m_iNumTeams; i++ ) { - if ( !stricmp( TeamName, g_TeamInfo[i].name ) ) + if( !stricmp( TeamName, g_TeamInfo[i].name ) ) break; } - if ( i > m_iNumTeams ) + if( i > m_iNumTeams ) return 1; // use this new score data instead of combined player scores g_TeamInfo[i].scores_overriden = TRUE; g_TeamInfo[i].frags = READ_SHORT(); g_TeamInfo[i].deaths = READ_SHORT(); - + return 1; } -void CHudScoreboard :: DeathMsg( int killer, int victim ) +void CHudScoreboard::DeathMsg( int killer, int victim ) { // if we were the one killed, or the world killed us, set the scoreboard to indicate suicide - if ( victim == m_iPlayerNum || killer == 0 ) + if( victim == m_iPlayerNum || killer == 0 ) { m_iLastKilledBy = killer ? killer : m_iPlayerNum; m_fLastKillTime = gHUD.m_flTime + 10; // display who we were killed by for 10 seconds - if ( killer == m_iPlayerNum ) + if( killer == m_iPlayerNum ) m_iLastKilledBy = m_iPlayerNum; } } - - -void CHudScoreboard :: UserCmd_ShowScores( void ) +void CHudScoreboard::UserCmd_ShowScores( void ) { m_iShowscoresHeld = TRUE; } -void CHudScoreboard :: UserCmd_HideScores( void ) +void CHudScoreboard::UserCmd_HideScores( void ) { m_iShowscoresHeld = FALSE; } diff --git a/cl_dll/soundsystem.cpp b/cl_dll/soundsystem.cpp index d368109b..9ee33861 100644 --- a/cl_dll/soundsystem.cpp +++ b/cl_dll/soundsystem.cpp @@ -15,6 +15,7 @@ // // $NoKeywords: $ //============================================================================= + #include #include #include @@ -28,9 +29,9 @@ extern engine_studio_api_t IEngineStudio; #define ENGINE_LAUNCHER_API_VERSION 1 -LPDIRECTSOUND lpDS = NULL; -LPDIRECTSOUNDBUFFER lpDSBuf = NULL; -LPHWAVEOUT lpHW = NULL; +LPDIRECTSOUND lpDS = NULL; +LPDIRECTSOUNDBUFFER lpDSBuf = NULL; +LPHWAVEOUT lpHW = NULL; static HMODULE hEngine = 0; @@ -116,10 +117,10 @@ int Eng_LoadFunctions( HMODULE hMod ) engine_api_func pfnEngineAPI; pfnEngineAPI = ( engine_api_func )GetProcAddress( hMod, "Sys_EngineAPI" ); - if ( !pfnEngineAPI ) + if( !pfnEngineAPI ) return 0; - if ( !(*pfnEngineAPI)( ENGINE_LAUNCHER_API_VERSION, sizeof( engine_api_t ), &engineapi ) ) + if( !(*pfnEngineAPI)( ENGINE_LAUNCHER_API_VERSION, sizeof( engine_api_t ), &engineapi ) ) return 0; // All is okay @@ -132,11 +133,11 @@ int Eng_LoadFunctions( HMODULE hMod ) void LoadSoundAPIs( void ) { hEngine = ::LoadLibrary( IEngineStudio.IsHardware() ? "hw.dll" : "sw.dll" ); - if ( hEngine ) + if( hEngine ) { - if ( Eng_LoadFunctions( hEngine ) ) + if( Eng_LoadFunctions( hEngine ) ) { - if ( engineapi.S_GetDSPointer && engineapi.S_GetWAVPointer ) + if( engineapi.S_GetDSPointer && engineapi.S_GetWAVPointer ) { engineapi.S_GetDSPointer(&lpDS, &lpDSBuf); lpHW = (HWAVEOUT FAR *)engineapi.S_GetWAVPointer(); @@ -155,7 +156,7 @@ void ShutdownSoundAPIs( void ) FreeLibrary( hEngine ); hEngine = 0; } - + lpDS = 0; lpDSBuf = 0; lpHW = 0; diff --git a/cl_dll/status_icons.cpp b/cl_dll/status_icons.cpp index 375c9d57..c960d5ef 100644 --- a/cl_dll/status_icons.cpp +++ b/cl_dll/status_icons.cpp @@ -15,6 +15,7 @@ // // status_icons.cpp // + #include "hud.h" #include "cl_util.h" #include "const.h" @@ -40,7 +41,6 @@ int CHudStatusIcons::Init( void ) int CHudStatusIcons::VidInit( void ) { - return 1; } @@ -53,24 +53,24 @@ void CHudStatusIcons::Reset( void ) // Draw status icons along the left-hand side of the screen int CHudStatusIcons::Draw( float flTime ) { - if (gEngfuncs.IsSpectateOnly()) + if( gEngfuncs.IsSpectateOnly() ) return 1; // find starting position to draw from, along right-hand side of screen int x = 5; int y = ScreenHeight / 2; // loop through icon list, and draw any valid icons drawing up from the middle of screen - for ( int i = 0; i < MAX_ICONSPRITES; i++ ) + for( int i = 0; i < MAX_ICONSPRITES; i++ ) { - if ( m_IconList[i].spr ) + if( m_IconList[i].spr ) { y -= ( m_IconList[i].rc.bottom - m_IconList[i].rc.top ) + 5; - + SPR_Set( m_IconList[i].spr, m_IconList[i].r, m_IconList[i].g, m_IconList[i].b ); SPR_DrawAdditive( 0, x, y, &m_IconList[i].rc ); } } - + return 1; } @@ -87,7 +87,7 @@ int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *p int ShouldEnable = READ_BYTE(); char *pszIconName = READ_STRING(); - if ( ShouldEnable ) + if( ShouldEnable ) { int r = READ_BYTE(); int g = READ_BYTE(); @@ -109,24 +109,24 @@ void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned int i; // check to see if the sprite is in the current list - for ( i = 0; i < MAX_ICONSPRITES; i++ ) + for( i = 0; i < MAX_ICONSPRITES; i++ ) { - if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) ) + if( !stricmp( m_IconList[i].szSpriteName, pszIconName ) ) break; } - if ( i == MAX_ICONSPRITES ) + if( i == MAX_ICONSPRITES ) { // icon not in list, so find an empty slot to add to - for ( i = 0; i < MAX_ICONSPRITES; i++ ) + for( i = 0; i < MAX_ICONSPRITES; i++ ) { - if ( !m_IconList[i].spr ) + if( !m_IconList[i].spr ) break; } } // if we've run out of space in the list, overwrite the first icon - if ( i == MAX_ICONSPRITES ) + if( i == MAX_ICONSPRITES ) { i = 0; } @@ -142,7 +142,7 @@ void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned strcpy( m_IconList[i].szSpriteName, pszIconName ); // Hack: Play Timer sound when a grenade icon is played (in 0.8 seconds) - if ( strstr(m_IconList[i].szSpriteName, "grenade") ) + if( strstr(m_IconList[i].szSpriteName, "grenade") ) { cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer(); gEngfuncs.pEventAPI->EV_PlaySound( pthisplayer->index, pthisplayer->origin, CHAN_STATIC, "weapons/timer.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); @@ -152,12 +152,12 @@ void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned void CHudStatusIcons::DisableIcon( char *pszIconName ) { // find the sprite is in the current list - for ( int i = 0; i < MAX_ICONSPRITES; i++ ) + for( int i = 0; i < MAX_ICONSPRITES; i++ ) { - if ( !stricmp( m_IconList[i].szSpriteName, pszIconName ) ) + if( !stricmp( m_IconList[i].szSpriteName, pszIconName ) ) { // clear the item from the list - memset( &m_IconList[i], 0, sizeof( icon_sprite_t ) ); + memset( &m_IconList[i], 0, sizeof(icon_sprite_t) ); return; } } diff --git a/cl_dll/statusbar.cpp b/cl_dll/statusbar.cpp index 152fb9b1..e730f05e 100644 --- a/cl_dll/statusbar.cpp +++ b/cl_dll/statusbar.cpp @@ -34,7 +34,7 @@ DECLARE_MESSAGE( m_StatusBar, StatusValue ) float *GetClientColor( int clientIndex ); extern float g_ColorYellow[3]; -int CHudStatusBar :: Init( void ) +int CHudStatusBar::Init( void ) { gHUD.AddHudElem( this ); @@ -48,19 +48,18 @@ int CHudStatusBar :: Init( void ) return 1; } -int CHudStatusBar :: VidInit( void ) +int CHudStatusBar::VidInit( void ) { // Load sprites here - return 1; } -void CHudStatusBar :: Reset( void ) +void CHudStatusBar::Reset( void ) { int i = 0; m_iFlags &= ~HUD_ACTIVE; // start out inactive - for ( i = 0; i < MAX_STATUSBAR_LINES; i++ ) + for( i = 0; i < MAX_STATUSBAR_LINES; i++ ) m_szStatusText[i][0] = 0; memset( m_iStatusValues, 0, sizeof m_iStatusValues ); @@ -71,7 +70,7 @@ void CHudStatusBar :: Reset( void ) m_pflNameColors[i] = g_ColorYellow; } -void CHudStatusBar :: ParseStatusString( int line_num ) +void CHudStatusBar::ParseStatusString( int line_num ) { // localise string first char szBuffer[MAX_STATUSTEXT_LENGTH]; @@ -85,29 +84,31 @@ void CHudStatusBar :: ParseStatusString( int line_num ) char *src_start = src, *dst_start = dst; - while ( *src != 0 ) + while( *src != 0 ) { - while ( *src == '\n' ) + while( *src == '\n' ) src++; // skip over any newlines - if ( ((src - src_start) >= MAX_STATUSTEXT_LENGTH) || ((dst - dst_start) >= MAX_STATUSTEXT_LENGTH) ) + if( ( ( src - src_start ) >= MAX_STATUSTEXT_LENGTH ) || ( ( dst - dst_start ) >= MAX_STATUSTEXT_LENGTH ) ) break; int index = atoi( src ); // should we draw this line? - if ( (index >= 0 && index < MAX_STATUSBAR_VALUES) && (m_iStatusValues[index] != 0) ) - { // parse this line and append result to the status bar + if( ( index >= 0 && index < MAX_STATUSBAR_VALUES ) && ( m_iStatusValues[index] != 0 ) ) + { + // parse this line and append result to the status bar while ( *src >= '0' && *src <= '9' ) src++; - if ( *src == '\n' || *src == 0 ) + if( *src == '\n' || *src == 0 ) continue; // no more left in this text line // copy the text, char by char, until we hit a % or a \n - while ( *src != '\n' && *src != 0 ) + while( *src != '\n' && *src != 0 ) { - if ( *src != '%' ) - { // just copy the character + if( *src != '%' ) + { + // just copy the character *dst = *src; dst++, src++; } @@ -126,20 +127,20 @@ void CHudStatusBar :: ParseStatusString( int line_num ) // move over descriptor, then get and move over the index index = atoi( ++src ); - while ( *src >= '0' && *src <= '9' ) + while( *src >= '0' && *src <= '9' ) src++; - if ( index >= 0 && index < MAX_STATUSBAR_VALUES ) + if( index >= 0 && index < MAX_STATUSBAR_VALUES ) { int indexval = m_iStatusValues[index]; // get the string to substitute in place of the %XX char szRepString[MAX_PLAYER_NAME_LENGTH]; - switch ( valtype ) + switch( valtype ) { case 'p': // player name GetPlayerInfo( indexval, &g_PlayerInfoList[indexval] ); - if ( g_PlayerInfoList[indexval].name != NULL ) + if( g_PlayerInfoList[indexval].name != NULL ) { strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH ); m_pflNameColors[line_num] = GetClientColor( indexval ); @@ -148,7 +149,6 @@ void CHudStatusBar :: ParseStatusString( int line_num ) { strcpy( szRepString, "******" ); } - break; case 'i': // number sprintf( szRepString, "%d", indexval ); @@ -157,7 +157,7 @@ void CHudStatusBar :: ParseStatusString( int line_num ) szRepString[0] = 0; } - for ( char *cp = szRepString; *cp != 0 && ((dst - dst_start) < MAX_STATUSTEXT_LENGTH); cp++, dst++ ) + for( char *cp = szRepString; *cp != 0 && ( ( dst - dst_start ) < MAX_STATUSTEXT_LENGTH ); cp++, dst++ ) *dst = *cp; } } @@ -166,17 +166,17 @@ void CHudStatusBar :: ParseStatusString( int line_num ) else { // skip to next line of text - while ( *src != 0 && *src != '\n' ) + while( *src != 0 && *src != '\n' ) src++; } } } -int CHudStatusBar :: Draw( float fTime ) +int CHudStatusBar::Draw( float fTime ) { - if ( m_bReparseString ) + if( m_bReparseString ) { - for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) + for( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) { m_pflNameColors[i] = g_ColorYellow; ParseStatusString( i ); @@ -184,10 +184,10 @@ int CHudStatusBar :: Draw( float fTime ) m_bReparseString = FALSE; } - int Y_START = ScreenHeight - YRES(32 + 4); + int Y_START = ScreenHeight - YRES( 32 + 4 ); // Draw the status bar lines - for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) + for( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) { int TextHeight, TextWidth; GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight ); @@ -196,13 +196,13 @@ int CHudStatusBar :: Draw( float fTime ) int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen // let user set status ID bar centering - if ( (i == STATUSBAR_ID_LINE) && CVAR_GET_FLOAT("hud_centerid") ) + if( ( i == STATUSBAR_ID_LINE ) && CVAR_GET_FLOAT( "hud_centerid" ) ) { - x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 ); - y = (ScreenHeight / 2) + (TextHeight*CVAR_GET_FLOAT("hud_centerid")); + x = max( 0, max( 2, ( ScreenWidth - TextWidth ) ) / 2 ); + y = ( ScreenHeight / 2 ) + ( TextHeight * CVAR_GET_FLOAT( "hud_centerid" ) ); } - if ( m_pflNameColors[i] ) + if( m_pflNameColors[i] ) DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] ); DrawConsoleString( x, y, m_szStatusBar[i] ); @@ -223,19 +223,19 @@ int CHudStatusBar :: Draw( float fTime ) // if StatusValue[slotnum] != 0, the following string is drawn, upto the next newline - otherwise the text is skipped upto next newline // %pX, where X is an integer, will substitute a player name here, getting the player index from StatusValue[X] // %iX, where X is an integer, will substitute a number here, getting the number from StatusValue[X] -int CHudStatusBar :: MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf ) +int CHudStatusBar::MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); int line = READ_BYTE(); - if ( line < 0 || line >= MAX_STATUSBAR_LINES ) + if( line < 0 || line >= MAX_STATUSBAR_LINES ) return 1; strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH ); - m_szStatusText[line][MAX_STATUSTEXT_LENGTH-1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long) + m_szStatusText[line][MAX_STATUSTEXT_LENGTH - 1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long) - if ( m_szStatusText[0] == 0 ) + if( m_szStatusText[0] == 0 ) m_iFlags &= ~HUD_ACTIVE; else m_iFlags |= HUD_ACTIVE; // we have status text, so turn on the status bar @@ -249,17 +249,17 @@ int CHudStatusBar :: MsgFunc_StatusText( const char *pszName, int iSize, void *p // accepts two values: // byte: index into the status value array // short: value to store -int CHudStatusBar :: MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf ) +int CHudStatusBar::MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); int index = READ_BYTE(); - if ( index < 1 || index >= MAX_STATUSBAR_VALUES ) + if( index < 1 || index >= MAX_STATUSBAR_VALUES ) return 1; // index out of range m_iStatusValues[index] = READ_SHORT(); m_bReparseString = TRUE; - + return 1; } diff --git a/cl_dll/studio_util.cpp b/cl_dll/studio_util.cpp index df5fc4bf..a5eb39f1 100644 --- a/cl_dll/studio_util.cpp +++ b/cl_dll/studio_util.cpp @@ -18,31 +18,31 @@ AngleMatrix ==================== */ -void AngleMatrix (const float *angles, float (*matrix)[4] ) +void AngleMatrix( const float *angles, float (*matrix)[4] ) { - float angle; - float sr, sp, sy, cr, cp, cy; - - angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); - angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); - angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); + float angle; + float sr, sp, sy, cr, cp, cy; + + angle = angles[YAW] * ( M_PI*2 / 360 ); + sy = sin( angle ); + cy = cos( angle ); + angle = angles[PITCH] * ( M_PI*2 / 360 ); + sp = sin( angle ); + cp = cos( angle ); + angle = angles[ROLL] * ( M_PI*2 / 360 ); + sr = sin( angle ); + cr = cos( angle ); // matrix = (YAW * PITCH) * ROLL - matrix[0][0] = cp*cy; - matrix[1][0] = cp*sy; + matrix[0][0] = cp * cy; + matrix[1][0] = cp * sy; matrix[2][0] = -sp; - matrix[0][1] = sr*sp*cy+cr*-sy; - matrix[1][1] = sr*sp*sy+cr*cy; - matrix[2][1] = sr*cp; - matrix[0][2] = (cr*sp*cy+-sr*-sy); - matrix[1][2] = (cr*sp*sy+-sr*cy); - matrix[2][2] = cr*cp; + matrix[0][1] = sr * sp * cy + cr * -sy; + matrix[1][1] = sr * sp * sy + cr * cy; + matrix[2][1] = sr * cp; + matrix[0][2] = (cr * sp * cy + -sr * -sy); + matrix[1][2] = (cr * sp * sy + -sr* cy); + matrix[2][2] = cr * cp; matrix[0][3] = 0.0; matrix[1][3] = 0.0; matrix[2][3] = 0.0; @@ -54,14 +54,14 @@ VectorCompare ==================== */ -int VectorCompare (const float *v1, const float *v2) +int VectorCompare( const float *v1, const float *v2 ) { - int i; - - for (i=0 ; i<3 ; i++) - if (v1[i] != v2[i]) + int i; + + for( i = 0; i < 3; i++ ) + if( v1[i] != v2[i] ) return 0; - + return 1; } @@ -71,7 +71,7 @@ CrossProduct ==================== */ -void CrossProduct (const float *v1, const float *v2, float *cross) +void CrossProduct( const float *v1, const float *v2, float *cross ) { cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; @@ -84,7 +84,7 @@ VectorTransform ==================== */ -void VectorTransform (const float *in1, float in2[3][4], float *out) +void VectorTransform( const float *in1, float in2[3][4], float *out ) { out[0] = DotProduct(in1, in2[0]) + in2[0][3]; out[1] = DotProduct(in1, in2[1]) + in2[1][3]; @@ -97,7 +97,7 @@ ConcatTransforms ================ */ -void ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]) +void ConcatTransforms( float in1[3][4], float in2[3][4], float out[3][4] ) { out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] + in1[0][2] * in2[2][0]; @@ -135,24 +135,24 @@ AngleQuaternion */ void AngleQuaternion( float *angles, vec4_t quaternion ) { - float angle; - float sr, sp, sy, cr, cp, cy; + float angle; + float sr, sp, sy, cr, cp, cy; // FIXME: rescale the inputs to 1/2 angle angle = angles[2] * 0.5; - sy = sin(angle); - cy = cos(angle); + sy = sin( angle ); + cy = cos( angle ); angle = angles[1] * 0.5; - sp = sin(angle); - cp = cos(angle); + sp = sin( angle ); + cp = cos( angle ); angle = angles[0] * 0.5; - sr = sin(angle); - cr = cos(angle); + sr = sin( angle ); + cr = cos( angle ); - quaternion[0] = sr*cp*cy-cr*sp*sy; // X - quaternion[1] = cr*sp*cy+sr*cp*sy; // Y - quaternion[2] = cr*cp*sy-sr*sp*cy; // Z - quaternion[3] = cr*cp*cy+sr*sp*sy; // W + quaternion[0] = sr * cp * cy - cr * sp * sy; // X + quaternion[1] = cr * sp * cy + sr * cp * sy; // Y + quaternion[2] = cr * cp * sy - sr * sp * cy; // Z + quaternion[3] = cr * cp * cy + sr * sp * sy; // W } /* @@ -164,42 +164,43 @@ QuaternionSlerp void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt ) { int i; - float omega, cosom, sinom, sclp, sclq; + float omega, cosom, sinom, sclp, sclq; // decide if one of the quaternions is backwards float a = 0; float b = 0; - for (i = 0; i < 4; i++) + for( i = 0; i < 4; i++ ) { - a += (p[i]-q[i])*(p[i]-q[i]); - b += (p[i]+q[i])*(p[i]+q[i]); + a += ( p[i] - q[i] ) * ( p[i] - q[i] ); + b += ( p[i] + q[i] ) * ( p[i] + q[i] ); } - if (a > b) + if(a > b) { - for (i = 0; i < 4; i++) + for( i = 0; i < 4; i++ ) { q[i] = -q[i]; } } - cosom = p[0]*q[0] + p[1]*q[1] + p[2]*q[2] + p[3]*q[3]; + cosom = p[0] * q[0] + p[1] * q[1] + p[2] * q[2] + p[3] * q[3]; - if ((1.0 + cosom) > 0.000001) + if( ( 1.0 + cosom ) > 0.000001 ) { - if ((1.0 - cosom) > 0.000001) + if( ( 1.0 - cosom ) > 0.000001 ) { omega = acos( cosom ); sinom = sin( omega ); - sclp = sin( (1.0 - t)*omega) / sinom; - sclq = sin( t*omega ) / sinom; + sclp = sin( ( 1.0 - t ) * omega ) / sinom; + sclq = sin( t * omega ) / sinom; } else { sclp = 1.0 - t; sclq = t; } - for (i = 0; i < 4; i++) { + for( i = 0; i < 4; i++ ) + { qt[i] = sclp * p[i] + sclq * q[i]; } } @@ -209,9 +210,9 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt ) qt[1] = q[0]; qt[2] = -q[3]; qt[3] = q[2]; - sclp = sin( (1.0 - t) * (0.5 * M_PI)); - sclq = sin( t * (0.5 * M_PI)); - for (i = 0; i < 3; i++) + sclp = sin( ( 1.0 - t ) * ( 0.5 * M_PI ) ); + sclq = sin( t * ( 0.5 * M_PI ) ); + for( i = 0; i < 3; i++ ) { qt[i] = sclp * p[i] + sclq * qt[i]; } @@ -248,4 +249,4 @@ MatrixCopy void MatrixCopy( float in[3][4], float out[3][4] ) { memcpy( out, in, sizeof( float ) * 3 * 4 ); -} \ No newline at end of file +} diff --git a/cl_dll/studio_util.h b/cl_dll/studio_util.h index aa8dcf6b..963dcda7 100644 --- a/cl_dll/studio_util.h +++ b/cl_dll/studio_util.h @@ -25,16 +25,15 @@ #define ROLL 2 #endif -#define FDotProduct( a, b ) (fabs((a[0])*(b[0])) + fabs((a[1])*(b[1])) + fabs((a[2])*(b[2]))) +#define FDotProduct( a, b ) ( fabs( ( a[0] ) * ( b[0] ) ) + fabs( ( a[1] ) * ( b[1] ) ) + fabs( ( a[2] ) * ( b[2] ) ) ) -void AngleMatrix (const float *angles, float (*matrix)[4] ); -int VectorCompare (const float *v1, const float *v2); -void CrossProduct (const float *v1, const float *v2, float *cross); -void VectorTransform (const float *in1, float in2[3][4], float *out); -void ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]); +void AngleMatrix( const float *angles, float (*matrix)[4] ); +int VectorCompare( const float *v1, const float *v2 ); +void CrossProduct( const float *v1, const float *v2, float *cross ); +void VectorTransform( const float *in1, float in2[3][4], float *out ); +void ConcatTransforms( float in1[3][4], float in2[3][4], float out[3][4] ); void MatrixCopy( float in[3][4], float out[3][4] ); void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] ); void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt ); void AngleQuaternion( float *angles, vec4_t quaternion ); - -#endif // STUDIO_UTIL_H \ No newline at end of file +#endif // STUDIO_UTIL_H diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index eb6f73a9..af62a915 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -26,10 +26,9 @@ #include #include "parsemsg.h" - DECLARE_MESSAGE( m_TextMessage, TextMsg ) -int CHudTextMessage::Init(void) +int CHudTextMessage::Init( void ) { HOOK_MESSAGE( TextMsg ); @@ -46,14 +45,14 @@ int CHudTextMessage::Init(void) char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ) { char *dst = dst_buffer; - for ( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) + for( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) { - if ( *src == '#' ) + if( *src == '#' ) { // cut msg name out of string static char word_buf[255]; char *wdst = word_buf, *word_start = src; - for ( ++src ; (*src >= 'A' && *src <= 'z') || (*src >= '0' && *src <= '9'); wdst++, src++ ) + for( ++src; ( *src >= 'A' && *src <= 'z' ) || ( *src >= '0' && *src <= '9' ); wdst++, src++ ) { *wdst = *src; } @@ -61,7 +60,7 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in // lookup msg name in titles.txt client_textmessage_t *clmsg = TextMessageGet( word_buf ); - if ( !clmsg || !(clmsg->pMessage) ) + if( !clmsg || !( clmsg->pMessage ) ) { src = word_start; *dst = *src; @@ -70,7 +69,7 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in } // copy string into message over the msg name - for ( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ ) + for( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ ) { *dst = *wsrc; } @@ -84,7 +83,7 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in } } - dst_buffer[buffer_size-1] = 0; // ensure null termination + dst_buffer[buffer_size - 1] = 0; // ensure null termination return dst_buffer; } @@ -99,30 +98,31 @@ char *CHudTextMessage::BufferedLocaliseTextString( const char *msg ) // Simplified version of LocaliseTextString; assumes string is only one word char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) { - if ( !msg ) + if( !msg ) return ""; // '#' character indicates this is a reference to a string in titles.txt, and not the string itself - if ( msg[0] == '#' ) + if( msg[0] == '#' ) { // this is a message name, so look up the real message - client_textmessage_t *clmsg = TextMessageGet( msg+1 ); + client_textmessage_t *clmsg = TextMessageGet( msg + 1 ); - if ( !clmsg || !(clmsg->pMessage) ) + if( !clmsg || !(clmsg->pMessage) ) return (char*)msg; // lookup failed, so return the original string - - if ( msg_dest ) + + if( msg_dest ) { // check to see if titles.txt info overrides msg destination // if clmsg->effect is less than 0, then clmsg->effect holds -1 * message_destination - if ( clmsg->effect < 0 ) // + if( clmsg->effect < 0 ) // *msg_dest = -clmsg->effect; } return (char*)clmsg->pMessage; } else - { // nothing special about this message, so just return the same string + { + // nothing special about this message, so just return the same string return (char*)msg; } } @@ -130,7 +130,7 @@ char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) void StripEndNewlineFromString( char *str ) { int s = strlen( str ) - 1; - if ( str[s] == '\n' || str[s] == '\r' ) + if( str[s] == '\n' || str[s] == '\r' ) str[s] = 0; } @@ -138,8 +138,8 @@ void StripEndNewlineFromString( char *str ) // returns a pointer to str char* ConvertCRtoNL( char *str ) { - for ( char *ch = str; *ch != 0; ch++ ) - if ( *ch == '\r' ) + for( char *ch = str; *ch != 0; ch++ ) + if( *ch == '\r' ) *ch = '\n'; return str; } @@ -181,24 +181,21 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf StripEndNewlineFromString( sstr4 ); char *psz = szBuf[5]; - switch ( msg_dest ) + switch( msg_dest ) { case HUD_PRINTCENTER: sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); CenterPrint( ConvertCRtoNL( psz ) ); break; - case HUD_PRINTNOTIFY: psz[0] = 1; // mark this message to go into the notify buffer - sprintf( psz+1, msg_text, sstr1, sstr2, sstr3, sstr4 ); + sprintf( psz + 1, msg_text, sstr1, sstr2, sstr3, sstr4 ); ConsolePrint( ConvertCRtoNL( psz ) ); break; - case HUD_PRINTTALK: sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 ); break; - case HUD_PRINTCONSOLE: sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); ConsolePrint( ConvertCRtoNL( psz ) ); diff --git a/cl_dll/tf_defs.h b/cl_dll/tf_defs.h index 06d9af09..a9270f1e 100644 --- a/cl_dll/tf_defs.h +++ b/cl_dll/tf_defs.h @@ -362,7 +362,6 @@ enum // Silent Spy Feign #define TF_SPY_SILENTDIE 199 - /*==================================================*/ /* Defines for the ENGINEER's Building ability */ /*==================================================*/ @@ -458,28 +457,28 @@ enum // HL-compatible weapon numbers #define WEAPON_HOOK 1 -#define WEAPON_BIOWEAPON (WEAPON_HOOK+1) -#define WEAPON_MEDIKIT (WEAPON_HOOK+2) -#define WEAPON_SPANNER (WEAPON_HOOK+3) -#define WEAPON_AXE (WEAPON_HOOK+4) -#define WEAPON_SNIPER_RIFLE (WEAPON_HOOK+5) -#define WEAPON_AUTO_RIFLE (WEAPON_HOOK+6) -#define WEAPON_TF_SHOTGUN (WEAPON_HOOK+7) -#define WEAPON_SUPER_SHOTGUN (WEAPON_HOOK+8) -#define WEAPON_NAILGUN (WEAPON_HOOK+9) -#define WEAPON_SUPER_NAILGUN (WEAPON_HOOK+10) -#define WEAPON_GRENADE_LAUNCHER (WEAPON_HOOK+11) -#define WEAPON_FLAMETHROWER (WEAPON_HOOK+12) -#define WEAPON_ROCKET_LAUNCHER (WEAPON_HOOK+13) -#define WEAPON_INCENDIARY (WEAPON_HOOK+14) -#define WEAPON_ASSAULT_CANNON (WEAPON_HOOK+16) -#define WEAPON_LIGHTNING (WEAPON_HOOK+17) -#define WEAPON_DETPACK (WEAPON_HOOK+18) -#define WEAPON_TRANQ (WEAPON_HOOK+19) -#define WEAPON_LASER (WEAPON_HOOK+20) -#define WEAPON_PIPEBOMB_LAUNCHER (WEAPON_HOOK+21) -#define WEAPON_KNIFE (WEAPON_HOOK+22) -#define WEAPON_BENCHMARK (WEAPON_HOOK+23) +#define WEAPON_BIOWEAPON (WEAPON_HOOK + 1) +#define WEAPON_MEDIKIT (WEAPON_HOOK + 2) +#define WEAPON_SPANNER (WEAPON_HOOK + 3) +#define WEAPON_AXE (WEAPON_HOOK + 4) +#define WEAPON_SNIPER_RIFLE (WEAPON_HOOK + 5) +#define WEAPON_AUTO_RIFLE (WEAPON_HOOK + 6) +#define WEAPON_TF_SHOTGUN (WEAPON_HOOK + 7) +#define WEAPON_SUPER_SHOTGUN (WEAPON_HOOK + 8) +#define WEAPON_NAILGUN (WEAPON_HOOK + 9) +#define WEAPON_SUPER_NAILGUN (WEAPON_HOOK + 10) +#define WEAPON_GRENADE_LAUNCHER (WEAPON_HOOK + 11) +#define WEAPON_FLAMETHROWER (WEAPON_HOOK + 12) +#define WEAPON_ROCKET_LAUNCHER (WEAPON_HOOK + 13) +#define WEAPON_INCENDIARY (WEAPON_HOOK + 14) +#define WEAPON_ASSAULT_CANNON (WEAPON_HOOK + 16) +#define WEAPON_LIGHTNING (WEAPON_HOOK + 17) +#define WEAPON_DETPACK (WEAPON_HOOK + 18) +#define WEAPON_TRANQ (WEAPON_HOOK + 19) +#define WEAPON_LASER (WEAPON_HOOK + 20) +#define WEAPON_PIPEBOMB_LAUNCHER (WEAPON_HOOK + 21) +#define WEAPON_KNIFE (WEAPON_HOOK + 22) +#define WEAPON_BENCHMARK (WEAPON_HOOK + 23) /*==================================================*/ /* New Weapon Related Defines */ @@ -509,7 +508,7 @@ enum // Detpack #define WEAP_DETPACK_DISARMTIME 3 // Time it takes to disarm a Detpack #define WEAP_DETPACK_SETTIME 3 // Time it takes to set a Detpack -#define WEAP_DETPACK_SIZE 700 // Explosion Size +#define WEAP_DETPACK_SIZE 700 // Explosion Size #define WEAP_DETPACK_GOAL_SIZE 1500 // Explosion Size for goal triggering #define WEAP_DETPACK_BITS_NO 12 // Bits that detpack explodes into @@ -519,15 +518,15 @@ enum // Grenades #define GR_PRIMETIME 3 #define GR_CALTROP_PRIME 0.5 -#define GR_TYPE_NONE 0 -#define GR_TYPE_NORMAL 1 -#define GR_TYPE_CONCUSSION 2 -#define GR_TYPE_NAIL 3 -#define GR_TYPE_MIRV 4 -#define GR_TYPE_NAPALM 5 -//#define GR_TYPE_FLARE 6 -#define GR_TYPE_GAS 7 -#define GR_TYPE_EMP 8 +#define GR_TYPE_NONE 0 +#define GR_TYPE_NORMAL 1 +#define GR_TYPE_CONCUSSION 2 +#define GR_TYPE_NAIL 3 +#define GR_TYPE_MIRV 4 +#define GR_TYPE_NAPALM 5 +//#define GR_TYPE_FLARE 6 +#define GR_TYPE_GAS 7 +#define GR_TYPE_EMP 8 #define GR_TYPE_CALTROP 9 //#define GR_TYPE_FLASH 10 @@ -542,8 +541,8 @@ enum // Defines for Concussion Grenade #define GR_CONCUSS_TIME 0.25 #define GR_CONCUSS_DEC 10 -#define MEDIUM_PING 150 -#define HIGH_PING 200 +#define MEDIUM_PING 150 +#define HIGH_PING 200 // Defines for the Gas Grenade #define GR_HALLU_TIME 0.3 @@ -551,7 +550,7 @@ enum #define GR_HALLU_DEC 2.5 // Defines for the BioInfection -#define BIO_JUMP_RADIUS 128 // The distance the bioinfection can jump between players +#define BIO_JUMP_RADIUS 128 // The distance the bioinfection can jump between players /*==================================================*/ /* New Items */ @@ -1382,8 +1381,5 @@ public: void Spawn( void ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); }; - #endif // TF_DEFS_ONLY #endif // __TF_DEFS_H - - diff --git a/cl_dll/train.cpp b/cl_dll/train.cpp index 1cbbb444..de480ec2 100644 --- a/cl_dll/train.cpp +++ b/cl_dll/train.cpp @@ -24,59 +24,56 @@ #include #include "parsemsg.h" -DECLARE_MESSAGE(m_Train, Train ) +DECLARE_MESSAGE( m_Train, Train ) - -int CHudTrain::Init(void) +int CHudTrain::Init( void ) { HOOK_MESSAGE( Train ); m_iPos = 0; m_iFlags = 0; - gHUD.AddHudElem(this); + gHUD.AddHudElem( this ); return 1; } -int CHudTrain::VidInit(void) +int CHudTrain::VidInit( void ) { m_hSprite = 0; return 1; } -int CHudTrain::Draw(float fTime) +int CHudTrain::Draw( float fTime ) { - if ( !m_hSprite ) - m_hSprite = LoadSprite("sprites/%d_train.spr"); + if( !m_hSprite ) + m_hSprite = LoadSprite( "sprites/%d_train.spr" ); - if (m_iPos) + if( m_iPos ) { int r, g, b, x, y; - UnpackRGB(r,g,b, RGB_YELLOWISH); - SPR_Set(m_hSprite, r, g, b ); + UnpackRGB( r, g, b, RGB_YELLOWISH ); + SPR_Set( m_hSprite, r, g, b ); // This should show up to the right and part way up the armor number - y = ScreenHeight - SPR_Height(m_hSprite,0) - gHUD.m_iFontHeight; - x = ScreenWidth/3 + SPR_Width(m_hSprite,0)/4; - - SPR_DrawAdditive( m_iPos - 1, x, y, NULL); + y = ScreenHeight - SPR_Height( m_hSprite, 0 ) - gHUD.m_iFontHeight; + x = ScreenWidth / 3 + SPR_Width( m_hSprite, 0 ) / 4; + SPR_DrawAdditive( m_iPos - 1, x, y, NULL ); } return 1; } - -int CHudTrain::MsgFunc_Train(const char *pszName, int iSize, void *pbuf) +int CHudTrain::MsgFunc_Train( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); // update Train data m_iPos = READ_BYTE(); - if (m_iPos) + if( m_iPos ) m_iFlags |= HUD_ACTIVE; else m_iFlags &= ~HUD_ACTIVE; diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index 77d1d466..517ef982 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -40,7 +40,7 @@ void Draw_Triangles( void ) // Load it up with some bogus data player = gEngfuncs.GetLocalPlayer(); - if ( !player ) + if( !player ) return; org = player->origin; @@ -48,18 +48,18 @@ void Draw_Triangles( void ) org.x += 50; org.y += 50; - if (gHUD.m_hsprCursor == 0) + if( gHUD.m_hsprCursor == 0 ) { char sz[256]; sprintf( sz, "sprites/cursor.spr" ); gHUD.m_hsprCursor = SPR_Load( sz ); } - if ( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 )) + if( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ) ) { return; } - + // Create a triangle, sigh gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); gEngfuncs.pTriAPI->CullFace( TRI_NONE ); @@ -86,7 +86,6 @@ void Draw_Triangles( void ) gEngfuncs.pTriAPI->End(); gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); } - #endif /* @@ -98,9 +97,7 @@ Non-transparent triangles-- add them here */ void DLLEXPORT HUD_DrawNormalTriangles( void ) { - gHUD.m_Spectator.DrawOverview(); - #if defined( TEST_IT ) // Draw_Triangles(); #endif @@ -115,7 +112,6 @@ Render any triangles with transparent rendermode needs here */ void DLLEXPORT HUD_DrawTransparentTriangles( void ) { - #if defined( TEST_IT ) // Draw_Triangles(); #endif diff --git a/cl_dll/util.cpp b/cl_dll/util.cpp index 14474a9f..52dc2f61 100644 --- a/cl_dll/util.cpp +++ b/cl_dll/util.cpp @@ -32,102 +32,100 @@ extern vec3_t vec3_origin; -double sqrt(double x); +double sqrt( double x ); -float Length(const float *v) +float Length( const float *v ) { - int i; + int i; float length; - + length = 0; - for (i=0 ; i< 3 ; i++) - length += v[i]*v[i]; - length = sqrt (length); // FIXME + for( i = 0; i < 3; i++ ) + length += v[i] * v[i]; + length = sqrt( length ); // FIXME return length; } void VectorAngles( const float *forward, float *angles ) { - float tmp, yaw, pitch; - - if (forward[1] == 0 && forward[0] == 0) + float tmp, yaw, pitch; + + if( forward[1] == 0 && forward[0] == 0 ) { yaw = 0; - if (forward[2] > 0) + if( forward[2] > 0 ) pitch = 90; else pitch = 270; } else { - yaw = (atan2(forward[1], forward[0]) * 180 / M_PI); - if (yaw < 0) + yaw = ( atan2( forward[1], forward[0]) * 180 / M_PI ); + if( yaw < 0 ) yaw += 360; - tmp = sqrt (forward[0]*forward[0] + forward[1]*forward[1]); - pitch = (atan2(forward[2], tmp) * 180 / M_PI); - if (pitch < 0) + tmp = sqrt( forward[0] * forward[0] + forward[1] * forward[1] ); + pitch = ( atan2( forward[2], tmp ) * 180 / M_PI ); + if( pitch < 0 ) pitch += 360; } - + angles[0] = pitch; angles[1] = yaw; angles[2] = 0; } -float VectorNormalize (float *v) +float VectorNormalize( float *v ) { - float length, ilength; + float length, ilength; - length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - length = sqrt (length); // FIXME + length = v[0] * v[0] + v[1] * v[1] + v[2] * v[2]; + length = sqrt( length ); // FIXME - if (length) + if( length ) { - ilength = 1/length; + ilength = 1 / length; v[0] *= ilength; v[1] *= ilength; v[2] *= ilength; } - - return length; + return length; } -void VectorInverse ( float *v ) +void VectorInverse( float *v ) { v[0] = -v[0]; v[1] = -v[1]; v[2] = -v[2]; } -void VectorScale (const float *in, float scale, float *out) +void VectorScale( const float *in, float scale, float *out ) { - out[0] = in[0]*scale; - out[1] = in[1]*scale; - out[2] = in[2]*scale; + out[0] = in[0] * scale; + out[1] = in[1] * scale; + out[2] = in[2] * scale; } -void VectorMA (const float *veca, float scale, const float *vecb, float *vecc) +void VectorMA( const float *veca, float scale, const float *vecb, float *vecc ) { - vecc[0] = veca[0] + scale*vecb[0]; - vecc[1] = veca[1] + scale*vecb[1]; - vecc[2] = veca[2] + scale*vecb[2]; + vecc[0] = veca[0] + scale * vecb[0]; + vecc[1] = veca[1] + scale * vecb[1]; + vecc[2] = veca[2] + scale * vecb[2]; } -HSPRITE LoadSprite(const char *pszName) +HSPRITE LoadSprite( const char *pszName ) { int i; - char sz[256]; + char sz[256]; - if (ScreenWidth < 640) + if( ScreenWidth < 640 ) i = 320; else i = 640; - sprintf(sz, pszName, i); + sprintf( sz, pszName, i ); - return SPR_Load(sz); + return SPR_Load( sz ); } - diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index fdac17cc..ff5f9a91 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -22,8 +22,8 @@ #include "math.h" // Header file containing definition of globalvars_t and entvars_t -typedef unsigned int func_t; // -typedef unsigned int string_t; // from engine's pr_comp.h; +typedef unsigned int func_t; // +typedef unsigned int string_t; // from engine's pr_comp.h; typedef float vec_t; // needed before including progdefs.h //========================================================= @@ -33,21 +33,21 @@ typedef float vec_t; // needed before including progdefs.h class Vector2D { public: - inline Vector2D(void) { } - inline Vector2D(float X, float Y) { x = X; y = Y; } - inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); } - inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); } - inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); } - inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); } - - inline float Length(void) const { return (float)sqrt(x*x + y*y ); } + inline Vector2D( void ) { } + inline Vector2D( float X, float Y ) { x = X; y = Y; } + inline Vector2D operator+( const Vector2D& v ) const { return Vector2D(x+v.x, y+v.y); } + inline Vector2D operator-( const Vector2D& v ) const { return Vector2D(x-v.x, y-v.y); } + inline Vector2D operator*( float fl ) const { return Vector2D(x*fl, y*fl); } + inline Vector2D operator/( float fl ) const { return Vector2D(x/fl, y/fl); } - inline Vector2D Normalize ( void ) const + inline float Length( void ) const { return (float)sqrt(x*x + y*y ); } + + inline Vector2D Normalize( void ) const { Vector2D vec2; float flLen = Length(); - if ( flLen == 0 ) + if( flLen == 0 ) { return Vector2D( (float)0, (float)0 ); } @@ -61,61 +61,66 @@ public: vec_t x, y; }; -inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); } -inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; } +inline float DotProduct( const Vector2D& a, const Vector2D& b ) { return( a.x * b.x + a.y * b.y ); } +inline Vector2D operator*( float fl, const Vector2D& v ) { return v * fl; } //========================================================= // 3D Vector //========================================================= class Vector // same data-layout as engine's vec3_t, -{ // which is a vec_t[3] +{ //which is a vec_t[3] public: // Construction/destruction - inline Vector(void) { } - inline Vector(float X, float Y, float Z) { x = X; y = Y; z = Z; } - inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector(const Vector& v) { x = v.x; y = v.y; z = v.z; } - inline Vector(float rgfl[3]) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } + inline Vector( void ) { } + inline Vector( float X, float Y, float Z ) { x = X; y = Y; z = Z; } + inline Vector( double X, double Y, double Z ) { x = (float)X; y = (float)Y; z = (float)Z; } + inline Vector( int X, int Y, int Z ) { x = (float)X; y = (float)Y; z = (float)Z; } + inline Vector( const Vector& v ) { x = v.x; y = v.y; z = v.z; } + inline Vector( float rgfl[3] ) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } // Operators - inline Vector operator-(void) const { return Vector(-x,-y,-z); } - inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; } - inline int operator!=(const Vector& v) const { return !(*this==v); } - inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); } - inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); } - inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); } - inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); } + inline Vector operator-( void ) const { return Vector( -x, -y, -z ); } + inline int operator==( const Vector& v ) const { return x == v.x && y == v.y && z == v.z; } + inline int operator!=( const Vector& v ) const { return !( *this == v ); } + inline Vector operator+( const Vector& v ) const { return Vector( x + v.x, y + v.y, z + v.z ); } + inline Vector operator-( const Vector& v ) const { return Vector( x - v.x, y - v.y, z - v.z ); } + inline Vector operator*( float fl ) const { return Vector( x * fl, y * fl, z * fl ); } + inline Vector operator/( float fl ) const { return Vector( x / fl, y / fl, z / fl ); } // Methods - inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } - inline float Length(void) const { return (float)sqrt(x*x + y*y + z*z); } - operator float *() { return &x; } // Vectors will now automatically convert to float * when needed - operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed - inline Vector Normalize(void) const + inline void CopyToArray( float* rgfl ) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } + inline float Length( void ) const { return (float)sqrt( x * x + y * y + z * z); } + operator float *() { return &x; } // Vectors will now automatically convert to float * when needed + operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed + inline Vector Normalize( void ) const { float flLen = Length(); - if (flLen == 0) return Vector(0,0,1); // ???? + if( flLen == 0 ) return Vector( 0, 0, 1); // ???? flLen = 1 / flLen; - return Vector(x * flLen, y * flLen, z * flLen); + return Vector( x * flLen, y * flLen, z * flLen ); } - inline Vector2D Make2D ( void ) const + inline Vector2D Make2D( void ) const { - Vector2D Vec2; + Vector2D Vec2; Vec2.x = x; Vec2.y = y; return Vec2; } - inline float Length2D(void) const { return (float)sqrt(x*x + y*y); } + + inline float Length2D( void ) const + { + return (float)sqrt( x * x + y * y ); + } // Members vec_t x, y, z; }; -inline Vector operator*(float fl, const Vector& v) { return v * fl; } -inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); } -inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); } + +inline Vector operator*( float fl, const Vector& v ) { return v * fl; } +inline float DotProduct( const Vector& a, const Vector& b) { return( a.x * b.x + a.y * b.y + a.z * b.z ); } +inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x ); } #define vec3_t Vector diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index d0b87c53..401f2c68 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -29,11 +29,11 @@ // Spectator Mode extern "C" { - float vecNewViewAngles[3]; - int iHasNewViewAngles; - float vecNewViewOrigin[3]; - int iHasNewViewOrigin; - int iIsSpectator; + float vecNewViewAngles[3]; + int iHasNewViewAngles; + float vecNewViewOrigin[3]; + int iHasNewViewOrigin; + int iIsSpectator; } #ifndef M_PI @@ -47,19 +47,19 @@ extern "C" void DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams ); - void PM_ParticleLine( float *start, float *end, int pcolor, float life, float vert); - int PM_GetVisEntInfo( int ent ); - int PM_GetPhysEntInfo( int ent ); - void InterpolateAngles( float * start, float * end, float * output, float frac ); - void NormalizeAngles( float * angles ); - float Distance(const float * v1, const float * v2); - float AngleBetweenVectors( const float * v1, const float * v2 ); + void PM_ParticleLine( float *start, float *end, int pcolor, float life, float vert ); + int PM_GetVisEntInfo( int ent ); + int PM_GetPhysEntInfo( int ent ); + void InterpolateAngles( float * start, float * end, float * output, float frac ); + void NormalizeAngles( float * angles ); + float Distance( const float * v1, const float * v2 ); + float AngleBetweenVectors( const float * v1, const float * v2 ); - float vJumpOrigin[3]; - float vJumpAngles[3]; + float vJumpOrigin[3]; + float vJumpAngles[3]; } -void V_DropPunchAngle ( float frametime, float *ev_punchangle ); +void V_DropPunchAngle( float frametime, float *ev_punchangle ); void VectorAngles( const float *forward, float *angles ); #include "r_studioint.h" @@ -82,12 +82,12 @@ extern cvar_t *cl_vsmoothing; #define CAM_MODE_RELAX 1 #define CAM_MODE_FOCUS 2 -vec3_t v_origin, v_angles, v_cl_angles, v_sim_org, v_lastAngles; -float v_frametime, v_lastDistance; -float v_cameraRelaxAngle = 5.0f; -float v_cameraFocusAngle = 35.0f; -int v_cameraMode = CAM_MODE_FOCUS; -qboolean v_resetCamera = 1; +vec3_t v_origin, v_angles, v_cl_angles, v_sim_org, v_lastAngles; +float v_frametime, v_lastDistance; +float v_cameraRelaxAngle = 5.0f; +float v_cameraFocusAngle = 35.0f; +int v_cameraMode = CAM_MODE_FOCUS; +qboolean v_resetCamera = 1; vec3_t ev_punchangle; @@ -120,21 +120,21 @@ float v_idlescale; // used by TFC for concussion grenade effect void V_NormalizeAngles( float *angles ) { int i; + // Normalize angles - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - if ( angles[i] > 180.0 ) + if( angles[i] > 180.0 ) { angles[i] -= 360.0; } - else if ( angles[i] < -180.0 ) + else if( angles[i] < -180.0 ) { angles[i] += 360.0; } } } - =================== V_InterpolateAngles @@ -148,22 +148,22 @@ void V_InterpolateAngles( float *start, float *end, float *output, float frac ) int i; float ang1, ang2; float d; - + V_NormalizeAngles( start ); V_NormalizeAngles( end ); - for ( i = 0 ; i < 3 ; i++ ) + for( i = 0 ; i < 3 ; i++ ) { ang1 = start[i]; ang2 = end[i]; d = ang2 - ang1; - if ( d > 180 ) + if( d > 180 ) { d -= 360; } - else if ( d < -180 ) - { + else if( d < -180 ) + { d += 360; } @@ -174,16 +174,15 @@ void V_InterpolateAngles( float *start, float *end, float *output, float frac ) } */ // Quakeworld bob code, this fixes jitters in the mutliplayer since the clock (pparams->time) isn't quite linear -float V_CalcBob ( struct ref_params_s *pparams ) +float V_CalcBob( struct ref_params_s *pparams ) { - static double bobtime; - static float bob; - float cycle; - static float lasttime; + static double bobtime; + static float bob; + float cycle; + static float lasttime; vec3_t vel; - - if ( pparams->onground == -1 || + if( pparams->onground == -1 || pparams->time == lasttime ) { // just use old value @@ -195,8 +194,8 @@ float V_CalcBob ( struct ref_params_s *pparams ) bobtime += pparams->frametime; cycle = bobtime - (int)( bobtime / cl_bobcycle->value ) * cl_bobcycle->value; cycle /= cl_bobcycle->value; - - if ( cycle < cl_bobup->value ) + + if( cycle < cl_bobup->value ) { cycle = M_PI * cycle / cl_bobup->value; } @@ -215,7 +214,6 @@ float V_CalcBob ( struct ref_params_s *pparams ) bob = min( bob, 4 ); bob = max( bob, -7 ); return bob; - } /* @@ -224,25 +222,25 @@ V_CalcRoll Used by view and sv_user =============== */ -float V_CalcRoll (vec3_t angles, vec3_t velocity, float rollangle, float rollspeed ) +float V_CalcRoll( vec3_t angles, vec3_t velocity, float rollangle, float rollspeed ) { - float sign; - float side; - float value; - vec3_t forward, right, up; - - AngleVectors ( angles, forward, right, up ); - - side = DotProduct (velocity, right); - sign = side < 0 ? -1 : 1; - side = fabs( side ); - + float sign; + float side; + float value; + vec3_t forward, right, up; + + AngleVectors( angles, forward, right, up ); + + side = DotProduct( velocity, right ); + sign = side < 0 ? -1 : 1; + side = fabs( side ); + value = rollangle; - if (side < rollspeed) + if( side < rollspeed ) { side = side * value / rollspeed; } - else + else { side = value; } @@ -251,15 +249,14 @@ float V_CalcRoll (vec3_t angles, vec3_t velocity, float rollangle, float rollspe typedef struct pitchdrift_s { - float pitchvel; - int nodrift; - float driftmove; - double laststop; + float pitchvel; + int nodrift; + float driftmove; + double laststop; } pitchdrift_t; static pitchdrift_t pd; - /* =============== V_DriftPitch @@ -282,21 +279,21 @@ mlook and mouse, or klook and keyboard, pitch drifting is constantly stopped. V_CalcGunAngle ================== */ -void V_CalcGunAngle ( struct ref_params_s *pparams ) +void V_CalcGunAngle( struct ref_params_s *pparams ) { cl_entity_t *viewent; - + viewent = gEngfuncs.GetViewModel(); - if ( !viewent ) + if( !viewent ) return; - viewent->angles[YAW] = pparams->viewangles[YAW] + pparams->crosshairangle[YAW]; + viewent->angles[YAW] = pparams->viewangles[YAW] + pparams->crosshairangle[YAW]; viewent->angles[PITCH] = -pparams->viewangles[PITCH] + pparams->crosshairangle[PITCH] * 0.25; - viewent->angles[ROLL] -= v_idlescale * sin(pparams->time*v_iroll_cycle.value) * v_iroll_level.value; - + viewent->angles[ROLL] -= v_idlescale * sin( pparams->time * v_iroll_cycle.value ) * v_iroll_level.value; + // don't apply all of the v_ipitch to prevent normally unseen parts of viewmodel from coming into view. - viewent->angles[PITCH] -= v_idlescale * sin(pparams->time*v_ipitch_cycle.value) * (v_ipitch_level.value * 0.5); - viewent->angles[YAW] -= v_idlescale * sin(pparams->time*v_iyaw_cycle.value) * v_iyaw_level.value; + viewent->angles[PITCH] -= v_idlescale * sin( pparams->time * v_ipitch_cycle.value ) * ( v_ipitch_level.value * 0.5 ); + viewent->angles[YAW] -= v_idlescale * sin( pparams->time * v_iyaw_cycle.value ) * v_iyaw_level.value; VectorCopy( viewent->angles, viewent->curstate.angles ); VectorCopy( viewent->angles, viewent->latched.prevangles ); @@ -309,14 +306,13 @@ V_AddIdle Idle swaying ============== */ -void V_AddIdle ( struct ref_params_s *pparams ) +void V_AddIdle( struct ref_params_s *pparams ) { - pparams->viewangles[ROLL] += v_idlescale * sin(pparams->time*v_iroll_cycle.value) * v_iroll_level.value; - pparams->viewangles[PITCH] += v_idlescale * sin(pparams->time*v_ipitch_cycle.value) * v_ipitch_level.value; - pparams->viewangles[YAW] += v_idlescale * sin(pparams->time*v_iyaw_cycle.value) * v_iyaw_level.value; + pparams->viewangles[ROLL] += v_idlescale * sin( pparams->time * v_iroll_cycle.value ) * v_iroll_level.value; + pparams->viewangles[PITCH] += v_idlescale * sin( pparams->time * v_ipitch_cycle.value ) * v_ipitch_level.value; + pparams->viewangles[YAW] += v_idlescale * sin( pparams->time * v_iyaw_cycle.value ) * v_iyaw_level.value; } - /* ============== V_CalcViewRoll @@ -324,20 +320,20 @@ V_CalcViewRoll Roll is induced by movement and damage ============== */ -void V_CalcViewRoll ( struct ref_params_s *pparams ) +void V_CalcViewRoll( struct ref_params_s *pparams ) { - float side; + float side; cl_entity_t *viewentity; - + viewentity = gEngfuncs.GetEntityByIndex( pparams->viewentity ); - if ( !viewentity ) + if( !viewentity ) return; - side = V_CalcRoll ( viewentity->angles, pparams->simvel, pparams->movevars->rollangle, pparams->movevars->rollspeed ); + side = V_CalcRoll( viewentity->angles, pparams->simvel, pparams->movevars->rollangle, pparams->movevars->rollspeed ); pparams->viewangles[ROLL] += side; - if ( pparams->health <= 0 && ( pparams->viewheight[2] != 0 ) ) + if( pparams->health <= 0 && ( pparams->viewheight[2] != 0 ) ) { // only roll the view if the player is dead and the viewheight[2] is nonzero // this is so deadcam in multiplayer will work. @@ -346,26 +342,25 @@ void V_CalcViewRoll ( struct ref_params_s *pparams ) } } - /* ================== V_CalcIntermissionRefdef ================== */ -void V_CalcIntermissionRefdef ( struct ref_params_s *pparams ) +void V_CalcIntermissionRefdef( struct ref_params_s *pparams ) { - cl_entity_t *ent, *view; - float old; + cl_entity_t *ent, *view; + float old; // ent is the player model ( visible when out of body ) ent = gEngfuncs.GetLocalPlayer(); - + // view is the weapon model (only visible from inside body ) view = gEngfuncs.GetViewModel(); - VectorCopy ( pparams->simorg, pparams->vieworg ); - VectorCopy ( pparams->cl_viewangles, pparams->viewangles ); + VectorCopy( pparams->simorg, pparams->vieworg ); + VectorCopy( pparams->cl_viewangles, pparams->viewangles ); view->model = NULL; @@ -373,9 +368,9 @@ void V_CalcIntermissionRefdef ( struct ref_params_s *pparams ) old = v_idlescale; v_idlescale = 1; - V_AddIdle ( pparams ); + V_AddIdle( pparams ); - if ( gEngfuncs.IsSpectateOnly() ) + if( gEngfuncs.IsSpectateOnly() ) { // in HLTV we must go to 'intermission' position by ourself VectorCopy( gHUD.m_Spectator.m_cameraOrigin, pparams->vieworg ); @@ -394,11 +389,11 @@ void V_CalcIntermissionRefdef ( struct ref_params_s *pparams ) typedef struct { - float Origins[ ORIGIN_BACKUP ][3]; - float OriginTime[ ORIGIN_BACKUP ]; + float Origins[ORIGIN_BACKUP][3]; + float OriginTime[ORIGIN_BACKUP]; - float Angles[ ORIGIN_BACKUP ][3]; - float AngleTime[ ORIGIN_BACKUP ]; + float Angles[ORIGIN_BACKUP][3]; + float AngleTime[ORIGIN_BACKUP]; int CurrentOrigin; int CurrentAngle; @@ -410,13 +405,13 @@ V_CalcRefdef ================== */ -void V_CalcNormalRefdef ( struct ref_params_s *pparams ) +void V_CalcNormalRefdef( struct ref_params_s *pparams ) { - cl_entity_t *ent, *view; - int i; - vec3_t angles; - float bob, waterOffset; - static viewinterp_t ViewInterp; + cl_entity_t *ent, *view; + int i; + vec3_t angles; + float bob, waterOffset; + static viewinterp_t ViewInterp; static float oldz = 0; static float lasttime; @@ -424,7 +419,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) vec3_t camAngles, camForward, camRight, camUp; cl_entity_t *pwater; - if ( gEngfuncs.IsSpectateOnly() ) + if( gEngfuncs.IsSpectateOnly() ) { ent = gEngfuncs.GetEntityByIndex( g_iUser2 ); } @@ -433,20 +428,20 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) // ent is the player model ( visible when out of body ) ent = gEngfuncs.GetLocalPlayer(); } - + // view is the weapon model (only visible from inside body ) view = gEngfuncs.GetViewModel(); // transform the view offset by the model's matrix to get the offset from // model origin for the view - bob = V_CalcBob ( pparams ); + bob = V_CalcBob( pparams ); // refresh position - VectorCopy ( pparams->simorg, pparams->vieworg ); - pparams->vieworg[2] += ( bob ); + VectorCopy( pparams->simorg, pparams->vieworg ); + pparams->vieworg[2] += bob ; VectorAdd( pparams->vieworg, pparams->viewheight, pparams->vieworg ); - VectorCopy ( pparams->cl_viewangles, pparams->viewangles ); + VectorCopy( pparams->cl_viewangles, pparams->viewangles ); gEngfuncs.V_CalcShake(); gEngfuncs.V_ApplyShake( pparams->vieworg, pparams->viewangles, 1.0 ); @@ -455,28 +450,27 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) // dissapear when viewed with the eye exactly on it. // FIXME, we send origin at 1/128 now, change this? // the server protocol only specifies to 1/16 pixel, so add 1/32 in each axis - - pparams->vieworg[0] += 1.0/32; - pparams->vieworg[1] += 1.0/32; - pparams->vieworg[2] += 1.0/32; + pparams->vieworg[0] += 1.0 / 32; + pparams->vieworg[1] += 1.0 / 32; + pparams->vieworg[2] += 1.0 / 32; // Check for problems around water, move the viewer artificially if necessary // -- this prevents drawing errors in GL due to waves waterOffset = 0; - if ( pparams->waterlevel >= 2 ) + if( pparams->waterlevel >= 2 ) { - int contents, waterDist, waterEntity; - vec3_t point; + int contents, waterDist, waterEntity; + vec3_t point; waterDist = cl_waterdist->value; - if ( pparams->hardware ) + if( pparams->hardware ) { waterEntity = gEngfuncs.PM_WaterEntity( pparams->simorg ); - if ( waterEntity >= 0 && waterEntity < pparams->max_entities ) + if( waterEntity >= 0 && waterEntity < pparams->max_entities ) { pwater = gEngfuncs.GetEntityByIndex( waterEntity ); - if ( pwater && ( pwater->model != NULL ) ) + if( pwater && ( pwater->model != NULL ) ) { waterDist += ( pwater->curstate.scale * 16 ); // Add in wave height } @@ -486,58 +480,58 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) { waterEntity = 0; // Don't need this in software } - + VectorCopy( pparams->vieworg, point ); // Eyes are above water, make sure we're above the waves - if ( pparams->waterlevel == 2 ) + if( pparams->waterlevel == 2 ) { point[2] -= waterDist; - for ( i = 0; i < waterDist; i++ ) + for( i = 0; i < waterDist; i++ ) { contents = gEngfuncs.PM_PointContents( point, NULL ); - if ( contents > CONTENTS_WATER ) + if( contents > CONTENTS_WATER ) break; point[2] += 1; } - waterOffset = (point[2] + waterDist) - pparams->vieworg[2]; + waterOffset = ( point[2] + waterDist ) - pparams->vieworg[2]; } else { // eyes are under water. Make sure we're far enough under point[2] += waterDist; - for ( i = 0; i < waterDist; i++ ) + for( i = 0; i < waterDist; i++ ) { contents = gEngfuncs.PM_PointContents( point, NULL ); - if ( contents <= CONTENTS_WATER ) + if( contents <= CONTENTS_WATER ) break; point[2] -= 1; } - waterOffset = (point[2] - waterDist) - pparams->vieworg[2]; + waterOffset = ( point[2] - waterDist ) - pparams->vieworg[2]; } } pparams->vieworg[2] += waterOffset; - - V_CalcViewRoll ( pparams ); - - V_AddIdle ( pparams ); + + V_CalcViewRoll( pparams ); + + V_AddIdle( pparams ); // offsets VectorCopy( pparams->cl_viewangles, angles ); - AngleVectors ( angles, pparams->forward, pparams->right, pparams->up ); + AngleVectors( angles, pparams->forward, pparams->right, pparams->up ); // don't allow cheats in multiplayer - if ( pparams->maxclients <= 1 ) + if( pparams->maxclients <= 1 ) { - for ( i=0 ; i<3 ; i++ ) + for( i = 0; i < 3; i++ ) { pparams->vieworg[i] += scr_ofsx->value*pparams->forward[i] + scr_ofsy->value*pparams->right[i] + scr_ofsz->value*pparams->up[i]; } } - + // Treating cam_ofs[2] as the distance if( CL_IsThirdPerson() ) { @@ -548,39 +542,39 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) CL_CameraOffset( (float *)&ofs ); VectorCopy( ofs, camAngles ); - camAngles[ ROLL ] = 0; + camAngles[ROLL] = 0; AngleVectors( camAngles, camForward, camRight, camUp ); - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - pparams->vieworg[ i ] += -ofs[2] * camForward[ i ]; + pparams->vieworg[i] += -ofs[2] * camForward[i]; } } - + // Give gun our viewangles - VectorCopy ( pparams->cl_viewangles, view->angles ); - + VectorCopy( pparams->cl_viewangles, view->angles ); + // set up gun position - V_CalcGunAngle ( pparams ); + V_CalcGunAngle( pparams ); // Use predicted origin as view origin. - VectorCopy ( pparams->simorg, view->origin ); - view->origin[2] += ( waterOffset ); + VectorCopy( pparams->simorg, view->origin ); + view->origin[2] += waterOffset; VectorAdd( view->origin, pparams->viewheight, view->origin ); // Let the viewmodel shake at about 10% of the amplitude gEngfuncs.V_ApplyShake( view->origin, view->angles, 0.9 ); - for ( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { - view->origin[ i ] += bob * 0.4 * pparams->forward[ i ]; + view->origin[i] += bob * 0.4 * pparams->forward[i]; } view->origin[2] += bob; // throw in a little tilt. - view->angles[YAW] -= bob * 0.5; - view->angles[ROLL] -= bob * 1; + view->angles[YAW] -= bob * 0.5; + view->angles[ROLL] -= bob * 1; view->angles[PITCH] -= bob * 0.3; // pushing the view origin down off of the same X/Z plane as the ent's origin will give the @@ -590,46 +584,46 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) // fudge position around to keep amount of weapon visible // roughly equal with different FOV - if (pparams->viewsize == 110) + if( pparams->viewsize == 110 ) { view->origin[2] += 1; } - else if (pparams->viewsize == 100) + else if( pparams->viewsize == 100 ) { view->origin[2] += 2; } - else if (pparams->viewsize == 90) + else if( pparams->viewsize == 90 ) { view->origin[2] += 1; } - else if (pparams->viewsize == 80) + else if( pparams->viewsize == 80 ) { view->origin[2] += 0.5; } // Add in the punchangle, if any - VectorAdd ( pparams->viewangles, pparams->punchangle, pparams->viewangles ); + VectorAdd( pparams->viewangles, pparams->punchangle, pparams->viewangles ); // Include client side punch, too - VectorAdd ( pparams->viewangles, (float *)&ev_punchangle, pparams->viewangles); + VectorAdd( pparams->viewangles, (float *)&ev_punchangle, pparams->viewangles ); - V_DropPunchAngle ( pparams->frametime, (float *)&ev_punchangle ); + V_DropPunchAngle( pparams->frametime, (float *)&ev_punchangle ); // smooth out stair step ups #if 1 - if ( !pparams->smoothing && pparams->onground && pparams->simorg[2] - oldz > 0) + if( !pparams->smoothing && pparams->onground && pparams->simorg[2] - oldz > 0 ) { float steptime; - + steptime = pparams->time - lasttime; - if (steptime < 0) - //FIXME I_Error ("steptime < 0"); + if( steptime < 0 ) + //FIXME I_Error( "steptime < 0" ); steptime = 0; oldz += steptime * 150; - if (oldz > pparams->simorg[2]) + if( oldz > pparams->simorg[2] ) oldz = pparams->simorg[2]; - if (pparams->simorg[2] - oldz > 18) + if( pparams->simorg[2] - oldz > 18 ) oldz = pparams->simorg[2]- 18; pparams->vieworg[2] += oldz - pparams->simorg[2]; view->origin[2] += oldz - pparams->simorg[2]; @@ -639,17 +633,16 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) oldz = pparams->simorg[2]; } #endif - { static float lastorg[3]; vec3_t delta; VectorSubtract( pparams->simorg, lastorg, delta ); - if ( Length( delta ) != 0.0 ) + if( Length( delta ) != 0.0 ) { - VectorCopy( pparams->simorg, ViewInterp.Origins[ ViewInterp.CurrentOrigin & ORIGIN_MASK ] ); - ViewInterp.OriginTime[ ViewInterp.CurrentOrigin & ORIGIN_MASK ] = pparams->time; + VectorCopy( pparams->simorg, ViewInterp.Origins[ViewInterp.CurrentOrigin & ORIGIN_MASK] ); + ViewInterp.OriginTime[ViewInterp.CurrentOrigin & ORIGIN_MASK] = pparams->time; ViewInterp.CurrentOrigin++; VectorCopy( pparams->simorg, lastorg ); @@ -657,27 +650,27 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) } // Smooth out whole view in multiplayer when on trains, lifts - if ( cl_vsmoothing && cl_vsmoothing->value && + if( cl_vsmoothing && cl_vsmoothing->value && ( pparams->smoothing && ( pparams->maxclients > 1 ) ) ) { int foundidx; float t; - if ( cl_vsmoothing->value < 0.0 ) + if( cl_vsmoothing->value < 0.0 ) { gEngfuncs.Cvar_SetValue( "cl_vsmoothing", 0.0 ); } t = pparams->time - cl_vsmoothing->value; - for ( i = 1; i < ORIGIN_MASK; i++ ) + for( i = 1; i < ORIGIN_MASK; i++ ) { foundidx = ViewInterp.CurrentOrigin - 1 - i; - if ( ViewInterp.OriginTime[ foundidx & ORIGIN_MASK ] <= t ) + if( ViewInterp.OriginTime[foundidx & ORIGIN_MASK] <= t ) break; } - if ( i < ORIGIN_MASK && ViewInterp.OriginTime[ foundidx & ORIGIN_MASK ] != 0.0 ) + if( i < ORIGIN_MASK && ViewInterp.OriginTime[foundidx & ORIGIN_MASK] != 0.0 ) { // Interpolate vec3_t delta; @@ -685,23 +678,22 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) double dt; vec3_t neworg; - dt = ViewInterp.OriginTime[ (foundidx + 1) & ORIGIN_MASK ] - ViewInterp.OriginTime[ foundidx & ORIGIN_MASK ]; - if ( dt > 0.0 ) + dt = ViewInterp.OriginTime[( foundidx + 1 ) & ORIGIN_MASK] - ViewInterp.OriginTime[foundidx & ORIGIN_MASK]; + if( dt > 0.0 ) { - frac = ( t - ViewInterp.OriginTime[ foundidx & ORIGIN_MASK] ) / dt; + frac = ( t - ViewInterp.OriginTime[foundidx & ORIGIN_MASK] ) / dt; frac = min( 1.0, frac ); - VectorSubtract( ViewInterp.Origins[ ( foundidx + 1 ) & ORIGIN_MASK ], ViewInterp.Origins[ foundidx & ORIGIN_MASK ], delta ); - VectorMA( ViewInterp.Origins[ foundidx & ORIGIN_MASK ], frac, delta, neworg ); + VectorSubtract( ViewInterp.Origins[( foundidx + 1 ) & ORIGIN_MASK], ViewInterp.Origins[foundidx & ORIGIN_MASK], delta ); + VectorMA( ViewInterp.Origins[foundidx & ORIGIN_MASK], frac, delta, neworg ); // Dont interpolate large changes - if ( Length( delta ) < 64 ) + if( Length( delta ) < 64 ) { VectorSubtract( neworg, pparams->simorg, delta ); VectorAdd( pparams->simorg, delta, pparams->simorg ); VectorAdd( pparams->vieworg, delta, pparams->vieworg ); VectorAdd( view->origin, delta, view->origin ); - } } } @@ -710,34 +702,34 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) // Store off v_angles before munging for third person v_angles = pparams->viewangles; v_lastAngles = pparams->viewangles; -// v_cl_angles = pparams->cl_viewangles; // keep old user mouse angles ! - if ( CL_IsThirdPerson() ) + //v_cl_angles = pparams->cl_viewangles; // keep old user mouse angles ! + if( CL_IsThirdPerson() ) { - VectorCopy( camAngles, pparams->viewangles); - float pitch = camAngles[ 0 ]; + VectorCopy( camAngles, pparams->viewangles ); + float pitch = camAngles[0]; // Normalize angles - if ( pitch > 180 ) + if( pitch > 180 ) pitch -= 360.0; - else if ( pitch < -180 ) + else if( pitch < -180 ) pitch += 360; // Player pitch is inverted pitch /= -3.0; // Slam local player's pitch value - ent->angles[ 0 ] = pitch; - ent->curstate.angles[ 0 ] = pitch; - ent->prevstate.angles[ 0 ] = pitch; - ent->latched.prevangles[ 0 ] = pitch; + ent->angles[0] = pitch; + ent->curstate.angles[0] = pitch; + ent->prevstate.angles[0] = pitch; + ent->latched.prevangles[0] = pitch; } // override all previous settings if the viewent isn't the client - if ( pparams->viewentity > pparams->maxclients ) + if( pparams->viewentity > pparams->maxclients ) { cl_entity_t *viewentity; viewentity = gEngfuncs.GetEntityByIndex( pparams->viewentity ); - if ( viewentity ) + if( viewentity ) { VectorCopy( viewentity->origin, pparams->vieworg ); VectorCopy( viewentity->angles, pparams->viewangles ); @@ -754,46 +746,46 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams ) void V_SmoothInterpolateAngles( float * startAngle, float * endAngle, float * finalAngle, float degreesPerSec ) { - float absd,frac,d,threshhold; - + float absd, frac, d, threshhold; + NormalizeAngles( startAngle ); NormalizeAngles( endAngle ); - for ( int i = 0 ; i < 3 ; i++ ) + for( int i = 0; i < 3; i++ ) { d = endAngle[i] - startAngle[i]; - if ( d > 180.0f ) + if( d > 180.0f ) { d -= 360.0f; } - else if ( d < -180.0f ) - { + else if( d < -180.0f ) + { d += 360.0f; } - absd = fabs(d); + absd = fabs( d ); - if ( absd > 0.01f ) + if( absd > 0.01f ) { frac = degreesPerSec * v_frametime; threshhold= degreesPerSec / 4; - if ( absd < threshhold ) + if( absd < threshhold ) { float h = absd / threshhold; h *= h; - frac*= h; // slow down last degrees + frac *= h; // slow down last degrees } - if ( frac > absd ) + if( frac > absd ) { finalAngle[i] = endAngle[i]; } else { - if ( d>0) + if( d > 0 ) finalAngle[i] = startAngle[i] + frac; else finalAngle[i] = startAngle[i] - frac; @@ -803,7 +795,6 @@ void V_SmoothInterpolateAngles( float * startAngle, float * endAngle, float * fi { finalAngle[i] = endAngle[i]; } - } NormalizeAngles( finalAngle ); @@ -812,88 +803,88 @@ void V_SmoothInterpolateAngles( float * startAngle, float * endAngle, float * fi // Get the origin of the Observer based around the target's position and angles void V_GetChaseOrigin( float * angles, float * origin, float distance, float * returnvec ) { - vec3_t vecEnd; - vec3_t forward; - vec3_t vecStart; - pmtrace_t * trace; + vec3_t vecEnd; + vec3_t forward; + vec3_t vecStart; + pmtrace_t *trace; int maxLoops = 8; int ignoreent = -1; // first, ignore no entity - - cl_entity_t * ent = NULL; - + + cl_entity_t *ent = NULL; + // Trace back from the target using the player's view angles - AngleVectors(angles, forward, NULL, NULL); - - VectorScale(forward,-1,forward); + AngleVectors( angles, forward, NULL, NULL ); + + VectorScale( forward, -1, forward ); VectorCopy( origin, vecStart ); - VectorMA(vecStart, distance , forward, vecEnd); + VectorMA( vecStart, distance , forward, vecEnd ); - while ( maxLoops > 0) + while( maxLoops > 0 ) { trace = gEngfuncs.PM_TraceLine( vecStart, vecEnd, PM_TRACELINE_PHYSENTSONLY, 2, ignoreent ); // WARNING! trace->ent is is the number in physent list not the normal entity number - if ( trace->ent <= 0) + if( trace->ent <= 0) break; // we hit the world or nothing, stop trace ent = gEngfuncs.GetEntityByIndex( PM_GetPhysEntInfo( trace->ent ) ); - if ( ent == NULL ) + if( ent == NULL ) break; // hit non-player solid BSP , stop here - if ( ent->curstate.solid == SOLID_BSP && !ent->player ) + if( ent->curstate.solid == SOLID_BSP && !ent->player ) break; // if close enought to end pos, stop, otherwise continue trace - if( Distance(trace->endpos, vecEnd ) < 1.0f ) + if( Distance( trace->endpos, vecEnd ) < 1.0f ) { break; } else { ignoreent = trace->ent; // ignore last hit entity - VectorCopy( trace->endpos, vecStart); + VectorCopy( trace->endpos, vecStart ); } maxLoops--; - } + } -/* if ( ent ) +/* if( ent ) { - gEngfuncs.Con_Printf("Trace loops %i , entity %i, model %s, solid %i\n",(8-maxLoops),ent->curstate.number, ent->model->name , ent->curstate.solid ); + gEngfuncs.Con_Printf( "Trace loops %i , entity %i, model %s, solid %i\n",(8-maxLoops),ent->curstate.number, ent->model->name , ent->curstate.solid ); } */ VectorMA( trace->endpos, 4, trace->plane.normal, returnvec ); - v_lastDistance = Distance(trace->endpos, origin); // real distance without offset + v_lastDistance = Distance( trace->endpos, origin ); // real distance without offset } -/*void V_GetDeathCam(cl_entity_t * ent1, cl_entity_t * ent2, float * angle, float * origin) +/*void V_GetDeathCam( cl_entity_t * ent1, cl_entity_t * ent2, float * angle, float * origin ) { - float newAngle[3]; float newOrigin[3]; + float newAngle[3]; float newOrigin[3]; float distance = 168.0f; - v_lastDistance+= v_frametime * 96.0f; // move unit per seconds back + v_lastDistance += v_frametime * 96.0f; // move unit per seconds back - if ( v_resetCamera ) + if( v_resetCamera ) v_lastDistance = 64.0f; - if ( distance > v_lastDistance ) + if( distance > v_lastDistance ) distance = v_lastDistance; - VectorCopy(ent1->origin, newOrigin); + VectorCopy( ent1->origin, newOrigin ); - if ( ent1->player ) - newOrigin[2]+= 17; // head level of living player + if( ent1->player ) + newOrigin[2] += 17; // head level of living player // get new angle towards second target - if ( ent2 ) + if( ent2 ) { VectorSubtract( ent2->origin, ent1->origin, newAngle ); VectorAngles( newAngle, newAngle ); @@ -909,70 +900,68 @@ void V_GetChaseOrigin( float * angles, float * origin, float distance, float * r // and smooth view V_SmoothInterpolateAngles( v_lastAngles, newAngle, angle, 120.0f ); - + V_GetChaseOrigin( angle, newOrigin, distance, origin ); - VectorCopy(angle, v_lastAngles); + VectorCopy( angle, v_lastAngles ); }*/ -void V_GetSingleTargetCam(cl_entity_t * ent1, float * angle, float * origin) +void V_GetSingleTargetCam( cl_entity_t * ent1, float * angle, float * origin ) { - float newAngle[3]; float newOrigin[3]; - - int flags = gHUD.m_Spectator.m_iObserverFlags; + float newAngle[3]; float newOrigin[3]; + + int flags = gHUD.m_Spectator.m_iObserverFlags; // see is target is a dead player - qboolean deadPlayer = ent1->player && (ent1->curstate.solid == SOLID_NOT); - - float dfactor = ( flags & DRC_FLAG_DRAMATIC )? -1.0f : 1.0f; + qboolean deadPlayer = ent1->player && ( ent1->curstate.solid == SOLID_NOT ); + + float dfactor = ( flags & DRC_FLAG_DRAMATIC ) ? -1.0f : 1.0f; float distance = 112.0f + ( 16.0f * dfactor ); // get close if dramatic; - + // go away in final scenes or if player just died - if ( flags & DRC_FLAG_FINAL ) - distance*=2.0f; - else if ( deadPlayer ) - distance*=1.5f; + if( flags & DRC_FLAG_FINAL ) + distance *= 2.0f; + else if( deadPlayer ) + distance *= 1.5f; // let v_lastDistance float smoothly away - v_lastDistance+= v_frametime * 32.0f; // move unit per seconds back + v_lastDistance += v_frametime * 32.0f; // move unit per seconds back - if ( distance > v_lastDistance ) + if( distance > v_lastDistance ) distance = v_lastDistance; - - VectorCopy(ent1->origin, newOrigin); - if ( ent1->player ) + VectorCopy( ent1->origin, newOrigin ); + + if( ent1->player ) { - if ( deadPlayer ) - newOrigin[2]+= 2; //laying on ground + if( deadPlayer ) + newOrigin[2] += 2; //laying on ground else - newOrigin[2]+= 17; // head level of living player - + newOrigin[2] += 17; // head level of living player } else newOrigin[2]+= 8; // object, tricky, must be above bomb in CS // we have no second target, choose view direction based on // show front of primary target - VectorCopy(ent1->angles, newAngle); + VectorCopy( ent1->angles, newAngle ); // show dead players from front, normal players back - if ( flags & DRC_FLAG_FACEPLAYER ) - newAngle[1]+= 180.0f; + if( flags & DRC_FLAG_FACEPLAYER ) + newAngle[1] += 180.0f; - - newAngle[0]+= 12.5f * dfactor; // lower angle if dramatic + newAngle[0] += 12.5f * dfactor; // lower angle if dramatic // if final scene (bomb), show from real high pos - if ( flags & DRC_FLAG_FINAL ) + if( flags & DRC_FLAG_FINAL ) newAngle[0] = 22.5f; // choose side of object/player - if ( flags & DRC_FLAG_SIDE ) - newAngle[1]+=22.5f; + if( flags & DRC_FLAG_SIDE ) + newAngle[1] += 22.5f; else - newAngle[1]-=22.5f; + newAngle[1] -= 22.5f; V_SmoothInterpolateAngles( v_lastAngles, newAngle, angle, 120.0f ); @@ -980,60 +969,60 @@ void V_GetSingleTargetCam(cl_entity_t * ent1, float * angle, float * origin) V_GetChaseOrigin( angle, newOrigin, distance, origin ); } -float MaxAngleBetweenAngles( float * a1, float * a2 ) +float MaxAngleBetweenAngles( float *a1, float *a2 ) { float d, maxd = 0.0f; NormalizeAngles( a1 ); NormalizeAngles( a2 ); - for ( int i = 0 ; i < 3 ; i++ ) + for( int i = 0; i < 3; i++ ) { d = a2[i] - a1[i]; - if ( d > 180 ) + if( d > 180 ) { d -= 360; } - else if ( d < -180 ) + else if( d < -180 ) { d += 360; } - d = fabs(d); + d = fabs( d ); - if ( d > maxd ) - maxd=d; + if( d > maxd ) + maxd = d; } return maxd; } -void V_GetDoubleTargetsCam(cl_entity_t * ent1, cl_entity_t * ent2,float * angle, float * origin) +void V_GetDoubleTargetsCam( cl_entity_t *ent1, cl_entity_t *ent2, float *angle, float *origin ) { - float newAngle[3]; float newOrigin[3]; float tempVec[3]; + float newAngle[3], newOrigin[3], tempVec[3]; - int flags = gHUD.m_Spectator.m_iObserverFlags; + int flags = gHUD.m_Spectator.m_iObserverFlags; - float dfactor = ( flags & DRC_FLAG_DRAMATIC )? -1.0f : 1.0f; + float dfactor = ( flags & DRC_FLAG_DRAMATIC ) ? -1.0f : 1.0f; float distance = 112.0f + ( 16.0f * dfactor ); // get close if dramatic; - - // go away in final scenes or if player just died - if ( flags & DRC_FLAG_FINAL ) - distance*=2.0f; - - // let v_lastDistance float smoothly away - v_lastDistance+= v_frametime * 32.0f; // move unit per seconds back - if ( distance > v_lastDistance ) + // go away in final scenes or if player just died + if( flags & DRC_FLAG_FINAL ) + distance *= 2.0f; + + // let v_lastDistance float smoothly away + v_lastDistance += v_frametime * 32.0f; // move unit per seconds back + + if( distance > v_lastDistance ) distance = v_lastDistance; - VectorCopy(ent1->origin, newOrigin); + VectorCopy( ent1->origin, newOrigin ); - if ( ent1->player ) - newOrigin[2]+= 17; // head level of living player + if( ent1->player ) + newOrigin[2] += 17; // head level of living player else - newOrigin[2]+= 8; // object, tricky, must be above bomb in CS + newOrigin[2] += 8; // object, tricky, must be above bomb in CS // get new angle towards second target VectorSubtract( ent2->origin, ent1->origin, newAngle ); @@ -1042,21 +1031,21 @@ void V_GetDoubleTargetsCam(cl_entity_t * ent1, cl_entity_t * ent2,float * angle newAngle[0] = -newAngle[0]; // set angle diffrent in Dramtaic scenes - newAngle[0]+= 12.5f * dfactor; // lower angle if dramatic - - if ( flags & DRC_FLAG_SIDE ) - newAngle[1]+=22.5f; + newAngle[0] += 12.5f * dfactor; // lower angle if dramatic + + if( flags & DRC_FLAG_SIDE ) + newAngle[1] += 22.5f; else - newAngle[1]-=22.5f; + newAngle[1] -= 22.5f; float d = MaxAngleBetweenAngles( v_lastAngles, newAngle ); - if ( ( d < v_cameraFocusAngle) && ( v_cameraMode == CAM_MODE_RELAX ) ) + if( ( d < v_cameraFocusAngle) && ( v_cameraMode == CAM_MODE_RELAX ) ) { // difference is to small and we are in relax camera mode, keep viewangles - VectorCopy(v_lastAngles, newAngle ); + VectorCopy( v_lastAngles, newAngle ); } - else if ( (d < v_cameraRelaxAngle) && (v_cameraMode == CAM_MODE_FOCUS) ) + else if( ( d < v_cameraRelaxAngle ) && ( v_cameraMode == CAM_MODE_FOCUS ) ) { // we catched up with our target, relax again v_cameraMode = CAM_MODE_RELAX; @@ -1068,7 +1057,7 @@ void V_GetDoubleTargetsCam(cl_entity_t * ent1, cl_entity_t * ent2,float * angle } // and smooth view, if not a scene cut - if ( v_resetCamera || (v_cameraMode == CAM_MODE_RELAX) ) + if( v_resetCamera || ( v_cameraMode == CAM_MODE_RELAX ) ) { VectorCopy( newAngle, angle ); } @@ -1080,8 +1069,8 @@ void V_GetDoubleTargetsCam(cl_entity_t * ent1, cl_entity_t * ent2,float * angle V_GetChaseOrigin( newAngle, newOrigin, distance, origin ); // move position up, if very close at target - if ( v_lastDistance < 64.0f ) - origin[2]+= 16.0f*( 1.0f - (v_lastDistance / 64.0f ) ); + if( v_lastDistance < 64.0f ) + origin[2] += 16.0f * ( 1.0f - ( v_lastDistance / 64.0f ) ); // calculate angle to second target VectorSubtract( ent2->origin, origin, tempVec ); @@ -1089,27 +1078,23 @@ void V_GetDoubleTargetsCam(cl_entity_t * ent1, cl_entity_t * ent2,float * angle tempVec[0] = -tempVec[0]; /* take middle between two viewangles - InterpolateAngles( newAngle, tempVec, newAngle, 0.5f); */ - - - + InterpolateAngles( newAngle, tempVec, newAngle, 0.5f ); */ } -void V_GetDirectedChasePosition(cl_entity_t * ent1, cl_entity_t * ent2,float * angle, float * origin) +void V_GetDirectedChasePosition(cl_entity_t *ent1, cl_entity_t *ent2,float *angle, float *origin) { - - if ( v_resetCamera ) + if( v_resetCamera ) { v_lastDistance = 4096.0f; // v_cameraMode = CAM_MODE_FOCUS; } - if ( ( ent2 == (cl_entity_t*)0xFFFFFFFF ) || ( ent1->player && (ent1->curstate.solid == SOLID_NOT) ) ) + if( ( ent2 == (cl_entity_t*)0xFFFFFFFF ) || ( ent1->player && ( ent1->curstate.solid == SOLID_NOT ) ) ) { // we have no second target or player just died - V_GetSingleTargetCam(ent1, angle, origin); + V_GetSingleTargetCam( ent1, angle, origin ); } - else if ( ent2 ) + else if( ent2 ) { // keep both target in view V_GetDoubleTargetsCam( ent1, ent2, angle, origin ); @@ -1121,77 +1106,74 @@ void V_GetDirectedChasePosition(cl_entity_t * ent1, cl_entity_t * ent2,float * // keep last good viewangle float newOrigin[3]; - int flags = gHUD.m_Spectator.m_iObserverFlags; + int flags = gHUD.m_Spectator.m_iObserverFlags; - float dfactor = ( flags & DRC_FLAG_DRAMATIC )? -1.0f : 1.0f; + float dfactor = ( flags & DRC_FLAG_DRAMATIC ) ? -1.0f : 1.0f; float distance = 112.0f + ( 16.0f * dfactor ); // get close if dramatic; - + // go away in final scenes or if player just died - if ( flags & DRC_FLAG_FINAL ) - distance*=2.0f; - + if( flags & DRC_FLAG_FINAL ) + distance *= 2.0f; + // let v_lastDistance float smoothly away v_lastDistance+= v_frametime * 32.0f; // move unit per seconds back - if ( distance > v_lastDistance ) + if( distance > v_lastDistance ) distance = v_lastDistance; - - VectorCopy(ent1->origin, newOrigin); - if ( ent1->player ) - newOrigin[2]+= 17; // head level of living player + VectorCopy( ent1->origin, newOrigin ); + + if( ent1->player ) + newOrigin[2] += 17; // head level of living player else - newOrigin[2]+= 8; // object, tricky, must be above bomb in CS + newOrigin[2] += 8; // object, tricky, must be above bomb in CS V_GetChaseOrigin( angle, newOrigin, distance, origin ); } - VectorCopy(angle, v_lastAngles); + VectorCopy( angle, v_lastAngles ); } -void V_GetChasePos(int target, float * cl_angles, float * origin, float * angles) +void V_GetChasePos( int target, float *cl_angles, float *origin, float *angles ) { - cl_entity_t * ent = NULL; - - if ( target ) + cl_entity_t *ent = NULL; + + if( target ) { ent = gEngfuncs.GetEntityByIndex( target ); - }; - - if (!ent) - { - // just copy a save in-map position - VectorCopy ( vJumpAngles, angles ); - VectorCopy ( vJumpOrigin, origin ); - return; } - - - if ( gHUD.m_Spectator.m_autoDirector->value ) + if( !ent ) { - if ( g_iUser3 ) + // just copy a save in-map position + VectorCopy( vJumpAngles, angles ); + VectorCopy( vJumpOrigin, origin ); + return; + } + + if( gHUD.m_Spectator.m_autoDirector->value ) + { + if( g_iUser3 ) V_GetDirectedChasePosition( ent, gEngfuncs.GetEntityByIndex( g_iUser3 ), angles, origin ); else - V_GetDirectedChasePosition( ent, ( cl_entity_t*)0xFFFFFFFF, + V_GetDirectedChasePosition( ent, (cl_entity_t*)0xFFFFFFFF, angles, origin ); } else { - if ( cl_angles == NULL ) // no mouse angles given, use entity angles ( locked mode ) + if( cl_angles == NULL ) // no mouse angles given, use entity angles ( locked mode ) { - VectorCopy ( ent->angles, angles); - angles[0]*=-1; + VectorCopy( ent->angles, angles); + angles[0] *= -1; } else - VectorCopy ( cl_angles, angles); + VectorCopy( cl_angles, angles ); + VectorCopy( ent->origin, origin ); - VectorCopy ( ent->origin, origin); - - origin[2]+= 28; // DEFAULT_VIEWHEIGHT - some offset + origin[2] += 28; // DEFAULT_VIEWHEIGHT - some offset V_GetChaseOrigin( angles, origin, cl_chasedist->value, origin ); } @@ -1204,10 +1186,9 @@ void V_ResetChaseCam() v_resetCamera = true; } - -void V_GetInEyePos(int target, float * origin, float * angles ) +void V_GetInEyePos( int target, float *origin, float *angles ) { - if ( !target) + if( !target ) { // just copy a save in-map position VectorCopy ( vJumpAngles, angles ); @@ -1215,126 +1196,125 @@ void V_GetInEyePos(int target, float * origin, float * angles ) return; }; + cl_entity_t *ent = gEngfuncs.GetEntityByIndex( target ); - cl_entity_t * ent = gEngfuncs.GetEntityByIndex( target ); - - if ( !ent ) + if( !ent ) return; - VectorCopy ( ent->origin, origin ); - VectorCopy ( ent->angles, angles ); + VectorCopy( ent->origin, origin ); + VectorCopy( ent->angles, angles ); - angles[PITCH]*=-3.0f; // see CL_ProcessEntityUpdate() + angles[PITCH] *= -3.0f; // see CL_ProcessEntityUpdate() - if ( ent->curstate.solid == SOLID_NOT ) + if( ent->curstate.solid == SOLID_NOT ) { angles[ROLL] = 80; // dead view angle - origin[2]+= -8 ; // PM_DEAD_VIEWHEIGHT + origin[2] += -8 ; // PM_DEAD_VIEWHEIGHT } - else if (ent->curstate.usehull == 1 ) - origin[2]+= 12; // VEC_DUCK_VIEW; + else if( ent->curstate.usehull == 1 ) + origin[2] += 12; // VEC_DUCK_VIEW; else // exacty eye position can't be caluculated since it depends on // client values like cl_bobcycle, this offset matches the default values - origin[2]+= 28; // DEFAULT_VIEWHEIGHT + origin[2] += 28; // DEFAULT_VIEWHEIGHT } -void V_GetMapFreePosition( float * cl_angles, float * origin, float * angles ) +void V_GetMapFreePosition( float *cl_angles, float *origin, float *angles ) { vec3_t forward; vec3_t zScaledTarget; - VectorCopy(cl_angles, angles); + VectorCopy( cl_angles, angles ); // modify angles since we don't wanna see map's bottom - angles[0] = 51.25f + 38.75f*(angles[0]/90.0f); + angles[0] = 51.25f + 38.75f * ( angles[0] / 90.0f ); zScaledTarget[0] = gHUD.m_Spectator.m_mapOrigin[0]; zScaledTarget[1] = gHUD.m_Spectator.m_mapOrigin[1]; - zScaledTarget[2] = gHUD.m_Spectator.m_mapOrigin[2] * (( 90.0f - angles[0] ) / 90.0f ); - + zScaledTarget[2] = gHUD.m_Spectator.m_mapOrigin[2] * ( ( 90.0f - angles[0] ) / 90.0f ); - AngleVectors(angles, forward, NULL, NULL); + AngleVectors( angles, forward, NULL, NULL ); - VectorNormalize(forward); + VectorNormalize( forward ); - VectorMA(zScaledTarget, -( 4096.0f / gHUD.m_Spectator.m_mapZoom ), forward , origin); + VectorMA( zScaledTarget, -( 4096.0f / gHUD.m_Spectator.m_mapZoom ), forward, origin ); } -void V_GetMapChasePosition(int target, float * cl_angles, float * origin, float * angles) +void V_GetMapChasePosition( int target, float *cl_angles, float *origin, float *angles ) { vec3_t forward; - if ( target ) + if( target ) { - cl_entity_t * ent = gEngfuncs.GetEntityByIndex( target ); + cl_entity_t *ent = gEngfuncs.GetEntityByIndex( target ); - if ( gHUD.m_Spectator.m_autoDirector->value ) + if( gHUD.m_Spectator.m_autoDirector->value ) { // this is done to get the angles made by director mode - V_GetChasePos(target, cl_angles, origin, angles); - VectorCopy(ent->origin, origin); - + V_GetChasePos( target, cl_angles, origin, angles ); + VectorCopy( ent->origin, origin ); + // keep fix chase angle horizontal angles[0] = 45.0f; } else { - VectorCopy(cl_angles, angles); - VectorCopy(ent->origin, origin); + VectorCopy( cl_angles, angles ); + VectorCopy( ent->origin, origin ); // modify angles since we don't wanna see map's bottom - angles[0] = 51.25f + 38.75f*(angles[0]/90.0f); + angles[0] = 51.25f + 38.75f * ( angles[0] / 90.0f ); } } else { // keep out roaming position, but modify angles - VectorCopy(cl_angles, angles); - angles[0] = 51.25f + 38.75f*(angles[0]/90.0f); + VectorCopy( cl_angles, angles ); + angles[0] = 51.25f + 38.75f * ( angles[0] / 90.0f ); } - origin[2] *= (( 90.0f - angles[0] ) / 90.0f ); + origin[2] *= ( ( 90.0f - angles[0] ) / 90.0f ); angles[2] = 0.0f; // don't roll angle (if chased player is dead) - AngleVectors(angles, forward, NULL, NULL); + AngleVectors( angles, forward, NULL, NULL ); - VectorNormalize(forward); + VectorNormalize( forward ); - VectorMA(origin, -1536, forward, origin); + VectorMA( origin, -1536, forward, origin ); } -int V_FindViewModelByWeaponModel(int weaponindex) +int V_FindViewModelByWeaponModel( int weaponindex ) { - - static char * modelmap[][2] = { - { "models/p_crossbow.mdl", "models/v_crossbow.mdl" }, - { "models/p_crowbar.mdl", "models/v_crowbar.mdl" }, - { "models/p_egon.mdl", "models/v_egon.mdl" }, - { "models/p_gauss.mdl", "models/v_gauss.mdl" }, - { "models/p_9mmhandgun.mdl", "models/v_9mmhandgun.mdl" }, - { "models/p_grenade.mdl", "models/v_grenade.mdl" }, - { "models/p_hgun.mdl", "models/v_hgun.mdl" }, - { "models/p_9mmAR.mdl", "models/v_9mmAR.mdl" }, - { "models/p_357.mdl", "models/v_357.mdl" }, - { "models/p_rpg.mdl", "models/v_rpg.mdl" }, - { "models/p_shotgun.mdl", "models/v_shotgun.mdl" }, - { "models/p_squeak.mdl", "models/v_squeak.mdl" }, - { "models/p_tripmine.mdl", "models/v_tripmine.mdl" }, - { "models/p_satchel_radio.mdl", "models/v_satchel_radio.mdl"}, - { "models/p_satchel.mdl", "models/v_satchel.mdl" }, - { NULL, NULL } }; + static char *modelmap[][2] = + { + { "models/p_crossbow.mdl", "models/v_crossbow.mdl" }, + { "models/p_crowbar.mdl", "models/v_crowbar.mdl" }, + { "models/p_egon.mdl", "models/v_egon.mdl" }, + { "models/p_gauss.mdl", "models/v_gauss.mdl" }, + { "models/p_9mmhandgun.mdl", "models/v_9mmhandgun.mdl" }, + { "models/p_grenade.mdl", "models/v_grenade.mdl" }, + { "models/p_hgun.mdl", "models/v_hgun.mdl" }, + { "models/p_9mmAR.mdl", "models/v_9mmAR.mdl" }, + { "models/p_357.mdl", "models/v_357.mdl" }, + { "models/p_rpg.mdl", "models/v_rpg.mdl" }, + { "models/p_shotgun.mdl", "models/v_shotgun.mdl" }, + { "models/p_squeak.mdl", "models/v_squeak.mdl" }, + { "models/p_tripmine.mdl", "models/v_tripmine.mdl" }, + { "models/p_satchel_radio.mdl", "models/v_satchel_radio.mdl" }, + { "models/p_satchel.mdl", "models/v_satchel.mdl" }, + { NULL, NULL } + }; struct model_s * weaponModel = IEngineStudio.GetModelByIndex( weaponindex ); - if ( weaponModel ) + if( weaponModel ) { int len = strlen( weaponModel->name ); int i = 0; - while ( modelmap[i][0] != NULL ) + while( modelmap[i][0] != NULL ) { - if ( !strnicmp( weaponModel->name, modelmap[i][0], len ) ) + if( !strnicmp( weaponModel->name, modelmap[i][0], len ) ) { return gEngfuncs.pEventAPI->EV_FindModelIndex( modelmap[i][1] ); } @@ -1345,71 +1325,68 @@ int V_FindViewModelByWeaponModel(int weaponindex) } else return 0; - } - /* ================== V_CalcSpectatorRefdef ================== */ -void V_CalcSpectatorRefdef ( struct ref_params_s * pparams ) +void V_CalcSpectatorRefdef( struct ref_params_s * pparams ) { - static vec3_t velocity ( 0.0f, 0.0f, 0.0f); + static vec3_t velocity( 0.0f, 0.0f, 0.0f ); static int lastWeaponModelIndex = 0; static int lastViewModelIndex = 0; - - cl_entity_t * ent = gEngfuncs.GetEntityByIndex( g_iUser2 ); - + + cl_entity_t *ent = gEngfuncs.GetEntityByIndex( g_iUser2 ); + pparams->onlyClientDraw = false; // refresh position - VectorCopy ( pparams->simorg, v_sim_org ); + VectorCopy( pparams->simorg, v_sim_org ); // get old values - VectorCopy ( pparams->cl_viewangles, v_cl_angles ); - VectorCopy ( pparams->viewangles, v_angles ); - VectorCopy ( pparams->vieworg, v_origin ); + VectorCopy( pparams->cl_viewangles, v_cl_angles ); + VectorCopy( pparams->viewangles, v_angles ); + VectorCopy( pparams->vieworg, v_origin ); - if ( ( g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) && ent ) + if( ( g_iUser1 == OBS_IN_EYE || gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) && ent ) { // calculate player velocity float timeDiff = ent->curstate.msg_time - ent->prevstate.msg_time; - if ( timeDiff > 0 ) + if( timeDiff > 0 ) { vec3_t distance; - VectorSubtract(ent->prevstate.origin, ent->curstate.origin, distance); - VectorScale(distance, 1/timeDiff, distance ); + VectorSubtract( ent->prevstate.origin, ent->curstate.origin, distance ); + VectorScale( distance, 1 / timeDiff, distance ); - velocity[0] = velocity[0]*0.9f + distance[0]*0.1f; - velocity[1] = velocity[1]*0.9f + distance[1]*0.1f; - velocity[2] = velocity[2]*0.9f + distance[2]*0.1f; - - VectorCopy(velocity, pparams->simvel); + velocity[0] = velocity[0] * 0.9f + distance[0] * 0.1f; + velocity[1] = velocity[1] * 0.9f + distance[1] * 0.1f; + velocity[2] = velocity[2] * 0.9f + distance[2] * 0.1f; + + VectorCopy( velocity, pparams->simvel ); } // predict missing client data and set weapon model ( in HLTV mode or inset in eye mode ) - if ( gEngfuncs.IsSpectateOnly() ) + if( gEngfuncs.IsSpectateOnly() ) { V_GetInEyePos( g_iUser2, pparams->simorg, pparams->cl_viewangles ); pparams->health = 1; - cl_entity_t * gunModel = gEngfuncs.GetViewModel(); + cl_entity_t *gunModel = gEngfuncs.GetViewModel(); - if ( lastWeaponModelIndex != ent->curstate.weaponmodel ) + if( lastWeaponModelIndex != ent->curstate.weaponmodel ) { // weapon model changed - lastWeaponModelIndex = ent->curstate.weaponmodel; lastViewModelIndex = V_FindViewModelByWeaponModel( lastWeaponModelIndex ); - if ( lastViewModelIndex ) + if( lastViewModelIndex ) { - gEngfuncs.pfnWeaponAnim(0,0); // reset weapon animation + gEngfuncs.pfnWeaponAnim( 0, 0 ); // reset weapon animation } else { @@ -1419,7 +1396,7 @@ void V_CalcSpectatorRefdef ( struct ref_params_s * pparams ) } } - if ( lastViewModelIndex ) + if( lastViewModelIndex ) { gunModel->model = IEngineStudio.GetModelByIndex( lastViewModelIndex ); gunModel->curstate.modelindex = lastViewModelIndex; @@ -1435,109 +1412,102 @@ void V_CalcSpectatorRefdef ( struct ref_params_s * pparams ) else { // only get viewangles from entity - VectorCopy ( ent->angles, pparams->cl_viewangles ); - pparams->cl_viewangles[PITCH]*=-3.0f; // see CL_ProcessEntityUpdate() + VectorCopy( ent->angles, pparams->cl_viewangles ); + pparams->cl_viewangles[PITCH] *= -3.0f; // see CL_ProcessEntityUpdate() } } v_frametime = pparams->frametime; - if ( pparams->nextView == 0 ) + if( pparams->nextView == 0 ) { // first renderer cycle, full screen - - switch ( g_iUser1 ) + switch( g_iUser1 ) { - case OBS_CHASE_LOCKED: V_GetChasePos( g_iUser2, NULL, v_origin, v_angles ); - break; - - case OBS_CHASE_FREE: V_GetChasePos( g_iUser2, v_cl_angles, v_origin, v_angles ); - break; - - case OBS_ROAMING : VectorCopy (v_cl_angles, v_angles); - VectorCopy (v_sim_org, v_origin); - break; - - case OBS_IN_EYE : V_CalcNormalRefdef ( pparams ); - break; - - case OBS_MAP_FREE : pparams->onlyClientDraw = true; - V_GetMapFreePosition( v_cl_angles, v_origin, v_angles ); - break; - - case OBS_MAP_CHASE : pparams->onlyClientDraw = true; - V_GetMapChasePosition( g_iUser2, v_cl_angles, v_origin, v_angles ); - break; + case OBS_CHASE_LOCKED: + V_GetChasePos( g_iUser2, NULL, v_origin, v_angles ); + break; + case OBS_CHASE_FREE: + V_GetChasePos( g_iUser2, v_cl_angles, v_origin, v_angles ); + break; + case OBS_ROAMING: + VectorCopy( v_cl_angles, v_angles ); + VectorCopy( v_sim_org, v_origin ); + break; + case OBS_IN_EYE: + V_CalcNormalRefdef( pparams ); + break; + case OBS_MAP_FREE: + pparams->onlyClientDraw = true; + V_GetMapFreePosition( v_cl_angles, v_origin, v_angles ); + break; + case OBS_MAP_CHASE: + pparams->onlyClientDraw = true; + V_GetMapChasePosition( g_iUser2, v_cl_angles, v_origin, v_angles ); + break; } - if ( gHUD.m_Spectator.m_pip->value ) + if( gHUD.m_Spectator.m_pip->value ) pparams->nextView = 1; // force a second renderer view gHUD.m_Spectator.m_iDrawCycle = 0; - } else { // second renderer cycle, inset window - // set inset parameters - pparams->viewport[0] = XRES(gHUD.m_Spectator.m_OverviewData.insetWindowX); // change viewport to inset window - pparams->viewport[1] = YRES(gHUD.m_Spectator.m_OverviewData.insetWindowY); - pparams->viewport[2] = XRES(gHUD.m_Spectator.m_OverviewData.insetWindowWidth); - pparams->viewport[3] = YRES(gHUD.m_Spectator.m_OverviewData.insetWindowHeight); - pparams->nextView = 0; // on further view + pparams->viewport[0] = XRES( gHUD.m_Spectator.m_OverviewData.insetWindowX ); // change viewport to inset window + pparams->viewport[1] = YRES( gHUD.m_Spectator.m_OverviewData.insetWindowY ); + pparams->viewport[2] = XRES( gHUD.m_Spectator.m_OverviewData.insetWindowWidth ); + pparams->viewport[3] = YRES( gHUD.m_Spectator.m_OverviewData.insetWindowHeight ); + pparams->nextView = 0; // on further view // override some settings in certain modes - switch ( (int)gHUD.m_Spectator.m_pip->value ) + switch( (int)gHUD.m_Spectator.m_pip->value ) { - case INSET_CHASE_FREE : V_GetChasePos( g_iUser2, v_cl_angles, v_origin, v_angles ); - break; - - case INSET_IN_EYE : V_CalcNormalRefdef ( pparams ); - break; - - case INSET_MAP_FREE : pparams->onlyClientDraw = true; - V_GetMapFreePosition( v_cl_angles, v_origin, v_angles ); - break; - - case INSET_MAP_CHASE : pparams->onlyClientDraw = true; - - if ( g_iUser1 == OBS_ROAMING ) - V_GetMapChasePosition( 0, v_cl_angles, v_origin, v_angles ); - else - V_GetMapChasePosition( g_iUser2, v_cl_angles, v_origin, v_angles ); - - break; + case INSET_CHASE_FREE: + V_GetChasePos( g_iUser2, v_cl_angles, v_origin, v_angles ); + break; + case INSET_IN_EYE: + V_CalcNormalRefdef( pparams ); + break; + case INSET_MAP_FREE: + pparams->onlyClientDraw = true; + V_GetMapFreePosition( v_cl_angles, v_origin, v_angles ); + break; + case INSET_MAP_CHASE: + pparams->onlyClientDraw = true; + if( g_iUser1 == OBS_ROAMING ) + V_GetMapChasePosition( 0, v_cl_angles, v_origin, v_angles ); + else + V_GetMapChasePosition( g_iUser2, v_cl_angles, v_origin, v_angles ); + break; } gHUD.m_Spectator.m_iDrawCycle = 1; } // write back new values into pparams - VectorCopy ( v_cl_angles, pparams->cl_viewangles ); - VectorCopy ( v_angles, pparams->viewangles ) - VectorCopy ( v_origin, pparams->vieworg ); - + VectorCopy( v_cl_angles, pparams->cl_viewangles ); + VectorCopy( v_angles, pparams->viewangles ) + VectorCopy( v_origin, pparams->vieworg ); } - - void DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams ) { // intermission / finale rendering - if ( pparams->intermission ) - { - V_CalcIntermissionRefdef ( pparams ); - } - else if ( pparams->spectator || g_iUser1 ) // g_iUser true if in spectator mode + if( pparams->intermission ) { - V_CalcSpectatorRefdef ( pparams ); + V_CalcIntermissionRefdef( pparams ); } - else if ( !pparams->paused ) + else if( pparams->spectator || g_iUser1 ) // g_iUser true if in spectator mode { - V_CalcNormalRefdef ( pparams ); + V_CalcSpectatorRefdef( pparams ); + } + else if( !pparams->paused ) + { + V_CalcNormalRefdef( pparams ); } - /* // Example of how to overlay the whole screen with red at 50 % alpha #define SF_TEST @@ -1564,14 +1534,14 @@ V_DropPunchAngle ============= */ -void V_DropPunchAngle ( float frametime, float *ev_punchangle ) +void V_DropPunchAngle( float frametime, float *ev_punchangle ) { - float len; - - len = VectorNormalize ( ev_punchangle ); - len -= (10.0 + len * 0.5) * frametime; + float len; + + len = VectorNormalize( ev_punchangle ); + len -= ( 10.0 + len * 0.5 ) * frametime; len = max( len, 0.0 ); - VectorScale ( ev_punchangle, len, ev_punchangle ); + VectorScale( ev_punchangle, len, ev_punchangle ); } /* @@ -1583,7 +1553,7 @@ Client side punch effect */ void V_PunchAxis( int axis, float punch ) { - ev_punchangle[ axis ] = punch; + ev_punchangle[axis] = punch; } /* @@ -1591,24 +1561,22 @@ void V_PunchAxis( int axis, float punch ) V_Init ============= */ -void V_Init (void) +void V_Init( void ) { + scr_ofsx = gEngfuncs.pfnRegisterVariable( "scr_ofsx","0", 0 ); + scr_ofsy = gEngfuncs.pfnRegisterVariable( "scr_ofsy","0", 0 ); + scr_ofsz = gEngfuncs.pfnRegisterVariable( "scr_ofsz","0", 0 ); - scr_ofsx = gEngfuncs.pfnRegisterVariable( "scr_ofsx","0", 0 ); - scr_ofsy = gEngfuncs.pfnRegisterVariable( "scr_ofsy","0", 0 ); - scr_ofsz = gEngfuncs.pfnRegisterVariable( "scr_ofsz","0", 0 ); + v_centermove = gEngfuncs.pfnRegisterVariable( "v_centermove", "0.15", 0 ); + v_centerspeed = gEngfuncs.pfnRegisterVariable( "v_centerspeed","500", 0 ); - v_centermove = gEngfuncs.pfnRegisterVariable( "v_centermove", "0.15", 0 ); - v_centerspeed = gEngfuncs.pfnRegisterVariable( "v_centerspeed","500", 0 ); - - cl_bobcycle = gEngfuncs.pfnRegisterVariable( "cl_bobcycle","0.8", 0 );// best default for my experimental gun wag (sjb) - cl_bob = gEngfuncs.pfnRegisterVariable( "cl_bob","0.01", 0 );// best default for my experimental gun wag (sjb) - cl_bobup = gEngfuncs.pfnRegisterVariable( "cl_bobup","0.5", 0 ); - cl_waterdist = gEngfuncs.pfnRegisterVariable( "cl_waterdist","4", 0 ); - cl_chasedist = gEngfuncs.pfnRegisterVariable( "cl_chasedist","112", 0 ); + cl_bobcycle = gEngfuncs.pfnRegisterVariable( "cl_bobcycle","0.8", 0 );// best default for my experimental gun wag (sjb) + cl_bob = gEngfuncs.pfnRegisterVariable( "cl_bob","0.01", 0 );// best default for my experimental gun wag (sjb) + cl_bobup = gEngfuncs.pfnRegisterVariable( "cl_bobup","0.5", 0 ); + cl_waterdist = gEngfuncs.pfnRegisterVariable( "cl_waterdist","4", 0 ); + cl_chasedist = gEngfuncs.pfnRegisterVariable( "cl_chasedist","112", 0 ); } - //#define TRACE_TEST #if defined( TRACE_TEST ) @@ -1618,19 +1586,19 @@ extern float in_fov; CalcFov ==================== */ -float CalcFov (float fov_x, float width, float height) +float CalcFov( float fov_x, float width, float height ) { - float a; - float x; + float a; + float x; - if (fov_x < 1 || fov_x > 179) + if( fov_x < 1 || fov_x > 179 ) fov_x = 90; // error, set to 90 - x = width/tan(fov_x/360*M_PI); + x = width / tan( fov_x / 360 * M_PI ); - a = atan (height/x); + a = atan ( height / x ); - a = a*360/M_PI; + a = a * 360 / M_PI; return a; } @@ -1667,18 +1635,18 @@ void V_Move( int mx, int my ) newangles = v_angles; - newangles[ YAW ] -= dX; - newangles[ PITCH ] += dY; + newangles[YAW] -= dX; + newangles[PITCH] += dY; // Now rotate v_forward around that point - AngleVectors ( newangles, forward, right, up ); + AngleVectors( newangles, forward, right, up ); farpoint = v_origin + 8192 * forward; // Trace - tr = *(gEngfuncs.PM_TraceLine( (float *)&v_origin, (float *)&farpoint, PM_TRACELINE_PHYSENTSONLY, 2 /*point sized hull*/, -1 )); + tr = *( gEngfuncs.PM_TraceLine( (float *)&v_origin, (float *)&farpoint, PM_TRACELINE_PHYSENTSONLY, 2 /*point sized hull*/, -1 ) ); - if ( tr.fraction != 1.0 && tr.ent != 0 ) + if( tr.fraction != 1.0 && tr.ent != 0 ) { hitent = PM_GetPhysEntInfo( tr.ent ); PM_ParticleLine( (float *)&v_origin, (float *)&tr.endpos, 5, 1.0, 0.0 ); @@ -1688,5 +1656,4 @@ void V_Move( int mx, int my ) hitent = -1; } } - #endif diff --git a/cl_dll/view.h b/cl_dll/view.h index 1afbe38e..c0aa0e8f 100644 --- a/cl_dll/view.h +++ b/cl_dll/view.h @@ -11,5 +11,4 @@ void V_StartPitchDrift( void ); void V_StopPitchDrift( void ); - -#endif // !VIEWH \ No newline at end of file +#endif // !VIEWH