-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: resolve minimap tile urls in map component (#59)
- Loading branch information
Showing
8 changed files
with
136 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import express from 'express'; | ||
import tiles from './tiles.mjs'; | ||
|
||
const minimap = express(); | ||
|
||
minimap.get('/tiles/*', (req, res) => { | ||
const directoryName = req.params[0]; | ||
|
||
if (!tiles[directoryName]) { | ||
res.sendStatus(404); | ||
return; | ||
} | ||
|
||
res.json(tiles[directoryName]); | ||
}); | ||
|
||
export default minimap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import mpq from '../mpq/index.mjs'; | ||
import logger from '../utils/logger.mjs'; | ||
|
||
const log = logger('minimap'); | ||
|
||
log('generating tile index'); | ||
|
||
const file = mpq.files.get('textures\\Minimap\\md5translate.trs'); | ||
const source = file.data.toString(); | ||
file.close(); | ||
|
||
// tile directory -> tile name -> content path | ||
const tiles = {}; | ||
let tileCount = 0; | ||
|
||
for (const line of source.split(/\n|\r\n/)) { | ||
if (line.startsWith('dir:') || line.trim().length === 0) { | ||
continue; | ||
} | ||
|
||
const [tilePath, contentPath] = line.split(/\t+/); | ||
const tilePathParts = tilePath.split(/[/\\]/); | ||
const tileDirectory = tilePathParts.slice(0, -1).map((t) => t.toLowerCase()).join('/'); | ||
const tileName = tilePathParts.at(-1).split('.')[0].toLowerCase(); | ||
|
||
if (!tiles[tileDirectory]) { | ||
tiles[tileDirectory] = {}; | ||
} | ||
|
||
tiles[tileDirectory][tileName] = contentPath.toLowerCase(); | ||
tileCount++; | ||
} | ||
|
||
log(`tile index contains ${tileCount} tiles`); | ||
|
||
export default tiles; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ module.exports = { | |
'DEBUG', | ||
'PIPELINE_URI', | ||
'DATA_URI', | ||
'MINIMAP_URI', | ||
]), | ||
], | ||
module: { | ||
|