From 36e1c715fcecb8a5b1620ae04e074f25ae3d1b8f Mon Sep 17 00:00:00 2001 From: Tralenor <76077537+Tralenor@users.noreply.github.com> Date: Sat, 15 Jun 2024 13:11:46 +0200 Subject: [PATCH] fix: gossip menu item overflow (#180) Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com> --- src/LuaEngine/PlayerMethods.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/LuaEngine/PlayerMethods.h b/src/LuaEngine/PlayerMethods.h index 8ede7c84fd..0960182626 100644 --- a/src/LuaEngine/PlayerMethods.h +++ b/src/LuaEngine/PlayerMethods.h @@ -8,6 +8,7 @@ #define PLAYERMETHODS_H #include "GameTime.h" +#include "GossipDef.h" /*** * Inherits all methods from: [Object], [WorldObject], [Unit] @@ -4038,7 +4039,15 @@ namespace LuaPlayer const char* _promptMsg = Eluna::CHECKVAL(L, 7, ""); uint32 _money = Eluna::CHECKVAL(L, 8, 0); #if defined TRINITY || AZEROTHCORE - player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, _icon, msg, _sender, _intid, _promptMsg, _money, _code); + if (player->PlayerTalkClass->GetGossipMenu().GetMenuItemCount() < GOSSIP_MAX_MENU_ITEMS) + { + player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, _icon, msg, _sender, _intid, _promptMsg, _money, + _code); + } + else + { + return luaL_error(L, "GossipMenuItem not added. Reached Max amount of possible GossipMenuItems in this GossipMenu"); + } #else #ifndef CLASSIC player->PlayerTalkClass->GetGossipMenu().AddMenuItem(_icon, msg, _sender, _intid, _promptMsg, _money, _code);