From cbf10d8a01aeaa4af5c289644a1adaa92cb0c48b Mon Sep 17 00:00:00 2001 From: oranges Date: Wed, 6 May 2020 23:49:52 +1200 Subject: [PATCH] Fixes overlay subsystem being lenient on large amounts of overlays (#50915) --- code/_compile_options.dm | 4 ++++ code/controllers/subsystem/overlays.dm | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/code/_compile_options.dm b/code/_compile_options.dm index fad4eee1d47..9c845e3201d 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -56,3 +56,7 @@ #ifdef TRAVISTESTING #define TESTING #endif + +// A reasonable number of maximum overlays an object needs +// If you think you need more, rethink it +#define MAX_ATOM_OVERLAYS 100 diff --git a/code/controllers/subsystem/overlays.dm b/code/controllers/subsystem/overlays.dm index 20eb2af001e..c0cc225b8d9 100644 --- a/code/controllers/subsystem/overlays.dm +++ b/code/controllers/subsystem/overlays.dm @@ -47,8 +47,13 @@ SUBSYSTEM_DEF(overlays) for (var/thing in queue) count++ if(thing) - STAT_START_STOPWATCH var/atom/A = thing + if(A.overlays.len >= MAX_ATOM_OVERLAYS) + //Break it real GOOD + stack_trace("Too many overlays on [A.type] - [A.overlays.len], refusing to update and cutting") + A.overlays.Cut() + continue + STAT_START_STOPWATCH COMPILE_OVERLAYS(A) STAT_STOP_STOPWATCH STAT_LOG_ENTRY(stats, A.type)