diff --git a/code/__defines/map.dm b/code/__defines/map.dm new file mode 100644 index 0000000000..9419415e1c --- /dev/null +++ b/code/__defines/map.dm @@ -0,0 +1,8 @@ +// Z-level flags bitfield - Set these flags to determine the z level's purpose +#define MAP_LEVEL_STATION 0x001 // Z-levels the station exists on +#define MAP_LEVEL_ADMIN 0x002 // Z-levels for admin functionality (Centcom, shuttle transit, etc) +#define MAP_LEVEL_CONTACT 0x004 // Z-levels that can be contacted from the station, for eg announcements +#define MAP_LEVEL_PLAYER 0x008 // Z-levels a character can typically reach +#define MAP_LEVEL_SEALED 0x010 // Z-levels that don't allow random transit at edge +#define MAP_LEVEL_EMPTY 0x020 // Empty Z-levels that may be used for various things (currently used by bluespace jump) +#define MAP_LEVEL_CONSOLES 0x040 // Z-levels available to various consoles, such as the crew monitor (when that gets coded in). Defaults to station_levels if unset. diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index a4a2197288..62d1399095 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -176,6 +176,7 @@ var/list/admin_verbs_debug = list( /client/proc/debug_controller, /client/proc/debug_antagonist_template, /client/proc/cmd_debug_mob_lists, + /client/proc/cmd_debug_using_map, /client/proc/cmd_admin_delete, /client/proc/cmd_debug_del_all, /client/proc/cmd_debug_tog_aliens, @@ -286,6 +287,7 @@ var/list/admin_verbs_hideable = list( /client/proc/debug_controller, /client/proc/startSinglo, /client/proc/cmd_debug_mob_lists, + /client/proc/cmd_debug_using_map, /client/proc/cmd_debug_del_all, /client/proc/cmd_debug_tog_aliens, /client/proc/air_report, diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index f06ab9ca33..82206fdc30 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -943,6 +943,15 @@ if("Clients") usr << jointext(clients,",") +/client/proc/cmd_debug_using_map() + set category = "Debug" + set name = "Debug Map Datum" + set desc = "Debug the map metadata about the currently compiled in map." + + if(!check_rights(R_DEBUG)) + return + debug_variables(using_map) + // DNA2 - Admin Hax /client/proc/cmd_admin_toggle_block(var/mob/M,var/block) if(!ticker) diff --git a/html/changelogs/Leshana-mapz.yml b/html/changelogs/Leshana-mapz.yml new file mode 100644 index 0000000000..1b5544383c --- /dev/null +++ b/html/changelogs/Leshana-mapz.yml @@ -0,0 +1,4 @@ +author: Leshana +delete-after: True +changes: +- rscadd: "Added an admin verb to debug the map datum." diff --git a/maps/example/example_defines.dm b/maps/example/example_defines.dm index 3c7ae5d30e..a0a9967f5d 100644 --- a/maps/example/example_defines.dm +++ b/maps/example/example_defines.dm @@ -9,26 +9,7 @@ lobby_icon = 'icons/misc/title.dmi' lobby_screens = list("mockingjay00") - station_levels = list( - Z_LEVEL_FIRST_EXAMPLE, - Z_LEVEL_SECOND_EXAMPLE - ) - - admin_levels = list() - contact_levels = list( - Z_LEVEL_FIRST_EXAMPLE, - Z_LEVEL_SECOND_EXAMPLE - ) - - player_levels = list( - Z_LEVEL_FIRST_EXAMPLE, - Z_LEVEL_SECOND_EXAMPLE - ) - - sealed_levels = list() - empty_levels = list() - accessible_z_levels = list("1" = 50, "2" = 50) // The defines can't be used here sadly. - base_turf_by_z = list("2" = /turf/simulated/open) + zlevel_datum_type = /datum/map_z_level/example station_name = "The Funhouse" station_short = "Funhouse" @@ -46,4 +27,17 @@ emergency_shuttle_docked_message = "The Emergency Shuttle has docked with the station at docks one and two. You have approximately %ETD% to board the Emergency Shuttle." emergency_shuttle_leaving_dock = "The Emergency Shuttle has left the station. Estimate %ETA% until the shuttle docks at %dock_name%." emergency_shuttle_called_message = "An emergency evacuation shuttle has been called. It will arrive at docks one and two in approximately %ETA%" - emergency_shuttle_recall_message = "The emergency shuttle has been recalled." \ No newline at end of file + emergency_shuttle_recall_message = "The emergency shuttle has been recalled." + +/datum/map_z_level/example/first + z = Z_LEVEL_FIRST_EXAMPLE + name = "First Floor" + flags = MAP_LEVEL_STATION|MAP_LEVEL_CONTACT|MAP_LEVEL_PLAYER + transit_chance = 50 + +/datum/map_z_level/example/second + z = Z_LEVEL_SECOND_EXAMPLE + name = "Second Floor" + flags = MAP_LEVEL_STATION|MAP_LEVEL_CONTACT|MAP_LEVEL_PLAYER + transit_chance = 50 + base_turf = /turf/simulated/open diff --git a/maps/northern_star/northern_star_defines.dm b/maps/northern_star/northern_star_defines.dm index aeb1426de2..350026fbf4 100644 --- a/maps/northern_star/northern_star_defines.dm +++ b/maps/northern_star/northern_star_defines.dm @@ -14,34 +14,7 @@ lobby_icon = 'icons/misc/title.dmi' lobby_screens = list("mockingjay00") - station_levels = list( - Z_LEVEL_MAIN_NORTHERN_STAR, - Z_LEVEL_MINING_NORTHERN_STAR - ) - - admin_levels = list(Z_LEVEL_CENTCOM_NORTHERN_STAR) - contact_levels = list( - Z_LEVEL_MAIN_NORTHERN_STAR, - Z_LEVEL_CENTCOM_NORTHERN_STAR, - Z_LEVEL_MINING_NORTHERN_STAR - ) - - player_levels = list( - Z_LEVEL_MAIN_NORTHERN_STAR, - Z_LEVEL_TELECOMMS_NORTHERN_STAR, - Z_LEVEL_ABANDONED_ASTEROID_NORTHERN_STAR, - Z_LEVEL_MINING_NORTHERN_STAR, - Z_LEVEL_EMPTY_NORTHERN_STAR - ) - - sealed_levels = list() - empty_levels = list() - accessible_z_levels = list("1" = 5, "3" = 10, "4" = 15, "5" = 10, "6" = 60) // The defines can't be used here sadly. - base_turf_by_z = list( - "1" = /turf/simulated/mineral/floor, - "4" = /turf/simulated/mineral/floor, - "5" = /turf/simulated/mineral/floor - ) + zlevel_datum_type = /datum/map_z_level/northern_star station_name = "NCS Northern Star" station_short = "Northern Star" @@ -92,4 +65,42 @@ new /datum/random_map/automata/cave_system(null, 1, 1, Z_LEVEL_MINING_NORTHERN_STAR, world.maxx, world.maxy) // Create the mining Z-level. new /datum/random_map/noise/ore(null, 1, 1, Z_LEVEL_MINING_NORTHERN_STAR, 64, 64) // Create the mining ore distribution map. - return 1 \ No newline at end of file + return 1 + +/datum/map_z_level/northern_star/main + z = Z_LEVEL_MAIN_NORTHERN_STAR + name = "Main" + flags = MAP_LEVEL_STATION|MAP_LEVEL_CONTACT|MAP_LEVEL_PLAYER + transit_chance = 5 + base_turf = /turf/simulated/mineral/floor + +/datum/map_z_level/northern_star/centcomm + z = Z_LEVEL_CENTCOM_NORTHERN_STAR + name = "Centcomm" + flags = MAP_LEVEL_ADMIN|MAP_LEVEL_CONTACT + +/datum/map_z_level/northern_star/telecomms + z = Z_LEVEL_TELECOMMS_NORTHERN_STAR + name = "Telecomms" + flags = MAP_LEVEL_PLAYER + transit_chance = 10 + +/datum/map_z_level/northern_star/abandoned_asteroid + z = Z_LEVEL_ABANDONED_ASTEROID_NORTHERN_STAR + name = "Abandoned Asteroid" + flags = MAP_LEVEL_PLAYER + transit_chance = 15 + base_turf = /turf/simulated/mineral/floor + +/datum/map_z_level/northern_star/mining + z = Z_LEVEL_MINING_NORTHERN_STAR + name = "Mining" + flags = MAP_LEVEL_STATION|MAP_LEVEL_CONTACT|MAP_LEVEL_PLAYER + transit_chance = 10 + base_turf = /turf/simulated/mineral/floor + +/datum/map_z_level/northern_star/empty + z = Z_LEVEL_EMPTY_NORTHERN_STAR + name = "Empty" + flags = MAP_LEVEL_PLAYER + transit_chance = 60 diff --git a/maps/~map_system/maps.dm b/maps/~map_system/maps.dm index 0ee2316a4b..67307102dd 100644 --- a/maps/~map_system/maps.dm +++ b/maps/~map_system/maps.dm @@ -22,6 +22,9 @@ var/list/all_maps = list() var/full_name = "Unnamed Map" var/path + var/list/zlevels = list() + var/zlevel_datum_type // If populated, all subtypes of this type will be instantiated and used to populate the *_levels lists. + var/list/station_levels = list() // Z-levels the station exists on var/list/admin_levels = list() // Z-levels for admin functionality (Centcom, shuttle transit, etc) var/list/contact_levels = list() // Z-levels that can be contacted from the station, for eg announcements @@ -73,6 +76,9 @@ var/list/all_maps = list() /datum/map/New() ..() + if(zlevel_datum_type) + for(var/type in subtypesof(zlevel_datum_type)) + new type(src) if(!map_levels) map_levels = station_levels.Copy() if(!allowed_jobs || !allowed_jobs.len) @@ -111,4 +117,38 @@ var/list/all_maps = list() if(empty_levels == null) world.maxz++ empty_levels = list(world.maxz) - return pick(empty_levels) \ No newline at end of file + return pick(empty_levels) + +// Another way to setup the map datum that can be convenient. Just declare all your zlevels as subtypes of a common +// subtype of /datum/map_z_level and set zlevel_datum_type on /datum/map to have the lists auto-initialized. + +// Structure to hold zlevel info together in one nice convenient package. +/datum/map_z_level + var/z = 0 // Actual z-index of the zlevel. This had better be right! + var/name // Friendly name of the zlevel + var/flags = 0 // Bitflag of which *_levels lists this z should be put into. + var/turf/base_turf // Type path of the base turf for this z + var/transit_chance = 0 // Percentile chance this z will be chosen for map-edge space transit. + +// Default constructor applies itself to the parent map datum +/datum/map_z_level/New(var/datum/map/map) + if(!z) return + map.zlevels["[z]"] = src + if(flags & MAP_LEVEL_STATION) map.station_levels += z + if(flags & MAP_LEVEL_ADMIN) map.admin_levels += z + if(flags & MAP_LEVEL_CONTACT) map.contact_levels += z + if(flags & MAP_LEVEL_PLAYER) map.player_levels += z + if(flags & MAP_LEVEL_SEALED) map.sealed_levels += z + if(flags & MAP_LEVEL_EMPTY) + if(!map.empty_levels) map.empty_levels = list() + map.empty_levels += z + if(flags & MAP_LEVEL_CONSOLES) + if (!map.map_levels) map.map_levels = list() + map.map_levels += z + if(base_turf) + map.base_turf_by_z["[z]"] = base_turf + if(transit_chance) + map.accessible_z_levels["[z]"] = transit_chance + +/datum/map_z_level/Destroy() + return TRUE // No. diff --git a/polaris.dme b/polaris.dme index f8f889a5d8..9f075b1d76 100644 --- a/polaris.dme +++ b/polaris.dme @@ -29,6 +29,7 @@ #include "code\__defines\items_clothing.dm" #include "code\__defines\lighting.dm" #include "code\__defines\machinery.dm" +#include "code\__defines\map.dm" #include "code\__defines\math_physics.dm" #include "code\__defines\misc.dm" #include "code\__defines\mobs.dm"