| 4325 | /* |
| 4326 | ================== |
| 4327 | CL_GlobalServersAllMaster_f |
| 4328 | Joe Kari: attempt to have a command that get a list form *ALL* master server available. |
| 4329 | ================== |
| 4330 | */ |
| 4331 | void CL_GlobalServersAllMaster_f( void ) { |
| 4332 | netadr_t to; |
| 4333 | int count, i, masterNum; |
| 4334 | char command[1024], *masteraddress; |
| 4335 | |
| 4336 | if ((count = Cmd_Argc()) < 2 ) |
| 4337 | { |
| 4338 | Com_Printf("usage: globalserversallmaster <protocol> [keywords]\n"); |
| 4339 | return; |
| 4340 | } |
| 4341 | |
| 4342 | for ( masterNum = 0 ; masterNum < MAX_MASTER_SERVERS ; masterNum ++ ) |
| 4343 | { |
| 4344 | sprintf(command, "sv_master%d", masterNum + 1); |
| 4345 | masteraddress = Cvar_VariableString(command); |
| 4346 | |
| 4347 | if(!*masteraddress) |
| 4348 | continue; |
| 4349 | |
| 4350 | // reset the list, waiting for response |
| 4351 | // -1 is used to distinguish a "no response" |
| 4352 | |
| 4353 | i = NET_StringToAdr(masteraddress, &to, NA_UNSPEC); |
| 4354 | |
| 4355 | if(!i) |
| 4356 | continue; |
| 4357 | else if(i == 2) |
| 4358 | to.port = BigShort(PORT_MASTER); |
| 4359 | |
| 4360 | Com_Printf("Requesting servers from master %s...\n", masteraddress); |
| 4361 | |
| 4362 | cls.numglobalservers = -1; |
| 4363 | cls.pingUpdateSource = AS_GLOBAL; |
| 4364 | |
| 4365 | // Use the extended query for IPv6 masters |
| 4366 | if (to.type == NA_IP6 || to.type == NA_MULTICAST6) |
| 4367 | { |
| 4368 | int v4enabled = Cvar_VariableIntegerValue("net_enabled") & NET_ENABLEV4; |
| 4369 | |
| 4370 | if(v4enabled) |
| 4371 | { |
| 4372 | Com_sprintf(command, sizeof(command), "getserversExt %s %s ipv6", |
| 4373 | com_gamename->string, Cmd_Argv(1)); |
| 4374 | } |
| 4375 | else |
| 4376 | { |
| 4377 | Com_sprintf(command, sizeof(command), "getserversExt %s %s", |
| 4378 | com_gamename->string, Cmd_Argv(1)); |
| 4379 | } |
| 4380 | |
| 4381 | // TODO: test if we only have an IPv6 connection. If it's the case, |
| 4382 | // request IPv6 servers only by appending " ipv6" to the command |
| 4383 | } |
| 4384 | else |
| 4385 | Com_sprintf(command, sizeof(command), "getservers %s", Cmd_Argv(1)); |
| 4386 | |
| 4387 | for (i=2; i < count; i++) |
| 4388 | { |
| 4389 | Q_strcat(command, sizeof(command), " "); |
| 4390 | Q_strcat(command, sizeof(command), Cmd_Argv(i)); |
| 4391 | } |
| 4392 | |
| 4393 | NET_OutOfBandPrint( NS_SERVER, to, "%s", command ); |
| 4394 | } |
| 4395 | } |
| 4396 | |