forked from ElunaLuaEngine/Eluna
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add DBCStores access via Lua with getters for DBC entries
- Loading branch information
Showing
8 changed files
with
948 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "ElunaDBCRegistry.h" | ||
|
||
std::vector<DBCDefinition> dbcRegistry = { | ||
REGISTER_DBC(GemProperties, GemPropertiesEntry, sGemPropertiesStore), | ||
REGISTER_DBC(Spell, SpellEntry, sSpellStore), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef ELUNADBCREGISTRY_H | ||
#define ELUNADBCREGISTRY_H | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <functional> | ||
#include <typeinfo> | ||
|
||
#include "DBCStores.h" | ||
#include "LuaEngine.h" | ||
|
||
struct DBCDefinition | ||
{ | ||
std::string name; | ||
void* storage; | ||
const std::type_info& type; | ||
std::function<const void*(uint32)> lookupFunction; | ||
std::function<void(lua_State*, const void*)> pushFunction; | ||
}; | ||
|
||
extern std::vector<DBCDefinition> dbcRegistry; | ||
|
||
#define REGISTER_DBC(dbcName, entryType, store) \ | ||
{ \ | ||
#dbcName, \ | ||
reinterpret_cast<void*>(&store), \ | ||
typeid(DBCStorage<entryType>), \ | ||
[](uint32 id) -> const void* { \ | ||
return store.LookupEntry(id); \ | ||
}, \ | ||
[](lua_State* L, const void* entry) { \ | ||
auto cast_entry = static_cast<const entryType*>(entry); \ | ||
Eluna::Push(L, *cast_entry); \ | ||
} \ | ||
} | ||
|
||
#endif // ELUNADBCREGISTRY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/> | ||
* This program is free software licensed under GPL version 3 | ||
* Please see the included DOCS/LICENSE.md for more information | ||
*/ | ||
|
||
#ifndef GEMPROPERTIESENTRYMETHODS_H | ||
#define GEMPROPERTIESENTRYMETHODS_H | ||
|
||
namespace LuaGemPropertiesEntry | ||
{ | ||
|
||
/** | ||
* Returns the ID of a [GemPropertiesEntry]. | ||
* | ||
* This method retrieves the ID from a given GemPropertiesEntry instance | ||
* and pushes it onto the Lua stack. | ||
* | ||
* @return uint32 id : The ID of the specified GemPropertiesEntry. | ||
*/ | ||
int GetId(lua_State* L, GemPropertiesEntry* gemProperties) | ||
{ | ||
Eluna::Push(L, gemProperties->ID); | ||
return 1; | ||
} | ||
|
||
/** | ||
* Returns the spell item enchantment of a [GemPropertiesEntry]. | ||
* | ||
* This function retrieves the `spellitemenchantement` attribute from the provided `GemPropertiesEntry`. | ||
* | ||
* @return uint32 spellitemenchantement : The spell item enchantment ID. | ||
*/ | ||
int GetSpellItemEnchantement(lua_State* L, GemPropertiesEntry* entry) | ||
{ | ||
Eluna::Push(L, entry->spellitemenchantement); | ||
return 1; | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.