-am (#1335)
This commit is contained in:
+13
-3
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user