From 6b15aeb69ad096d3c17742ca9b5dedb561048a1b Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Sun, 3 May 2015 23:34:05 +0100 Subject: [PATCH 1/2] Fixes centerX and centerY not being correctly centered, corrects sphere logic. why is it called sphereMagic? because as far as I'm concerned, it is magic, it was previously named centerZ but it actually was quite a ways off being the center of any spheres. Idk what it does, but It serves a vital part of building mathematically correct spheres. --- .../procedural mapping/mapGenerator.dm | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index 887ddfc40a4..f480a2b11f3 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -49,30 +49,29 @@ 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/centerX = max(abs((End.x+Start.x)/2),1) + var/centerY = max(abs((End.y+Start.y)/2),1) 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/sphereMagic = 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() - //Sphere mode engage - var/evenCheckZ = 0 - if(max(bigZ,lilZ) % 2 == 0) - evenCheckZ = centerZ+1 + //Even sphere correction engage + var/offByOneOffset = 1 + if(bigZ % 2 == 0) + offByOneOffset = 0 - for(var/i = lilZ, i <= bigZ, i++) + for(var/i = lilZ, i <= bigZ+offByOneOffset, i++) var/theRadius = radius - if(i != centerZ) + if(i != sphereMagic) if(i != evenCheckZ) - theRadius = max(radius/max((2*abs(centerZ-i)),1),1) + theRadius = max(radius/max((2*abs(sphereMagic-i)),1),1) map |= circlerange(locate(centerX,centerY,i),theRadius) From 984e337c47d1fe8ea7e86be85919b928b8e3e640 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Sun, 3 May 2015 23:39:04 +0100 Subject: [PATCH 2/2] minor correction. --- code/modules/procedural mapping/mapGenerator.dm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index f480a2b11f3..c0b89549f3e 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -70,8 +70,7 @@ for(var/i = lilZ, i <= bigZ+offByOneOffset, i++) var/theRadius = radius if(i != sphereMagic) - if(i != evenCheckZ) - theRadius = max(radius/max((2*abs(sphereMagic-i)),1),1) + theRadius = max(radius/max((2*abs(sphereMagic-i)),1),1) map |= circlerange(locate(centerX,centerY,i),theRadius)