From f2710790c54f34ae6c8442729b3f5a00353b8bd3 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 9 Mar 2014 16:45:09 +0000 Subject: [PATCH] Merged revision(s) 7040 from branches/ja2_source_official_2014: Fix: if using scope modes, basic weapon item boni were always added, even if another scope was currently used. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7041 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Items.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 4d0da23b0..f6328af8a 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -10267,31 +10267,38 @@ INT32 GetObjectModifier( SOLDIERTYPE* pSoldier, OBJECTTYPE *pObj, UINT8 ubStance UINT8 ubRef = GetStanceModifierRef( ubStance ); - if (pObj->exists() )//&& UsingNewCTHSystem() == true) + if (pObj->exists() ) { - iModifier += GetItemModifier( pObj, ubRef, usType); - for (attachmentList::iterator iter = (*pObj)[0]->attachments.begin(); iter != (*pObj)[0]->attachments.end(); ++iter) { if( iter->exists() ) { // Flugente: if we use scope modes, are a soldier, this is a gun and the attachment a scope/sight, ignore it for the moment - if ( gGameExternalOptions.fScopeModes && pSoldier && Item[pObj->usItem].usItemClass == IC_GUN && IsAttachmentClass(iter->usItem, (AC_SCOPE|AC_SIGHT|AC_IRONSIGHT) ) ) + if ( gGameExternalOptions.fScopeModes && pSoldier && Item[pObj->usItem].usItemClass & IC_GUN && IsAttachmentClass(iter->usItem, (AC_SCOPE|AC_SIGHT|AC_IRONSIGHT) ) ) continue; iModifier += GetItemModifier( (&(*iter)), ubRef, usType); } } - // Flugente: check for scope mode - if ( gGameExternalOptions.fScopeModes && pSoldier && Item[pObj->usItem].usItemClass == IC_GUN ) + // Flugente::if we are a soldier and are using a gun, we might be checking for scope modes + if ( gGameExternalOptions.fScopeModes && pSoldier && Item[pObj->usItem].usItemClass & IC_GUN ) { - std::map ObjList; - GetScopeLists(pObj, ObjList); + // only apply boni if we are not hip-firing + if ( pSoldier->bScopeMode != USE_ALT_WEAPON_HOLD ) + { + std::map ObjList; + GetScopeLists(pObj, ObjList); - // only use scope mode if gun is in hand, otherwise an error might occur! - if ( (&pSoldier->inv[HANDPOS]) == pObj && ObjList[pSoldier->bScopeMode] != NULL && pSoldier->bScopeMode != USE_ALT_WEAPON_HOLD ) - iModifier += GetItemModifier(ObjList[pSoldier->bScopeMode], ubRef, usType); + // only use scope mode if gun is in hand, otherwise an error might occur! + if ( (&pSoldier->inv[HANDPOS]) == pObj && ObjList[pSoldier->bScopeMode] != NULL ) + iModifier += GetItemModifier(ObjList[pSoldier->bScopeMode], ubRef, usType); + } + } + else + { + // simply add the object modifier + iModifier += GetItemModifier( pObj, ubRef, usType); } }