This commit is contained in:
@@ -46,6 +46,13 @@ void RegisterItemTypes::RegisterBattleItemCategoryEnum(asIScriptEngine* engine)
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
||||
// Hack to handle AngelScript not recognizing different sized enums on fields, and returning invalid values due to it.
|
||||
#define ENUM__SIZE_WRAPPER(name, type, func) \
|
||||
int32_t name(type* obj) { return static_cast<int32_t>(obj->func()); }
|
||||
|
||||
ENUM__SIZE_WRAPPER(Move_CategoryWrapper, PkmnLib::Library::Item, GetCategory)
|
||||
ENUM__SIZE_WRAPPER(Move_BattleCategoryWrapper, PkmnLib::Library::Item, GetBattleCategory)
|
||||
|
||||
void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
|
||||
[[maybe_unused]] int r = engine->RegisterObjectType("Item", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||
assert(r >= 0);
|
||||
@@ -53,10 +60,10 @@ void RegisterItemTypes::RegisterItemType(asIScriptEngine* engine) {
|
||||
asMETHOD(PkmnLib::Library::Item, GetName), asCALL_THISCALL);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Item", "ItemCategory get_Category() const property",
|
||||
asMETHOD(PkmnLib::Library::Item, GetCategory), asCALL_THISCALL);
|
||||
asFUNCTION(Move_CategoryWrapper), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Item", "BattleItemCategory get_BattleCategory() const property",
|
||||
asMETHOD(PkmnLib::Library::Item, GetBattleCategory), asCALL_THISCALL);
|
||||
asFUNCTION(Move_BattleCategoryWrapper), asCALL_CDECL_OBJLAST);
|
||||
assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Item", "int get_Price() const property",
|
||||
asMETHOD(PkmnLib::Library::Item, GetPrice), asCALL_THISCALL);
|
||||
|
||||
Reference in New Issue
Block a user