From a42c12ace83a4be4396219f41abeb8ca9dfb7bf1 Mon Sep 17 00:00:00 2001 From: beu Date: Sun, 22 Jun 2025 11:47:22 +0200 Subject: [PATCH] remove map from the playlist when erasing map file --- core/Maps/DirectoryBrowser.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/Maps/DirectoryBrowser.php b/core/Maps/DirectoryBrowser.php index e69cf404..fdfc8bc8 100644 --- a/core/Maps/DirectoryBrowser.php +++ b/core/Maps/DirectoryBrowser.php @@ -557,6 +557,17 @@ class DirectoryBrowser implements ManialinkPageAnswerListener { $fileName = base64_decode(substr($actionName, strlen(self::ACTION_ERASE_FILE))); $folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH); $filePath = $folderPath . $fileName; + + $maps = $this->maniaControl->getMapManager()->getMaps(); + $mapsFolder = $this->maniaControl->getServer()->getDirectory()->getMapsFolder(); + $filteredMaps = array_filter($maps, function ($item) use ($mapsFolder, $filePath) { + return ($mapsFolder . $item->fileName === $filePath); + }); + foreach ($filteredMaps as $map) { + Logger::log('Map "'. $filePath .'" loaded by the server, removing it from the playlist before erasing the file'); + $this->maniaControl->getMapManager()->removeMap($player, $map->uid); + } + if (@unlink($filePath)) { $message = $this->maniaControl->getChat()->formatMessage( 'Erased %s!',