-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcl-main.cpp
44 lines (37 loc) · 1.51 KB
/
cl-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
#include <client.hpp>
#include <argparser.hpp>
int main(int argc, char** argv)
{
ArgParser parser;
parser.AddOption("-ip", "IPv4 address of the server.", OptionAttr::RequiredWithValue, OptionValueType::STRING);
parser.AddOption("-port", "Game server port.", OptionAttr::RequiredWithValue, OptionValueType::INT16U);
parser.AddOption("-pw", "Password of the server", OptionAttr::OptionalWithValue, OptionValueType::STRING);
parser.AddOption("-name", "Nick name of you.", OptionAttr::RequiredWithValue, OptionValueType::STRING);
parser.AddOption("-cport", "Client port", OptionAttr::OptionalWithValue, OptionValueType::INT16U);
parser.AddOption("-ticket", "Auth session ticket from steam", OptionAttr::OptionalWithValue, OptionValueType::STRING);
parser.AddOption("-ts", "Connect to tiny csgo server", OptionAttr::OptionalWithoutValue);
try
{
parser.ParseArgument(argc, argv);
}
catch (const std::exception& e)
{
printf("%s\n", e.what());
return -1;
}
Client cl(parser);
if (!cl.PrepareSteamAPI())
return -1;
cl.InitCommandInput();
cl.BindServer(parser.GetOptionValueString("-ip"),
parser.GetOptionValueString("-name"),
parser.GetOptionValueString("-pw"),
parser.GetOptionValueInt16U("-port"),
parser.HasOption("-cport") ? parser.GetOptionValueInt16U("-cport") : 27015);
do
{
cl.SetRetryState(false);
cl.RunClient();
} while (cl.GetRetryState());
return 0;
}