mirror of
https://github.com/1dot13/source.git
synced 2026-09-02 14:36:06 +02:00
[~] Performance optimizations around Attachment[] and Launchable[] arrays
AIMNAS with its ~50K elements in Attachment[] suffered of performance drop when MOLLE stuff is in the visible inventory. To resolve it the following is done: * Introduce gMAXATTACHMENTS_READ with actual number of elements in Attachment[]; according refactoring. * Introduce gMAXLAUNCHABLES_READ with actual number of elements in Launchable[]; according refactoring. * Introduce std::multimap AttachmentBackmap for quick access to attachments using itemId as a key. * Sort Attachment[] by attachmentIndex right after loading from XML. According order in XML is not needed anymore. * Introduce FindAttachmentRange() for quick access to attachments using attachmentId as a key (binary search in Attachment[]). In a few words, GetHelpTextForItemInLaptop(), ValidAttachment(), SetAttachmentSlotsFlag() were heavily optimized.
This commit is contained in:
+23
-1
@@ -1724,9 +1724,30 @@ typedef enum
|
||||
MAXITEMS = 16001
|
||||
} ITEMDEFINE;
|
||||
|
||||
struct AttachmentStruct
|
||||
{
|
||||
UINT16 attachmentIndex;
|
||||
UINT16 itemIndex;
|
||||
UINT16 APCost;
|
||||
UINT16 NASOnly;
|
||||
|
||||
bool operator<(const AttachmentStruct& a) const
|
||||
{
|
||||
bool result = false;
|
||||
if (attachmentIndex < a.attachmentIndex)
|
||||
result = true;
|
||||
else if (attachmentIndex == a.attachmentIndex)
|
||||
result = itemIndex < a.itemIndex;
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
// Flugente: in order not to loop over MAXITEMS items if we only have a few thousand, remember the actual number of items in the xml
|
||||
extern UINT32 gMAXITEMS_READ;
|
||||
extern UINT32 gMAXAMMOTYPES_READ;
|
||||
extern UINT32 gMAXATTACHMENTS_READ;
|
||||
extern UINT32 gMAXLAUNCHABLES_READ;
|
||||
|
||||
/* CHRISL: Arrays to track ic group information. These allow us to determine which LBE slots control which pockets and
|
||||
what LBE class the pockets are.*/
|
||||
@@ -1781,7 +1802,8 @@ const INT16 icDefault[NUM_INV_SLOTS] = {
|
||||
#define MAXATTACHMENTS 60000
|
||||
|
||||
extern INVTYPE Item[MAXITEMS];
|
||||
extern UINT16 Attachment[MAXATTACHMENTS][4];
|
||||
extern AttachmentStruct Attachment[MAXATTACHMENTS];
|
||||
extern std::multimap<UINT16, AttachmentStruct> AttachmentBackmap;
|
||||
|
||||
//WarmSteel - Here we have some definitions for NAS
|
||||
typedef struct
|
||||
|
||||
Reference in New Issue
Block a user