2021-09-13 15:53:43 +03:00
|
|
|
//
|
|
|
|
// Created by Иван Ильин on 25.05.2021.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SHOOTER_SERVER_H
|
|
|
|
#define SHOOTER_SERVER_H
|
|
|
|
|
2021-10-09 13:41:12 +03:00
|
|
|
#include "engine/network/ServerUDP.h"
|
2021-09-13 15:53:43 +03:00
|
|
|
#include "Player.h"
|
|
|
|
#include "Bonus.h"
|
|
|
|
|
2021-10-17 10:21:10 +03:00
|
|
|
struct BonusInfo final {
|
|
|
|
const Point4D position{};
|
|
|
|
const double lastTake = std::numeric_limits<double>::min();
|
|
|
|
const bool onTheMap = false;
|
2021-09-13 15:53:43 +03:00
|
|
|
};
|
|
|
|
|
2021-10-12 20:18:56 +03:00
|
|
|
class Server final : public ServerUDP {
|
2021-09-13 15:53:43 +03:00
|
|
|
private:
|
|
|
|
std::map<sf::Uint16, std::shared_ptr<Player>> _players{};
|
2021-10-17 10:21:10 +03:00
|
|
|
std::map<std::string, std::shared_ptr<BonusInfo>> _bonuses{};
|
2021-09-13 15:53:43 +03:00
|
|
|
double _bonusRechargeTime = 60;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Server() = default;
|
|
|
|
|
|
|
|
void broadcast() override;
|
|
|
|
|
|
|
|
void processConnect(sf::Uint16 senderId) override;
|
|
|
|
void processClientUpdate(sf::Uint16 senderId, sf::Packet& packet) override;
|
|
|
|
void processDisconnect(sf::Uint16 senderId) override;
|
|
|
|
|
|
|
|
void processCustomPacket(MsgType type, sf::Packet& packet, sf::Uint16 senderId) override;
|
|
|
|
|
|
|
|
void processStop() override;
|
|
|
|
|
|
|
|
void generateBonuses();
|
|
|
|
|
|
|
|
void updateInfo() override;
|
2021-10-16 20:22:55 +03:00
|
|
|
|
|
|
|
~Server() override;
|
2021-09-13 15:53:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //MINECRAFT_3DZAVR_SERVER_H
|