Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
10#include "RType/Logger.hpp"
12
13#include <chrono>
14#include <csignal>
15#include <iostream>
16#include <thread>
17
18namespace rtp::server
19{
20 void signal_handler(int signum)
21 {
22 if (signum == SIGINT) {
23 rtp::log::info("Server received SIGINT (Ctrl+C). Initiating graceful "
24 "shutdown...");
25 exit(0);
26 }
27 }
28
29 uint16_t parseArguments(int argc, char **argv)
30 {
31 uint16_t port = 5000;
32 for (int i = 1; i < argc; ++i) {
33 std::string arg = argv[i];
34 if (arg == "--port" && i + 1 < argc) {
35 port = static_cast<uint16_t>(std::stoi(argv[++i]));
36 }
37 }
38 return port;
39 }
40} // namespace rtp::server
41
42int main(int ac, char **av)
43{
44 std::signal(SIGINT, rtp::server::signal_handler);
45
46 uint16_t ServerPort = rtp::server::parseArguments(ac, av);
47 try {
48 rtp::log::info("Starting R-Type Server on port {}", ServerPort);
49
50 rtp::server::ServerNetwork networkManager(ServerPort);
51 rtp::server::GameManager gameManager(networkManager);
52
53 networkManager.start();
54
55 gameManager.gameLoop();
56
57 } catch (const std::exception &e) {
58 rtp::log::fatal("Fatal error during server startup or game loop: {}",
59 e.what());
60 return 84;
61 }
62
63 rtp::log::info("Server main thread exiting.");
64 return 0;
65}
Logger declaration with support for multiple log levels.
Manages game state, rooms, and player interactions on the server side.
void gameLoop(void)
Main game loop.
Implementation ASIO du serveur réseau (TCP + UDP)
void start(void) override
Start the network server.
int main(int ac, char **av)
Definition main.cpp:38
void fatal(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log a fatal error message.
void info(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log an informational message.
File : GameManager.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....
uint16_t parseArguments(int argc, char **argv)
Definition main.cpp:29
void signal_handler(int signum)
Definition main.cpp:20