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

Improve code quality grep checks #4760

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion code/_helpers/files.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//Sends resource files to client cache
/client/proc/getFiles()
for(var/file in args)
direct_output(src, browse_rsc(file))
send_rsc(src, file, null)

/client/proc/browse_files(root="data/logs/", max_iterations=10, list/valid_extensions=list(".txt",".log",".htm"))
var/path = root
Expand Down
2 changes: 1 addition & 1 deletion code/_helpers/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ mob
// Send the icon to src's local cache
send_rsc(src, getFlatIcon(src), iconName)
// Display the icon in their browser
direct_output(src, browse("<body bgcolor='#000000'><p><img src='[iconName]'></p></body>"))
show_browser(src, "<body bgcolor='#000000'><p><img src='[iconName]'></p></body>")

Output_Icon()
set name = "2. Output Icon"
Expand Down
2 changes: 1 addition & 1 deletion code/_helpers/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var/global/log_end= world.system_type == UNIX ? ascii2text(13) : ""
to_world_log("## TESTING: [msg][log_end]")

/proc/game_log(category, text)
direct_output(diary, "\[[time_stamp()]] [game_id] [category]: [text][log_end]")
to_file(diary, "\[[time_stamp()]] [game_id] [category]: [text][log_end]")

/proc/log_admin(text)
global.admin_log.Add(text)
Expand Down
2 changes: 1 addition & 1 deletion code/_helpers/profiling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
lines += "[entry] => [num2text(data[STAT_ENTRY_TIME], 10)]ms ([data[STAT_ENTRY_COUNT]]) (avg:[num2text(data[STAT_ENTRY_TIME]/(data[STAT_ENTRY_COUNT] || 1), 99)])"

if (user)
direct_output(user, browse("<ol><li>[lines.Join("</li><li>")]</li></ol>", "window=[url_encode("stats:[ref(stats)]")]"))
show_browser(user, "<ol><li>[lines.Join("</li><li>")]</li></ol>", "window=[url_encode("stats:[ref(stats)]")]")

. = lines.Join("\n")

Expand Down
2 changes: 1 addition & 1 deletion code/_helpers/sorts/__main.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ reverse a descending sequence without violating stability.
var/r = 0 //becomes 1 if any bits are shifted off
while(n >= MIN_MERGE)
r |= (n & 1)
n >>= 1
n = BITSHIFT_RIGHT(n, 1)
return n + r

//Examines the stack of runs waiting to be merged and merges adjacent runs until the stack invariants are reestablished:
Expand Down
3 changes: 3 additions & 0 deletions code/_macros.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@
#define show_image(target, image) target << (image)
#define send_rsc(target, rsc_content, rsc_name) target << browse_rsc(rsc_content, rsc_name)
#define open_link(target, url) target << link(url)
#define ftp_to(target, file_entry, suggested_name) target << ftp(file_entry, suggested_name)
#define open_file_for(target, file) target << run(file)
#define to_savefile(target, key, value) target[(key)] << (value)
#define from_savefile(target, key, value) target[(key)] >> (value)
#define to_output(target, output_content, output_args) target << output((output_content), (output_args))
// Avoid using this where possible, prefer the other helpers instead.
#define direct_output(target, value) target << (value)

/proc/html_icon(var/thing) // Proc instead of macro to avoid precompiler problems.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ SUBSYSTEM_DEF(character_info)
fdel(dump_file_name)
text2file(JOINTEXT(SScharacter_info.get_character_manifest_html(apply_striping = FALSE)), dump_file_name)
if(fexists(dump_file_name))
direct_output(usr, ftp(dump_file_name, "dump_manifest.html"))
ftp_to(usr, dump_file_name, "dump_manifest.html")
return TOPIC_HANDLED
catch(var/exception/E)
log_debug("Exception when dumping character relationship manifest: [E]")
Expand Down
4 changes: 1 addition & 3 deletions code/datums/supplypacks/supplypack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ var/global/list/cargoprices = list()
cost = 0
for(var/entry in contains)
cost += atom_info_repository.get_combined_worth_for(entry) * max(1, contains[entry])
var/container_value = containertype ? atom_info_repository.get_single_worth_for(containertype) : 0
if(container_value)
cost += atom_info_repository.get_single_worth_for(containertype)
cost += containertype ? atom_info_repository.get_single_worth_for(containertype) : 0
cost = max(1, NONUNIT_CEILING((cost * WORTH_TO_SUPPLY_POINTS_CONSTANT * SSsupply.price_markup), WORTH_TO_SUPPLY_POINTS_ROUND_CONSTANT))
global.cargoprices[name] = cost

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/_item_force.dm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@

text2file(jointext(rows, "\n"), "weapon_stats_dump.csv")
if(fexists("weapon_stats_dump.csv"))
direct_output(usr, ftp("weapon_stats_dump.csv", "weapon_stats_dump.csv"))
ftp_to(usr, "weapon_stats_dump.csv", "weapon_stats_dump.csv")
to_chat(usr, "Done.")
*/
9 changes: 9 additions & 0 deletions code/game/objects/structures/flora/tree.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,22 @@
/obj/structure/flora/tree/pine/init_appearance()
icon_state = "pine_[rand(1, 3)]"

var/global/list/christmas_trees = list()
/obj/structure/flora/tree/pine/xmas
name = "\improper Christmas tree"
desc = "O Christmas tree, O Christmas tree..."
icon = 'icons/obj/flora/pinetrees.dmi'
icon_state = "pine_c"
stump_type = /obj/structure/flora/stump/tree/pine/xmas

/obj/structure/flora/tree/pine/xmas/Initialize(ml, _mat, _reinf_mat)
. = ..()
global.christmas_trees += src

/obj/structure/flora/tree/pine/xmas/Destroy()
global.christmas_trees -= src
return ..()

/obj/structure/flora/tree/pine/xmas/init_appearance()
return //Only one possible icon

Expand Down
4 changes: 2 additions & 2 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var/global/world_topic_last = world.timeofday
throttle[2] = reason

/world/Topic(T, addr, master, key)
direct_output(diary, "TOPIC: \"[T]\", from:[addr], master:[master], key:[key][log_end]")
to_file(diary, "TOPIC: \"[T]\", from:[addr], master:[master], key:[key][log_end]")

if (global.world_topic_last > world.timeofday)
global.world_topic_throttle = list() //probably passed midnight
Expand Down Expand Up @@ -201,7 +201,7 @@ var/global/_reboot_announced = FALSE
/world/proc/save_mode(var/the_mode)
var/F = file("data/mode.txt")
fdel(F)
direct_output(F, the_mode)
to_file(F, the_mode)

/world/proc/load_motd()
join_motd = safe_file2text("config/motd.txt", FALSE)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ var/global/BSACooldown = 0
dat += "<A href='byond://?src=\ref[src];remove_player_info=[key];remove_index=[i]'>Remove</A>"
dat += "<hr></li>"
if(update_file)
direct_output(info, infos)
to_file(info, infos)

dat += "</ul><br><A href='byond://?src=\ref[src];add_player_info=[key]'>Add Comment</A><br>"

Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
else if(task == "permissions")
if(!D) return
var/list/permissionlist = list()
for(var/i=1, i<=R_MAXPERMISSION, i<<=1) //that <<= is shorthand for i = i << 1. Which is a left BITSHIFT_LEFT
for(var/i=1, i<=R_MAXPERMISSION, i = BITSHIFT_LEFT(i, 1))
permissionlist[rights2text(i)] = i
var/new_permission = input("Select a permission to turn on/off", "Permission toggle", null, null) as null|anything in permissionlist
if(!new_permission) return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/verbs/diagnostics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
var/inactive_groups = SSair.zones.len - active_groups

var/hotspots = 0
for(var/obj/fire/hotspot in world)
for(var/obj/fire/hotspot in SSair.active_hotspots)
hotspots++

var/active_on_main_station = 0
Expand Down
4 changes: 2 additions & 2 deletions code/modules/admin/verbs/getlogs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
return

message_admins("[key_name_admin(src)] accessed file: [path]")
direct_output(src, run(file(path)))
open_file_for(src, file(path))
to_chat(src, "Attempting to send file, this may take a fair few minutes if the file is very large.")
return

Expand All @@ -64,6 +64,6 @@
set name = "Show Server Log"
set desc = "Shows today's server log."

direct_output(usr, run(diary))
open_file_for(usr, diary)
SSstatistics.add_field_details("admin_verb","VTL") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
return
19 changes: 17 additions & 2 deletions code/modules/admin/verbs/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
var/global/camera_range_display_status = 0
var/global/intercom_range_display_status = 0

var/global/list/debug_camera_range_markers = list()
/obj/effect/debugging/camera_range
icon = 'icons/480x480.dmi'
icon_state = "25percent"
Expand All @@ -33,11 +34,25 @@ var/global/intercom_range_display_status = 0
default_pixel_x = -224
default_pixel_y = -224
reset_offsets(0)
global.debug_camera_range_markers += src

/obj/effect/debugging/camera_range/Destroy()
global.debug_camera_range_markers -= src
return ..()

var/global/list/mapping_debugging_markers = list()
/obj/effect/debugging/marker
icon = 'icons/turf/areas.dmi'
icon_state = "yellow"

/obj/effect/debugging/marker/Initialize(mapload)
. = ..()
global.mapping_debugging_markers += src

/obj/effect/debugging/marker/Destroy()
global.mapping_debugging_markers -= src
return ..()

/obj/effect/debugging/marker/Move()
return 0

Expand All @@ -56,7 +71,7 @@ var/global/intercom_range_display_status = 0



for(var/obj/effect/debugging/camera_range/C in world)
for(var/obj/effect/debugging/camera_range/C as anything in debug_camera_range_markers)
qdel(C)

if(camera_range_display_status)
Expand Down Expand Up @@ -113,7 +128,7 @@ var/global/intercom_range_display_status = 0
else
intercom_range_display_status = 1

for(var/obj/effect/debugging/marker/M in world)
for(var/obj/effect/debugging/marker/M in global.mapping_debugging_markers)
qdel(M)

if(intercom_range_display_status)
Expand Down
6 changes: 3 additions & 3 deletions code/modules/admin/view_variables/helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
return {"
<a href='byond://?_src_=vars;datumedit=\ref[src];varnameedit=name'><b>[src]</b></a>
<br><font size='1'>
<a href='byond://?_src_=vars;rotatedatum=\ref[src];rotatedir=left'><<</a>
<a href='byond://?_src_=vars;rotatedatum=\ref[src];rotatedir=left'>\<\<</a>
<a href='byond://?_src_=vars;datumedit=\ref[src];varnameedit=dir'>[dir2text(dir)]</a>
<a href='byond://?_src_=vars;rotatedatum=\ref[src];rotatedir=right'>>></a>
<a href='byond://?_src_=vars;rotatedatum=\ref[src];rotatedir=right'>\>\></a>
</font>
"}

/mob/living/get_view_variables_header()
return {"
<a href='byond://?_src_=vars;rename=\ref[src]'><b>[src]</b></a><font size='1'>
<br><a href='byond://?_src_=vars;rotatedatum=\ref[src];rotatedir=left'><<</a> <a href='byond://?_src_=vars;datumedit=\ref[src];varnameedit=dir'>[dir2text(dir)]</a> <a href='byond://?_src_=vars;rotatedatum=\ref[src];rotatedir=right'>>></a>
<br><a href='byond://?_src_=vars;rotatedatum=\ref[src];rotatedir=left'>\<\<</a> <a href='byond://?_src_=vars;datumedit=\ref[src];varnameedit=dir'>[dir2text(dir)]</a> <a href='byond://?_src_=vars;rotatedatum=\ref[src];rotatedir=right'>\>\></a>
<br><a href='byond://?_src_=vars;datumedit=\ref[src];varnameedit=ckey'>[ckey ? ckey : "No ckey"]</a> / <a href='byond://?_src_=vars;datumedit=\ref[src];varnameedit=real_name'>[real_name ? real_name : "No real name"]</a>
<br>
BRUTE:<a href='byond://?_src_=vars;mobToDamage=\ref[src];adjustDamage=[BRUTE]'>[get_damage(BRUTE)]</a>
Expand Down
4 changes: 2 additions & 2 deletions code/modules/client/asset_cache.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ You can set verify to TRUE if you want send() to sleep until the client has the
client.sending |= asset_name
var/job = ++client.last_asset_job

direct_output(client, browse("<script>window.location.href='byond://?asset_cache_confirm_arrival=[job]'</script>", "window=asset_cache_browser"))
show_browser(client, "<script>window.location.href='byond://?asset_cache_confirm_arrival=[job]'</script>", "window=asset_cache_browser")

var/t = 0
var/timeout_time = (ASSET_CACHE_SEND_TIMEOUT * client.sending.len) + ASSET_CACHE_SEND_TIMEOUT
Expand Down Expand Up @@ -85,7 +85,7 @@ You can set verify to TRUE if you want send() to sleep until the client has the
client.sending |= unreceived
var/job = ++client.last_asset_job

direct_output(client, browse("<script>window.location.href='byond://?asset_cache_confirm_arrival=[job]'</script>", "window=asset_cache_browser"))
show_browser(client, "<script>window.location.href='byond://?asset_cache_confirm_arrival=[job]'</script>", "window=asset_cache_browser")

var/t = 0
var/timeout_time = ASSET_CACHE_SEND_TIMEOUT * client.sending.len
Expand Down
2 changes: 1 addition & 1 deletion code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ var/global/list/time_prefs_fixed = list()
return
if(href_list["preference"] == "open_whitelist_forum")
if(get_config_value(/decl/config/text/forumurl))
direct_output(user, link(get_config_value(/decl/config/text/forumurl)))
open_link(user, get_config_value(/decl/config/text/forumurl))
else
to_chat(user, "<span class='danger'>The forum URL is not set in the server configuration.</span>")
return
Expand Down
16 changes: 8 additions & 8 deletions code/modules/holidays/holiday_special.dm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/datum/holiday/christmas/New()
..()
/datum/holiday/christmas
announcement = "Merry Christmas, everyone!"

/datum/holiday/christmas/set_up_holiday()
for(var/obj/structure/flora/tree/pine/xmas in world)
if(isNotStationLevel(xmas.z))
for(var/obj/structure/flora/tree/pine/xmas/crimmas_tree in global.christmas_trees)
if(isNotStationLevel(crimmas_tree.z))
continue
for(var/turf/T in orange(1,xmas))
if(T.is_floor() && T.simulated)
for(var/i = 1 to rand(1,5))
new /obj/item/a_gift(T)
for(var/turf/T in orange(1, crimmas_tree))
if(!T.is_floor() || !T.simulated)
continue
for(var/i = 1 to rand(1,5))
new /obj/item/a_gift(T)
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/robot/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@
sleep(5)
to_chat(src, "<span class='danger'>Would you like to send a report to the vendor? Y/N</span>")
sleep(10)
to_chat(src, "<span class='danger'>> N</span>")
to_chat(src, "<span class='danger'>\> N</span>")
sleep(20)
to_chat(src, "<span class='danger'>ERRORERRORERROR</span>")
to_chat(src, "<b>Obey these laws:</b>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

var/started_on = 0 // When the program started some science.
var/current_interval = 0 // How long the current interval will be.
var/next_event = 0 // in world timeofday, when the next event is scheduled to pop.
var/next_event = 0 // based on world.timeofday, when the next event is scheduled to pop.
var/program_status = PROGRAM_STATUS_RUNNING // Program periodically needs a restart, increases crash chance slightly over time.
var/crashed_at = 0 // When the program crashed.

Expand Down
18 changes: 9 additions & 9 deletions code/modules/modular_computers/terminal/terminal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
account_name = "LOCAL"
else
account_name = "GUEST"
content += "<form action='byond://'><input type='hidden' name='src' value='\ref[src]'>>[account_name]:/[current_disk?.get_dir_path(current_directory, TRUE)]<input type='text' size='40' name='input' autofocus><input type='submit' value='Enter'></form>"
content += "<form action='byond://'><input type='hidden' name='src' value='\ref[src]'\>\>[account_name]:/[current_disk?.get_dir_path(current_directory, TRUE)]<input type='text' size='40' name='input' autofocus><input type='submit' value='Enter'></form>"
content += "<i>type `man` for a list of available commands.</i>"
panel.set_content("<tt>[jointext(content, "<br>")]</tt>")

Expand Down Expand Up @@ -159,7 +159,7 @@
/datum/terminal/proc/parse_directory(directory_path, create_directories = FALSE)
var/datum/file_storage/target_disk = current_disk
var/datum/computer_file/directory/root_dir = current_directory

if(!length(directory_path))
return list(target_disk, root_dir)

Expand All @@ -168,8 +168,8 @@

// Otherwise, we append the working directory path to the passed path.
var/list/directories = splittext(directory_path, "/")
// When splitting the text, there could be blank strings at either end, so remove them. If there's any in the body of the path, there was a

// When splitting the text, there could be blank strings at either end, so remove them. If there's any in the body of the path, there was a
// missed input, so leave them.
if(!length(directories[1]))
directories.Cut(1, 2)
Expand All @@ -194,7 +194,7 @@
if(!target_disk) // Invalid disk entered.
return OS_DIR_NOT_FOUND
directories.Cut(1, 2)

break // Any further use of ../ is handled by the hard drive.

// If we were only pathing to the parent of a directory or to a disk, we can return early.
Expand All @@ -208,7 +208,7 @@
var/datum/computer_file/directory/target_directory = target_disk.parse_directory(final_path, create_directories)
if(!istype(target_directory))
return OS_DIR_NOT_FOUND

return list(target_disk, target_directory)

// Returns list(/datum/file_storage, /datum/computer_file/directory, /datum/computer_file) on success. Returns error code on failure.
Expand All @@ -221,7 +221,7 @@
var/list/dirs_and_file = splittext(file_path, "/")
if(!length(dirs_and_file))
return OS_DIR_NOT_FOUND

// Join together everything but the filename into a path.
var/list/file_loc = parse_directory(jointext(dirs_and_file, "/", 1, dirs_and_file.len))
if(!islist(file_loc)) // Errored!
Expand All @@ -231,7 +231,7 @@
var/datum/computer_file/directory/target_dir = file_loc[2]
if(!istype(target_disk))
return OS_DIR_NOT_FOUND

var/filename = dirs_and_file[dirs_and_file.len]
var/datum/computer_file/target_file = target_disk.get_file(filename, target_dir)
if(!istype(target_file))
Expand Down Expand Up @@ -265,5 +265,5 @@
return "I/O error, Harddrive may be non-functional"
if(OS_NETWORK_ERROR)
return "Unable to connect to the network"

return "An unspecified error occured."
1 change: 0 additions & 1 deletion code/modules/overmap/contacts/_contacts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

radar = image(loc = effect, icon = 'icons/obj/overmap.dmi', icon_state = "sensor_range")
radar.color = source.color
radar.tag = "radar"
MistakeNot4892 marked this conversation as resolved.
Show resolved Hide resolved
radar.add_filter("blur", 1, list(type = "blur", size = 1))
radar.appearance_flags |= RESET_TRANSFORM | KEEP_APART
radar.appearance_flags &= ~PIXEL_SCALE
Expand Down
Loading