Give multiple copies of shuttles their own area instances (#39890)

This commit is contained in:
Tad Hardesty
2018-08-27 03:04:48 -07:00
committed by yogstation13-bot
parent f272ae8192
commit 4c846aa4aa
12 changed files with 33 additions and 35 deletions

View File

@@ -577,14 +577,9 @@ Turf and target are separate in case you want to teleport some distance from a t
//Takes: Area type as a text string from a variable.
//Returns: Instance for the area in the world.
/proc/get_area_instance_from_text(areatext)
var/areainstance = null
if(istext(areatext))
areatext = text2path(areatext)
for(var/V in GLOB.sortedAreas)
var/area/A = V
if(A.type == areatext)
areainstance = V
return areainstance
return GLOB.areas_by_type[areatext]
//Takes: Area type as text string or as typepath OR an instance of the area.
//Returns: A list of all areas of that type in the world.

View File

@@ -35,5 +35,7 @@ GLOBAL_LIST_EMPTY(vr_spawnpoints)
//used by jump-to-area etc. Updated by area/updateName()
GLOBAL_LIST_EMPTY(sortedAreas)
/// An association from typepath to area instance. Only includes areas with `unique` set.
GLOBAL_LIST_EMPTY(areas_by_type)
GLOBAL_LIST_EMPTY(all_abstract_markers)

View File

@@ -567,7 +567,7 @@ SUBSYSTEM_DEF(job)
SendToAtom(M, pick(latejoin_trackers), buckle)
else
//bad mojo
var/area/shuttle/arrival/A = locate() in GLOB.sortedAreas
var/area/shuttle/arrival/A = GLOB.areas_by_type[/area/shuttle/arrival]
if(A)
//first check if we can find a chair
var/obj/structure/chair/C = locate() in A

View File

@@ -46,6 +46,8 @@
var/noteleport = FALSE //Are you forbidden from teleporting to the area? (centcom, mobs, wizard, hand teleporter)
var/hidden = FALSE //Hides area from player Teleport function.
var/safe = FALSE //Is the area teleport-safe: no space / radiation / aggresive mobs / other dangers
/// If false, loading multiple maps with this area type will create multiple instances.
var/unique = TRUE
var/no_air = null
@@ -82,6 +84,12 @@ GLOBAL_LIST_EMPTY(teleportlocs)
// ===
/area/New()
// This interacts with the map loader, so it needs to be set immediately
// rather than waiting for atoms to initialize.
if (unique)
GLOB.areas_by_type[type] = src
return ..()
/area/Initialize()
icon_state = ""
@@ -135,6 +143,8 @@ GLOBAL_LIST_EMPTY(teleportlocs)
power_change() // all machines set to current power level, also updates icon
/area/Destroy()
if(GLOB.areas_by_type[type] == src)
GLOB.areas_by_type[type] = null
STOP_PROCESSING(SSobj, src)
return ..()

View File

@@ -10,6 +10,8 @@
always_unpowered = FALSE
valid_territory = FALSE
icon_state = "shuttle"
// Loading the same shuttle map at a different time will produce distinct area instances.
unique = FALSE
/area/shuttle/Initialize()
if(!canSmoothWithAreas)
@@ -103,6 +105,7 @@
/area/shuttle/arrival
name = "Arrival Shuttle"
unique = TRUE // SSjob refers to this area for latejoiners
/area/shuttle/pod_1
name = "Escape Pod One"

View File

@@ -539,7 +539,7 @@ GLOBAL_LIST_EMPTY(possible_items_special)
/datum/objective/capture/check_completion()//Basically runs through all the mobs in the area to determine how much they are worth.
var/captured_amount = 0
var/area/centcom/holding/A = locate() in GLOB.sortedAreas
var/area/centcom/holding/A = GLOB.areas_by_type[/area/centcom/holding]
for(var/mob/living/carbon/human/M in A)//Humans.
if(M.stat == DEAD)//Dead folks are worth less.
captured_amount+=0.5

View File

@@ -76,7 +76,7 @@
return 0
/datum/spellbook_entry/proc/Refund(mob/living/carbon/human/user,obj/item/spellbook/book) //return point value or -1 for failure
var/area/wizard_station/A = locate() in GLOB.sortedAreas
var/area/wizard_station/A = GLOB.areas_by_type[/area/wizard_station]
if(!(user in A.contents))
to_chat(user, "<span class='warning'>You can only refund spells at the wizard lair</span>")
return -1

View File

@@ -167,7 +167,7 @@
LZ = get_turf(beacon)
beacon.update_status(SP_LAUNCH)
else if (!usingBeacon)//find a suitable supplypod landing zone in cargobay
landingzone = locate(/area/quartermaster/storage) in GLOB.sortedAreas
landingzone = GLOB.areas_by_type[/area/quartermaster/storage]
if (!landingzone)
WARNING("[src] couldnt find a Quartermaster/Storage (aka cargobay) area on the station, and as such it has set the supplypod landingzone to the area it resides in.")
landingzone = get_area(src)
@@ -185,7 +185,7 @@
update_icon()
else
if(SO.pack.cost * (0.72*MAX_EMAG_ROCKETS) <= SSshuttle.points) // bulk discount :^)
landingzone = locate(pick(GLOB.the_station_areas)) in GLOB.sortedAreas //override default landing zone
landingzone = GLOB.areas_by_type[pick(GLOB.the_station_areas)] //override default landing zone
for(var/turf/open/floor/T in landingzone.contents)
if(is_blocked_turf(T))
continue

View File

@@ -177,7 +177,7 @@
/obj/machinery/computer/holodeck/proc/generate_program_list()
for(var/typekey in subtypesof(program_type))
var/area/holodeck/A = locate(typekey) in GLOB.sortedAreas
var/area/holodeck/A = GLOB.areas_by_type[typekey]
if(!A || !A.contents.len)
continue
var/list/info_this = list()

View File

@@ -138,6 +138,7 @@
// Do not call except via load() above.
/datum/parsed_map/proc/_load_impl(x_offset = 1, y_offset = 1, z_offset = world.maxz + 1, cropMap = FALSE, no_changeturf = FALSE, x_lower = -INFINITY, x_upper = INFINITY, y_lower = -INFINITY, y_upper = INFINITY, placeOnTop = FALSE)
var/list/areaCache = list()
var/list/modelCache = build_cache(no_changeturf)
var/space_key = modelCache[SPACE_KEY]
var/list/bounds
@@ -182,7 +183,7 @@
var/list/cache = modelCache[model_key]
if(!cache)
CRASH("Undefined model key in DMM: [model_key]")
build_coordinate(cache, xcrd, ycrd, zcrd, no_afterchange, placeOnTop)
build_coordinate(areaCache, cache, locate(xcrd, ycrd, zcrd), no_afterchange, placeOnTop)
// only bother with bounds that actually exist
bounds[MAP_MINX] = min(bounds[MAP_MINX], xcrd)
@@ -292,7 +293,7 @@
.[model_key] = list(members, members_attributes)
/datum/parsed_map/proc/build_coordinate(list/model, xcrd as num, ycrd as num, zcrd as num, no_changeturf as num, placeOnTop as num)
/datum/parsed_map/proc/build_coordinate(list/areaCache, list/model, turf/crds, no_changeturf as num, placeOnTop as num)
var/index
var/list/members = model[1]
var/list/members_attributes = model[2]
@@ -302,20 +303,17 @@
////////////////
//The next part of the code assumes there's ALWAYS an /area AND a /turf on a given tile
var/turf/crds = locate(xcrd,ycrd,zcrd)
//first instance the /area and remove it from the members list
index = members.len
if(members[index] != /area/template_noop)
var/atom/instance
GLOB._preloader.setup(members_attributes[index])//preloader for assigning set variables on atom creation
var/atype = members[index]
for(var/area/A in world)
if(A.type == atype)
instance = A
break
if(!instance)
instance = new atype(null)
var/atom/instance = areaCache[atype]
if (!instance)
instance = GLOB.areas_by_type[atype]
if (!instance)
instance = new atype(null)
areaCache[atype] = instance
if(crds)
instance.contents.Add(crds)

View File

@@ -32,12 +32,7 @@
// The underlying old area is the area assumed to be under the shuttle's starting location
// If it no longer/has never existed it will be created
var/area/underlying_old_area
for(var/i in GLOB.sortedAreas) // Locate grabs subtypes and we want a particular type
var/area/place = i
if(place.type == underlying_area_type)
underlying_old_area = place
break
var/area/underlying_old_area = GLOB.areas_by_type[underlying_area_type]
if(!underlying_old_area)
underlying_old_area = new underlying_area_type(null)

View File

@@ -435,12 +435,7 @@
var/list/old_turfs = return_ordered_turfs(x, y, z, dir)
var/area/underlying_area
for(var/i in GLOB.sortedAreas)
var/area/place = i
if(place.type == underlying_area_type)
underlying_area = place
break
var/area/underlying_area = GLOB.areas_by_type[underlying_area_type]
if(!underlying_area)
underlying_area = new underlying_area_type(null)