Advertisement
Guest User

Untitled

a guest
Feb 16th, 2009
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.97 KB | None | 0 0
  1. Index: game/client/c_prop_vehicle.cpp
  2. ===================================================================
  3. --- game/client/c_prop_vehicle.cpp (revision 1)
  4. +++ game/client/c_prop_vehicle.cpp (working copy)
  5. @@ -228,6 +228,11 @@
  6.  
  7. #define TRIANGULATED_CROSSHAIR 1
  8.  
  9. +int C_PropVehicleDriveable::Speed()
  10. +{
  11. + return m_nSpeed;
  12. +}
  13. +
  14. void C_PropVehicleDriveable::DrawHudElements( )
  15. {
  16. CHudTexture *pIcon;
  17. Index: game/client/c_prop_vehicle.h
  18. ===================================================================
  19. --- game/client/c_prop_vehicle.h (revision 1)
  20. +++ game/client/c_prop_vehicle.h (working copy)
  21. @@ -73,6 +73,8 @@
  22. // Mark the shadow as dirty while the vehicle is being driven
  23. virtual void ClientThink( void );
  24.  
  25. + virtual int Speed();
  26. +
  27. // C_PropVehicleDriveable
  28. public:
  29.  
  30. Index: game/client/c_vehicle_choreo_generic.cpp
  31. ===================================================================
  32. --- game/client/c_vehicle_choreo_generic.cpp (revision 1)
  33. +++ game/client/c_vehicle_choreo_generic.cpp (working copy)
  34. @@ -74,6 +74,7 @@
  35. virtual bool IsPredicted() const { return false; }
  36. virtual void ItemPostFrame( C_BasePlayer *pPlayer ) {}
  37. virtual bool IsSelfAnimating() { return false; };
  38. + virtual int Speed() { return 0; }
  39.  
  40. private:
  41.  
  42. Index: game/client/c_vehicle_jeep.cpp
  43. ===================================================================
  44. --- game/client/c_vehicle_jeep.cpp (revision 1)
  45. +++ game/client/c_vehicle_jeep.cpp (working copy)
  46. @@ -41,6 +41,7 @@
  47.  
  48. ConVarRef r_JeepFOV( "r_JeepFOV" );
  49. m_ViewSmoothingData.flFOV = r_JeepFOV.GetFloat();
  50. +
  51. }
  52.  
  53. //-----------------------------------------------------------------------------
  54. Index: game/client/hl2/c_vehicle_cannon.cpp
  55. ===================================================================
  56. --- game/client/hl2/c_vehicle_cannon.cpp (revision 1)
  57. +++ game/client/hl2/c_vehicle_cannon.cpp (working copy)
  58. @@ -50,6 +50,7 @@
  59. virtual int GetPrimaryAmmoClip() const { return -1; }
  60. virtual bool PrimaryAmmoUsesClips() const { return false; }
  61. virtual int GetJoystickResponseCurve() const { return 0; }
  62. + virtual int Speed() { return 0; }
  63.  
  64. public:
  65.  
  66. Index: game/client/hl2/c_vehicle_crane.h
  67. ===================================================================
  68. --- game/client/hl2/c_vehicle_crane.h (revision 1)
  69. +++ game/client/hl2/c_vehicle_crane.h (working copy)
  70. @@ -47,6 +47,7 @@
  71. virtual int GetPrimaryAmmoClip() const { return -1; }
  72. virtual bool PrimaryAmmoUsesClips() const { return false; }
  73. virtual int GetJoystickResponseCurve() const { return 0; }
  74. + virtual int Speed() { return 0; }
  75.  
  76. public:
  77.  
  78. Index: game/client/hl2/c_vehicle_prisoner_pod.cpp
  79. ===================================================================
  80. --- game/client/hl2/c_vehicle_prisoner_pod.cpp (revision 1)
  81. +++ game/client/hl2/c_vehicle_prisoner_pod.cpp (working copy)
  82. @@ -68,6 +68,7 @@
  83. virtual int GetPrimaryAmmoClip() const { return -1; }
  84. virtual bool PrimaryAmmoUsesClips() const { return false; }
  85. virtual int GetJoystickResponseCurve() const { return 0; }
  86. + virtual int Speed() { return 0; }
  87.  
  88. public:
  89.  
  90. Index: game/client/hl2/hud_ammo.cpp
  91. ===================================================================
  92. --- game/client/hl2/hud_ammo.cpp (revision 1)
  93. +++ game/client/hl2/hud_ammo.cpp (working copy)
  94. @@ -44,7 +44,7 @@
  95. void UpdateAmmoDisplays();
  96. void UpdatePlayerAmmo( C_BasePlayer *player );
  97. void UpdateVehicleAmmo( C_BasePlayer *player, IClientVehicle *pVehicle );
  98. -
  99. +
  100. private:
  101. CHandle< C_BaseCombatWeapon > m_hCurrentActiveWeapon;
  102. CHandle< C_BaseEntity > m_hCurrentVehicle;
  103. @@ -75,7 +75,7 @@
  104. {
  105. m_iAmmo = -1;
  106. m_iAmmo2 = -1;
  107. -
  108. +
  109. m_iconPrimaryAmmo = NULL;
  110.  
  111. wchar_t *tempString = g_pVGuiLocalize->Find("#Valve_Hud_AMMO");
  112. @@ -127,7 +127,7 @@
  113. if ( !wpn || !player || !wpn->UsesPrimaryAmmo() )
  114. {
  115. hudlcd->SetGlobalStat( "(ammo_primary)", "n/a" );
  116. - hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" );
  117. + hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" );
  118.  
  119. SetPaintEnabled(false);
  120. SetPaintBackgroundEnabled(false);
  121. @@ -189,6 +189,12 @@
  122.  
  123. void CHudAmmo::UpdateVehicleAmmo( C_BasePlayer *player, IClientVehicle *pVehicle )
  124. {
  125. + // HudSpeed overrides this.
  126. + SetPaintEnabled(false);
  127. + SetPaintBackgroundEnabled(false);
  128. + return;
  129. +
  130. + /*
  131. m_hCurrentActiveWeapon = NULL;
  132. CBaseEntity *pVehicleEnt = pVehicle->GetVehicleEnt();
  133.  
  134. @@ -244,6 +250,7 @@
  135. g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponChanged");
  136. m_hCurrentVehicle = pVehicleEnt;
  137. }
  138. + */
  139. }
  140.  
  141. //-----------------------------------------------------------------------------
  142. @@ -345,7 +352,7 @@
  143. // Figure out where we're going to put this
  144. int x = text_xpos + ( nLabelWidth - m_iconPrimaryAmmo->Width() ) / 2;
  145. int y = text_ypos - ( nLabelHeight + ( m_iconPrimaryAmmo->Height() / 2 ) );
  146. -
  147. +
  148. m_iconPrimaryAmmo->DrawSelf( x, y, GetFgColor() );
  149. }
  150. #endif // HL2MP
  151. @@ -486,17 +493,16 @@
  152. g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("WeaponDoesNotUseSecondaryAmmo");
  153. }
  154. m_hCurrentActiveWeapon = wpn;
  155. -
  156. +
  157. // Get the icon we should be displaying
  158. m_iconSecondaryAmmo = gWR.GetAmmoIconFromWeapon( m_hCurrentActiveWeapon->GetSecondaryAmmoType() );
  159. }
  160. }
  161. -
  162. +
  163. private:
  164. CHandle< C_BaseCombatWeapon > m_hCurrentActiveWeapon;
  165. CHudTexture *m_iconSecondaryAmmo;
  166. int m_iAmmo;
  167. };
  168.  
  169. -DECLARE_HUDELEMENT( CHudSecondaryAmmo );
  170. -
  171. +DECLARE_HUDELEMENT( CHudSecondaryAmmo );
  172. \ No newline at end of file
  173. Index: game/client/hl2/hud_speed.cpp
  174. ===================================================================
  175. --- game/client/hl2/hud_speed.cpp (revision 0)
  176. +++ game/client/hl2/hud_speed.cpp (revision 0)
  177. @@ -0,0 +1,121 @@
  178. +#include "cbase.h"
  179. +#include "hud.h"
  180. +#include "hudelement.h"
  181. +#include "hud_macros.h"
  182. +#include "hud_numericdisplay.h"
  183. +#include "iclientmode.h"
  184. +#include "iclientvehicle.h"
  185. +#include <vgui_controls/AnimationController.h>
  186. +#include <vgui/ILocalize.h>
  187. +#include <vgui/ISurface.h>
  188. +#include "ihudlcd.h"
  189. +
  190. +// memdbgon must be the last include file in a .cpp file!!!
  191. +#include "tier0/memdbgon.h"
  192. +
  193. +using namespace vgui;
  194. +
  195. +//-----------------------------------------------------------------------------
  196. +// Purpose: Displays current ammunition level
  197. +//-----------------------------------------------------------------------------
  198. +class CHudSpeed : public CHudNumericDisplay, public CHudElement
  199. +{
  200. + DECLARE_CLASS_SIMPLE( CHudSpeed, CHudNumericDisplay );
  201. +
  202. +public:
  203. + CHudSpeed( const char *pElementName );
  204. + void Init( void );
  205. + void VidInit( void );
  206. + void Reset();
  207. +
  208. + virtual void Paint( void );
  209. +
  210. +protected:
  211. + virtual void OnThink();
  212. +
  213. +private:
  214. + CHandle< C_BaseEntity > m_hCurrentVehicle;
  215. +};
  216. +
  217. +DECLARE_HUDELEMENT( CHudSpeed );
  218. +
  219. +//-----------------------------------------------------------------------------
  220. +// Purpose: Constructor
  221. +//-----------------------------------------------------------------------------
  222. +CHudSpeed::CHudSpeed( const char *pElementName ) : BaseClass(NULL, "HudSpeed"), CHudElement( pElementName )
  223. +{
  224. + SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT | HIDEHUD_WEAPONSELECTION );
  225. +
  226. + hudlcd->SetGlobalStat( "(speed_vehicle)", "0" );
  227. +}
  228. +
  229. +//-----------------------------------------------------------------------------
  230. +// Purpose:
  231. +//-----------------------------------------------------------------------------
  232. +void CHudSpeed::Init( void )
  233. +{
  234. + SetLabelText(L"Speed");
  235. +}
  236. +
  237. +//-----------------------------------------------------------------------------
  238. +// Purpose:
  239. +//-----------------------------------------------------------------------------
  240. +void CHudSpeed::VidInit( void )
  241. +{
  242. +}
  243. +
  244. +//-----------------------------------------------------------------------------
  245. +// Purpose: Resets hud after save/restore
  246. +//-----------------------------------------------------------------------------
  247. +void CHudSpeed::Reset()
  248. +{
  249. + BaseClass::Reset();
  250. + m_hCurrentVehicle = NULL;
  251. +
  252. + OnThink();
  253. +}
  254. +
  255. +//-----------------------------------------------------------------------------
  256. +// Purpose: called every frame to get ammo info from the weapon
  257. +//-----------------------------------------------------------------------------
  258. +void CHudSpeed::OnThink()
  259. +{
  260. + C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
  261. + IClientVehicle *pVehicle = player ? player->GetVehicle() : NULL;
  262. +
  263. + if ( pVehicle )
  264. + {
  265. + CBaseEntity *pVehicleEnt = pVehicle->GetVehicleEnt();
  266. +
  267. + if ( !pVehicleEnt )
  268. + {
  269. + SetPaintEnabled(false);
  270. + SetPaintBackgroundEnabled(false);
  271. + SetShouldDisplayValue(false);
  272. + return;
  273. + }
  274. +
  275. + m_hCurrentVehicle = pVehicleEnt;
  276. +
  277. + SetShouldDisplayValue(true);
  278. + SetPaintEnabled(true);
  279. + SetPaintBackgroundEnabled(true);
  280. +
  281. + SetDisplayValue( (int)((float)pVehicle->Speed() * 1.4) );
  282. + }
  283. + else
  284. + {
  285. + SetPaintEnabled(false);
  286. + SetPaintBackgroundEnabled(false);
  287. + SetShouldDisplayValue(false);
  288. + return;
  289. + }
  290. +}
  291. +
  292. +//-----------------------------------------------------------------------------
  293. +// Purpose: We add an icon into the
  294. +//-----------------------------------------------------------------------------
  295. +void CHudSpeed::Paint( void )
  296. +{
  297. + BaseClass::Paint();
  298. +}
  299. \ No newline at end of file
  300. Index: game/client/iclientvehicle.h
  301. ===================================================================
  302. --- game/client/iclientvehicle.h (revision 1)
  303. +++ game/client/iclientvehicle.h (working copy)
  304. @@ -46,6 +46,8 @@
  305. // Allows vehicles to choose their own curves for players using joysticks
  306. virtual int GetJoystickResponseCurve() const = 0;
  307.  
  308. + virtual int Speed() = 0;
  309. +
  310. #ifdef HL2_CLIENT_DLL
  311. // Ammo in the vehicles
  312. virtual int GetPrimaryAmmoType() const = 0;
  313. Index: game/server/hl2/vehicle_crane.cpp
  314. ===================================================================
  315. --- game/server/hl2/vehicle_crane.cpp (revision 1)
  316. +++ game/server/hl2/vehicle_crane.cpp (working copy)
  317. @@ -852,7 +852,7 @@
  318. //-----------------------------------------------------------------------------
  319. void CPropCrane::InputForcePlayerIn( inputdata_t &inputdata )
  320. {
  321. - CBasePlayer *pPlayer = UTIL_PlayerByIndex( 1 );
  322. + CBasePlayer *pPlayer = UTIL_GetNearestPlayer(GetAbsOrigin());
  323. if ( pPlayer && !m_hPlayer )
  324. {
  325. GetServerVehicle()->HandlePassengerEntry( pPlayer, 0 );
  326. @@ -1115,3 +1115,6 @@
  327. return pCraneTip;
  328. }
  329.  
  330. +
  331. +
  332. +
  333. Index: game/server/hl2/vehicle_crane.h
  334. ===================================================================
  335. --- game/server/hl2/vehicle_crane.h (revision 1)
  336. +++ game/server/hl2/vehicle_crane.h (working copy)
  337. @@ -88,6 +88,7 @@
  338.  
  339. virtual bool IsPassengerEntering( void ) { return false; } // NOTE: This mimics the scenario HL2 would have seen
  340. virtual bool IsPassengerExiting( void ) { return false; }
  341. + virtual int Speed() { return 0; }
  342.  
  343. protected:
  344. CPropCrane *GetCrane( void );
  345. Index: game/server/hl2/vehicle_prisoner_pod.cpp
  346. ===================================================================
  347. --- game/server/hl2/vehicle_prisoner_pod.cpp (revision 1)
  348. +++ game/server/hl2/vehicle_prisoner_pod.cpp (working copy)
  349. @@ -61,6 +61,7 @@
  350.  
  351. virtual bool IsPassengerEntering( void ) { return false; } // NOTE: This mimics the scenario HL2 would have seen
  352. virtual bool IsPassengerExiting( void ) { return false; }
  353. + virtual int Speed() { return 0; }
  354.  
  355. protected:
  356.  
  357. @@ -595,8 +596,8 @@
  358. CBaseCombatCharacter *pPassenger = ToBaseCombatCharacter( inputdata.pActivator );
  359. if ( pPassenger == NULL )
  360. {
  361. - // Activator was not a player, just grab the singleplayer player.
  362. - pPassenger = UTIL_PlayerByIndex( 1 );
  363. + // Activator was not a player, just grab the nearest player.
  364. + pPassenger = UTIL_GetNearestPlayer(GetAbsOrigin());
  365. if ( pPassenger == NULL )
  366. return;
  367. }
  368. @@ -622,8 +623,8 @@
  369. CBaseCombatCharacter *pPassenger = ToBaseCombatCharacter( inputdata.pActivator );
  370. if ( pPassenger == NULL )
  371. {
  372. - // Activator was not a player, just grab the singleplayer player.
  373. - pPassenger = UTIL_PlayerByIndex( 1 );
  374. + // Activator was not a player, just grab the nearest player.
  375. + pPassenger = UTIL_GetNearestPlayer(GetAbsOrigin());
  376. if ( pPassenger == NULL )
  377. return;
  378. }
  379. Index: game/server/hl2/vehicle_viewcontroller.cpp
  380. ===================================================================
  381. --- game/server/hl2/vehicle_viewcontroller.cpp (revision 1)
  382. +++ game/server/hl2/vehicle_viewcontroller.cpp (working copy)
  383. @@ -134,7 +134,7 @@
  384. //-----------------------------------------------------------------------------
  385. void CPropVehicleViewController::InputForcePlayerIn( inputdata_t &inputdata )
  386. {
  387. - CBasePlayer *pPlayer = UTIL_PlayerByIndex(1);
  388. + CBasePlayer *pPlayer = UTIL_GetNearestPlayer(GetAbsOrigin());
  389. if ( !pPlayer )
  390. return;
  391.  
  392. Index: game/server/vehicle_base.cpp
  393. ===================================================================
  394. --- game/server/vehicle_base.cpp (revision 1)
  395. +++ game/server/vehicle_base.cpp (working copy)
  396. @@ -1137,6 +1137,11 @@
  397. }
  398. }
  399.  
  400. +int CFourWheelServerVehicle::Speed()
  401. +{
  402. + return m_pVehicle->m_flSpeed;
  403. +}
  404. +
  405. //-----------------------------------------------------------------------------
  406. // Purpose: Modify the player view/camera while in a vehicle
  407. //-----------------------------------------------------------------------------
  408. Index: game/server/vehicle_base.h
  409. ===================================================================
  410. --- game/server/vehicle_base.h (revision 1)
  411. +++ game/server/vehicle_base.h (working copy)
  412. @@ -57,6 +57,7 @@
  413.  
  414. CPropVehicleDriveable *GetFourWheelVehicle( void );
  415. bool GetWheelContactPoint( int nWheelIndex, Vector &vecPos );
  416. + int Speed();
  417.  
  418. public:
  419. virtual void SetVehicle( CBaseEntity *pVehicle );
  420. Index: game/shared/IVehicle.h
  421. ===================================================================
  422. --- game/shared/IVehicle.h (revision 1)
  423. +++ game/shared/IVehicle.h (working copy)
  424. @@ -41,6 +41,8 @@
  425.  
  426. // Process input
  427. virtual void ItemPostFrame( CBasePlayer *pPlayer ) = 0;
  428. +
  429. + virtual int Speed() = 0;
  430. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement