Skip to content

Commit

Permalink
Implemented mapTileSize setting in properties file
Browse files Browse the repository at this point in the history
  • Loading branch information
woubuc committed Dec 22, 2017
1 parent 5a555e4 commit e76b609
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public static void generateConfigFile() throws IOException {
int minZoom = 0;

int count = 0;
for (int i = mapSize; i > 256; i++) {
for (int i = mapSize; i > WurmMapGen.properties.mapTileSize; i++) {
i = (i/2);
nativeZoom = count;
count++;
}

count = 0;
for (int i = maxMapSize; i > 256; i++) {
for (int i = maxMapSize; i > WurmMapGen.properties.mapTileSize; i++) {
i = (i/2);
maxZoom = count;
count++;
Expand All @@ -47,6 +47,7 @@ public static void generateConfigFile() throws IOException {
config.put("mapMaxZoom", maxZoom);
config.put("actualMapSize", mapSize);
config.put("maxMapSize", maxMapSize);
config.put("mapTileSize", WurmMapGen.properties.mapTileSize);

config.put("markerType", WurmMapGen.properties.markerType);

Expand Down
7 changes: 7 additions & 0 deletions src/resources/WurmMapGen.properties
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ showStructures=true
# Higher = faster, but more CPU usage
mapGeneratorThreads=2

# Size of a tile on the map
# Should be a power of 2 (64, 128, 256, 512, 1024, ...)
# Smaller tiles = more files generated, takes longer but needs slightly less memory
# Larger tiles = less files generated, but can use a lot of memory if the tiles are too large
# Advised value is between 128 and 512, lower than 128 could give bad performance in the browser
mapTileSize=256

# Generate shading on map based on tile height
mapGenerateShading=true

Expand Down
2 changes: 1 addition & 1 deletion src/resources/template/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Promise.all(promises)
})
.then(function() {
// Add computed config values
WurmMapGen.config.xyMulitiplier = (WurmMapGen.config.actualMapSize / 256);
WurmMapGen.config.xyMulitiplier = (WurmMapGen.config.actualMapSize / WurmMapGen.config.mapTileSize);

// Create the map
WurmMapGen.map.create();
Expand Down
1 change: 1 addition & 0 deletions src/resources/template/app/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WurmMapGen.map = {
map.setZoom(Math.ceil((config.mapMinZoom + config.mapMaxZoom) / 2) - 1);

var wurmMapLayer = L.tileLayer('images/{x}-{y}.png', {
tileSize: config.mapTileSize,
maxNativeZoom: config.nativeZoom,
minNativeZoom: config.nativeZoom,
minZoom: config.mapMinZoom,
Expand Down

0 comments on commit e76b609

Please sign in to comment.