Skip to content

Commit

Permalink
overmaps 1 - generation & spatial (#6550)
Browse files Browse the repository at this point in the history
here we go gamers
  • Loading branch information
silicons authored Jul 15, 2024
1 parent 48e5ea6 commit b0cec39
Show file tree
Hide file tree
Showing 33 changed files with 707 additions and 525 deletions.
7 changes: 5 additions & 2 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -4172,6 +4172,7 @@
#include "code\modules\organs\subtypes\nano.dm"
#include "code\modules\organs\subtypes\unbreakable.dm"
#include "code\modules\organs\subtypes\unseverable.dm"
#include "code\modules\overmap\object.dm"
#include "code\modules\overmap\public.dm"
#include "code\modules\overmap\entity\entity.dm"
#include "code\modules\overmap\entity\physics.dm"
Expand All @@ -4186,7 +4187,6 @@
#include "code\modules\overmap\legacy\overmap_planet.dm"
#include "code\modules\overmap\legacy\overmap_shuttle.dm"
#include "code\modules\overmap\legacy\sectors.dm"
#include "code\modules\overmap\legacy\spacetravel.dm"
#include "code\modules\overmap\legacy\disperser\disperser.dm"
#include "code\modules\overmap\legacy\disperser\disperser_charge.dm"
#include "code\modules\overmap\legacy\disperser\disperser_circuit.dm"
Expand All @@ -4206,8 +4206,11 @@
#include "code\modules\overmap\legacy\ships\engines\gas_thruster_vr.dm"
#include "code\modules\overmap\legacy\ships\engines\ion_thruster.dm"
#include "code\modules\overmap\map\area.dm"
#include "code\modules\overmap\map\object.dm"
#include "code\modules\overmap\map\overmap.dm"
#include "code\modules\overmap\map\overmap_template.dm"
#include "code\modules\overmap\map\overmap_template_layer.dm"
#include "code\modules\overmap\map\turf.dm"
#include "code\modules\overmap\map\template_layers\legacy_events.dm"
#include "code\modules\overmap\tiled\tiled.dm"
#include "code\modules\paperwork\adminpaper.dm"
#include "code\modules\paperwork\carbonpaper.dm"
Expand Down
4 changes: 0 additions & 4 deletions code/controllers/subsystem/mapping/_mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ SUBSYSTEM_DEF(mapping)
// load world - this also initializes our first reserved level, which is compiled in.
load_station()

// perform snowflake legacy init stuff
// todo: refactor
if(!(LEGACY_MAP_DATUM).overmap_z)
build_overmap()
// todo: refactor - Set up antagonists.
populate_antag_type_list()
// todo: refactor - Set up spawn points.
Expand Down
3 changes: 3 additions & 0 deletions code/controllers/subsystem/mapping/obfuscation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/**
* Obfuscation module
*
* todo: should this be mapping? this is a lot more important than just mapping
*
* * Generates **mangled** IDs; these are either persistently-unique or round-local IDs that are separate per map / map template.
* * Generates **obfuscated** IDs; these are mangled and obfuscated IDs that are safe to reveal to players.
*
Expand All @@ -14,6 +16,7 @@
*/
/datum/controller/subsystem/mapping
/// used to ensure global-ness
// todo: should this be here? this is used literally everywhere
var/static/round_global_descriptor
/// round-local hash storage for specific map ids
var/static/round_local_mangling_cache = list()
Expand Down
122 changes: 120 additions & 2 deletions code/controllers/subsystem/overmap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ SUBSYSTEM_DEF(overmaps)
subsystem_flags = SS_NO_FIRE
init_order = INIT_ORDER_OVERMAPS

/// overmap by id
// todo: recover
var/static/list/datum/overmap/overmap_by_id = list()

/// im so sorry bros dont hurt me please--
/// (eventually we'll have proper bindings but for now, uh, this is how it is!)
var/const/default_overmap_id = "main"

/datum/controller/subsystem/overmaps/Initialize()
if((LEGACY_MAP_DATUM).use_overmap)
GLOB.overmap_event_handler.create_events((LEGACY_MAP_DATUM).overmap_z, (LEGACY_MAP_DATUM).overmap_size, (LEGACY_MAP_DATUM).overmap_event_areas)
make_default_overmap()
rebuild_helm_computers()
return ..()

//! legacy code below

/datum/controller/subsystem/overmaps/proc/rebuild_helm_computers()
for(var/obj/machinery/computer/ship/helm/H in GLOB.machines)
H.get_known_sectors()
Expand All @@ -17,3 +26,112 @@ SUBSYSTEM_DEF(overmaps)
if(!initialized)
return
addtimer(CALLBACK(src, PROC_REF(rebuild_helm_computers)), 0, TIMER_UNIQUE)

/*
/client/proc/overmap_upload()
set name = "Instantiate Overmap"
set category = "Debug"
var/are_you_sure = alert(
src,
"Instantiating overmaps is an advanced feature. \
The uploaded file is placed and instantiated as an overmap; only overmap tiles, overmap entities, and overmap tile entities \
should exist in the file, or you may have funny things happen and the server explode. \
Are you sure you know what you are doing?",
"Upload Overmap",
"No",
"Yes",
)
if(are_you_sure != "Yes")
return
var/map = input(src, "Select overmap .dmm", "Instantiate Overmap") as file|null
if(!map)
return
var/datum/dmm_parsed/parsed_map = parse_map(map)
if(!parsed_map.parsed)
alert(src, "Failed to parse map.", "Parse Error")
return
var/max_x = world.maxx - TURF_CHUNK_RESOLUTION * 2
var/max_y = world.maxy - TURF_CHUNK_RESOLUTION * 2
if(parsed_map.width >= max_x || parsed_map.height >= max_y)
alert(src, "Your map is too big for the current world size. Maximum: [max_x]x[max_y]", "Improper Dimensions")
return
// welcome to hell
// allocate turf reservation and load at offset
// from this point on, if we crash, we don't warn the user, because it shouldn't be possible to crash
var/datum/overmap_template/template = new
template.width = parsed_map.width
template.height = parsed_map.height
var/datum/overmap/creating = new("loaded-[rand(1, 1000000)]", template)
creating.initialize()
// loaded, load the map template in there
var/datum/dmm_context/loaded_context = parsed_map.load(
creating.reservation.bottom_left_coords[1],
creating.reservation.bottom_left_coords[2],
creating.reservation.bottom_left_coords[3],
)
// initialize
SSatoms.init_map_bounds(loaded_context)
var/llx = loaded_context.loaded_bounds[MAP_MINX]
var/lly = loaded_context.loaded_bounds[MAP_MINY]
var/llz = loaded_context.loaded_bounds[MAP_MINZ]
// announce
log_and_message_admins("overmap [creating.id] with dimensions [creating.width]x[creating.height] loaded at LL-bounds [llx], [lly], [llz]")
*/

//! end

//* Overmap Management *//

/**
* i don't know what to put here
* this isn't a good long-term proc but for now it's fine
*/
/datum/controller/subsystem/overmaps/proc/get_or_load_default_overmap()
if(overmap_by_id[default_overmap_id])
return overmap_by_id[default_overmap_id]
make_default_overmap()
return overmap_by_id[default_overmap_id]


/datum/controller/subsystem/overmaps/proc/make_default_overmap()
if(overmap_by_id[default_overmap_id])
return
var/datum/map/station/map_datum = SSmapping.loaded_station
if(!map_datum.use_overmap)
return
var/datum/overmap_template/legacy_default/using_default_template = new(map_datum.overmap_size, map_datum.overmap_size, event_clouds = map_datum.overmap_event_areas)
create_overmap_from_template(using_default_template, default_overmap_id)

/datum/controller/subsystem/overmaps/proc/create_overmap_from_template(datum/overmap_template/templatelike, use_id)
if(ispath(templatelike))
templatelike = new templatelike
// make sure template is valid
ASSERT(istype(templatelike))
// get template into another var
var/datum/overmap_template/template = templatelike
// get id or generate
var/id = use_id || generate_overmap_id()
ASSERT(!overmap_by_id[id])
// make overmap
var/datum/overmap/creating = new(id, template)
// instantiation
creating.initialize()
// done
return creating

/datum/controller/subsystem/overmaps/proc/generate_overmap_id()
var/potential
var/safety = 1000
do
if(safety-- <= 0)
CRASH("failed to generate overmap id - too many loops")
potential = "[SSmapping.round_global_descriptor && "[SSmapping.round_global_descriptor]-"][copytext(md5("[rand(1, 1000000)]"), 1, 5)]"
while(overmap_by_id[potential])
return potential
5 changes: 4 additions & 1 deletion code/controllers/subsystem/spatial_grids.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ SUBSYSTEM_DEF(spatial_grids)

/// /living mobs. they don't have to be alive, just a subtype of /living.
var/datum/spatial_grid/living
/// /obj/overmap/entity's
var/datum/spatial_grid/overmap_entities

/datum/controller/subsystem/spatial_grids/Initialize()
make_grids()
return ..()

/datum/controller/subsystem/spatial_grids/proc/make_grids()
living = new /datum/spatial_grid(/mob/living, 16)
living = new /datum/spatial_grid(/mob/living)
overmap_entities = new /datum/spatial_grid(/obj/overmap/entity)

/datum/controller/subsystem/spatial_grids/on_max_z_changed(old_z_count, new_z_count)
. = ..()
Expand Down
1 change: 1 addition & 0 deletions code/datums/components/turfs/reservation_border.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* todo: allow simulation of specific atmos instead of just RESERVED_TURF_TYPe
*/
/datum/component/reservation_border
can_transfer = TRUE
var/atom/movable/mirage_border/holder1
var/atom/movable/mirage_border/holder2
var/atom/movable/mirage_border/holder3
Expand Down
46 changes: 0 additions & 46 deletions code/game/atoms/movable/movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -231,52 +231,6 @@
if(mover.loc in locs)
. = TRUE

/atom/movable/proc/touch_map_edge()
if(z in (LEGACY_MAP_DATUM).sealed_levels)
return

if((LEGACY_MAP_DATUM).use_overmap)
overmap_spacetravel(get_turf(src), src)
return

var/move_to_z = src.get_transit_zlevel()
if(move_to_z)
var/new_z = move_to_z
var/new_x
var/new_y

if(x <= TRANSITIONEDGE)
new_x = world.maxx - TRANSITIONEDGE - 2
new_y = rand(TRANSITIONEDGE + 2, world.maxy - TRANSITIONEDGE - 2)

else if (x >= (world.maxx - TRANSITIONEDGE + 1))
new_x = TRANSITIONEDGE + 1
new_y = rand(TRANSITIONEDGE + 2, world.maxy - TRANSITIONEDGE - 2)

else if (y <= TRANSITIONEDGE)
new_y = world.maxy - TRANSITIONEDGE -2
new_x = rand(TRANSITIONEDGE + 2, world.maxx - TRANSITIONEDGE - 2)

else if (y >= (world.maxy - TRANSITIONEDGE + 1))
new_y = TRANSITIONEDGE + 1
new_x = rand(TRANSITIONEDGE + 2, world.maxx - TRANSITIONEDGE - 2)

if(SSticker && istype(SSticker.mode, /datum/game_mode/nuclear)) // Only really care if the game mode is nuclear
var/datum/game_mode/nuclear/G = SSticker.mode
G.check_nuke_disks()

var/turf/T = locate(new_x, new_y, new_z)
if(istype(T))
forceMove(T)

//by default, transition randomly to another zlevel
/atom/movable/proc/get_transit_zlevel()
var/list/candidates = SSmapping.crosslinked_levels()
candidates -= z
if(!length(candidates))
return
return pick(candidates)

// Returns the current scaling of the sprite.
// Note this DOES NOT measure the height or width of the icon, but returns what number is being multiplied with to scale the icons, if any.
/atom/movable/proc/get_icon_scale_x()
Expand Down
3 changes: 0 additions & 3 deletions code/game/gamemodes/events/dust.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ The "dust" will damage the hull of the station causin minor hull breaches.
walk(src, 0) // Because we might have called walk_towards, we must stop the walk loop or BYOND keeps an internal reference to us forever.
return ..()

/obj/effect/space_dust/touch_map_edge()
qdel(src)

/obj/effect/space_dust/Bump(atom/A)
. = ..()
hit(A)
Expand Down
3 changes: 0 additions & 3 deletions code/game/machinery/nuclear_bomb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,3 @@ var/bomb_set
log_game("[src], the last authentication disk, has been destroyed. Spawning [D] at ([D.x], [D.y], [D.z]).")
nuke_disks -= src
return ..()

/obj/item/disk/nuclear/touch_map_edge()
qdel(src)
71 changes: 0 additions & 71 deletions code/game/mecha/combat/fighter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,77 +61,6 @@
. = ..()
consider_gravity()

//We don't get lost quite as easy.
/obj/mecha/combat/fighter/touch_map_edge()
//No overmap enabled or no driver to choose
if(!(LEGACY_MAP_DATUM).use_overmap || !occupant || !can_ztravel())
return ..()

var/obj/overmap/entity/visitable/our_ship = get_overmap_sector(z)

//We're not on the overmap
if(!our_ship)
return ..()

//Stored for safety checking after user input
var/this_x = x
var/this_y = y
var/this_z = z
var/this_occupant = occupant

var/what_edge

var/new_x
var/new_y
var/new_z

if(x <= TRANSITIONEDGE)
what_edge = WEST
new_x = world.maxx - TRANSITIONEDGE - 2
new_y = rand(TRANSITIONEDGE + 2, world.maxy - TRANSITIONEDGE - 2)

else if (x >= (world.maxx - TRANSITIONEDGE + 1))
what_edge = EAST
new_x = TRANSITIONEDGE + 1
new_y = rand(TRANSITIONEDGE + 2, world.maxy - TRANSITIONEDGE - 2)

else if (y <= TRANSITIONEDGE)
what_edge = SOUTH
new_y = world.maxy - TRANSITIONEDGE -2
new_x = rand(TRANSITIONEDGE + 2, world.maxx - TRANSITIONEDGE - 2)

else if (y >= (world.maxy - TRANSITIONEDGE + 1))
what_edge = NORTH
new_y = TRANSITIONEDGE + 1
new_x = rand(TRANSITIONEDGE + 2, world.maxx - TRANSITIONEDGE - 2)

var/list/choices = list()
for(var/obj/overmap/entity/visitable/V in range(1, our_ship))
choices[V.name] = V

var/choice = input("Choose an overmap destination:", "Destination", null) as null|anything in choices
if(!choice)
var/backwards = turn(what_edge, 180)
forceMove(get_step(src,backwards)) //Move them back a step, then.
setDir(backwards)
return
else
var/obj/overmap/entity/visitable/V = choices[choice]
if(occupant != this_occupant || this_x != x || this_y != y || this_z != z || get_dist(V,our_ship) > 1) //Sanity after user input
to_chat(occupant, "<span class='warning'>You or they appear to have moved!</span>")
return
var/list/levels = V.get_space_zlevels()
if(!levels.len)
to_chat(occupant, "<span class='warning'>You don't appear to be able to get there from here!</span>")
return
new_z = pick(levels)
var/turf/destination = locate(new_x, new_y, new_z)
if(!destination || destination.density)
to_chat(occupant, "<span class='warning'>You don't appear to be able to get there from here! Is it blocked?</span>")
return
else
forceMove(destination)

//Modified phazon code
/obj/mecha/combat/fighter/Topic(href, href_list)
..()
Expand Down
Loading

0 comments on commit b0cec39

Please sign in to comment.