feat(gossip): GetNumGossipOptions

3.3.5 pushes m_gossipOptionsCount; 1.12 keeps no count. Count the slots
1.12's Script_GetGossipOptions (0x4E28D0) pushes: every slot with a
non-negative index, no session check, so the count matches the list.
This commit is contained in:
Brues
2026-10-28 18:53:12 -05:00
parent 79d4b7f44d
commit 7d9dafbfcf
3 changed files with 37 additions and 1 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ In the Frame rows, a name that starts with `:` is a method of the widget that th
| [GameObject](docs/API.md#gameobject) | `C_GameObjectInfo.GetGameObjectInfoByID`, `C_GameObjectInfo.RequestLoadGameObjectByID`, `ClosestGameObjectPosition` |
| [Glue](docs/API.md#glue) | `C_Glue.IsOnGlueScreen` |
| [GameTooltip](docs/API.md#gametooltip) | `GameTooltip:AddSpellByID`, `GameTooltip:AddTexture`, `GameTooltip:GetGameObject`, `GameTooltip:GetItem`, `GameTooltip:GetMinimumWidth`, `GameTooltip:GetOwner`, `GameTooltip:GetPadding`, `GameTooltip:GetSpell`, `GameTooltip:GetUnit`, `GameTooltip:GetUnitGUID`, `GameTooltip:HasGameObject`, `GameTooltip:HasItem`, `GameTooltip:HasSpell`, `GameTooltip:HasUnit`, `GameTooltip:IsEquippedItem`, `GameTooltip:IsUnit`, `GameTooltip:SetAnchorType`, `GameTooltip:SetEquipmentSet`, `GameTooltip:SetFrameStack`, `GameTooltip:SetHyperlink` (full links, `spell:`, `quest:`), `GameTooltip:SetHyperlinkCompareItem`, `GameTooltip:SetInventoryItemByID`, `GameTooltip:SetItemByGUID`, `GameTooltip:SetItemByID`, `GameTooltip:SetSpellByID`, `GameTooltip:SetTalentByID`, `GameTooltip:SetTotem`, `GameTooltip:SetUnitAura`, `OnTooltipSetItem`, `OnTooltipSetSpell`, `OnTooltipSetUnit`, `OnTooltipSetGameObject`, `OnTooltipSetFrameStack` (scripts) |
| [Gossip](docs/API.md#gossip) | `C_GossipInfo.CloseGossip`, `C_GossipInfo.GetActiveQuests`, `C_GossipInfo.GetAvailableQuests`, `C_GossipInfo.GetNumActiveQuests`, `C_GossipInfo.GetNumAvailableQuests`, `C_GossipInfo.GetNumOptions`, `C_GossipInfo.GetOptions`, `C_GossipInfo.GetPoiForUiMapID`, `C_GossipInfo.GetPoiInfo`, `C_GossipInfo.GetText`, `C_GossipInfo.SelectActiveQuest`, `C_GossipInfo.SelectAvailableQuest`, `C_GossipInfo.SelectOption`, `C_GossipInfo.SelectOptionByIndex`, `GetNumGossipActiveQuests`, `GetNumGossipAvailableQuests` |
| [Gossip](docs/API.md#gossip) | `C_GossipInfo.CloseGossip`, `C_GossipInfo.GetActiveQuests`, `C_GossipInfo.GetAvailableQuests`, `C_GossipInfo.GetNumActiveQuests`, `C_GossipInfo.GetNumAvailableQuests`, `C_GossipInfo.GetNumOptions`, `C_GossipInfo.GetOptions`, `C_GossipInfo.GetPoiForUiMapID`, `C_GossipInfo.GetPoiInfo`, `C_GossipInfo.GetText`, `C_GossipInfo.SelectActiveQuest`, `C_GossipInfo.SelectAvailableQuest`, `C_GossipInfo.SelectOption`, `C_GossipInfo.SelectOptionByIndex`, `GetNumGossipActiveQuests`, `GetNumGossipAvailableQuests`, `GetNumGossipOptions` |
| [Hooks](docs/API.md#hooks) | `hooksecurefunc` |
| [Input](docs/API.md#input) | `GetMouseButtonClicked`, `GetMouseButtonName`, `IsLeftAltKeyDown`, `IsLeftControlKeyDown`, `IsLeftShiftKeyDown`, `IsModifierKeyDown`, `IsMouseButtonDown`, `IsRightAltKeyDown`, `IsRightControlKeyDown`, `IsRightShiftKeyDown` |
| [Instance](docs/API.md#instance) | `GetInstanceInfo`, `IsActiveBattlefieldArena` |
+13
View File
@@ -472,6 +472,7 @@ build instructions.
- [`C_GossipInfo.GetPoiForUiMapID(uiMapID)`](#c_gossipinfogetpoiforuimapiduimapid)
- [`C_GossipInfo.GetPoiInfo(uiMapID, gossipPoiID)`](#c_gossipinfogetpoiinfouimapid-gossippoiid)
- [`GetNumGossipAvailableQuests()` / `GetNumGossipActiveQuests()`](#getnumgossipavailablequests--getnumgossipactivequests)
- [`GetNumGossipOptions()`](#getnumgossipoptions)
- [Hooks](#hooks)
- [`hooksecurefunc(name, callback)` / `hooksecurefunc(table, name, callback)`](#hooksecurefuncname-callback--hooksecurefunctable-name-callback)
@@ -10829,6 +10830,18 @@ for i = 1, GetNumGossipAvailableQuests() do
end
```
### `GetNumGossipOptions()`
Returns the number of options that `GetGossipOptions()` returns. Each
option is one (text, type) pair, so the count always agrees with the list.
```lua
local options = { GetGossipOptions() }
for i = 1, GetNumGossipOptions() do
local text, gossipType = options[i * 2 - 1], options[i * 2]
end
```
## Hooks
### `hooksecurefunc(name, callback)` / `hooksecurefunc(table, name, callback)`
+23
View File
@@ -364,6 +364,27 @@ int __fastcall Script_GetNumGossipActiveQuests(void *L) {
return 1;
}
// `GetNumGossipOptions()` — 3.3.5 pushes m_gossipOptionsCount. 1.12 keeps no
// count and has no counter like the quest ones: Script_GetGossipOptions
// (0x004E28D0) walks all 16 slots, skips a negative index, and pushes a
// (text, type) pair per remaining slot, with no session check. This counts
// exactly those slots.
int __fastcall Script_GetNumGossipOptions(void *L) {
int count = 0;
for (int slot = 0; slot < Offsets::GOSSIP_OPTIONS_MAX; ++slot) {
if (OptionIndex(OptionEntry(slot)) >= 0)
count += 1;
}
Game::Lua::PushNumber(L, static_cast<double>(count));
return 1;
}
const Game::Doc::Field kNumOptionsRets[] = {
Game::Doc::Req("numOptions", "number", nullptr),
};
const Game::Doc::Function kGetNumGossipOptions{
"Returns the number of options GetGossipOptions returns.", {}, kNumOptionsRets, "GossipGlobals"};
// Selectors — translate the retail-shape arg into the engine's
// 0-based slot/index and call the engine helper directly. The helpers
// are what the `Script_SelectGossip*` Lua wrappers tail-call after
@@ -539,6 +560,8 @@ void RegisterLuaFunctions() {
&Script_GetNumGossipAvailableQuests);
Game::Lua::RegisterGlobalFunction("GetNumGossipActiveQuests",
&Script_GetNumGossipActiveQuests);
Game::Lua::RegisterGlobalFunction("GetNumGossipOptions", &Script_GetNumGossipOptions,
&kGetNumGossipOptions);
Game::Lua::RegisterTableFunction("C_GossipInfo", "SelectOption",
&Script_C_GossipInfo_SelectOption);
Game::Lua::RegisterTableFunction("C_GossipInfo", "SelectOptionByIndex",