mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
Merged New Inventory Project into main branch
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1871 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+46
-44
@@ -37,6 +37,8 @@
|
||||
#include "World Items.h"
|
||||
#include "text.h"
|
||||
#include "Soldier Create.h"
|
||||
#include "GameVersion.h"
|
||||
#include "Campaign Types.h"
|
||||
#endif
|
||||
|
||||
extern BOOLEAN gfOverheadMapDirty;
|
||||
@@ -475,19 +477,19 @@ void DestroySummaryWindow()
|
||||
|
||||
if( gpWorldItemsSummaryArray )
|
||||
{
|
||||
MemFree( gpWorldItemsSummaryArray );
|
||||
delete[]( gpWorldItemsSummaryArray );
|
||||
gpWorldItemsSummaryArray = NULL;
|
||||
gusWorldItemsSummaryArraySize = 0;
|
||||
}
|
||||
if( gpPEnemyItemsSummaryArray )
|
||||
{
|
||||
MemFree( gpPEnemyItemsSummaryArray );
|
||||
delete[]( gpPEnemyItemsSummaryArray );
|
||||
gpPEnemyItemsSummaryArray = NULL;
|
||||
gusPEnemyItemsSummaryArraySize = 0;
|
||||
}
|
||||
if( gpNEnemyItemsSummaryArray )
|
||||
{
|
||||
MemFree( gpNEnemyItemsSummaryArray );
|
||||
delete[]( gpNEnemyItemsSummaryArray );
|
||||
gpNEnemyItemsSummaryArray = NULL;
|
||||
gusNEnemyItemsSummaryArraySize = 0;
|
||||
}
|
||||
@@ -709,27 +711,27 @@ void RenderItemDetails()
|
||||
{
|
||||
if( index == SWITCH || index == ACTION_ITEM )
|
||||
{
|
||||
if( gpWorldItemsSummaryArray[ i ].o.usItem == index )
|
||||
if( gpWorldItemsSummaryArray[ i ].object.usItem == index )
|
||||
{
|
||||
if( gubSummaryItemMode == ITEMMODE_SCIFI && !(gpWorldItemsSummaryArray[ i ].usFlags & WORLD_ITEM_REALISTIC_ONLY) ||
|
||||
gubSummaryItemMode == ITEMMODE_REAL && !(gpWorldItemsSummaryArray[ i ].usFlags & WORLD_ITEM_SCIFI_ONLY) )
|
||||
gubSummaryItemMode == ITEMMODE_REAL && !(gpWorldItemsSummaryArray[ i ].usFlags & WORLD_ITEM_SCIFI_ONLY) )
|
||||
{
|
||||
pItem = &gpWorldItemsSummaryArray[ i ].o;
|
||||
if( !pItem->ItemData.Trigger.BombTrigger.bFrequency )
|
||||
pItem = &gpWorldItemsSummaryArray[ i ].object;
|
||||
if( !(*pItem)[0]->data.misc.bFrequency )
|
||||
bFreqIndex = 7;
|
||||
else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY )
|
||||
else if( (*pItem)[0]->data.misc.bFrequency == PANIC_FREQUENCY )
|
||||
bFreqIndex = 0;
|
||||
else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY_2 )
|
||||
else if( (*pItem)[0]->data.misc.bFrequency == PANIC_FREQUENCY_2 )
|
||||
bFreqIndex = 1;
|
||||
else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == PANIC_FREQUENCY_3 )
|
||||
else if( (*pItem)[0]->data.misc.bFrequency == PANIC_FREQUENCY_3 )
|
||||
bFreqIndex = 2;
|
||||
else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 1 )
|
||||
else if( (*pItem)[0]->data.misc.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 1 )
|
||||
bFreqIndex = 3;
|
||||
else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 2 )
|
||||
else if( (*pItem)[0]->data.misc.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 2 )
|
||||
bFreqIndex = 4;
|
||||
else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 3 )
|
||||
else if( (*pItem)[0]->data.misc.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 3 )
|
||||
bFreqIndex = 5;
|
||||
else if( pItem->ItemData.Trigger.BombTrigger.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 4 )
|
||||
else if( (*pItem)[0]->data.misc.bFrequency == FIRST_MAP_PLACED_FREQUENCY + 4 )
|
||||
bFreqIndex = 6;
|
||||
else
|
||||
continue;
|
||||
@@ -747,15 +749,14 @@ void RenderItemDetails()
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if( gpWorldItemsSummaryArray[ i ].o.usItem == index )
|
||||
if( gpWorldItemsSummaryArray[ i ].object.usItem == index )
|
||||
{
|
||||
if( gubSummaryItemMode == ITEMMODE_SCIFI && !(gpWorldItemsSummaryArray[ i ].usFlags & WORLD_ITEM_REALISTIC_ONLY) ||
|
||||
gubSummaryItemMode == ITEMMODE_REAL && !(gpWorldItemsSummaryArray[ i ].usFlags & WORLD_ITEM_SCIFI_ONLY) )
|
||||
gubSummaryItemMode == ITEMMODE_REAL && !(gpWorldItemsSummaryArray[ i ].usFlags & WORLD_ITEM_SCIFI_ONLY) )
|
||||
{
|
||||
pItem = &gpWorldItemsSummaryArray[ i ].o;
|
||||
pItem = &gpWorldItemsSummaryArray[ i ].object;
|
||||
uiExistChance += (100 - gpWorldItemsSummaryArray[ i ].ubNonExistChance) * pItem->ubNumberOfObjects;
|
||||
uiStatus += pItem->ItemData.Generic.bStatus[0];
|
||||
uiQuantity += pItem->ubNumberOfObjects;
|
||||
uiStatus += (*pItem)[0]->data.objectStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -862,7 +863,7 @@ void RenderItemDetails()
|
||||
{
|
||||
pItem = &gpPEnemyItemsSummaryArray[ i ];
|
||||
uiExistChance += 100 * pItem->ubNumberOfObjects;
|
||||
uiStatus += pItem->ItemData.Generic.bStatus[0];
|
||||
uiStatus += (*pItem)[0]->data.objectStatus;
|
||||
uiQuantity += pItem->ubNumberOfObjects;
|
||||
}
|
||||
}
|
||||
@@ -934,7 +935,7 @@ void RenderItemDetails()
|
||||
{
|
||||
pItem = &gpNEnemyItemsSummaryArray[ i ];
|
||||
uiExistChance += 100 * pItem->ubNumberOfObjects;
|
||||
uiStatus += pItem->ItemData.Generic.bStatus[0];
|
||||
uiStatus += (*pItem)[0]->data.objectStatus;
|
||||
uiQuantity += pItem->ubNumberOfObjects;
|
||||
}
|
||||
}
|
||||
@@ -2014,7 +2015,7 @@ void MapClickCallback( MOUSE_REGION *reg, INT32 reason )
|
||||
}
|
||||
if( gpWorldItemsSummaryArray )
|
||||
{
|
||||
MemFree( gpWorldItemsSummaryArray );
|
||||
delete[]( gpWorldItemsSummaryArray );
|
||||
gpWorldItemsSummaryArray = NULL;
|
||||
gusWorldItemsSummaryArraySize = 0;
|
||||
}
|
||||
@@ -2230,7 +2231,7 @@ void LoadGlobalSummary()
|
||||
STRING512 MapsDir;
|
||||
UINT32 uiNumBytesRead;
|
||||
FLOAT dMajorVersion;
|
||||
INT32 x,y;
|
||||
INT32 x,y;
|
||||
CHAR8 szFilename[40];
|
||||
CHAR8 szSector[6];
|
||||
|
||||
@@ -2758,7 +2759,7 @@ void SummaryUpdateCallback( GUI_BUTTON *btn, INT32 reason )
|
||||
// ADB: The current sector summary should be set to the array value, not the other way around.
|
||||
// Also the sector X and Y values are 1-based and the array is 0-based. So subtract 1 from X and Y
|
||||
gpCurrentSectorSummary = gpSectorSummary[ gsSelSectorX - 1][ gsSelSectorY - 1][ giCurrLevel ];
|
||||
|
||||
|
||||
gfRenderSummary = TRUE;
|
||||
|
||||
RemoveProgressBar( 0 );
|
||||
@@ -2913,6 +2914,9 @@ void ApologizeOverrideAndForceUpdateEverything()
|
||||
gusNumberOfMapsToBeForceUpdated = 0;
|
||||
}
|
||||
|
||||
//CHRISL: ADB changed the way this load file is handled
|
||||
extern int gEnemyPreservedTempFileVersion[256];
|
||||
extern int gCivPreservedTempFileVersion[256];
|
||||
void SetupItemDetailsMode( BOOLEAN fAllowRecursion )
|
||||
{
|
||||
HWFILE hfile;
|
||||
@@ -2929,19 +2933,19 @@ void SetupItemDetailsMode( BOOLEAN fAllowRecursion )
|
||||
//Clear memory for all the item summaries loaded
|
||||
if( gpWorldItemsSummaryArray )
|
||||
{
|
||||
MemFree( gpWorldItemsSummaryArray );
|
||||
delete[]( gpWorldItemsSummaryArray );
|
||||
gpWorldItemsSummaryArray = NULL;
|
||||
gusWorldItemsSummaryArraySize = 0;
|
||||
}
|
||||
if( gpPEnemyItemsSummaryArray )
|
||||
{
|
||||
MemFree( gpPEnemyItemsSummaryArray );
|
||||
delete[]( gpPEnemyItemsSummaryArray );
|
||||
gpPEnemyItemsSummaryArray = NULL;
|
||||
gusPEnemyItemsSummaryArraySize = 0;
|
||||
}
|
||||
if( gpNEnemyItemsSummaryArray )
|
||||
{
|
||||
MemFree( gpNEnemyItemsSummaryArray );
|
||||
delete[]( gpNEnemyItemsSummaryArray );
|
||||
gpNEnemyItemsSummaryArray = NULL;
|
||||
gusNEnemyItemsSummaryArraySize = 0;
|
||||
}
|
||||
@@ -2993,9 +2997,12 @@ void SetupItemDetailsMode( BOOLEAN fAllowRecursion )
|
||||
ShowButton( iSummaryButton[ SUMMARY_SCIFI ] );
|
||||
ShowButton( iSummaryButton[ SUMMARY_REAL ] );
|
||||
ShowButton( iSummaryButton[ SUMMARY_ENEMY ] );
|
||||
gpWorldItemsSummaryArray = (WORLDITEM*)MemAlloc( sizeof( WORLDITEM ) * uiNumItems );
|
||||
gpWorldItemsSummaryArray = new WORLDITEM[ uiNumItems ];
|
||||
gusWorldItemsSummaryArraySize = gpCurrentSectorSummary->usNumItems;
|
||||
FileRead( hfile, gpWorldItemsSummaryArray, sizeof( WORLDITEM ) * uiNumItems, &uiNumBytesRead );
|
||||
for (unsigned int x = 0; x < uiNumItems; ++x)
|
||||
{
|
||||
gpWorldItemsSummaryArray[x].Load(hfile);
|
||||
}
|
||||
|
||||
//NOW, do the enemy's items!
|
||||
//We need to do two passes. The first pass simply processes all the enemies and counts all the droppable items
|
||||
@@ -3020,9 +3027,7 @@ void SetupItemDetailsMode( BOOLEAN fAllowRecursion )
|
||||
}
|
||||
if( basic.fDetailedPlacement )
|
||||
{ //skip static priority placement
|
||||
// WDS - Clean up inventory handling
|
||||
FileRead( hfile, &priority, SIZEOF_SOLDIERCREATE_STRUCT, &uiNumBytesRead );
|
||||
if( uiNumBytesRead != SIZEOF_SOLDIERCREATE_STRUCT )
|
||||
if ( !priority.Load(hfile, SAVE_GAME_VERSION, false) )
|
||||
{ //Invalid situation.
|
||||
FileClose( hfile );
|
||||
return;
|
||||
@@ -3039,7 +3044,7 @@ void SetupItemDetailsMode( BOOLEAN fAllowRecursion )
|
||||
for( j = 0; j < 9; j++ )
|
||||
{
|
||||
pItem = &priority.Inv[ gbMercSlotTypes[ j ] ];
|
||||
if( pItem->usItem != NOTHING && !( pItem->fFlags & OBJECT_UNDROPPABLE ) )
|
||||
if( pItem->exists() == true && !( (*pItem).fFlags & OBJECT_UNDROPPABLE ) )
|
||||
{
|
||||
usNumItems++;
|
||||
}
|
||||
@@ -3058,13 +3063,11 @@ void SetupItemDetailsMode( BOOLEAN fAllowRecursion )
|
||||
//Pass 1 completed, so now allocate enough space to hold all the items
|
||||
if( gusPEnemyItemsSummaryArraySize )
|
||||
{
|
||||
gpPEnemyItemsSummaryArray = (OBJECTTYPE*)MemAlloc( sizeof( OBJECTTYPE ) * gusPEnemyItemsSummaryArraySize );
|
||||
memset( gpPEnemyItemsSummaryArray, 0, sizeof( OBJECTTYPE ) * gusPEnemyItemsSummaryArraySize );
|
||||
gpPEnemyItemsSummaryArray = new OBJECTTYPE[ gusPEnemyItemsSummaryArraySize ];
|
||||
}
|
||||
if( gusNEnemyItemsSummaryArraySize )
|
||||
{
|
||||
gpNEnemyItemsSummaryArray = (OBJECTTYPE*)MemAlloc( sizeof( OBJECTTYPE ) * gusNEnemyItemsSummaryArraySize );
|
||||
memset( gpNEnemyItemsSummaryArray, 0, sizeof( OBJECTTYPE ) * gusNEnemyItemsSummaryArraySize );
|
||||
gpNEnemyItemsSummaryArray = new OBJECTTYPE[ gusNEnemyItemsSummaryArraySize ];
|
||||
}
|
||||
|
||||
//PASS #2
|
||||
@@ -3085,9 +3088,7 @@ void SetupItemDetailsMode( BOOLEAN fAllowRecursion )
|
||||
}
|
||||
if( basic.fDetailedPlacement )
|
||||
{ //skip static priority placement
|
||||
// WDS - Clean up inventory handling
|
||||
FileRead( hfile, &priority, SIZEOF_SOLDIERCREATE_STRUCT, &uiNumBytesRead );
|
||||
if( uiNumBytesRead != SIZEOF_SOLDIERCREATE_STRUCT )
|
||||
if ( !priority.Load(hfile, SAVE_GAME_VERSION, false) )
|
||||
{ //Invalid situation.
|
||||
FileClose( hfile );
|
||||
return;
|
||||
@@ -3104,16 +3105,16 @@ void SetupItemDetailsMode( BOOLEAN fAllowRecursion )
|
||||
for( j = 0; j < 9; j++ )
|
||||
{
|
||||
pItem = &priority.Inv[ gbMercSlotTypes[ j ] ];
|
||||
if( pItem->usItem != NOTHING && !( pItem->fFlags & OBJECT_UNDROPPABLE ) )
|
||||
if( pItem->exists() == true && !( (*pItem).fFlags & OBJECT_UNDROPPABLE ) )
|
||||
{
|
||||
if( basic.fPriorityExistance )
|
||||
{
|
||||
memcpy( &(gpPEnemyItemsSummaryArray[ usPEnemyIndex ]), pItem, sizeof( OBJECTTYPE ) );
|
||||
gpPEnemyItemsSummaryArray[ usPEnemyIndex ] = *pItem;
|
||||
usPEnemyIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy( &(gpNEnemyItemsSummaryArray[ usNEnemyIndex ]), pItem, sizeof( OBJECTTYPE ) );
|
||||
gpNEnemyItemsSummaryArray[ usNEnemyIndex ] = *pItem;
|
||||
usNEnemyIndex++;
|
||||
}
|
||||
}
|
||||
@@ -3150,4 +3151,5 @@ void ClearSummaryInfo()
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user