vectozavr-shooter/Server.h

43 lines
997 B
C
Raw Normal View History

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"
2021-10-17 10:21:10 +03:00
struct BonusInfo final {
2021-10-25 04:09:45 +03:00
const Vec3D position{};
2021-10-17 10:21:10 +03:00
const double lastTake = std::numeric_limits<double>::min();
const bool onTheMap = false;
2021-09-13 15:53:43 +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
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;
2021-10-28 16:58:02 +03:00
void processCustomPacket(sf::Packet& packet, sf::Uint16 senderId) override;
2021-09-13 15:53:43 +03:00
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