mirror of
https://github.com/1dot13/source.git
synced 2026-08-26 14:30:26 +02:00
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:
+6
-20
@@ -620,19 +620,17 @@ void InitBobbyRayInventory()
|
||||
|
||||
BOOLEAN InitBobbyRayNewInventory()
|
||||
{
|
||||
UINT16 i;
|
||||
UINT16 usBobbyrIndex = 0;
|
||||
|
||||
|
||||
memset( LaptopSaveInfo.BobbyRayInventory, 0, sizeof(STORE_INVENTORY) * MAXITEMS);
|
||||
|
||||
// add all the NEW items he can ever sell into his possible inventory list, for now in order by item #
|
||||
for( i = 0; i < MAXITEMS; i++ )
|
||||
for( UINT16 i = 0; i < MAXITEMS; ++i )
|
||||
{
|
||||
//if Bobby Ray sells this, it can be sold, and it's allowed into this game (some depend on e.g. gun-nut option)
|
||||
// if( ( StoreInventory[ i ][ BOBBY_RAY_NEW ] != 0) && !( Item[ i ].fFlags & ITEM_NOT_BUYABLE ) && ItemIsLegal( i ) )
|
||||
LaptopSaveInfo.BobbyRayInventory[ usBobbyrIndex ].usItemIndex = i;
|
||||
usBobbyrIndex++;
|
||||
++usBobbyrIndex;
|
||||
}
|
||||
|
||||
if ( usBobbyrIndex > 1 )
|
||||
@@ -641,7 +639,6 @@ BOOLEAN InitBobbyRayNewInventory()
|
||||
qsort( LaptopSaveInfo.BobbyRayInventory, usBobbyrIndex, sizeof( STORE_INVENTORY ), BobbyRayItemQsortCompare );
|
||||
}
|
||||
|
||||
|
||||
// remember how many entries in the list are valid
|
||||
LaptopSaveInfo.usInventoryListLength[ BOBBY_RAY_NEW ] = usBobbyrIndex;
|
||||
// also mark the end of the list of valid item entries
|
||||
@@ -653,14 +650,13 @@ BOOLEAN InitBobbyRayNewInventory()
|
||||
|
||||
BOOLEAN InitBobbyRayUsedInventory()
|
||||
{
|
||||
UINT16 i;
|
||||
UINT16 usBobbyrIndex = 0;
|
||||
|
||||
|
||||
memset( LaptopSaveInfo.BobbyRayUsedInventory, 0, sizeof(STORE_INVENTORY) * MAXITEMS);
|
||||
|
||||
// add all the NEW items he can ever sell into his possible inventory list, for now in order by item #
|
||||
for( i = 0; i < MAXITEMS; i++ )
|
||||
for( UINT16 i = 0; i < MAXITEMS; ++i )
|
||||
{
|
||||
//if Bobby Ray sells this, it can be sold, and it's allowed into this game (some depend on e.g. gun-nut option)
|
||||
// if( ( StoreInventory[ i ][ BOBBY_RAY_USED ] != 0) && !( Item[ i ].fFlags & ITEM_NOT_BUYABLE ) && ItemIsLegal( i ) )
|
||||
@@ -668,7 +664,7 @@ BOOLEAN InitBobbyRayUsedInventory()
|
||||
if ( CanDealerItemBeSoldUsed( i ) )
|
||||
{
|
||||
LaptopSaveInfo.BobbyRayUsedInventory[ usBobbyrIndex ].usItemIndex = i;
|
||||
usBobbyrIndex++;
|
||||
++usBobbyrIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,7 +696,7 @@ void DailyUpdateOfBobbyRaysNewInventory()
|
||||
SimulateBobbyRayCustomer(LaptopSaveInfo.BobbyRayInventory, BOBBY_RAY_NEW);
|
||||
|
||||
//loop through all items BR can stock to see what needs reordering
|
||||
for(i = 0; i < LaptopSaveInfo.usInventoryListLength[BOBBY_RAY_NEW]; i++)
|
||||
for(i = 0; i < LaptopSaveInfo.usInventoryListLength[BOBBY_RAY_NEW]; ++i)
|
||||
{
|
||||
// the index is NOT the item #, get that from the table
|
||||
usItemIndex = LaptopSaveInfo.BobbyRayInventory[ i ].usItemIndex;
|
||||
@@ -951,13 +947,11 @@ void SimulateBobbyRayCustomer(STORE_INVENTORY *pInventoryArray, BOOLEAN fUsed)
|
||||
|
||||
void CancelAllPendingBRPurchaseOrders(void)
|
||||
{
|
||||
INT16 i;
|
||||
|
||||
// remove all the BR-Order events off the event queue
|
||||
DeleteAllStrategicEventsOfType( EVENT_UPDATE_BOBBY_RAY_INVENTORY );
|
||||
|
||||
// zero out all the quantities on order
|
||||
for(i = 0; i < MAXITEMS; i++)
|
||||
for( UINT16 i = 0; i < MAXITEMS; ++i)
|
||||
{
|
||||
LaptopSaveInfo.BobbyRayInventory[ i ].ubQtyOnOrder = 0;
|
||||
LaptopSaveInfo.BobbyRayUsedInventory[ i ].ubQtyOnOrder = 0;
|
||||
@@ -967,11 +961,3 @@ void CancelAllPendingBRPurchaseOrders(void)
|
||||
DailyUpdateOfBobbyRaysNewInventory();
|
||||
DailyUpdateOfBobbyRaysUsedInventory();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+5
-13
@@ -2519,7 +2519,7 @@ void SetFirstLastPagesForNew( UINT32 uiClassMask, INT32 iFilter, INT32 iSubFilte
|
||||
gubCurPage = 0;
|
||||
|
||||
//First loop through to get the first and last index indexs
|
||||
for(i=0; i<MAXITEMS; i++)
|
||||
for(i=0; i<MAXITEMS; ++i)
|
||||
{
|
||||
//If we have some of the inventory on hand
|
||||
if( LaptopSaveInfo.BobbyRayInventory[ i ].ubQtyOnHand != 0 )
|
||||
@@ -2614,7 +2614,7 @@ void SetFirstLastPagesForNew( UINT32 uiClassMask, INT32 iFilter, INT32 iSubFilte
|
||||
//Loops through Bobby Rays Used Inventory to find the first and last index
|
||||
void SetFirstLastPagesForUsed(INT32 iFilter)
|
||||
{
|
||||
UINT16 i;
|
||||
UINT16 i;
|
||||
INT16 sFirst = -1;
|
||||
INT16 sLast = -1;
|
||||
UINT16 ubNumItems=0;
|
||||
@@ -2623,9 +2623,8 @@ void SetFirstLastPagesForUsed(INT32 iFilter)
|
||||
gubCurPage = 0;
|
||||
BOOLEAN bCntNumItems = FALSE;
|
||||
|
||||
|
||||
//First loop through to get the first and last index indexs
|
||||
for(i=0; i<MAXITEMS; i++)
|
||||
for(i=0; i<MAXITEMS; ++i)
|
||||
{
|
||||
//If we have some of the inventory on hand
|
||||
if( LaptopSaveInfo.BobbyRayUsedInventory[ i ].ubQtyOnHand != 0 )
|
||||
@@ -3594,20 +3593,13 @@ void CalcFirstIndexForPage( STORE_INVENTORY *pInv, UINT32 uiItemClass )
|
||||
|
||||
BOOLEAN IsAmmoMatchinWeaponType(UINT16 usItemIndex, UINT8 ubWeaponType)
|
||||
{
|
||||
// usItemIndex == Ammo
|
||||
|
||||
BOOLEAN bRetValue = FALSE;
|
||||
|
||||
UINT32 i;
|
||||
|
||||
for (i = 0; i < MAXITEMS; i++)
|
||||
|
||||
for ( UINT32 i = 0; i < gMAXITEMS_READ; ++i )
|
||||
{
|
||||
if (Item[i].usItemClass != IC_GUN )
|
||||
continue;
|
||||
|
||||
if (Item[i].usItemClass == 0)
|
||||
break; // out of items
|
||||
|
||||
// We found the Weapon that uses this Ammo
|
||||
if (Magazine[ Item[ usItemIndex ].ubClassIndex ].ubCalibre == Weapon[i].ubCalibre)
|
||||
{
|
||||
|
||||
@@ -1166,9 +1166,6 @@ BOOLEAN LoadBriefingRoomFromLoadGameFile( HWFILE hFile )
|
||||
#ifdef ENABLE_BRIEFINGROOM
|
||||
UINT32 uiNumBytesRead;
|
||||
UINT32 i;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_BRIEFINGROOM
|
||||
|
||||
// Flugente: compatibility fix
|
||||
BOOLEAN briefingroomreadingdone = FALSE;
|
||||
@@ -1189,7 +1186,7 @@ BOOLEAN LoadBriefingRoomFromLoadGameFile( HWFILE hFile )
|
||||
|
||||
if ( !briefingroomreadingdone )
|
||||
{
|
||||
for(i=0; i<NUM_MISSION; i++)
|
||||
for(i=0; i<NUM_MISSION; ++i)
|
||||
{
|
||||
gBriefingRoomData[ i ].Hidden = saveBriefingRoomData[i].Hidden;
|
||||
gBriefingRoomData[ i ].CheckMission = saveBriefingRoomData[i].CheckMission;
|
||||
@@ -1202,7 +1199,7 @@ BOOLEAN LoadBriefingRoomFromLoadGameFile( HWFILE hFile )
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
for(i=0; i<NUM_MISSION; i++)
|
||||
for(i=0; i<NUM_MISSION; ++i)
|
||||
{
|
||||
gBriefingRoomSpecialMissionData[ i ].Hidden = saveBriefingRoomSpecialMissionData[i].Hidden;
|
||||
gBriefingRoomSpecialMissionData[ i ].CheckMission = saveBriefingRoomSpecialMissionData[i].CheckMission;
|
||||
|
||||
@@ -1683,11 +1683,11 @@ void GiveIMPRandomItems( MERCPROFILESTRUCT *pProfile, UINT8 typeIndex )
|
||||
BOOLEAN ubItemsGiven[ 50 ]={FALSE};
|
||||
|
||||
// check how many legal items are in the choices list, this is to prevent infinite loop
|
||||
for ( UINT8 cnt=0; cnt < ubNumChoices; cnt++ )
|
||||
for ( UINT8 cnt=0; cnt < ubNumChoices; ++cnt )
|
||||
{
|
||||
usItem = gIMPItemChoices[ typeIndex ].bItemNo[ cnt ];
|
||||
if ( ItemIsLegal(usItem) )
|
||||
ubValidChoices++;
|
||||
++ubValidChoices;
|
||||
}
|
||||
|
||||
// if no valid items found, bail out
|
||||
@@ -1702,7 +1702,7 @@ void GiveIMPRandomItems( MERCPROFILESTRUCT *pProfile, UINT8 typeIndex )
|
||||
// give us the maximum possible
|
||||
ubNumItemsToGive = gIMPItemChoices[typeIndex].ubNumItems;
|
||||
|
||||
for ( int i=0; i < ubNumItemsToGive ;i++ )
|
||||
for ( int i=0; i < ubNumItemsToGive; ++i )
|
||||
{
|
||||
usItem = 0;
|
||||
while (usItem == 0 )
|
||||
@@ -1720,7 +1720,7 @@ void GiveIMPRandomItems( MERCPROFILESTRUCT *pProfile, UINT8 typeIndex )
|
||||
MakeProfileInvItemAnySlot(pProfile,usItem,100,1);
|
||||
|
||||
// give ammo for guns
|
||||
Assert(usItem<MAXITEMS);
|
||||
Assert( usItem < gMAXITEMS_READ );
|
||||
if ( Item[usItem].usItemClass == IC_GUN && !Item[usItem].rocketlauncher )
|
||||
{
|
||||
usItem = DefaultMagazine(usItem);
|
||||
@@ -1736,7 +1736,6 @@ void GiveIMPRandomItems( MERCPROFILESTRUCT *pProfile, UINT8 typeIndex )
|
||||
MakeProfileInvItemAnySlot(pProfile,usItem,100,(2+Random(2)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GiveIMPItems( MERCPROFILESTRUCT *pProfile, INT8 abilityValue, UINT8 typeIndex )
|
||||
|
||||
@@ -796,10 +796,10 @@ void SetupStoreInventory( STORE_INVENTORY *pInventoryArray, BOOLEAN fUsed )
|
||||
UINT8 ubNumBought;
|
||||
|
||||
//loop through all items BR can stock to init a starting quantity on hand
|
||||
for(i = 0; i < LaptopSaveInfo.usInventoryListLength[fUsed]; i++)
|
||||
for(i = 0; i < LaptopSaveInfo.usInventoryListLength[fUsed]; ++i)
|
||||
{
|
||||
usItemIndex = pInventoryArray[ i ].usItemIndex;
|
||||
Assert(usItemIndex < MAXITEMS);
|
||||
Assert( usItemIndex < MAXITEMS );
|
||||
|
||||
ubNumBought = DetermineInitialInvItems( -1, usItemIndex, StoreInventory[ usItemIndex ][ fUsed ], fUsed);
|
||||
if ( ubNumBought > 0)
|
||||
@@ -830,17 +830,14 @@ void SetupStoreInventory( STORE_INVENTORY *pInventoryArray, BOOLEAN fUsed )
|
||||
|
||||
BOOLEAN DoesGunOfSameClassExistInInventory( UINT8 ubItemIndex, UINT8 ubDealerID )
|
||||
{
|
||||
UINT16 i;
|
||||
|
||||
STORE_INVENTORY *pInventoryArray;
|
||||
|
||||
pInventoryArray = GetPtrToStoreInventory( ubDealerID );
|
||||
if( pInventoryArray == NULL )
|
||||
return( FALSE );
|
||||
|
||||
|
||||
|
||||
//go through all of the guns
|
||||
for(i=0; i<MAXITEMS; i++)
|
||||
for ( UINT16 i = 0; i<gMAXITEMS_READ; ++i )
|
||||
{
|
||||
//if it's the class we are looking for
|
||||
if( Weapon[ i ].ubWeaponClass == ubItemIndex )
|
||||
@@ -856,6 +853,7 @@ BOOLEAN DoesGunOfSameClassExistInInventory( UINT8 ubItemIndex, UINT8 ubDealerID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user