mirror of
https://git.techniverse.net/scriptos/tmserver-docker.git
synced 2026-07-09 13:37:03 +00:00
feat: Automatische MatchSettings-Erkennung & AdminServ-Bugfixes
This commit is contained in:
@@ -369,6 +369,34 @@ if [ -f "$CUSTOMPOINTS_FILE" ] && ! grep -q 'defined.*pt_custom' "$CUSTOMPOINTS_
|
||||
echo " CustomPoints-Plugin erfolgreich gepatcht."
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# AdminServ: MatchSettings-Bugfixes fuer bestehende Volumes
|
||||
# ============================================================
|
||||
# 1) get_matchset_mapimport.php: Berechnet den relativen Pfad aus dem
|
||||
# absoluten Dropdown-Pfad statt den URL-Parameter 'd' zu verwenden.
|
||||
# Ohne Fix wird z.B. "MatchSettings/" statt "Challenges/Downloaded/"
|
||||
# als Praefix in die MatchSettings-Datei geschrieben.
|
||||
# 2) maps-creatematchset.php: Ueberspringt GetModeScriptInfo fuer
|
||||
# TmForever (Methode existiert nur in ManiaPlanet/TM2, Fehler -506).
|
||||
# ============================================================
|
||||
ADMINSERV_MAPIMPORT="/var/www/html/resources/ajax/get_matchset_mapimport.php"
|
||||
ADMINSERV_MAPIMPORT_DEFAULT="/opt/tmserver/default-controlpanel/resources/ajax/get_matchset_mapimport.php"
|
||||
if [ -f "$ADMINSERV_MAPIMPORT" ] && ! grep -q 'relativePath' "$ADMINSERV_MAPIMPORT"; then
|
||||
echo "==> Patche AdminServ: MatchSettings Map-Import (Pfad-Fix)..."
|
||||
cp "$ADMINSERV_MAPIMPORT_DEFAULT" "$ADMINSERV_MAPIMPORT"
|
||||
chown www-data:www-data "$ADMINSERV_MAPIMPORT"
|
||||
echo " get_matchset_mapimport.php erfolgreich gepatcht."
|
||||
fi
|
||||
|
||||
ADMINSERV_CREATEMATCHSET="/var/www/html/resources/process/maps-creatematchset.php"
|
||||
ADMINSERV_CREATEMATCHSET_DEFAULT="/opt/tmserver/default-controlpanel/resources/process/maps-creatematchset.php"
|
||||
if [ -f "$ADMINSERV_CREATEMATCHSET" ] && grep -q "query('GetModeScriptInfo')" "$ADMINSERV_CREATEMATCHSET" && ! grep -q "SERVER_VERSION_NAME != 'TmForever'" "$ADMINSERV_CREATEMATCHSET"; then
|
||||
echo "==> Patche AdminServ: GetModeScriptInfo-Fix fuer TmForever..."
|
||||
cp "$ADMINSERV_CREATEMATCHSET_DEFAULT" "$ADMINSERV_CREATEMATCHSET"
|
||||
chown www-data:www-data "$ADMINSERV_CREATEMATCHSET"
|
||||
echo " maps-creatematchset.php erfolgreich gepatcht."
|
||||
fi
|
||||
|
||||
echo "Starting apache server"
|
||||
service apache2 start
|
||||
|
||||
@@ -576,6 +604,50 @@ else
|
||||
echo "==> Kein AdminServ ServerOptions-Verzeichnis gefunden. Ueberspringe Import."
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# MatchSettings: Neueste Datei automatisch ermitteln
|
||||
# ============================================================
|
||||
# Ueber die Umgebungsvariable MATCHSETTINGS_FILE kann gesteuert werden,
|
||||
# welche MatchSettings-Datei beim Serverstart geladen wird:
|
||||
# - "auto" (Standard): Die neueste .txt-Datei im MatchSettings-Ordner
|
||||
# wird automatisch anhand des Aenderungsdatums ermittelt.
|
||||
# - "<dateiname.txt>": Eine bestimmte Datei wird direkt verwendet.
|
||||
# Fallback: custom_game_settings.txt (Standard-MatchSettings aus dem Image).
|
||||
# ============================================================
|
||||
|
||||
MATCHSETTINGS_DIR="$GAMEDATA_DIR/Tracks/MatchSettings"
|
||||
MATCHSETTINGS_FILE_ENV="${MATCHSETTINGS_FILE:-auto}"
|
||||
|
||||
if [ "$MATCHSETTINGS_FILE_ENV" = "auto" ]; then
|
||||
echo "==> MatchSettings: Automatische Erkennung (MATCHSETTINGS_FILE=auto)..."
|
||||
# Neueste .txt-Datei im MatchSettings-Ordner anhand des Aenderungsdatums ermitteln
|
||||
NEWEST_MS=$(ls -t "$MATCHSETTINGS_DIR"/*.txt 2>/dev/null | head -1)
|
||||
if [ -n "$NEWEST_MS" ] && [ -f "$NEWEST_MS" ]; then
|
||||
MS_FILENAME=$(basename "$NEWEST_MS")
|
||||
GAME_SETTINGS_PATH="MatchSettings/${MS_FILENAME}"
|
||||
echo " Neueste MatchSettings gefunden: ${MS_FILENAME}"
|
||||
echo " Aenderungsdatum: $(stat -c '%y' "$NEWEST_MS" 2>/dev/null || ls -la "$NEWEST_MS" | awk '{print $6, $7, $8}')"
|
||||
else
|
||||
GAME_SETTINGS_PATH="MatchSettings/custom_game_settings.txt"
|
||||
echo " Keine .txt-Dateien in ${MATCHSETTINGS_DIR} gefunden."
|
||||
echo " Fallback: ${GAME_SETTINGS_PATH}"
|
||||
fi
|
||||
else
|
||||
# Explizit angegebene Datei verwenden
|
||||
if [ -f "$MATCHSETTINGS_DIR/$MATCHSETTINGS_FILE_ENV" ]; then
|
||||
GAME_SETTINGS_PATH="MatchSettings/${MATCHSETTINGS_FILE_ENV}"
|
||||
echo "==> MatchSettings: Verwende explizit gesetzte Datei: ${MATCHSETTINGS_FILE_ENV}"
|
||||
else
|
||||
echo "==> WARNUNG: Angegebene MatchSettings-Datei nicht gefunden: ${MATCHSETTINGS_FILE_ENV}"
|
||||
echo " Vorhandene Dateien in ${MATCHSETTINGS_DIR}:"
|
||||
ls -la "$MATCHSETTINGS_DIR"/*.txt 2>/dev/null || echo " (keine .txt-Dateien vorhanden)"
|
||||
GAME_SETTINGS_PATH="MatchSettings/custom_game_settings.txt"
|
||||
echo " Fallback: ${GAME_SETTINGS_PATH}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo " Aktive MatchSettings: ${GAME_SETTINGS_PATH}"
|
||||
|
||||
# Bestimme Server-Modus (Standard: internet)
|
||||
SERVER_MODE="${SERVER_MODE:-internet}"
|
||||
|
||||
@@ -595,8 +667,8 @@ fi
|
||||
echo "Server config dedicated_cfg.txt is"
|
||||
cat "$CONFIG"
|
||||
|
||||
echo "Launching Server in ${SERVER_MODE} mode"
|
||||
./TrackmaniaServer /dedicated_cfg=dedicated_cfg.txt /game_settings=MatchSettings/custom_game_settings.txt /nodaemon ${LAUNCH_MODE} &
|
||||
echo "Launching Server in ${SERVER_MODE} mode (MatchSettings: ${GAME_SETTINGS_PATH})"
|
||||
./TrackmaniaServer /dedicated_cfg=dedicated_cfg.txt /game_settings=${GAME_SETTINGS_PATH} /nodaemon ${LAUNCH_MODE} &
|
||||
TM_PID=$!
|
||||
echo "TrackmaniaServer gestartet (PID: ${TM_PID})"
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// INCLUDES
|
||||
session_start();
|
||||
if( !isset($_SESSION['adminserv']['sid']) ){ exit; }
|
||||
$configPath = '../../'.$_SESSION['adminserv']['path'].'config/';
|
||||
require_once $configPath.'adminlevel.cfg.php';
|
||||
require_once $configPath.'adminserv.cfg.php';
|
||||
require_once $configPath.'extension.cfg.php';
|
||||
require_once $configPath.'servers.cfg.php';
|
||||
require_once '../core/adminserv.php';
|
||||
AdminServConfig::$PATH_RESOURCES = '../';
|
||||
AdminServ::getClass();
|
||||
AdminServUI::lang();
|
||||
|
||||
// ISSET
|
||||
if( isset($_GET['path']) ){ $path = addslashes($_GET['path']); }else{ $path = null; }
|
||||
if( isset($_GET['d']) ){ $directory = addslashes($_GET['d']); }else{ $directory = null; }
|
||||
if( isset($_GET['op']) ){ $operation = addslashes($_GET['op']); }else{ $operation = null; }
|
||||
if( isset($_GET['select']) ){ $selection = $_GET['select']; }else{ $selection = null; }
|
||||
|
||||
// DATA
|
||||
$out = null;
|
||||
if( AdminServ::initialize() && $path != null ){
|
||||
// Maps
|
||||
if($path == 'currentServerSelection'){
|
||||
$mapsImport = AdminServ::getMapList();
|
||||
}
|
||||
else{
|
||||
// FIX: Den relativen Pfad aus dem absoluten Pfad (Dropdown-Auswahl)
|
||||
// berechnen, statt den URL-Parameter 'd' (= MatchSettings-Speicherordner)
|
||||
// zu verwenden. Sonst wird z.B. "MatchSettings/" statt "Challenges/Downloaded/"
|
||||
// als Pfad-Praefix in die MatchSettings-Datei geschrieben.
|
||||
$mapsDirectoryPath = AdminServ::getMapsDirectoryPath();
|
||||
$relativePath = str_replace($mapsDirectoryPath, '', Str::toSlash($path));
|
||||
// Sicherstellen, dass der Pfad mit / endet (wenn nicht leer)
|
||||
if($relativePath && substr($relativePath, -1) !== '/'){
|
||||
$relativePath .= '/';
|
||||
}
|
||||
|
||||
$currentDir = Folder::read($path, AdminServConfig::$MATCHSET_HIDDEN_FOLDERS, AdminServConfig::$MATCHSET_EXTENSION, intval(AdminServConfig::RECENT_STATUS_PERIOD * 3600) );
|
||||
$mapsImport = AdminServ::getLocalMapList($currentDir, $relativePath);
|
||||
}
|
||||
|
||||
// Faire une sélection
|
||||
if($operation == 'setSelection'){
|
||||
// On supprime les maps non sélectionnées
|
||||
if( $selection != null && count($selection) > 0 ){
|
||||
foreach($mapsImport['lst'] as $id => $values){
|
||||
if( !in_array($id, $selection) ){
|
||||
unset($mapsImport['lst'][$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
foreach($mapsImport['lst'] as $id => $values){
|
||||
unset($mapsImport['lst'][$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enregistrement de la sélection du MatchSettings
|
||||
if($operation != 'getSelection'){
|
||||
AdminServ::saveMatchSettingSelection($mapsImport);
|
||||
}
|
||||
|
||||
$client->Terminate();
|
||||
}
|
||||
|
||||
// OUT
|
||||
if($operation == 'getSelection'){
|
||||
echo json_encode($mapsImport);
|
||||
}
|
||||
else{
|
||||
echo json_encode($_SESSION['adminserv']['matchset_maps_selected']);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
// ENREGISTREMENT
|
||||
if( isset($_POST['savematchsetting']) && isset($_SESSION['adminserv']['matchset_maps_selected']) ){
|
||||
// Filename
|
||||
$matchSettingName = Str::replaceChars($_POST['matchSettingName']);
|
||||
$filename = $data['mapsDirectoryPath'].$args['directory'].$matchSettingName;
|
||||
if(File::getExtension($matchSettingName) != 'txt'){
|
||||
$filename .= '.txt';
|
||||
}
|
||||
|
||||
$struct = array();
|
||||
|
||||
// Gameinfos
|
||||
$gameinfos = AdminServ::getGameInfosStructFromPOST();
|
||||
$struct['gameinfos'] = array(
|
||||
'game_mode' => $gameinfos['GameMode'],
|
||||
'chat_time' => $gameinfos['ChatTime'],
|
||||
'finishtimeout' => $gameinfos['FinishTimeout'],
|
||||
'allwarmupduration' => $gameinfos['AllWarmUpDuration'],
|
||||
'disablerespawn' => $gameinfos['DisableRespawn'],
|
||||
'forceshowallopponents' => $gameinfos['ForceShowAllOpponents'],
|
||||
'rounds_pointslimit' => $gameinfos['RoundsPointsLimit'],
|
||||
'rounds_custom_points' => $gameinfos['RoundCustomPoints'],
|
||||
'rounds_usenewrules' => $gameinfos['RoundsUseNewRules'],
|
||||
'rounds_forcedlaps' => $gameinfos['RoundsForcedLaps'],
|
||||
'rounds_pointslimitnewrules' => $gameinfos['RoundsPointsLimitNewRules'],
|
||||
'team_pointslimit' => $gameinfos['TeamPointsLimit'],
|
||||
'team_maxpoints' => $gameinfos['TeamMaxPoints'],
|
||||
'team_usenewrules' => $gameinfos['TeamUseNewRules'],
|
||||
'team_pointslimitnewrules' => $gameinfos['TeamPointsLimitNewRules'],
|
||||
'timeattack_limit' => $gameinfos['TimeAttackLimit'],
|
||||
'timeattack_synchstartperiod' => $gameinfos['TimeAttackSynchStartPeriod'],
|
||||
'laps_nblaps' => $gameinfos['LapsNbLaps'],
|
||||
'laps_timelimit' => $gameinfos['LapsTimeLimit'],
|
||||
'cup_pointslimit' => $gameinfos['CupPointsLimit'],
|
||||
'cup_roundsperchallenge' => $gameinfos['CupRoundsPerMap'],
|
||||
'cup_nbwinners' => $gameinfos['CupNbWinners'],
|
||||
'cup_warmupduration' => $gameinfos['CupWarmUpDuration']
|
||||
);
|
||||
if(SERVER_VERSION_NAME != 'TmForever'){
|
||||
$struct['gameinfos']['script_name'] = $gameinfos['ScriptName'];
|
||||
}
|
||||
|
||||
// HotSeat
|
||||
$struct['hotseat'] = array(
|
||||
'game_mode' => intval($_POST['hotSeatGameMode']),
|
||||
'time_limit' => TimeDate::secToMillisec( intval($_POST['hotSeatTimeLimit']) ),
|
||||
'rounds_count' => intval($_POST['hotSeatCountRound'])
|
||||
);
|
||||
|
||||
// Filter
|
||||
$struct['filter'] = array(
|
||||
'is_lan' => array_key_exists('filterIsLan', $_POST),
|
||||
'is_internet' => array_key_exists('filterIsInternet', $_POST),
|
||||
'is_solo' => array_key_exists('filterIsSolo', $_POST),
|
||||
'is_hotseat' => array_key_exists('filterIsHotSeat', $_POST),
|
||||
'sort_index' => intval($_POST['filterSortIndex']),
|
||||
'random_map_order' => array_key_exists('filterRandomMaps', $_POST),
|
||||
'force_default_gamemode' => intval($_POST['filterDefaultGameMode']),
|
||||
);
|
||||
|
||||
// ScriptSettings (nur fuer ManiaPlanet/TM2, nicht fuer TmForever)
|
||||
// TmForever kennt die Methode 'GetModeScriptInfo' nicht (Fehler -506).
|
||||
if(SERVER_VERSION_NAME != 'TmForever'){
|
||||
if( !$client->query('GetModeScriptInfo') ){
|
||||
AdminServ::error();
|
||||
}
|
||||
else{
|
||||
$scriptsettings = $client->getResponse();
|
||||
|
||||
if( !empty($scriptsettings['ParamDescs']) ){
|
||||
foreach($scriptsettings['ParamDescs'] as $param){
|
||||
$struct['scriptsettings'][] = array(
|
||||
'name' => $param['Name'],
|
||||
'type' => $param['Type'],
|
||||
'value' => $param['Default']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Maps
|
||||
$struct['startindex'] = 1;
|
||||
$maps = $_SESSION['adminserv']['matchset_maps_selected']['lst'];
|
||||
if( isset($maps) && is_array($maps) && !empty($maps) ){
|
||||
$mapsField = (SERVER_VERSION_NAME == 'TmForever') ? 'challenge' : 'map';
|
||||
foreach($maps as $id => $values){
|
||||
$struct[$mapsField][$values['UId']] = $values['FileName'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Enregistrement
|
||||
if( ($result = AdminServ::saveMatchSettings($filename, $struct)) !== true ){
|
||||
AdminServ::error(Utils::t('Unable to save the MatchSettings').' : '.$matchSettingName.' ('.$result.')');
|
||||
}
|
||||
else{
|
||||
$action = Utils::t('The MatchSettings "!matchSettingName" was successfully created in the folder', array('!matchSettingName' => $matchSettingName)).' : '.$data['mapsDirectoryPath'].$args['directory'];
|
||||
AdminServ::info($action);
|
||||
AdminServLogs::add('action', $action);
|
||||
Utils::redirection(false, '?p='.USER_PAGE .$hasDirectory);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if( !isset($_GET['f']) ){
|
||||
unset($_SESSION['adminserv']['matchset_maps_selected']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// LECTURE
|
||||
$data['directoryList'] = Folder::getArborescence($data['mapsDirectoryPath'], AdminServConfig::$MAPS_HIDDEN_FOLDERS, substr_count($data['mapsDirectoryPath'], '/'));
|
||||
$data['matchSettings'] = array();
|
||||
// Édition
|
||||
if( isset($_GET['f']) && $_GET['f'] != null ){
|
||||
$data['pageTitle'] = Utils::t('Edit');
|
||||
$data['matchSettings']['name'] = $_GET['f'];
|
||||
$matchSettingsData = AdminServ::getMatchSettingsData($data['mapsDirectoryPath'].$args['directory'].$data['matchSettings']['name']);
|
||||
$data['gameInfos'] = array(
|
||||
'curr' => null,
|
||||
'next' => $matchSettingsData['gameinfos']
|
||||
);
|
||||
unset($matchSettingsData['gameinfos']);
|
||||
$data['matchSettings'] += $matchSettingsData;
|
||||
if( isset($data['matchSettings']['maps']) ){
|
||||
$maps = AdminServ::getMapListFromMatchSetting($data['matchSettings']['maps']);
|
||||
$data['matchSettings']['nbm'] = $maps['nbm']['count'];
|
||||
$_SESSION['adminserv']['matchset_maps_selected'] = $maps;
|
||||
}
|
||||
else{
|
||||
$data['matchSettings']['nbm'] = 0;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$data['pageTitle'] = Utils::t('Create');
|
||||
$data['matchSettings']['name'] = 'match_settings';
|
||||
$gameInfos = AdminServ::getGameInfos();
|
||||
$data['gameInfos'] = array(
|
||||
'curr' => null,
|
||||
'next' => $gameInfos['next']
|
||||
);
|
||||
$data['matchSettings']['hotseat'] = array(
|
||||
'GameMode' => 1,
|
||||
'TimeLimit' => 300000,
|
||||
'RoundsCount' => 5
|
||||
);
|
||||
$data['matchSettings']['filter'] = array(
|
||||
'IsLan' => 1,
|
||||
'IsInternet' => 1,
|
||||
'IsSolo' => 0,
|
||||
'IsHotseat' => 1,
|
||||
'SortIndex' => 1000,
|
||||
'RandomMapOrder' => 0,
|
||||
'ForceDefaultGameMode' => 1
|
||||
);
|
||||
$data['matchSettings']['StartIndex'] = 0;
|
||||
$data['matchSettings']['nbm'] = 0;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user