This commit is contained in:
NotSoToothless
2026-06-18 20:11:22 -07:00
committed by GitHub
parent 48f96ca8ff
commit 76844c1c6f
2 changed files with 170 additions and 32 deletions
+13 -3
View File
@@ -2034,9 +2034,19 @@ app.get('/api/match/minimap/:level', (req, res) => {
if (!level || !/^[a-zA-Z0-9_]+$/.test(level)) {
return res.status(400).json({ error: 'Invalid level name' });
}
const suffix = req.query.type === 'full' ? '.png' : '_tankmap.png';
const minimapPath = path.join(__dirname, '..', '..', 'SHARED', 'MAPS', 'MINIMAPS', level + suffix);
if (!fs.existsSync(minimapPath)) {
const minimapsDir = path.join(__dirname, '..', '..', 'SHARED', 'MAPS', 'MINIMAPS');
const names = req.query.type === 'full'
? [level + '.png', level + '_map.png']
: [level + '_tankmap.png', level + '.png', level + '_map.png'];
let minimapPath = null;
for (const name of [...new Set(names)]) {
const candidate = path.join(minimapsDir, name);
if (fs.existsSync(candidate)) {
minimapPath = candidate;
break;
}
}
if (!minimapPath) {
return res.status(404).json({ error: 'Minimap not found' });
}
res.sendFile(minimapPath, {