Various code improvements (#40932)

* adsf

* asdf

* take these

* Further cleanup to windoor code
This commit is contained in:
MrDoomBringer
2018-10-21 03:01:02 -04:00
committed by Jordan Brown
parent 0d8c17d199
commit 703a365aec
14 changed files with 65 additions and 66 deletions

View File

@@ -74,7 +74,7 @@ Actual Adjacent procs :
return b.f - a.f
//wrapper that returns an empty list if A* failed to find a path
/proc/get_path_to(caller, end, dist, maxnodes, maxnodedepth = 30, mintargetdist, adjacent = /turf/proc/reachableTurftest, id=null, turf/exclude=null, simulated_only = 1)
/proc/get_path_to(caller, end, dist, maxnodes, maxnodedepth = 30, mintargetdist, adjacent = /turf/proc/reachableTurftest, id=null, turf/exclude=null, simulated_only = TRUE)
var/l = SSpathfinder.mobs.getfree(caller)
while(!l)
stoplag(3)
@@ -86,7 +86,7 @@ Actual Adjacent procs :
path = list()
return path
/proc/cir_get_path_to(caller, end, dist, maxnodes, maxnodedepth = 30, mintargetdist, adjacent = /turf/proc/reachableTurftest, id=null, turf/exclude=null, simulated_only = 1)
/proc/cir_get_path_to(caller, end, dist, maxnodes, maxnodedepth = 30, mintargetdist, adjacent = /turf/proc/reachableTurftest, id=null, turf/exclude=null, simulated_only = TRUE)
var/l = SSpathfinder.circuits.getfree(caller)
while(!l)
stoplag(3)
@@ -97,19 +97,19 @@ Actual Adjacent procs :
path = list()
return path
/proc/AStar(caller, _end, dist, maxnodes, maxnodedepth = 30, mintargetdist, adjacent = /turf/proc/reachableTurftest, id=null, turf/exclude=null, simulated_only = 1)
/proc/AStar(caller, _end, dist, maxnodes, maxnodedepth = 30, mintargetdist, adjacent = /turf/proc/reachableTurftest, id=null, turf/exclude=null, simulated_only = TRUE)
//sanitation
var/turf/end = get_turf(_end)
var/turf/start = get_turf(caller)
if(!start || !end)
stack_trace("Invalid A* start or destination")
return 0
return FALSE
if( start.z != end.z || start == end ) //no pathfinding between z levels
return 0
return FALSE
if(maxnodes)
//if start turf is farther than maxnodes from end turf, no need to do anything
if(call(start, dist)(end) > maxnodes)
return 0
return FALSE
maxnodedepth = maxnodes //no need to consider path longer than maxnodes
var/datum/Heap/open = new /datum/Heap(/proc/HeapPathWeightCompare) //the open list
var/list/openc = new() //open list for node check
@@ -198,12 +198,12 @@ Actual Adjacent procs :
var/rdir = ((adir & MASK_ODD)<<1)|((adir & MASK_EVEN)>>1)
for(var/obj/structure/window/W in src)
if(!W.CanAStarPass(ID, adir))
return 1
return TRUE
for(var/obj/machinery/door/window/W in src)
if(!W.CanAStarPass(ID, adir))
return 1
return TRUE
for(var/obj/O in T)
if(!O.CanAStarPass(ID, rdir, caller))
return 1
return TRUE
return 0
return FALSE

View File

@@ -313,7 +313,7 @@
roundend_report.set_content(content)
roundend_report.stylesheets = list()
roundend_report.add_stylesheet("roundend", 'html/browser/roundend.css')
roundend_report.open(0)
roundend_report.open(FALSE)
/datum/controller/subsystem/ticker/proc/personal_report(client/C, popcount)
var/list/parts = list()

View File

@@ -739,10 +739,10 @@ Turf and target are separate in case you want to teleport some distance from a t
return locate(final_x, final_y, T.z)
//Finds the distance between two atoms, in pixels
//centered = 0 counts from turf edge to edge
//centered = 1 counts from turf center to turf center
//centered = FALSE counts from turf edge to edge
//centered = TRUE counts from turf center to turf center
//of course mathematically this is just adding world.icon_size on again
/proc/getPixelDistance(atom/A, atom/B, centered = 1)
/proc/getPixelDistance(atom/A, atom/B, centered = TRUE)
if(!istype(A)||!istype(B))
return 0
. = bounds_dist(A, B) + sqrt((((A.pixel_x+B.pixel_x)**2) + ((A.pixel_y+B.pixel_y)**2)))

View File

@@ -31,7 +31,7 @@ SUBSYSTEM_DEF(vote)
client_popup = new(C, "vote", "Voting Panel")
client_popup.set_window_options("can_close=0")
client_popup.set_content(interface(C))
client_popup.open(0)
client_popup.open(FALSE)
/datum/controller/subsystem/vote/proc/reset()
@@ -302,7 +302,7 @@ SUBSYSTEM_DEF(vote)
var/datum/browser/popup = new(src, "vote", "Voting Panel")
popup.set_window_options("can_close=0")
popup.set_content(SSvote.interface(client))
popup.open(0)
popup.open(FALSE)
/datum/action/vote
name = "Vote!"

View File

@@ -91,7 +91,7 @@
[get_footer()]
"}
/datum/browser/proc/open(use_onclose = 1)
/datum/browser/proc/open(use_onclose = TRUE)
if(isnull(window_id)) //null check because this can potentially nuke goonchat
WARNING("Browser [title] tried to open with a null ID")
to_chat(user, "<span class='userdanger'>The [title] browser you tried to open failed a sanity check! Please report this on github!</span>")

View File

@@ -26,9 +26,9 @@
. = ..()
if(set_dir)
setDir(set_dir)
if(src.req_access && src.req_access.len)
src.icon_state = "[src.icon_state]"
src.base_state = src.icon_state
if(req_access && req_access.len)
icon_state = "[icon_state]"
base_state = icon_state
for(var/i in 1 to shards)
debris += new /obj/item/shard(src)
if(rods)
@@ -52,23 +52,23 @@
if(density)
icon_state = base_state
else
icon_state = "[src.base_state]open"
icon_state = "[base_state]open"
/obj/machinery/door/window/proc/open_and_close()
open()
if(src.check_access(null))
if(check_access(null))
sleep(50)
else //secure doors close faster
sleep(20)
close()
/obj/machinery/door/window/Bumped(atom/movable/AM)
if( operating || !src.density )
if( operating || !density )
return
if (!( ismob(AM) ))
if(ismecha(AM))
var/obj/mecha/mecha = AM
if(mecha.occupant && src.allowed(mecha.occupant))
if(mecha.occupant && allowed(mecha.occupant))
open_and_close()
else
do_animate("deny")
@@ -81,10 +81,10 @@
bumpopen(M)
/obj/machinery/door/window/bumpopen(mob/user)
if( operating || !src.density )
if( operating || !density )
return
src.add_fingerprint(user)
if(!src.requiresID())
add_fingerprint(user)
if(!requiresID())
user = null
if(allowed(user))
@@ -129,8 +129,8 @@
else
return 1
/obj/machinery/door/window/open(forced=0)
if (src.operating == 1) //doors can still open when emag-disabled
/obj/machinery/door/window/open(forced=FALSE)
if (operating) //doors can still open when emag-disabled
return 0
if(!forced)
if(!hasPower())
@@ -138,15 +138,14 @@
if(forced < 2)
if(obj_flags & EMAGGED)
return 0
if(!src.operating) //in case of emag
if(!operating) //in case of emag
operating = TRUE
do_animate("opening")
playsound(src.loc, 'sound/machines/windowdoor.ogg', 100, 1)
src.icon_state ="[src.base_state]open"
playsound(src, 'sound/machines/windowdoor.ogg', 100, 1)
icon_state ="[base_state]open"
sleep(10)
density = FALSE
// src.sd_set_opacity(0) //TODO: why is this here? Opaque windoors? ~Carn
air_update_turf(1)
update_freelook_sight()
@@ -154,8 +153,8 @@
operating = FALSE
return 1
/obj/machinery/door/window/close(forced=0)
if (src.operating)
/obj/machinery/door/window/close(forced=FALSE)
if (operating)
return 0
if(!forced)
if(!hasPower())
@@ -165,8 +164,8 @@
return 0
operating = TRUE
do_animate("closing")
playsound(src.loc, 'sound/machines/windowdoor.ogg', 100, 1)
src.icon_state = src.base_state
playsound(src, 'sound/machines/windowdoor.ogg', 100, 1)
icon_state = base_state
density = TRUE
air_update_turf(1)
@@ -179,9 +178,9 @@
/obj/machinery/door/window/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
switch(damage_type)
if(BRUTE)
playsound(loc, 'sound/effects/glasshit.ogg', 90, 1)
playsound(src, 'sound/effects/glasshit.ogg', 90, 1)
if(BURN)
playsound(src.loc, 'sound/items/welder.ogg', 100, 1)
playsound(src, 'sound/items/welder.ogg', 100, 1)
/obj/machinery/door/window/deconstruct(disassembled = TRUE)
@@ -209,7 +208,7 @@
if(!operating && density && !(obj_flags & EMAGGED))
obj_flags |= EMAGGED
operating = TRUE
flick("[src.base_state]spark", src)
flick("[base_state]spark", src)
playsound(src, "sparks", 75, 1)
sleep(6)
operating = FALSE
@@ -229,16 +228,16 @@
return
I.play_tool_sound(src)
panel_open = !panel_open
to_chat(user, "<span class='notice'>You [panel_open ? "open":"close"] the maintenance panel of the [src.name].</span>")
to_chat(user, "<span class='notice'>You [panel_open ? "open":"close"] the maintenance panel of the [name].</span>")
return
if(I.tool_behaviour == TOOL_CROWBAR)
if(panel_open && !density && !operating)
user.visible_message("[user] removes the electronics from the [src.name].", \
"<span class='notice'>You start to remove electronics from the [src.name]...</span>")
user.visible_message("[user] removes the electronics from the [name].", \
"<span class='notice'>You start to remove electronics from the [name]...</span>")
if(I.use_tool(src, user, 40, volume=50))
if(panel_open && !density && !operating && src.loc)
var/obj/structure/windoor_assembly/WA = new /obj/structure/windoor_assembly(src.loc)
if(panel_open && !density && !operating && loc)
var/obj/structure/windoor_assembly/WA = new /obj/structure/windoor_assembly(loc)
switch(base_state)
if("left")
WA.facing = "l"
@@ -252,10 +251,10 @@
WA.secure = TRUE
WA.setAnchored(TRUE)
WA.state= "02"
WA.setDir(src.dir)
WA.ini_dir = src.dir
WA.setDir(dir)
WA.ini_dir = dir
WA.update_icon()
WA.created_name = src.name
WA.created_name = name
if(obj_flags & EMAGGED)
to_chat(user, "<span class='warning'>You discard the damaged electronics.</span>")
@@ -266,12 +265,12 @@
var/obj/item/electronics/airlock/ae
if(!electronics)
ae = new/obj/item/electronics/airlock( src.loc )
ae = new/obj/item/electronics/airlock(drop_location())
if(req_one_access)
ae.one_access = 1
ae.accesses = src.req_one_access
ae.accesses = req_one_access
else
ae.accesses = src.req_access
ae.accesses = req_access
else
ae = electronics
electronics = null
@@ -296,11 +295,11 @@
/obj/machinery/door/window/do_animate(animation)
switch(animation)
if("opening")
flick("[src.base_state]opening", src)
flick("[base_state]opening", src)
if("closing")
flick("[src.base_state]closing", src)
flick("[base_state]closing", src)
if("deny")
flick("[src.base_state]deny", src)
flick("[base_state]deny", src)
/obj/machinery/door/window/check_access_ntnet(datum/netdata/data)
return !requiresID() || ..()

View File

@@ -158,7 +158,7 @@
var/datum/browser/popup = new(user, "stack", name, 400, 400)
popup.set_content(t1)
popup.open(0)
popup.open(FALSE)
onclose(user, "stack")
/obj/item/stack/Topic(href, href_list)

View File

@@ -77,7 +77,7 @@
var/datum/browser/popup = new(user, "gunlocker", "<div align='center'>[name]</div>", 350, 300)
popup.set_content(dat)
popup.open(0)
popup.open(FALSE)
/obj/structure/guncase/Topic(href, href_list)
if(href_list["retrieve"])

View File

@@ -48,7 +48,7 @@
return
if(!isturf(user.loc))
return
if(!AStar(user, target.loc, /turf/proc/Distance, changeling.sting_range, simulated_only = 0))
if(!AStar(user, target.loc, /turf/proc/Distance, changeling.sting_range, simulated_only = FALSE))
return
return 1

View File

@@ -604,7 +604,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/datum/browser/popup = new(user, "preferences", "<div align='center'>Character Setup</div>", 640, 770)
popup.set_content(dat.Join())
popup.open(0)
popup.open(FALSE)
#undef APPEARANCE_CATEGORY_COLUMN
#undef MAX_MUTANT_ROWS
@@ -734,7 +734,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/datum/browser/popup = new(user, "mob_occupation", "<div align='center'>Occupation Preferences</div>", width, height)
popup.set_window_options("can_close=0")
popup.set_content(HTML)
popup.open(0)
popup.open(FALSE)
return
/datum/preferences/proc/SetJobPreferenceLevel(datum/job/job, level)
@@ -928,7 +928,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/datum/browser/popup = new(user, "mob_occupation", "<div align='center'>Quirk Preferences</div>", 900, 600) //no reason not to reuse the occupation window, as it's cleaner that way
popup.set_window_options("can_close=0")
popup.set_content(dat.Join())
popup.open(0)
popup.open(FALSE)
return
/datum/preferences/proc/GetQuirkBalance()

View File

@@ -97,7 +97,7 @@
return
idc.access = assembly.access_card.access
var/turf/a_loc = get_turf(assembly)
var/list/P = cir_get_path_to(assembly, locate(get_pin_data(IC_INPUT, 1),get_pin_data(IC_INPUT, 2),a_loc.z), /turf/proc/Distance_cardinal, 0, 200, id=idc, exclude=get_turf(get_pin_data_as_type(IC_INPUT,3, /atom)), simulated_only = 0)
var/list/P = cir_get_path_to(assembly, locate(get_pin_data(IC_INPUT, 1),get_pin_data(IC_INPUT, 2),a_loc.z), /turf/proc/Distance_cardinal, 0, 200, id=idc, exclude=get_turf(get_pin_data_as_type(IC_INPUT,3, /atom)), simulated_only = FALSE)
if(!P)
activate_pin(3)

View File

@@ -72,7 +72,7 @@
var/datum/browser/popup = new(src, "playersetup", "<div align='center'>New Player Options</div>", 250, 265)
popup.set_window_options("can_close=0")
popup.set_content(output)
popup.open(0)
popup.open(FALSE)
/mob/dead/new_player/Topic(href, href_list[])
if(src != usr)
@@ -467,7 +467,7 @@
var/datum/browser/popup = new(src, "latechoices", "Choose Profession", 440, 500)
popup.add_stylesheet("playeroptions", 'html/browser/playeroptions.css')
popup.set_content(dat)
popup.open(0) // 0 is passed to open so that it doesn't use the onclose() proc
popup.open(FALSE) // FALSE is passed to open so that it doesn't use the onclose() proc
/mob/dead/new_player/proc/create_character(transfer_after)

View File

@@ -243,9 +243,9 @@
if(path.len == 0)
if(!isturf(target))
var/turf/TL = get_turf(target)
path = get_path_to(src, TL, /turf/proc/Distance_cardinal, 0, 30, id=access_card,simulated_only = 0)
path = get_path_to(src, TL, /turf/proc/Distance_cardinal, 0, 30, id=access_card,simulated_only = FALSE)
else
path = get_path_to(src, target, /turf/proc/Distance_cardinal, 0, 30, id=access_card,simulated_only = 0)
path = get_path_to(src, target, /turf/proc/Distance_cardinal, 0, 30, id=access_card,simulated_only = FALSE)
if(!bot_move(target))
add_to_ignore(target)

View File

@@ -177,7 +177,7 @@
var/datum/browser/popup = new(user, "reagentgrinder", "All-In-One Grinder")
popup.set_content(dat)
popup.set_title_image(user.browse_rsc_icon(icon, icon_state))
popup.open(1)
popup.open(TRUE)
return
/obj/machinery/reagentgrinder/Topic(href, href_list)