Mapping verb cleanup (#37015)

* commit this now, put on backburner maybe

* updates to this

* does this for this too

* cleaner logic

* oh right like this

* no longer necessary

* here too

* cleans this up

* takes range into account
This commit is contained in:
SECBATON GRIFFON
2024-09-09 13:57:22 +01:00
committed by GitHub
parent ade845a724
commit f79f22d1d2
7 changed files with 81 additions and 75 deletions

View File

@@ -33,6 +33,7 @@
#define TICK_CHECK ( TICK_USAGE > CURRENT_TICKLIMIT )
// runs stoplag if tick_usage is above the limit
#define CHECK_TICK ( TICK_CHECK ? stoplag() : 0 )
#define IN_ROUND_CHECK_TICK ( ticker && ticker.current_state == GAME_STATE_PLAYING ? CHECK_TICK : 0 )
// Returns true if tick usage is above 95, for high priority usage
#define TICK_CHECK_HIGH_PRIORITY ( TICK_USAGE > 95 )

View File

@@ -207,6 +207,8 @@
var/thermal_dissipation = 1 //Whether or not thermal dissipation occurs.
var/reagents_heat_air = 0 //Whether or not reagents exchanging heat with the surrounding air actually heat or the cool air. If off, the energy change only applies to the reagents.
var/maprender_lags_game = 0 //If the map render checks tick or not to get done during a round
var/library_url = ""
/datum/configuration/New()
@@ -696,6 +698,8 @@
config.silent_borg = 1
if("borer_takeover_immediately")
config.borer_takeover_immediately = 1
if("maprender_lags_game")
config.maprender_lags_game = 1
if("hardcore_mode")
hardcore_mode = value
if("humans_speak")

View File

@@ -366,7 +366,6 @@ var/list/admin_verbs_mod = list(
/*Debug verbs added by "show debug verbs"*/
/client/proc/Cell,
/client/proc/pdiff,
/client/proc/do_not_use_these,
/client/proc/camera_view,
/client/proc/sec_camera_report,
/client/proc/intercom_view,

View File

@@ -519,12 +519,12 @@ Pressure: [env.pressure]"}
if(A && !(A.type in areas_with_light))
areas_with_light.Add(A.type)
for(var/obj/machinery/light_switch/LS in world)
for(var/obj/machinery/light_switch/LS in lightswitches)
var/area/A = get_area(LS)
if(A && !(A.type in areas_with_LS))
areas_with_LS.Add(A.type)
for(var/obj/item/device/radio/intercom/I in world)
for(var/obj/item/device/radio/intercom/I in radio_list)
var/area/A = get_area(I)
if(A && !(A.type in areas_with_intercom))
areas_with_intercom.Add(A.type)
@@ -542,33 +542,37 @@ Pressure: [env.pressure]"}
var/list/areas_without_intercom = areas_all - areas_with_intercom
var/list/areas_without_camera = areas_all - areas_with_camera
to_chat(world, "<b>AREAS WITHOUT AN APC:</b>")
var/error_str = "<h1>AREAS WITHOUT AN APC:</h1>"
for(var/areatype in areas_without_APC)
to_chat(world, "* [areatype]")
error_str += "* [areatype]<br>"
to_chat(world, "<b>AREAS WITHOUT AN AIR ALARM:</b>")
error_str += "<h1>AREAS WITHOUT AN AIR ALARM:</h1>"
for(var/areatype in areas_without_air_alarm)
to_chat(world, "* [areatype]")
error_str += "* [areatype]<br>"
to_chat(world, "<b>AREAS WITHOUT A REQUEST CONSOLE:</b>")
error_str += "<h1>AREAS WITHOUT A REQUEST CONSOLE:</h1>"
for(var/areatype in areas_without_RC)
to_chat(world, "* [areatype]")
error_str += "* [areatype]<br>"
to_chat(world, "<b>AREAS WITHOUT ANY LIGHTS:</b>")
error_str += "<h1>AREAS WITHOUT ANY LIGHTS:</h1>"
for(var/areatype in areas_without_light)
to_chat(world, "* [areatype]")
error_str += "* [areatype]<br>"
to_chat(world, "<b>AREAS WITHOUT A LIGHT SWITCH:</b>")
error_str += "<h1>AREAS WITHOUT A LIGHT SWITCH:</h1>"
for(var/areatype in areas_without_LS)
to_chat(world, "* [areatype]")
error_str += "* [areatype]<br>"
to_chat(world, "<b>AREAS WITHOUT ANY INTERCOMS:</b>")
error_str += "<h1>AREAS WITHOUT ANY INTERCOMS:</h1>"
for(var/areatype in areas_without_intercom)
to_chat(world, "* [areatype]")
error_str += "* [areatype]<br>"
to_chat(world, "<b>AREAS WITHOUT ANY CAMERAS:</b>")
error_str += "<h1>AREAS WITHOUT ANY CAMERAS:</h1>"
for(var/areatype in areas_without_camera)
to_chat(world, "* [areatype]")
error_str += "* [areatype]<br>"
var/datum/browser/popup = new(usr, "Area issues", usr.name, 300, 400)
popup.set_content(error_str)
popup.open()
/client/proc/startSinglo()
set category = "Debug"

View File

@@ -19,49 +19,32 @@
//- Identify how hard it is to break into the area and where the weak points are
//- Check if the area has too much empty space. If so, make it smaller and replace the rest with maintenance tunnels.
var/camera_range_display_status = 0
var/intercom_range_display_status = 0
/obj/effect/debugging/camera_range
icon = 'icons/480x480.dmi'
icon_state = "25percent"
/obj/effect/debugging/camera_range/New()
src.pixel_x = -224 * PIXEL_MULTIPLIER
src.pixel_y = -224 * PIXEL_MULTIPLIER
/obj/effect/debugging/marker
icon = 'icons/turf/areas.dmi'
icon_state = "yellow"
/obj/effect/debugging/marker/Move(NewLoc, Dir = 0, step_x = 0, step_y = 0, glide_size_override = 0)
return 0
/client/proc/do_not_use_these()
set category = "Mapping"
set name = "-None of these are for ingame use!!"
/client
var/camera_range_display = FALSE
var/list/camera_range_images
var/intercom_range_display = FALSE
var/list/intercom_range_images
/client/proc/camera_view()
set category = "Mapping"
set name = "Camera Range Display"
if(camera_range_display_status)
camera_range_display_status = 0
else
camera_range_display_status = 1
camera_range_display = !camera_range_display
if(camera_range_images)
images -= camera_range_images
QDEL_LIST(camera_range_images)
camera_range_images = list()
for(var/obj/effect/debugging/camera_range/C in world)
del(C)
if(camera_range_display_status)
if(camera_range_display)
for(var/obj/machinery/camera/C in cameranet.cameras)
new/obj/effect/debugging/camera_range(C.loc)
for (var/turf/T in view(C.view_range, C))
var/image/camrange = image('icons/turf/areas.dmi',T,"green")
images += camrange
camera_range_images += camrange
feedback_add_details("admin_verb","mCRD") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
/client/proc/sec_camera_report()
set category = "Mapping"
set name = "Camera Report"
@@ -106,18 +89,19 @@ var/intercom_range_display_status = 0
set category = "Mapping"
set name = "Intercom Range Display"
if (intercom_range_display_status)
intercom_range_display_status = FALSE
else
intercom_range_display_status = TRUE
intercom_range_display = !intercom_range_display
for (var/obj/effect/debugging/marker/M in world)
qdel(M)
if(intercom_range_images)
images -= intercom_range_images
QDEL_LIST(intercom_range_images)
intercom_range_images = list()
if (intercom_range_display_status)
for (var/obj/item/device/radio/intercom/I in world)
if(intercom_range_display)
for (var/obj/item/device/radio/intercom/I in radio_list)
for (var/turf/T in view(I.canhear_range, I))
new /obj/effect/debugging/marker(T)
var/image/comrange = image('icons/turf/areas.dmi',T,"yellow")
images += comrange
intercom_range_images += comrange
feedback_add_details("admin_verb","mIRD") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
@@ -128,7 +112,6 @@ var/intercom_range_display_status = 0
if(!check_rights(R_DEBUG))
return
src.verbs += /client/proc/do_not_use_these //-errorage
src.verbs += /client/proc/camera_view //-errorage
src.verbs += /client/proc/sec_camera_report //-errorage
src.verbs += /client/proc/intercom_view //-errorage
@@ -424,9 +407,8 @@ var/global/movement_disabled_exception //This is the client that calls the proc,
return
var/z = mob.z
to_chat(usr, "<span class = 'notice'>Checking wire connections on current Z Level [z]</span>")
for(var/obj/structure/cable/C in world)
var/error_str = "<h1>Wire connections on current Z Level [z]</h1>"
for(var/obj/structure/cable/C in cable_list)
if(C.z != z)
continue
if(!C.d1) //It's a stub
@@ -434,10 +416,14 @@ var/global/movement_disabled_exception //This is the client that calls the proc,
var/obj/structure/cable/neighbour
neighbour = locate() in get_step(get_turf(C),C.d1)
if(!neighbour || neighbour.get_powernet() != C.get_powernet())
to_chat(usr, "<span class = 'warning'>Disconnected wire at [formatJumpTo(get_turf(C))]</span>")
error_str += "<span class = 'warning'>Disconnected wire at [formatJumpTo(get_turf(C))]</span><br>"
neighbour = locate() in get_step(get_turf(C),C.d2)
if(!neighbour || neighbour.get_powernet() != C.get_powernet())
to_chat(usr, "<span class = 'warning'>Disconnected wire at [formatJumpTo(get_turf(C))]</span>")
error_str += "<span class = 'warning'>Disconnected wire at [formatJumpTo(get_turf(C))]</span><br>"
var/datum/browser/popup = new(usr, "Wire connections", usr.name, 300, 400)
popup.set_content(error_str)
popup.open()
/client/proc/check_pipes()
set category = "Mapping"

View File

@@ -377,4 +377,7 @@ BLOCKING_QUERY_TIMEOUT 5
BSQL_THREAD_LIMIT 50
## Uncomment to enable verbose BSQL communication logs
#BSQL_DEBUG
#BSQL_DEBUG
## Comment to make the map rendering verb not lag the game during rounds when done
MAPRENDER_LAGS_GAME

View File

@@ -1,3 +1,5 @@
#define MAPRENDER_IN_ROUND_CHECK_TICK ( !config.maprender_lags_game ? IN_ROUND_CHECK_TICK : 0 )
/client/proc/maprender()
set category = "Mapping"
set name = "Generate Map Render"
@@ -5,8 +7,9 @@
if(!holder)
to_chat(src, "Only administrators may use this command.")
return
if(alert("Sure you want to do this? It should NEVER be done in an active round and cannot be cancelled", "generate maps", "Yes", "No") == "No")
return
if(config.maprender_lags_game)
if(alert("Sure you want to do this? It should NEVER be done in an active round and cannot be cancelled", "generate maps", "Yes", "No") == "No")
return
var/allz = alert("Do you wish to generate a specific zlevel or all zlevels?", "Generate what levels?", "All", "Specific", "Cancel")
@@ -47,25 +50,25 @@
continue
var/list/allturfcontents = currentturf.contents.Copy()
//Remove the following line to allow lighting to be considered, if you do this it must be blended with BLEND_MULTIPLY instead of ICON_OVERLAY
allturfcontents -= locate(/atom/movable/lighting_overlay) in allturfcontents
//Remove the following line if you want to add space to your renders, I think it is cheaper to merely use a pregenned image for this
if(!istype(currentturf,/turf/space))
var/icon/turficon = getFlatIcon(currentturf, currentturf.dir, cache = 0)
map_icon.Blend(turficon, ICON_OVERLAY, ((a-1)*WORLD_ICON_SIZE)+1, ((b-1)*WORLD_ICON_SIZE)+1)
for(var/atom/movable/A in allturfcontents)
if(A.locs.len > 1) //Fix for multitile objects I wish I didn't have to do this its probably slow
//Remove the following line to allow lighting to be considered, if you do this it must be blended with BLEND_MULTIPLY instead of ICON_OVERLAY
if(A.type == /atom/movable/lighting_overlay)
allturfcontents -= A
else if(A.locs.len > 1) //Fix for multitile objects I wish I didn't have to do this its probably slow
if(A.locs[1] != A.loc)
allturfcontents -= A
continue
//Due to processing order, a pixelshifted object will be overriden in certain directions,
//we'll apply it at the end, they're almost always at the top layer anyway
for(var/atom/A in allturfcontents)
if(A.pixel_x || A.pixel_y)
allturfcontents -= A
pixel_shift_objects += A
MAPRENDER_IN_ROUND_CHECK_TICK
if(!allturfcontents.len)
continue
@@ -76,12 +79,15 @@
for(var/A in allturfcontents)
var/icon/icontoblend = getFlatIcon(A,A:dir, cache = 0)
map_icon.Blend(icontoblend, ICON_OVERLAY, ((a-1)*WORLD_ICON_SIZE)+1, ((b-1)*WORLD_ICON_SIZE)+1)
MAPRENDER_IN_ROUND_CHECK_TICK
sleep(-1)
MAPRENDER_IN_ROUND_CHECK_TICK
MAPRENDER_IN_ROUND_CHECK_TICK
for(var/A in pixel_shift_objects)
var/icon/icontoblend = getFlatIcon(A, A:dir, cache = 0)
//This part is tricky since we've skipped a and b, since these are map objects they have valid x,y. a and b should be the modulo'd value of x,y with icon_size
map_icon.Blend(icontoblend, ICON_OVERLAY, (((A:x % icon_size)-1)*WORLD_ICON_SIZE)+1+A:pixel_x, (((A:y % icon_size)-1)*WORLD_ICON_SIZE)+1+A:pixel_y)
MAPRENDER_IN_ROUND_CHECK_TICK
if(y >= world.maxy)
map_icon.DrawBox(rgb(255,255,255,255), x1 = 1, y1 = 1, x2 = WORLD_ICON_SIZE*icon_size, y2 = WORLD_ICON_SIZE*(icon_size-world.maxy % icon_size))
@@ -97,5 +103,8 @@
if(fexists(resultpath))
fdel(resultpath)
fcopy(result_icon, resultpath)
MAPRENDER_IN_ROUND_CHECK_TICK
MAPRENDER_IN_ROUND_CHECK_TICK
MAPRENDER_IN_ROUND_CHECK_TICK
to_chat(world, "<b>The map has been rendered successfully<b>")
src << sound('sound/effects/maprendercomplete.ogg')