SuperTuxKart
Loading...
Searching...
No Matches
child_loop.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2020 SuperTuxKart-Team
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18#ifndef HEADER_SERVER_LOOP_HPP
19#define HEADER_SERVER_LOOP_HPP
20
21#include "utils/types.hpp"
22#include <atomic>
23#include <string>
24
26{
27 bool m_lan_server;
28 uint32_t m_login_id;
29 std::string m_token;
30 unsigned m_server_ai;
31};
32
34{
35private:
36 const ChildLoopConfig* m_cl_config;
37
38 std::atomic_bool m_abort;
39
40 std::atomic<uint16_t> m_port;
41
42 std::atomic<uint32_t> m_server_online_id;
43
44 uint64_t m_curr_time;
45 uint64_t m_prev_time;
46 float getLimitedDt();
47public:
48 ChildLoop(const ChildLoopConfig& clc)
49 : m_cl_config(new ChildLoopConfig(clc))
50 {
51 m_abort = false;
52 m_prev_time = m_curr_time = 0;
53 m_port = 0;
54 m_server_online_id = 0;
55 }
56 void run();
58 void abort() { m_abort = true; }
59 bool isAborted() const { return m_abort; }
60 uint16_t getPort() const { return m_port; }
61 uint32_t getServerOnlineId() const { return m_server_online_id; }
62}; // ChildLoop
63
64#endif
Definition: child_loop.hpp:34
void abort()
Set the abort flag, causing the mainloop to be left.
Definition: child_loop.hpp:58
Definition: child_loop.hpp:26
Declares the general types that are used by the network.