|
Zappy GUI
C++ graphic client: renderer, camera, network
|
The main application class that manages the game state, network communication, and rendering. It parses command-line arguments, connects to the game server, receives events, updates the game state, and renders the game using a renderer. More...
#include <App.hpp>
Collaboration diagram for App:Public Member Functions | |
| App (int argc, char **argv) | |
| bool | shouldRun () const |
| Checks if the application should run based on the parsed arguments. | |
| int | exitCode () const |
| Gets the exit code to return if the application should not run. | |
| void | run () |
| Runs the application. | |
Protected Member Functions | |
| void | pollAndEnqueue (TcpSocket &socket, EventQueue &queue) |
| Polls the socket for new data and enqueues any received events. | |
| bool | _connectWithRetry (TcpSocket &socket, const std::string &host, int port) |
| Attempts to connect with exponential backoff. Returns true on success. | |
| void | _trySendStu (TcpSocket &socket) |
| Sends stu once per real second and silences it after 3 consecutive non-responses. | |
| void | _resetStuState () |
| Resets stu polling state, called on reconnect. | |
Protected Attributes | |
| Args | args |
| GameState | state |
| bool | _rendererActive = false |
| std::chrono::steady_clock::time_point | _lastStuSent {} |
| int | _stuMissedResponses = 0 |
| bool | _stuSilenced = false |
| std::unique_ptr< IAudioManager > | _audioManager |
The main application class that manages the game state, network communication, and rendering. It parses command-line arguments, connects to the game server, receives events, updates the game state, and renders the game using a renderer.
|
protected |
Attempts to connect with exponential backoff. Returns true on success.
Definition at line 134 of file App.cpp.
References TcpSocket::connect(), g_interrupted, MAX_RETRIES, TcpSocket::send(), and TcpException::what().
Referenced by run().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Resets stu polling state, called on reconnect.
Definition at line 127 of file App.cpp.
References _lastStuSent, _stuMissedResponses, and _stuSilenced.
Referenced by run().
Here is the caller graph for this function:
|
protected |
Sends stu once per real second and silences it after 3 consecutive non-responses.
Definition at line 105 of file App.cpp.
References _lastStuSent, _stuMissedResponses, _stuSilenced, GameState::receivedStuResponse, TcpSocket::send(), and state.
Referenced by run().
Here is the call graph for this function:
Here is the caller graph for this function:| int App::exitCode | ( | ) | const |
Gets the exit code to return if the application should not run.
Definition at line 26 of file App.cpp.
References args, and Args::exitCode().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Polls the socket for new data and enqueues any received events.
| socket | The TCP socket to poll. |
| queue | The event queue to enqueue events into. |
Definition at line 95 of file App.cpp.
References ProtocolParser::parse(), TcpSocket::poll(), EventQueue::push(), and TcpSocket::recvLine().
Referenced by run().
Here is the call graph for this function:
Here is the caller graph for this function:| void App::run | ( | ) |
Runs the application.
Definition at line 28 of file App.cpp.
References _audioManager, _connectWithRetry(), _rendererActive, _resetStuState(), _trySendStu(), GameState::applyEvent(), args, EventQueue::clear(), AppConfig::dev, g_interrupted, Args::getConfig(), IRenderer::getPendingSpeedChange(), IRenderer::handleInput(), AppConfig::headless, IRenderer::init(), AppConfig::language, AppConfig::machine, pollAndEnqueue(), EventQueue::pop(), AppConfig::port, IRenderer::render(), IRenderer::setDevMode(), I18n::setLanguage(), IRenderer::setState(), IRenderer::shouldClose(), IRenderer::shutdown(), state, and TcpException::what().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| bool App::shouldRun | ( | ) | const |
Checks if the application should run based on the parsed arguments.
Definition at line 24 of file App.cpp.
References args, and Args::isValid().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
|
protected |
Definition at line 60 of file App.hpp.
Referenced by _resetStuState(), and _trySendStu().
|
protected |
|
protected |
Definition at line 61 of file App.hpp.
Referenced by _resetStuState(), and _trySendStu().
|
protected |
Definition at line 62 of file App.hpp.
Referenced by _resetStuState(), and _trySendStu().
|
protected |
Definition at line 40 of file App.hpp.
Referenced by exitCode(), run(), and shouldRun().
|
protected |
Definition at line 41 of file App.hpp.
Referenced by _trySendStu(), and run().