Merge branch 'records' into 'master'

[Lua] Fix implementation of types.*.records

See merge request OpenMW/openmw!2918
depth-refraction
psi29a 1 year ago
commit d6d7746c9b

@ -80,17 +80,14 @@ namespace MWLua
return "{" + std::to_string(store.getSize()) + " " + std::string(T::getRecordType()) + " records}";
};
storeT[sol::meta_function::length] = [](const StoreT& store) { return store.getSize(); };
storeT[sol::meta_function::index] = [](const StoreT& store, size_t index) -> const T& {
if (index > 0 && index <= store.getSize())
return store.at(index - 1); // Translate from Lua's 1-based indexing.
else
throw std::runtime_error("Index out of range");
storeT[sol::meta_function::index] = [](const StoreT& store, size_t index) -> const T* {
return store.at(index - 1); // Translate from Lua's 1-based indexing.
};
storeT[sol::meta_function::pairs] = lua["ipairsForArray"].template get<sol::function>();
storeT[sol::meta_function::ipairs] = lua["ipairsForArray"].template get<sol::function>();
// Provide access to the store.
table["records"] = [&store]() { return &store; };
table["records"] = &store;
}
}

@ -205,11 +205,6 @@ namespace MWWorld
{
return mShared.end();
}
template <typename T>
const T& TypedDynamicStore<T>::at(size_t index) const
{
return *mShared.at(index);
}
template <typename T>
size_t TypedDynamicStore<T>::getSize() const

@ -209,7 +209,7 @@ namespace MWWorld
iterator begin() const;
iterator end() const;
const T& at(size_t index) const;
const T* at(size_t index) const { return mShared.at(index); }
size_t getSize() const override;
int getDynamicSize() const override;

@ -453,6 +453,7 @@
-- @type Creature
-- @extends #Actor
-- @field #Actor baseType @{#Actor}
-- @field #list<#CreatureRecord> records A read-only list of all @{#CreatureRecord}s in the world database.
---
-- Whether the object is a creature.
@ -466,11 +467,6 @@
-- @param #any objectOrRecordId
-- @return #CreatureRecord
---
-- Returns a read-only list of all @{#CreatureRecord}s in the world database.
-- @function [parent=#Creature] records
-- @return #list<#CreatureRecord>
---
-- @type CreatureRecord
-- @field #string id The record ID of the creature
@ -489,6 +485,7 @@
-- @extends #Actor
-- @field #Actor baseType @{#Actor}
-- @field [parent=#NPC] #NpcStats stats
-- @field #list<#NpcRecord> records A read-only list of all @{#NpcRecord}s in the world database.
---
-- Whether the object is an NPC or a Player.
@ -508,11 +505,6 @@
-- @param #any objectOrRecordId
-- @return #NpcRecord
---
-- Returns a read-only list of all @{#NpcRecord}s in the world database.
-- @function [parent=#Npc] records
-- @return #list<#NpcRecord>
---
-- @type NpcRecord
-- @field #string id The record ID of the NPC
@ -546,6 +538,7 @@
-- @type Armor
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#ArmorRecord> records A read-only list of all @{#ArmorRecord}s in the world database.
---
-- Whether the object is an Armor.
@ -576,11 +569,6 @@
-- @param #any objectOrRecordId
-- @return #ArmorRecord
---
-- Returns a read-only list of all @{#ArmorRecord}s in the world database.
-- @function [parent=#Armor] records
-- @return #list<#ArmorRecord>
---
-- @type ArmorRecord
-- @field #string id Record id
@ -605,6 +593,7 @@
-- @type Book
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#BookRecord> records A read-only list of all @{#BookRecord}s in the world database.
---
-- Whether the object is a Book.
@ -651,11 +640,6 @@
-- @param #any objectOrRecordId
-- @return #BookRecord
---
-- Returns a read-only list of all @{#BookRecord}s in the world database.
-- @function [parent=#Book] records
-- @return #list<#BookRecord>
---
-- @type BookRecord
-- @field #string id The record ID of the book
@ -680,6 +664,7 @@
-- @type Clothing
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#ClothingRecord> records A read-only list of all @{#ClothingRecord}s in the world database.
---
-- Whether the object is a Clothing.
@ -709,11 +694,6 @@
-- @param #any objectOrRecordId
-- @return #ClothingRecord
---
-- Returns a read-only list of all @{#ClothingRecord}s in the world database.
-- @function [parent=#Clothing] records
-- @return #list<#ClothingRecord>
---
-- @type ClothingRecord
-- @field #string id Record id
@ -737,6 +717,7 @@
-- @type Ingredient
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#IngredientRecord> records A read-only list of all @{#IngredientRecord}s in the world database.
---
-- Whether the object is an Ingredient.
@ -750,11 +731,6 @@
-- @param #any objectOrRecordId
-- @return #IngredientRecord
---
-- Returns a read-only list of all @{#IngredientRecord}s in the world database.
-- @function [parent=#Ingredient] records
-- @return #list<#IngredientRecord>
---
-- @type IngredientRecord
-- @field #string id Record id
@ -774,6 +750,7 @@
-- @type Light
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#LightRecord> records A read-only list of all @{#LightRecord}s in the world database.
---
-- Whether the object is a Light.
@ -787,11 +764,6 @@
-- @param #any objectOrRecordId
-- @return #LightRecord
---
-- Returns a read-only list of all @{#LightRecord}s in the world database.
-- @function [parent=#Light] records
-- @return #list<#LightRecord>
---
-- @type LightRecord
-- @field #string id Record id
@ -816,6 +788,7 @@
-- @type Miscellaneous
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#MiscellaneousRecord> records A read-only list of all @{#MiscellaneousRecord}s in the world database.
---
-- Whether the object is a Miscellaneous.
@ -829,11 +802,6 @@
-- @param #any objectOrRecordId
-- @return #MiscellaneousRecord
---
-- Returns a read-only list of all @{#MiscellaneousRecord}s in the world database.
-- @function [parent=#Miscellaneous] records
-- @return #list<#MiscellaneousRecord>
---
-- @type MiscellaneousRecord
-- @field #string id The record ID of the miscellaneous item
@ -852,6 +820,7 @@
-- @type Potion
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#PotionRecord> records A read-only list of all @{#PotionRecord}s in the world database.
---
-- Whether the object is a Potion.
@ -865,11 +834,6 @@
-- @param #any objectOrRecordId
-- @return #PotionRecord
---
-- Returns a read-only list of all @{#PotionRecord}s in the world database.
-- @function [parent=#Potion] records
-- @return #list<#PotionRecord>
---
-- Creates a @{#PotionRecord} without adding it to the world database.
-- Use @{openmw_world#(world).createRecord} to add the record to the world.
@ -896,6 +860,7 @@
-- @type Weapon
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#WeaponRecord> records A read-only list of all @{#WeaponRecord}s in the world database.
---
-- Whether the object is a Weapon.
@ -929,11 +894,6 @@
-- @param #any objectOrRecordId
-- @return #WeaponRecord
---
-- Returns a read-only list of all @{#WeaponRecord}s in the world database.
-- @function [parent=#Weapon] records
-- @return #list<#WeaponRecord>
---
-- @type WeaponRecord
-- @field #string id Record id
@ -967,6 +927,7 @@
-- @type Apparatus
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#ApparatusRecord> records A read-only list of all @{#ApparatusRecord}s in the world database.
---
-- Whether the object is an Apparatus.
@ -990,11 +951,6 @@
-- @param #any objectOrRecordId
-- @return #ApparatusRecord
---
-- Returns a read-only list of all @{#ApparatusRecord}s in the world database.
-- @function [parent=#Apparatus] records
-- @return #list<#ApparatusRecord>
---
-- @type ApparatusRecord
-- @field #string id The record ID of the apparatus
@ -1014,6 +970,7 @@
-- @type Lockpick
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#LockpickRecord> records A read-only list of all @{#LockpickRecord}s in the world database.
---
-- Whether the object is a Lockpick.
@ -1027,11 +984,6 @@
-- @param #any objectOrRecordId
-- @return #LockpickRecord
---
-- Returns a read-only list of all @{#LockpickRecord}s in the world database.
-- @function [parent=#Lockpick] records
-- @return #list<#LockpickRecord>
---
-- @type LockpickRecord
-- @field #string id The record ID of the lockpick
@ -1051,6 +1003,7 @@
-- @type Probe
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#ProbeRecord> records A read-only list of all @{#ProbeRecord}s in the world database.
---
-- Whether the object is a Probe.
@ -1064,11 +1017,6 @@
-- @param #any objectOrRecordId
-- @return #ProbeRecord
---
-- Returns a read-only list of all @{#ProbeRecord}s in the world database.
-- @function [parent=#Probe] records
-- @return #list<#ProbeRecord>
---
-- @type ProbeRecord
-- @field #string id The record ID of the probe
@ -1088,6 +1036,7 @@
-- @type Repair
-- @extends #Item
-- @field #Item baseType @{#Item}
-- @field #list<#RepairRecord> records A read-only list of all @{#RepairRecord}s in the world database.
---
-- Whether the object is a Repair.
@ -1101,11 +1050,6 @@
-- @param #any objectOrRecordId
-- @return #RepairRecord
---
-- Returns a read-only list of all @{#RepairRecord}s in the world database.
-- @function [parent=#Repair] records
-- @return #list<#RepairRecord>
---
-- @type RepairRecord
-- @field #string id The record ID of the repair tool
@ -1123,6 +1067,7 @@
---
-- @type Activator
-- @field #list<#ActivatorRecord> records A read-only list of all @{#ActivatorRecord}s in the world database.
---
-- Whether the object is an Activator.
@ -1136,11 +1081,6 @@
-- @param #any objectOrRecordId
-- @return #ActivatorRecord
---
-- Returns a read-only list of all @{#ActivatorRecord}s in the world database.
-- @function [parent=#Activator] records
-- @return #list<#ActivatorRecord>
---
-- @type ActivatorRecord
-- @field #string id Record id
@ -1153,6 +1093,7 @@
---
-- @type Container
-- @field #list<#ContainerRecord> records A read-only list of all @{#ContainerRecord}s in the world database.
---
-- Container content.
@ -1184,11 +1125,6 @@
-- @param #any objectOrRecordId
-- @return #ContainerRecord
---
-- Returns a read-only list of all @{#ContainerRecord}s in the world database.
-- @function [parent=#Container] records
-- @return #list<#ContainerRecord>
---
-- @type ContainerRecord
-- @field #string id Record id
@ -1202,6 +1138,7 @@
---
-- @type Door
-- @field #list<#DoorRecord> records A read-only list of all @{#DoorRecord}s in the world database.
---
-- Whether the object is a Door.
@ -1239,11 +1176,6 @@
-- @param #any objectOrRecordId
-- @return #DoorRecord
---
-- Returns a read-only list of all @{#DoorRecord}s in the world database.
-- @function [parent=#Door] records
-- @return #list<#DoorRecord>
---
-- @type DoorRecord
-- @field #string id Record id
@ -1260,6 +1192,7 @@
---
-- @type Static
-- @field #list<#StaticRecord> records A read-only list of all @{#StaticRecord}s in the world database.
---
-- Whether the object is a Static.
@ -1273,11 +1206,6 @@
-- @param #any objectOrRecordId
-- @return #StaticRecord
---
-- Returns a read-only list of all @{#StaticRecord}s in the world database.
-- @function [parent=#Static] records
-- @return #list<#StaticRecord>
---
-- @type StaticRecord
-- @field #string id Record id

Loading…
Cancel
Save