-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
46 lines (40 loc) · 1.17 KB
/
main.cpp
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
44
45
46
#include "gamewindow.hpp"
/*
#ifdef _WIN32
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
#else
*/
#ifdef _WIN32
#undef main
#endif
int main(int argc, char **argv)
{
GameWindow *win = new GameWindow(1280, 720);
for(int i=1; i < argc; i++)
{
if(strcmp(argv[i], "--server") == 0)
{
assert((i+1) < argc && "Port required");
uint16_t port = atoi(argv[i+1]);
assert(port > 0 && "Incorrect port");
win->host(port);
continue;
}
else if(strcmp(argv[i], "--connect") == 0)
{
assert((i+1) < argc && "Insufficient arguments");
std::string dest = argv[i+1];
size_t iplen = dest.find_first_of(':');
assert(iplen < dest.length() && "Port required");
assert(iplen != std::string::npos && "Insufficient arguments");
std::string ip = dest.substr(0, iplen);
uint16_t port = atoi(dest.substr(iplen+1).c_str());
win->connect(ip, port);
}
}
return win->exec();
}