If the itemlist is huge and one uses New Inventory System, New Attachment System and a lot of MOLLE items, there is a noticable slowdown if inventory is open in tactical. I cleaned up code to ease that somewhat, but the problem will likely persist.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7600 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2014-10-19 21:53:05 +00:00
parent 5dbcf2a1e8
commit 499ff2db06
24 changed files with 674 additions and 702 deletions
+12 -16
View File
@@ -38,6 +38,9 @@
#include "store inventory.h"
#endif
// 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
UINT32 gMAXITEMS_READ = 0;
struct
{
PARSE_STAGE curElement;
@@ -381,6 +384,9 @@ itemEndElementHandle(void *userData, const XML_Char *name)
InheritStanceModifiers( pData );
pData->curArray[pData->curItem.uiIndex] = pData->curItem; //write the item into the table
// Flugente: new item -> read items increase
gMAXITEMS_READ = pData->curItem.uiIndex;
}
else if ( sizeof(pData->curItem.szItemName)>0 && localizedTextOnly )
{
@@ -1477,10 +1483,10 @@ itemEndElementHandle(void *userData, const XML_Char *name)
pData->curItem.usItemFlag |= DISEASEPROTECTION_HAND;
}
pData->maxReadDepth--;
--pData->maxReadDepth;
}
pData->currentDepth--;
--pData->currentDepth;
}
@@ -1519,11 +1525,9 @@ BOOLEAN ReadInItemStats(STR fileName, BOOLEAN localizedVersion )
lpcBuffer[uiFSize] = 0; //add a null terminator
FileClose( hFile );
XML_SetElementHandler(parser, itemStartElementHandle, itemEndElementHandle);
XML_SetCharacterDataHandler(parser, itemCharacterDataHandle);
memset(&pData,0,sizeof(pData));
pData.curArray = Item;
@@ -1531,7 +1535,6 @@ BOOLEAN ReadInItemStats(STR fileName, BOOLEAN localizedVersion )
XML_SetUserData(parser, &pData);
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
{
CHAR8 errorBuf[511];
@@ -1542,21 +1545,14 @@ BOOLEAN ReadInItemStats(STR fileName, BOOLEAN localizedVersion )
MemFree(lpcBuffer);
return FALSE;
}
// item read was x -> x+1 items
++gMAXITEMS_READ;
MemFree(lpcBuffer);
XML_ParserFree(parser);
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("done reading item stats"));
//CHAR16 str[512];
//for (int i = 0; i < MAXITEMS; i++)
//{
// swprintf(str, Item[i].szLongItemName);
// DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("ReadInItemStats: long item name: %s", str));
//}
return( TRUE );
}
BOOLEAN WriteItemStats()
@@ -1576,7 +1572,7 @@ BOOLEAN WriteItemStats()
CHAR16 strDesc[500];
FilePrintf(hFile,"<ITEMLIST>\r\n");
for(cnt = 0;cnt < 351;cnt++)//just do the old limit for now
for(cnt = 0;cnt < 351; ++cnt)//just do the old limit for now
{
LoadShortNameItemInfo( (UINT16)cnt, str );