Files
ClassicAPI/src/item/scrape/AuctionSellID.cpp
T
Brues 48c2c83bd3 refactor(offsets): one name per engine address and per DBC column
Offsets.h named the same address or field twice in ten places, against
its own single-source rule. A sweep for equal addresses found nine; the
tenth is a column pair. Each now has one name:

- 0x468460 (the object resolver) was also FUN_GET_OBJECT_BY_GUID and
  FUN_OBJECT_FROM_GUID, called through local typedefs (one a __thiscall
  form) in mail/SendMailItemLink, item/scrape/AuctionSellID and
  cursor/Info. Those now call Object::ByGuid, which also gates on the
  registry; OBJECT_TYPE_ITEM goes for TYPEMASK_ITEM.
- 0x6F3BC0 was LUA_RAWGETI and FUN_FRAMESCRIPT_PUSH_OBJECT; its three
  callers use Game::Lua::RawGetI. 0x6F3740 (lua_touserdata) becomes
  LUA_TO_USERDATA beside the other Lua C API names.
- 0x605570: FUN_UNIT_CREATURE_TYPE (was also FUN_UNIT_PET_MINION_CLASS).
- 0xB4B2BC: VAR_GAME_STATE_PTR (was also VAR_WORLDFRAME_CLICK_INFO).
- 0xBC6F48: VAR_PARTY_GUIDS (was also VAR_PARTY_MEMBER_GUIDS).
- 0xBB4AA8: VAR_TAXI_NODE_COUNT (was also VAR_TAXI_MAP_NODE_COUNT).
- 0xCECAC0: VAR_SPELL_TARGETING_FLAGS (was also
  VAR_SPELL_PLACEMENT_STATE).
- Backpack linear base 23: INVMGR_BACKPACK_FIRST_SLOT (was also
  BACKPACK_LINEAR_BASE).
- Spell.dbc School (+0x04): OFF_SPELL_RECORD_SCHOOL (was also
  OFF_SPELL_SCHOOL); EffectItemType (+0x19C): OFF_SPELL_RECORD_EFFECT_ITEM_TYPE
  (was also OFF_SPELL_RECORD_CREATED_ITEM).

The surviving entry keeps both comments.
2026-11-15 16:46:43 -06:00

73 lines
2.6 KiB
C++

// This file is part of ClassicAPI.
//
// ClassicAPI is free software: you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// ClassicAPI is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// ClassicAPI. If not, see <https://www.gnu.org/licenses/>.
#include "Game.h"
#include "Offsets.h"
#include "item/ID.h"
#include "object/Resolve.h"
#include <cstdint>
namespace Item::AuctionSellID {
namespace {
// Engine's typed object lookup. Pass the typeCode in ECX and the
// 64-bit GUID split into low/high on the stack. The third stack arg
// is a `__LINE__`-style debug hint that the function reads only for
// asserts — anything works at runtime.
} // namespace
// `GetAuctionSellItemID()` — itemID companion to the engine's
// `GetAuctionSellItemInfo` (which returns name/texture/count/quality
// for the item currently sitting in the auction-sell slot, but does
// NOT return itemID). nil when the sell slot is empty.
static int __fastcall Script_GetAuctionSellItemID(void *L) {
const uint32_t guidLo = *reinterpret_cast<const uint32_t *>(
Offsets::VAR_AUCTION_SELL_GUID_LO);
const uint32_t guidHi = *reinterpret_cast<const uint32_t *>(
Offsets::VAR_AUCTION_SELL_GUID_HI);
if ((guidLo | guidHi) == 0)
return 0;
const uint64_t guid = (static_cast<uint64_t>(guidHi) << 32) | guidLo;
auto *item = static_cast<uint8_t *>(
Object::ByGuid(Offsets::TYPEMASK_ITEM, guid, nullptr, 0));
if (item == nullptr)
return 0;
const int itemID = Item::ID::FromCGItem(item);
if (itemID == 0)
return 0;
Game::Lua::PushNumber(L, static_cast<double>(itemID));
return 1;
}
static const Game::Doc::Field kRets[] = {
Game::Doc::Opt("itemID", "number", nullptr, "Nil when the sell slot is empty."),
};
static const Game::Doc::Function kGetAuctionSellItemID{
"Returns the item ID of the item in the auction house sell slot.", {}, kRets,
"ItemGlobals", true};
static void RegisterLuaFunctions() {
Game::Lua::RegisterGlobalFunction("GetAuctionSellItemID", &Script_GetAuctionSellItemID,
&kGetAuctionSellItemID);
}
static const Game::ModuleAutoRegister _autoreg{&RegisterLuaFunctions};
} // namespace Item::AuctionSellID