Skip to content

Commit

Permalink
Readd cooldowns on the world topic
Browse files Browse the repository at this point in the history
Thanks to whomever removed these, you're a real star
  • Loading branch information
optimumtact committed Jan 2, 2020
1 parent 83c3452 commit b86e0b5
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions code/game/world.dm
@@ -1,4 +1,6 @@
#define RESTART_COUNTER_PATH "data/round_counter.txt"
#define MAX_TOPIC_LEN 100
#define TOPIC_BANNED 1

GLOBAL_VAR(restart_counter)

Expand Down Expand Up @@ -164,10 +166,30 @@ GLOBAL_VAR(restart_counter)
log_runtime(GLOB.revdata.get_log_message())

/world/Topic(T, addr, master, key)
TGS_TOPIC //redirect to server tools if necessary

var/static/list/bannedsourceaddrs = list()
var/static/list/lasttimeaddr = list()
var/static/list/topic_handlers = TopicHandlers()

//LEAVE THIS COOLDOWN HANDLING IN PLACE, OR SO HELP ME I WILL MAKE YOU SUFFER
if (addr in bannedsourceaddrs)
return

if (T.length >= MAX_TOPIC_LEN)
log_admin("[addr] banned from topic calls for a round for too long status message")
bannedsourceaddrs[addr] = TOPIC_BANNED
return
if (addr in lasttimeaddr)
var/lasttime = lasttimeaddr[addr]
if(world.time < (lasttime + 2 SECONDS))
log_admin("[addr] banned from topic calls for a round for too frequent messages")
bannedsourceaddrs[addr] = TOPIC_BANNED
return

lasttimeaddr[addr] = world.time


TGS_TOPIC //redirect to server tools if necessary

var/list/input = params2list(T)
var/datum/world_topic/handler
for(var/I in topic_handlers)
Expand Down

0 comments on commit b86e0b5

Please sign in to comment.