Skip to content

Commit

Permalink
WeaponMagazined.cpp => Moved CheckForMisfire method to after the shot…
Browse files Browse the repository at this point in the history
… to fix issue with tri-state reload weapons

script_game_object_inventory_owner.cpp | xrServer_Objects_ALife_Items_script.cpp => Fix install_upgrade
  • Loading branch information
revolucas committed May 5, 2018
1 parent d8a4659 commit 02400c2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/xrGame/WeaponMagazined.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,6 @@ void CWeaponMagazined::state_Fire(float dt)

while (!m_magazine.empty() && fShotTimeCounter < 0 && (IsWorking() || m_bFireSingleShot) && (m_iQueueSize < 0 || m_iShotNum < m_iQueueSize))
{
if (CheckForMisfire())
{
StopShooting();
return;
}

m_bFireSingleShot = false;

//Alundaio: Use fModeShotTime instead of fOneShotTime if current fire mode is 2-shot burst
Expand All @@ -616,6 +610,12 @@ void CWeaponMagazined::state_Fire(float dt)
FireTrace(p1, d);
else
FireTrace(m_vStartPos, m_vStartDir);

if (CheckForMisfire())
{
StopShooting();
return;
}
}

if (m_iShotNum == m_iQueueSize)
Expand Down
5 changes: 4 additions & 1 deletion src/xrGame/script_game_object_inventory_owner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,10 @@ bool CScriptGameObject::InstallUpgrade(LPCSTR upgrade)
if (!pSettings->section_exist(upgrade))
return false;

return ai().alife().inventory_upgrade_manager().upgrade_install(*item, upgrade, false);
item->pre_install_upgrade();

shared_str upgrade_id(upgrade);
return ai().alife().inventory_upgrade_manager().upgrade_install(*item, upgrade_id, true);
}

bool CScriptGameObject::HasUpgrade(LPCSTR upgrade)
Expand Down
10 changes: 6 additions & 4 deletions src/xrServerEntities/xrServer_Objects_ALife_Items_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

void add_upgrade_script(CSE_ALifeInventoryItem* ta, LPCSTR str)
{
ta->add_upgrade(str);
shared_str upgrade_id(str);
ta->add_upgrade(upgrade_id);
}

bool has_upgrade_script(CSE_ALifeInventoryItem* ta,LPCSTR str)
{
return ta->has_upgrade(str);
shared_str upgrade_id(str);
return ta->has_upgrade(upgrade_id);
}

using namespace luabind;
Expand All @@ -29,8 +31,8 @@ void CSE_ALifeInventoryItem::script_register(lua_State *L)
class_<CSE_ALifeInventoryItem>
("cse_alife_inventory_item")
// .def( constructor<LPCSTR>())
.def("has_upgrade", &has_upgrade)
.def("add_upgrade", &add_upgrade)
.def("has_upgrade", &has_upgrade_script)
.def("add_upgrade", &add_upgrade_script)
.def_readwrite("condition", &CSE_ALifeInventoryItem::m_fCondition)
];
}
Expand Down

0 comments on commit 02400c2

Please sign in to comment.