From 6ed5cbb7d03016221f5c36c7b9782226ba9b93e4 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Wed, 20 Sep 2023 19:51:29 +0200 Subject: [PATCH 1/2] Remove numeric magic school ids and deprecate the enum --- CMakeLists.txt | 2 +- apps/openmw/mwlua/luabindings.cpp | 4 ++-- apps/openmw/mwlua/magicbindings.cpp | 17 +++++++++-------- files/lua_api/openmw/core.lua | 28 ++++++++++++++-------------- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3a16c285f..43bbcfc2e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,7 @@ message(STATUS "Configuring OpenMW...") set(OPENMW_VERSION_MAJOR 0) set(OPENMW_VERSION_MINOR 49) set(OPENMW_VERSION_RELEASE 0) -set(OPENMW_LUA_API_REVISION 48) +set(OPENMW_LUA_API_REVISION 49) set(OPENMW_VERSION_COMMITHASH "") set(OPENMW_VERSION_TAGHASH "") diff --git a/apps/openmw/mwlua/luabindings.cpp b/apps/openmw/mwlua/luabindings.cpp index 8b62c5480d..cb0dcfff97 100644 --- a/apps/openmw/mwlua/luabindings.cpp +++ b/apps/openmw/mwlua/luabindings.cpp @@ -184,7 +184,7 @@ namespace MWLua return sol::nil; }; - // TODO: deprecate this and provide access to the store instead + // deprecated, use core.stats.Skill sol::table skills(context.mLua->sol(), sol::create); api["SKILL"] = LuaUtil::makeStrictReadOnly(skills); for (int i = 0; i < ESM::Skill::Length; ++i) @@ -197,7 +197,7 @@ namespace MWLua skills[key] = id; } - // TODO: deprecate this and provide access to the store instead + // deprecated, use core.stats.Attribute sol::table attributes(context.mLua->sol(), sol::create); api["ATTRIBUTE"] = LuaUtil::makeStrictReadOnly(attributes); for (int i = 0; i < ESM::Attribute::Length; ++i) diff --git a/apps/openmw/mwlua/magicbindings.cpp b/apps/openmw/mwlua/magicbindings.cpp index afcc5bc54a..c0596a9478 100644 --- a/apps/openmw/mwlua/magicbindings.cpp +++ b/apps/openmw/mwlua/magicbindings.cpp @@ -203,13 +203,14 @@ namespace MWLua { "Touch", ESM::RT_Touch }, { "Target", ESM::RT_Target }, })); - magicApi["SCHOOL"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs({ - { "Alteration", 0 }, - { "Conjuration", 1 }, - { "Destruction", 2 }, - { "Illusion", 3 }, - { "Mysticism", 4 }, - { "Restoration", 5 }, + // deprecated, use core.stats.Skill + magicApi["SCHOOL"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs({ + { "Alteration", ESM::RefId(ESM::Skill::Alteration).serializeText() }, + { "Conjuration", ESM::RefId(ESM::Skill::Conjuration).serializeText() }, + { "Destruction", ESM::RefId(ESM::Skill::Destruction).serializeText() }, + { "Illusion", ESM::RefId(ESM::Skill::Illusion).serializeText() }, + { "Mysticism", ESM::RefId(ESM::Skill::Mysticism).serializeText() }, + { "Restoration", ESM::RefId(ESM::Skill::Restoration).serializeText() }, })); magicApi["SPELL_TYPE"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs({ @@ -406,7 +407,7 @@ namespace MWLua ->mValue.getString(); }); magicEffectT["school"] = sol::readonly_property( - [](const ESM::MagicEffect& rec) -> int { return ESM::MagicSchool::skillRefIdToIndex(rec.mData.mSchool); }); + [](const ESM::MagicEffect& rec) -> std::string { return rec.mData.mSchool.serializeText(); }); magicEffectT["baseCost"] = sol::readonly_property([](const ESM::MagicEffect& rec) -> float { return rec.mData.mBaseCost; }); magicEffectT["color"] = sol::readonly_property([](const ESM::MagicEffect& rec) -> Misc::Color { diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index b7a3b65ba6..efa88a0cbd 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -333,8 +333,8 @@ --- -- @type ActiveSpellEffect --- @field #string affectedSkill @{#SKILL} or nil --- @field #string affectedAttribute @{#ATTRIBUTE} or nil +-- @field #string affectedSkill Optional skill ID +-- @field #string affectedAttribute Optional attribute ID -- @field #string id Magic effect id -- @field #string name Localized name of the effect -- @field #number magnitudeThisFrame The magnitude of the effect in the current frame. This will be a new random number between minMagnitude and maxMagnitude every frame. Or nil if the effect has no magnitude. @@ -498,17 +498,17 @@ -- @field #number Target Ranged spell ---- Possible @{#MagicSchool} values +--- Possible @{#MagicSchool} values (DEPRECATED use @{#Skill}) -- @field [parent=#Magic] #MagicSchool SCHOOL --- `core.magic.SCHOOL` -- @type MagicSchool --- @field #number Alteration Alteration --- @field #number Conjuration Conjuration --- @field #number Destruction Destruction --- @field #number Illusion Illusion --- @field #number Mysticism Mysticism --- @field #number Restoration Restoration +-- @field #string Alteration alteration +-- @field #string Conjuration conjuration +-- @field #string Destruction destruction +-- @field #string Illusion illusion +-- @field #string Mysticism mysticism +-- @field #string Restoration restoration --- Possible @{#MagicEffectId} values @@ -720,7 +720,7 @@ -- @field #string id Effect ID -- @field #string icon Effect Icon Path -- @field #string name Localized name of the effect --- @field #number school @{#MagicSchool} +-- @field #string school Skill ID -- @field #number baseCost -- @field openmw.util#Color color -- @field #boolean harmful @@ -728,8 +728,8 @@ --- -- @type MagicEffectWithParams -- @field #MagicEffect effect @{#MagicEffect} --- @field #string affectedSkill @{#SKILL} or nil --- @field #string affectedAttribute @{#ATTRIBUTE} or nil +-- @field #string affectedSkill Optional skill ID +-- @field #string affectedAttribute Optional attribute ID -- @field #number range -- @field #number area -- @field #number magnitudeMin @@ -738,8 +738,8 @@ --- -- @type ActiveEffect --- @field #string affectedSkill @{#SKILL} or nil --- @field #string affectedAttribute @{#ATTRIBUTE} or nil +-- @field #string affectedSkill Optional skill ID +-- @field #string affectedAttribute Optional attribute ID -- @field #string id Effect id string -- @field #string name Localized name of the effect -- @field #number magnitude From 90ca8a2f4e903977d63fef944bbbcb2aa68a801f Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Thu, 21 Sep 2023 19:34:13 +0200 Subject: [PATCH 2/2] Remove ATTRIBUTE, SKILL, and SCHOOL enums --- apps/openmw/mwlua/luabindings.cpp | 26 ------------ apps/openmw/mwlua/magicbindings.cpp | 9 ---- files/lua_api/openmw/core.lua | 64 ----------------------------- 3 files changed, 99 deletions(-) diff --git a/apps/openmw/mwlua/luabindings.cpp b/apps/openmw/mwlua/luabindings.cpp index cb0dcfff97..a50459502b 100644 --- a/apps/openmw/mwlua/luabindings.cpp +++ b/apps/openmw/mwlua/luabindings.cpp @@ -184,32 +184,6 @@ namespace MWLua return sol::nil; }; - // deprecated, use core.stats.Skill - sol::table skills(context.mLua->sol(), sol::create); - api["SKILL"] = LuaUtil::makeStrictReadOnly(skills); - for (int i = 0; i < ESM::Skill::Length; ++i) - { - ESM::RefId skill = ESM::Skill::indexToRefId(i); - std::string id = skill.serializeText(); - std::string key = Misc::StringUtils::lowerCase(skill.getRefIdString()); - // force first character to uppercase for backwards compatability - key[0] += 'A' - 'a'; - skills[key] = id; - } - - // deprecated, use core.stats.Attribute - sol::table attributes(context.mLua->sol(), sol::create); - api["ATTRIBUTE"] = LuaUtil::makeStrictReadOnly(attributes); - for (int i = 0; i < ESM::Attribute::Length; ++i) - { - ESM::RefId attribute = ESM::Attribute::indexToRefId(i); - std::string id = attribute.serializeText(); - std::string key = Misc::StringUtils::lowerCase(attribute.getRefIdString()); - // force first character to uppercase for backwards compatability - key[0] += 'A' - 'a'; - attributes[key] = id; - } - return LuaUtil::makeReadOnly(api); } diff --git a/apps/openmw/mwlua/magicbindings.cpp b/apps/openmw/mwlua/magicbindings.cpp index c0596a9478..0e99a57c97 100644 --- a/apps/openmw/mwlua/magicbindings.cpp +++ b/apps/openmw/mwlua/magicbindings.cpp @@ -203,15 +203,6 @@ namespace MWLua { "Touch", ESM::RT_Touch }, { "Target", ESM::RT_Target }, })); - // deprecated, use core.stats.Skill - magicApi["SCHOOL"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs({ - { "Alteration", ESM::RefId(ESM::Skill::Alteration).serializeText() }, - { "Conjuration", ESM::RefId(ESM::Skill::Conjuration).serializeText() }, - { "Destruction", ESM::RefId(ESM::Skill::Destruction).serializeText() }, - { "Illusion", ESM::RefId(ESM::Skill::Illusion).serializeText() }, - { "Mysticism", ESM::RefId(ESM::Skill::Mysticism).serializeText() }, - { "Restoration", ESM::RefId(ESM::Skill::Restoration).serializeText() }, - })); magicApi["SPELL_TYPE"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs({ { "Spell", ESM::Spell::ST_Spell }, diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index efa88a0cbd..601e8ea27c 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -433,57 +433,6 @@ -- @usage for _, item in ipairs(inventory:findAll('common_shirt_01')) do ... end ---- Possible @{#ATTRIBUTE} values (DEPRECATED use @{#Attribute}) --- @field [parent=#core] #ATTRIBUTE ATTRIBUTE - ---- DEPRECATED, use @{#Attribute} ---- `core.ATTRIBUTE` --- @type ATTRIBUTE --- @field #string Strength "strength" --- @field #string Intelligence "intelligence" --- @field #string Willpower "willpower" --- @field #string Agility "agility" --- @field #string Speed "speed" --- @field #string Endurance "endurance" --- @field #string Personality "personality" --- @field #string Luck "luck" - - ---- Possible @{#SKILL} values (DEPRECATED use @{#Skill}) --- @field [parent=#core] #SKILL SKILL - ---- DEPRECATED, use @{#Skill} ---- `core.SKILL` --- @type SKILL --- @field #string Acrobatics "acrobatics" --- @field #string Alchemy "alchemy" --- @field #string Alteration "alteration" --- @field #string Armorer "armorer" --- @field #string Athletics "athletics" --- @field #string Axe "axe" --- @field #string Block "block" --- @field #string BluntWeapon "bluntweapon" --- @field #string Conjuration "conjuration" --- @field #string Destruction "destruction" --- @field #string Enchant "enchant" --- @field #string HandToHand "handtohand" --- @field #string HeavyArmor "heavyarmor" --- @field #string Illusion "illusion" --- @field #string LightArmor "lightarmor" --- @field #string LongBlade "longblade" --- @field #string Marksman "marksman" --- @field #string MediumArmor "mediumarmor" --- @field #string Mercantile "mercantile" --- @field #string Mysticism "mysticism" --- @field #string Restoration "restoration" --- @field #string Security "security" --- @field #string ShortBlade "shortblade" --- @field #string Sneak "sneak" --- @field #string Spear "spear" --- @field #string Speechcraft "speechcraft" --- @field #string Unarmored "unarmored" - - --- @{#Magic}: spells and spell effects -- @field [parent=#core] #Magic magic @@ -498,19 +447,6 @@ -- @field #number Target Ranged spell ---- Possible @{#MagicSchool} values (DEPRECATED use @{#Skill}) --- @field [parent=#Magic] #MagicSchool SCHOOL - ---- `core.magic.SCHOOL` --- @type MagicSchool --- @field #string Alteration alteration --- @field #string Conjuration conjuration --- @field #string Destruction destruction --- @field #string Illusion illusion --- @field #string Mysticism mysticism --- @field #string Restoration restoration - - --- Possible @{#MagicEffectId} values -- @field [parent=#Magic] #MagicEffectId EFFECT_TYPE