mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-15 20:22:07 +00:00
# MAINTAINER - USE THE BUTTON THAT SAYS "MERGE MASTER" THEN SET THE PR TO AUTO-MERGE! IT'S MUCH EASIER FOR ME TO FIX THINGS BEFORE THEY SKEW RATHER THAN AFTER THE FACT. ## About The Pull Request Hey there, This took a while to do, but here's the gist: Python file now regexes every file in `/code` except for those that have some valid reason to be tacking on more global defines. Some of those reasons are simply just that I don't have the time right now (doing what you see in this PR took a few hours) to refactor and parse what should belong and what should be thrown out. For the time being though, this PR will at least _halt_ people making the mistake of not `#undef`ing any files they `#define` "locally", or within the scope of a file. Most people forget to do this and this leads to a lot of mess later on due to how many variables can be unmanaged on the global level. I've made this mistake, you've made this mistake, it's a common thing. Let's automatically check for it so it can be fixed no-stress. Scenarios this PR corrects: * Forgetting to undef a define but undeffing others. * Not undeffing any defines in your file. * Earmarking a define as a "file local" define, but not defining it. * Having a define be a "file local" define, but having it be used elsewhere. * Having a "local" define not even be in the file that it only shows up in. * Having a completely unused define* (* I kept some of these because they seemed important... Others were junked.) ## Why It's Good For The Game If you wanna use it across multiple files, no reason to not make it a global define (maybe there's a few reasons but let's assume that this is the 95% case). Let me know if you don't like how I re-arranged some of the defines and how you'd rather see it be implemented, and I'd be happy to do that. This was mostly just "eh does it need it or not" sorta stuff. I used a pretty cool way to detect if we should use the standardized GitHub "error" output, you can see the results of that here https://github.com/san7890/bruhstation/actions/runs/4549766579/jobs/8022186846#step:7:792 ## Changelog Nothing that really concerns players. (I fixed up all this stuff using vscode, no regexes beyond what you see in the python script. sorry downstreams)
188 lines
5.3 KiB
Plaintext
188 lines
5.3 KiB
Plaintext
/datum/map_generator
|
|
|
|
//Map information
|
|
var/list/map = list()
|
|
|
|
//mapGeneratorModule information
|
|
var/list/modules = list()
|
|
|
|
var/buildmode_name = "Undocumented"
|
|
|
|
/datum/map_generator/New()
|
|
..()
|
|
if(buildmode_name == "Undocumented")
|
|
buildmode_name = copytext_char("[type]", 20) // / d a t u m / m a p g e n e r a t o r / = 20 characters.
|
|
initialiseModules()
|
|
|
|
//Defines the region the map represents, sets map
|
|
//Returns the map
|
|
/datum/map_generator/proc/defineRegion(turf/Start, turf/End, replace = 0)
|
|
if(!checkRegion(Start, End))
|
|
return 0
|
|
|
|
if(replace)
|
|
undefineRegion()
|
|
map |= block(Start,End)
|
|
return map
|
|
|
|
|
|
//Defines the region the map represents, as a CIRCLE!, sets map
|
|
//Returns the map
|
|
/datum/map_generator/proc/defineCircularRegion(turf/Start, turf/End, replace = 0)
|
|
if(!checkRegion(Start, End))
|
|
return 0
|
|
|
|
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/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()
|
|
|
|
//Even sphere correction engage
|
|
var/offByOneOffset = 1
|
|
if(bigZ % 2 == 0)
|
|
offByOneOffset = 0
|
|
|
|
for(var/i in lilZ to bigZ+offByOneOffset)
|
|
var/theRadius = radius
|
|
if(i != sphereMagic)
|
|
theRadius = max(radius/max((2*abs(sphereMagic-i)),1),1)
|
|
|
|
|
|
map |= circle_range(locate(centerX,centerY,i),theRadius)
|
|
|
|
|
|
return map
|
|
|
|
|
|
//Empties the map list, he's dead jim.
|
|
/datum/map_generator/proc/undefineRegion()
|
|
map = list() //bai bai
|
|
|
|
|
|
//Checks for and Rejects bad region coordinates
|
|
//Returns 1/0
|
|
/datum/map_generator/proc/checkRegion(turf/Start, turf/End)
|
|
if(!Start || !End)
|
|
return FALSE //Just bail
|
|
|
|
if(Start.x > world.maxx || End.x > world.maxx)
|
|
return FALSE
|
|
if(Start.y > world.maxy || End.y > world.maxy)
|
|
return FALSE
|
|
if(Start.z > world.maxz || End.z > world.maxz)
|
|
return FALSE
|
|
return TRUE
|
|
|
|
|
|
//Requests the mapGeneratorModule(s) to (re)generate
|
|
/datum/map_generator/proc/generate()
|
|
syncModules()
|
|
if(!modules || !modules.len)
|
|
return
|
|
for(var/datum/map_generator_module/mod in modules)
|
|
INVOKE_ASYNC(mod, TYPE_PROC_REF(/datum/map_generator_module, generate))
|
|
|
|
|
|
//Requests the mapGeneratorModule(s) to (re)generate this one turf
|
|
/datum/map_generator/proc/generateOneTurf(turf/T)
|
|
if(!T)
|
|
return
|
|
syncModules()
|
|
if(!modules || !modules.len)
|
|
return
|
|
for(var/datum/map_generator_module/mod in modules)
|
|
INVOKE_ASYNC(mod, TYPE_PROC_REF(/datum/map_generator_module, place), T)
|
|
|
|
|
|
//Replaces all paths in the module list with actual module datums
|
|
/datum/map_generator/proc/initialiseModules()
|
|
for(var/path in modules)
|
|
if(ispath(path))
|
|
modules.Remove(path)
|
|
modules |= new path
|
|
syncModules()
|
|
|
|
|
|
//Sync mapGeneratorModule(s) to mapGenerator
|
|
/datum/map_generator/proc/syncModules()
|
|
for(var/datum/map_generator_module/mod in modules)
|
|
mod.sync(src)
|
|
|
|
|
|
|
|
///////////////////////////
|
|
// HERE BE DEBUG DRAGONS //
|
|
///////////////////////////
|
|
|
|
/client/proc/debugNatureMapGenerator()
|
|
set name = "Test Nature Map Generator"
|
|
set category = "Debug"
|
|
|
|
var/datum/map_generator/nature/N = new()
|
|
var/startInput = input(usr,"Start turf of Map, (X;Y;Z)", "Map Gen Settings", "1;1;1") as text|null
|
|
|
|
if (isnull(startInput))
|
|
return
|
|
|
|
var/endInput = input(usr,"End turf of Map (X;Y;Z)", "Map Gen Settings", "[world.maxx];[world.maxy];[mob ? mob.z : 1]") as text|null
|
|
|
|
if (isnull(endInput))
|
|
return
|
|
|
|
//maxx maxy and current z so that if you fuck up, you only fuck up one entire z level instead of the entire universe
|
|
if(!startInput || !endInput)
|
|
to_chat(src, "Missing Input")
|
|
return
|
|
|
|
var/list/startCoords = splittext(startInput, ";")
|
|
var/list/endCoords = splittext(endInput, ";")
|
|
if(!startCoords || !endCoords)
|
|
to_chat(src, "Invalid Coords")
|
|
to_chat(src, "Start Input: [startInput]")
|
|
to_chat(src, "End Input: [endInput]")
|
|
return
|
|
|
|
var/turf/Start = locate(text2num(startCoords[1]),text2num(startCoords[2]),text2num(startCoords[3]))
|
|
var/turf/End = locate(text2num(endCoords[1]),text2num(endCoords[2]),text2num(endCoords[3]))
|
|
if(!Start || !End)
|
|
to_chat(src, "Invalid Turfs")
|
|
to_chat(src, "Start Coords: [startCoords[1]] - [startCoords[2]] - [startCoords[3]]")
|
|
to_chat(src, "End Coords: [endCoords[1]] - [endCoords[2]] - [endCoords[3]]")
|
|
return
|
|
|
|
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 (Cancel to leave unchanged from defaults)","Map Gen Settings") as null|anything in clusters
|
|
//null for default
|
|
|
|
var/theCluster = 0
|
|
if(moduleClusters != "None")
|
|
if(!clusters[moduleClusters])
|
|
to_chat(src, "Invalid Cluster Flags")
|
|
return
|
|
theCluster = clusters[moduleClusters]
|
|
else
|
|
theCluster = CLUSTER_CHECK_NONE
|
|
|
|
if(theCluster)
|
|
for(var/datum/map_generator_module/M in N.modules)
|
|
M.clusterCheckFlags = theCluster
|
|
|
|
|
|
to_chat(src, "Defining Region")
|
|
N.defineRegion(Start, End)
|
|
to_chat(src, "Region Defined")
|
|
to_chat(src, "Generating Region")
|
|
N.generate()
|
|
to_chat(src, "Generated Region")
|