From 9b0e732fb8c27735075231057968770581a749c1 Mon Sep 17 00:00:00 2001 From: sindoring Date: Mon, 27 Jul 2026 01:29:47 +0400 Subject: [PATCH] Fix creature previews in the store --- lua_scripts/Store_System/Store_Client.lua | 14 +++++++--- lua_scripts/Store_System/Store_DataStruct.lua | 26 ++++++++++++++++++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/lua_scripts/Store_System/Store_Client.lua b/lua_scripts/Store_System/Store_Client.lua index 8674a0743..5dd3764b5 100644 --- a/lua_scripts/Store_System/Store_Client.lua +++ b/lua_scripts/Store_System/Store_Client.lua @@ -64,7 +64,8 @@ local KEYS = { rewardCount_7 = 27, rewardCount_8 = 28, new = 29, - enabled = 30 + enabled = 30, + previewDisplayId = 31 }, } @@ -503,7 +504,7 @@ function SHOP_UI.ServiceBoxes_Create(parent) if(self.Type == 1 and service.Flags == 1) then SHOP_UI.ModelFrame_ShowPlayer(self.Rewards) elseif((self.Type == 3 or self.Type == 4) and self.DisplayId > 0) then -- Handler for creatures with models - SHOP_UI.ModelFrame_ShowCreature(self.DisplayId) + SHOP_UI.ModelFrame_ShowCreature(self.DisplayId, self.PreviewDisplayId) end -- Parchment page sound PlaySound(836) @@ -614,6 +615,7 @@ function SHOP_UI.ServiceBoxes_Update() service.Currency = serviceData[KEYS.service.currency] service.TooltipHyperlink = serviceData[KEYS.service.hyperlink] service.DisplayId = serviceData[KEYS.service.displayId] + service.PreviewDisplayId = serviceData[KEYS.service.previewDisplayId] or 0 service.Discount = serviceData[KEYS.service.discount] service.Flags = serviceData[KEYS.service.flags] service.New = serviceData[KEYS.service.new] @@ -1150,7 +1152,7 @@ function SHOP_UI.ModelFrame_ShowPlayer(displayId) PlaySound("INTERFACESOUND_GAMESCROLLBUTTON", "Master") end -function SHOP_UI.ModelFrame_ShowCreature(displayId) +function SHOP_UI.ModelFrame_ShowCreature(creatureEntry, previewDisplayId) -- hacky ass model frame handling -- hide model frames if(SHOP_UI["MODEL_FRAME"].playerModel:IsShown()) then @@ -1161,7 +1163,11 @@ function SHOP_UI.ModelFrame_ShowCreature(displayId) SHOP_UI["MODEL_FRAME"]:Hide() -- set the correct unit and show frame - SHOP_UI["MODEL_FRAME"].creatureModel:SetCreature(displayId) + if(previewDisplayId and previewDisplayId > 0) then + SHOP_UI["MODEL_FRAME"].creatureModel:SetCreature(creatureEntry, previewDisplayId) + else + SHOP_UI["MODEL_FRAME"].creatureModel:SetCreature(creatureEntry) + end SHOP_UI["MODEL_FRAME"].creatureModel:Show() SHOP_UI["MODEL_FRAME"]:Show() diff --git a/lua_scripts/Store_System/Store_DataStruct.lua b/lua_scripts/Store_System/Store_DataStruct.lua index 04806d28a..6aa733a5c 100644 --- a/lua_scripts/Store_System/Store_DataStruct.lua +++ b/lua_scripts/Store_System/Store_DataStruct.lua @@ -59,7 +59,8 @@ local KEYS = { rewardCount_7 = 27, rewardCount_8 = 28, new = 29, - enabled = 30 + enabled = 30, + previewDisplayId = 31 }, } @@ -139,6 +140,8 @@ function ServiceData.Load() Query:GetUInt32(KEYS.service.rewardCount_7), Query:GetUInt32(KEYS.service.rewardCount_8), Query:GetUInt32(KEYS.service.new), + Query:GetUInt32(KEYS.service.enabled), + 0, } end until not Query:NextRow() @@ -224,6 +227,27 @@ function CreatureDisplays.Load() until not ModelQuery:NextRow() end end + + -- Keep the creature entry for the stock preview path, but also send its + -- primary CreatureDisplayInfo ID. WarcraftXL can apply that display + -- directly, avoiding stale or missing client creature-cache records. + for _, service in pairs(ServiceData.Cache) do + local serviceType = service[KEYS.service.serviceType] + local entry = service[KEYS.service.displayOrEntry] + if ((serviceType == 3 or serviceType == 4) and entry > 0) then + local creature = CreatureDisplays.Cache[entry] + local displayId = 0 + if (creature) then + for modelIndex = 11, 14 do + if (creature[modelIndex] and creature[modelIndex] > 0) then + displayId = creature[modelIndex] + break + end + end + end + service[KEYS.service.previewDisplayId] = displayId + end + end end function LinkData.Load()