Skip to content

Commit

Permalink
that
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Sep 20, 2024
1 parent c1e02f1 commit b07c1e3
Show file tree
Hide file tree
Showing 23 changed files with 170 additions and 104 deletions.
6 changes: 4 additions & 2 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@
#include "code\__DEFINES\dcs\signals\signals_turf.dm"
#include "code\__DEFINES\dcs\signals\datums\signals_beam.dm"
#include "code\__DEFINES\dcs\signals\datums\signals_beam_legacy.dm"
#include "code\__DEFINES\dcs\signals\datums\signals_map_level.dm"
#include "code\__DEFINES\dcs\signals\datums\signals_map_struct.dm"
#include "code\__DEFINES\dcs\signals\datums\signals_perspective.dm"
#include "code\__DEFINES\dcs\signals\elements\signals_element_conflict_checking.dm"
#include "code\__DEFINES\dcs\signals\items\signals_inducer.dm"
Expand Down Expand Up @@ -561,8 +563,8 @@
#include "code\controllers\subsystem\nanoui.dm"
#include "code\controllers\subsystem\nightshift.dm"
#include "code\controllers\subsystem\overlays.dm"
#include "code\controllers\subsystem\overmap.dm"
#include "code\controllers\subsystem\overmap_physics.dm"
#include "code\controllers\subsystem\overmaps.dm"
#include "code\controllers\subsystem\parallax.dm"
#include "code\controllers\subsystem\pathfinder.dm"
#include "code\controllers\subsystem\photography.dm"
Expand Down Expand Up @@ -623,7 +625,6 @@
#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"
Expand Down Expand Up @@ -3260,6 +3261,7 @@
#include "code\modules\lore_hardcoded\species\xenomorph_hybrid\origin.dm"
#include "code\modules\lore_hardcoded\species\xenomorph_hybrid\religion.dm"
#include "code\modules\mapping\map.dm"
#include "code\modules\mapping\map_level-load.dm"
#include "code\modules\mapping\map_level.dm"
#include "code\modules\mapping\map_struct.dm"
#include "code\modules\mapping\map_template.dm"
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals/datums/signals_map_level.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

#define COMSIG_MAP_LEVEL_LOADED "loaded"
#define COMSIG_MAP_LEVEL_UNLOADED "unloaded"
5 changes: 5 additions & 0 deletions code/__DEFINES/dcs/signals/datums/signals_map_struct.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

#define COMSIG_MAP_STRUCT_CONSTRUCTED "constructed"
#define COMSIG_MAP_STRUCT_DECONSTRUCTED "deconstructed"
17 changes: 0 additions & 17 deletions code/controllers/subsystem/mapping/level/mapping-level-structs.dm

This file was deleted.

25 changes: 1 addition & 24 deletions code/controllers/subsystem/mapping/mapping-levels.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,6 @@
* All adds/removes should go through this. Directly modifying zlevel amount/whatever is forbidden.
*/

//* Rebuilds / Caching

/datum/controller/subsystem/mapping/on_max_z_changed(old_z_count, new_z_count)
. = ..()
synchronize_datastructures()

/**
* Ensure all synchronized lists are valid
*/
/datum/controller/subsystem/mapping/proc/synchronize_datastructures()
#define SYNC(var) if(!var) { var = list() ; } ; if(var.len != world.maxz) { . = TRUE ; var.len = world.maxz; }
. = FALSE
SYNC(cached_level_up)
SYNC(cached_level_down)
SYNC(cached_level_east)
SYNC(cached_level_west)
SYNC(cached_level_north)
SYNC(cached_level_south)
SYNC(z_stack_lookup)
z_stack_dirty = FALSE
if(.)
z_stack_dirty = TRUE
#undef SYNC

/**
* Call whenever a zlevel's up/down is modified
*
Expand Down Expand Up @@ -184,6 +160,7 @@
level_or_path.z_index = z_index
ordered_levels[z_index] = level_or_path
level_or_path.loaded = TRUE
SEND_SIGNAL(levle_or_path, COMSIG_MAP_LEVEL_LOADED)

Check failure on line 163 in code/controllers/subsystem/mapping/mapping-levels.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "levle_or_path"

Check failure on line 163 in code/controllers/subsystem/mapping/mapping-levels.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "levle_or_path"

Check failure on line 163 in code/controllers/subsystem/mapping/mapping-levels.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "levle_or_path"
. = level_or_path

if(isnull(level_or_path.display_id))
Expand Down
19 changes: 19 additions & 0 deletions code/controllers/subsystem/mapping/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,25 @@ SUBSYSTEM_DEF(mapping)
reservation_spatial_lookups.len = new_z_count
// just to make sure order of ops / assumptions are right
ASSERT(length(ordered_levels) == world.maxz)
synchronize_datastructures()

/**
* Ensure all synchronized lists are valid
*/
/datum/controller/subsystem/mapping/proc/synchronize_datastructures()
#define SYNC(var) if(!var) { var = list() ; } ; if(var.len != world.maxz) { . = TRUE ; var.len = world.maxz; }
. = FALSE
SYNC(cached_level_up)
SYNC(cached_level_down)
SYNC(cached_level_east)
SYNC(cached_level_west)
SYNC(cached_level_north)
SYNC(cached_level_south)
SYNC(z_stack_lookup)
z_stack_dirty = FALSE
if(.)
z_stack_dirty = TRUE
#undef SYNC

//! Legacy Below !//

Expand Down
11 changes: 4 additions & 7 deletions code/controllers/subsystem/overmap_physics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ SUBSYSTEM_DEF(overmap_physics)
/// currentrun
var/list/obj/overmap/entity/running

//* Global Tuning *//
//* Global Tuning *//
//* Sim tuning goes in here; not balance *//
//* Example: 'thrust mult' is balance, 'sim speed' is sim. *//

/// hard movement limit in pixels / tick
///
Expand All @@ -23,15 +25,10 @@ SUBSYSTEM_DEF(overmap_physics)
if(!resumed)
src.running = src.moving.Copy()
var/list/obj/overmap/entity/running = src.running
// tick_lag is in deciseconds
// in ticker, our wait is that many ds
// in non-ticker, our wait is either wait in ds, or a minimum of tick_lag in ds
// we convert it to seconds with * 0.1
var/dt = (subsystem_flags & SS_TICKER? (wait * world.tick_lag) : max(world.tick_lag, wait)) * 0.1
var/index = 0
for(index in length(running) to 1 step -1)
var/obj/overmap/entity/to_run = running[index]
to_run.physics_tick(dt)
to_run.physics_tick(nominal_dt_s)
if(MC_TICK_CHECK)
break
running.len -= length(running) - index
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,29 @@ SUBSYSTEM_DEF(overmaps)
/// (eventually we'll have proper bindings but for now, uh, this is how it is!)
var/const/default_overmap_id = "main"

//* Global Tuning *//

//* Global Tuning *//
//* Balance tuning goes in here; not sim *//
//* Example: 'thrust mult' is balance, 'sim speed' is sim. *//
/// applied to all ship thrust
var/global_thrust_multiplier = 2

//* Level System *//

/// Z-level ownership lookup
///
/// * Automatically managed by /datum/overmap_location registration
var/static/list/datum/overmap_location/level_ownership_lookup = list()

/datum/controller/subsystem/overmaps/Initialize()
make_default_overmap()
rebuild_helm_computers()
return ..()

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

//! legacy code below

/datum/controller/subsystem/overmaps/proc/rebuild_helm_computers()
Expand Down
41 changes: 41 additions & 0 deletions code/modules/mapping/map_level-load.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

/**
* Contains loading / unloading logic.
*/

//* Loading *//

/**
* called right after we physically load in, before init
* called before atom init
*
* this is *not* called if we are created from a zlevel, say, when dynamically generating a planet.
* this is solely for hardcoded map levels to have load behaviors.
* undefined behavior will result if this is overridden on a level used for dynamic generation.
*
* @params
* * z_index - zlevel we loaded on
* * generation_callbacks - callbacks to add to perform post_loaded generation. this will be done in a batch before on_loaded_finalize and before atom init.
*/
/datum/map_level/proc/on_loaded_immediate(z_index, list/datum/callback/additional_generation)
return

/**
* called in a group after all maps and dependencies load **and** generation callbacks fire.
* called after atom init
*
* this is *not* called if we are created from a zlevel, say, when dynamically generating a planet.
* this is solely for hardcoded map levels to have load behaviors.
* undefined behavior will result if this is overridden on a level used for dynamic generation.
*
* @params
* * z_index - zlevel we loaded on
*/
/datum/map_level/proc/on_loaded_finalize(z_index)
return

//* Unloading *//

// No hooks yet.
29 changes: 0 additions & 29 deletions code/modules/mapping/map_level.dm
Original file line number Diff line number Diff line change
Expand Up @@ -410,35 +410,6 @@
return RESOLVE(link_below)
#undef RESOLVE

/**
* called right after we physically load in, before init
* called before atom init
*
* this is *not* called if we are created from a zlevel, say, when dynamically generating a planet.
* this is solely for hardcoded map levels to have load behaviors.
* undefined behavior will result if this is overridden on a level used for dynamic generation.
*
* @params
* * z_index - zlevel we loaded on
* * generation_callbacks - callbacks to add to perform post_loaded generation. this will be done in a batch before on_loaded_finalize and before atom init.
*/
/datum/map_level/proc/on_loaded_immediate(z_index, list/datum/callback/additional_generation)
return

/**
* called in a group after all maps and dependencies load **and** generation callbacks fire.
* called after atom init
*
* this is *not* called if we are created from a zlevel, say, when dynamically generating a planet.
* this is solely for hardcoded map levels to have load behaviors.
* undefined behavior will result if this is overridden on a level used for dynamic generation.
*
* @params
* * z_index - zlevel we loaded on
*/
/datum/map_level/proc/on_loaded_finalize(z_index)
return

/**
* allow deallocation/unload
*/
Expand Down
4 changes: 4 additions & 0 deletions code/modules/mapping/map_struct.dm
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@

constructed = TRUE

SEND_SIGNAL(src, COMSIG_MAP_STRUCT_CONSTRUCTED)

/**
* Completely destroys our state and unbinds levels.
*/
Expand All @@ -266,6 +268,8 @@

constructed = FALSE

SEND_SIGNAL(src, COMSIG_MAP_STRUCT_DECONSTRUCTED)

//* Helpers *//

/proc/cmp_map_level_struct_z(datum/map_level/A, datum/map_level/B)
Expand Down
14 changes: 10 additions & 4 deletions code/modules/overmap/entity/entity-location.dm
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

/**
* Checks if we're actually loaded in
*/
/obj/overmap/entity/proc/is_loaded_into_world()
return !isnull(location)

/**
* get our z-level indices
*
* * entities that are on z's like shuttles instead of owning them use the z level they're on
*
* @return null if there are none / this is not semantically an entity on a z, and list() if we're not in a level right now.
* @return list() of indices; empty list is possible.
*/
/obj/overmap/entity/proc/get_z_indices()
RETURN_TYPE(/list)
return location?.get_z_indices()
return location ? location.get_owned_z_indices() : list()

/**
* get our owned z-level indices
*
* * shuttles and similar entities don't own their indices.
*
* @return null if this is not semantically an entity on a z, and list() if none are owned, otherwise
* @return list() of indices; empty list is possible.
*/
/obj/overmap/entity/proc/get_owned_z_indices()
RETURN_TYPE(/list)
return location?.get_owned_z_indices()
return location ? location.get_owned_z_indices() : list()
4 changes: 4 additions & 0 deletions code/modules/overmap/entity/entity-physics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
/obj/overmap/entity/process(delta_time)
physics_tick(delta_time)

/**
* @params
* * dt - time passed in seconds
*/
/obj/overmap/entity/proc/physics_tick(dt)
if(!overmap || !isturf(loc))
initialize_physics()
Expand Down
2 changes: 2 additions & 0 deletions code/modules/overmap/entity/entity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
/obj/overmap/entity/Destroy()
// stop physics
deactivate_physics()
// unbind location
QDEL_NULL(location)
return ..()

/obj/overmap/entity/set_glide_size(new_glide_size, recursive)
Expand Down
22 changes: 22 additions & 0 deletions code/modules/overmap/entity/overmap_location.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@
/// owning entity, if any
var/obj/overmap/entity/entity

/datum/overmap_location/New(location, obj/overmap/entity/entity)
if(entity)
if(entity.location)
stack_trace("entity [entity] already had a location")
else
src.entity = entity
if(location)
bind(location)

/datum/overmap_location/Destroy()
if(entity.location == src)
entity.location = null
entity = null
unbind()
return ..()

/datum/overmap_location/proc/bind(location)
CRASH("unimplemented proc called")

/datum/overmap_location/proc/unbind()
CRASH("unimplemented proc called")

/**
* get our z-level indices
*
Expand Down
10 changes: 10 additions & 0 deletions code/modules/overmap/entity/overmap_location/level.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
/// the map level we're bound to
var/datum/map_level/level

/datum/overmap_location/level/bind(datum/map_level/location)
if(!istype(location))
CRASH("unexpected type")
#warn impl

/datum/overmap_location/level/unbind()
if(!level)
return
#warn impl

/datum/overmap_location/level/get_z_indices()

/datum/overmap_location/level/get_z_index_random()
Expand Down
Loading

0 comments on commit b07c1e3

Please sign in to comment.