redid wall generation completely.
This commit is contained in:
+23
-4
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
@@ -54,7 +55,7 @@ type Settings struct {
|
||||
TurretSize float64 `json:"turret_size"`
|
||||
TurretShape string `json:"turret_shape"`
|
||||
TurretSpacing float64 `json:"turret_spacing"`
|
||||
GateSpacing float64 `json:"gate_spacing"` // percent of wall circumference between gates (0=no gates)
|
||||
GateCount int `json:"gate_count"` // number of gates on the outer wall before inner-wall halving
|
||||
|
||||
// Building settings
|
||||
NumBuildings int `json:"num_buildings"`
|
||||
@@ -161,7 +162,7 @@ func LoadSettings() (*Settings, error) {
|
||||
TurretSize: 0.6,
|
||||
TurretShape: "circular",
|
||||
TurretSpacing: 55,
|
||||
GateSpacing: 25,
|
||||
GateCount: 3,
|
||||
NumBuildings: 200,
|
||||
MinBuildingSize: 3.5,
|
||||
MaxBuildingSize: 10.0,
|
||||
@@ -264,8 +265,20 @@ func normalizeSettings(settings *Settings, rawKeys map[string]json.RawMessage) {
|
||||
if _, ok := rawKeys["turret_spacing"]; !ok {
|
||||
settings.TurretSpacing = 55
|
||||
}
|
||||
if _, ok := rawKeys["gate_spacing"]; !ok {
|
||||
settings.GateSpacing = 25
|
||||
if _, ok := rawKeys["gate_count"]; !ok {
|
||||
if legacyRaw, legacy := rawKeys["gate_spacing"]; legacy && settings.GateCount == 0 {
|
||||
var legacySpacing float64
|
||||
if err := json.Unmarshal(legacyRaw, &legacySpacing); err == nil {
|
||||
legacyCount := int(math.Round(100.0 / clamp(legacySpacing, 1, 100)))
|
||||
if legacyCount < 1 {
|
||||
legacyCount = 1
|
||||
}
|
||||
settings.GateCount = legacyCount
|
||||
}
|
||||
}
|
||||
if settings.GateCount == 0 {
|
||||
settings.GateCount = 3
|
||||
}
|
||||
}
|
||||
|
||||
// Wall widths are percentages of average image dimension.
|
||||
@@ -289,6 +302,12 @@ func normalizeSettings(settings *Settings, rawKeys map[string]json.RawMessage) {
|
||||
settings.WallCurvyness = clamp(settings.WallCurvyness, 0, 100)
|
||||
settings.TurretSize = snapTurretSizePercent(settings.TurretSize)
|
||||
settings.TurretSpacing = clamp(settings.TurretSpacing, 0, 100)
|
||||
if settings.GateCount < 1 {
|
||||
settings.GateCount = 1
|
||||
}
|
||||
if settings.GateCount > 20 {
|
||||
settings.GateCount = 20
|
||||
}
|
||||
|
||||
// Tree sizes are percentages of average image dimension.
|
||||
// Migrate older pixel-based values when they exceed the valid percentage range.
|
||||
|
||||
Reference in New Issue
Block a user