Skip to content

Commit f655759

Browse files
committed
Merge branch 'development' into cf/468-add-proper-semantic-version-comparison-to-check-mod-compatibility
2 parents 92237c0 + bfa9e73 commit f655759

File tree

7 files changed

+50
-40
lines changed

7 files changed

+50
-40
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
313313
- Added `ACrab` INI properties for setting individual foot `AtomGroup`s, as opposed to setting the same foot `AtomGroup`s for both `Legs` on the left or right side.
314314
These are `LeftFGFootGroup`, `LeftBGFootGroup`, `RightFGFootGroup` and `RightBGFootGroup`.
315315

316+
- Added alternative `Actor` Lua function `RemoveInventoryItem(moduleName, presetName)`, that lets you specify the module and preset name of the inventory item, instead of just the preset name.
317+
318+
- Added alternative `AHuman` Lua function `EquipNamedDevice(moduleName, presetName, doEquip)`, that lets you specify the module and preset name of the `HeldDevice` to equip, instead of just the preset name.
319+
320+
- Added Lua access (R/W) to `Attachable` property `DeleteWhenRemovedFromParent`, which determines whether the given `Attachable` should delete itself when it's removed from its current parent.
321+
316322
</details>
317323

318324
<details><summary><b>Changed</b></summary>
@@ -478,6 +484,8 @@ As such, the `Index.ini` property `SupportedGameVersion` must now be a valid sem
478484

479485
- Fix advanced performance stats (graphs) peak values stuck at 0.
480486

487+
- Fixed `Entity.ModuleName` returning and empty string for `Entities` defined in Base.rte. They now return "Base.rte", as they should.
488+
481489
</details>
482490

483491
<details><summary><b>Removed</b></summary>

Entities/AHuman.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ bool AHuman::EquipLoadedFirearmInGroup(std::string group, std::string excludeGro
10021002
// of with the specified preset name in the inventory. If the held device already
10031003
// is of that preset name, or no device is in inventory, nothing happens.
10041004

1005-
bool AHuman::EquipNamedDevice(const std::string name, bool doEquip)
1005+
bool AHuman::EquipNamedDevice(const std::string &moduleName, const std::string &presetName, bool doEquip)
10061006
{
10071007
if (!(m_pFGArm && m_pFGArm->IsAttached()))
10081008
return false;
@@ -1013,7 +1013,7 @@ bool AHuman::EquipNamedDevice(const std::string name, bool doEquip)
10131013
if (m_pFGArm->HoldsSomething())
10141014
{
10151015
pDevice = dynamic_cast<HeldDevice *>(m_pFGArm->GetHeldMO());
1016-
if (pDevice && pDevice->GetPresetName() == name)
1016+
if (pDevice && (moduleName.empty() || pDevice->GetModuleName() == moduleName) && pDevice->GetPresetName() == presetName)
10171017
return true;
10181018
}
10191019

@@ -1022,7 +1022,7 @@ bool AHuman::EquipNamedDevice(const std::string name, bool doEquip)
10221022
{
10231023
pDevice = dynamic_cast<HeldDevice *>(*itr);
10241024
// Found proper device to equip, so make the switch!
1025-
if (pDevice && pDevice->GetPresetName() == name)
1025+
if (pDevice && (moduleName.empty() || pDevice->GetModuleName() == moduleName) && pDevice->GetPresetName() == presetName)
10261026
{
10271027
if (doEquip)
10281028
{

Entities/AHuman.h

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -462,19 +462,24 @@ DefaultPieMenuNameGetter("Default Human Pie Menu");
462462

463463
bool EquipLoadedFirearmInGroup(std::string group, std::string exludeGroup, bool doEquip = true);
464464

465+
/// <summary>
466+
/// Switches the equipped HeldDevice (if any) to the first found device with the specified preset name in the inventory.
467+
/// If the equipped HeldDevice is of that module and preset name, nothing happens.
468+
/// </summary>
469+
/// <param name="presetName">The preset name of the HeldDevice to equip.</param>
470+
/// <param name="doEquip">Whether to actually equip any matching item found in the inventory, or just report whether or not it's there.</param>
471+
/// <returns>Whether a matching HeldDevice was successfully found/switched -o, or already held.</returns>
472+
bool EquipNamedDevice(const std::string &presetName, bool doEquip) { return EquipNamedDevice("", presetName, doEquip); }
465473

466-
//////////////////////////////////////////////////////////////////////////////////////////
467-
// Virtual Method: EquipNamedDevice
468-
//////////////////////////////////////////////////////////////////////////////////////////
469-
// Description: Switches the currently held device (if any) to the first found device
470-
// of with the specified preset name in the inventory. If the held device already
471-
// is of that preset name, or no device is in inventory, nothing happens.
472-
// Arguments: The preset name the device must have.
473-
// Whether to actually equip any matching item found in the inventory,
474-
// or just report that it's there or not.
475-
// Return value: Whether a device was successfully switched to, or already held.
476-
477-
bool EquipNamedDevice(const std::string name, bool doEquip);
474+
/// <summary>
475+
/// Switches the equipped HeldDevice (if any) to the first found device with the specified module and preset name in the inventory.
476+
/// If the equipped HeldDevice is of that module and preset name, nothing happens.
477+
/// </summary>
478+
/// <param name="moduleName">The module name of the HeldDevice to equip.</param>
479+
/// <param name="presetName">The preset name of the HeldDevice to equip.</param>
480+
/// <param name="doEquip">Whether to actually equip any matching item found in the inventory, or just report whether or not it's there.</param>
481+
/// <returns>Whether a matching HeldDevice was successfully found/switched -o, or already held.</returns>
482+
bool EquipNamedDevice(const std::string &moduleName, const std::string &presetName, bool doEquip);
478483

479484

480485
//////////////////////////////////////////////////////////////////////////////////////////

Entities/Actor.cpp

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -762,28 +762,15 @@ MovableObject * Actor::SwapNextInventory(MovableObject *pSwapIn, bool muteSound)
762762
return pRetDev;
763763
}
764764

765+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
765766

766-
//////////////////////////////////////////////////////////////////////////////////////////
767-
// Virtual Method: RemoveInventoryItem
768-
//////////////////////////////////////////////////////////////////////////////////////////
769-
// Description: Removes a specified item from the actor's inventory. Only one item is removed at a time.
770-
771-
void Actor::RemoveInventoryItem(std::string presetName)
772-
{
773-
if (!IsInventoryEmpty())
774-
{
775-
//while(HasObject(presetName))
776-
//{
777-
for (std::deque<MovableObject *>::iterator gItr = m_Inventory.begin(); gItr != m_Inventory.end(); ++gItr)
778-
{
779-
if ((*gItr) && (*gItr)->GetPresetName() == presetName)
780-
{
781-
delete (*gItr);
782-
m_Inventory.erase(gItr);
783-
break;
784-
}
785-
}
786-
//}
767+
void Actor::RemoveInventoryItem(const std::string &moduleName, const std::string &presetName) {
768+
for (std::deque<MovableObject*>::iterator inventoryIterator = m_Inventory.begin(); inventoryIterator != m_Inventory.end(); ++inventoryIterator) {
769+
if ((moduleName.empty() || (*inventoryIterator)->GetModuleName() == moduleName) && (*inventoryIterator)->GetPresetName() == presetName) {
770+
delete (*inventoryIterator);
771+
m_Inventory.erase(inventoryIterator);
772+
break;
773+
}
787774
}
788775
}
789776

Entities/Actor.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,14 @@ ClassInfoGetters;
834834
// Arguments: Preset name of an item to remove.
835835
// Return value: None.
836836

837-
void RemoveInventoryItem(std::string presetName);
837+
void RemoveInventoryItem(const std::string &presetName) { RemoveInventoryItem("", presetName); }
838+
839+
/// <summary>
840+
/// Removes the first inventory item with the given module name and preset name.
841+
/// </summary>
842+
/// <param name="moduleName">The module name of the item to remove.</param>
843+
/// <param name="presetName">The preset name of the item to remove.</param>
844+
void RemoveInventoryItem(const std::string &moduleName, const std::string &presetName);
838845

839846
/// <summary>
840847
/// Removes and returns the inventory item at the given index. Ownership IS transferred.

Lua/LuaBindingsEntities.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ namespace RTE {
270270
.def("RemoveMovePathBeginning", &Actor::RemoveMovePathBeginning)
271271
.def("RemoveMovePathEnd", &Actor::RemoveMovePathEnd)
272272
.def("AddInventoryItem", &Actor::AddInventoryItem, luabind::adopt(_2))
273-
.def("RemoveInventoryItem", &Actor::RemoveInventoryItem)
273+
.def("RemoveInventoryItem", (void (Actor::*)(const std::string &))&Actor::RemoveInventoryItem)
274+
.def("RemoveInventoryItem", (void (Actor::*)(const std::string &, const std::string &))&Actor::RemoveInventoryItem)
274275
.def("SwapNextInventory", &Actor::SwapNextInventory)
275276
.def("SwapPrevInventory", &Actor::SwapPrevInventory)
276277
.def("DropAllInventory", &Actor::DropAllInventory)
@@ -444,7 +445,8 @@ namespace RTE {
444445
.def("EquipShield", &AHuman::EquipShield)
445446
.def("EquipShieldInBGArm", &AHuman::EquipShieldInBGArm)
446447
.def("EquipDeviceInGroup", &AHuman::EquipDeviceInGroup)
447-
.def("EquipNamedDevice", &AHuman::EquipNamedDevice)
448+
.def("EquipNamedDevice", (bool (AHuman::*)(const std::string &, bool))&AHuman::EquipNamedDevice)
449+
.def("EquipNamedDevice", (bool (AHuman::*)(const std::string &, const std::string &, bool))&AHuman::EquipNamedDevice)
448450
.def("EquipLoadedFirearmInGroup", &AHuman::EquipLoadedFirearmInGroup)
449451
.def("UnequipFGArm", &AHuman::UnequipFGArm)
450452
.def("UnequipBGArm", &AHuman::UnequipBGArm)
@@ -552,6 +554,7 @@ namespace RTE {
552554
.property("JointStiffness", &Attachable::GetJointStiffness, &Attachable::SetJointStiffness)
553555
.property("JointOffset", &Attachable::GetJointOffset, &Attachable::SetJointOffset)
554556
.property("JointPos", &Attachable::GetJointPos)
557+
.property("DeleteWhenRemovedFromParent", &Attachable::GetDeleteWhenRemovedFromParent, &Attachable::SetDeleteWhenRemovedFromParent)
555558
.property("ApplyTransferredForcesAtOffset", &Attachable::GetApplyTransferredForcesAtOffset, &Attachable::SetApplyTransferredForcesAtOffset)
556559
.property("BreakWound", &Attachable::GetBreakWound, &LuaAdaptersPropertyOwnershipSafetyFaker::AttachableSetBreakWound)
557560
.property("ParentBreakWound", &Attachable::GetParentBreakWound, &LuaAdaptersPropertyOwnershipSafetyFaker::AttachableSetParentBreakWound)

System/Entity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ namespace RTE {
152152
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
153153

154154
std::string Entity::GetModuleName() const {
155-
if (m_DefinedInModule > 0) {
155+
if (m_DefinedInModule >= 0) {
156156
if (const DataModule *dataModule = g_PresetMan.GetDataModule(m_DefinedInModule)) {
157157
return dataModule->GetFileName();
158158
}

0 commit comments

Comments
 (0)