From d8e4f0d207009eb1fef68cf0bc85dca9999f091a Mon Sep 17 00:00:00 2001 From: Vectozavr <60608292+vectozavr@users.noreply.github.com> Date: Sun, 21 May 2023 16:34:55 +0300 Subject: [PATCH] Resolve conflicts 3 --- 3dzavr | 2 +- CMakeLists.txt | 2 ++ Shooter.h | 5 +++-- ShooterConsts.h | 1 + Source.cpp | 2 +- network/ShooterClient.cpp | 45 ++++++++++++++++++++++++++++++++++--- network/ShooterClient.h | 5 ++++- network/ShooterServer.cpp | 2 +- network/ShooterServer.h | 2 +- player/Player.cpp | 6 ++--- player/Player.h | 7 +++--- player/PlayerController.cpp | 4 ++-- player/PlayerController.h | 4 ++-- weapon/Gun.h | 2 +- weapon/Rifle.h | 2 +- weapon/Shotgun.h | 2 +- weapon/Weapon.cpp | 4 ++-- weapon/Weapon.h | 12 +++++----- 18 files changed, 78 insertions(+), 31 deletions(-) diff --git a/3dzavr b/3dzavr index f80ebaf..5217578 160000 --- a/3dzavr +++ b/3dzavr @@ -1 +1 @@ -Subproject commit f80ebaf4522310a7560c19e6da2a3a8f36f2eb16 +Subproject commit 5217578e1500cbe567ddf13a44fffd60e3ad445c diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a018a5..d51135b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,8 @@ add_executable(${CMAKE_PROJECT_NAME} ShooterConsts.h network/ShooterMsgType.h network/ShooterMsgType.cpp + network/Chat.cpp + network/Chat.h # 3d engine: 3dzavr/engine/Consts.h 3dzavr/engine/math/Vec4D.h diff --git a/Shooter.h b/Shooter.h index 9628784..6ff4c27 100644 --- a/Shooter.h +++ b/Shooter.h @@ -5,11 +5,11 @@ #ifndef SHOOTER_SHOOTER_H #define SHOOTER_SHOOTER_H -#include "engine/Engine.h" +#include "3dzavr/engine/Engine.h" #include "player/Player.h" #include "player/PlayerController.h" #include "player/PlayerController.h" -#include "engine/gui/Window.h" +#include "3dzavr/engine/gui/Window.h" #include "network/ShooterClient.h" #include "network/ShooterServer.h" @@ -32,6 +32,7 @@ private: bool inGame = false; int fireTraces = 0; + std::string current_map = ShooterConsts::MAP_OBJ; void start() override; void update() override; diff --git a/ShooterConsts.h b/ShooterConsts.h index e8d2a18..d25c5fc 100644 --- a/ShooterConsts.h +++ b/ShooterConsts.h @@ -40,6 +40,7 @@ namespace ShooterConsts { const std::string CUBE_OBJ = "obj/other/cube.obj"; const std::string MAP_OBJ = "obj/maps/map1.obj"; + const std::string MAR_RAILWAY_OBJ = "obj/maps/railway.obj"; const std::string BIG_MAP_OBJ = "obj/maps/map2.obj"; const std::string SIMPLE_MAP_OBJ = "obj/maps/map_simple.obj"; const std::string PLANE_MAP_OBJ = "obj/maps/plane.obj"; diff --git a/Source.cpp b/Source.cpp index 0a1f244..bb97154 100644 --- a/Source.cpp +++ b/Source.cpp @@ -12,7 +12,7 @@ int main() { // Optimal for standard monitors: //game.create(720, 480, ShooterConsts::PROJECT_NAME, true); - game.create(1280, 720, ShooterConsts::PROJECT_NAME, true); + game.create(1920, 1080, ShooterConsts::PROJECT_NAME, true); //game.create(1920, 1080, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen); // Optimal for MacBook Pro 16 display: diff --git a/network/ShooterClient.cpp b/network/ShooterClient.cpp index 3ffa60a..33d067a 100644 --- a/network/ShooterClient.cpp +++ b/network/ShooterClient.cpp @@ -4,11 +4,13 @@ #include "ShooterClient.h" +#include +#include #include -#include "../engine/utils/Log.h" -#include "../engine/animation/Timeline.h" +#include "../3dzavr/engine/utils/Log.h" +#include "../3dzavr/engine/animation/Timeline.h" #include "ShooterMsgType.h" -#include "../engine/animation/Animations.h" +#include "../3dzavr/engine/animation/Animations.h" void ShooterClient::updatePacket() { sf::Packet packet; @@ -318,3 +320,40 @@ void ShooterClient::setChangeEnemyWeaponCallBack(std::function changeEnemyWeapon) { _changeEnemyWeaponCallBack = std::move(changeEnemyWeapon); } + +void ShooterClient::requestMap(const std::string& clientIp, std::string *current_map) { + Log::log("---------[FTP server]---------"); + sf::Ftp ftp; + sf::Ftp::Response connectResponse = ftp.connect(clientIp, 21); + if (connectResponse.isOk()) { + ftp.login(); + + sf::Ftp::ListingResponse dirResponse = ftp.getDirectoryListing("current_map/"); + Log::log("Response code: "+std::to_string(dirResponse.getStatus())+" | Message: "+dirResponse.getMessage()); + if (dirResponse.isOk()) { + const std::vector& listing = dirResponse.getListing(); + + if (listing.size() != 0) { + for (std::vector::const_iterator it = listing.begin(); it != listing.end(); ++it) + Log::log("- "+*it); + + sf::Ftp::Response downloadResponse = ftp.download(listing.at(0), "./obj/maps/", sf::Ftp::Ascii); + Log::log("Response code: "+std::to_string(downloadResponse.getStatus())+" | Message: "+downloadResponse.getMessage()); + + if (downloadResponse.isOk()) { + std::string map_path = listing.at(0); + map_path = "./obj/maps"+map_path.substr(map_path.find("/")); + Log::log("Map set to: "+map_path); + *current_map = map_path; + } + } else { + Log::log("there is no map file"); + } + } + + ftp.disconnect(); + } else { + Log::log("Couldn't connect to FTP server with ip: "+clientIp+" and port: 21"); + } + Log::log("------------------------------"); +} diff --git a/network/ShooterClient.h b/network/ShooterClient.h index 1b1934c..1f9e12a 100644 --- a/network/ShooterClient.h +++ b/network/ShooterClient.h @@ -5,8 +5,9 @@ #ifndef SHOOTER_SHOOTERCLIENT_H #define SHOOTER_SHOOTERCLIENT_H -#include "../engine/network/ClientUDP.h" +#include "../3dzavr/engine/network/ClientUDP.h" #include "../player/Player.h" +#include #include "Chat.h" class ShooterClient final : public ClientUDP { @@ -69,6 +70,8 @@ public: void addPlayer(sf::Uint16 id, std::shared_ptr player); + static void requestMap(const std::string& clientIp, std::string *current_map); + [[nodiscard]] std::map> const &players() const { return _players; } [[nodiscard]] std::string lastEvent() const { return _lastEvent; } diff --git a/network/ShooterServer.cpp b/network/ShooterServer.cpp index ebec713..350c692 100644 --- a/network/ShooterServer.cpp +++ b/network/ShooterServer.cpp @@ -3,7 +3,7 @@ // #include "ShooterServer.h" -#include "../engine/utils/Log.h" +#include "../3dzavr/engine/utils/Log.h" #include "ShooterMsgType.h" void ShooterServer::broadcast() { diff --git a/network/ShooterServer.h b/network/ShooterServer.h index 6034b96..b1e5e86 100644 --- a/network/ShooterServer.h +++ b/network/ShooterServer.h @@ -5,7 +5,7 @@ #ifndef SHOOTER_SHOOTERSERVER_H #define SHOOTER_SHOOTERSERVER_H -#include "../engine/network/ServerUDP.h" +#include "../3dzavr/engine/network/ServerUDP.h" #include "../player/Player.h" struct BonusInfo final { diff --git a/player/Player.cpp b/player/Player.cpp index d198edd..ad4767d 100644 --- a/player/Player.cpp +++ b/player/Player.cpp @@ -5,9 +5,9 @@ #include "Player.h" #include -#include "../engine/io/Screen.h" -#include "../engine/utils/Log.h" -#include "../engine/animation/Animations.h" +#include "../3dzavr/engine/io/Screen.h" +#include "../3dzavr/engine/utils/Log.h" +#include "../3dzavr/engine/animation/Animations.h" Player::Player(ObjectNameTag name, const std::string &filename, const Vec3D &scale) : RigidBody(std::move(name), filename, scale) { setAcceleration(Vec3D{0, -ShooterConsts::GRAVITY, 0}); diff --git a/player/Player.h b/player/Player.h index 36e97e0..c77e659 100644 --- a/player/Player.h +++ b/player/Player.h @@ -7,9 +7,9 @@ #include #include -#include "../engine/utils/ResourceManager.h" -#include "../engine/Camera.h" -#include "../engine/World.h" +#include "../3dzavr/engine/utils/ResourceManager.h" +#include "../3dzavr/engine/Camera.h" +#include "../3dzavr/engine/World.h" #include "../weapon/Ak47.h" #include "../weapon/Shotgun.h" #include "../weapon/Gun.h" @@ -17,6 +17,7 @@ #include "../weapon/Rifle.h" #include "../ShooterConsts.h" + class Player final : public RigidBody { private: double _health = ShooterConsts::HEALTH_MAX; diff --git a/player/PlayerController.cpp b/player/PlayerController.cpp index f3fde49..7aa3fb9 100644 --- a/player/PlayerController.cpp +++ b/player/PlayerController.cpp @@ -3,8 +3,8 @@ // #include "PlayerController.h" -#include "../engine/utils/Log.h" -#include "../engine/animation/Animations.h" +#include "../3dzavr/engine/utils/Log.h" +#include "../3dzavr/engine/animation/Animations.h" PlayerController::PlayerController(std::shared_ptr player, std::shared_ptr keyboard, diff --git a/player/PlayerController.h b/player/PlayerController.h index 97639d0..5d08915 100644 --- a/player/PlayerController.h +++ b/player/PlayerController.h @@ -6,8 +6,8 @@ #define SHOOTER_PLAYERCONTROLLER_H #include "Player.h" -#include "../engine/io/Keyboard.h" -#include "../engine/io/Mouse.h" +#include "../3dzavr/engine/io/Keyboard.h" +#include "../3dzavr/engine/io/Mouse.h" class PlayerController final { private: diff --git a/weapon/Gun.h b/weapon/Gun.h index 028d041..328c9f6 100644 --- a/weapon/Gun.h +++ b/weapon/Gun.h @@ -6,7 +6,7 @@ #define SHOOTER_GUN_H #include "Weapon.h" -#include "../engine/utils/ResourceManager.h" +#include "../3dzavr/engine/utils/ResourceManager.h" #include "../ShooterConsts.h" class Gun final : public Weapon { diff --git a/weapon/Rifle.h b/weapon/Rifle.h index 3e19b38..bd6efef 100644 --- a/weapon/Rifle.h +++ b/weapon/Rifle.h @@ -6,7 +6,7 @@ #define SHOOTER_RIFLE_H #include "Weapon.h" -#include "../engine/utils/ResourceManager.h" +#include "../3dzavr/engine/utils/ResourceManager.h" #include "../ShooterConsts.h" class Rifle final : public Weapon { diff --git a/weapon/Shotgun.h b/weapon/Shotgun.h index 059af7c..0bb7a4f 100644 --- a/weapon/Shotgun.h +++ b/weapon/Shotgun.h @@ -6,7 +6,7 @@ #define SHOOTER_SHOTGUN_H #include "Weapon.h" -#include "../engine/utils/ResourceManager.h" +#include "../3dzavr/engine/utils/ResourceManager.h" #include "../ShooterConsts.h" class Shotgun final : public Weapon { diff --git a/weapon/Weapon.cpp b/weapon/Weapon.cpp index addefef..2bc9107 100644 --- a/weapon/Weapon.cpp +++ b/weapon/Weapon.cpp @@ -3,8 +3,8 @@ // #include "Weapon.h" -#include "../engine/utils/ResourceManager.h" -#include "../engine/utils/Log.h" +#include "../3dzavr/engine/utils/ResourceManager.h" +#include "../3dzavr/engine/utils/Log.h" #include "../ShooterConsts.h" using namespace std; diff --git a/weapon/Weapon.h b/weapon/Weapon.h index 4b2395a..1e77958 100644 --- a/weapon/Weapon.h +++ b/weapon/Weapon.h @@ -7,13 +7,13 @@ #include -#include "../engine/World.h" -#include "../engine/Camera.h" +#include "../3dzavr/engine/World.h" +#include "../3dzavr/engine/Camera.h" #include -#include "../engine/Mesh.h" -#include "../engine/utils/Time.h" -#include "../engine/io/SoundController.h" -#include "../engine/Consts.h" +#include "../3dzavr/engine/Mesh.h" +#include "../3dzavr/engine/utils/Time.h" +#include "../3dzavr/engine/io/SoundController.h" +#include "../3dzavr/engine/Consts.h" struct FireInformation final { const std::map damagedPlayers;