// Tribes 2 Unofficial Master List for TribesNext // https://www.tribesnext.com/ // Written by Krash // Copyright 2008 by Krash and the Tribes 2 Community System Reengineering Intitiative //================================================================ if ($Host::TN::beat $= "") $Host::TN::beat = 5; // Time between heartbeats in minutes. if ($Host::TN::echo $= "") $Host::TN::echo = true; // Echo server notices to the console. if ($Host::TN::master $= "") $Host::TN::master = "master.tribesnext.com:80"; //================================================================ function Master::queryMasterGameTypes(%this) { %this.mode = 0; %this.get($Host::TN::master, "/listtypes"); } function Master::queryMasterServer(%this, %port, %flags, %mod, %mapType, %minPlayers, %maxPlayers, %maxBots, %regionMask, %maxPing, %minCpu, %filtFlags, %buddy) { %path = "/list64"; if (%flags !$= "") %path = %path @ "/" @ %mod @ "/" @ %mapType @ "/" @ %minPlayers @ "/" @ %maxPlayers @ "/" @ %maxBots @ "/" @ %filtFlags SPC %buddy; %this.mode = 1; %this.get($Host::TN::master, %path); } function Master::sendHeartbeat(%this) { if (isEventPending(%this.beat)) cancel(%this.beat); %path = "/add/" @ $Host::Port; if ($Host::BindAddress !$= "") %path = %path @ "/" @ $Host::BindAddress; %this.mode = 2; %this.get($Host::TN::master, %path); if ($Host::TN::echo) echo("-- Sent heartbeat to TN Master. (" @ $Host::TN::master @ ")"); if ($Host::TN::beat) %this.beat = %this.schedule($Host::TN::beat * 60000, "sendHeartbeat"); } function Master::get(%this, %server, %query) { %this.primed = false; %this.query = "GET" SPC %query SPC "HTTP/1.0\r\nHost:" SPC %server @ "\r\nUser-Agent: Tribes 2\r\nConnection: close\r\n\r\n"; %this.connect(%server); } function Master::onConnected(%this) { if (%this.query !$= "") { if ($Host::TN::debug) echo(%this.query); %this.send(%this.query); } } function Master::onConnectFailed(%this) { if ($Host::TN::echo) error("-- Could not connect to master server."); %this.disconnect(); } function Master::onDNSFailed(%this) { if ($Host::TN::echo) error("-- DNS lookup failed for:" SPC $Host::TN::master); %this.disconnect(); } function Master::onDisconnect(%this) { if (%this.mode $= "1" && GMJ_Browser.rowCount() == 0) updateServerBrowserStatus("No servers found.", 0); %this.disconnect(); } function Master::onLine(%this, %line) { if ($Host::TN::debug) echo(%line); if (firstWord(%line) $= "Address:") { if ($IPv4::InetAddress $= "" || $Host::TN::resetIPv4) { %address = trim(restWords(%line)); $IPv4::InetAddress = %address; } } if (trim(%line) $= "" && !%this.primed) { %this.primed = true; return; } if (!%this.primed) return; switch (%this.mode) { case 0: // gametype filters if (getWordCount(%line) >= 2) { switch (getSubStr(%line, 0, 1)) { case 0: addGameType(restWords(%line)); case 1: addMissionType(restWords(%line)); } } case 1: // server listings %server = Base64_decode(%line); if (strpos(%server, ":") != -1 && strstr(%server, ".") != -1) querySingleServer(%server); case 2: // heartbeat responses if ($Host::TN::echo) { switch (getSubStr(%line, 0, 1)) { case 0: echo(" - Server added to list."); case 1: error(" - Your server could not be contacted."); error(" - Check your IP / port configuration."); case 2: echo(" - Heartbeat confirmed."); default: error(" - Invalid response from master."); } } %this.primed = false; } } //================================================================ package t2csri_list { function OptionsDlg::onWake(%this) { parent::onWake(%this); OP_ForceFeedbackTgl.setVisible(0); for (%i = OP_GamePane.getCount(); %i > 0; %i--) { %obj = OP_GamePane.getObject(%i); if (%obj.text $= "IGNORE REPAIR MESSAGES") { %obj.position = OP_ForceFeedbackTgl.position; break; } } } function LaunchToolbarMenu::add(%this, %id, %text) { parent::add(%this, %id, %text); if (%text $= "BROWSER") { LaunchToolbarMenu.add(1, "TRAINING"); } } function OpenLaunchTabs(%gotoWarriorSetup) { parent::OpenLaunchTabs(%gotoWarriorSetup); if (!TrainingGui.added) { LaunchTabView.addLaunchTab("TRAINING", TrainingGui); TrainingGui.added = true; } } function JoinSelectedGame() { if (($IPv4::InetAddress $= "" || strstr($IPv4::InetAddress, ".") == -1)) { messageBoxOK("IP ERROR", "Your external address has not been set or is set incorrectly. \n\nAttempting to reset..."); ipv4_getInetAddress(); return; } parent::JoinSelectedGame(); } function ClientReceivedDataBlock(%index, %total) { DB_LoadingProgress.setValue(%index / %total); parent::ClientReceivedDataBlock(%index, %total); } function CreateServer(%mission, %missionType) { parent::CreateServer(%mission, %missionType); if (!isActivePackage(t2csri_server)) exec("t2csri/serverGlue.cs"); } function StartHeartbeat() { Master.sendHeartbeat(); } function StopHeartbeat() { if (isObject(Master) && isEventPending(Master.beat)) { cancel(Master.beat); if ($Host::TN::echo) echo("-- Stopping new heartbeats."); } } function queryMasterGameTypes() { clearGameTypes(); clearMissionTypes(); Master.queryMasterGameTypes(); } function queryMasterServer(%port, %flags, %mod, %mapType, %minPlayers, %maxPlayers, %maxBots, %regionMask, %maxPing, %minCpu, %filtFlags, %buddy) { queryLANServers(28000); Master.queryMasterServer(%port, %flags, %mod, %mapType, %minPlayers, %maxPlayers, %maxBots, %regionMask, %maxPing, %minCpu, %filtFlags, %buddy); } }; //================================================================ if ($PlayingOnline && !isActivePackage(t2csri_list)) { activatepackage(t2csri_list); new TCPObject( Master ){}; }