Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports Mapping Backend updates #5165

Merged
merged 32 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c9af451
WIP
fira Dec 7, 2023
b0ce9b8
Testing 1
fira Dec 7, 2023
22e6c90
Testing 2
fira Dec 7, 2023
58d78fb
shuttle fixes
fira Dec 8, 2023
ac7d895
fix offset map loading
fira Dec 8, 2023
60e2d09
Testing 3
fira Dec 8, 2023
b3a089b
cleanup and comments
fira Dec 8, 2023
478f1ad
revert mass screenshot boundaries
fira Dec 8, 2023
22fe7f6
remove unused space_lit
fira Dec 8, 2023
fb4d6c2
add missing zlevel expansion locking
fira Dec 8, 2023
7c3ae30
mapping logging and unit test conditions
fira Dec 8, 2023
b519878
missing testing code
fira Dec 8, 2023
5700000
oops
fira Dec 8, 2023
95eb48f
refactor trijent elevator linking
fira Dec 8, 2023
bd278a0
Mass Screenshot boundary fixes
fira Dec 9, 2023
055ce65
Merge branch 'master' into backport-mapping
fira Dec 9, 2023
4ddd79b
Merge branch 'master' into backport-mapping
fira Dec 9, 2023
78d7804
fix master soft-conflict
fira Dec 9, 2023
b82c074
standardize world border and uses as cordon
fira Dec 9, 2023
13fece5
Merge branch 'master' into backport-mapping
fira Dec 10, 2023
332c287
revert weakrefs in used_turfs
fira Dec 10, 2023
6c3cb05
Merge branch 'master' into backport-mapping
fira Jan 2, 2024
62e3c6e
tutorial soft conflicts fix
fira Jan 2, 2024
1fb4bea
Merge branch 'master' into backport-mapping
harryob Jan 18, 2024
239f836
Merge branch 'master' into backport-mapping
fira Jan 21, 2024
6d6bf20
fix area initialization
fira Jan 23, 2024
80f27d3
unfudges shuttles with space turfs, fixes light loading, fixes max bo…
harryob Feb 21, 2024
274113e
makes this work with multiz properly...
harryob Feb 21, 2024
fefcb6a
bit horrid, but makes sure the bounds'll be set properly on multiz maps
harryob Feb 21, 2024
f0fc7ec
Merge branch 'master' into backport-mapping
harryob Feb 21, 2024
b3cd827
Merge remote-tracking branch 'origin/fira/maploader' into pr/fira/5165
harryob Feb 21, 2024
040d13a
place admins correctly in the middle of their nice new map
harryob Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions code/__DEFINES/__game.dm
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#define RANGE_TURFS(RADIUS, CENTER) \
block( \
locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \
locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \
)

//Admin perms are in global.dm.

/// To make it even more clear that something is a bitfield.
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/_math.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#define CEILING(x, y) ( -round(-(x) / (y)) * (y) )

#define ROUND_UP(x) ( -round(-(x)))

// round() acts like floor(x, 1) by default but can't handle other values
#define FLOOR(x, y) ( round((x) / (y)) * (y) )

Expand Down
3 changes: 2 additions & 1 deletion code/__DEFINES/dcs/signals/atom/signals_atom.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// From /atom/proc/Decorate
#define COMSIG_ATOM_DECORATED "atom_decorated"

//from SSatoms InitAtom - Only if the atom was not deleted or failed initialization and has a loc
#define COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON "atom_init_success_on"
///from base of atom/setDir(): (old_dir, new_dir). Called before the direction changes.
#define COMSIG_ATOM_DIR_CHANGE "atom_dir_change"

Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/dcs/signals/atom/signals_turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@

///from /turf/closed/wall/proc/place_poster
#define COMSIG_POSTER_PLACED "poster_placed"

///from base of /datum/turf_reservation/proc/Release: (datum/turf_reservation/reservation)
#define COMSIG_TURF_RESERVATION_RELEASED "turf_reservation_released"
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals/signals_global.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

///from base of datum/controller/subsystem/mapping/proc/add_new_zlevel(): (list/args)
#define COMSIG_GLOB_NEW_Z "!new_z"
/// sent after world.maxx and/or world.maxy are expanded: (has_exapnded_world_maxx, has_expanded_world_maxy)
#define COMSIG_GLOB_EXPANDED_WORLD_BOUNDS "!expanded_world_bounds"
///from base of datum/controller/subsystem/mapping/proc/add_new_zlevel(): (list/args)
#define COMSIG_GLOB_VEHICLE_ORDERED "!vehicle_ordered"
/// from /datum/controller/subsystem/ticker/fire
Expand Down
7 changes: 2 additions & 5 deletions code/__DEFINES/maps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,5 @@ require only minor tweaks.
#define MAP_ARMOR_STYLE_JUNGLE "jungle"
#define MAP_ARMOR_STYLE_PRISON "prison"

//turf-only flags
#define NOJAUNT_1 (1<<0)
#define UNUSED_RESERVATION_TURF (1<<1)
/// If a turf can be made dirty at roundstart. This is also used in areas.
#define CAN_BE_DIRTY_1 (1<<2)
/// A map key that corresponds to being one exclusively for Space.
#define SPACE_KEY "space"
5 changes: 5 additions & 0 deletions code/__DEFINES/objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,8 @@ GLOBAL_LIST_INIT(RESTRICTED_CAMERA_NETWORKS, list( //Those networks can only be
#define CHECKS_PASSED 1
#define STILL_ON_COOLDOWN 2
#define NO_LIGHT_STATE_CHANGE 3

//tool capabilities or something i don't know
#define REMOVE_CROWBAR (1<<0)
#define BREAK_CROWBAR (1<<1)
#define REMOVE_SCREWDRIVER (1<<2)
2 changes: 1 addition & 1 deletion code/__DEFINES/shuttles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define TRANSIT_REQUEST 1
#define TRANSIT_READY 2

#define SHUTTLE_TRANSIT_BORDER 8
#define SHUTTLE_TRANSIT_BORDER 16

#define PARALLAX_LOOP_TIME 25
#define HYPERSPACE_END_TIME 5
Expand Down
18 changes: 9 additions & 9 deletions code/__DEFINES/turf_flags.dm
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//turf_flags values
/// Marks a turf as organic. Used for alien wall and membranes.
#define TURF_ORGANIC (1<<0)
/// If a turf is an usused reservation turf awaiting assignment
#define UNUSED_RESERVATION_TURF (1<<1)
/// If a turf is a reserved turf
#define RESERVATION_TURF (1<<2)

//ChangeTurf options to change its behavior
#define CHANGETURF_DEFER_CHANGE (1<<0)
/// This flag prevents changeturf from gathering air from nearby turfs to fill the new turf with an approximation of local air
#define CHANGETURF_IGNORE_AIR (1<<1)
#define CHANGETURF_FORCEOP (1<<2)
/// A flag for PlaceOnTop to just instance the new turf instead of calling ChangeTurf. Used for uninitialized turfs NOTHING ELSE
#define CHANGETURF_SKIP (1<<3)

#define IS_OPAQUE_TURF(turf) (turf.directional_opacity == ALL_CARDINALS)

/// Marks a turf as organic. Used for alien wall and membranes.
#define TURF_ORGANIC (1<<0)


#define REMOVE_CROWBAR (1<<0)
#define BREAK_CROWBAR (1<<1)
#define REMOVE_SCREWDRIVER (1<<2)
29 changes: 29 additions & 0 deletions code/__DEFINES/turfs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#define RANGE_TURFS(RADIUS, CENTER) \
block( \
locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \
locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \
)

#define RECT_TURFS(H_RADIUS, V_RADIUS, CENTER) \
block( \
locate(max((CENTER).x-(H_RADIUS),1), max((CENTER).y-(V_RADIUS),1), (CENTER).z), \
locate(min((CENTER).x+(H_RADIUS),world.maxx), min((CENTER).y+(V_RADIUS),world.maxy), (CENTER).z) \
)

///Returns all turfs in a zlevel
#define Z_TURFS(ZLEVEL) block(locate(1,1,ZLEVEL), locate(world.maxx, world.maxy, ZLEVEL))

/// Returns a list of turfs in the rectangle specified by BOTTOM LEFT corner and height/width, checks for being outside the world border for you
#define CORNER_BLOCK(corner, width, height) CORNER_BLOCK_OFFSET(corner, width, height, 0, 0)

/// Returns a list of turfs similar to CORNER_BLOCK but with offsets
#define CORNER_BLOCK_OFFSET(corner, width, height, offset_x, offset_y) ((block(locate(corner.x + offset_x, corner.y + offset_y, corner.z), locate(min(corner.x + (width - 1) + offset_x, world.maxx), min(corner.y + (height - 1) + offset_y, world.maxy), corner.z))))

/// Returns an outline (neighboring turfs) of the given block
#define CORNER_OUTLINE(corner, width, height) ( \
CORNER_BLOCK_OFFSET(corner, width + 2, 1, -1, -1) + \
CORNER_BLOCK_OFFSET(corner, width + 2, 1, -1, height) + \
CORNER_BLOCK_OFFSET(corner, 1, height, -1, 0) + \
CORNER_BLOCK_OFFSET(corner, 1, height, width, 0))

#define TURF_FROM_COORDS_LIST(List) (locate(List[1], List[2], List[3]))
1 change: 1 addition & 0 deletions code/__DEFINES/typecheck/generic_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define ismovableatom(A) (ismovable(A))
#define isatom(A) (isloc(A))
#define isfloorturf(A) (istype(A, /turf/open/floor))
#define isclosedturf(A) (istype(A, /turf/closed))
#define isweakref(D) (istype(D, /datum/weakref))
#define isgenerator(A) (istype(A, /generator))

Expand Down
2 changes: 2 additions & 0 deletions code/__HELPERS/lighting.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define IS_OPAQUE_TURF(turf) (turf.directional_opacity == ALL_CARDINALS)

/// Produces a mutable appearance glued to the [EMISSIVE_PLANE] dyed to be the [EMISSIVE_COLOR].
/proc/emissive_appearance(icon, icon_state = "", layer = FLOAT_LAYER, alpha = 255, appearance_flags = NONE)
var/mutable_appearance/appearance = mutable_appearance(icon, icon_state, layer, EMISSIVE_PLANE, alpha, appearance_flags | EMISSIVE_APPEARANCE_FLAGS)
Expand Down
6 changes: 3 additions & 3 deletions code/__HELPERS/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@

//Copies a list, and all lists inside it recusively
//Does not copy any other reference type
/proc/deepCopyList(list/L)
/proc/deep_copy_list(list/L)
if(!islist(L))
return L
. = L.Copy()
Expand All @@ -545,10 +545,10 @@
continue
var/value = .[key]
if(islist(value))
value = deepCopyList(value)
value = deep_copy_list(value)
.[key] = value
if(islist(key))
key = deepCopyList(key)
key = deep_copy_list(key)
.[i] = key
.[key] = value

Expand Down
10 changes: 10 additions & 0 deletions code/__HELPERS/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ GLOBAL_PROTECT(config_error_log)
WRITE_LOG(GLOB.config_error_log, text)
SEND_TEXT(world.log, text)

/// Logging for mapping errors
/proc/log_mapping(text, skip_world_log)
#ifdef UNIT_TESTS
GLOB.unit_test_mapping_logs += text
#endif
if(skip_world_log)
return
WRITE_LOG(GLOB.mapping_log, text)
SEND_TEXT(world.log, text)

/proc/log_admin_private(text)
log_admin(text)

Expand Down
23 changes: 23 additions & 0 deletions code/__HELPERS/string_lists.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
GLOBAL_LIST_EMPTY(string_lists)

/**
* Caches lists with non-numeric stringify-able values (text or typepath).
*/
/proc/string_list(list/values)
var/string_id = values.Join("-")

. = GLOB.string_lists[string_id]

if(.)
return .

return GLOB.string_lists[string_id] = values

///A wrapper for baseturf string lists, to offer support of non list values, and a stack_trace if we have major issues
/proc/baseturfs_string_list(list/values, turf/baseturf_holder)
if(!islist(values))
return values //baseturf things
// return values
if(length(values) > 10)
return string_list(list(/turf/closed/cordon/debug))
return string_list(values)
18 changes: 18 additions & 0 deletions code/__HELPERS/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@

return ""

//Returns a string with reserved characters and spaces after the first and last letters removed
//Like trim(), but very slightly faster. worth it for niche usecases
/proc/trim_reduced(text)
var/starting_coord = 1
var/text_len = length(text)
for (var/i in 1 to text_len)
if (text2ascii(text, i) > 32)
starting_coord = i
break

for (var/i = text_len, i >= starting_coord, i--)
if (text2ascii(text, i) > 32)
return copytext(text, starting_coord, i + 1)

if(starting_coord > 1)
return copytext(text, starting_coord)
return ""

//Returns a string with reserved characters and spaces before the first word and after the last word removed.
/proc/trim(text)
return trim_left(trim_right(text))
Expand Down
14 changes: 11 additions & 3 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -820,14 +820,24 @@
animation.master = target
flick(flick_anim, animation)

//Will return the contents of an atom recursivly to a depth of 'searchDepth'
///Will return the contents of an atom recursivly to a depth of 'searchDepth', not including starting atom
/atom/proc/GetAllContents(searchDepth = 5, list/toReturn = list())
for(var/atom/part as anything in contents)
toReturn += part
if(part.contents.len && searchDepth)
part.GetAllContents(searchDepth - 1, toReturn)
return toReturn

///Returns the src and all recursive contents as a list. Includes the starting atom.
/atom/proc/get_all_contents(ignore_flag_1)
. = list(src)
var/i = 0
while(i < length(.))
var/atom/checked_atom = .[++i]
if(checked_atom.flags_atom & ignore_flag_1)
continue
. += checked_atom.contents

/// Returns list of contents of a turf recursively, much like GetAllContents
/// We only get containing atoms in the turf, excluding multitiles bordering on it
/turf/proc/GetAllTurfStrictContents(searchDepth = 5, list/toReturn = list())
Expand Down Expand Up @@ -1946,8 +1956,6 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)

return list(region_x1 & region_x2, region_y1 & region_y2)

#define TURF_FROM_COORDS_LIST(List) (locate(List[1], List[2], List[3]))

//Vars that will not be copied when using /DuplicateObject
GLOBAL_LIST_INIT(duplicate_forbidden_vars,list(
"tag", "datum_components", "area", "type", "loc", "locs", "vars", "parent", "parent_type", "verbs", "ckey", "key",
Expand Down
6 changes: 6 additions & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ DEFINE_BITFIELD(flags_atom, list(
"HTML_USE_INITAL_ICON" = HTML_USE_INITAL_ICON,
))

DEFINE_BITFIELD(turf_flags, list(
"TURF_ORGANIC" = TURF_ORGANIC,
"UNUSED_RESERVATION_TURF" = UNUSED_RESERVATION_TURF,
"RESERVATION_TURF" = RESERVATION_TURF,
))

DEFINE_BITFIELD(flags_item, list(
"NODROP" = NODROP,
"NOBLUDGEON" = NOBLUDGEON,
Expand Down
3 changes: 3 additions & 0 deletions code/_globalvars/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ GLOBAL_LIST_EMPTY(minimap_icons)

GLOBAL_LIST_EMPTY(mainship_pipes)

/// List of all the maps that have been cached for /proc/load_map
GLOBAL_LIST_EMPTY(cached_maps)

/proc/initiate_minimap_icons()
var/list/icons = list()
for(var/iconstate in icon_states('icons/UI_icons/map_blips.dmi'))
Expand Down
14 changes: 9 additions & 5 deletions code/controllers/subsystem/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ SUBSYSTEM_DEF(atoms)

var/list/BadInitializeCalls = list()

///initAtom() adds the atom its creating to this list iff InitializeAtoms() has been given a list to populate as an argument
var/list/created_atoms

initialized = INITIALIZATION_INSSATOMS

/datum/controller/subsystem/atoms/Initialize(timeofday)
Expand All @@ -34,7 +37,7 @@ SUBSYSTEM_DEF(atoms)
populate_seed_list()
return SS_INIT_SUCCESS

/datum/controller/subsystem/atoms/proc/InitializeAtoms(list/atoms)
/datum/controller/subsystem/atoms/proc/InitializeAtoms(list/atoms, list/atoms_to_return)
if(initialized == INITIALIZATION_INSSATOMS)
return

Expand Down Expand Up @@ -73,7 +76,10 @@ SUBSYSTEM_DEF(atoms)
processing_late_loaders = FALSE

/// Actually creates the list of atoms. Exists soley so a runtime in the creation logic doesn't cause initalized to totally break
/datum/controller/subsystem/atoms/proc/CreateAtoms(list/atoms)
/datum/controller/subsystem/atoms/proc/CreateAtoms(list/atoms, list/atoms_to_return = null)
if (atoms_to_return)
LAZYINITLIST(created_atoms)

#ifdef TESTING
var/count
#endif
Expand Down Expand Up @@ -152,12 +158,10 @@ SUBSYSTEM_DEF(atoms)
qdeleted = TRUE
else if(!(A.flags_atom & INITIALIZED))
BadInitializeCalls[the_type] |= BAD_INIT_DIDNT_INIT
/*
else
SEND_SIGNAL(A,COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZE)
SEND_SIGNAL(A, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON)
if(created_atoms && from_template && ispath(the_type, /atom/movable))//we only want to populate the list with movables
created_atoms += A.get_all_contents()
*/

return qdeleted || QDELING(A)

Expand Down
13 changes: 4 additions & 9 deletions code/controllers/subsystem/interior.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ SUBSYSTEM_DEF(interior)
var/height_to_request = template.height + INTERIOR_BORDER_SIZE
var/width_to_request = template.width + INTERIOR_BORDER_SIZE

var/datum/turf_reservation/reserved_area = SSmapping.RequestBlockReservation(width_to_request, height_to_request, type = /datum/turf_reservation/interior)
var/datum/turf_reservation/reserved_area = SSmapping.request_turf_block_reservation(width_to_request, height_to_request, reservation_type = /datum/turf_reservation/interior)

var/list/bottom_left = reserved_area.bottom_left_coords
var/turf/bottom_left = reserved_area.bottom_left_turfs[1]

var/list/bounds = template.load(locate(bottom_left[1] + (INTERIOR_BORDER_SIZE / 2), bottom_left[2] + (INTERIOR_BORDER_SIZE / 2), bottom_left[3]), centered = FALSE)
var/list/bounds = template.load(locate(bottom_left.x + (INTERIOR_BORDER_SIZE / 2), bottom_left.y + (INTERIOR_BORDER_SIZE / 2), bottom_left.z), centered = FALSE)

var/list/turfs = block( locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ]))
Expand Down Expand Up @@ -51,12 +51,7 @@ SUBSYSTEM_DEF(interior)
if(!isturf(loc))
loc = get_turf(loc)

var/datum/weakref/reservation_weakref = SSmapping.used_turfs[loc]

if(!reservation_weakref)
return

var/datum/turf_reservation/interior/reservation = reservation_weakref.resolve()
var/datum/turf_reservation/interior/reservation = SSmapping.used_turfs[loc]

if(!istype(reservation))
return FALSE
Expand Down
Loading