Resolve conflicts 3

master
Vectozavr 2023-05-21 16:34:55 +03:00
parent f3d1f11429
commit d8e4f0d207
18 changed files with 78 additions and 31 deletions

2
3dzavr

@ -1 +1 @@
Subproject commit f80ebaf4522310a7560c19e6da2a3a8f36f2eb16 Subproject commit 5217578e1500cbe567ddf13a44fffd60e3ad445c

View File

@ -28,6 +28,8 @@ add_executable(${CMAKE_PROJECT_NAME}
ShooterConsts.h ShooterConsts.h
network/ShooterMsgType.h network/ShooterMsgType.h
network/ShooterMsgType.cpp network/ShooterMsgType.cpp
network/Chat.cpp
network/Chat.h
# 3d engine: # 3d engine:
3dzavr/engine/Consts.h 3dzavr/engine/Consts.h
3dzavr/engine/math/Vec4D.h 3dzavr/engine/math/Vec4D.h

View File

@ -5,11 +5,11 @@
#ifndef SHOOTER_SHOOTER_H #ifndef SHOOTER_SHOOTER_H
#define SHOOTER_SHOOTER_H #define SHOOTER_SHOOTER_H
#include "engine/Engine.h" #include "3dzavr/engine/Engine.h"
#include "player/Player.h" #include "player/Player.h"
#include "player/PlayerController.h" #include "player/PlayerController.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/ShooterClient.h"
#include "network/ShooterServer.h" #include "network/ShooterServer.h"
@ -32,6 +32,7 @@ private:
bool inGame = false; bool inGame = false;
int fireTraces = 0; int fireTraces = 0;
std::string current_map = ShooterConsts::MAP_OBJ;
void start() override; void start() override;
void update() override; void update() override;

View File

@ -40,6 +40,7 @@ namespace ShooterConsts {
const std::string CUBE_OBJ = "obj/other/cube.obj"; const std::string CUBE_OBJ = "obj/other/cube.obj";
const std::string MAP_OBJ = "obj/maps/map1.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 BIG_MAP_OBJ = "obj/maps/map2.obj";
const std::string SIMPLE_MAP_OBJ = "obj/maps/map_simple.obj"; const std::string SIMPLE_MAP_OBJ = "obj/maps/map_simple.obj";
const std::string PLANE_MAP_OBJ = "obj/maps/plane.obj"; const std::string PLANE_MAP_OBJ = "obj/maps/plane.obj";

View File

@ -12,7 +12,7 @@ int main() {
// Optimal for standard monitors: // Optimal for standard monitors:
//game.create(720, 480, ShooterConsts::PROJECT_NAME, true); //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); //game.create(1920, 1080, ShooterConsts::PROJECT_NAME, true, Consts::BACKGROUND_COLOR, sf::Style::Fullscreen);
// Optimal for MacBook Pro 16 display: // Optimal for MacBook Pro 16 display:

View File

@ -4,11 +4,13 @@
#include "ShooterClient.h" #include "ShooterClient.h"
#include <SFML/Network/Ftp.hpp>
#include <string>
#include <utility> #include <utility>
#include "../engine/utils/Log.h" #include "../3dzavr/engine/utils/Log.h"
#include "../engine/animation/Timeline.h" #include "../3dzavr/engine/animation/Timeline.h"
#include "ShooterMsgType.h" #include "ShooterMsgType.h"
#include "../engine/animation/Animations.h" #include "../3dzavr/engine/animation/Animations.h"
void ShooterClient::updatePacket() { void ShooterClient::updatePacket() {
sf::Packet packet; sf::Packet packet;
@ -318,3 +320,40 @@ void
ShooterClient::setChangeEnemyWeaponCallBack(std::function<void(const std::string &, sf::Uint16)> changeEnemyWeapon) { ShooterClient::setChangeEnemyWeaponCallBack(std::function<void(const std::string &, sf::Uint16)> changeEnemyWeapon) {
_changeEnemyWeaponCallBack = std::move(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<std::string>& listing = dirResponse.getListing();
if (listing.size() != 0) {
for (std::vector<std::string>::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("------------------------------");
}

View File

@ -5,8 +5,9 @@
#ifndef SHOOTER_SHOOTERCLIENT_H #ifndef SHOOTER_SHOOTERCLIENT_H
#define SHOOTER_SHOOTERCLIENT_H #define SHOOTER_SHOOTERCLIENT_H
#include "../engine/network/ClientUDP.h" #include "../3dzavr/engine/network/ClientUDP.h"
#include "../player/Player.h" #include "../player/Player.h"
#include <SFML/Config.hpp>
#include "Chat.h" #include "Chat.h"
class ShooterClient final : public ClientUDP { class ShooterClient final : public ClientUDP {
@ -69,6 +70,8 @@ public:
void addPlayer(sf::Uint16 id, std::shared_ptr<Player> player); void addPlayer(sf::Uint16 id, std::shared_ptr<Player> player);
static void requestMap(const std::string& clientIp, std::string *current_map);
[[nodiscard]] std::map<sf::Uint16, std::shared_ptr<Player>> const &players() const { return _players; } [[nodiscard]] std::map<sf::Uint16, std::shared_ptr<Player>> const &players() const { return _players; }
[[nodiscard]] std::string lastEvent() const { return _lastEvent; } [[nodiscard]] std::string lastEvent() const { return _lastEvent; }

View File

@ -3,7 +3,7 @@
// //
#include "ShooterServer.h" #include "ShooterServer.h"
#include "../engine/utils/Log.h" #include "../3dzavr/engine/utils/Log.h"
#include "ShooterMsgType.h" #include "ShooterMsgType.h"
void ShooterServer::broadcast() { void ShooterServer::broadcast() {

View File

@ -5,7 +5,7 @@
#ifndef SHOOTER_SHOOTERSERVER_H #ifndef SHOOTER_SHOOTERSERVER_H
#define SHOOTER_SHOOTERSERVER_H #define SHOOTER_SHOOTERSERVER_H
#include "../engine/network/ServerUDP.h" #include "../3dzavr/engine/network/ServerUDP.h"
#include "../player/Player.h" #include "../player/Player.h"
struct BonusInfo final { struct BonusInfo final {

View File

@ -5,9 +5,9 @@
#include "Player.h" #include "Player.h"
#include <utility> #include <utility>
#include "../engine/io/Screen.h" #include "../3dzavr/engine/io/Screen.h"
#include "../engine/utils/Log.h" #include "../3dzavr/engine/utils/Log.h"
#include "../engine/animation/Animations.h" #include "../3dzavr/engine/animation/Animations.h"
Player::Player(ObjectNameTag name, const std::string &filename, const Vec3D &scale) : RigidBody(std::move(name), filename, scale) { Player::Player(ObjectNameTag name, const std::string &filename, const Vec3D &scale) : RigidBody(std::move(name), filename, scale) {
setAcceleration(Vec3D{0, -ShooterConsts::GRAVITY, 0}); setAcceleration(Vec3D{0, -ShooterConsts::GRAVITY, 0});

View File

@ -7,9 +7,9 @@
#include <SFML/Audio/Sound.hpp> #include <SFML/Audio/Sound.hpp>
#include <utility> #include <utility>
#include "../engine/utils/ResourceManager.h" #include "../3dzavr/engine/utils/ResourceManager.h"
#include "../engine/Camera.h" #include "../3dzavr/engine/Camera.h"
#include "../engine/World.h" #include "../3dzavr/engine/World.h"
#include "../weapon/Ak47.h" #include "../weapon/Ak47.h"
#include "../weapon/Shotgun.h" #include "../weapon/Shotgun.h"
#include "../weapon/Gun.h" #include "../weapon/Gun.h"
@ -17,6 +17,7 @@
#include "../weapon/Rifle.h" #include "../weapon/Rifle.h"
#include "../ShooterConsts.h" #include "../ShooterConsts.h"
class Player final : public RigidBody { class Player final : public RigidBody {
private: private:
double _health = ShooterConsts::HEALTH_MAX; double _health = ShooterConsts::HEALTH_MAX;

View File

@ -3,8 +3,8 @@
// //
#include "PlayerController.h" #include "PlayerController.h"
#include "../engine/utils/Log.h" #include "../3dzavr/engine/utils/Log.h"
#include "../engine/animation/Animations.h" #include "../3dzavr/engine/animation/Animations.h"
PlayerController::PlayerController(std::shared_ptr<Player> player, PlayerController::PlayerController(std::shared_ptr<Player> player,
std::shared_ptr<Keyboard> keyboard, std::shared_ptr<Keyboard> keyboard,

View File

@ -6,8 +6,8 @@
#define SHOOTER_PLAYERCONTROLLER_H #define SHOOTER_PLAYERCONTROLLER_H
#include "Player.h" #include "Player.h"
#include "../engine/io/Keyboard.h" #include "../3dzavr/engine/io/Keyboard.h"
#include "../engine/io/Mouse.h" #include "../3dzavr/engine/io/Mouse.h"
class PlayerController final { class PlayerController final {
private: private:

View File

@ -6,7 +6,7 @@
#define SHOOTER_GUN_H #define SHOOTER_GUN_H
#include "Weapon.h" #include "Weapon.h"
#include "../engine/utils/ResourceManager.h" #include "../3dzavr/engine/utils/ResourceManager.h"
#include "../ShooterConsts.h" #include "../ShooterConsts.h"
class Gun final : public Weapon { class Gun final : public Weapon {

View File

@ -6,7 +6,7 @@
#define SHOOTER_RIFLE_H #define SHOOTER_RIFLE_H
#include "Weapon.h" #include "Weapon.h"
#include "../engine/utils/ResourceManager.h" #include "../3dzavr/engine/utils/ResourceManager.h"
#include "../ShooterConsts.h" #include "../ShooterConsts.h"
class Rifle final : public Weapon { class Rifle final : public Weapon {

View File

@ -6,7 +6,7 @@
#define SHOOTER_SHOTGUN_H #define SHOOTER_SHOTGUN_H
#include "Weapon.h" #include "Weapon.h"
#include "../engine/utils/ResourceManager.h" #include "../3dzavr/engine/utils/ResourceManager.h"
#include "../ShooterConsts.h" #include "../ShooterConsts.h"
class Shotgun final : public Weapon { class Shotgun final : public Weapon {

View File

@ -3,8 +3,8 @@
// //
#include "Weapon.h" #include "Weapon.h"
#include "../engine/utils/ResourceManager.h" #include "../3dzavr/engine/utils/ResourceManager.h"
#include "../engine/utils/Log.h" #include "../3dzavr/engine/utils/Log.h"
#include "../ShooterConsts.h" #include "../ShooterConsts.h"
using namespace std; using namespace std;

View File

@ -7,13 +7,13 @@
#include <string> #include <string>
#include "../engine/World.h" #include "../3dzavr/engine/World.h"
#include "../engine/Camera.h" #include "../3dzavr/engine/Camera.h"
#include <SFML/Audio/Sound.hpp> #include <SFML/Audio/Sound.hpp>
#include "../engine/Mesh.h" #include "../3dzavr/engine/Mesh.h"
#include "../engine/utils/Time.h" #include "../3dzavr/engine/utils/Time.h"
#include "../engine/io/SoundController.h" #include "../3dzavr/engine/io/SoundController.h"
#include "../engine/Consts.h" #include "../3dzavr/engine/Consts.h"
struct FireInformation final { struct FireInformation final {
const std::map<ObjectNameTag, double> damagedPlayers; const std::map<ObjectNameTag, double> damagedPlayers;