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
+9 -9
View File
@@ -15,9 +15,9 @@
#ifdef JA2EDITOR #ifdef JA2EDITOR
#ifdef JA2UB #ifdef JA2UB
CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.7529 (Development Build)" }; CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.7599 (Development Build)" };
#else #else
CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.7529 (Development Build)" }; CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.7599 (Development Build)" };
#endif #endif
// ------------------------------ // ------------------------------
@@ -27,11 +27,11 @@
//DEBUG BUILD VERSION //DEBUG BUILD VERSION
#ifdef JA2UB #ifdef JA2UB
CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.7529 (Development Build)" }; CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.7599 (Development Build)" };
#elif defined (JA113DEMO) #elif defined (JA113DEMO)
CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.7529 (Development Build)" }; CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.7599 (Development Build)" };
#else #else
CHAR16 zVersionLabel[256] = { L"Debug: v1.13.7529 (Development Build)" }; CHAR16 zVersionLabel[256] = { L"Debug: v1.13.7599 (Development Build)" };
#endif #endif
#elif defined CRIPPLED_VERSION #elif defined CRIPPLED_VERSION
@@ -46,16 +46,16 @@
//RELEASE BUILD VERSION //RELEASE BUILD VERSION
#ifdef JA2UB #ifdef JA2UB
CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.7529 (Development Build)" }; CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.7599 (Development Build)" };
#elif defined (JA113DEMO) #elif defined (JA113DEMO)
CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.7529 (Development Build)" }; CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.7599 (Development Build)" };
#else #else
CHAR16 zVersionLabel[256] = { L"Release v1.13.7529 (Development Build)" }; CHAR16 zVersionLabel[256] = { L"Release v1.13.7599 (Development Build)" };
#endif #endif
#endif #endif
CHAR8 czVersionNumber[16] = { "Build 14.09.24" }; //YY.MM.DD CHAR8 czVersionNumber[16] = { "Build 14.10.19" }; //YY.MM.DD
CHAR16 zTrackingNumber[16] = { L"Z" }; CHAR16 zTrackingNumber[16] = { L"Z" };
// SAVE_GAME_VERSION is defined in header, change it there // SAVE_GAME_VERSION is defined in header, change it there
+6 -20
View File
@@ -620,19 +620,17 @@ void InitBobbyRayInventory()
BOOLEAN InitBobbyRayNewInventory() BOOLEAN InitBobbyRayNewInventory()
{ {
UINT16 i;
UINT16 usBobbyrIndex = 0; UINT16 usBobbyrIndex = 0;
memset( LaptopSaveInfo.BobbyRayInventory, 0, sizeof(STORE_INVENTORY) * MAXITEMS); 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 # // 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 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 ) ) // if( ( StoreInventory[ i ][ BOBBY_RAY_NEW ] != 0) && !( Item[ i ].fFlags & ITEM_NOT_BUYABLE ) && ItemIsLegal( i ) )
LaptopSaveInfo.BobbyRayInventory[ usBobbyrIndex ].usItemIndex = i; LaptopSaveInfo.BobbyRayInventory[ usBobbyrIndex ].usItemIndex = i;
usBobbyrIndex++; ++usBobbyrIndex;
} }
if ( usBobbyrIndex > 1 ) if ( usBobbyrIndex > 1 )
@@ -641,7 +639,6 @@ BOOLEAN InitBobbyRayNewInventory()
qsort( LaptopSaveInfo.BobbyRayInventory, usBobbyrIndex, sizeof( STORE_INVENTORY ), BobbyRayItemQsortCompare ); qsort( LaptopSaveInfo.BobbyRayInventory, usBobbyrIndex, sizeof( STORE_INVENTORY ), BobbyRayItemQsortCompare );
} }
// remember how many entries in the list are valid // remember how many entries in the list are valid
LaptopSaveInfo.usInventoryListLength[ BOBBY_RAY_NEW ] = usBobbyrIndex; LaptopSaveInfo.usInventoryListLength[ BOBBY_RAY_NEW ] = usBobbyrIndex;
// also mark the end of the list of valid item entries // also mark the end of the list of valid item entries
@@ -653,14 +650,13 @@ BOOLEAN InitBobbyRayNewInventory()
BOOLEAN InitBobbyRayUsedInventory() BOOLEAN InitBobbyRayUsedInventory()
{ {
UINT16 i;
UINT16 usBobbyrIndex = 0; UINT16 usBobbyrIndex = 0;
memset( LaptopSaveInfo.BobbyRayUsedInventory, 0, sizeof(STORE_INVENTORY) * MAXITEMS); 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 # // 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 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 ) ) // if( ( StoreInventory[ i ][ BOBBY_RAY_USED ] != 0) && !( Item[ i ].fFlags & ITEM_NOT_BUYABLE ) && ItemIsLegal( i ) )
@@ -668,7 +664,7 @@ BOOLEAN InitBobbyRayUsedInventory()
if ( CanDealerItemBeSoldUsed( i ) ) if ( CanDealerItemBeSoldUsed( i ) )
{ {
LaptopSaveInfo.BobbyRayUsedInventory[ usBobbyrIndex ].usItemIndex = i; LaptopSaveInfo.BobbyRayUsedInventory[ usBobbyrIndex ].usItemIndex = i;
usBobbyrIndex++; ++usBobbyrIndex;
} }
} }
@@ -700,7 +696,7 @@ void DailyUpdateOfBobbyRaysNewInventory()
SimulateBobbyRayCustomer(LaptopSaveInfo.BobbyRayInventory, BOBBY_RAY_NEW); SimulateBobbyRayCustomer(LaptopSaveInfo.BobbyRayInventory, BOBBY_RAY_NEW);
//loop through all items BR can stock to see what needs reordering //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 // the index is NOT the item #, get that from the table
usItemIndex = LaptopSaveInfo.BobbyRayInventory[ i ].usItemIndex; usItemIndex = LaptopSaveInfo.BobbyRayInventory[ i ].usItemIndex;
@@ -951,13 +947,11 @@ void SimulateBobbyRayCustomer(STORE_INVENTORY *pInventoryArray, BOOLEAN fUsed)
void CancelAllPendingBRPurchaseOrders(void) void CancelAllPendingBRPurchaseOrders(void)
{ {
INT16 i;
// remove all the BR-Order events off the event queue // remove all the BR-Order events off the event queue
DeleteAllStrategicEventsOfType( EVENT_UPDATE_BOBBY_RAY_INVENTORY ); DeleteAllStrategicEventsOfType( EVENT_UPDATE_BOBBY_RAY_INVENTORY );
// zero out all the quantities on order // 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.BobbyRayInventory[ i ].ubQtyOnOrder = 0;
LaptopSaveInfo.BobbyRayUsedInventory[ i ].ubQtyOnOrder = 0; LaptopSaveInfo.BobbyRayUsedInventory[ i ].ubQtyOnOrder = 0;
@@ -967,11 +961,3 @@ void CancelAllPendingBRPurchaseOrders(void)
DailyUpdateOfBobbyRaysNewInventory(); DailyUpdateOfBobbyRaysNewInventory();
DailyUpdateOfBobbyRaysUsedInventory(); DailyUpdateOfBobbyRaysUsedInventory();
} }
+5 -13
View File
@@ -2519,7 +2519,7 @@ void SetFirstLastPagesForNew( UINT32 uiClassMask, INT32 iFilter, INT32 iSubFilte
gubCurPage = 0; gubCurPage = 0;
//First loop through to get the first and last index indexs //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 we have some of the inventory on hand
if( LaptopSaveInfo.BobbyRayInventory[ i ].ubQtyOnHand != 0 ) 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 //Loops through Bobby Rays Used Inventory to find the first and last index
void SetFirstLastPagesForUsed(INT32 iFilter) void SetFirstLastPagesForUsed(INT32 iFilter)
{ {
UINT16 i; UINT16 i;
INT16 sFirst = -1; INT16 sFirst = -1;
INT16 sLast = -1; INT16 sLast = -1;
UINT16 ubNumItems=0; UINT16 ubNumItems=0;
@@ -2623,9 +2623,8 @@ void SetFirstLastPagesForUsed(INT32 iFilter)
gubCurPage = 0; gubCurPage = 0;
BOOLEAN bCntNumItems = FALSE; BOOLEAN bCntNumItems = FALSE;
//First loop through to get the first and last index indexs //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 we have some of the inventory on hand
if( LaptopSaveInfo.BobbyRayUsedInventory[ i ].ubQtyOnHand != 0 ) if( LaptopSaveInfo.BobbyRayUsedInventory[ i ].ubQtyOnHand != 0 )
@@ -3594,20 +3593,13 @@ void CalcFirstIndexForPage( STORE_INVENTORY *pInv, UINT32 uiItemClass )
BOOLEAN IsAmmoMatchinWeaponType(UINT16 usItemIndex, UINT8 ubWeaponType) BOOLEAN IsAmmoMatchinWeaponType(UINT16 usItemIndex, UINT8 ubWeaponType)
{ {
// usItemIndex == Ammo
BOOLEAN bRetValue = FALSE; BOOLEAN bRetValue = FALSE;
UINT32 i; for ( UINT32 i = 0; i < gMAXITEMS_READ; ++i )
for (i = 0; i < MAXITEMS; i++)
{ {
if (Item[i].usItemClass != IC_GUN ) if (Item[i].usItemClass != IC_GUN )
continue; continue;
if (Item[i].usItemClass == 0)
break; // out of items
// We found the Weapon that uses this Ammo // We found the Weapon that uses this Ammo
if (Magazine[ Item[ usItemIndex ].ubClassIndex ].ubCalibre == Weapon[i].ubCalibre) if (Magazine[ Item[ usItemIndex ].ubClassIndex ].ubCalibre == Weapon[i].ubCalibre)
{ {
+2 -5
View File
@@ -1166,9 +1166,6 @@ BOOLEAN LoadBriefingRoomFromLoadGameFile( HWFILE hFile )
#ifdef ENABLE_BRIEFINGROOM #ifdef ENABLE_BRIEFINGROOM
UINT32 uiNumBytesRead; UINT32 uiNumBytesRead;
UINT32 i; UINT32 i;
#endif
#ifdef ENABLE_BRIEFINGROOM
// Flugente: compatibility fix // Flugente: compatibility fix
BOOLEAN briefingroomreadingdone = FALSE; BOOLEAN briefingroomreadingdone = FALSE;
@@ -1189,7 +1186,7 @@ BOOLEAN LoadBriefingRoomFromLoadGameFile( HWFILE hFile )
if ( !briefingroomreadingdone ) if ( !briefingroomreadingdone )
{ {
for(i=0; i<NUM_MISSION; i++) for(i=0; i<NUM_MISSION; ++i)
{ {
gBriefingRoomData[ i ].Hidden = saveBriefingRoomData[i].Hidden; gBriefingRoomData[ i ].Hidden = saveBriefingRoomData[i].Hidden;
gBriefingRoomData[ i ].CheckMission = saveBriefingRoomData[i].CheckMission; gBriefingRoomData[ i ].CheckMission = saveBriefingRoomData[i].CheckMission;
@@ -1202,7 +1199,7 @@ BOOLEAN LoadBriefingRoomFromLoadGameFile( HWFILE hFile )
return( FALSE ); return( FALSE );
} }
for(i=0; i<NUM_MISSION; i++) for(i=0; i<NUM_MISSION; ++i)
{ {
gBriefingRoomSpecialMissionData[ i ].Hidden = saveBriefingRoomSpecialMissionData[i].Hidden; gBriefingRoomSpecialMissionData[ i ].Hidden = saveBriefingRoomSpecialMissionData[i].Hidden;
gBriefingRoomSpecialMissionData[ i ].CheckMission = saveBriefingRoomSpecialMissionData[i].CheckMission; gBriefingRoomSpecialMissionData[ i ].CheckMission = saveBriefingRoomSpecialMissionData[i].CheckMission;
+4 -5
View File
@@ -1683,11 +1683,11 @@ void GiveIMPRandomItems( MERCPROFILESTRUCT *pProfile, UINT8 typeIndex )
BOOLEAN ubItemsGiven[ 50 ]={FALSE}; BOOLEAN ubItemsGiven[ 50 ]={FALSE};
// check how many legal items are in the choices list, this is to prevent infinite loop // 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 ]; usItem = gIMPItemChoices[ typeIndex ].bItemNo[ cnt ];
if ( ItemIsLegal(usItem) ) if ( ItemIsLegal(usItem) )
ubValidChoices++; ++ubValidChoices;
} }
// if no valid items found, bail out // if no valid items found, bail out
@@ -1702,7 +1702,7 @@ void GiveIMPRandomItems( MERCPROFILESTRUCT *pProfile, UINT8 typeIndex )
// give us the maximum possible // give us the maximum possible
ubNumItemsToGive = gIMPItemChoices[typeIndex].ubNumItems; ubNumItemsToGive = gIMPItemChoices[typeIndex].ubNumItems;
for ( int i=0; i < ubNumItemsToGive ;i++ ) for ( int i=0; i < ubNumItemsToGive; ++i )
{ {
usItem = 0; usItem = 0;
while (usItem == 0 ) while (usItem == 0 )
@@ -1720,7 +1720,7 @@ void GiveIMPRandomItems( MERCPROFILESTRUCT *pProfile, UINT8 typeIndex )
MakeProfileInvItemAnySlot(pProfile,usItem,100,1); MakeProfileInvItemAnySlot(pProfile,usItem,100,1);
// give ammo for guns // give ammo for guns
Assert(usItem<MAXITEMS); Assert( usItem < gMAXITEMS_READ );
if ( Item[usItem].usItemClass == IC_GUN && !Item[usItem].rocketlauncher ) if ( Item[usItem].usItemClass == IC_GUN && !Item[usItem].rocketlauncher )
{ {
usItem = DefaultMagazine(usItem); usItem = DefaultMagazine(usItem);
@@ -1736,7 +1736,6 @@ void GiveIMPRandomItems( MERCPROFILESTRUCT *pProfile, UINT8 typeIndex )
MakeProfileInvItemAnySlot(pProfile,usItem,100,(2+Random(2))); MakeProfileInvItemAnySlot(pProfile,usItem,100,(2+Random(2)));
} }
} }
} }
void GiveIMPItems( MERCPROFILESTRUCT *pProfile, INT8 abilityValue, UINT8 typeIndex ) void GiveIMPItems( MERCPROFILESTRUCT *pProfile, INT8 abilityValue, UINT8 typeIndex )
+5 -7
View File
@@ -796,10 +796,10 @@ void SetupStoreInventory( STORE_INVENTORY *pInventoryArray, BOOLEAN fUsed )
UINT8 ubNumBought; UINT8 ubNumBought;
//loop through all items BR can stock to init a starting quantity on hand //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; usItemIndex = pInventoryArray[ i ].usItemIndex;
Assert(usItemIndex < MAXITEMS); Assert( usItemIndex < MAXITEMS );
ubNumBought = DetermineInitialInvItems( -1, usItemIndex, StoreInventory[ usItemIndex ][ fUsed ], fUsed); ubNumBought = DetermineInitialInvItems( -1, usItemIndex, StoreInventory[ usItemIndex ][ fUsed ], fUsed);
if ( ubNumBought > 0) if ( ubNumBought > 0)
@@ -830,17 +830,14 @@ void SetupStoreInventory( STORE_INVENTORY *pInventoryArray, BOOLEAN fUsed )
BOOLEAN DoesGunOfSameClassExistInInventory( UINT8 ubItemIndex, UINT8 ubDealerID ) BOOLEAN DoesGunOfSameClassExistInInventory( UINT8 ubItemIndex, UINT8 ubDealerID )
{ {
UINT16 i;
STORE_INVENTORY *pInventoryArray; STORE_INVENTORY *pInventoryArray;
pInventoryArray = GetPtrToStoreInventory( ubDealerID ); pInventoryArray = GetPtrToStoreInventory( ubDealerID );
if( pInventoryArray == NULL ) if( pInventoryArray == NULL )
return( FALSE ); return( FALSE );
//go through all of the guns //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 it's the class we are looking for
if( Weapon[ i ].ubWeaponClass == ubItemIndex ) if( Weapon[ i ].ubWeaponClass == ubItemIndex )
@@ -856,6 +853,7 @@ BOOLEAN DoesGunOfSameClassExistInInventory( UINT8 ubItemIndex, UINT8 ubDealerID
} }
} }
} }
return(FALSE); return(FALSE);
} }
+8 -8
View File
@@ -849,22 +849,20 @@ BOOLEAN LoadArmsDealerInventoryFromSavedGameFile( HWFILE hFile )
OLD_DEALER_SPECIAL_ITEM_101 oldSpecial; OLD_DEALER_SPECIAL_ITEM_101 oldSpecial;
DEALER_SPECIAL_ITEM loadedSpecial; DEALER_SPECIAL_ITEM loadedSpecial;
//loop through all the dealers inventories //loop through all the dealers inventories
for( ubArmsDealer=0; ubArmsDealer<uiDealersSaved; ubArmsDealer++ ) for( ubArmsDealer=0; ubArmsDealer<uiDealersSaved; ++ubArmsDealer )
{ {
gArmsDealerStatus[ubArmsDealer] = gOldArmsDealerStatus[ubArmsDealer]; gArmsDealerStatus[ubArmsDealer] = gOldArmsDealerStatus[ubArmsDealer];
//loop through this dealer's individual items //loop through this dealer's individual items
for(usItemIndex = 1; usItemIndex < MAXITEMS; usItemIndex++ ) for ( usItemIndex = 1; usItemIndex < gMAXITEMS_READ; ++usItemIndex )
{ {
if ( Item[usItemIndex].usItemClass == 0 )
continue;
//some things are much much better stored in status now //some things are much much better stored in status now
gArmsDealerStatus[ubArmsDealer].fPreviouslyEligible[usItemIndex] = (*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].fPreviouslyEligible; gArmsDealerStatus[ubArmsDealer].fPreviouslyEligible[usItemIndex] = (*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].fPreviouslyEligible;
gArmsDealerStatus[ubArmsDealer].ubStrayAmmo[usItemIndex] = (*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubStrayAmmo; gArmsDealerStatus[ubArmsDealer].ubStrayAmmo[usItemIndex] = (*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubStrayAmmo;
//if there are any perfect items, insert them immediately //if there are any perfect items, insert them immediately
if ((*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubPerfectItems) { if ((*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubPerfectItems)
{
gArmsDealersInventory[ubArmsDealer].push_back(DEALER_SPECIAL_ITEM()); gArmsDealersInventory[ubArmsDealer].push_back(DEALER_SPECIAL_ITEM());
DEALER_SPECIAL_ITEM* pPerfectItem = &gArmsDealersInventory[ubArmsDealer].back(); DEALER_SPECIAL_ITEM* pPerfectItem = &gArmsDealersInventory[ubArmsDealer].back();
CreateObjectForDealer(usItemIndex, 100, (*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubPerfectItems, &pPerfectItem->object); CreateObjectForDealer(usItemIndex, 100, (*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubPerfectItems, &pPerfectItem->object);
@@ -873,14 +871,16 @@ BOOLEAN LoadArmsDealerInventoryFromSavedGameFile( HWFILE hFile )
} }
//if there are any items on order, order them //if there are any items on order, order them
if ((*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubQtyOnOrder) { if ((*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubQtyOnOrder)
{
OrderDealerItems(ubArmsDealer, usItemIndex, OrderDealerItems(ubArmsDealer, usItemIndex,
(*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubQtyOnOrder, (*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubQtyOnOrder,
(*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].uiOrderArrivalTime); (*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].uiOrderArrivalTime);
} }
//if there are any special elements allocated for this item, load them //if there are any special elements allocated for this item, load them
for ( int x = 0; x < (*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubElementsAlloced; ++x) { for ( int x = 0; x < (*pOldArmsDealersInventory)[ubArmsDealer][usItemIndex].ubElementsAlloced; ++x)
{
if (!FileRead( hFile, &oldSpecial, sizeof( OLD_DEALER_SPECIAL_ITEM_101 ), &uiNumBytesRead )) if (!FileRead( hFile, &oldSpecial, sizeof( OLD_DEALER_SPECIAL_ITEM_101 ), &uiNumBytesRead ))
{ {
return( FALSE ); return( FALSE );
@@ -2054,10 +2054,10 @@ void BuildStashForSelectedSector( INT16 sMapX, INT16 sMapY, INT16 sMapZ )
// was temporay used to get #items in file, now count what actually is added // was temporay used to get #items in file, now count what actually is added
fNumTotal = 0; fNumTotal = 0;
// now run through list and copy reference // now run through list and copy reference
for(UINT32 i = 0; i < fWorldItems.size(); i++ ) for(UINT32 i = 0; i < fWorldItems.size(); ++i )
{ {
// TEST!! If the item exists, and is NOT VALID, report it // TEST!! If the item exists, and is NOT VALID, report it
if( fWorldItems[i].fExists && fWorldItems[ i ].object.usItem > MAXITEMS ) if( fWorldItems[i].fExists && fWorldItems[ i ].object.usItem > gMAXITEMS_READ )
{ {
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"The %d item in the list is NOT valid (ID%d). Please send save. DF 1.", i, fWorldItems[i].object.usItem ); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"The %d item in the list is NOT valid (ID%d). Please send save. DF 1.", i, fWorldItems[i].object.usItem );
} }
@@ -4744,7 +4744,7 @@ void SortSectorInventoryAmmo(bool useBoxes)
while (ammoPresent && loopCount <= 10 ) while (ammoPresent && loopCount <= 10 )
{ {
// Start scanning through the entire Sector Inventory pool. // Start scanning through the entire Sector Inventory pool.
for(UINT32 iInvCounter = 0; iInvCounter < uiOrigInvSize; iInvCounter++) for(UINT32 iInvCounter = 0; iInvCounter < uiOrigInvSize; ++iInvCounter)
{ {
// Set values // Set values
crateItem = 0; crateItem = 0;
@@ -4770,7 +4770,7 @@ void SortSectorInventoryAmmo(bool useBoxes)
// as possible into crates. // as possible into crates.
// Look through all items in the game to try and find an ammocrate that can contain this kind of ammo. // Look through all items in the game to try and find an ammocrate that can contain this kind of ammo.
for(int iCrateLoop = 0; iCrateLoop < MAXITEMS; iCrateLoop++) for ( int iCrateLoop = 0; iCrateLoop < gMAXITEMS_READ; ++iCrateLoop )
{ {
// Is it the right ammo crate? // Is it the right ammo crate?
if( Item[iCrateLoop].usItemClass == IC_AMMO && if( Item[iCrateLoop].usItemClass == IC_AMMO &&
@@ -4788,7 +4788,7 @@ void SortSectorInventoryAmmo(bool useBoxes)
if(crateItem != 0) if(crateItem != 0)
{ {
// Excellent. Let see if a crate like this already exists in the Sector Inventory. // Excellent. Let see if a crate like this already exists in the Sector Inventory.
for(UINT32 iInvCounter2=0; iInvCounter2 < pInventoryPoolList.size(); iInvCounter2++) for(UINT32 iInvCounter2=0; iInvCounter2 < pInventoryPoolList.size(); ++iInvCounter2)
{ {
// Non-empty slots please... // Non-empty slots please...
if(pInventoryPoolList[iInvCounter2].object.exists() == true) if(pInventoryPoolList[iInvCounter2].object.exists() == true)
+29 -35
View File
@@ -197,8 +197,7 @@ void InitAllArmsDealers()
void InitializeOneArmsDealer( UINT8 ubArmsDealer ) void InitializeOneArmsDealer( UINT8 ubArmsDealer )
{ {
UINT16 usItemIndex; UINT16 usItemIndex;
UINT8 ubNumItems=0; UINT8 ubNumItems=0;
memset( &( gArmsDealerStatus[ ubArmsDealer ] ), 0, sizeof( ARMS_DEALER_STATUS ) ); memset( &( gArmsDealerStatus[ ubArmsDealer ] ), 0, sizeof( ARMS_DEALER_STATUS ) );
gArmsDealersInventory.resize(gArmsDealersInventory.size() + 1); gArmsDealersInventory.resize(gArmsDealersInventory.size() + 1);
@@ -212,9 +211,8 @@ void InitializeOneArmsDealer( UINT8 ubArmsDealer )
return; return;
} }
//loop through all the item types //loop through all the item types
for( usItemIndex = 1; usItemIndex < MAXITEMS; usItemIndex++ ) for ( usItemIndex = 1; usItemIndex < gMAXITEMS_READ; ++usItemIndex )
{ {
if ( Item[usItemIndex].usItemClass == 0 ) if ( Item[usItemIndex].usItemClass == 0 )
break; break;
@@ -332,14 +330,14 @@ void DailyUpdateOfArmsDealersInventory()
// Once a day, loop through each dealer's inventory items and possibly sell some // Once a day, loop through each dealer's inventory items and possibly sell some
void SimulateArmsDealerCustomer() void SimulateArmsDealerCustomer()
{ {
UINT8 ubArmsDealer=0; UINT8 ubArmsDealer=0;
UINT16 usItemIndex; UINT16 usItemIndex;
UINT8 ubItemsSold=0; UINT8 ubItemsSold=0;
static int numPerfectItems[MAXITEMS]; static int numPerfectItems[MAXITEMS];
//loop through all the arms dealers //loop through all the arms dealers
for( ubArmsDealer=0;ubArmsDealer<NUM_ARMS_DEALERS;ubArmsDealer++ ) for( ubArmsDealer=0;ubArmsDealer<NUM_ARMS_DEALERS; ++ubArmsDealer )
{ {
if( gArmsDealerStatus[ ubArmsDealer ].fOutOfBusiness ) if( gArmsDealerStatus[ ubArmsDealer ].fOutOfBusiness )
continue; continue;
@@ -350,15 +348,17 @@ void SimulateArmsDealerCustomer()
memset (&numPerfectItems, 0, sizeof(numPerfectItems)); memset (&numPerfectItems, 0, sizeof(numPerfectItems));
for (DealerItemList::iterator iter = gArmsDealersInventory[ ubArmsDealer ].begin(); DealerItemList::iterator iterend = gArmsDealersInventory[ubArmsDealer].end( );
iter != gArmsDealersInventory[ ubArmsDealer ].end(); ++iter) { for (DealerItemList::iterator iter = gArmsDealersInventory[ ubArmsDealer ].begin(); iter != iterend; ++iter )
if (iter->ItemIsInInventory() == true && iter->bItemCondition == 100) { {
if (iter->ItemIsInInventory() == true && iter->bItemCondition == 100)
{
numPerfectItems[iter->object.usItem] += iter->object.ubNumberOfObjects; numPerfectItems[iter->object.usItem] += iter->object.ubNumberOfObjects;
} }
} }
//loop through all items of the same type //loop through all items of the same type
for( usItemIndex = 1; usItemIndex < MAXITEMS; usItemIndex++ ) for ( usItemIndex = 1; usItemIndex < gMAXITEMS_READ; ++usItemIndex )
{ {
if ( Item[usItemIndex].usItemClass == 0 ) if ( Item[usItemIndex].usItemClass == 0 )
break; break;
@@ -389,19 +389,21 @@ void SimulateArmsDealerCustomer()
} }
} }
for (DealerItemList::iterator iter = gArmsDealersInventory[ ubArmsDealer ].begin(); iterend = gArmsDealersInventory[ubArmsDealer].end();
iter != gArmsDealersInventory[ ubArmsDealer ].end(); ++iter) { for (DealerItemList::iterator iter = gArmsDealersInventory[ ubArmsDealer ].begin(); iter != iterend; ++iter )
{
// next, try to sell all the used ones, gotta do these one at a time so we can remove them by element // next, try to sell all the used ones, gotta do these one at a time so we can remove them by element
// don't worry about negative condition, repairmen can't come this far, they don't sell! // don't worry about negative condition, repairmen can't come this far, they don't sell!
if (iter->bItemCondition < 100 && iter->bItemCondition > 0) { if (iter->bItemCondition < 100 && iter->bItemCondition > 0)
if ( iter->ItemIsInInventory() == true) { {
if ( iter->ItemIsInInventory() == true)
{
// try selling just this one // try selling just this one
if (HowManyItemsAreSold( ubArmsDealer, iter->object.usItem, 1, TRUE) > 0) if (HowManyItemsAreSold( ubArmsDealer, iter->object.usItem, 1, TRUE) > 0)
{ {
iter = gArmsDealersInventory[ ubArmsDealer ].erase(iter); iter = gArmsDealersInventory[ ubArmsDealer ].erase(iter);
if (iter == gArmsDealersInventory[ ubArmsDealer ].end()) { if (iter == gArmsDealersInventory[ ubArmsDealer ].end() )
break; break;
}
} }
} }
} }
@@ -424,7 +426,7 @@ void DailyCheckOnItemQuantities()
//loop through all the arms dealers //loop through all the arms dealers
for( ubArmsDealer=0;ubArmsDealer<NUM_ARMS_DEALERS;ubArmsDealer++ ) for( ubArmsDealer=0;ubArmsDealer<NUM_ARMS_DEALERS; ++ubArmsDealer )
{ {
if( gArmsDealerStatus[ ubArmsDealer ].fOutOfBusiness ) if( gArmsDealerStatus[ ubArmsDealer ].fOutOfBusiness )
continue; continue;
@@ -469,10 +471,8 @@ void DailyCheckOnItemQuantities()
} }
//loop through all items of the same type //loop through all items of the same type
for( usItemIndex = 1; usItemIndex < MAXITEMS; usItemIndex++ ) for ( usItemIndex = 1; usItemIndex < gMAXITEMS_READ; ++usItemIndex )
{ {
if ( Item[usItemIndex].usItemClass == 0 )
break;
//if the dealer can sell the item type //if the dealer can sell the item type
if( CanDealerTransactItem( ubArmsDealer, usItemIndex, FALSE ) ) if( CanDealerTransactItem( ubArmsDealer, usItemIndex, FALSE ) )
{ {
@@ -701,10 +701,8 @@ void LimitArmsDealersInventory( UINT8 ubArmsDealer, UINT32 uiDealerItemType, UIN
std::vector<int> usAvailableItems; std::vector<int> usAvailableItems;
std::vector<UINT32> ubNumberOfAvailableItem; std::vector<UINT32> ubNumberOfAvailableItem;
//loop through all items of the same class and count the number in stock //loop through all items of the same class and count the number in stock
for( usItemIndex = 1; usItemIndex < MAXITEMS; usItemIndex++ ) for ( usItemIndex = 1; usItemIndex < gMAXITEMS_READ; ++usItemIndex )
{ {
if ( Item[usItemIndex].usItemClass == 0 )
break;
//if there is some items in stock //if there is some items in stock
if( numTotalItems[usItemIndex] > 0) if( numTotalItems[usItemIndex] > 0)
{ {
@@ -838,10 +836,8 @@ void GuaranteeAtLeastOneItemOfType( UINT8 ubArmsDealer, UINT32 uiDealerItemType
std::vector<UINT16> usAvailableItems; std::vector<UINT16> usAvailableItems;
std::vector<UINT8> ubChanceForAvailableItem; std::vector<UINT8> ubChanceForAvailableItem;
//loop through all items of the same type //loop through all items of the same type
for( usItemIndex = 1; usItemIndex < MAXITEMS; usItemIndex++ ) for ( usItemIndex = 1; usItemIndex < gMAXITEMS_READ; ++usItemIndex )
{ {
if ( Item[usItemIndex].usItemClass == 0 )
break;
//if the item is of the same dealer item type //if the item is of the same dealer item type
if( uiDealerItemType & GetArmsDealerItemTypeFromItemNumber( usItemIndex ) ) if( uiDealerItemType & GetArmsDealerItemTypeFromItemNumber( usItemIndex ) )
{ {
@@ -1447,7 +1443,6 @@ bool ItemIsSpecial(DEALER_SPECIAL_ITEM& item)
UINT16 CountTotalItemsRepairDealerHasInForRepairs( UINT8 ubArmsDealer ) UINT16 CountTotalItemsRepairDealerHasInForRepairs( UINT8 ubArmsDealer )
{ {
UINT16 usItemIndex;
UINT16 usHowManyInForRepairs = 0; UINT16 usHowManyInForRepairs = 0;
//if the dealer is not a repair dealer, no need to count, return 0 //if the dealer is not a repair dealer, no need to count, return 0
@@ -1455,10 +1450,8 @@ UINT16 CountTotalItemsRepairDealerHasInForRepairs( UINT8 ubArmsDealer )
return( 0 ); return( 0 );
//loop through the dealers inventory and count the number of items in for repairs //loop through the dealers inventory and count the number of items in for repairs
for( usItemIndex=0; usItemIndex < MAXITEMS; usItemIndex++ ) for ( UINT16 usItemIndex = 0; usItemIndex < gMAXITEMS_READ; ++usItemIndex )
{ {
if ( Item[usItemIndex].usItemClass == 0 )
break;
usHowManyInForRepairs += CountSpecificItemsRepairDealerHasInForRepairs( ubArmsDealer, usItemIndex ); usHowManyInForRepairs += CountSpecificItemsRepairDealerHasInForRepairs( ubArmsDealer, usItemIndex );
} }
@@ -1474,13 +1467,12 @@ UINT8 CountSpecificItemsRepairDealerHasInForRepairs( UINT8 ubArmsDealer, UINT16
if( !DoesDealerDoRepairs( ubArmsDealer ) ) if( !DoesDealerDoRepairs( ubArmsDealer ) )
return( 0 ); return( 0 );
for (DealerItemList::iterator iter = gArmsDealersInventory[ ubArmsDealer ].begin(); for (DealerItemList::iterator iter = gArmsDealersInventory[ ubArmsDealer ].begin();
iter != gArmsDealersInventory[ ubArmsDealer ].end(); ++iter) { iter != gArmsDealersInventory[ ubArmsDealer ].end(); ++iter) {
if (iter->object.exists() == true && iter->object.usItem == usItemIndex) { if (iter->object.exists() == true && iter->object.usItem == usItemIndex) {
if( iter->IsUnderRepair() == true ) if( iter->IsUnderRepair() == true )
{ {
ubHowManyInForRepairs++; ++ubHowManyInForRepairs;
} }
} }
} }
@@ -1697,11 +1689,13 @@ void RemoveItemFromArmsDealerInventory( UINT8 ubArmsDealer, UINT16 usItemIndex,
{ {
return; return;
} }
for (DealerItemList::iterator iter = gArmsDealersInventory[ ubArmsDealer ].begin(); iter != gArmsDealersInventory[ ubArmsDealer ].end(); iter++){ for (DealerItemList::iterator iter = gArmsDealersInventory[ ubArmsDealer ].begin(); iter != gArmsDealersInventory[ ubArmsDealer ].end(); ++iter)
if (iter->ItemIsInInventory() == true && iter->object.usItem == usItemIndex) { {
if (iter->ItemIsInInventory() == true && iter->object.usItem == usItemIndex)
{
if(pObj != 0) if(pObj != 0)
{ {
for(unsigned int i = 0; i < ubHowMany; i++) for(unsigned int i = 0; i < ubHowMany; ++i)
{ {
if((*pObj)[i]->operator == (*iter->object[i])) if((*pObj)[i]->operator == (*iter->object[i]))
match = TRUE; match = TRUE;
+3 -5
View File
@@ -1459,14 +1459,13 @@ int CompareItemsForSorting( UINT16 usItem1Index, UINT16 usItem2Index, UINT16 ubI
UINT8 GetDealerItemCategoryNumber( UINT16 usItemIndex ) UINT8 GetDealerItemCategoryNumber( UINT16 usItemIndex )
{ {
UINT32 uiItemClass; UINT32 uiItemClass;
UINT8 ubWeaponClass; UINT8 ubWeaponClass;
UINT8 ubCategory = 0; UINT8 ubCategory = 0;
uiItemClass = Item[ usItemIndex ].usItemClass; uiItemClass = Item[ usItemIndex ].usItemClass;
if ( usItemIndex < MAXITEMS && IsWeapon(usItemIndex) ) if ( usItemIndex < gMAXITEMS_READ && IsWeapon( usItemIndex ) )
{ {
ubWeaponClass = 0;// Madd: commented out so we can sort guns by name instead ... Weapon[ usItemIndex ].ubWeaponClass; ubWeaponClass = 0;// Madd: commented out so we can sort guns by name instead ... Weapon[ usItemIndex ].ubWeaponClass;
} }
@@ -1476,7 +1475,6 @@ UINT8 GetDealerItemCategoryNumber( UINT16 usItemIndex )
ubWeaponClass = 0; ubWeaponClass = 0;
} }
ubCategory = 0; ubCategory = 0;
// search table until end-of-list marker is encountered // search table until end-of-list marker is encountered
@@ -1502,7 +1500,7 @@ UINT8 GetDealerItemCategoryNumber( UINT16 usItemIndex )
} }
// check vs. next category in the list // check vs. next category in the list
ubCategory++; ++ubCategory;
} }
// WANNE: commented the assert out, because we always get the assertion in debug mode! // WANNE: commented the assert out, because we always get the assertion in debug mode!
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -3021,7 +3021,7 @@ void RenderSMPanel( BOOLEAN *pfDirty )
// lets rearrange our skills to a temp array // lets rearrange our skills to a temp array
// we also get the number of lines (skills) to be displayed // we also get the number of lines (skills) to be displayed
for ( UINT8 ubCnt = 1; ubCnt < NUM_SKILLTRAITS_NT; ubCnt++ ) for ( UINT8 ubCnt = 1; ubCnt < NUM_SKILLTRAITS_NT; ++ubCnt )
{ {
if ( ProfileHasSkillTrait( gpSMCurrentMerc->ubProfile, ubCnt ) == 2 ) if ( ProfileHasSkillTrait( gpSMCurrentMerc->ubProfile, ubCnt ) == 2 )
{ {
@@ -3041,7 +3041,7 @@ void RenderSMPanel( BOOLEAN *pfDirty )
} }
else else
{ {
for ( UINT8 ubCnt = 0; ubCnt < bNumSkillTraits; ubCnt++ ) for ( UINT8 ubCnt = 0; ubCnt < bNumSkillTraits; ++ubCnt )
{ {
swprintf( sTemp, L"%s\n", gzMercSkillTextNew[ ubTempSkillArray[ubCnt] ] ); swprintf( sTemp, L"%s\n", gzMercSkillTextNew[ ubTempSkillArray[ubCnt] ] );
wcscat( pStr, sTemp ); wcscat( pStr, sTemp );
+28 -62
View File
@@ -21,7 +21,7 @@
#include "GameSettings.h" #include "GameSettings.h"
#endif #endif
#define LIFE_BAR_SHADOW FROMRGB( 108, 12, 12 ) #define LIFE_BAR_SHADOW FROMRGB( 108, 12, 12 )
#define LIFE_BAR FROMRGB( 200, 0, 0 ) #define LIFE_BAR FROMRGB( 200, 0, 0 )
#define BANDAGE_BAR_SHADOW FROMRGB( 156, 60, 60 ) #define BANDAGE_BAR_SHADOW FROMRGB( 156, 60, 60 )
#define BANDAGE_BAR FROMRGB( 222, 132, 132 ) #define BANDAGE_BAR FROMRGB( 222, 132, 132 )
@@ -81,7 +81,6 @@ STR pbCarPortraitFileNames[ ]={
// load int he portraits for the car faces that will be use in mapscreen // load int he portraits for the car faces that will be use in mapscreen
BOOLEAN LoadCarPortraitValues( void ) BOOLEAN LoadCarPortraitValues( void )
{ {
INT32 iCounter = 0;
VOBJECT_DESC VObjectDesc; VOBJECT_DESC VObjectDesc;
/* /*
@@ -91,15 +90,15 @@ BOOLEAN LoadCarPortraitValues( void )
} }
*/ */
for( iCounter = 0; iCounter < NUM_PROFILES; iCounter++ ) for ( INT32 iCounter = 0; iCounter < NUM_PROFILES; ++iCounter )
{ {
// silversurfer: fixed to make sure that we only create objects for vehicles that have a face defined // silversurfer: fixed to make sure that we only create objects for vehicles that have a face defined
// otherwise CHECKF will fail and return FALSE breaking the for loop and ignoring any further vehicles // otherwise CHECKF will fail and return FALSE breaking the for loop and ignoring any further vehicles
if ( gProfilesVehicle[ iCounter ].ProfilId == iCounter && gNewVehicle[ iCounter ].szIconFace[0] != 0 ) if ( gProfilesVehicle[ iCounter ].ProfilId == iCounter && gNewVehicle[ iCounter ].szIconFace[0] != 0 )
{ {
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
strcpy( VObjectDesc.ImageFile, gNewVehicle[ iCounter ].szIconFace ); strcpy( VObjectDesc.ImageFile, gNewVehicle[ iCounter ].szIconFace );
CHECKF( AddVideoObject( &VObjectDesc, (UINT32 *)&giCarPortraits[ iCounter ] ) ); CHECKF( AddVideoObject( &VObjectDesc, (UINT32 *)&giCarPortraits[ iCounter ] ) );
} }
} }
@@ -116,8 +115,6 @@ BOOLEAN LoadCarPortraitValues( void )
// get rid of the images we loaded for the mapscreen car portraits // get rid of the images we loaded for the mapscreen car portraits
void UnLoadCarPortraits( void ) void UnLoadCarPortraits( void )
{ {
INT32 iCounter = 0;
// car protraits loaded? // car protraits loaded?
/* /*
if( giCarPortraits[ 0 ] == -1 ) if( giCarPortraits[ 0 ] == -1 )
@@ -132,15 +129,13 @@ void UnLoadCarPortraits( void )
} }
*/ */
for( iCounter = 0; iCounter < NUM_PROFILES; iCounter++ ) for ( INT32 iCounter = 0; iCounter < NUM_PROFILES; ++iCounter )
{ {
if ( gProfilesVehicle[ iCounter ].ProfilId == iCounter ) if ( gProfilesVehicle[ iCounter ].ProfilId == iCounter )
{ {
DeleteVideoObjectFromIndex( giCarPortraits[ iCounter ] ); DeleteVideoObjectFromIndex( giCarPortraits[ iCounter ] );
} }
} }
return;
} }
@@ -281,19 +276,18 @@ void DrawLifeUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 sWi
} }
UnLockVideoSurface( uiBuffer ); UnLockVideoSurface( uiBuffer );
} }
void DrawBreathUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 sWidth, INT16 sHeight, BOOLEAN fErase, UINT32 uiBuffer ) void DrawBreathUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 sWidth, INT16 sHeight, BOOLEAN fErase, UINT32 uiBuffer )
{ {
FLOAT dStart, dEnd, dPercentage; FLOAT dStart, dEnd, dPercentage;
//UINT16 usLineColor; //UINT16 usLineColor;
UINT32 uiDestPitchBYTES; UINT32 uiDestPitchBYTES;
UINT8 *pDestBuf; UINT8 *pDestBuf;
UINT16 usLineColor; UINT16 usLineColor;
HVOBJECT hHandle; HVOBJECT hHandle;
// Erase what was there // Erase what was there
if ( fErase ) if ( fErase )
@@ -307,12 +301,10 @@ void DrawBreathUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 s
return; return;
} }
// DO MAX MAX BREATH // DO MAX MAX BREATH
dPercentage = 1.; dPercentage = 1.;
dEnd = dPercentage * sHeight; dEnd = dPercentage * sHeight;
dStart = sYPos; dStart = sYPos;
// brown guy // brown guy
GetVideoObject( &hHandle, guiBrownBackgroundForTeamPanel ); GetVideoObject( &hHandle, guiBrownBackgroundForTeamPanel );
@@ -323,21 +315,18 @@ void DrawBreathUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 s
if( gusSelectedSoldier == pSoldier->ubID && gTacticalStatus.ubCurrentTeam == OUR_TEAM && OK_INTERRUPT_MERC( pSoldier ) ) if( gusSelectedSoldier == pSoldier->ubID && gTacticalStatus.ubCurrentTeam == OUR_TEAM && OK_INTERRUPT_MERC( pSoldier ) )
{ {
// gold, the second entry in the .sti // gold, the second entry in the .sti
BltVideoObject( uiBuffer , hHandle, 1, sXPos, ( INT16 )( sYPos - sHeight ), VO_BLT_SRCTRANSPARENCY, NULL ); BltVideoObject( uiBuffer , hHandle, 1, sXPos, ( INT16 )( sYPos - sHeight ), VO_BLT_SRCTRANSPARENCY, NULL );
} }
else else
{ {
// brown, first entry // brown, first entry
BltVideoObject( uiBuffer , hHandle, 0, sXPos, ( INT16 )( sYPos - sHeight ), VO_BLT_SRCTRANSPARENCY, NULL ); BltVideoObject( uiBuffer , hHandle, 0, sXPos, ( INT16 )( sYPos - sHeight ), VO_BLT_SRCTRANSPARENCY, NULL );
} }
} }
else else
{ {
// brown, first entry // brown, first entry
BltVideoObject( uiBuffer , hHandle, 0, sXPos, ( INT16 )( sYPos - sHeight ), VO_BLT_SRCTRANSPARENCY, NULL ); BltVideoObject( uiBuffer , hHandle, 0, sXPos, ( INT16 )( sYPos - sHeight ), VO_BLT_SRCTRANSPARENCY, NULL );
} }
pDestBuf = LockVideoSurface( uiBuffer, &uiDestPitchBYTES ); pDestBuf = LockVideoSurface( uiBuffer, &uiDestPitchBYTES );
@@ -360,9 +349,6 @@ void DrawBreathUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 s
RectangleDraw( TRUE, sXPos+ 2, (INT32)dStart, sXPos + 2, (INT32)( dStart - dEnd ), usLineColor, pDestBuf ); RectangleDraw( TRUE, sXPos+ 2, (INT32)dStart, sXPos + 2, (INT32)( dStart - dEnd ), usLineColor, pDestBuf );
} }
dPercentage = (FLOAT)pSoldier->bBreathMax / (FLOAT)100; dPercentage = (FLOAT)pSoldier->bBreathMax / (FLOAT)100;
dEnd = dPercentage * sHeight; dEnd = dPercentage * sHeight;
dStart = sYPos; dStart = sYPos;
@@ -376,7 +362,6 @@ void DrawBreathUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 s
usLineColor = Get16BPPColor( CURR_MAX_BREATH_SHADOW ); usLineColor = Get16BPPColor( CURR_MAX_BREATH_SHADOW );
RectangleDraw( TRUE, sXPos+ 2, (INT32)dStart, sXPos + 2, (INT32)( dStart - dEnd ), usLineColor, pDestBuf ); RectangleDraw( TRUE, sXPos+ 2, (INT32)dStart, sXPos + 2, (INT32)( dStart - dEnd ), usLineColor, pDestBuf );
// NOW DO BREATH // NOW DO BREATH
dPercentage = (FLOAT)pSoldier->bBreath / (FLOAT)100; dPercentage = (FLOAT)pSoldier->bBreath / (FLOAT)100;
dEnd = dPercentage * sHeight; dEnd = dPercentage * sHeight;
@@ -390,10 +375,8 @@ void DrawBreathUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 s
usLineColor = Get16BPPColor( CURR_BREATH_BAR_SHADOW ); usLineColor = Get16BPPColor( CURR_BREATH_BAR_SHADOW );
RectangleDraw( TRUE, sXPos+ 2, (INT32)dStart, sXPos + 2, (INT32)( dStart - dEnd ), usLineColor, pDestBuf ); RectangleDraw( TRUE, sXPos+ 2, (INT32)dStart, sXPos + 2, (INT32)( dStart - dEnd ), usLineColor, pDestBuf );
UnLockVideoSurface( uiBuffer ); UnLockVideoSurface( uiBuffer );
} }
void DrawMoraleUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 sWidth, INT16 sHeight, BOOLEAN fErase, UINT32 uiBuffer ) void DrawMoraleUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 sWidth, INT16 sHeight, BOOLEAN fErase, UINT32 uiBuffer )
@@ -420,7 +403,6 @@ void DrawMoraleUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 s
pDestBuf = LockVideoSurface( uiBuffer, &uiDestPitchBYTES ); pDestBuf = LockVideoSurface( uiBuffer, &uiDestPitchBYTES );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
// FIRST DO BREATH // FIRST DO BREATH
dPercentage = (FLOAT)pSoldier->aiData.bMorale / (FLOAT)100; dPercentage = (FLOAT)pSoldier->aiData.bMorale / (FLOAT)100;
dEnd = dPercentage * sHeight; dEnd = dPercentage * sHeight;
@@ -434,24 +416,21 @@ void DrawMoraleUIBarEx( SOLDIERTYPE *pSoldier, INT16 sXPos, INT16 sYPos, INT16 s
usLineColor = Get16BPPColor( MORALE_BAR_SHADOW ); usLineColor = Get16BPPColor( MORALE_BAR_SHADOW );
RectangleDraw( TRUE, sXPos+ 2, (INT32)dStart, sXPos + 2, (INT32)( dStart - dEnd ), usLineColor, pDestBuf ); RectangleDraw( TRUE, sXPos+ 2, (INT32)dStart, sXPos + 2, (INT32)( dStart - dEnd ), usLineColor, pDestBuf );
UnLockVideoSurface( uiBuffer ); UnLockVideoSurface( uiBuffer );
} }
void DrawItemUIBarEx( OBJECTTYPE *pObject, UINT8 ubStatus, INT16 sXPos, INT16 sYPos, INT16 sWidth, INT16 sHeight, INT16 sColor1, INT16 sColor2, BOOLEAN fErase, UINT32 uiBuffer, UINT8 iter ) void DrawItemUIBarEx( OBJECTTYPE *pObject, UINT8 ubStatus, INT16 sXPos, INT16 sYPos, INT16 sWidth, INT16 sHeight, INT16 sColor1, INT16 sColor2, BOOLEAN fErase, UINT32 uiBuffer, UINT8 iter )
{ {
FLOAT dStart, dEnd, dPercentage; FLOAT dStart, dEnd, dPercentage;
//UINT16 usLineColor; //UINT16 usLineColor;
UINT32 uiDestPitchBYTES; UINT32 uiDestPitchBYTES;
UINT8 *pDestBuf; UINT8 *pDestBuf;
UINT16 usLineColor; UINT16 usLineColor;
INT16 sValue; INT16 sValue;
if ( ubStatus >= DRAW_ITEM_STATUS_ATTACHMENT1 ) if ( ubStatus >= DRAW_ITEM_STATUS_ATTACHMENT1 )
{ {
sValue = 0; sValue = 0;
@@ -469,18 +448,15 @@ void DrawItemUIBarEx( OBJECTTYPE *pObject, UINT8 ubStatus, INT16 sXPos, INT16 sY
} }
else else
{ {
if (ubStatus < pObject->ubNumberOfObjects) { if (ubStatus < pObject->ubNumberOfObjects)
sValue = (*pObject)[ ubStatus ]->data.objectStatus; sValue = (*pObject)[ ubStatus ]->data.objectStatus;
} else
else {
sValue = 0; sValue = 0;
}
} }
// Adjust for ammo, other thingys.. // Adjust for ammo, other thingys..
if( Item[ pObject->usItem ].usItemClass & IC_AMMO ) if( Item[ pObject->usItem ].usItemClass & IC_AMMO )
{ {
sValue = sValue * 100 / Magazine[ Item[ pObject->usItem ].ubClassIndex ].ubMagSize; sValue = sValue * 100 / Magazine[ Item[ pObject->usItem ].ubClassIndex ].ubMagSize;
if ( sValue < 0 ) if ( sValue < 0 )
@@ -488,17 +464,13 @@ void DrawItemUIBarEx( OBJECTTYPE *pObject, UINT8 ubStatus, INT16 sXPos, INT16 sY
sValue = (*pObject)[iter]->data.ubShotsLeft * 100 / Magazine[ Item[ pObject->usItem ].ubClassIndex ].ubMagSize; sValue = (*pObject)[iter]->data.ubShotsLeft * 100 / Magazine[ Item[ pObject->usItem ].ubClassIndex ].ubMagSize;
DebugMsg ( TOPIC_JA2, DBG_LEVEL_3, String("Ammo status: shots left %d * 100 / Mag Size %d = value %d",(*pObject)[iter]->data.ubShotsLeft,Magazine[ Item[ pObject->usItem ].ubClassIndex ].ubMagSize,sValue )); DebugMsg ( TOPIC_JA2, DBG_LEVEL_3, String("Ammo status: shots left %d * 100 / Mag Size %d = value %d",(*pObject)[iter]->data.ubShotsLeft,Magazine[ Item[ pObject->usItem ].ubClassIndex ].ubMagSize,sValue ));
} }
if ( sValue > 100 )
{
sValue = 100;
}
if ( sValue > 100 )
sValue = 100;
} }
if( Item[ pObject->usItem ].usItemClass & IC_KEY ) if( Item[ pObject->usItem ].usItemClass & IC_KEY )
{
sValue =100; sValue =100;
}
// Flugente // Flugente
if ( ubStatus == DRAW_ITEM_TEMPERATURE ) if ( ubStatus == DRAW_ITEM_TEMPERATURE )
@@ -531,14 +503,14 @@ void DrawItemUIBarEx( OBJECTTYPE *pObject, UINT8 ubStatus, INT16 sXPos, INT16 sY
// ATE: Subtract 1 to exagerate bad status // ATE: Subtract 1 to exagerate bad status
if ( sValue < 100 && sValue > 1 ) if ( sValue < 100 && sValue > 1 )
{ {
sValue--; --sValue;
} }
// Erase what was there // Erase what was there
if ( fErase ) /*if ( fErase )
{ {
//RestoreExternBackgroundRect( sXPos, (INT16)(sYPos - sHeight), sWidth, (INT16)(sHeight + 1 ) ); RestoreExternBackgroundRect( sXPos, (INT16)(sYPos - sHeight), sWidth, (INT16)(sHeight + 1 ) );
} }*/
pDestBuf = LockVideoSurface( uiBuffer, &uiDestPitchBYTES ); pDestBuf = LockVideoSurface( uiBuffer, &uiDestPitchBYTES );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
@@ -560,14 +532,12 @@ void DrawItemUIBarEx( OBJECTTYPE *pObject, UINT8 ubStatus, INT16 sXPos, INT16 sY
RectangleDraw( TRUE, sXPos + 1, (INT32)(dStart - repairthresholdend), sXPos + 1, (INT32)( dStart - sHeight ) , usLineColor, pDestBuf ); RectangleDraw( TRUE, sXPos + 1, (INT32)(dStart - repairthresholdend), sXPos + 1, (INT32)( dStart - sHeight ) , usLineColor, pDestBuf );
} }
//usLineColor = Get16BPPColor( STATUS_BAR );
usLineColor = sColor1; usLineColor = sColor1;
RectangleDraw( TRUE, sXPos, (INT32)dStart, sXPos, (INT32)( dStart - dEnd ) , usLineColor, pDestBuf ); RectangleDraw( TRUE, sXPos, (INT32)dStart, sXPos, (INT32)( dStart - dEnd ) , usLineColor, pDestBuf );
usLineColor = sColor2; usLineColor = sColor2;
RectangleDraw( TRUE, sXPos+ 1, (INT32)dStart, sXPos + 1, (INT32)( dStart - dEnd ), usLineColor, pDestBuf ); RectangleDraw( TRUE, sXPos+ 1, (INT32)dStart, sXPos + 1, (INT32)( dStart - dEnd ), usLineColor, pDestBuf );
UnLockVideoSurface( uiBuffer ); UnLockVideoSurface( uiBuffer );
if ( uiBuffer == guiSAVEBUFFER ) if ( uiBuffer == guiSAVEBUFFER )
@@ -578,7 +548,6 @@ void DrawItemUIBarEx( OBJECTTYPE *pObject, UINT8 ubStatus, INT16 sXPos, INT16 sY
{ {
InvalidateRegion( sXPos, (INT16)(sYPos - sHeight), sXPos + sWidth, (INT16)(sYPos + 1 ) ); InvalidateRegion( sXPos, (INT16)(sYPos - sHeight), sXPos + sWidth, (INT16)(sYPos + 1 ) );
} }
} }
void RenderSoldierFace( SOLDIERTYPE *pSoldier, INT16 sFaceX, INT16 sFaceY, BOOLEAN fAutoFace ) void RenderSoldierFace( SOLDIERTYPE *pSoldier, INT16 sFaceX, INT16 sFaceY, BOOLEAN fAutoFace )
@@ -586,10 +555,8 @@ void RenderSoldierFace( SOLDIERTYPE *pSoldier, INT16 sFaceX, INT16 sFaceY, BOOLE
BOOLEAN fDoFace = FALSE; BOOLEAN fDoFace = FALSE;
// UINT8 ubVehicleType = 0; // UINT8 ubVehicleType = 0;
if ( pSoldier->bActive ) if ( pSoldier->bActive )
{ {
if( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE ) if( pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE )
{ {
// get the type of vehicle // get the type of vehicle
@@ -641,7 +608,6 @@ void RenderSoldierFace( SOLDIERTYPE *pSoldier, INT16 sFaceX, INT16 sFaceY, BOOLE
//} //}
RestoreExternBackgroundRect( sFaceX, sFaceY, FACE_WIDTH, FACE_HEIGHT ); RestoreExternBackgroundRect( sFaceX, sFaceY, FACE_WIDTH, FACE_HEIGHT );
} }
} }
// HEADROCK HAM 5: This function draws a rectangle around the item image in the zoomed inventory // HEADROCK HAM 5: This function draws a rectangle around the item image in the zoomed inventory
+19 -59
View File
@@ -305,41 +305,35 @@ extern FLOAT Distance2D( FLOAT dDeltaX, FLOAT dDeltaY );
// Flugente: toggle display of enemy role indicators // Flugente: toggle display of enemy role indicators
BOOLEAN gDisplayEnemyRoles = TRUE; BOOLEAN gDisplayEnemyRoles = TRUE;
#define SCSTI ".STI"
#define SCSTI_IMP "_IMP.STI"
BOOLEAN InitializeFaceGearGraphics() BOOLEAN InitializeFaceGearGraphics()
{ {
VOBJECT_DESC VObjectDesc; VOBJECT_DESC VObjectDesc;
char fileName[500]; char fileName[500];
for(UINT32 iCounter2 = 1; iCounter2 < MAXITEMS; iCounter2++ ) for ( UINT32 iCounter2 = 1; iCounter2 < gMAXITEMS_READ; ++iCounter2 )
{ {
VObjectDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE;
#define SCSTI ".STI"
if ( zNewFaceGear[iCounter2].Type > 0 ) if ( zNewFaceGear[iCounter2].Type > 0 )
{ {
strcpy(fileName, zNewFaceGear[iCounter2].szFile); {
strcat(fileName, SCSTI); VObjectDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE;
strcpy(VObjectDesc.ImageFile, fileName); strcpy(fileName, zNewFaceGear[iCounter2].szFile);
CHECKF(AddVideoObject(&VObjectDesc,&zNewFaceGear[iCounter2].uiIndex)); strcat(fileName, SCSTI);
strcpy(VObjectDesc.ImageFile, fileName);
CHECKF(AddVideoObject(&VObjectDesc,&zNewFaceGear[iCounter2].uiIndex));
}
}
}
for(UINT32 iCounter2 = 1; iCounter2 < MAXITEMS; iCounter2++ )
{
VObjectDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE;
#define SCSTI_IMP "_IMP.STI"
if ( zNewFaceGear[iCounter2].Type > 0 )
{
//IMP //IMP
strcpy(fileName, zNewFaceGear[iCounter2].szFile); {
strcat(fileName, SCSTI_IMP); VObjectDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE;
strcpy(VObjectDesc.ImageFile, fileName); strcpy( fileName, zNewFaceGear[iCounter2].szFile );
CHECKF(AddVideoObject(&VObjectDesc,&zNewFaceGearIMP[iCounter2].uiIndex)); strcat( fileName, SCSTI_IMP );
strcpy( VObjectDesc.ImageFile, fileName );
CHECKF( AddVideoObject( &VObjectDesc, &zNewFaceGearIMP[iCounter2].uiIndex ) );
}
} }
} }
@@ -562,40 +556,6 @@ BOOLEAN InitializeTacticalInterface( )
InitializeFaceGearGraphics(); InitializeFaceGearGraphics();
/*
for( iCounter2 = 1; iCounter2 < MAXITEMS; iCounter2++ )
{
VObjectDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE;
#define SCSTI ".STI"
if ( zNewFaceGear[iCounter2].Type > 0 )
{
strcpy(fileName, zNewFaceGear[iCounter2].szFile);
strcat(fileName, SCSTI);
strcpy(VObjectDesc.ImageFile, fileName);
CHECKF(AddVideoObject(&VObjectDesc,&zNewFaceGear[iCounter2].uiIndex));
}
}
for( iCounter2 = 1; iCounter2 < MAXITEMS; iCounter2++ )
{
VObjectDesc.fCreateFlags = VSURFACE_CREATE_FROMFILE;
#define SCSTI_IMP "_IMP.STI"
if ( zNewFaceGear[iCounter2].Type > 0 )
{
//IMP
strcpy(fileName, zNewFaceGear[iCounter2].szFile);
strcat(fileName, SCSTI_IMP);
strcpy(VObjectDesc.ImageFile, fileName);
CHECKF(AddVideoObject(&VObjectDesc,&zNewFaceGearIMP[iCounter2].uiIndex));
}
}
*/
// LOAD RADIO // LOAD RADIO
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
FilenameForBPP("INTERFACE\\radio.sti", VObjectDesc.ImageFile); FilenameForBPP("INTERFACE\\radio.sti", VObjectDesc.ImageFile);
+2 -2
View File
@@ -140,7 +140,7 @@ void InitArmyGunTypes(void)
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"InitArmyGunTypes mark weapons as not dropped"); DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"InitArmyGunTypes mark weapons as not dropped");
// set all flags that track whether this weapon type has been dropped before to FALSE // set all flags that track whether this weapon type has been dropped before to FALSE
for (ubWeapon = 0; ubWeapon < MAXITEMS; ubWeapon++) for (ubWeapon = 0; ubWeapon < MAXITEMS; ++ubWeapon)
{ {
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("InitArmyGunTypes marking weapons %d", ubWeapon)); DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("InitArmyGunTypes marking weapons %d", ubWeapon));
gStrategicStatus.fWeaponDroppedAlready[ubWeapon] = FALSE; gStrategicStatus.fWeaponDroppedAlready[ubWeapon] = FALSE;
@@ -2627,7 +2627,7 @@ else
if (gGameExternalOptions.ubEnemiesItemDrop == 0) if (gGameExternalOptions.ubEnemiesItemDrop == 0)
{ {
// if it's a weapon (monster parts included - they won't drop due to checks elsewhere!) // if it's a weapon (monster parts included - they won't drop due to checks elsewhere!)
if ((usItem > NONE) && (usItem < MAXITEMS )) // Madd -- this should be ok set to maxitems instead of max_Weapons if ( (usItem > NONE) && (usItem < gMAXITEMS_READ) ) // Madd -- this should be ok set to maxitems instead of max_Weapons
{ {
// and we're allowed to change its flags // and we're allowed to change its flags
if(! (pp->Inv[ i ].fFlags & OBJECT_NO_OVERWRITE )) if(! (pp->Inv[ i ].fFlags & OBJECT_NO_OVERWRITE ))
+3
View File
@@ -1674,6 +1674,9 @@ typedef enum
MAXITEMS = 16001 MAXITEMS = 16001
} ITEMDEFINE; } ITEMDEFINE;
// 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;
/* CHRISL: Arrays to track ic group information. These allow us to determine which LBE slots control which pockets and /* 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.*/ what LBE class the pockets are.*/
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54} // { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54}
+320 -218
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -92,7 +92,7 @@ void InitRandomMercs()
// HLT DEX AGI STR WIS MRK LDR MEC EXP MED // HLT DEX AGI STR WIS MRK LDR MEC EXP MED
//populate random gear list //populate random gear list
for (int i = 0;i < MAXITEMS; i++) for ( int i = 0; i < gMAXITEMS_READ; ++i )
{ {
INVTYPE* item = &Item[i]; INVTYPE* item = &Item[i];
+2 -3
View File
@@ -1105,7 +1105,7 @@ void HandleAllReachAbleItemsInTheSector( INT16 sSectorX, INT16 sSectorY, INT8 bS
{ {
sGridNo2 = gMapInformation.sIsolatedGridNo; sGridNo2 = gMapInformation.sIsolatedGridNo;
for( uiCounter = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; uiCounter < gTacticalStatus.Team[ gbPlayerNum ].bLastID; uiCounter++ ) for( uiCounter = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; uiCounter < gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++uiCounter )
{ {
pSoldier = MercPtrs[ uiCounter ]; pSoldier = MercPtrs[ uiCounter ];
if ( pSoldier && pSoldier->bActive && pSoldier->stats.bLife > 0 && pSoldier->sSectorX == sSectorX && pSoldier->sSectorY == sSectorY && pSoldier->bSectorZ == bSectorZ ) if ( pSoldier && pSoldier->bActive && pSoldier->stats.bLife > 0 && pSoldier->sSectorX == sSectorX && pSoldier->sSectorY == sSectorY && pSoldier->bSectorZ == bSectorZ )
@@ -1122,12 +1122,11 @@ void HandleAllReachAbleItemsInTheSector( INT16 sSectorX, INT16 sSectorY, INT8 bS
{ {
sGridNo2 = NOWHERE; sGridNo2 = NOWHERE;
} }
} }
GlobalItemsReachableTest( sGridNo, sGridNo2 ); GlobalItemsReachableTest( sGridNo, sGridNo2 );
for( uiCounter = 0; uiCounter < guiNumWorldItems; uiCounter++ ) for( uiCounter = 0; uiCounter < guiNumWorldItems; ++uiCounter )
{ {
// reset reachablity // reset reachablity
fReachable = FALSE; fReachable = FALSE;
+9 -12
View File
@@ -3457,10 +3457,11 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
{ {
if(CHEATER_CHEAT_LEVEL()) if(CHEATER_CHEAT_LEVEL())
{ {
for(UINT16 i=FIRST_WEAPON; i<MAXITEMS; i++) for ( UINT16 i = FIRST_WEAPON; i<gMAXITEMS_READ; ++i )
{ {
if(i == 1580 || Item[i].ubWeight == 0 && !(i == 257 || i == 1006 || i == 1026 || i == 1183))//dnl!!! items 257, 1006, 1026, 1183 had weight 0 which need to be changed in xml if(i == 1580 || Item[i].ubWeight == 0 && !(i == 257 || i == 1006 || i == 1026 || i == 1183))//dnl!!! items 257, 1006, 1026, 1183 had weight 0 which need to be changed in xml
continue; continue;
CreateItem(i, 100, &gTempObject); CreateItem(i, 100, &gTempObject);
AddItemToPool(usMapPos, &gTempObject, VISIBLE , 0, WORLD_ITEM_REACHABLE, 0); AddItemToPool(usMapPos, &gTempObject, VISIBLE , 0, WORLD_ITEM_REACHABLE, 0);
} }
@@ -4904,7 +4905,6 @@ void CycleSelectedMercsItem()
pSoldier->ReLoadSoldierAnimationDueToHandItemChange( usOldHandItem, pSoldier->inv[HANDPOS].usItem ); pSoldier->ReLoadSoldierAnimationDueToHandItemChange( usOldHandItem, pSoldier->inv[HANDPOS].usItem );
DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 ); DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 );
} }
} }
@@ -8039,11 +8039,8 @@ void HandleTacticalAmmoCrates( UINT8 magType )
//we have a valid, ammo item. Look through Items.xml and see if we have an ammo crate for //we have a valid, ammo item. Look through Items.xml and see if we have an ammo crate for
// this ammo type // this ammo type
for(int iLoop = 0; iLoop < MAXITEMS; iLoop++) for ( int iLoop = 0; iLoop < gMAXITEMS_READ; ++iLoop )
{ {
if (Item[iLoop].usItemClass == 0)
break; //no more valid items after this point
//if ammo crate && calibers match && Ammo Types match //if ammo crate && calibers match && Ammo Types match
if(Item[iLoop].usItemClass == IC_AMMO && Magazine[Item[iLoop].ubClassIndex].ubMagType == magType && Magazine[Item[iLoop].ubClassIndex].ubCalibre == Magazine[Item[worldItem].ubClassIndex].ubCalibre && Magazine[Item[iLoop].ubClassIndex].ubAmmoType == Magazine[Item[worldItem].ubClassIndex].ubAmmoType) if(Item[iLoop].usItemClass == IC_AMMO && Magazine[Item[iLoop].ubClassIndex].ubMagType == magType && Magazine[Item[iLoop].ubClassIndex].ubCalibre == Magazine[Item[worldItem].ubClassIndex].ubCalibre && Magazine[Item[iLoop].ubClassIndex].ubAmmoType == Magazine[Item[worldItem].ubClassIndex].ubAmmoType)
{ {
@@ -8056,7 +8053,7 @@ void HandleTacticalAmmoCrates( UINT8 magType )
if(crateItem != 0) if(crateItem != 0)
{ {
//look through world items first //look through world items first
for(unsigned int loop=0; loop < guiNumWorldItems; loop++) for(unsigned int loop=0; loop < guiNumWorldItems; ++loop)
{ {
if(gWorldItems[loop].object.usItem == crateItem) if(gWorldItems[loop].object.usItem == crateItem)
{ {
@@ -8121,7 +8118,7 @@ void HandleTacticalAmmoCrates( UINT8 magType )
//MM: loop through ammo multiple times, as boxes and crates may take a few passes to fill //MM: loop through ammo multiple times, as boxes and crates may take a few passes to fill
ammoPresent = false; ammoPresent = false;
for(unsigned int wItem = 0; wItem < guiNumWorldItems; wItem++) for(unsigned int wItem = 0; wItem < guiNumWorldItems; ++wItem)
{ {
if(Item[gWorldItems[wItem].object.usItem].usItemClass == IC_AMMO && gWorldItems[wItem].bVisible == TRUE && gWorldItems[wItem].fExists && (gWorldItems[wItem].usFlags & WORLD_ITEM_REACHABLE) && !(gWorldItems[wItem].usFlags & WORLD_ITEM_ARMED_BOMB)) if(Item[gWorldItems[wItem].object.usItem].usItemClass == IC_AMMO && gWorldItems[wItem].bVisible == TRUE && gWorldItems[wItem].fExists && (gWorldItems[wItem].usFlags & WORLD_ITEM_REACHABLE) && !(gWorldItems[wItem].usFlags & WORLD_ITEM_ARMED_BOMB))
{ {
@@ -8142,7 +8139,7 @@ void HandleTacticalAmmoCrates( UINT8 magType )
void HandleTacticalInventoryMenu( void ) void HandleTacticalInventoryMenu( void )
{ {
for( INT32 cnt = 0; cnt < TACTICAL_INVENTORY_DIALOG_NUM; cnt++) for( INT32 cnt = 0; cnt < TACTICAL_INVENTORY_DIALOG_NUM; ++cnt)
{ {
wcscpy( gzUserDefinedButton[cnt], szTacticalInventoryDialogString[cnt+1] ); wcscpy( gzUserDefinedButton[cnt], szTacticalInventoryDialogString[cnt+1] );
gzUserDefinedButtonColor[cnt] = 0; gzUserDefinedButtonColor[cnt] = 0;
@@ -8218,7 +8215,7 @@ void TacticalInventoryMessageBoxCallBack( UINT8 ubExitValue )
void HandleTacticalCoverMenu( void ) void HandleTacticalCoverMenu( void )
{ {
for( INT32 cnt = 0; cnt < TACTICAL_COVER_DIALOG_NUM; cnt++) for( INT32 cnt = 0; cnt < TACTICAL_COVER_DIALOG_NUM; ++cnt)
{ {
wcscpy( gzUserDefinedButton[cnt], szTacticalCoverDialogString[cnt+1] ); wcscpy( gzUserDefinedButton[cnt], szTacticalCoverDialogString[cnt+1] );
gzUserDefinedButtonColor[cnt] = 0; gzUserDefinedButtonColor[cnt] = 0;
@@ -8363,7 +8360,7 @@ void HandleTacticalTransformItem( void )
BOOLEAN FindTransformation( UINT16 usItem, TransformInfoStruct **pTransformation ) BOOLEAN FindTransformation( UINT16 usItem, TransformInfoStruct **pTransformation )
{ {
// find transformation // find transformation
for (INT32 x = 0; x < MAXITEMS; x++) for ( INT32 x = 0; x < gMAXITEMS_READ; ++x )
{ {
if ( Transform[x].usItem == (UINT16)-1 ) if ( Transform[x].usItem == (UINT16)-1 )
{ {
@@ -8389,7 +8386,7 @@ void HandleTacticalMoveItems( void )
if ( GetSoldier( &pSoldier, gusSelectedSoldier ) ) if ( GetSoldier( &pSoldier, gusSelectedSoldier ) )
{ {
for ( UINT32 uiLoop = 0; uiLoop < guiNumWorldItems; uiLoop++ ) //for all items in sector for ( UINT32 uiLoop = 0; uiLoop < guiNumWorldItems; ++uiLoop ) //for all items in sector
{ {
if ( (gWorldItems[ uiLoop ].bVisible == TRUE) && (gWorldItems[ uiLoop ].fExists) && (gWorldItems[ uiLoop ].usFlags & WORLD_ITEM_REACHABLE) && !(gWorldItems[ uiLoop ].usFlags & WORLD_ITEM_ARMED_BOMB) && (gWorldItems[ uiLoop ].sGridNo != pSoldier->sGridNo) )//item exists and is reachable and is not already on soldiers tile if ( (gWorldItems[ uiLoop ].bVisible == TRUE) && (gWorldItems[ uiLoop ].fExists) && (gWorldItems[ uiLoop ].usFlags & WORLD_ITEM_REACHABLE) && !(gWorldItems[ uiLoop ].usFlags & WORLD_ITEM_ARMED_BOMB) && (gWorldItems[ uiLoop ].sGridNo != pSoldier->sGridNo) )//item exists and is reachable and is not already on soldiers tile
{ {
+1 -1
View File
@@ -816,7 +816,7 @@ BOOLEAN WriteWeaponStats()
UINT32 cnt; UINT32 cnt;
FilePrintf(hFile,"<WEAPONLIST>\r\n"); FilePrintf(hFile,"<WEAPONLIST>\r\n");
for(cnt = 0;cnt < MAXITEMS;cnt++) for(cnt = 0;cnt < MAXITEMS; ++cnt)
{ {
CHAR8 * szRemainder = Weapon[cnt].szWeaponName; //the remaining string to be output (for making valid XML) CHAR8 * szRemainder = Weapon[cnt].szWeaponName; //the remaining string to be output (for making valid XML)
+3 -6
View File
@@ -1573,18 +1573,15 @@ void AIDecideRadioAnimation( SOLDIERTYPE *pSoldier )
UINT32 GetTankCannonIndex() UINT32 GetTankCannonIndex()
{ {
UINT32 tankCannonIndex = 0; for ( UINT32 i = 0; i < gMAXITEMS_READ; ++i )
for (UINT32 i = 0; i < MAXITEMS; i++)
{ {
if (Item[i].cannon) if (Item[i].cannon)
{ {
tankCannonIndex = Item[i].uiIndex; return Item[i].uiIndex;
break;
} }
} }
return tankCannonIndex; return 0;
} }
+1 -4
View File
@@ -971,15 +971,12 @@ BOOLEAN LoadShortNameItemInfo(UINT16 ubIndex, STR16 pNameString )
void LoadAllItemNames( void ) void LoadAllItemNames( void )
{ {
UINT16 usLoop; for ( UINT16 usLoop = 0; usLoop < gMAXITEMS_READ; ++usLoop )
for (usLoop = 0; usLoop < MAXITEMS; usLoop++)
{ {
LoadItemInfo( usLoop, ItemNames[usLoop], NULL ); LoadItemInfo( usLoop, ItemNames[usLoop], NULL );
// Load short item info // Load short item info
LoadShortNameItemInfo( usLoop, ShortItemNames[usLoop] ); LoadShortNameItemInfo( usLoop, ShortItemNames[usLoop] );
} }
} }
+12 -16
View File
@@ -38,6 +38,9 @@
#include "store inventory.h" #include "store inventory.h"
#endif #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 struct
{ {
PARSE_STAGE curElement; PARSE_STAGE curElement;
@@ -381,6 +384,9 @@ itemEndElementHandle(void *userData, const XML_Char *name)
InheritStanceModifiers( pData ); InheritStanceModifiers( pData );
pData->curArray[pData->curItem.uiIndex] = pData->curItem; //write the item into the table 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 ) 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->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 lpcBuffer[uiFSize] = 0; //add a null terminator
FileClose( hFile ); FileClose( hFile );
XML_SetElementHandler(parser, itemStartElementHandle, itemEndElementHandle); XML_SetElementHandler(parser, itemStartElementHandle, itemEndElementHandle);
XML_SetCharacterDataHandler(parser, itemCharacterDataHandle); XML_SetCharacterDataHandler(parser, itemCharacterDataHandle);
memset(&pData,0,sizeof(pData)); memset(&pData,0,sizeof(pData));
pData.curArray = Item; pData.curArray = Item;
@@ -1531,7 +1535,6 @@ BOOLEAN ReadInItemStats(STR fileName, BOOLEAN localizedVersion )
XML_SetUserData(parser, &pData); XML_SetUserData(parser, &pData);
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE)) if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
{ {
CHAR8 errorBuf[511]; CHAR8 errorBuf[511];
@@ -1542,21 +1545,14 @@ BOOLEAN ReadInItemStats(STR fileName, BOOLEAN localizedVersion )
MemFree(lpcBuffer); MemFree(lpcBuffer);
return FALSE; return FALSE;
} }
// item read was x -> x+1 items
++gMAXITEMS_READ;
MemFree(lpcBuffer); MemFree(lpcBuffer);
XML_ParserFree(parser); 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 ); return( TRUE );
} }
BOOLEAN WriteItemStats() BOOLEAN WriteItemStats()
@@ -1576,7 +1572,7 @@ BOOLEAN WriteItemStats()
CHAR16 strDesc[500]; CHAR16 strDesc[500];
FilePrintf(hFile,"<ITEMLIST>\r\n"); 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 ); LoadShortNameItemInfo( (UINT16)cnt, str );