From 8e7c447646fb764caf2a7520e73d1b16e9013626 Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Sat, 2 Apr 2016 17:38:49 -0700 Subject: [PATCH] Ports tgstation/-tg-station#16569, World Topic() changes Full changes: - World Topic() is now standardized to use if("parameter" in topic_list) instead of an amalgamation of findtext() and if(topic == "parameter"). - Comms password is now verified at the top of world/Topic() and sets a variable to true if it is present and correct. - "status" now returns extra information if the comms_password is provided and correct. Misc changes: - Shuttle text has been standardized as a proc on mobile docking ports. This is used by status/supply displays and mob/Stat() for the -ETA- etc stuff. --- .gitignore | 1 + code/__DEFINES/stat.dm | 12 ++-- code/game/machinery/status_display.dm | 31 ++-------- code/game/machinery/supply_display.dm | 2 +- code/modules/mob/mob.dm | 25 +------- code/modules/shuttle/shuttle.dm | 26 +++++++++ code/world.dm | 84 +++++++++++++-------------- 7 files changed, 85 insertions(+), 96 deletions(-) diff --git a/.gitignore b/.gitignore index f784b30d80e..8c7388a42d2 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ data/ /_maps/map_files/**/*.dmm.backup /nano/debug.html *.db +.atom-build.json \ No newline at end of file diff --git a/code/__DEFINES/stat.dm b/code/__DEFINES/stat.dm index 756ae54765f..4ab2ba43203 100644 --- a/code/__DEFINES/stat.dm +++ b/code/__DEFINES/stat.dm @@ -34,10 +34,10 @@ #define WAIT_FINISH 3 //shuttle mode defines -#define SHUTTLE_IDLE 0 -#define SHUTTLE_RECALL 1 -#define SHUTTLE_CALL 2 -#define SHUTTLE_DOCKED 3 +#define SHUTTLE_IDLE 0 +#define SHUTTLE_RECALL 1 +#define SHUTTLE_CALL 2 +#define SHUTTLE_DOCKED 3 #define SHUTTLE_STRANDED 4 -#define SHUTTLE_ESCAPE 5 -#define SHUTTLE_ENDGAME 6 \ No newline at end of file +#define SHUTTLE_ESCAPE 5 +#define SHUTTLE_ENDGAME 6 \ No newline at end of file diff --git a/code/game/machinery/status_display.dm b/code/game/machinery/status_display.dm index 7c43e3c8e62..824d38df94c 100644 --- a/code/game/machinery/status_display.dm +++ b/code/game/machinery/status_display.dm @@ -88,25 +88,18 @@ remove_display() return 1 if(STATUS_DISPLAY_TRANSFER_SHUTTLE_TIME) //emergency shuttle timer + var/use_warn = 0 if(shuttle_master.emergency.timer) - message2 = get_shuttle_timer() - switch(shuttle_master.emergency.mode) - if(SHUTTLE_RECALL, SHUTTLE_ESCAPE) - message1 = "-ETR-" - if(SHUTTLE_CALL) - message1 = "-ETA-" - if(SHUTTLE_DOCKED) - message1 = "-ETD-" - else - message1 = "-ERR-" - message2 = "??:??" + use_warn = 1 + message1 = "-[shuttle_master.emergency.getModeStr()]" + message2 = shuttle_master.emergency.getTimerStr() + if(length(message2) > CHARS_PER_LINE) message2 = "Error!" - update_display(message1, message2, 1) else message1 = "TIME" message2 = worldtime2text() - update_display(message1, message2) + update_display(message1, message2, use_warn) return 1 if(STATUS_DISPLAY_MESSAGE) //custom messages var/line1 @@ -168,18 +161,6 @@ if(maptext != new_text) maptext = new_text -/obj/machinery/status_display/proc/get_shuttle_timer() - var/timeleft = shuttle_master.emergency.timeLeft() - if(timeleft > 0) - return "[add_zero(num2text((timeleft / 60) % 60),2)]:[add_zero(num2text(timeleft % 60), 2)]" - return "00:00" - -/obj/machinery/status_display/proc/get_supply_shuttle_timer() - var/timeleft = shuttle_master.supply.timeLeft() - if(timeleft > 0) - return "[add_zero(num2text((timeleft / 60) % 60),2)]:[add_zero(num2text(timeleft % 60), 2)]" - return "00:00" - /obj/machinery/status_display/proc/remove_display() if(overlays.len) overlays.Cut() diff --git a/code/game/machinery/supply_display.dm b/code/game/machinery/supply_display.dm index 2bc51b495f3..ebe6459b996 100644 --- a/code/game/machinery/supply_display.dm +++ b/code/game/machinery/supply_display.dm @@ -13,7 +13,7 @@ message2 = worldtime2text() else message1 = "CARGO" - message2 = get_supply_shuttle_timer() + shuttle_master.supply.getTimerStr() if(lentext(message2) > CHARS_PER_LINE) message2 = "Error" diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 2fcd5406946..57dfec1d00a 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -995,28 +995,9 @@ var/list/slot_equipment_priority = list( \ /mob/proc/show_stat_emergency_shuttle_eta() var/obj/docking_port/mobile/emergency/E = shuttle_master.emergency - if(E.mode >= SHUTTLE_RECALL) - var/message = "" - - var/timeleft = E.timeLeft() - message = "[add_zero(num2text((timeleft / 60) % 60),2)]:[add_zero(num2text(timeleft % 60), 2)]" - - switch(E.mode) - if(SHUTTLE_RECALL, SHUTTLE_ESCAPE) - message = "ETR-[message]" - if(SHUTTLE_CALL) - message = "ETA-[message]" - if(SHUTTLE_DOCKED) - if(timeleft < 5) - message = "Departing..." - else - message = "ETD-[message]" - if(SHUTTLE_STRANDED) - message = "ETA-ERR" - if(SHUTTLE_ENDGAME) - return - - stat(null, message) + var/ETA = shuttle_master.emergency.getModeStr() + if(ETA) + stat(null, "[ETA] [shuttle_master.emergency.getTimerStr()]") /mob/proc/add_stings_to_statpanel(var/list/stings) for(var/obj/effect/proc_holder/changeling/S in stings) diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index 290f8e0fc75..0c09b0ea920 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -563,6 +563,32 @@ return round(callTime/divisor, 1) return max( round((timer+callTime-world.time)/divisor,1), 0 ) +// returns 3-letter mode string, used by status screens and mob status panel +/obj/docking_port/mobile/proc/getModeStr() + switch(mode) + if(SHUTTLE_RECALL) + return "RCL" + if(SHUTTLE_CALL) + return "ETA" + if(SHUTTLE_DOCKED) + return "ETD" + if(SHUTTLE_ESCAPE) + return "ESC" + if(SHUTTLE_STRANDED) + return "ERR" + return "" + +// returns 5-letter timer string, used by status screens and mob status panel +/obj/docking_port/mobile/proc/getTimerStr() + if(mode == SHUTTLE_STRANDED) + return "--:--" + + var/timeleft = timeLeft() + if(timeleft > 0) + return "[add_zero(num2text((timeleft / 60) % 60),2)]:[add_zero(num2text(timeleft % 60), 2)]" + else + return "00:00" + /obj/docking_port/mobile/proc/getStatusText() var/obj/docking_port/stationary/dockedAt = get_docked() . = (dockedAt && dockedAt.name) ? dockedAt.name : "unknown" diff --git a/code/world.dm b/code/world.dm index 5f60f4aa5cf..899a3ca1b3a 100644 --- a/code/world.dm +++ b/code/world.dm @@ -98,20 +98,23 @@ var/world_topic_spam_protect_time = world.timeofday /world/Topic(T, addr, master, key) diary << "TOPIC: \"[T]\", from:[addr], master:[master], key:[key]" - if (T == "ping") + var/list/input = params2list(T) + var/key_valid = (config.comms_password && input["key"] == config.comms_password) //no password means no comms, not any password + + if ("ping" in input) var/x = 1 for (var/client/C) x++ return x - else if(T == "players") + else if("players" in input) var/n = 0 for(var/mob/M in player_list) if(M.client) n++ return n - else if (T == "status") + else if ("status" in input) var/list/s = list() s["version"] = game_version s["mode"] = master_mode @@ -122,25 +125,35 @@ var/world_topic_spam_protect_time = world.timeofday s["host"] = host ? host : null s["players"] = list() s["stationtime"] = worldtime2text() - var/n = 0 - var/admins = 0 + var/player_count = 0 + var/admin_count = 0 for(var/client/C in clients) if(C.holder) if(C.holder.fakekey) continue //so stealthmins aren't revealed by the hub - admins++ - s["player[n]"] = C.key - n++ - s["players"] = n - -// if(revdata) s["revision"] = revdata.revision - s["admins"] = admins + admin_count++ + s["player[player_count]"] = C.key + player_count++ + s["players"] = player_count + s["admins"] = admin_count s["map_name"] = map_name ? map_name : "Unknown" + if(key_valid) + if(ticker && ticker.mode) + s["real_mode"] = ticker.mode.name + + s["security_level"] = get_security_level() + + if(shuttle_master && shuttle_master.emergency) + // Shuttle status, see /__DEFINES/stat.dm + s["shuttle_mode"] = shuttle_master.emergency.mode + // Shuttle timer, in seconds + s["shuttle_timer"] = shuttle_master.emergency.timeLeft() + return list2params(s) - else if(copytext(T,1,9) == "adminmsg") + else if("adminmsg" in input) /* We got an adminmsg from IRC bot lets split the input then validate the input. expected output: @@ -149,20 +162,8 @@ var/world_topic_spam_protect_time = world.timeofday 3. validatationkey = the key the bot has, it should match the gameservers commspassword in it's configuration. 4. sender = the ircnick that send the message. */ - - - var/input[] = params2list(T) - if(input["key"] != config.comms_password) - if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50) - - spawn(50) - world_topic_spam_protect_time = world.time - return "Bad Key (Throttled)" - - world_topic_spam_protect_time = world.time - world_topic_spam_protect_ip = addr - - return "Bad Key" + if(!key_valid) + return keySpamProtect(addr) var/client/C @@ -182,36 +183,25 @@ var/world_topic_spam_protect_time = world.timeofday C << 'sound/effects/adminhelp.ogg' C << message - for(var/client/A in admins) if(A != C) A << amessage return "Message Successful" - else if(copytext(T,1,6) == "notes") + else if("notes" in input) /* We got a request for notes from the IRC Bot expected output: 1. notes = ckey of person the notes lookup is for 2. validationkey = the key the bot has, it should match the gameservers commspassword in it's configuration. */ - var/input[] = params2list(T) - if(input["key"] != config.comms_password) - if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50) - - spawn(50) - world_topic_spam_protect_time = world.time - return "Bad Key (Throttled)" - - world_topic_spam_protect_time = world.time - world_topic_spam_protect_ip = addr - return "Bad Key" + if(!key_valid) + return keySpamProtect(addr) return show_player_info_irc(input["notes"]) - else if (copytext(T,1,9) == "announce") - var/input[] = params2list(T) + else if("announce" in input) if(config.comms_password) if(input["key"] != config.comms_password) return "Bad Key" @@ -219,6 +209,16 @@ var/world_topic_spam_protect_time = world.timeofday for(var/client/C in clients) C << "PR: [input["announce"]]" +/proc/keySpamProtect(var/addr) + if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50) + spawn(50) + world_topic_spam_protect_time = world.time + return "Bad Key (Throttled)" + + world_topic_spam_protect_time = world.time + world_topic_spam_protect_ip = addr + return "Bad Key" + /world/Reboot(var/reason, var/feedback_c, var/feedback_r, var/time) if (reason == 1) //special reboot, do none of the normal stuff if(usr)