feat: add DBCStores access via Lua with getters for DBC entries (#222)

This commit is contained in:
iThorgrim
2025-01-24 21:03:52 +01:00
committed by GitHub
parent a5b2182fc2
commit d76f64f838
8 changed files with 952 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
#define GLOBALMETHODS_H
#include "BindingMap.h"
#include "ElunaDBCRegistry.h"
#include "BanMgr.h"
#include "GameTime.h"
@@ -15,6 +16,7 @@
#include "OutdoorPvPMgr.h"
#include "../../../../src/server/scripts/OutdoorPvP/OutdoorPvPNA.h"
enum BanMode
{
BAN_ACCOUNT = 1,
@@ -3227,5 +3229,37 @@ namespace LuaGlobalFunctions
return 0;
}
/**
* Returns the instance of the specified DBC (DatabaseClient) store.
*
* This function retrieves the DBC store associated with the provided name
* and pushes it onto the Lua stack.
*
* @param const char* dbcName : The name of the DBC store to retrieve.
* @param uint32 id : The ID used to look up within the specified DBC store.
*
* @return [DBCStore] store : The requested DBC store instance.
*/
int LookupEntry(lua_State* L)
{
const char* dbcName = Eluna::CHECKVAL<const char*>(L, 1);
uint32 id = Eluna::CHECKVAL<uint32>(L, 2);
for (const auto& dbc : dbcRegistry)
{
if (dbc.name == dbcName)
{
const void* entry = dbc.lookupFunction(id);
if (!entry)
return 0;
dbc.pushFunction(L, entry);
return 1;
}
}
return luaL_error(L, "Invalid DBC name: %s", dbcName);
}
}
#endif