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.
This commit is contained in:
Tigercat2000
2016-04-02 17:38:49 -07:00
parent a42bcb53e3
commit 8e7c447646
7 changed files with 85 additions and 96 deletions
+6 -6
View File
@@ -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
#define SHUTTLE_ESCAPE 5
#define SHUTTLE_ENDGAME 6
+6 -25
View File
@@ -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()
+1 -1
View File
@@ -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"
+3 -22
View File
@@ -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)
+26
View File
@@ -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"
+42 -42
View File
@@ -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 << "<span class='announce'>PR: [input["announce"]]</span>"
/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)