-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
42 lines (33 loc) · 884 Bytes
/
main.cpp
File metadata and controls
42 lines (33 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Main file for Netmap dedicated server
#include <unistd.h> // For sleep() calls
#include <iostream>
#include <string>
#include <vector>
#include <SFML/Network.hpp>
#include "serverdatabattle.h" // Do we need this anymore?
#include "lobby.h"
using namespace std;
Lobby* LOBBY;
void cleanup() { // Called when the server closes
cout << "Cleaning up...\n";
delete LOBBY;
//sleep(1);
}
int main(int argc, char** argv) {
atexit(cleanup);
int PORT = 9900; // Default port is 9900
for (int i=0; i<argc; i++) { // Read command-line arguments
cout << argv[i] << '\n';
if (argv[i] == "-port") {
if (argc < i + 1) {
PORT = stoi(argv[i+1]);
}
}
}
cout << '\n';
cout << "Starting Netmap 1.0 server\n";
LOBBY = new Lobby(PORT);
while (true) {
LOBBY->tick();
}
}