From 24a1615706532028ed397c6a35eb5019e4e47863 Mon Sep 17 00:00:00 2001 From: David Vogel Date: Mon, 5 Feb 2024 16:14:48 +0100 Subject: [PATCH] Prevent duplicate modification entries in message --- files/message.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/files/message.lua b/files/message.lua index 1260415..dc7c520 100644 --- a/files/message.lua +++ b/files/message.lua @@ -192,8 +192,19 @@ function Message:ShowModificationUnsupported(realm, name, value) Type = "warning", } + -- Create or append to list of modifications. + -- We have to prevent duplicate entries. self.List["ModificationFailed"].ModificationEntries = self.List["ModificationFailed"].ModificationEntries or {} - table.insert(self.List["ModificationFailed"].ModificationEntries, {realm = realm, name = name, value = value}) + local found + for _, modEntry in ipairs(self.List["ModificationFailed"].ModificationEntries) do + if modEntry.realm == realm and modEntry.name == name then + found = true + break + end + end + if not found then + table.insert(self.List["ModificationFailed"].ModificationEntries, {realm = realm, name = name, value = value}) + end -- Build message lines. self.List["ModificationFailed"].Lines = {"The mod couldn't apply the following changes:"}