From d41c0f2f93bbc3cf6f61228f6804973ddd50ecbc Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Sun, 2 May 2021 05:23:52 +0000 Subject: [PATCH] Efficiency improvements for code dealing with attachments validity to fix any potential lag issues (by Shadooow). git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8997 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Items.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 509e9e7f..04834730 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -2294,6 +2294,10 @@ BOOLEAN ValidAttachment( UINT16 usAttachment, OBJECTTYPE * pObj, UINT8 * pubAPCo if ( !pObj->exists() ) return FALSE; + // shadooow: efficiency check, we are passing all kinds of items into this function that are not neccessary attachments at all + if (!Item[usAttachment].attachment && !Item[usAttachment].hiddenaddon) + return FALSE; + if( UsingNewAttachmentSystem() ) { //It's possible we've entered this function without being passed the usAttachmentSlotIndexVector parameter @@ -2387,6 +2391,10 @@ BOOLEAN ValidItemAttachmentSlot( OBJECTTYPE * pObj, UINT16 usAttachment, BOOLEAN if (pObj->exists() == false) return FALSE; + // shadooow: efficiency check, we are passing all kinds of items into this function that are not neccessary attachments at all + if (!Item[usAttachment].attachment && !Item[usAttachment].hiddenaddon) + return FALSE; + //It's possible we could get here without being sent the usAttachmentSlotIndexVector parameter if(usAttachmentSlotIndexVector.empty()) usAttachmentSlotIndexVector = GetItemSlots(pObj, subObject); @@ -2679,6 +2687,10 @@ BOOLEAN TwoHandedItem( UINT16 usItem ) BOOLEAN ValidLaunchable( UINT16 usLaunchable, UINT16 usItem ) { + // shadooow: efficiency check, we are passing all kinds of items into this function that are not neccessary attachments at all + if (!Item[usLaunchable].attachment && !Item[usLaunchable].hiddenaddon) + return FALSE; + INT32 iLoop = 0; // Flugente: as this would cause launchers to happily launch attachments around the landscape, we really have to check the list of launchables // if a modder decides to define launchables via attachment points, slap him and tell him not to do that