From 306a5d565b594b5ddd92b27ea57b742c94ae0e45 Mon Sep 17 00:00:00 2001 From: Pinsplash <39359267+Pinsplash@users.noreply.github.com> Date: Tue, 7 May 2024 13:32:26 -0500 Subject: [PATCH] fixed #11 --- sp/src/game/client/c_vguiscreen.h | 2 +- .../game/client/client_episodic.vcxproj.user | 2 +- .../episodic/c_vehicle_jeep_episodic.cpp | 45 +++++++++++-------- sp/src/game/client/hl2/hud_radar.cpp | 10 ++--- sp/src/game/client/hl2/hud_radar.h | 2 +- .../server/episodic/vehicle_jeep_episodic.cpp | 4 +- .../server/episodic/vehicle_jeep_episodic.h | 2 +- sp/src/game/server/hl2/hl2_player.cpp | 36 +++++---------- sp/src/game/shared/hl2/hl2_usermessages.cpp | 2 +- 9 files changed, 51 insertions(+), 54 deletions(-) diff --git a/sp/src/game/client/c_vguiscreen.h b/sp/src/game/client/c_vguiscreen.h index d304f5c9..6248121f 100644 --- a/sp/src/game/client/c_vguiscreen.h +++ b/sp/src/game/client/c_vguiscreen.h @@ -69,6 +69,7 @@ public: C_VGuiScreen(); ~C_VGuiScreen(); + CPanelWrapper m_PanelWrapper; virtual void PreDataUpdate( DataUpdateType_t updateType ); virtual void OnDataChanged( DataUpdateType_t type ); virtual int DrawModel( int flags ); @@ -154,7 +155,6 @@ private: VMatrix m_PanelToWorld; - CPanelWrapper m_PanelWrapper; CHandle m_hPlayerOwner; }; diff --git a/sp/src/game/client/client_episodic.vcxproj.user b/sp/src/game/client/client_episodic.vcxproj.user index 35532493..15939bf1 100644 --- a/sp/src/game/client/client_episodic.vcxproj.user +++ b/sp/src/game/client/client_episodic.vcxproj.user @@ -3,7 +3,7 @@ C:\Program Files (x86)\Steam\steamapps\common\Source SDK Base 2013 Singleplayer\hl2.exe WindowsLocalDebugger - -allowdebug -novid -game "C:\Program Files (x86)\Steam\steamapps\sourcemods\ep1chaos" + -allowdebug -novid -game "C:\Program Files (x86)\Steam\steamapps\sourcemods\ep2chaos" C:\Program Files (x86)\Steam\steamapps\common\Source SDK Base 2013 Singleplayer\hl2.exe diff --git a/sp/src/game/client/episodic/c_vehicle_jeep_episodic.cpp b/sp/src/game/client/episodic/c_vehicle_jeep_episodic.cpp index 66beface..6a821d9c 100644 --- a/sp/src/game/client/episodic/c_vehicle_jeep_episodic.cpp +++ b/sp/src/game/client/episodic/c_vehicle_jeep_episodic.cpp @@ -41,13 +41,17 @@ public: int m_iNumRadarContacts; Vector m_vecRadarContactPos[ RADAR_MAX_CONTACTS ]; int m_iRadarContactType[ RADAR_MAX_CONTACTS ]; + EHANDLE m_hRadarScreen; + CHudRadar* m_Radar; + void UpdateJalopyRadar(); }; -C_PropJeepEpisodic *g_pJalopy = NULL; +//C_PropJeepEpisodic *g_pJalopy = NULL; IMPLEMENT_CLIENTCLASS_DT( C_PropJeepEpisodic, DT_CPropJeepEpisodic, CPropJeepEpisodic ) //CNetworkVar( int, m_iNumRadarContacts ); RecvPropInt( RECVINFO(m_iNumRadarContacts) ), + RecvPropEHandle(RECVINFO(m_hRadarScreen)), //CNetworkArray( Vector, m_vecRadarContactPos, RADAR_MAX_CONTACTS ); RecvPropArray( RecvPropVector(RECVINFO(m_vecRadarContactPos[0])), m_vecRadarContactPos ), @@ -59,28 +63,28 @@ END_RECV_TABLE() //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- -void __MsgFunc_UpdateJalopyRadar(bf_read &msg) +void C_PropJeepEpisodic::UpdateJalopyRadar() { // Radar code here! - if( !GetHudRadar() ) + if (!m_Radar) return; - + m_Radar->Paint(); // Sometimes we update more quickly when we need to track something in high resolution. // Usually we do not, so default to false. - GetHudRadar()->m_bUseFastUpdate = false; + m_Radar->m_bUseFastUpdate = false; - for( int i = 0 ; i < g_pJalopy->m_iNumRadarContacts ; i++ ) + for( int i = 0 ; i < m_iNumRadarContacts ; i++ ) { - if( g_pJalopy->m_iRadarContactType[i] == RADAR_CONTACT_DOG ) + if( m_iRadarContactType[i] == RADAR_CONTACT_DOG ) { - GetHudRadar()->m_bUseFastUpdate = true; + m_Radar->m_bUseFastUpdate = true; break; } } float flContactTimeToLive; - if( GetHudRadar()->m_bUseFastUpdate ) + if (m_Radar->m_bUseFastUpdate) { flContactTimeToLive = RADAR_UPDATE_FREQUENCY_FAST; } @@ -89,9 +93,9 @@ void __MsgFunc_UpdateJalopyRadar(bf_read &msg) flContactTimeToLive = RADAR_UPDATE_FREQUENCY; } - for( int i = 0 ; i < g_pJalopy->m_iNumRadarContacts ; i++ ) + for( int i = 0 ; i < m_iNumRadarContacts ; i++ ) { - GetHudRadar()->AddRadarContact( g_pJalopy->m_vecRadarContactPos[i], g_pJalopy->m_iRadarContactType[i], flContactTimeToLive ); + m_Radar->AddRadarContact(m_vecRadarContactPos[i], m_iRadarContactType[i], flContactTimeToLive); } } @@ -99,12 +103,7 @@ void __MsgFunc_UpdateJalopyRadar(bf_read &msg) //----------------------------------------------------------------------------- C_PropJeepEpisodic::C_PropJeepEpisodic() { - if( g_pJalopy == NULL ) - { - usermessages->HookMessage( "UpdateJalopyRadar", __MsgFunc_UpdateJalopyRadar ); - } - - g_pJalopy = this; + UpdateJalopyRadar(); } //----------------------------------------------------------------------------- @@ -112,15 +111,23 @@ C_PropJeepEpisodic::C_PropJeepEpisodic() //----------------------------------------------------------------------------- void C_PropJeepEpisodic::Simulate( void ) { + if (m_hRadarScreen != NULL && m_Radar == NULL) + { + C_VGuiScreen *pScreen = dynamic_cast(m_hRadarScreen.Get()); + if (pScreen) + m_Radar = dynamic_cast(pScreen->m_PanelWrapper.GetPanel()); + } // Keep trying to hook to the radar. - if( GetHudRadar() != NULL ) + if (m_Radar != NULL) { // This is not our ideal long-term solution. This will only work if you only have // one jalopy in a given level. The Jalopy and the Radar Screen are currently both // assumed to be singletons. This is appropriate for EP2, however. (sjb) - GetHudRadar()->SetVehicle( this ); + m_Radar->SetVehicle(this); } + UpdateJalopyRadar(); + BaseClass::Simulate(); } diff --git a/sp/src/game/client/hl2/hud_radar.cpp b/sp/src/game/client/hl2/hud_radar.cpp index 2f0fd7e9..a3e753fe 100644 --- a/sp/src/game/client/hl2/hud_radar.cpp +++ b/sp/src/game/client/hl2/hud_radar.cpp @@ -29,13 +29,13 @@ DECLARE_VGUI_SCREEN_FACTORY( CHudRadar, "jalopy_radar_panel" ); #define RADAR_CONTACT_DOG_MATERIAL "vgui/icons/icon_dog" // Dog #define RADAR_CONTACT_BASE_MATERIAL "vgui/icons/icon_base" // Ally base -static CHudRadar *s_Radar = NULL; - +//static CHudRadar *s_Radar = NULL; +/* CHudRadar *GetHudRadar() { return s_Radar; } - +*/ DECLARE_HUDELEMENT( CMapOverview ); //--------------------------------------------------------- @@ -55,7 +55,7 @@ CHudRadar::CHudRadar( vgui::Panel *parent, const char *panelName ) : BaseClass( //--------------------------------------------------------- CHudRadar::~CHudRadar() { - s_Radar = NULL; + //s_Radar = NULL; #if defined(_X360) if( m_iImageID != -1 ) @@ -102,7 +102,7 @@ bool CHudRadar::Init( KeyValues* pKeyValues, VGuiScreenInitData_t* pInitData ) { bool result = BaseClass::Init( pKeyValues, pInitData ); ClearAllRadarContacts(); - s_Radar = this; + //s_Radar = this; m_ghostAlpha = 0; m_flTimeStartGhosting = gpGlobals->curtime + 1.0f; diff --git a/sp/src/game/client/hl2/hud_radar.h b/sp/src/game/client/hl2/hud_radar.h index 81134cae..6571d9b8 100644 --- a/sp/src/game/client/hl2/hud_radar.h +++ b/sp/src/game/client/hl2/hud_radar.h @@ -74,5 +74,5 @@ private: int m_textureID_IconBase; }; -extern CHudRadar *GetHudRadar(); +//extern CHudRadar *GetHudRadar(); #endif // HUD_RADAR_H diff --git a/sp/src/game/server/episodic/vehicle_jeep_episodic.cpp b/sp/src/game/server/episodic/vehicle_jeep_episodic.cpp index 647351ac..e5161817 100644 --- a/sp/src/game/server/episodic/vehicle_jeep_episodic.cpp +++ b/sp/src/game/server/episodic/vehicle_jeep_episodic.cpp @@ -370,6 +370,7 @@ IMPLEMENT_SERVERCLASS_ST(CPropJeepEpisodic, DT_CPropJeepEpisodic) //CNetworkVar( int, m_iNumRadarContacts ); SendPropInt( SENDINFO(m_iNumRadarContacts), 8 ), + SendPropEHandle(SENDINFO(m_hRadarScreen)), //CNetworkArray( Vector, m_vecRadarContactPos, RADAR_MAX_CONTACTS ); SendPropArray( SendPropVector( SENDINFO_ARRAY(m_vecRadarContactPos), -1, SPROP_COORD), m_vecRadarContactPos ), @@ -966,12 +967,13 @@ void CPropJeepEpisodic::UpdateRadar( bool forceUpdate ) } //Msg("Server detected %d objects\n", m_iNumRadarContacts ); - + /* CBasePlayer *pPlayer = AI_GetSinglePlayer(); CSingleUserRecipientFilter filter(pPlayer); UserMessageBegin( filter, "UpdateJalopyRadar" ); WRITE_BYTE( 0 ); // end marker MessageEnd(); // send message + */ } ConVar jalopy_cargo_anim_time( "jalopy_cargo_anim_time", "1.0" ); diff --git a/sp/src/game/server/episodic/vehicle_jeep_episodic.h b/sp/src/game/server/episodic/vehicle_jeep_episodic.h index 6276b15e..7e628446 100644 --- a/sp/src/game/server/episodic/vehicle_jeep_episodic.h +++ b/sp/src/game/server/episodic/vehicle_jeep_episodic.h @@ -144,7 +144,7 @@ private: bool m_bRadarEnabled; bool m_bRadarDetectsEnemies; float m_flNextRadarUpdateTime; - EHANDLE m_hRadarScreen; + CNetworkHandle(CBaseEntity, m_hRadarScreen); EHANDLE m_hLinkControllerFront; EHANDLE m_hLinkControllerRear; diff --git a/sp/src/game/server/hl2/hl2_player.cpp b/sp/src/game/server/hl2/hl2_player.cpp index afd756db..1de70795 100644 --- a/sp/src/game/server/hl2/hl2_player.cpp +++ b/sp/src/game/server/hl2/hl2_player.cpp @@ -7261,31 +7261,19 @@ void CERandomVehicle::StartEffect() nRandom = chaos_rng1.GetInt() == -1 ? RandomInt(0, 5) : chaos_rng1.GetInt(); if (nRandom == 5) { - if (gEntList.FindEntityByClassname(NULL, "prop_vehicle_jeep"))//avoid radar issues that come up when there is more than one jalopy in the map at a time - { - nRandom = chaos_rng1.GetInt() == -1 ? RandomInt(0, 4) : chaos_rng1.GetInt(); - } + CBaseEntity *pJalopy; + if (UTIL_GetLocalPlayer()->GetModelScale() == 2) + pJalopy = ChaosSpawnVehicle("prop_vehicle_jeep", MAKE_STRING("Spawn Jalopy"), SPAWNTYPE_VEHICLE, "models/vehicle_2.mdl", "jalopy", "scripts/vehicles/jalopy_2.txt"); + else if (UTIL_GetLocalPlayer()->GetModelScale() == 0.5) + pJalopy = ChaosSpawnVehicle("prop_vehicle_jeep", MAKE_STRING("Spawn Jalopy"), SPAWNTYPE_VEHICLE, "models/vehicle_0_5.mdl", "jalopy", "scripts/vehicles/jalopy_0_5.txt"); else - { - CBaseEntity *pJalopy; - if (UTIL_GetLocalPlayer()->GetModelScale() == 2) - pJalopy = ChaosSpawnVehicle("prop_vehicle_jeep", MAKE_STRING("Spawn Jalopy"), SPAWNTYPE_VEHICLE, "models/vehicle_2.mdl", "jalopy", "scripts/vehicles/jalopy_2.txt"); - else if (UTIL_GetLocalPlayer()->GetModelScale() == 0.5) - pJalopy = ChaosSpawnVehicle("prop_vehicle_jeep", MAKE_STRING("Spawn Jalopy"), SPAWNTYPE_VEHICLE, "models/vehicle_0_5.mdl", "jalopy", "scripts/vehicles/jalopy_0_5.txt"); - else - pJalopy = ChaosSpawnVehicle("prop_vehicle_jeep", MAKE_STRING("Spawn Jalopy"), SPAWNTYPE_VEHICLE, "models/vehicle.mdl", "jalopy", "scripts/vehicles/jalopy.txt"); - if (pJalopy == NULL) - { - Msg("Did not spawn jalopy\n"); - return; - } - pJalopy->AcceptInput("EnableRadar", pJalopy, pJalopy, sVariant, 0); - pJalopy->AcceptInput("EnableRadarDetectEnemies", pJalopy, pJalopy, sVariant, 0); - pJalopy->AcceptInput("AddBusterToCargo", pJalopy, pJalopy, sVariant, 0); - CBasePlayer* pPlayer = UTIL_GetLocalPlayer(); - CHL2_Player *pHL2Player = static_cast(pPlayer); - pHL2Player->SetLocatorTargetEntity(pJalopy); - } + pJalopy = ChaosSpawnVehicle("prop_vehicle_jeep", MAKE_STRING("Spawn Jalopy"), SPAWNTYPE_VEHICLE, "models/vehicle.mdl", "jalopy", "scripts/vehicles/jalopy.txt"); + pJalopy->AcceptInput("EnableRadar", pJalopy, pJalopy, sVariant, 0); + pJalopy->AcceptInput("EnableRadarDetectEnemies", pJalopy, pJalopy, sVariant, 0); + pJalopy->AcceptInput("AddBusterToCargo", pJalopy, pJalopy, sVariant, 0); + CBasePlayer* pPlayer = UTIL_GetLocalPlayer(); + CHL2_Player *pHL2Player = static_cast(pPlayer); + pHL2Player->SetLocatorTargetEntity(pJalopy); } if (nRandom == 4) { diff --git a/sp/src/game/shared/hl2/hl2_usermessages.cpp b/sp/src/game/shared/hl2/hl2_usermessages.cpp index 8f5caeea..c5979e7f 100644 --- a/sp/src/game/shared/hl2/hl2_usermessages.cpp +++ b/sp/src/game/shared/hl2/hl2_usermessages.cpp @@ -44,7 +44,7 @@ void RegisterUserMessages( void ) usermessages->Register( "CreditsMsg", 1 ); usermessages->Register( "LogoTimeMsg", 4 ); usermessages->Register("AchievementEvent", -1); - usermessages->Register("UpdateJalopyRadar", -1); + //usermessages->Register("UpdateJalopyRadar", -1); usermessages->Register("Go", -1); #ifndef _X360