diff --git a/PlayerController.cpp b/PlayerController.cpp index 1c462e4..31505b1 100644 --- a/PlayerController.cpp +++ b/PlayerController.cpp @@ -115,7 +115,7 @@ void PlayerController::update() { bool shot = _player->fire(); if(shot) { - if(!_player->inCollision() && (_player->weaponName() == ObjectNameTag("weapon_shotgun"))) { + if(!_player->inCollision() && (_player->weaponName() == ObjectNameTag("shotgun"))) { _player->addVelocity(-camera->lookAt() * 30 * coeff); } } diff --git a/Shooter.cpp b/Shooter.cpp index c02e92e..229deb4 100644 --- a/Shooter.cpp +++ b/Shooter.cpp @@ -306,10 +306,9 @@ void Shooter::changeEnemyWeapon(const std::string& weaponName, sf::Uint16 enemyI auto head = world->body(ObjectNameTag("Enemy_" + std::to_string(enemyId) + "_head")); auto enemy = world->body(ObjectNameTag("Enemy_" + std::to_string(enemyId))); - // remove old weapon: world->removeBody(weaponTag); - enemy->unattach(ObjectNameTag("Weapon")); + enemy->unattach(weaponTag); world->loadBody(weaponTag, "obj/" + weaponName + ".obj"); world->body(weaponTag)->setCollider(false); diff --git a/engine/network/UDPSocket.cpp b/engine/network/UDPSocket.cpp index 44fe0d1..55f50a2 100644 --- a/engine/network/UDPSocket.cpp +++ b/engine/network/UDPSocket.cpp @@ -27,8 +27,7 @@ void UDPSocket::unbind() { sf::Packet packet; packet << MsgType::Disconnect << _ownId; - for (auto it = _connections.begin(); it != _connections.end();) - { + for (auto it = _connections.begin(); it != _connections.end();) { send(packet, it->first); _connections.erase(it++); } diff --git a/weapon/Ak47.cpp b/weapon/Ak47.cpp index 8008016..9b3db28 100644 --- a/weapon/Ak47.cpp +++ b/weapon/Ak47.cpp @@ -8,5 +8,5 @@ using namespace std; -Ak47::Ak47(const std::string& weaponName) : Weapon(100, 30, 3.0, 0.1, 300, 2.0, ShooterConsts::AK47_FIRE_SOUND, ShooterConsts::AK47_RELOAD_SOUND, weaponName, ShooterConsts::AK47_OBJ, Vec3D{3, 3, 3}, Vec3D{-2.2, 1.0, 1.3}, Vec3D{0, Consts::PI, 0}) { +Ak47::Ak47() : Weapon(100, 30, 3.0, 0.1, 300, 2.0, ShooterConsts::AK47_FIRE_SOUND, ShooterConsts::AK47_RELOAD_SOUND, ObjectNameTag("ak47"), ShooterConsts::AK47_OBJ, Vec3D{3, 3, 3}, Vec3D{-2.2, 1.0, 1.3}, Vec3D{0, Consts::PI, 0}) { } diff --git a/weapon/Ak47.h b/weapon/Ak47.h index 0233219..2c881bc 100644 --- a/weapon/Ak47.h +++ b/weapon/Ak47.h @@ -9,7 +9,7 @@ class Ak47 final : public Weapon { public: - explicit Ak47(const std::string& weaponName = "ak47"); + explicit Ak47(); }; diff --git a/weapon/Gold_Ak47.h b/weapon/Gold_Ak47.h index 1be5861..fafee57 100644 --- a/weapon/Gold_Ak47.h +++ b/weapon/Gold_Ak47.h @@ -10,7 +10,7 @@ class Gold_Ak47 final : public Weapon { public: - explicit Gold_Ak47(const std::string& weaponName = "gold_ak47") : Weapon(200, 60, 1.5, 0.05, 600, 1.0, ShooterConsts::GOLD_AK47_FIRE_SOUND, ShooterConsts::GOLD_AK47_RELOAD_SOUND, weaponName, ShooterConsts::GOLD_AK47_OBJ, Vec3D{3, 3, 3}, Vec3D{-2.2, 1.0, 1.3}, Vec3D{0, Consts::PI, 0}) { + explicit Gold_Ak47() : Weapon(200, 60, 1.5, 0.05, 600, 1.0, ShooterConsts::GOLD_AK47_FIRE_SOUND, ShooterConsts::GOLD_AK47_RELOAD_SOUND, ObjectNameTag("gold_ak47"), ShooterConsts::GOLD_AK47_OBJ, Vec3D{3, 3, 3}, Vec3D{-2.2, 1.0, 1.3}, Vec3D{0, Consts::PI, 0}) { } }; diff --git a/weapon/Gun.cpp b/weapon/Gun.cpp index 64aabe5..5d58d10 100644 --- a/weapon/Gun.cpp +++ b/weapon/Gun.cpp @@ -8,5 +8,5 @@ using namespace std; -Gun::Gun() : Weapon(30, 6, 2.0, 0.3, 800, 3.0, ShooterConsts::GUN_FIRE_SOUND, ShooterConsts::GUN_RELOAD_SOUND, "gun", ShooterConsts::GUN_OBJ, Vec3D{3, 3, 3}, Vec3D{-1.8, 1.3, 1.8}, Vec3D{0, Consts::PI, 0}) { +Gun::Gun() : Weapon(30, 6, 2.0, 0.3, 800, 3.0, ShooterConsts::GUN_FIRE_SOUND, ShooterConsts::GUN_RELOAD_SOUND, ObjectNameTag("gun"), ShooterConsts::GUN_OBJ, Vec3D{3, 3, 3}, Vec3D{-1.8, 1.3, 1.8}, Vec3D{0, Consts::PI, 0}) { } diff --git a/weapon/Rifle.cpp b/weapon/Rifle.cpp index b446977..bb4382a 100644 --- a/weapon/Rifle.cpp +++ b/weapon/Rifle.cpp @@ -6,5 +6,5 @@ #include "Rifle.h" #include "../ShooterConsts.h" -Rifle::Rifle() : Weapon(5, 1, 1.0, 1.0, 30000, 0.5, ShooterConsts::RIFLE_FIRE_SOUND, ShooterConsts::RIFLE_RELOAD_SOUND, "rifle", ShooterConsts::RIFLE_OBJ, Vec3D{3, 3, 3}, Vec3D{-2.3, 1, 1.3}, Vec3D{0, Consts::PI, 0}) { +Rifle::Rifle() : Weapon(5, 1, 1.0, 1.0, 30000, 0.5, ShooterConsts::RIFLE_FIRE_SOUND, ShooterConsts::RIFLE_RELOAD_SOUND, ObjectNameTag("rifle"), ShooterConsts::RIFLE_OBJ, Vec3D{3, 3, 3}, Vec3D{-2.3, 1, 1.3}, Vec3D{0, Consts::PI, 0}) { } diff --git a/weapon/Shotgun.cpp b/weapon/Shotgun.cpp index 6897c11..0d8eabb 100644 --- a/weapon/Shotgun.cpp +++ b/weapon/Shotgun.cpp @@ -9,7 +9,7 @@ using namespace std; -Shotgun::Shotgun(const std::string& weaponName) : Weapon(15, 1, 1.0, 1.0, 400, 5.0, ShooterConsts::SHOTGUN_FIRE_SOUND, ShooterConsts::SHOTGUN_RELOAD_SOUND, weaponName, ShooterConsts::SHOTGUN_OBJ, Vec3D{3, 3, 3}, Vec3D{-1.95, 0.8, 1.5}, Vec3D{0, Consts::PI, 0}) { +Shotgun::Shotgun() : Weapon(15, 1, 1.0, 1.0, 400, 5.0, ShooterConsts::SHOTGUN_FIRE_SOUND, ShooterConsts::SHOTGUN_RELOAD_SOUND, ObjectNameTag("shotgun"), ShooterConsts::SHOTGUN_OBJ, Vec3D{3, 3, 3}, Vec3D{-1.95, 0.8, 1.5}, Vec3D{0, Consts::PI, 0}) { } std::map diff --git a/weapon/Shotgun.h b/weapon/Shotgun.h index 8d13cb4..5ff9032 100644 --- a/weapon/Shotgun.h +++ b/weapon/Shotgun.h @@ -9,7 +9,7 @@ class Shotgun final : public Weapon { public: - explicit Shotgun(const std::string& weaponName = "shotgun"); + explicit Shotgun(); std::map processFire(std::function rayCastFunction, const Vec3D& position, const Vec3D& direction) override; }; diff --git a/weapon/Weapon.cpp b/weapon/Weapon.cpp index 87cfaea..6096610 100644 --- a/weapon/Weapon.cpp +++ b/weapon/Weapon.cpp @@ -11,7 +11,7 @@ using namespace std; -Weapon::Weapon(int initialPack, int clipCapacity, double reloadTime, double fireDelay, double damage, double spreading, std::string fireSound, std::string reloadSound, const std::string& weaponName, const std::string& objFileName, const Vec3D& s, const Vec3D& t, const Vec3D& r) : RigidBody(ObjectNameTag("weapon_" + weaponName), weaponName), _initialPack(initialPack), _clipCapacity(clipCapacity), _reloadTime(reloadTime), _fireDelay(fireDelay), _damage(damage), _spreading(spreading), _fireSound(std::move(fireSound)), _reloadSound(std::move(reloadSound)) { +Weapon::Weapon(int initialPack, int clipCapacity, double reloadTime, double fireDelay, double damage, double spreading, std::string fireSound, std::string reloadSound, ObjectNameTag weaponName, const std::string& objFileName, const Vec3D& s, const Vec3D& t, const Vec3D& r) : RigidBody(std::move(weaponName), objFileName), _initialPack(initialPack), _clipCapacity(clipCapacity), _reloadTime(reloadTime), _fireDelay(fireDelay), _damage(damage), _spreading(spreading), _fireSound(std::move(fireSound)), _reloadSound(std::move(reloadSound)) { _stockAmmo = _initialPack - _clipCapacity; _clipAmmo = _clipCapacity; diff --git a/weapon/Weapon.h b/weapon/Weapon.h index 3fa3769..026995a 100644 --- a/weapon/Weapon.h +++ b/weapon/Weapon.h @@ -44,7 +44,7 @@ protected: virtual std::map processFire(std::function rayCastFunction, const Vec3D& position, const Vec3D& direction); public: - Weapon(int initialPack, int clipCapacity, double reloadTime, double fireDelay, double damage, double spreading, std::string fireSound, std::string reloadSound, const std::string& weaponName, const std::string& objFileName, const Vec3D& s, const Vec3D& t, const Vec3D& r); + Weapon(int initialPack, int clipCapacity, double reloadTime, double fireDelay, double damage, double spreading, std::string fireSound, std::string reloadSound, ObjectNameTag weaponName, const std::string& objFileName, const Vec3D& s, const Vec3D& t, const Vec3D& r); FireInformation fire(std::function rayCastFunction, const Vec3D& position, const Vec3D& direction); void reload();