//================================================================================
// MMServerQuery.       (C)opyright - originally by [A]Nobody
//			[Adapted by ~MainMan~ with permission from the above.]
//================================================================================
//class MMServerQuery extends UdpServerQuery;
//Now:
class MMServerQuery extends NptServerQuery;


// Return a string of important system information.
function bool NptSendInfo( int NumPlayers )
{
	local int idx;
	local bool bResult;

	bResult = true;

	// The server name, i.e.: Bob's Server
	if ( bReplaceBackslashes )	bResult = bResult && NptSendPart( "\\hostname\\" $ StrReplace(Level.Game.GameReplicationInfo.ServerName, "\\", "/") );
	else						bResult = bResult && NptSendPart( "\\hostname\\" $ Level.Game.GameReplicationInfo.ServerName );

	if ( !(Level.EngineVersion >= EngineVersionDXlo && Level.EngineVersion <= EngineVersionDXhi) ) {
		// The short server name
		if ( bReplaceBackslashes )	bResult = bResult && NptSendPart( "\\shortname\\" $ StrReplace(Level.Game.GameReplicationInfo.ShortName, "\\", "/") );
		else						bResult = bResult && NptSendPart( "\\shortname\\" $ Level.Game.GameReplicationInfo.ShortName );
	}

	// The server port.
	bResult = bResult && NptSendPart( "\\hostport\\" $ Level.Game.GetServerPort() );

	if ( Level.EngineVersion >= EngineVersionDXlo && Level.EngineVersion <= EngineVersionDXhi ) {
		// The map/level name
		if ( bReplaceBackslashes )	bResult = bResult && NptSendPart( "\\maptitle\\" $ StrReplace(Level.Title, "\\", "/") );
		else						bResult = bResult && NptSendPart( "\\maptitle\\" $ Level.Title );

		// Map name
		bResult = bResult && NptSendPart( "\\mapname\\" $ GetMapFileName() );
	}
	else {
		// The map/level name
		if ( Level.Title == "" || Level.Title ~= "Untitled" )	bResult = bResult && NptSendPart( "\\mapname\\" $ GetMapFileName() );
		else if ( bReplaceBackslashes )							bResult = bResult && NptSendPart( "\\mapname\\" $ StrReplace(Level.Title, "\\", "/") );
		else													bResult = bResult && NptSendPart( "\\mapname\\" $ Level.Title );
	}

	// The mod or game type
	if (MainMansCity(level.game) != none)
	{
		bResult = bResult && NptSendPart( "\\gametype\\" $ GetItemName(MainMansCity(Level.Game).OriginalGameType) );
	}
	else
	{
		bResult = bResult && NptSendPart( "\\gametype\\" $ GetItemName(string(Level.Game.Class)) );
	}

	// The number of players
	bResult = bResult && NptSendPart( "\\numplayers\\" $ NumPlayers );

	// The maximum number of players
	bResult = bResult && NptSendPart( "\\maxplayers\\" $ Level.Game.MaxPlayers );

	// The game mode: openplaying
	bResult = bResult && NptSendPart( "\\gamemode\\openplaying" );

	// The version of this game.
	bResult = bResult && NptSendPart( "\\gamever\\" $ Level.EngineVersion );

	// The most recent network compatible version.
	if ( Level.EngineVersion >= EngineVersionDXlo && Level.EngineVersion <= EngineVersionDXhi ) {
		bResult = bResult && NptSendPart( "\\minnetver\\" $ Level.MinNetVersion );
	}
	else {
		bResult = bResult && NptSendPart( "\\mingamever\\" $ Level.MinNetVersion );
	}

	if ( !(Level.EngineVersion >= EngineVersionDXlo && Level.EngineVersion <= EngineVersionDXhi) ) {
		// The file name of the current map.
		bResult = bResult && NptSendPart( "\\mapfilename\\" $ GetMapFileName() );
	}

	// add some more info...
	for ( idx = 0; idx < ArrayCount(AddServerRule) && AddServerRule[idx].Tag != ""; idx++ ) {
		if ( bReplaceBackslashes )	bResult = bResult && NptSendPart( "\\" $ StrReplace(AddServerRule[idx].Tag, "\\", "/") $ "\\" $ StrReplace(AddServerRule[idx].Value, "\\", "/") );
		else						bResult = bResult && NptSendPart( "\\" $ AddServerRule[idx].Tag $ "\\" $ AddServerRule[idx].Value );
	}

	if ( Level.EngineVersion >= EngineVersionDXlo && Level.EngineVersion <= EngineVersionDXhi ) {
		//assert("false" == "needs to be adapted for Deus Ex");
		bResult = bResult && NptSendPart( Level.Game.GetInfo() );
	}

	return bResult;
}

