From 7a0a724d6c96e57252bee25e3c2239bf0ee40ba8 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Fri, 1 May 2015 01:26:28 +0100 Subject: [PATCH 1/6] Fixes a bug where turf cluster checks checked for atoms instead of turfs, adds proc to define a circular region, CIRCLES! --- .../procedural mapping/mapGenerator.dm | 26 +++++--- .../procedural mapping/mapGeneratorModule.dm | 60 +++++++++++++++---- .../procedural mapping/mapGeneratorReadme.dm | 25 +++++--- 3 files changed, 82 insertions(+), 29 deletions(-) diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index 9a304e5c57a..cda6f44c991 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -3,8 +3,6 @@ //Map information var/list/map = list() - var/turf/bottomLeft = null - var/turf/topRight = null //mapGeneratorModule information var/list/modules = list() @@ -13,18 +11,30 @@ ..() initialiseModules() -//Defines the region the map represents, sets map, bottomLeft, topRight +//Defines the region the map represents, sets map //Returns the map /datum/mapGenerator/proc/defineRegion(var/turf/Start, var/turf/End) if(!checkRegion(Start, End)) return 0 - if(!Start || !End) - return 0 - bottomLeft = Start - topRight = End + map = block(Start,End) + return map - map = block(bottomLeft,topRight) + +//Defines the region the map represents, as a CIRCLE!, sets map +//Returns the map +/datum/mapGenerator/proc/defineCircularRegion(var/turf/Start, var/turf/End) + if(!checkRegion(Start, End)) + return 0 + + var/centerX = abs(max(End.x-Start.x,1)) + var/centerY = abs(max(End.y-Start.y,1)) + var/centerZ = abs(max(End.z-Start.z,1)) + var/radius = abs(max(centerX,centerY)) //take the biggest displacement as the radius + + var/turf/center = locate(centerX, centerY, centerZ) //spherical maps! because Idk + + map = circlerange(center,radius) return map diff --git a/code/modules/procedural mapping/mapGeneratorModule.dm b/code/modules/procedural mapping/mapGeneratorModule.dm index 458f11cd969..b7e84b5fda8 100644 --- a/code/modules/procedural mapping/mapGeneratorModule.dm +++ b/code/modules/procedural mapping/mapGeneratorModule.dm @@ -1,8 +1,19 @@ +//clusterCheckFlags defines +//All based on clusterMin and clusterMax as guides -#define CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible -#define CLUSTER_CHECK_ATOMS 2 //Don't let atoms cluster, based on clusterMin and clusterMax as guides -#define CLUSTER_CHECK_TURFS 4 //Don't let turfs cluster, based on clusterMin and clusterMax as guides -#define CLUSTER_CHECK_ALL 6 //Don't let anything cluster, based on clusterMind and clusterMax as guides +//Individual defines +#define CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible +#define CLUSTER_CHECK_DIFFERENT_TURFS 2 //Don't let turfs of DIFFERENT types cluster +#define CLUSTER_CHECK_DIFFERENT_ATOMS 4 //Don't let atoms of DIFFERENT types cluster +#define CLUSTER_CHECK_SAME_TURFS 8 //Don't let turfs of the SAME type cluster +#define CLUSTER_CHECK_SAME_ATOMS 16 //Don't let atoms of the SAME type cluster + +//Combined defines +#define CLUSTER_CHECK_ALL_TURFS 32 //Don't let ANY turfs cluster same and different types +#define CLUSTER_CHECK_ALL_ATOMS 64 //Don't let ANY atoms cluster same and different types + +//All +#define CLUSTER_CHECK_ALL 96 //Don't let anything cluster, like, at all /datum/mapGeneratorModule var/datum/mapGenerator/mother = null @@ -38,24 +49,47 @@ //Turfs don't care whether atoms can be placed here for(var/turfPath in spawnableTurfs) - if(clusterCheckFlags & CLUSTER_CHECK_TURFS) - if(clusterMax && clusterMin) + + //Clustering! + if(clusterMax && clusterMin) + + //You're the same as me? I hate you I'm going home + if(clusterCheckFlags & CLUSTER_CHECK_SAME_TURFS) clustering = rand(clusterMin,clusterMax) - if(locate(/atom/movable) in range(clustering, T)) + if(locate(turfPath) in trange(clustering, T)) continue + + //You're DIFFERENT to me? I hate you I'm going home + if(clusterCheckFlags & CLUSTER_CHECK_DIFFERENT_TURFS) + clustering = rand(clusterMin,clusterMax) + for(var/turf/F in trange(clustering,T)) + if(istype(F, turfPath)) + continue + + //Success! if(prob(spawnableTurfs[turfPath])) T.ChangeTurf(turfPath) //Atoms DO care whether atoms can be placed here if(checkPlaceAtom(T)) + for(var/atomPath in spawnableAtoms) - if(clusterCheckFlags & CLUSTER_CHECK_ATOMS) - if(clusterMax && clusterMin) - clustering = rand(clusterMin,clusterMax) - if(locate(/atom/movable) in range(clustering, T)) + + //Clustering! + if(clusterMax && clusterMin) + + //You're the same as me? I hate you I'm going home + if(clusterCheckFlags & CLUSTER_CHECK_SAME_ATOMS) + clustering = rand(clusterMin, clusterMax) + if(locate(atomPath) in range(clustering,T)) continue - if(prob(spawnableAtoms[atomPath])) - new atomPath (T) + + //You're DIFFERENT from me? I hate you I'm going home + if(clusterCheckFlags & CLUSTER_CHECK_DIFFERENT_ATOMS) + clustering = rand(clusterMin, clusterMax) + for(var/atom/movable/M in range(clustering,T)) + if(istype(M, atomPath)) + continue . = 1 diff --git a/code/modules/procedural mapping/mapGeneratorReadme.dm b/code/modules/procedural mapping/mapGeneratorReadme.dm index 95fa449624e..636d64cd90b 100644 --- a/code/modules/procedural mapping/mapGeneratorReadme.dm +++ b/code/modules/procedural mapping/mapGeneratorReadme.dm @@ -11,10 +11,14 @@ mapGenerator: Desc: a mapGenerator is a master datum that collects and syncs all mapGeneratorModules in it's modules list - defineRegion(var/list/startList, var/list/endList) + defineRegion(var/turf/Start, var/turf/End) Example: defineRegion(locate(1,1,1),locate(5,5,5)) Desc: Sets the bounds of the mapGenerator's "map" + defineCircularRegion(var/turf/Start, var/turf/End) + Example: defineCircularRegion(locate(1,1,1),locate(5,5,5)) + Desc: Sets the mapGenerator's "map" as a circle, with center in the middle of Start and End's X,Y,Z coordinates + checkRegion(var/turf/Start, var/turf/End) Example: checkRegion(locate(1,1,1), locate(5,5,5)) Desc: Checks if a rectangle between Start's coords and End's coords is valid @@ -108,8 +112,6 @@ Variable Breakdown (For Mappers): mapGenerator map - INTERNAL, do not touch - bottomLeft - INTERNAL, do not touch - topRight - INTERNAL, do not touch modules - A list of typepaths of mapGeneratorModules mapGeneratorModule @@ -118,13 +120,20 @@ Variable Breakdown (For Mappers): spawnableTurfs - A list of typepaths and their probability to spawn, eg: spawnableTurfs = list(/turf/unsimulated/floor/grass = 100) clusterMax - The max range to check for something being "too close" for this atom/turf to spawn, the true value is random between clusterMin and clusterMax clusterMin - The min range to check for something being "too close" for this atom/turf to spawn, the true value is random between clusterMin and clusterMax - clusterCheckFlags - A Bitfield that controls how the cluster checks work. + clusterCheckFlags - A Bitfield that controls how the cluster checks work, All based on clusterMin and clusterMax guides clusterCheckFlags flags: - CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible - CLUSTER_CHECK_ATOMS 2 //Don't let atoms cluster, based on clusterMin and clusterMax as guides - CLUSTER_CHECK_TURFS 4 //Don't let turfs cluster, based on clusterMin and clusterMax as guides - CLUSTER_CHECK_ALL 6 //Don't let anything cluster, based on clusterMind and clusterMax as guides + CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible + CLUSTER_CHECK_DIFFERENT_TURFS 2 //Don't let turfs of DIFFERENT types cluster + CLUSTER_CHECK_DIFFERENT_ATOMS 4 //Don't let atoms of DIFFERENT types cluster + CLUSTER_CHECK_SAME_TURFS 8 //Don't let turfs of the SAME type cluster + CLUSTER_CHECK_SAME_ATOMS 16 //Don't let atoms of the SAME type cluster + + CLUSTER_CHECK_ALL_TURFS 32 //Don't let ANY turfs cluster same and different types + CLUSTER_CHECK_ALL_ATOMS 64 //Don't let ANY atoms cluster same and different types + + CLUSTER_CHECK_ALL 96 //Don't let anything cluster, like, at all + */ \ No newline at end of file From baa758921b4c847f297bb27863eb92bc4f164350 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Fri, 1 May 2015 01:38:39 +0100 Subject: [PATCH 2/6] Made defineRegion() procs additive instead of overwriting, overwriting has been moved to a "replace" argument, adds undefineRegion() which makes the map list a new list. --- .../procedural mapping/mapGenerator.dm | 19 +++++++++++++++---- .../procedural mapping/mapGeneratorReadme.dm | 14 +++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index cda6f44c991..541c280fa4e 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -13,17 +13,20 @@ //Defines the region the map represents, sets map //Returns the map -/datum/mapGenerator/proc/defineRegion(var/turf/Start, var/turf/End) +/datum/mapGenerator/proc/defineRegion(var/turf/Start, var/turf/End, var/replace = 0) if(!checkRegion(Start, End)) return 0 - map = block(Start,End) + if(replace) + undefineRegion() + + map |= block(Start,End) return map //Defines the region the map represents, as a CIRCLE!, sets map //Returns the map -/datum/mapGenerator/proc/defineCircularRegion(var/turf/Start, var/turf/End) +/datum/mapGenerator/proc/defineCircularRegion(var/turf/Start, var/turf/End, var/replace = 0) if(!checkRegion(Start, End)) return 0 @@ -34,10 +37,18 @@ var/turf/center = locate(centerX, centerY, centerZ) //spherical maps! because Idk - map = circlerange(center,radius) + if(replace) + undefineRegion() + + map |= circlerange(center,radius) return map +//Empties the map list, he's dead jim. +/datum/mapGenerator/proc/undefineRegion() + map = list() //bai bai + + //Checks for and Rejects bad region coordinates //Returns 1/0 /datum/mapGenerator/proc/checkRegion(var/turf/Start, var/turf/End) diff --git a/code/modules/procedural mapping/mapGeneratorReadme.dm b/code/modules/procedural mapping/mapGeneratorReadme.dm index 636d64cd90b..bb43a331afc 100644 --- a/code/modules/procedural mapping/mapGeneratorReadme.dm +++ b/code/modules/procedural mapping/mapGeneratorReadme.dm @@ -11,18 +11,22 @@ mapGenerator: Desc: a mapGenerator is a master datum that collects and syncs all mapGeneratorModules in it's modules list - defineRegion(var/turf/Start, var/turf/End) - Example: defineRegion(locate(1,1,1),locate(5,5,5)) + defineRegion(var/turf/Start, var/turf/End, var/replace = 0) + Example: defineRegion(locate(1,1,1),locate(5,5,5),0) Desc: Sets the bounds of the mapGenerator's "map" - defineCircularRegion(var/turf/Start, var/turf/End) - Example: defineCircularRegion(locate(1,1,1),locate(5,5,5)) + defineCircularRegion(var/turf/Start, var/turf/End, var/replace = 0) + Example: defineCircularRegion(locate(1,1,1),locate(5,5,5),0) Desc: Sets the mapGenerator's "map" as a circle, with center in the middle of Start and End's X,Y,Z coordinates + undefineRegion() + Example: undefineRegion() + Desc: Empties the map generator list + checkRegion(var/turf/Start, var/turf/End) Example: checkRegion(locate(1,1,1), locate(5,5,5)) Desc: Checks if a rectangle between Start's coords and End's coords is valid - Existing Calls: mapGenerator/defineRegion() + Existing Calls: mapGenerator/defineRegion(), mapGenerator/defineCircularRegion() generate() Example: generate() From 0bcdcd037b8183c2ce7d4936fbba306b372e2a66 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Fri, 1 May 2015 04:27:14 +0100 Subject: [PATCH 3/6] Fixes atoms not spawning, Corrects defineCircularRange() to produce proper spheres when given differing Z coords. --- .../procedural mapping/mapGenerator.dm | 70 ++++++++++++++++--- .../procedural mapping/mapGeneratorModule.dm | 38 +++++----- .../procedural mapping/mapGeneratorReadme.dm | 3 + .../mapGenerators/nature.dm | 4 +- 4 files changed, 84 insertions(+), 31 deletions(-) diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index 541c280fa4e..c71657d15d7 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -1,3 +1,22 @@ +//clusterCheckFlags defines +//All based on clusterMin and clusterMax as guides + +//Individual defines +#define CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible +#define CLUSTER_CHECK_DIFFERENT_TURFS 2 //Don't let turfs of DIFFERENT types cluster +#define CLUSTER_CHECK_DIFFERENT_ATOMS 4 //Don't let atoms of DIFFERENT types cluster +#define CLUSTER_CHECK_SAME_TURFS 8 //Don't let turfs of the SAME type cluster +#define CLUSTER_CHECK_SAME_ATOMS 16 //Don't let atoms of the SAME type cluster + +//Combined defines +#define CLUSTER_CHECK_SAMES 24 //Don't let any of the same type cluster +#define CLUSTER_CHECK_DIFFERENTS 6 //Don't let any of different types cluster +#define CLUSTER_CHECK_ALL_TURFS 32 //Don't let ANY turfs cluster same and different types +#define CLUSTER_CHECK_ALL_ATOMS 64 //Don't let ANY atoms cluster same and different types + +//All +#define CLUSTER_CHECK_ALL 96 //Don't let anything cluster, like, at all + /datum/mapGenerator @@ -32,15 +51,32 @@ var/centerX = abs(max(End.x-Start.x,1)) var/centerY = abs(max(End.y-Start.y,1)) - var/centerZ = abs(max(End.z-Start.z,1)) - var/radius = abs(max(centerX,centerY)) //take the biggest displacement as the radius - var/turf/center = locate(centerX, centerY, centerZ) //spherical maps! because Idk + + var/lilZ = min(Start.z,End.z) + var/bigZ = max(Start.z,End.z) + + var/centerZ = max(abs(bigZ-(lilZ/2)),1) //Spherical maps! woo! + + var/radius = abs(max(centerX,centerY)) //take the biggest displacement as the radius if(replace) undefineRegion() - map |= circlerange(center,radius) + var/evenCheckZ = 0 + if(max(bigZ,lilZ) % 2 == 0) + evenCheckZ = centerZ+1 + + for(var/i = lilZ, i <= bigZ, i++) + var/theRadius = radius + if(i != centerZ) + if(i != evenCheckZ) + theRadius = max(radius/max((2*abs(centerZ-i)),1),1) + + + map |= circlerange(locate(centerX,centerY,i),theRadius) + + return map @@ -73,7 +109,8 @@ if(!modules || !modules.len) return for(var/datum/mapGeneratorModule/mod in modules) - mod.generate() + spawn(0) + mod.generate() //Requests the mapGeneratorModule(s) to (re)generate this one turf @@ -84,7 +121,8 @@ if(!modules || !modules.len) return for(var/datum/mapGeneratorModule/mod in modules) - mod.place(T) + spawn(0) + mod.place(T) //Replaces all paths in the module list with actual module datums @@ -135,8 +173,24 @@ src << "End Coords: [endCoords[1]] - [endCoords[2]] - [endCoords[3]]" return - src << "Defining Region" - N.defineRegion(Start, End) + var/list/clusters = list("None"=CLUSTER_CHECK_NONE,"All"=CLUSTER_CHECK_ALL,"Sames"=CLUSTER_CHECK_SAMES,"Differents"=CLUSTER_CHECK_DIFFERENTS, \ + "Same turfs"=CLUSTER_CHECK_SAME_TURFS, "Same atoms"=CLUSTER_CHECK_SAME_ATOMS, "Different turfs"=CLUSTER_CHECK_DIFFERENT_TURFS, \ + "Different atoms"=CLUSTER_CHECK_DIFFERENT_ATOMS, "All turfs"=CLUSTER_CHECK_ALL_TURFS,"All atoms"=CLUSTER_CHECK_ALL_ATOMS) + + var/moduleClusters = input("Cluster Flags","Map Gen Settings") as null|anything in clusters + //null for default + + if(moduleClusters) + if(!clusters[moduleClusters]) + src << "Invalid Cluster Flags" + return + for(var/datum/mapGeneratorModule/M in N.modules) + M.clusterCheckFlags = clusters[moduleClusters] + + + //src << "Defining Region" + N.defineCircularRegion(Start,End) + //N.defineRegion(Start, End) src << "Region Defined" src << "Generating Region" N.generate() diff --git a/code/modules/procedural mapping/mapGeneratorModule.dm b/code/modules/procedural mapping/mapGeneratorModule.dm index b7e84b5fda8..79796b8f2c4 100644 --- a/code/modules/procedural mapping/mapGeneratorModule.dm +++ b/code/modules/procedural mapping/mapGeneratorModule.dm @@ -1,19 +1,3 @@ -//clusterCheckFlags defines -//All based on clusterMin and clusterMax as guides - -//Individual defines -#define CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible -#define CLUSTER_CHECK_DIFFERENT_TURFS 2 //Don't let turfs of DIFFERENT types cluster -#define CLUSTER_CHECK_DIFFERENT_ATOMS 4 //Don't let atoms of DIFFERENT types cluster -#define CLUSTER_CHECK_SAME_TURFS 8 //Don't let turfs of the SAME type cluster -#define CLUSTER_CHECK_SAME_ATOMS 16 //Don't let atoms of the SAME type cluster - -//Combined defines -#define CLUSTER_CHECK_ALL_TURFS 32 //Don't let ANY turfs cluster same and different types -#define CLUSTER_CHECK_ALL_ATOMS 64 //Don't let ANY atoms cluster same and different types - -//All -#define CLUSTER_CHECK_ALL 96 //Don't let anything cluster, like, at all /datum/mapGeneratorModule var/datum/mapGenerator/mother = null @@ -21,7 +5,8 @@ var/list/spawnableTurfs = list() var/clusterMax = 5 var/clusterMin = 1 - var/clusterCheckFlags = CLUSTER_CHECK_ALL + var/clusterCheckFlags = CLUSTER_CHECK_ALL_ATOMS + var/allowAtomsOnSpace = FALSE //Syncs the module up with it's mother @@ -56,6 +41,10 @@ //You're the same as me? I hate you I'm going home if(clusterCheckFlags & CLUSTER_CHECK_SAME_TURFS) clustering = rand(clusterMin,clusterMax) + for(var/turf/F in trange(clustering,T)) + if(F.type == turfPath) //NOT istype(), exact typematching + continue + if(locate(turfPath) in trange(clustering, T)) continue @@ -63,7 +52,7 @@ if(clusterCheckFlags & CLUSTER_CHECK_DIFFERENT_TURFS) clustering = rand(clusterMin,clusterMax) for(var/turf/F in trange(clustering,T)) - if(istype(F, turfPath)) + if(F.type != turfPath) continue //Success! @@ -81,16 +70,21 @@ //You're the same as me? I hate you I'm going home if(clusterCheckFlags & CLUSTER_CHECK_SAME_ATOMS) clustering = rand(clusterMin, clusterMax) - if(locate(atomPath) in range(clustering,T)) - continue + for(var/atom/movable/M in range(clustering,T)) + if(M.type == atomPath) + continue //You're DIFFERENT from me? I hate you I'm going home if(clusterCheckFlags & CLUSTER_CHECK_DIFFERENT_ATOMS) clustering = rand(clusterMin, clusterMax) for(var/atom/movable/M in range(clustering,T)) - if(istype(M, atomPath)) + if(M.type != atomPath) continue + //Success! + if(prob(spawnableAtoms[atomPath])) + new atomPath(T) + . = 1 @@ -105,6 +99,8 @@ if(A.density) . = 0 break + if(!allowAtomsOnSpace && (istype(T,/turf/space))) + . = 0 /////////////////////////////////////////////////////////// diff --git a/code/modules/procedural mapping/mapGeneratorReadme.dm b/code/modules/procedural mapping/mapGeneratorReadme.dm index bb43a331afc..c083f077404 100644 --- a/code/modules/procedural mapping/mapGeneratorReadme.dm +++ b/code/modules/procedural mapping/mapGeneratorReadme.dm @@ -125,6 +125,7 @@ Variable Breakdown (For Mappers): clusterMax - The max range to check for something being "too close" for this atom/turf to spawn, the true value is random between clusterMin and clusterMax clusterMin - The min range to check for something being "too close" for this atom/turf to spawn, the true value is random between clusterMin and clusterMax clusterCheckFlags - A Bitfield that controls how the cluster checks work, All based on clusterMin and clusterMax guides + allowAtomsOnSpace - A Boolean for if we allow atoms to spawn on space tiles clusterCheckFlags flags: CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible @@ -133,6 +134,8 @@ Variable Breakdown (For Mappers): CLUSTER_CHECK_SAME_TURFS 8 //Don't let turfs of the SAME type cluster CLUSTER_CHECK_SAME_ATOMS 16 //Don't let atoms of the SAME type cluster + CLUSTER_CHECK_SAMES 24 //Don't let any of the same type cluster + CLUSTER_CHECK_DIFFERENTS 6 //Don't let any different types cluster CLUSTER_CHECK_ALL_TURFS 32 //Don't let ANY turfs cluster same and different types CLUSTER_CHECK_ALL_ATOMS 64 //Don't let ANY atoms cluster same and different types diff --git a/code/modules/procedural mapping/mapGenerators/nature.dm b/code/modules/procedural mapping/mapGenerators/nature.dm index 0300de38211..7254e576ba4 100644 --- a/code/modules/procedural mapping/mapGenerators/nature.dm +++ b/code/modules/procedural mapping/mapGenerators/nature.dm @@ -2,9 +2,9 @@ //Exists primarily as a test type. /datum/mapGenerator/nature - modules = list(/datum/mapGeneratorModule/pineTrees, \ + modules = list(/datum/mapGeneratorModule/bottomLayer/grassTurfs, \ + /datum/mapGeneratorModule/pineTrees, \ /datum/mapGeneratorModule/deadTrees, \ /datum/mapGeneratorModule/randBushes, \ /datum/mapGeneratorModule/randRocks, \ - /datum/mapGeneratorModule/bottomLayer/grassTurfs, \ /datum/mapGeneratorModule/denseLayer/grassTufts) From 88faef42ea5c8cd89b36c7986a6dfa5c6b76a6c7 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Fri, 1 May 2015 05:05:32 +0100 Subject: [PATCH 4/6] Adjusts some code to reduce the rapid increase of clustering accidentally somehow caused in this improvement PR Conflicts: code/modules/procedural mapping/mapGeneratorModules/nature.dm --- .../procedural mapping/mapGenerator.dm | 6 +++--- .../procedural mapping/mapGeneratorModule.dm | 21 ++++++++++++------- .../mapGeneratorModules/nature.dm | 8 +++---- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index c71657d15d7..8992380daa8 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -63,6 +63,7 @@ if(replace) undefineRegion() + //Sphere mode engage var/evenCheckZ = 0 if(max(bigZ,lilZ) % 2 == 0) evenCheckZ = centerZ+1 @@ -188,9 +189,8 @@ M.clusterCheckFlags = clusters[moduleClusters] - //src << "Defining Region" - N.defineCircularRegion(Start,End) - //N.defineRegion(Start, End) + src << "Defining Region" + N.defineRegion(Start, End) src << "Region Defined" src << "Generating Region" N.generate() diff --git a/code/modules/procedural mapping/mapGeneratorModule.dm b/code/modules/procedural mapping/mapGeneratorModule.dm index 79796b8f2c4..3bf97d9ca65 100644 --- a/code/modules/procedural mapping/mapGeneratorModule.dm +++ b/code/modules/procedural mapping/mapGeneratorModule.dm @@ -42,7 +42,8 @@ if(clusterCheckFlags & CLUSTER_CHECK_SAME_TURFS) clustering = rand(clusterMin,clusterMax) for(var/turf/F in trange(clustering,T)) - if(F.type == turfPath) //NOT istype(), exact typematching + //if(F.type == turfPath) //NOT istype(), exact typematching + if(istype(F,turfPath)) continue if(locate(turfPath) in trange(clustering, T)) @@ -52,13 +53,15 @@ if(clusterCheckFlags & CLUSTER_CHECK_DIFFERENT_TURFS) clustering = rand(clusterMin,clusterMax) for(var/turf/F in trange(clustering,T)) - if(F.type != turfPath) + //if(F.type != turfPath) + if(!(istype(F,turfPath))) continue //Success! if(prob(spawnableTurfs[turfPath])) T.ChangeTurf(turfPath) + //Atoms DO care whether atoms can be placed here if(checkPlaceAtom(T)) @@ -71,14 +74,16 @@ if(clusterCheckFlags & CLUSTER_CHECK_SAME_ATOMS) clustering = rand(clusterMin, clusterMax) for(var/atom/movable/M in range(clustering,T)) - if(M.type == atomPath) + //if(M.type == atomPath) + if(istype(M,atomPath)) continue //You're DIFFERENT from me? I hate you I'm going home if(clusterCheckFlags & CLUSTER_CHECK_DIFFERENT_ATOMS) clustering = rand(clusterMin, clusterMax) for(var/atom/movable/M in range(clustering,T)) - if(M.type != atomPath) + //if(M.type != atomPath) + if(!(istype(M,atomPath))) continue //Success! @@ -121,11 +126,11 @@ //Settings appropriate for turfs/atoms that cover SOME of the map region, sometimes referred to as a splatter layer. /datum/mapGeneratorModule/splatterLayer clusterCheckFlags = CLUSTER_CHECK_ALL - spawnableAtoms = list(/atom = 30) - spawnableTurfs = list(/turf = 30) + spawnableAtoms = list(/atom = 15) + spawnableTurfs = list(/turf = 15) //Settings appropriate for turfs/atoms that cover a lot of the map region, eg a dense forest. /datum/mapGeneratorModule/denseLayer clusterCheckFlags = CLUSTER_CHECK_NONE - spawnableAtoms = list(/atom = 75) - spawnableTurfs = list(/turf = 75) \ No newline at end of file + spawnableAtoms = list(/atom = 35) + spawnableTurfs = list(/turf = 35) \ No newline at end of file diff --git a/code/modules/procedural mapping/mapGeneratorModules/nature.dm b/code/modules/procedural mapping/mapGeneratorModules/nature.dm index 742141f6fdf..df8dbccb28c 100644 --- a/code/modules/procedural mapping/mapGeneratorModules/nature.dm +++ b/code/modules/procedural mapping/mapGeneratorModules/nature.dm @@ -4,11 +4,11 @@ //Pine Trees /datum/mapGeneratorModule/pineTrees - spawnableAtoms = list(/obj/structure/flora/tree/pine = 30) + spawnableAtoms = list(/obj/structure/flora/tree/pine = 15) //Dead Trees /datum/mapGeneratorModule/deadTrees - spawnableAtoms = list(/obj/structure/flora/tree/dead = 10) + spawnableAtoms = list(/obj/structure/flora/tree/dead = 5) //Random assortment of bushes /datum/mapGeneratorModule/randBushes @@ -18,7 +18,7 @@ ..() spawnableAtoms = typesof(/obj/structure/flora/ausbushes) for(var/i in spawnableAtoms) - spawnableAtoms[i] = 20 + spawnableAtoms[i] = 15 //Random assortment of rocks and rockpiles @@ -34,4 +34,4 @@ //Grass tufts with a high spawn chance /datum/mapGeneratorModule/denseLayer/grassTufts spawnableTurfs = list() - spawnableAtoms = list(/obj/structure/flora/ausbushes/grassybush = 75) \ No newline at end of file + spawnableAtoms = list(/obj/structure/flora/ausbushes/grassybush = 35) From b2bba39a68212ab7ec00d6e5cfb68266e5ba3258 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Fri, 1 May 2015 08:13:47 +0100 Subject: [PATCH 5/6] Fixes the scope of the 4 Continue statements to correctly end the turfPath and atomPath loops, Corrects define bitflags --- .../procedural mapping/mapGenerator.dm | 6 +-- .../procedural mapping/mapGeneratorModule.dm | 40 ++++++++++++------- .../mapGeneratorModules/nature.dm | 8 ++-- .../procedural mapping/mapGeneratorReadme.dm | 6 +-- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index 8992380daa8..74bb3c8e692 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -11,11 +11,11 @@ //Combined defines #define CLUSTER_CHECK_SAMES 24 //Don't let any of the same type cluster #define CLUSTER_CHECK_DIFFERENTS 6 //Don't let any of different types cluster -#define CLUSTER_CHECK_ALL_TURFS 32 //Don't let ANY turfs cluster same and different types -#define CLUSTER_CHECK_ALL_ATOMS 64 //Don't let ANY atoms cluster same and different types +#define CLUSTER_CHECK_ALL_TURFS 10 //Don't let ANY turfs cluster same and different types +#define CLUSTER_CHECK_ALL_ATOMS 20 //Don't let ANY atoms cluster same and different types //All -#define CLUSTER_CHECK_ALL 96 //Don't let anything cluster, like, at all +#define CLUSTER_CHECK_ALL 30 //Don't let anything cluster, like, at all /datum/mapGenerator diff --git a/code/modules/procedural mapping/mapGeneratorModule.dm b/code/modules/procedural mapping/mapGeneratorModule.dm index 3bf97d9ca65..da08a540ef3 100644 --- a/code/modules/procedural mapping/mapGeneratorModule.dm +++ b/code/modules/procedural mapping/mapGeneratorModule.dm @@ -5,7 +5,7 @@ var/list/spawnableTurfs = list() var/clusterMax = 5 var/clusterMin = 1 - var/clusterCheckFlags = CLUSTER_CHECK_ALL_ATOMS + var/clusterCheckFlags = CLUSTER_CHECK_SAME_ATOMS var/allowAtomsOnSpace = FALSE @@ -31,6 +31,7 @@ return 0 var/clustering = 0 + var/skipLoopIteration = FALSE //Turfs don't care whether atoms can be placed here for(var/turfPath in spawnableTurfs) @@ -42,20 +43,23 @@ if(clusterCheckFlags & CLUSTER_CHECK_SAME_TURFS) clustering = rand(clusterMin,clusterMax) for(var/turf/F in trange(clustering,T)) - //if(F.type == turfPath) //NOT istype(), exact typematching if(istype(F,turfPath)) - continue - - if(locate(turfPath) in trange(clustering, T)) + skipLoopIteration = TRUE + break + if(skipLoopIteration) + skipLoopIteration = FALSE continue //You're DIFFERENT to me? I hate you I'm going home if(clusterCheckFlags & CLUSTER_CHECK_DIFFERENT_TURFS) clustering = rand(clusterMin,clusterMax) for(var/turf/F in trange(clustering,T)) - //if(F.type != turfPath) if(!(istype(F,turfPath))) - continue + skipLoopIteration = TRUE + break + if(skipLoopIteration) + skipLoopIteration = FALSE + continue //Success! if(prob(spawnableTurfs[turfPath])) @@ -74,17 +78,23 @@ if(clusterCheckFlags & CLUSTER_CHECK_SAME_ATOMS) clustering = rand(clusterMin, clusterMax) for(var/atom/movable/M in range(clustering,T)) - //if(M.type == atomPath) if(istype(M,atomPath)) - continue + skipLoopIteration = TRUE + break + if(skipLoopIteration) + skipLoopIteration = FALSE + continue //You're DIFFERENT from me? I hate you I'm going home if(clusterCheckFlags & CLUSTER_CHECK_DIFFERENT_ATOMS) clustering = rand(clusterMin, clusterMax) for(var/atom/movable/M in range(clustering,T)) - //if(M.type != atomPath) if(!(istype(M,atomPath))) - continue + skipLoopIteration = TRUE + break + if(skipLoopIteration) + skipLoopIteration = FALSE + continue //Success! if(prob(spawnableAtoms[atomPath])) @@ -126,11 +136,11 @@ //Settings appropriate for turfs/atoms that cover SOME of the map region, sometimes referred to as a splatter layer. /datum/mapGeneratorModule/splatterLayer clusterCheckFlags = CLUSTER_CHECK_ALL - spawnableAtoms = list(/atom = 15) - spawnableTurfs = list(/turf = 15) + spawnableAtoms = list(/atom = 30) + spawnableTurfs = list(/turf = 30) //Settings appropriate for turfs/atoms that cover a lot of the map region, eg a dense forest. /datum/mapGeneratorModule/denseLayer clusterCheckFlags = CLUSTER_CHECK_NONE - spawnableAtoms = list(/atom = 35) - spawnableTurfs = list(/turf = 35) \ No newline at end of file + spawnableAtoms = list(/atom = 75) + spawnableTurfs = list(/turf = 75) \ No newline at end of file diff --git a/code/modules/procedural mapping/mapGeneratorModules/nature.dm b/code/modules/procedural mapping/mapGeneratorModules/nature.dm index df8dbccb28c..09ca84574b1 100644 --- a/code/modules/procedural mapping/mapGeneratorModules/nature.dm +++ b/code/modules/procedural mapping/mapGeneratorModules/nature.dm @@ -4,11 +4,11 @@ //Pine Trees /datum/mapGeneratorModule/pineTrees - spawnableAtoms = list(/obj/structure/flora/tree/pine = 15) + spawnableAtoms = list(/obj/structure/flora/tree/pine = 30) //Dead Trees /datum/mapGeneratorModule/deadTrees - spawnableAtoms = list(/obj/structure/flora/tree/dead = 5) + spawnableAtoms = list(/obj/structure/flora/tree/dead = 10) //Random assortment of bushes /datum/mapGeneratorModule/randBushes @@ -18,7 +18,7 @@ ..() spawnableAtoms = typesof(/obj/structure/flora/ausbushes) for(var/i in spawnableAtoms) - spawnableAtoms[i] = 15 + spawnableAtoms[i] = 20 //Random assortment of rocks and rockpiles @@ -34,4 +34,4 @@ //Grass tufts with a high spawn chance /datum/mapGeneratorModule/denseLayer/grassTufts spawnableTurfs = list() - spawnableAtoms = list(/obj/structure/flora/ausbushes/grassybush = 35) + spawnableAtoms = list(/obj/structure/flora/ausbushes/grassybush = 75) diff --git a/code/modules/procedural mapping/mapGeneratorReadme.dm b/code/modules/procedural mapping/mapGeneratorReadme.dm index c083f077404..ae656b5b30b 100644 --- a/code/modules/procedural mapping/mapGeneratorReadme.dm +++ b/code/modules/procedural mapping/mapGeneratorReadme.dm @@ -136,10 +136,10 @@ Variable Breakdown (For Mappers): CLUSTER_CHECK_SAMES 24 //Don't let any of the same type cluster CLUSTER_CHECK_DIFFERENTS 6 //Don't let any different types cluster - CLUSTER_CHECK_ALL_TURFS 32 //Don't let ANY turfs cluster same and different types - CLUSTER_CHECK_ALL_ATOMS 64 //Don't let ANY atoms cluster same and different types + CLUSTER_CHECK_ALL_TURFS 10 //Don't let ANY turfs cluster same and different types + CLUSTER_CHECK_ALL_ATOMS 20 //Don't let ANY atoms cluster same and different types - CLUSTER_CHECK_ALL 96 //Don't let anything cluster, like, at all + CLUSTER_CHECK_ALL 30 //Don't let anything cluster, like, at all From 7adb829d338da4412703df2a5c6383b1c363bde6 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Fri, 1 May 2015 16:36:05 +0100 Subject: [PATCH 6/6] Fixes the nature generator verb failing to recognise CLUSTER_CHECK_NONE as a valid flag --- code/modules/procedural mapping/mapGenerator.dm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index 74bb3c8e692..887ddfc40a4 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -178,15 +178,21 @@ "Same turfs"=CLUSTER_CHECK_SAME_TURFS, "Same atoms"=CLUSTER_CHECK_SAME_ATOMS, "Different turfs"=CLUSTER_CHECK_DIFFERENT_TURFS, \ "Different atoms"=CLUSTER_CHECK_DIFFERENT_ATOMS, "All turfs"=CLUSTER_CHECK_ALL_TURFS,"All atoms"=CLUSTER_CHECK_ALL_ATOMS) - var/moduleClusters = input("Cluster Flags","Map Gen Settings") as null|anything in clusters + var/moduleClusters = input("Cluster Flags (Cancel to leave unchanged from defaults)","Map Gen Settings") as null|anything in clusters //null for default - - if(moduleClusters) + + var/theCluster = 0 + if(moduleClusters != "None") if(!clusters[moduleClusters]) src << "Invalid Cluster Flags" return + theCluster = clusters[moduleClusters] + else + theCluster = CLUSTER_CHECK_NONE + + if(theCluster) for(var/datum/mapGeneratorModule/M in N.modules) - M.clusterCheckFlags = clusters[moduleClusters] + M.clusterCheckFlags = theCluster src << "Defining Region"