From b8fc862aff5640fe0fad37a38ac0586b3943d7d8 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Tue, 17 Oct 2023 19:53:38 +0000 Subject: [PATCH] Fixed first shot freeze on weapons, optimize memory usage (#1369) Co-authored-by: Xottab_DUTY --- src/xrGame/CarWeapon.cpp | 3 ++- src/xrGame/Helicopter.cpp | 3 ++- src/xrGame/Weapon.cpp | 3 +++ src/xrGame/WeaponStatMgun.cpp | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/xrGame/CarWeapon.cpp b/src/xrGame/CarWeapon.cpp index 128edd20f97..ee9fc75aed3 100644 --- a/src/xrGame/CarWeapon.cpp +++ b/src/xrGame/CarWeapon.cpp @@ -60,7 +60,6 @@ CCarWeapon::CCarWeapon(CPhysicsShellHolder* obj) m_destEnemyDir.setHP(m_bind_y_rot, m_bind_x_rot); m_object->XFORM().transform_dir(m_destEnemyDir); - inheritedShooting::Light_Create(); Load(pUserData->r_string("mounted_weapon_definition", "wpn_section")); SetBoneCallbacks(); m_object->processing_activate(); @@ -82,6 +81,8 @@ void CCarWeapon::Load(LPCSTR section) inheritedShooting::Load(section); HUD_SOUND_ITEM::LoadSound(section, "snd_shoot", m_sndShot, SOUND_TYPE_WEAPON_SHOOTING); m_Ammo->Load(pSettings->r_string(section, "ammo_class"), 0); + if (m_bLightShotEnabled) + inheritedShooting::Light_Create(); } void CCarWeapon::UpdateCL() diff --git a/src/xrGame/Helicopter.cpp b/src/xrGame/Helicopter.cpp index a77467385bd..b4d52c0583e 100644 --- a/src/xrGame/Helicopter.cpp +++ b/src/xrGame/Helicopter.cpp @@ -213,7 +213,8 @@ bool CHelicopter::net_Spawn(CSE_Abstract* DC) m_engineSound.create(*heli->engine_sound, st_Effect, sg_SourceType); m_engineSound.play_at_pos(0, XFORM().c, sm_Looped); - CShootingObject::Light_Create(); + if (m_bLightShotEnabled) + CShootingObject::Light_Create(); setVisible(TRUE); setEnabled(TRUE); diff --git a/src/xrGame/Weapon.cpp b/src/xrGame/Weapon.cpp index d03e69ff250..e571052d4d1 100644 --- a/src/xrGame/Weapon.cpp +++ b/src/xrGame/Weapon.cpp @@ -579,6 +579,9 @@ bool CWeapon::net_Spawn(CSE_Abstract* DC) VERIFY((u32)iAmmoElapsed == m_magazine.size()); m_bAmmoWasSpawned = false; + if (m_bLightShotEnabled) + Light_Create(); + return bResult; } diff --git a/src/xrGame/WeaponStatMgun.cpp b/src/xrGame/WeaponStatMgun.cpp index 18f804df22c..e8d90c7c80d 100644 --- a/src/xrGame/WeaponStatMgun.cpp +++ b/src/xrGame/WeaponStatMgun.cpp @@ -118,7 +118,8 @@ bool CWeaponStatMgun::net_Spawn(CSE_Abstract* DC) m_destEnemyDir.setHP(m_bind_y_rot, m_bind_x_rot); XFORM().transform_dir(m_destEnemyDir); - inheritedShooting::Light_Create(); + if (m_bLightShotEnabled) + inheritedShooting::Light_Create(); processing_activate(); setVisible(TRUE);