34 : server_index(-1), host_request(false), conn(0)
69 if (!addr || !*addr || port < 1024 || port > 48000)
74 strcpy_s(buffer, name);
76 sprintf_s(buffer,
"%s:%d", addr, port);
79 server->
name = buffer;
87 Print(
"NetClientConfig::AddServer(%s, %s, %d) failed to resolve IP Addr\n",
97 if (index >= 0 && index < servers.
size()) {
107 if (n >= 0 && n < servers.
size())
108 return servers.
at(n);
118 if (server_index >= 0 && server_index < servers.
size())
119 return servers.
at(server_index);
149 strcpy_s(filename,
"client.cfg");
152 ::fopen_s(&f, filename,
"rb");
155 ::fseek(f, 0, SEEK_END);
157 ::fseek(f, 0, SEEK_SET);
159 block =
new(__FILE__,__LINE__) BYTE[blocklen+1];
162 ::fread(block, blocklen, 1, f);
171 Parser parser(
new(__FILE__,__LINE__)
BlockReader((
const char*) block, blocklen));
175 Print(
"ERROR: could not parse '%s'.\n", filename);
180 if (!file_type || file_type->
value() !=
"CLIENT_CONFIG") {
181 Print(
"WARNING: invalid '%s' file. Using defaults\n", filename);
196 Print(
"WARNING: server struct missing in '%s'\n", filename);
211 else if (pdef->
name()->
value() ==
"addr")
213 else if (pdef->
name()->
value() ==
"pass")
215 else if (pdef->
name()->
value() ==
"port")
220 AddServer(name, addr, (WORD) port, pass,
true);
224 Print(
"WARNING: unknown label '%s' in '%s'\n",
241 fopen_s(&f,
"client.cfg",
"w");
243 fprintf(f,
"CLIENT_CONFIG\n\n");
250 int port = (int) server->
port;
251 fprintf(f,
"server: {\n");
252 fprintf(f,
" name: \"%s\",\n", (
const char*) server->
name);
253 fprintf(f,
" addr: \"%s\",\n", (
const char*) server->
hostname);
254 fprintf(f,
" port: %d,\n", port);
257 fprintf(f,
" pass: \"%s\",\n", (
const char*) server->
password);
311 result = conn->
Login(host_request);