bettola/server/src/main.cpp
Ritchie Cunningham fce3b3aad6 [Add] Implement database persistance and Login UI.
[Build System]
- Integrate 'sqlite3' and 'sqlite_modern_cpp' using FetchContent.
- Enabled 'C' language to allow compilation of 'sqlite3' lib.

[Persistance]
- Adds a 'DatabaseManager' class to handle all SQLite operations.
- Creates a 'players' table on server startup.
- Server uses separate database for single-player 'bettola_sp.db' and
  'bettola.db'

[UI]
- Adds a new 'LoginScreen' UI.
- Game flow is now MainMenu -> LoginScreen -> bootSequence -> Desktop.
- 'LoginScreen' has interactive tabs to switch between "Login" and
  "Create Account" 'modes'.
- Full client-server communication for creating accounts and
  authentication.

[Server]
- Refactor 'NetworkManager' to handle an 'AUTHENTICATING' state for new
  connectiosn.
- Player state is only set to 'ACTIVE' after a successful login
2025-10-05 22:45:33 +01:00

26 lines
571 B
C++

#include <cstdio>
#include <exception>
#include <thread>
#include <chrono>
#include "network_manager.h"
#include "net/constants.h"
const std::string DB_FILE = "bettola.db";
int main(int argc, char** argv) {
try {
/* We'll keep main thread alive while server runs in background. */
NetworkManager server(DB_FILE);
server.start(MULTIPLAYER_PORT);
while(true) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
} catch(const std::exception& e) {
fprintf(stderr, "Main exception: %s\n", e.what());
return 1;
}
return 0;
}