Skip to content

Commit d8a8084

Browse files
authored
Merge pull request #573 from rfresh2/mapdownloader-fix1
2 parents 1f3a3dd + 0176be1 commit d8a8084

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/kotlin/com/lambda/client/module/modules/misc/MapDownloader.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ internal object MapDownloader : Module(
4646
private var pendingTasks = mutableSetOf<MapInfo>()
4747
private val secTimer = TickTimer(TimeUnit.SECONDS)
4848
private val milliSecTimer = TickTimer(TimeUnit.MILLISECONDS)
49+
private val illegalFilenameCharsRegex = "[^a-zA-Z0-9\\.\\-]".toRegex() // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file
4950

5051
init {
5152
existingHashes = getExistingHashes()
@@ -159,7 +160,11 @@ internal object MapDownloader : Module(
159160
try {
160161
val resized = BufferedImage(finalSize, finalSize, img.type)
161162
val g = resized.createGraphics()
162-
val loc = "${FolderUtils.mapImagesFolder}${mapInfo.hash}_name_${mapInfo.name.replace(File.separator, "")}_id_${mapInfo.id}_${if (mc.isIntegratedServerRunning) "local" else "server_${player.connection.networkManager.remoteAddress.toString().replace("/", "_").replace(":", "_")}"}.png"
163+
val loc = "${FolderUtils.mapImagesFolder}${mapInfo.hash}" +
164+
"_name_${mapInfo.name.replace(illegalFilenameCharsRegex, "_")}" +
165+
"_id_${mapInfo.id}" +
166+
"_${if (mc.isIntegratedServerRunning) "local"
167+
else "server_${player.connection.networkManager.remoteAddress.toString().replace("/", "_").replace(":", "_")}"}.png"
163168
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
164169
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR)
165170
g.drawImage(img, 0, 0, finalSize, finalSize, 0, 0, img.width,

0 commit comments

Comments
 (0)