-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.cc
43 lines (33 loc) · 1008 Bytes
/
main.cc
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
43
#include "rlbot/rlbot_generated.h"
#include "examplebot.h"
#include "rlbot/bot.h"
#include "rlbot/botmanager.h"
#include "rlbot/interface.h"
#include "rlbot/platform.h"
#include <cctype>
#include <fstream>
#include <iostream>
#include <string>
uint16_t getPortFromFile(std::string filename) {
std::ifstream file;
file.open(filename);
std::string line;
std::getline(file, line);
file.close();
return std::stoi(line);
}
rlbot::Bot *botFactory(int index, int team, std::string name) {
return new ExampleBot(index, team, name);
}
int main(int argc, char **argv) {
// Set the working directory to the directory of this executable so we can use
// relative paths.
rlbot::platform::SetWorkingDirectory(
rlbot::platform::GetExecutableDirectory());
// Read the port that we use for receiving bot spawn messages.
uint16_t port = getPortFromFile("port.cfg");
// Start the bot server.
rlbot::BotManager botmanager(botFactory);
botmanager.StartBotServer(port);
return 0;
}