From 78be1611c3d3113fb7d4d6e6e19b0d54ace7cb31 Mon Sep 17 00:00:00 2001 From: Luke aka SwissalpS Date: Thu, 28 Nov 2024 12:55:46 +0100 Subject: [PATCH] cap max amount of layers fixes #5 --- init.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/init.lua b/init.lua index b3270b9..af70ff0 100644 --- a/init.lua +++ b/init.lua @@ -29,6 +29,16 @@ banners.masks = { "star_chevron", "checkered_8_4", "checkered_16_8" } +-- The amount of transformations needs to be capped somewhere +-- to avoid crashing server. +-- It doesn't make sense to have any one mask multiple times +-- but users normally don't follow strict logic when being +-- creative, so we give them plenty of space to work with. +-- A better approach would be to strip duplicates and to +-- drop all previous masks if a full background is dropped +-- on top of other masks. +banners.max_transformations = #banners.masks * #banners.masks + banners.colors = { "black", "cyan", "green", "white", "blue", "darkblue", "red", "yellow", @@ -134,6 +144,9 @@ function banners.Banner:new(banner) end function banners.Banner.push_transform(self, transform) table.insert(self.transforms, transform) + if #self.transforms > banners.max_transformations then + table.remove(self.transforms, 1) + end end function banners.Banner.pop_transform(self) table.remove(self.transforms)