Skip to content

Commit

Permalink
Merge branch 'deprecations' into 'master'
Browse files Browse the repository at this point in the history
Remove numeric magic school ids and deprecate the enum

See merge request OpenMW/openmw!3440
  • Loading branch information
psi29a committed Sep 23, 2023
2 parents 6d32caa + 90ca8a2 commit 6707599
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 107 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down
26 changes: 0 additions & 26 deletions apps/openmw/mwlua/luabindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,32 +184,6 @@ namespace MWLua
return sol::nil;
};

// TODO: deprecate this and provide access to the store instead
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;
}

// TODO: deprecate this and provide access to the store instead
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);
}

Expand Down
10 changes: 1 addition & 9 deletions apps/openmw/mwlua/magicbindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,6 @@ namespace MWLua
{ "Touch", ESM::RT_Touch },
{ "Target", ESM::RT_Target },
}));
magicApi["SCHOOL"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, int>({
{ "Alteration", 0 },
{ "Conjuration", 1 },
{ "Destruction", 2 },
{ "Illusion", 3 },
{ "Mysticism", 4 },
{ "Restoration", 5 },
}));
magicApi["SPELL_TYPE"]
= LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs<std::string_view, ESM::Spell::SpellType>({
{ "Spell", ESM::Spell::ST_Spell },
Expand Down Expand Up @@ -406,7 +398,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 {
Expand Down
78 changes: 7 additions & 71 deletions files/lua_api/openmw/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand All @@ -498,19 +447,6 @@
-- @field #number Target Ranged spell


--- Possible @{#MagicSchool} values
-- @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


--- Possible @{#MagicEffectId} values
-- @field [parent=#Magic] #MagicEffectId EFFECT_TYPE

Expand Down Expand Up @@ -720,16 +656,16 @@
-- @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

---
-- @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
Expand All @@ -738,8 +674,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
Expand Down

0 comments on commit 6707599

Please sign in to comment.