mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 12:35:33 +01:00
Mafia now starts without admin intervention (#79348)
## About The Pull Request Mafia should now start without the need of admin intervention. I made a unit test that should always have a PDA and a ghost spawning in a game of Mafia and having it run through basic setup to confirm they both successfully sign up and the game starts. I had to change a lot of things in order to get this working, such as giving unique ckeys to mock clients, fixing harddels in Mafia, and plenty of minor fixes. This is the first time any of this code is put in CI, so a lot of uncaught errors are now showing their faces. Because loading maps mid-round runtimes due to smoothing, I have mafia their own unit test-only map that doesn't use smoothing. I also split the mafia ui code into its own file, and moved a single helper that was sitting around in mafia's file into a helpers file. I also added some comments to explain why certain things are the way they are, because I wrote some undocumented code previously and forgot a few things, leading to self-inflicted wasted time. ## Why It's Good For The Game ^ ## Changelog 🆑 fix: Mafia games can now start properly. /🆑 --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
///This type is responsible for any map generation behavior that is done in areas, override this to allow for
|
||||
///area-specific map generation. This generation is ran by areas in initialize.
|
||||
/datum/map_generator
|
||||
|
||||
//Map information
|
||||
var/list/map = list()
|
||||
///Map information, such as the start and end turfs of the map generation.
|
||||
var/list/turf/map = list()
|
||||
|
||||
//mapGeneratorModule information
|
||||
var/list/modules = list()
|
||||
///The map generator modules that we will generate and sync to.
|
||||
var/list/datum/map_generator_module/modules = list()
|
||||
|
||||
var/buildmode_name = "Undocumented"
|
||||
|
||||
@@ -14,6 +16,18 @@
|
||||
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()
|
||||
|
||||
/datum/map_generator/Destroy(force, ...)
|
||||
. = ..()
|
||||
QDEL_LIST(modules)
|
||||
|
||||
///This proc will be ran by areas on Initialize, and provides the areas turfs as argument to allow for generation.
|
||||
/datum/map_generator/proc/generate_terrain(list/turfs, area/generate_in)
|
||||
return
|
||||
|
||||
/// Populate terrain with flora, fauna, features and basically everything that isn't a turf.
|
||||
/datum/map_generator/proc/populate_terrain(list/turfs, area/generate_in)
|
||||
return
|
||||
|
||||
//Defines the region the map represents, sets map
|
||||
//Returns the map
|
||||
/datum/map_generator/proc/defineRegion(turf/Start, turf/End, replace = 0)
|
||||
@@ -22,7 +36,7 @@
|
||||
|
||||
if(replace)
|
||||
undefineRegion()
|
||||
map |= block(Start,End)
|
||||
map |= block(Start, End)
|
||||
return map
|
||||
|
||||
|
||||
@@ -56,7 +70,7 @@
|
||||
theRadius = max(radius/max((2*abs(sphereMagic-i)),1),1)
|
||||
|
||||
|
||||
map |= circle_range(locate(centerX,centerY,i),theRadius)
|
||||
map |= circle_range(locate(centerX, centerY, i),theRadius)
|
||||
|
||||
|
||||
return map
|
||||
@@ -87,7 +101,7 @@
|
||||
syncModules()
|
||||
if(!modules || !modules.len)
|
||||
return
|
||||
for(var/datum/map_generator_module/mod in modules)
|
||||
for(var/datum/map_generator_module/mod as anything in modules)
|
||||
INVOKE_ASYNC(mod, TYPE_PROC_REF(/datum/map_generator_module, generate))
|
||||
|
||||
|
||||
@@ -98,7 +112,7 @@
|
||||
syncModules()
|
||||
if(!modules || !modules.len)
|
||||
return
|
||||
for(var/datum/map_generator_module/mod in modules)
|
||||
for(var/datum/map_generator_module/mod as anything in modules)
|
||||
INVOKE_ASYNC(mod, TYPE_PROC_REF(/datum/map_generator_module, place), T)
|
||||
|
||||
|
||||
@@ -113,7 +127,7 @@
|
||||
|
||||
//Sync mapGeneratorModule(s) to mapGenerator
|
||||
/datum/map_generator/proc/syncModules()
|
||||
for(var/datum/map_generator_module/mod in modules)
|
||||
for(var/datum/map_generator_module/mod as anything in modules)
|
||||
mod.sync(src)
|
||||
|
||||
|
||||
@@ -127,12 +141,12 @@
|
||||
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
|
||||
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
|
||||
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
|
||||
@@ -158,9 +172,18 @@
|
||||
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/static/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
|
||||
@@ -175,7 +198,7 @@
|
||||
theCluster = CLUSTER_CHECK_NONE
|
||||
|
||||
if(theCluster)
|
||||
for(var/datum/map_generator_module/M in N.modules)
|
||||
for(var/datum/map_generator_module/M as anything in N.modules)
|
||||
M.clusterCheckFlags = theCluster
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
var/clusterCheckFlags = CLUSTER_CHECK_SAME_ATOMS
|
||||
var/allowAtomsOnSpace = FALSE
|
||||
|
||||
/datum/map_generator_module/Destroy(force, ...)
|
||||
mother = null
|
||||
return ..()
|
||||
|
||||
//Syncs the module up with its mother
|
||||
/datum/map_generator_module/proc/sync(datum/map_generator/mum)
|
||||
|
||||
Reference in New Issue
Block a user