workshop fix 37
This commit is contained in:
parent
8ab665ce3c
commit
b585aec260
8 changed files with 162 additions and 16 deletions
|
|
@ -28,6 +28,7 @@ require_once("modules/config_games/server_config_parser.php");
|
|||
|
||||
require_once("includes/refreshed.php");
|
||||
require_once('includes/lib_remote.php');
|
||||
require_once("modules/steam_workshop/functions.php");
|
||||
|
||||
if (!defined('GSP_WEBSITE_DOCS_BASE_URL')) {
|
||||
define('GSP_WEBSITE_DOCS_BASE_URL', 'https://gameservers.world/docs/');
|
||||
|
|
@ -488,6 +489,13 @@ echo "<table id='servermonitor' class='tablesorter' data-sortlist='[[0,0],[3,1]]
|
|||
$agent_state = isset($agent_status['status']) ? strtoupper($agent_status['status']) : "UNKNOWN";
|
||||
$screen_running = is_agent_status_active($agent_status);
|
||||
$update_in_progress = $remote->is_screen_running(OGP_SCREEN_TYPE_UPDATE,$server_home['home_id']) === 1;
|
||||
if($update_in_progress)
|
||||
{
|
||||
$workshop_log_txt = "";
|
||||
$workshop_log_state = $remote->get_log(OGP_SCREEN_TYPE_UPDATE, $server_home['home_id'], clean_path($server_home['home_path']), $workshop_log_txt, 25);
|
||||
if($workshop_log_state == 1 && steam_workshop_log_is_terminal($workshop_log_txt))
|
||||
$update_in_progress = false;
|
||||
}
|
||||
if($screen_running)
|
||||
{
|
||||
// Check if the screen running the server is running.
|
||||
|
|
|
|||
|
|
@ -564,8 +564,10 @@ function get_installed_mods($home_cfg, $remote, $xml)
|
|||
|
||||
if(!steam_workshop_has_config_file_path($filepath))
|
||||
{
|
||||
$retval = $remote->get_workshop_mods_info($mod_info_array);
|
||||
return $retval == "1" && !empty($mod_info_array) ? $mod_info_array : False;
|
||||
$retval = $remote->get_workshop_mods_info($mod_info_array, $home_cfg['home_id']);
|
||||
if($retval != "1")
|
||||
$retval = $remote->get_workshop_mods_info($mod_info_array);
|
||||
return $retval == "1" && !empty($mod_info_array) ? steam_workshop_normalize_installed_mod_records($mod_info_array, $home_cfg, $xml) : False;
|
||||
}
|
||||
|
||||
if($remote->rfile_exists($full_filepath) === 0)
|
||||
|
|
@ -580,7 +582,9 @@ function get_installed_mods($home_cfg, $remote, $xml)
|
|||
$current_mods_string = trim($matches[$mods_backreference_index]);
|
||||
if($current_mods_string != '')
|
||||
{
|
||||
$retval = $remote->get_workshop_mods_info($mod_info_array);
|
||||
$retval = $remote->get_workshop_mods_info($mod_info_array, $home_cfg['home_id']);
|
||||
if($retval != "1")
|
||||
$retval = $remote->get_workshop_mods_info($mod_info_array);
|
||||
$current = explode($string_separator, $current_mods_string);
|
||||
$installed_mods = array();
|
||||
foreach($current as $c)
|
||||
|
|
@ -588,10 +592,10 @@ function get_installed_mods($home_cfg, $remote, $xml)
|
|||
if($c != "")
|
||||
{
|
||||
$mod_string = trim($c);
|
||||
if($retval == "1")
|
||||
$installed_mods["$mod_string"] = isset($mod_info_array["$mod_string"])?$mod_info_array["$mod_string"]:$mod_string;
|
||||
if($retval == "1" && isset($mod_info_array["$mod_string"]))
|
||||
$installed_mods["$mod_string"] = is_array($mod_info_array["$mod_string"]) ? $mod_info_array["$mod_string"] : steam_workshop_installed_record_from_title($mod_string, $mod_info_array["$mod_string"], $home_cfg, $xml);
|
||||
else
|
||||
$installed_mods["$mod_string"] = $mod_string;
|
||||
$installed_mods["$mod_string"] = steam_workshop_installed_record_from_title($mod_string, $mod_string, $home_cfg, $xml);
|
||||
}
|
||||
}
|
||||
return $installed_mods;
|
||||
|
|
@ -603,6 +607,74 @@ function get_installed_mods($home_cfg, $remote, $xml)
|
|||
return False;
|
||||
}
|
||||
|
||||
function steam_workshop_installed_record_from_title($mod_string, $title, $home_cfg, $xml)
|
||||
{
|
||||
$mods_full_path = clean_path($home_cfg['home_path'].'/'.$xml->mods_path);
|
||||
$installed_folder = $mod_string;
|
||||
if(strpos($mod_string, '@') !== 0 && preg_match('/^\d+$/', $mod_string))
|
||||
$installed_folder = '@'.$mod_string;
|
||||
return array(
|
||||
'mod_string' => (string)$mod_string,
|
||||
'workshop_mod_id' => preg_match('/^\d+$/', (string)$mod_string) ? (string)$mod_string : '',
|
||||
'title' => (string)$title,
|
||||
'installed_folder' => $installed_folder,
|
||||
'installed_path' => clean_path($mods_full_path.'/'.$installed_folder),
|
||||
'workshop_app_id' => (string)$xml->workshop_id,
|
||||
'install_status' => 'installed',
|
||||
'install_time' => '',
|
||||
'last_update_time' => '',
|
||||
);
|
||||
}
|
||||
|
||||
function steam_workshop_normalize_installed_mod_records($mods, $home_cfg, $xml)
|
||||
{
|
||||
$records = array();
|
||||
foreach((array)$mods as $mod_string => $record)
|
||||
{
|
||||
if(is_array($record))
|
||||
{
|
||||
if(!isset($record['mod_string']) || $record['mod_string'] === '')
|
||||
$record['mod_string'] = $mod_string;
|
||||
$records[$record['mod_string']] = $record;
|
||||
}
|
||||
else
|
||||
{
|
||||
$records[$mod_string] = steam_workshop_installed_record_from_title($mod_string, $record, $home_cfg, $xml);
|
||||
}
|
||||
}
|
||||
return $records;
|
||||
}
|
||||
|
||||
function steam_workshop_build_mod_line($mods, $xml)
|
||||
{
|
||||
$parts = array();
|
||||
foreach((array)$mods as $record)
|
||||
{
|
||||
if(is_array($record))
|
||||
{
|
||||
$value = isset($record['installed_folder']) && $record['installed_folder'] !== '' ? $record['installed_folder'] : $record['mod_string'];
|
||||
$parts[] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$parts[] = $record;
|
||||
}
|
||||
}
|
||||
$separator = isset($xml->config->string_separator) && (string)$xml->config->string_separator !== '' ? stripcslashes($xml->config->string_separator) : ';';
|
||||
$mod_list = implode($separator, array_filter($parts));
|
||||
$format = isset($xml->config->variable) ? (string)$xml->config->variable : '';
|
||||
if($format !== '' && strpos($format, '{MOD_LIST}') !== false)
|
||||
return str_replace('{MOD_LIST}', $mod_list, $format);
|
||||
if($format !== '' && preg_match('/^-/', $format))
|
||||
return $format.$mod_list;
|
||||
return $mod_list;
|
||||
}
|
||||
|
||||
function steam_workshop_log_is_terminal($log_txt)
|
||||
{
|
||||
return preg_match('/GSP_WORKSHOP_INSTALL_(COMPLETE|FAILED)/', (string)$log_txt) === 1;
|
||||
}
|
||||
|
||||
function remove_mod($home_cfg, $remote, $xml, $mod_string)
|
||||
{
|
||||
$config = $xml->config;
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ function exec_ogp_module()
|
|||
if(isset($_GET['show_log']))
|
||||
{
|
||||
$update_active = $remote->get_log(OGP_SCREEN_TYPE_UPDATE,$home_id,clean_path($home_cfg['home_path']),$log_txt);
|
||||
if ( $update_active == 1 )
|
||||
if ( $update_active == 1 && !steam_workshop_log_is_terminal($log_txt) )
|
||||
{
|
||||
if(isset($_POST['sgc']))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -145,13 +145,44 @@ function exec_ogp_module()
|
|||
|
||||
if($mods and count($mods) > 0)
|
||||
{
|
||||
$mod_line = steam_workshop_build_mod_line($mods, $xml);
|
||||
$ft = new FormTable();
|
||||
$ft->start_form("?m=steam_workshop&p=uninstall&home_id-mod_id-ip-port=".$_GET['home_id-mod_id-ip-port'], "post", "autocomplete=\"off\"");
|
||||
$ft->start_table();
|
||||
echo '<tr><td><div id="uninstall_scrolling_checkbox">';
|
||||
foreach($mods as $mod_id => $mod_name)
|
||||
echo "<input type='checkbox' id='select_mod_$mod_id' name='mod_string[]' value='$mod_id'><label for='select_mod_$mod_id'>$mod_name</label><br>";
|
||||
echo '</div></td></tr>';
|
||||
echo "<tr><td colspan='2'><strong>".get_lang('workshop_mod_line')."</strong><br>".
|
||||
"<textarea readonly style='width:100%;min-height:70px;box-sizing:border-box;font-family:monospace;'>".steam_workshop_h($mod_line)."</textarea></td></tr>";
|
||||
echo '<tr><td colspan="2"><div id="uninstall_scrolling_checkbox">';
|
||||
echo "<table class='center' style='width:100%;'><tr><th></th><th>".get_lang('workshop_mod_title')."</th><th>".get_lang('workshop_id')."</th><th>".get_lang('installed_folder')."</th><th>".get_lang('install_status')."</th><th>".get_lang('install_time')."</th></tr>";
|
||||
foreach($mods as $mod_id => $mod_record)
|
||||
{
|
||||
if(is_array($mod_record))
|
||||
{
|
||||
$title = isset($mod_record['title']) && $mod_record['title'] !== '' ? $mod_record['title'] : $mod_record['mod_string'];
|
||||
$workshop_mod_id = isset($mod_record['workshop_mod_id']) ? $mod_record['workshop_mod_id'] : '';
|
||||
$installed_folder = isset($mod_record['installed_folder']) ? $mod_record['installed_folder'] : '';
|
||||
$installed_path = isset($mod_record['installed_path']) ? $mod_record['installed_path'] : '';
|
||||
$install_status = isset($mod_record['install_status']) ? $mod_record['install_status'] : '';
|
||||
$install_time = isset($mod_record['install_time']) ? $mod_record['install_time'] : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = $mod_record;
|
||||
$workshop_mod_id = preg_match('/^\d+$/', (string)$mod_id) ? $mod_id : '';
|
||||
$installed_folder = $mod_id;
|
||||
$installed_path = '';
|
||||
$install_status = 'installed';
|
||||
$install_time = '';
|
||||
}
|
||||
echo "<tr>".
|
||||
"<td><input type='checkbox' id='select_mod_".steam_workshop_h($mod_id)."' name='mod_string[]' value='".steam_workshop_h($mod_id)."'></td>".
|
||||
"<td><label for='select_mod_".steam_workshop_h($mod_id)."'>".steam_workshop_h($title)."</label></td>".
|
||||
"<td>".steam_workshop_h($workshop_mod_id)."</td>".
|
||||
"<td title='".steam_workshop_h($installed_path)."'>".steam_workshop_h($installed_folder)."</td>".
|
||||
"<td>".steam_workshop_h($install_status)."</td>".
|
||||
"<td>".steam_workshop_h($install_time)."</td>".
|
||||
"</tr>";
|
||||
}
|
||||
echo '</table></div></td></tr>';
|
||||
$ft->end_table();
|
||||
$ft->add_button("submit", "uninstall", get_lang('uninstall_mods'));
|
||||
$ft->end_form();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue