|
@@ -106,6 +106,8 @@
|
|
|
#include "game/version.h"
|
|
|
#include "game/gameConnection.h"
|
|
|
|
|
|
+#include "serverQuery_ScriptBinding.h"
|
|
|
+
|
|
|
// This is basically the server query protocol version now:
|
|
|
static const char* versionString = "VER1";
|
|
|
|
|
@@ -138,8 +140,6 @@ static U32 gServerPingCount = 0;
|
|
|
static U32 gServerQueryCount = 0;
|
|
|
static U32 gHeartbeatSeq = 0;
|
|
|
|
|
|
-ConsoleFunctionGroupBegin( ServerQuery, "Functions which allow you to query the LAN or a master server for online games.");
|
|
|
-
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
struct Ping
|
|
@@ -389,45 +389,6 @@ void queryLanServers(U32 port, U8 flags, const char* gameType, const char* missi
|
|
|
processPingsAndQueries( gPingSession );
|
|
|
}
|
|
|
|
|
|
-//-----------------------------------------------------------------------------
|
|
|
-ConsoleFunction( queryLanServers, void, 12, 12, "( port , flags , gametype , missiontype , minplayers , maxplayers , maxbots , regionmask , maxping , mincpu , filterflags ) Use the queryLANServers function to establish whether any game servers of the required specification(s) are available on the local area network (LAN).\n"
|
|
|
- "@param port Look for any game servers advertising at this port. Set to 0 if you don't care what port the game server is using.\n"
|
|
|
- "@param flags Look for any game servers with these special flags set. Set to 0 for no flags.\n"
|
|
|
- "@param gametype Look for any game servers playing a game type that matches this string. Set to the NULL string to look for any game type.\n"
|
|
|
- "@param missiontype Look for any game servers playing a mission type that matches this string. Set to the NULL string to look for any mission type.\n"
|
|
|
- "@param minplayers Look for any game servers with this number of players or more. Set to 0 for no lower limit.\n"
|
|
|
- "@param maxplayers Look for any game servers with this number of players or fewer. Set to 0 for no upper limit.\n"
|
|
|
- "@param maxbots Look for any game servers with this number of AI controlled players or fewer. Set to 0 for no limit.\n"
|
|
|
- "@param regionmask Look for any master servers, on our master server list, in this region. Set to 0 to examine all regions.\n"
|
|
|
- "@param maxping Look for any game servers with a PING rate equal to or lower than this. Set to 0 for no upper PING limit.\n"
|
|
|
- "@param mincpu Look for any game servers with a CPU (clock speed) equal or greater than this. Set to 0 for no CPU (clock speed) limit.\n"
|
|
|
- "@param filterflags Look for any game servers with this game version number or higher. Set to 0 to find all versions.\n"
|
|
|
- "@return No return value.\n"
|
|
|
- "@sa getServerCount, queryMasterServer, setServerInfo, stopServerQuery")
|
|
|
-{
|
|
|
- U32 lanPort = dAtoi(argv[1]);
|
|
|
- U8 flags = dAtoi(argv[2]);
|
|
|
-
|
|
|
- // It's not a good idea to hold onto args, recursive calls to
|
|
|
- // console exec will trash them.
|
|
|
- char* gameType = dStrdup(argv[3]);
|
|
|
- char* missionType = dStrdup(argv[4]);
|
|
|
-
|
|
|
- U8 minPlayers = dAtoi(argv[5]);
|
|
|
- U8 maxPlayers = dAtoi(argv[6]);
|
|
|
- U8 maxBots = dAtoi(argv[7]);
|
|
|
- U32 regionMask = dAtoi(argv[8]);
|
|
|
- U32 maxPing = dAtoi(argv[9]);
|
|
|
- U16 minCPU = dAtoi(argv[10]);
|
|
|
- U8 filterFlags = dAtoi(argv[11]);
|
|
|
-
|
|
|
- queryLanServers(lanPort, flags, gameType, missionType, minPlayers, maxPlayers, maxBots,
|
|
|
- regionMask, maxPing, minCPU, filterFlags);
|
|
|
-
|
|
|
- dFree(gameType);
|
|
|
- dFree(missionType);
|
|
|
-}
|
|
|
-
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
void queryMasterGameTypes()
|
|
@@ -513,63 +474,6 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
|
|
|
processMasterServerQuery( gPingSession );
|
|
|
}
|
|
|
|
|
|
-ConsoleFunction( queryMasterServer, void, 11, 11, "( flags , gametype , missiontype , minplayers , maxplayers , maxbots , regionmask , maxping , mincpu , filterflags ) Use the queryMasterServer function to query all master servers in the master server list and to establish if they are aware of any game servers that meet the specified requirements, as established by the arguments passed to this function.\n"
|
|
|
- "In order for this function to do anything, a list of master servers must have been previously specified. This list may contain one or more server addresses. A call to this function will search all servers in the list. To specify a list, simply create a set of array entries like this:\n$pref::Master[0] = \"2:192.168.123.15:28002\";\n$pref::Master[1] = \"2:192.168.123.2:28002\";\nThe format of these values is ==> Region Number : IP Address : Port Number\nThese values should be specified in either the client's or the server's preferences file (prefs.cs). You may specifiy it elsewhere, however be sure that it is specified prior to this function being called and before any other functions that rely on it.\n"
|
|
|
- "@param flags Look for any game servers with these special flags set. Set to 0 for no flags.\n"
|
|
|
- "@param gametype Look for any game servers playing a game type that matches this string. Set to the NULL string to look for any game type.\n"
|
|
|
- "@param missiontype Look for any game servers playing a mission type that matches this string. Set to the NULL string to look for any mission type.\n"
|
|
|
- "@param minplayers Look for any game servers with this number of players or more. Set to 0 for no lower limit.\n"
|
|
|
- "@param maxplayers Look for any game servers with this number of players or fewer. Set to 0 for no upper limit.\n"
|
|
|
- "@param maxbots Look for any game servers with this number of AI controlled players or fewer. Set to 0 for no limit.\n"
|
|
|
- "@param regionmask Look for any master servers, on our master server list, in this region. Set to 0 to examine all regions.\n"
|
|
|
- "@param maxping Look for any game servers with a PING rate equal to or lower than this. Set to 0 for no upper PING limit.\n"
|
|
|
- "@param mincpu Look for any game servers with a CPU (clock speed) equal or greater than this. Set to 0 for no CPU (clock speed) limit.\n"
|
|
|
- "@param filterflags Look for any game servers with this game version number or higher. Set to 0 to find all versions.\n"
|
|
|
- "@return No return value.\n"
|
|
|
- "@sa getServerCount, queryLANServers, setServerInfo, startHeartbeat, stopServerQuery")
|
|
|
-{
|
|
|
- U8 flags = dAtoi(argv[1]);
|
|
|
-
|
|
|
- // It's not a good idea to hold onto args, recursive calls to
|
|
|
- // console exec will trash them.
|
|
|
- char* gameType = dStrdup(argv[2]);
|
|
|
- char* missionType = dStrdup(argv[3]);
|
|
|
-
|
|
|
- U8 minPlayers = dAtoi(argv[4]);
|
|
|
- U8 maxPlayers = dAtoi(argv[5]);
|
|
|
- U8 maxBots = dAtoi(argv[6]);
|
|
|
- U32 regionMask = dAtoi(argv[7]);
|
|
|
- U32 maxPing = dAtoi(argv[8]);
|
|
|
- U16 minCPU = dAtoi(argv[9]);
|
|
|
- U8 filterFlags = dAtoi(argv[10]);
|
|
|
- U32 buddyList = 0;
|
|
|
-
|
|
|
- queryMasterServer(flags,gameType,missionType,minPlayers,maxPlayers,
|
|
|
- maxBots,regionMask,maxPing,minCPU,filterFlags,0,&buddyList);
|
|
|
-
|
|
|
- dFree(gameType);
|
|
|
- dFree(missionType);
|
|
|
-}
|
|
|
-
|
|
|
-//-----------------------------------------------------------------------------
|
|
|
-
|
|
|
-ConsoleFunction( querySingleServer, void, 3, 3, "( address [ , flags ] ) Use the querySingleServer function to re-query a previously queried lan server, OR a game server found with queryLANServers or with queryMasterServer and selected with setServerInfo. This will refresh the information stored by TGE about this server. It will not however modify the values of the $ServerInfo::* global variables.\n"
|
|
|
- "@param address The IP address and Port to re-query, i.e. \"192.168.123.2:28000\".\n"
|
|
|
- "@param flags No longer used.\n"
|
|
|
- "@return No return value.\n"
|
|
|
- "@sa getServerCount, queryLANServers, queryMasterServer, setServerInfo, stopServerQuery")
|
|
|
-{
|
|
|
- NetAddress addr;
|
|
|
- char* addrText;
|
|
|
-
|
|
|
- addrText = dStrdup(argv[1]);
|
|
|
- U8 flags = dAtoi(argv[2]);
|
|
|
-
|
|
|
-
|
|
|
- Net::stringToAddress( addrText, &addr );
|
|
|
- querySingleServer(&addr,flags);
|
|
|
-}
|
|
|
-
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
void queryFavoriteServers( U8 /*flags*/ )
|
|
@@ -647,13 +551,6 @@ void cancelServerQuery()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-ConsoleFunction( cancelServerQuery, void, 1, 1, "() Use the cancelServerQuery function to cancel a previous query*() call.\n"
|
|
|
- "@return No return value.\n"
|
|
|
- "@sa queryLANServers, queryMasterServer, querySingleServer")
|
|
|
-{
|
|
|
- cancelServerQuery();
|
|
|
-}
|
|
|
-
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
void stopServerQuery()
|
|
@@ -677,19 +574,7 @@ void stopServerQuery()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-ConsoleFunction( stopServerQuery, void, 1, 1, "() Use the stopServerQuery function to cancel any outstanding server queries.\n"
|
|
|
- "@return No return value.\n"
|
|
|
- "@sa queryLANServers, queryMasterServer, querySingleServer")
|
|
|
-{
|
|
|
- stopServerQuery();
|
|
|
-}
|
|
|
-
|
|
|
-//-----------------------------------------------------------------------------
|
|
|
-
|
|
|
-ConsoleFunction(startHeartbeat, void, 1, 1, "() Use the startHeartbeat function to start advertising this game serer to any master servers on the master server list.\n"
|
|
|
- "In order for this function to do anything, a list of master servers must have been previously specified. This list may contain one or more server addresses. Once this function is called, the game server will re-advertise itself to all the master servers on its master server lits every two minutes. To specify a list, simply create a set of array entries like this:\n$pref::Master[0] = \"2:192.168.123.15:28002\";\n$pref::Master[1] = \"2:192.168.123.2:28002\";\nThe format of these values is ==> Region Number : IP Address : Port Number\nThese values should be specified in either the client's or the server's preferences file (prefs.cs). You may specifiy it elsewhere, however be sure that it is specified prior to this function being called and before any other functions that rely on it.\n"
|
|
|
- "@return No return value.\n"
|
|
|
- "@sa queryMasterServer, stopHeartbeat")
|
|
|
+void startHeartbeat()
|
|
|
{
|
|
|
if (validateAuthenticatedServer())
|
|
|
{
|
|
@@ -698,60 +583,11 @@ ConsoleFunction(startHeartbeat, void, 1, 1, "() Use the startHeartbeat function
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-ConsoleFunction(stopHeartbeat, void, 1, 1, "() Use the startHeartbeat function to stop advertising this game serer to any master servers on the master server list.\n"
|
|
|
- "@return No return value.\n"
|
|
|
- "@sa queryMasterServer, startHeartbeat")
|
|
|
+void stopHeartBeat()
|
|
|
{
|
|
|
gHeartbeatSeq++;
|
|
|
}
|
|
|
|
|
|
-//-----------------------------------------------------------------------------
|
|
|
-
|
|
|
-ConsoleFunction( getServerCount, int, 1, 1, "() Use the getServerCount function to determine the number of game servers found on the last queryLANServers() or queryMasterServer() call.\n"
|
|
|
- "This value is important because it allows us to properly index when calling setServerInfo().\n"
|
|
|
- "@return Returns a numeric value equal to the number of game servers found on the last queryLANServers() or queryMasterServer() call. Returns 0 if the function was not called, or none were found.\n"
|
|
|
- "@sa queryLANServers, queryMasterServer, setServerInfo")
|
|
|
-{
|
|
|
- return gServerList.size();
|
|
|
-}
|
|
|
-
|
|
|
-ConsoleFunction( setServerInfo, bool, 2, 2, "( index ) Use the setServerInfo function to set the values of the $ServerInfo::* global variables with information for a server found with queryLANServers or with queryMasterServer.\n"
|
|
|
- "@param index The index of the server to get information about.\n"
|
|
|
- "@return Will return true if the information was successfully set, false otherwise.\n"
|
|
|
- "@sa getServerCount, queryLANServers, queryMasterServer, querySingleServer")
|
|
|
-{
|
|
|
- S32 index = dAtoi(argv[1]);
|
|
|
-
|
|
|
- if (index >= 0 && index < gServerList.size())
|
|
|
- {
|
|
|
- ServerInfo& info = gServerList[index];
|
|
|
-
|
|
|
- char addrString[256];
|
|
|
- Net::addressToString( &info.address, addrString );
|
|
|
-
|
|
|
- Con::setIntVariable("ServerInfo::Status",info.status);
|
|
|
- Con::setVariable("ServerInfo::Address",addrString);
|
|
|
- Con::setVariable("ServerInfo::Name",info.name);
|
|
|
- Con::setVariable("ServerInfo::GameType",info.gameType);
|
|
|
- Con::setVariable("ServerInfo::MissionName",info.missionName);
|
|
|
- Con::setVariable("ServerInfo::MissionType",info.missionType);
|
|
|
- Con::setVariable("ServerInfo::State",info.statusString);
|
|
|
- Con::setVariable("ServerInfo::Info",info.infoString);
|
|
|
- Con::setIntVariable("ServerInfo::PlayerCount",info.numPlayers);
|
|
|
- Con::setIntVariable("ServerInfo::MaxPlayers",info.maxPlayers);
|
|
|
- Con::setIntVariable("ServerInfo::BotCount",info.numBots);
|
|
|
- Con::setIntVariable("ServerInfo::Version",info.version);
|
|
|
- Con::setIntVariable("ServerInfo::Ping",info.ping);
|
|
|
- Con::setIntVariable("ServerInfo::CPUSpeed",info.cpuSpeed);
|
|
|
- Con::setBoolVariable("ServerInfo::Favorite",info.isFavorite);
|
|
|
- Con::setBoolVariable("ServerInfo::Dedicated",info.isDedicated());
|
|
|
- Con::setBoolVariable("ServerInfo::Password",info.isPassworded());
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
//-----------------------------------------------------------------------------
|
|
|
// Internal
|
|
|
//-----------------------------------------------------------------------------
|
|
@@ -2096,6 +1932,3 @@ void DemoNetInterface::handleInfoPacket( const NetAddress* address, U8 packetTyp
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-ConsoleFunctionGroupEnd( ServerQuery );
|