-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
35 lines (31 loc) · 753 Bytes
/
Copy pathMain.cpp
File metadata and controls
35 lines (31 loc) · 753 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
#include "Main.h"
namespace {
std::unique_ptr<Game> game;
}
void parse_config_file(const std::string& filename, std::string& ip, int& port) {
std::ifstream file(filename);
std::string line;
while (std::getline(file, line)) {
std::istringstream iss(line);
std::string key;
if (std::getline(iss, key, '=')) {
std::string value;
if (std::getline(iss, value)) {
// Do something with the key-value pair.
if (key == "ip") {
ip = value;
} else if (key == "port") {
port = stoi(value);
}
}
}
}
}
int main() {
std::string ip = {};
int port = 0;
parse_config_file("net_config.txt", ip, port);
std::cout << "Starting game..." << std::endl;
game = std::make_unique<Game>(ip, port);
game->InitializeGame();
}