Просмотр исходного кода

Adds Auto-Update Functionality.

Fulfilling the request
[here](http://www.opengamepanel.org/forum/viewthread.php?thread_id=5250)
- this adds the ability to do auto updates, get the latest buildid, and
get a game's current build id.

Tested with TF2, Ark, and GMOD.
Adjokip 9 лет назад
Родитель
Сommit
ff2d0b8e29
1 измененных файлов с 56 добавлено и 1 удалено
  1. 56 1
      includes/lib_remote.php

+ 56 - 1
includes/lib_remote.php

@@ -167,6 +167,8 @@ class OGPRemoteLibrary
 		if ( $response === NULL )
 			return 0;
 
+		if ( $response == -10 )
+			return 'Agent Returned: -10. Home not found.';
 		@list($retval,$data_tmp) = @explode(";",$response);
 
 		// We get log only with positive values.
@@ -340,6 +342,59 @@ class OGPRemoteLibrary
 		else
 			return -1;
 	}
+
+	// Returns the latest buildid for $appId
+	public function fetch_steam_version($appId, $pureOutput = 0)
+	{
+		$params = $this->encrypt_params($appId, $pureOutput);
+		$this->add_enc_chk($params);
+
+		$request = xmlrpc_encode_request("fetch_steam_version", $params);
+		$response = $this->sendRequest($request);
+
+		return $response;
+	}
+
+	// Returns -10 if the steamapps/appmanifest file doesn't exist.
+	// Returns the version installed otherwise.
+	public function installed_steam_version($game_home, $mod, $pureOutput = 0)
+	{
+		$params = $this->encrypt_params($game_home, $mod, $pureOutput);
+		$this->add_enc_chk($params);
+
+		$request = xmlrpc_encode_request("installed_steam_version", $params);
+		$response = $this->sendRequest($request);
+
+		return $response;
+	}
+
+	// If server is running, stops it. Starts an update. And if the server was running, starts the server upon finishing the update.
+	// Returns -10 if an update is currently in place.
+	// Returns -9 if the server failed to stop.
+	// Returns -8 if the update failed to start.
+	// Returns -7 if the server failed to start.
+	// Returns 1 on success. (updated, started)
+	// Returns 2 if the update was successful, but the server wasn't originally running. So wasn't started.
+
+	// Requires agent timeout to be set to a high value - otherwise return value will be null.
+	public function automatic_steam_update(
+						$home_id, $home_path, $server_ip, $server_port, $exec_path, $exec_folder_path,
+						$control_protocol, $control_password, $control_type,
+						$appId, $modname, $betaname, $betapwd, $user, $pass, $guard, $precmd, $postcmd, $cfg_os, $filesToLockUnlock,
+						$startup_cmd, $cpu, $nice, $preStart, $envVars
+	)
+	{
+		$params = $this->encrypt_params($home_id, $home_path, $server_ip, $server_port, $exec_path, $exec_folder_path,
+						$control_protocol, $control_password, $control_type,
+						$appId, $modname, $betaname, $betapwd, $user, $pass, $guard, $precmd, $postcmd, $cfg_os, $filesToLockUnlock,
+						$startup_cmd, $cpu, $nice, $preStart, $envVars);
+
+		$this->add_enc_chk($params);
+		$request = xmlrpc_encode_request("automatic_steam_update", $params);
+		$response = $this->sendRequest($request);
+
+		return $response;
+	}
 	
 	/// Updates the mod located in the game home with master server.
 	/// \return 1 If update started successfully
@@ -1050,4 +1105,4 @@ class OGPRemoteLibrary
 		return base64_decode($response);
 	}
 }
-?>
+?>