Skip to content

Commit

Permalink
runtime maploading 2/3: multiz update (#6145)
Browse files Browse the repository at this point in the history
3/3 is world structs and the fun that comes with that

this pr has:

- transitions
- new multiz system
- lookup optimizations
- misc updates

---------

Co-authored-by: silicons <[email protected]>
  • Loading branch information
silicons and silicons authored Nov 27, 2023
1 parent d8d0b5b commit e2dae42
Show file tree
Hide file tree
Showing 127 changed files with 17,366 additions and 16,863 deletions.
30 changes: 17 additions & 13 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
#include "code\__DEFINES\vote.dm"
#include "code\__DEFINES\vv.dm"
#include "code\__DEFINES\wires.dm"
#include "code\__DEFINES\z_levels.dm"
#include "code\__DEFINES\_flags\_flags.dm"
#include "code\__DEFINES\_flags\area_flags.dm"
#include "code\__DEFINES\_flags\atom_flags.dm"
Expand Down Expand Up @@ -579,6 +578,13 @@
#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\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\networks\_networks.dm"
#include "code\controllers\subsystem\networks\simple.dm"
#include "code\controllers\subsystem\persistence\_persistence.dm"
Expand Down Expand Up @@ -723,6 +729,7 @@
#include "code\datums\components\riding\mob\robot.dm"
#include "code\datums\components\riding\simple\_simple.dm"
#include "code\datums\components\riding\vehicle\_vehicle.dm"
#include "code\datums\components\turfs\transition_border.dm"
#include "code\datums\design\design.dm"
#include "code\datums\design\design_holder.dm"
#include "code\datums\design\designs\sheets.dm"
Expand Down Expand Up @@ -3086,8 +3093,6 @@
#include "code\modules\mapping\map_level.dm"
#include "code\modules\mapping\map_template.dm"
#include "code\modules\mapping\minimaps.dm"
#include "code\modules\mapping\multiz_helpers.dm"
#include "code\modules\mapping\paint.dm"
#include "code\modules\mapping\shuttle.dm"
#include "code\modules\mapping\submap.dm"
#include "code\modules\mapping\submaps_legacy.dm"
Expand All @@ -3101,6 +3106,7 @@
#include "code\modules\mapping\map_helpers\baseturf.dm"
#include "code\modules\mapping\map_helpers\component_injector.dm"
#include "code\modules\mapping\map_helpers\engine_loader.dm"
#include "code\modules\mapping\map_helpers\paint.dm"
#include "code\modules\mapping\map_helpers\network_builder\_network_builder.dm"
#include "code\modules\mapping\map_helpers\network_builder\power_cable.dm"
#include "code\modules\mapping\spawner\_spawner.dm"
Expand Down Expand Up @@ -3872,19 +3878,17 @@
#include "code\modules\movespeed\modifiers\misc.dm"
#include "code\modules\movespeed\modifiers\mob.dm"
#include "code\modules\multiz\atoms.dm"
#include "code\modules\multiz\basic.dm"
#include "code\modules\multiz\basic_legacy.dm"
#include "code\modules\multiz\core.dm"
#include "code\modules\multiz\falling.dm"
#include "code\modules\multiz\hoist.dm"
#include "code\modules\multiz\ladder.dm"
#include "code\modules\multiz\ladder_assembly_vr.dm"
#include "code\modules\multiz\level_data.dm"
#include "code\modules\multiz\map_data.dm"
#include "code\modules\multiz\movement.dm"
#include "code\modules\multiz\open_turf.dm"
#include "code\modules\multiz\pipes.dm"
#include "code\modules\multiz\structures.dm"
#include "code\modules\multiz\structures_vr.dm"
#include "code\modules\multiz\turf.dm"
#include "code\modules\multiz\structures\hoist.dm"
#include "code\modules\multiz\structures\ladder.dm"
#include "code\modules\multiz\structures\pipes.dm"
#include "code\modules\multiz\structures\stairs.dm"
#include "code\modules\multiz\structures\vorestation_portals.dm"
#include "code\modules\multiz\turfs\open.dm"
#include "code\modules\multiz\zmimic\_mimic_docs.dm"
#include "code\modules\multiz\zmimic\mimic_common.dm"
#include "code\modules\multiz\zmimic\mimic_movable.dm"
Expand Down
8 changes: 7 additions & 1 deletion code/__DEFINES/_flags/atom_flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
/// Atom queued to SSoverlay for compile_overlays
#define ATOM_OVERLAY_QUEUED (1<<3)
/// Atom is absolute-abstract - should not be interactable or movable in any way shape or form
/// This is for stuff like lighting.
#define ATOM_ABSTRACT (1<<4)
/// Atom is not considered a game world object.
/// This means semantic "wipe game world state" things like turf.empty(), saving, loading, etc, should ignore it,
/// but the atom is not abstract.
#define ATOM_NONWORLD (1<<5)
/// uses integrity, and is broken
#define ATOM_BROKEN (1<<5)
#define ATOM_BROKEN (1<<6)
/// Used for items if they don't want to get a blood overlay.
#define NOBLOODY (1<<7) // TODO: item flag
/// Reagents don't react inside this container.
Expand Down Expand Up @@ -50,6 +55,7 @@ DEFINE_BITFIELD(atom_flags, list(
BITFIELD(ATOM_HEAR),
BITFIELD(ATOM_OVERLAY_QUEUED),
BITFIELD(ATOM_ABSTRACT),
BITFIELD(ATOM_NONWORLD),
BITFIELD(ATOM_BROKEN),
BITFIELD(NOBLOODY),
BITFIELD(NOREACT),
Expand Down
6 changes: 4 additions & 2 deletions code/__DEFINES/mapping/levels.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
/// Default - don't preprocess for unlinked sides, just leave them empty
#define Z_LINKAGE_NORMAL "normal"
/// Crosslinked - crosslink with other crosslinked zlevels at random using some semblence of continuity
#define Z_LINKAGE_CROSSLINKED "crosslink"
// todo: crosslink support
// #define Z_LINKAGE_CROSSLINKED "crosslink"
/// Selflooping - automatically link to itself for unlinked sides
#define Z_LINKAGE_SELFLOOP "selfloop"
// todo: selfloop support
// #define Z_LINKAGE_SELFLOOP "selfloop"

//? "transition"

Expand Down
16 changes: 16 additions & 0 deletions code/__DEFINES/mapping/multiz.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,19 @@

/// these flags mean a fall should stop
#define FALL_FLAGS_STOP (FALL_BLOCKED | FALL_RECOVERED | FALL_TERMINATED)

/// there's a level above
#define Z_HAS_ABOVE(z) (!isnull(SSmapping.cached_level_up[z]))
/// there's a level below
#define Z_HAS_BELOW(z) (!isnull(SSmapping.cached_level_down[z]))

/// get turf below this turf, if any
/// we are at the mercy of zmimic when we do this. do not use in critical maploader code.
#define TURF_BELOW_ISH(T) (T.below || T.below())
/// get turf above this turf, if any
/// we are at the mercy of zmimic when we do this. do not use in critical maploader code.
#define TURF_ABOVE_ISH(T) (T.above || T.above())

/// we should use get virtual step due to our x/y being border
/// we do not get step this, so use it on something **on** game world. (aka turf or on turf).
#define AT_MAP_BORDER(A) (A.x == 2 || A.y == 2 || A.x == world.maxx - 1 || A.y == world.maxy - 1)
2 changes: 1 addition & 1 deletion code/__DEFINES/turfs/type_generation.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

/// create the standard 4 types of turfs for a given turf type.
#define CREATE_STANDARD_TURFS(type) \
##type/indoors { \
outdoors = FALSE; \
Expand Down
2 changes: 0 additions & 2 deletions code/__DEFINES/z_levels.dm

This file was deleted.

19 changes: 14 additions & 5 deletions code/_globals/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ GLOBAL_LIST_INIT(bitfields, generate_bitfields())
"TRANSPARENT" = TRANSPARENT,
"AMOUNT_VISIBLE" = AMOUNT_VISIBLE,
"NO_REACT" = NO_REACT,
),
),
"sight" = list(
"SEE_INFRA" = SEE_INFRA,
"SEE_SELF" = SEE_SELF,
Expand All @@ -70,9 +70,18 @@ GLOBAL_LIST_INIT(bitfields, generate_bitfields())
"SEE_PIXELS" = SEE_PIXELS,
"SEE_THRU" = SEE_THRU,
"SEE_BLACKNESS" = SEE_BLACKNESS,
"BLIND" = BLIND
),

)
"BLIND" = BLIND,
),
"vis_flags" = list(
"VIS_INHERIT_ICON" = VIS_INHERIT_ICON,
"VIS_INHERIT_ICON_STATE" = VIS_INHERIT_ICON_STATE,
"VIS_INHERIT_DIR" = VIS_INHERIT_DIR,
"VIS_INHERIT_LAYER" = VIS_INHERIT_LAYER,
"VIS_INHERIT_PLANE" = VIS_INHERIT_PLANE,
"VIS_INHERIT_ID" = VIS_INHERIT_ID,
"VIS_UNDERLAY" = VIS_UNDERLAY,
"VIS_HIDE" = VIS_HIDE,
),
)

#undef FLAG
4 changes: 2 additions & 2 deletions code/controllers/subsystem/air.dm
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ SUBSYSTEM_DEF(air)
gas_string = A.initial_gas_mix
// 2. check if it's special and should look up the level's defaults
switch(gas_string)
if(ATMOSPHERE_USE_INDOORS)
gas_string = SSmapping.lookup_outdoors_air(turf_context.z)
if(ATMOSPHERE_USE_OUTDOORS)
gas_string = SSmapping.lookup_outdoors_air(turf_context.z)
if(ATMOSPHERE_USE_INDOORS)
gas_string = SSmapping.lookup_indoors_air(turf_context.z)
// 3: process atmosphere
if(generated_atmospheres[gas_string])
Expand Down
4 changes: 3 additions & 1 deletion code/controllers/subsystem/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ SUBSYSTEM_DEF(lighting)
. += 1
if (TURF_IS_AMBIENT_LIT_UNSAFE(T))
T.generate_missing_corners() // Forcibly generate corners.

else
if(!T.lighting_disable_fullbright)
T.add_overlay(/obj/effect/fullbright, TRUE)
CHECK_TICK

// It's safe to pass a list of non-turfs to this list - it'll only check turfs.
Expand Down
10 changes: 6 additions & 4 deletions code/controllers/subsystem/mapping/level_helpers/linkage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
*/
/datum/controller/subsystem/mapping/proc/crosslinked_levels()
RETURN_TYPE(/list)
. = list()
for(var/datum/map_level/L as anything in ordered_levels)
if(L.linkage == Z_LINKAGE_CROSSLINKED)
. += L.z_index
return list()
// todo: crosslink support
// . = list()
// for(var/datum/map_level/L as anything in ordered_levels)
// if(L.linkage == Z_LINKAGE_CROSSLINKED)
// . += L.z_index
50 changes: 47 additions & 3 deletions code/controllers/subsystem/mapping/level_helpers/lookup.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,51 @@
return ordered_levels[z]?.display_name

/**
* returns the z index of an id
* returns level datum in dir of level
*
* if diagonal, only returns a level if both steps are consistent with each other.
*/
/datum/controller/subsystem/mapping/proc/level_by_id(id)
return keyed_levels[id]?.z_index
/datum/controller/subsystem/mapping/proc/level_datum_in_dir(z, dir)
if(dir & (dir - 1))
// if diagonal, pass to level for advanced handling
return ordered_levels[z].level_in_dir(dir)?.z_index
var/index
switch(dir)
if(NORTH)
index = cached_level_north[z]
if(SOUTH)
index = cached_level_south[z]
if(EAST)
index = cached_level_east[z]
if(WEST)
index = cached_level_west[z]
if(UP)
index = cached_level_up[z]
if(DOWN)
index = cached_level_down[z]
return ordered_levels[index]

/**
* returns level index in dir of level
*
* if diagonal, only returns a level if both steps are consistent with each other.
*/
/datum/controller/subsystem/mapping/proc/level_index_in_dir(z, dir)
if(dir & (dir - 1))
// if diagonal, pass to level for advanced handling
return ordered_levels[z].level_in_dir(dir)
var/index
switch(dir)
if(NORTH)
index = cached_level_north[z]
if(SOUTH)
index = cached_level_south[z]
if(EAST)
index = cached_level_east[z]
if(WEST)
index = cached_level_west[z]
if(UP)
index = cached_level_up[z]
if(DOWN)
index = cached_level_down[z]
return index
14 changes: 14 additions & 0 deletions code/controllers/subsystem/mapping/level_helpers/virtualization.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2023 Citadel Station developers. *//

/**
* GAME PROC: is_level_virtualized(z)
* Checks if we should use GetVirtualCoords or similar for things like GPSes, radios
*
* Returns TRUE if:
* z is in a world_struct
*/
/datum/controller/subsystem/mapping/proc/is_level_virtualized(z)
// todo: world structs
return FALSE
// return !isnull(struct_by_z[z])
Loading

0 comments on commit e2dae42

Please sign in to comment.