This commit is contained in:
Frank Harris 2026-01-18 17:11:20 -06:00
parent 74fbe0773a
commit 4baa43bcbf
2 changed files with 16 additions and 50 deletions

View file

@ -3,3 +3,6 @@
## 2026-01-17 ## 2026-01-17
- Added per-game Steam Workshop adapter management with CRUD UI and automatic mapping helpers. - Added per-game Steam Workshop adapter management with CRUD UI and automatic mapping helpers.
- Added workshop capability helpers and monitor button gating so only supported SteamCMD homes expose the Steam Workshop shortcut. - Added workshop capability helpers and monitor button gating so only supported SteamCMD homes expose the Steam Workshop shortcut.
## 2026-01-18
- Reworked Steam Workshop support detection to read installer AppIDs directly from the canonical game XMLs, ensuring admin mappings and Game Monitor buttons only appear for true Workshop-enabled titles.

View file

@ -11,8 +11,7 @@ class SteamWorkshopService
private string $adapterDir; private string $adapterDir;
private string $adapterMapFile; private string $adapterMapFile;
private string $gameAdapterDir; private string $gameAdapterDir;
private string $workshopConfigDir; private string $serverConfigDir;
private ?array $workshopAppIds = null;
public function __construct(OGPDatabase $db) public function __construct(OGPDatabase $db)
{ {
@ -21,7 +20,9 @@ class SteamWorkshopService
$this->adapterDir = __DIR__ . '/GameAdapters'; $this->adapterDir = __DIR__ . '/GameAdapters';
$this->adapterMapFile = __DIR__ . '/../data/game_adapter_map.json'; $this->adapterMapFile = __DIR__ . '/../data/game_adapter_map.json';
$this->gameAdapterDir = __DIR__ . '/../data/game_adapters'; $this->gameAdapterDir = __DIR__ . '/../data/game_adapters';
$this->workshopConfigDir = __DIR__ . '/../game_configs'; $this->serverConfigDir = defined('SERVER_CONFIG_LOCATION')
? SERVER_CONFIG_LOCATION
: __DIR__ . '/../../config_games/server_configs';
if (!is_dir($this->configDir)) { if (!is_dir($this->configDir)) {
mkdir($this->configDir, 0775, true); mkdir($this->configDir, 0775, true);
@ -502,20 +503,23 @@ class SteamWorkshopService
public function listWorkshopGameGroups(): array public function listWorkshopGameGroups(): array
{ {
$configDir = defined('SERVER_CONFIG_LOCATION') ? SERVER_CONFIG_LOCATION : __DIR__ . '/../../config_games/server_configs'; $configDir = $this->serverConfigDir;
$groups = []; if (!is_dir($configDir)) {
$supportedAppIds = $this->getWorkshopConfigAppIds();
if (empty($supportedAppIds)) {
return []; return [];
} }
$supportedLookup = array_flip($supportedAppIds);
$groups = [];
foreach (glob($configDir . '/*.xml') as $file) { foreach (glob($configDir . '/*.xml') as $file) {
$xml = @simplexml_load_file($file); $xml = @simplexml_load_file($file);
if ($xml === false) { if ($xml === false) {
continue; continue;
} }
$installer = isset($xml->installer) ? trim((string)$xml->installer) : '';
if ($installer !== 'steamcmd') {
continue;
}
$gameKey = isset($xml->game_key) ? trim((string)$xml->game_key) : ''; $gameKey = isset($xml->game_key) ? trim((string)$xml->game_key) : '';
if ($gameKey === '') { if ($gameKey === '') {
continue; continue;
@ -526,10 +530,6 @@ class SteamWorkshopService
continue; continue;
} }
if (!isset($supportedLookup[$appId])) {
continue;
}
$groupKey = $this->buildWorkshopGroupKey($appId); $groupKey = $this->buildWorkshopGroupKey($appId);
if (!isset($groups[$groupKey])) { if (!isset($groups[$groupKey])) {
$gameName = isset($xml->game_name) ? trim((string)$xml->game_name) : ''; $gameName = isset($xml->game_name) ? trim((string)$xml->game_name) : '';
@ -747,11 +747,7 @@ class SteamWorkshopService
} }
$appId = $this->parseSteamAppIdFromConfig($serverXml); $appId = $this->parseSteamAppIdFromConfig($serverXml);
if ($appId === null) { return $appId !== null;
return false;
}
return in_array($appId, $this->getWorkshopConfigAppIds(), true);
} }
private function parseSteamAppIdFromConfig($xml): ?string private function parseSteamAppIdFromConfig($xml): ?string
@ -782,39 +778,6 @@ class SteamWorkshopService
return $candidate; return $candidate;
} }
private function getWorkshopConfigAppIds(): array
{
if ($this->workshopAppIds !== null) {
return $this->workshopAppIds;
}
$dir = $this->workshopConfigDir;
if (!is_dir($dir)) {
$this->workshopAppIds = [];
return $this->workshopAppIds;
}
$appIds = [];
foreach (glob($dir . '/*.xml') as $file) {
$xml = @simplexml_load_file($file);
if ($xml === false) {
continue;
}
$appId = preg_replace('/[^0-9]/', '', (string)($xml->workshop_id ?? ''));
if ($appId === '') {
continue;
}
$appIds[$appId] = true;
}
$this->workshopAppIds = array_keys($appIds);
sort($this->workshopAppIds);
return $this->workshopAppIds;
}
private function buildWorkshopGroupKey(string $appId): string private function buildWorkshopGroupKey(string $appId): string
{ {
return 'steamapp_' . $appId; return 'steamapp_' . $appId;