Author Topic: Connext Argument on the Executable?  (Read 1954 times)

If there an argument that you can run on the EXE of Blockland to connect to a server automatically? Like -connect 55.55.555.555? Im trying to make custom support for Xfire so Blockland can connect to servers.

If there is a code, it would be an engine command, so if you were able to find <master server address, server IP, port> and say for example "<master server address, server IP, port>". I can't give you a straight answer, but try looking around for some Torque Engine tutorials.

main.cs
Code: [Select]
function parseArgs()
{
        for ($i = 1; $i < $Game::argc ; $i++)
        {
           $arg = $Game::argv[$i];
           $nextArg = $Game::argv[$i+1];
           $hasNextArg = $Game::argc - $i > 1;
           $logModeSpecified = false;
           
   //echo("ARG = ", $arg);
   //echo("-hasnextarg = ", %hasNextArg);

           switch$ ($arg)
           {
              ...
              case "-connect":
                 $argUsed[$i]++;
                 if ($hasNextArg)
                 {
                    // mark which server we will automatically connect to
                    setAutoConnect($nextArg);
                    $argUsed[$i+1]++;
                    $i++;
                 }
                 else
                    error("Error: Missing Command Line argument. Usage: -connect <x.x.x.x:port>");
        ...
                 case "-connect":
                    $argUsed[$i]++;
                    if ($hasNextArg) {
                       $JoinGameAddress = $nextArg;
                       $argUsed[$i+1]++;
                       $i++;
                    }
                    else
                       error("Error: Missing Command Line argument. Usage: -connect <ip_address>");
        ...
              case "-serverName":
$argUsed[$i]++;
                    if ($hasNextArg) {
                       $serverNameArg = $nextArg;
                       $serverNameArg = strReplace($serverNameArg, "_", " ");
                       $argUsed[$i+1]++;
                       $i++;
                    }
                    else
                       error("Error: Missing Command Line argument. Usage: -serverName <name>");
        ...
        }
     
         if(!$NoConsole)
            EnableWinConsole(true);
           

         //automatically record journal for debug
         if(!%playingJournal)
            if(getBuildString() $= "Debug")
              saveJournal("auto.jrn");
}   

I don't know why there's two -connect ones but it's likely the first one is more relevant, because it would be found first by switch$.

How did you get that code? From vanilla or what? And also, one says that if you do it wrong, put in the right IP, and the other says put the IP and port.

Damn U missing edit button. What I was gonna say was that I also don't see any code to actually preform the server connection. Only setting variables, unless it's in other code.

main.cs comes with every Torque game, next to the executable. I assume that setAutoConnect is a function linked to the engine, rather than the scripting, attempts to connect to that server as if you'd put it in the Manual Join function as soon as the engine is loaded. I'd use the x.x.x.x:port one, since all Blockland joining (the "sending connect request..." screen) has the port too.

When I try to connect to a server that is online, I get this in my Log and BL starts normally and doesn't connect:
Code: [Select]
Input Init:
   keyboard0 input device created.
   mouse0 input device created.
   DirectInput enabled.

--------- Parsing Arguments ---------
<input> (0): Unable to find function setAutoConnect
--------- Loading Common ---------
Loading compiled script base/main.cs.
Loading compiled script base/client/defaults.cs.
Loading compiled script base/server/defaults.cs.
Executing base/config/client/prefs.cs.
Executing base/config/server/prefs.cs.
--------- Loading MODS ---------
Skipping mod: Add-Ons

Okay, try deleting the first connect one (setAutoConnect) and use just the one with IP instead, $JoinGameAddress. Badspot probably used the standard file but deleted setAutoConnect for some reason.

Now it doesn't parse anything, or at least say anything in the console... I wish Badspot just locked the Authentication code and made everything else open source...

Make the auth checks part of the exe, then really stop you hosting (like AoT deleted all start server bits, BL could Auth Check --> Abort) if it's not validated.

Ok, try this:
Code: [Select]
              case "-connect":
                 $argUsed[$i]++;
                 if ($hasNextArg)
                 {
                    // Try to connect to the server.
                    connect($nextArg);
                    $argUsed[$i+1]++;
                    $i++;
                 }
                 else
                    error("Error: Missing Command Line argument. Usage: -connect <x.x.x.x:port>");

replacing the top -connect one.

Says there is no command "connect." We either need to decompile the game scripts or make our own connect command. Or ask Badspot.

Space. You sure that function is not called before the connect function is created?