3 #include <boost/asio/ip/tcp.hpp>
63 bool loadPlayer(std::string username, std::string password,
const std::shared_ptr<Connection>& connection);
85 boost::asio::executor_work_guard<boost::asio::io_context::executor_type>
workGuardM;
Class for handling database queries.
Definition: DatabaseManager.hpp:23
GameWorld class. It contains all the player, npc, object and item instances.
Definition: GameWorld.hpp:16
Main class for the server.
Definition: Server.hpp:15
void handleMessage(const Message &msg)
Function to parse and act upon messages received from clients.
Definition: Server.cpp:85
boost::asio::executor_work_guard< boost::asio::io_context::executor_type > workGuardM
Definition: Server.hpp:85
void sendGameState()
Sends the current gamestate to connected clients.
Definition: Server.cpp:251
void tick()
Function that updates the gamestate on each server tick, called by ticker()
Definition: Server.cpp:229
void savePlayer(int playerId)
Saves a player's data to the database.
Definition: Server.cpp:449
DatabaseManager dbManagerM
Definition: Server.hpp:89
void initGameState()
Initializes the gamestate and gameworld.
Definition: Server.cpp:403
std::vector< std::shared_ptr< Connection > > connectionsM
Definition: Server.hpp:75
std::thread ioThreadM
Definition: Server.hpp:79
void ticker()
Timer function that is used to start server ticks, runs on a separate thread.
Definition: Server.cpp:220
void acceptConnections()
Function to accept new connections from clients, runs on a seperate thread.
Definition: Server.cpp:46
std::thread acceptThreadM
Definition: Server.hpp:81
MessageQueue messagesM
Definition: Server.hpp:77
boost::asio::io_context ioContextM
Definition: Server.hpp:71
GameWorld gameWorldM
Definition: Server.hpp:87
Server()
Definition: Server.cpp:21
boost::asio::ip::tcp::acceptor acceptorM
Definition: Server.hpp:73
bool loadPlayer(std::string username, std::string password, const std::shared_ptr< Connection > &connection)
Loads a player's data from the database and adds the player to the game.
Definition: Server.cpp:408
void processMessages()
Server's main loop for processing messages.
Definition: Server.cpp:70
std::thread tickThreadM
Definition: Server.hpp:83