From ebd4c58c41c903dc680d7d8aadd3bcc1edf27aeb Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 09:23:18 +0100 Subject: [PATCH] "Fixed" weapon spawning over network --- include/Game/Systems/Weapon/WeaponBehaviour.h | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index 60675d67..e2d5980b 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -32,6 +32,21 @@ public: virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) override { + EntityWrapper firstPersonWeapon = entity.FirstChildByName("Hands").FirstChildByName("AssaultWeapon"); + EntityWrapper thirdPersonWeapon = entity.FirstChildByName("PlayerModel").FirstChildByName("AssaultWeapon"); + if (IsClient && (firstPersonWeapon.Valid() || thirdPersonWeapon.Valid())) { + if (m_ActiveWeapons.count(entity) == 0) { + + WeaponInfo& wi = m_ActiveWeapons[entity]; + wi.Player = entity; + wi.WeaponEntity = entity; + wi.FirstPersonEntity = firstPersonWeapon; + wi.ThirdPersonEntity = thirdPersonWeapon; + + OnEquip(cWeapon, wi); + } + } + auto weapon = getActiveWeapon(entity); if (!weapon) { return; @@ -239,6 +254,10 @@ private: void selectWeapon(ComponentWrapper cWeapon, EntityWrapper player) { + if (!IsServer) { + return; + } + // Don't reselect weapon if it's already active if (getActiveWeapon(player)) { return; @@ -268,11 +287,11 @@ private: // Spawn the weapon(s) EntityWrapper firstPersonWeapon; EntityWrapper thirdPersonWeapon; - if (IsClient) { + //if (IsClient) { if (firstPersonAttachment.Valid()) { firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment); } - } + //} if (thirdPersonAttachment.Valid()) { thirdPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment); }