Skip to content

Commit

Permalink
map management
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Sep 20, 2024
1 parent 72c2af1 commit c1e02f1
Show file tree
Hide file tree
Showing 35 changed files with 280 additions and 347 deletions.
44 changes: 22 additions & 22 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -611,28 +611,27 @@
#include "code\controllers\subsystem\job\joining.dm"
#include "code\controllers\subsystem\job\roundstart.dm"
#include "code\controllers\subsystem\job\spawnpoints.dm"
#include "code\controllers\subsystem\mapping\_mapping.dm"
#include "code\controllers\subsystem\mapping\allocation.dm"
#include "code\controllers\subsystem\mapping\boot.dm"
#include "code\controllers\subsystem\mapping\levels.dm"
#include "code\controllers\subsystem\mapping\maps.dm"
#include "code\controllers\subsystem\mapping\misc.dm"
#include "code\controllers\subsystem\mapping\obfuscation.dm"
#include "code\controllers\subsystem\mapping\reservations.dm"
#include "code\controllers\subsystem\mapping\level_helpers\air.dm"
#include "code\controllers\subsystem\mapping\level_helpers\attributes.dm"
#include "code\controllers\subsystem\mapping\level_helpers\baseturf.dm"
#include "code\controllers\subsystem\mapping\level_helpers\linkage.dm"
#include "code\controllers\subsystem\mapping\level_helpers\lookup.dm"
#include "code\controllers\subsystem\mapping\level_helpers\structs.dm"
#include "code\controllers\subsystem\mapping\level_helpers\traits.dm"
#include "code\controllers\subsystem\mapping\level_helpers\virtualization.dm"
#include "code\controllers\subsystem\mapping\spatial_helpers\angle.dm"
#include "code\controllers\subsystem\mapping\spatial_helpers\dir.dm"
#include "code\controllers\subsystem\mapping\spatial_helpers\distance.dm"
#include "code\controllers\subsystem\mapping\spatial_helpers\loc.dm"
#include "code\controllers\subsystem\mapping\spatial_helpers\stack.dm"
#include "code\controllers\subsystem\mapping\spatial_helpers\step.dm"
#include "code\controllers\subsystem\mapping\mapping-allocation.dm"
#include "code\controllers\subsystem\mapping\mapping-boot.dm"
#include "code\controllers\subsystem\mapping\mapping-levels.dm"
#include "code\controllers\subsystem\mapping\mapping-maps.dm"
#include "code\controllers\subsystem\mapping\mapping-misc.dm"
#include "code\controllers\subsystem\mapping\mapping-obfuscation.dm"
#include "code\controllers\subsystem\mapping\mapping-reservations.dm"
#include "code\controllers\subsystem\mapping\mapping.dm"
#include "code\controllers\subsystem\mapping\level\mapping-level-air.dm"
#include "code\controllers\subsystem\mapping\level\mapping-level-attributes.dm"
#include "code\controllers\subsystem\mapping\level\mapping-level-baseturf.dm"
#include "code\controllers\subsystem\mapping\level\mapping-level-lookup.dm"
#include "code\controllers\subsystem\mapping\level\mapping-level-structs.dm"
#include "code\controllers\subsystem\mapping\level\mapping-level-traits.dm"
#include "code\controllers\subsystem\mapping\level\mapping-level-virtualization.dm"
#include "code\controllers\subsystem\mapping\spatial\mapping-spatial-stack.dm"
#include "code\controllers\subsystem\mapping\virtual\mapping-virtual-angle.dm"
#include "code\controllers\subsystem\mapping\virtual\mapping-virtual-coords.dm"
#include "code\controllers\subsystem\mapping\virtual\mapping-virtual-dir.dm"
#include "code\controllers\subsystem\mapping\virtual\mapping-virtual-step.dm"
#include "code\controllers\subsystem\mapping\virtual\mapping-vritual-dist.dm"
#include "code\controllers\subsystem\networks\_networks.dm"
#include "code\controllers\subsystem\networks\simple.dm"
#include "code\controllers\subsystem\persistence\bunker.dm"
Expand Down Expand Up @@ -2118,6 +2117,7 @@
#include "code\modules\admin\callproc\callproc.dm"
#include "code\modules\admin\DB ban\functions.dm"
#include "code\modules\admin\functions\modify_traits.dm"
#include "code\modules\admin\modals\upload_map_sector.dm"
#include "code\modules\admin\permissionverbs\permissionedit.dm"
#include "code\modules\admin\secrets\admin_secrets\admin_logs.dm"
#include "code\modules\admin\secrets\admin_secrets\alter_narsie.dm"
Expand Down
78 changes: 0 additions & 78 deletions code/controllers/subsystem/mapping/_mapping.dm

This file was deleted.

File renamed without changes.
14 changes: 0 additions & 14 deletions code/controllers/subsystem/mapping/level_helpers/linkage.dm

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@
* I do not recommend anyone use this unless they absolutely know what they're doing.
* (if you think you need this, you probably don't, to be blunt.)
*/
/datum/controller/subsystem/mapping
// list of levels ready for reuse
var/static/list/reusable_levels = list()

// todo: recover()
// todo: add this module to recover()
// todo: zclear system will be in this later, for now, this is just a wrapper

/datum/controller/subsystem/mapping/on_max_z_changed(old_z_count, new_z_count)
. = ..()
// just to make sure order of ops / assumptions are right
ASSERT(length(ordered_levels) == world.maxz)

/**
* gets an reusable level, or increments world.maxz
* WARNING: AFTER THIS, YOU NEED TO USE THE LEVEL, OR READD TO REUSABLE, OR THIS IS A MEMORY LEAK!
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,6 @@
*
* All adds/removes should go through this. Directly modifying zlevel amount/whatever is forbidden.
*/
/datum/controller/subsystem/mapping
//* level lookups
/// indexed level datums
var/static/list/datum/map_level/ordered_levels = list()
/// k-v id to level datum lookup
var/static/list/datum/map_level/keyed_levels = list()
/// typepath to level datum lookup
/// we do that because we automatically generate level ids
/// so we can't use initial(id)
var/static/list/datum/map_level/typed_levels = list()

//* level fluff lookups
/// literally just a random hexadecimal store to prevent collision
var/static/list/random_fluff_level_hashes = list()

//* multiz core
/// Ordered lookup list for multiz up
var/list/cached_level_up
/// Ordered lookup list for multiz down
var/list/cached_level_down
/// Ordered lookup list for east transition
var/list/cached_level_east
/// Ordered lookup list for west transition
var/list/cached_level_west
/// Ordered lookup list for north transition
var/list/cached_level_north
/// Ordered lookup list for south transition
var/list/cached_level_south
/// Z access lookup - z = list() of zlevels it can directly access vertically
/// * For performance, this is currently only including bidirectional links
/// * For performance, this does not support looping.
/// * This is a direct stack lookup. This does not take map_struct's into account.
/// * You should only be using this for technical use cases like z-rendering and whatnot,
/// for fluff this is not sufficient to determine if something is actually above/below if it's not actually connected.
var/list/z_stack_lookup
/// does z stack lookup need a rebuild?
var/z_stack_dirty = TRUE

//* struct system
/// Active world_structs
var/static/list/datum/map_struct/structs = list()
/// World struct lookup by level
var/static/list/datum/map_struct/struct_by_z = list()

//* Rebuilds / Caching

Expand All @@ -69,7 +26,6 @@
SYNC(cached_level_north)
SYNC(cached_level_south)
SYNC(z_stack_lookup)
SYNC(struct_by_z)
z_stack_dirty = FALSE
if(.)
z_stack_dirty = TRUE
Expand Down Expand Up @@ -446,12 +402,6 @@
z_stack_lookup.len = world.maxz
var/list/left = list()
for(var/z in 1 to world.maxz)
// todo: stacks
// if(struct_by_z[z])
// var/datum/world_struct/struct = struct_by_z[z]
// z_stack_lookup[z] = struct.stack_lookup[struct.real_indices.Find(z)]
// else
// left += z
left += z
var/list/datum/map_level/bottoms = list()
// let's sing the bottom song
Expand Down Expand Up @@ -500,9 +450,5 @@
var/datum/map_level/level = ordered_levels[z]
level.link_above = null
level.link_below = null
// if(struct_by_z[z])
// var/datum/world_struct/struct = struct_by_z[z]
// struct.Deconstruct()
// qdel(struct)
stack_trace("WARNING: Up/Down loops found in zlevels [english_list(loops)]. This is not allowed and will cause both falling and zcopy to infinitely loop. All zlevels involved have been disconnected, and any structs involved have been destroyed.")
rebuild_verticality()
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,6 @@
*
* Allows dynamic loading of clusters of zlevels (maps) and the initialization of the server with a single station map.
*/
/datum/controller/subsystem/mapping
/// station is loaded
var/world_is_loaded = FALSE
/// loaded station map
var/static/datum/map/station/loaded_station
/// next station map
var/datum/map/station/next_station
/// loaded maps
var/static/list/datum/map/loaded_maps = list()
/// available maps - k-v lookup by id
var/list/datum/map/keyed_maps

/datum/controller/subsystem/mapping/Shutdown()
. = ..()
write_next_map()

/**
* initializes the key-value store of map datums.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@
* * It is usually already too late by the time Initialize() fires.
* * By default, /datum/map (not /datum/map_level), /datum/map_template, /datum/shuttle_template are the three things that form new mangling boundaries/contexts.
*/
/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()
/// round-local hash storage for specific map ids, reverse lookup
var/static/round_local_mangling_reverse_cache = list()
/// round-local hash storage for obfuscated ids
var/static/round_local_obfuscation_cache = list()
/// round-local hash storage for obfuscated ids, reverse lookup
var/static/round_local_obfuscation_reverse_cache = list()

/**
* Called at init first thing to setup mangling data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,6 @@
/**
* turf reservation system
*/
/datum/controller/subsystem/mapping
/// reserved levels allocated
var/static/reserved_level_count = 0
/// reserved turfs allowed - we can over-allocate this if we're only going to be slightly over and can always allocate atleast one level.
var/static/reserved_turfs_max = 192 * 192 * 3
/// allocated space reservations
var/static/list/datum/turf_reservation/reservations = list()
/// list of reserved z-indices for fast access
var/static/list/reserve_levels = list()
/// doing some blocking op on reservation system
var/static/reservation_blocking_op = FALSE
/// singleton area holding all free reservation turfs
var/static/area/reservation_unused/reservation_unallocated_area = new
/// spatial grid of turf reservations. the owner of a chunk is the bottom left tile's owner.
///
/// this is a list with length of world.maxz, with the actual spatial grid list being at the index of the z
/// e.g. to grab a reserved level's lookup, do `reservation_spatia_lookups[z_index]`
///
/// * null means that a level isn't a reservation level
/// * this also means that we can't zclear / 'free' reserved levels; they're effectively immovable due to this datastructure
/// * if it is a reserved level, it returns the spatial grid
/// * to get a chunk, do `spatial_lookup[ceil(where.x / TURF_CHUNK_RESOLUTION) + (ceil(where.y / TURF_CHUNK_RESOLUTION) - 1) * ceil(world.maxx / TURF_CHUNK_RESOLUTION)]`
/// * being in border counts as being in the reservation. you won't be soon, though.
var/static/list/reservation_spatial_lookups = list()

/datum/controller/subsystem/mapping/on_max_z_changed(old_z_count, new_z_count)
. = ..()
if(length(reservation_spatial_lookups) < new_z_count)
reservation_spatial_lookups.len = new_z_count

/datum/controller/subsystem/mapping/Recover()
. = ..()
reservation_blocking_op = FALSE

/**
* allocate a new reservation level
Expand Down
Loading

0 comments on commit c1e02f1

Please sign in to comment.