Slightly improved loading times.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7394 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2014-08-17 18:55:00 +00:00
parent 5cfda83df4
commit ce3369f72e
4 changed files with 113 additions and 132 deletions
+71 -79
View File
@@ -740,7 +740,8 @@ BOOLEAN LoadArmsDealerInventoryFromSavedGameFile( HWFILE hFile )
//Free all the dealers special inventory arrays //Free all the dealers special inventory arrays
ShutDownArmsDealers(); ShutDownArmsDealers();
if (guiCurrentSaveGameVersion >= NIV_SAVEGAME_DATATYPE_CHANGE) { if (guiCurrentSaveGameVersion >= NIV_SAVEGAME_DATATYPE_CHANGE)
{
int dealers; int dealers;
if (!FileRead( hFile, &dealers, sizeof( int ), &uiNumBytesRead )) if (!FileRead( hFile, &dealers, sizeof( int ), &uiNumBytesRead ))
{ {
@@ -754,32 +755,38 @@ BOOLEAN LoadArmsDealerInventoryFromSavedGameFile( HWFILE hFile )
} }
//loop through all the dealers inventories //loop through all the dealers inventories
for( ubArmsDealer=0; ubArmsDealer<dealers; ubArmsDealer++ ) for( ubArmsDealer=0; ubArmsDealer<dealers; ++ubArmsDealer )
{ {
int size; int size;
if (!FileRead( hFile, &size, sizeof( int ), &uiNumBytesRead )) if (!FileRead( hFile, &size, sizeof( int ), &uiNumBytesRead ))
{ {
return( FALSE ); return( FALSE );
} }
gArmsDealersInventory[ubArmsDealer].resize(size); gArmsDealersInventory[ubArmsDealer].resize(size);
//loop through this dealer's individual items //loop through this dealer's individual items
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->Load(hFile) ) { {
if (! iter->Load(hFile) )
{
return FALSE; return FALSE;
} }
//CHRISL: Because of the "100rnd" bug that Tony is experiencing, lets look at each item as we create it. If the //CHRISL: Because of the "100rnd" bug that Tony is experiencing, lets look at each item as we create it. If the
// item is ammo, reset the bItemCondition value to equal the number of rounds. Hopefully this will be unneccessary // item is ammo, reset the bItemCondition value to equal the number of rounds. Hopefully this will be unneccessary
// but for the time being, it may help to alleviate the "100rnd" bug. // but for the time being, it may help to alleviate the "100rnd" bug.
if(Item[iter->object.usItem].usItemClass == IC_AMMO) if(Item[iter->object.usItem].usItemClass == IC_AMMO)
{ {
// Flugente: this condition is unnecessary, as we afterwards make sure that iter->bItemCondition = iter->object[0]->data.ubShotsLeft anyway
//This condition should catch any dealer ammo items that have both invalid bItemCondition and ubShotsLeft values. //This condition should catch any dealer ammo items that have both invalid bItemCondition and ubShotsLeft values.
// We'll only make bItemCondition valid at this point. Let the next condition correct ubShotsLeft. // We'll only make bItemCondition valid at this point. Let the next condition correct ubShotsLeft.
if(iter->bItemCondition > Magazine[Item[iter->object.usItem].ubClassIndex].ubMagSize) /*if( iter->bItemCondition > Magazine[Item[iter->object.usItem].ubClassIndex].ubMagSize)
{ {
iter->bItemCondition = Magazine[Item[iter->object.usItem].ubClassIndex].ubMagSize; iter->bItemCondition = Magazine[Item[iter->object.usItem].ubClassIndex].ubMagSize;
} }*/
//This condition should catch any dealer ammo items that have an invalid bItemCondition assuming ubShotsLeft is valid //This condition should catch any dealer ammo items that have an invalid bItemCondition assuming ubShotsLeft is valid
if(iter->bItemCondition != iter->object[0]->data.ubShotsLeft) if(iter->bItemCondition != iter->object[0]->data.ubShotsLeft)
{ {
@@ -789,7 +796,8 @@ BOOLEAN LoadArmsDealerInventoryFromSavedGameFile( HWFILE hFile )
} }
} }
} }
else { else
{
//the format has changed and needs to be updated //the format has changed and needs to be updated
OLD_ARMS_DEALER_STATUS_101 gOldArmsDealerStatus[NUM_ARMS_DEALERS]; OLD_ARMS_DEALER_STATUS_101 gOldArmsDealerStatus[NUM_ARMS_DEALERS];
//OLD_DEALER_ITEM_HEADER_101 gOldArmsDealersInventory[NUM_ARMS_DEALERS][MAXITEMS]; //OLD_DEALER_ITEM_HEADER_101 gOldArmsDealersInventory[NUM_ARMS_DEALERS][MAXITEMS];
@@ -4470,11 +4478,11 @@ BOOLEAN LoadSavedGame( int ubSavedGameID )
//If there is someone talking, stop them //If there is someone talking, stop them
StopAnyCurrentlyTalkingSpeech( ); StopAnyCurrentlyTalkingSpeech( );
ZeroAnimSurfaceCounts( ); ZeroAnimSurfaceCounts( );
ShutdownNPCQuotes(); ShutdownNPCQuotes();
SetFastForwardMode(FALSE); // FF can sometimes be active if quick-load during AI turn transition SetFastForwardMode(FALSE); // FF can sometimes be active if quick-load during AI turn transition
SetClockSpeedPercent(gGameExternalOptions.fClockSpeedPercent); // sevenfm: set default clock speed SetClockSpeedPercent(gGameExternalOptions.fClockSpeedPercent); // sevenfm: set default clock speed
@@ -5914,7 +5922,7 @@ BOOLEAN LoadSavedGame( int ubSavedGameID )
#endif #endif
} }
if( guiCurrentSaveGameVersion > ENCYCLOPEDIA_SAVEGAME_CHANGE) if( guiCurrentSaveGameVersion > ENCYCLOPEDIA_SAVEGAME_CHANGE)
{ {
uiRelEndPerc += 1; uiRelEndPerc += 1;
@@ -6275,19 +6283,18 @@ BOOLEAN LoadSavedGame( int ubSavedGameID )
} }
} }
} }
if ( guiCurrentSaveGameVersion < 68 )
{
// correct bVehicleUnderRepairID for all mercs
UINT8 ubID;
for( ubID = 0; ubID < MAXMERCS; ubID++ )
{
Menptr[ ubID ].bVehicleUnderRepairID = -1;
}
}
if ( guiCurrentSaveGameVersion < 73 ) if ( guiCurrentSaveGameVersion < 73 )
{ {
if ( guiCurrentSaveGameVersion < 68 )
{
// correct bVehicleUnderRepairID for all mercs
for ( UINT16 ubID = 0; ubID < MAXMERCS; ++ubID )
{
Menptr[ubID].bVehicleUnderRepairID = -1;
}
}
if( LaptopSaveInfo.fMercSiteHasGoneDownYet ) if( LaptopSaveInfo.fMercSiteHasGoneDownYet )
LaptopSaveInfo.fFirstVisitSinceServerWentDown = 2; LaptopSaveInfo.fFirstVisitSinceServerWentDown = 2;
} }
@@ -6575,13 +6582,13 @@ BOOLEAN LoadSoldierStructure( HWFILE hFile )
SOLDIERTYPE SavedSoldierInfo; SOLDIERTYPE SavedSoldierInfo;
//Loop through all the soldier and delete them all //Loop through all the soldier and delete them all
for( cnt=0; cnt< TOTAL_SOLDIERS; cnt++) for( cnt=0; cnt< TOTAL_SOLDIERS; ++cnt)
{ {
TacticalRemoveSoldier( cnt ); TacticalRemoveSoldier( cnt );
} }
//Loop through all the soldier structs to load //Loop through all the soldier structs to load
for( cnt=0; cnt< TOTAL_SOLDIERS; cnt++) for( cnt=0; cnt< TOTAL_SOLDIERS; ++cnt)
{ {
//update the progress bar //update the progress bar
uiPercentage = (cnt * 100) / (TOTAL_SOLDIERS-1); uiPercentage = (cnt * 100) / (TOTAL_SOLDIERS-1);
@@ -6594,14 +6601,8 @@ BOOLEAN LoadSoldierStructure( HWFILE hFile )
return(FALSE); return(FALSE);
} }
// if the soldier is not active, continue // only continue if the soldier is active
if( !ubActive ) if( ubActive )
{
continue;
}
// else if there is a soldier
else
{ {
//Read in the saved soldier info into a Temp structure //Read in the saved soldier info into a Temp structure
if ( !SavedSoldierInfo.Load(hFile) ) if ( !SavedSoldierInfo.Load(hFile) )
@@ -6626,13 +6627,7 @@ BOOLEAN LoadSoldierStructure( HWFILE hFile )
SavedSoldierInfo.pForcedShade = NULL; SavedSoldierInfo.pForcedShade = NULL;
SavedSoldierInfo.pMercPath = NULL; SavedSoldierInfo.pMercPath = NULL;
memset( SavedSoldierInfo.pEffectShades, 0, sizeof( UINT16* ) * NUM_SOLDIER_EFFECTSHADES ); memset( SavedSoldierInfo.pEffectShades, 0, sizeof( UINT16* ) * NUM_SOLDIER_EFFECTSHADES );
//if the soldier wasnt active, dont add them now. Advance to the next merc
//if( !SavedSoldierInfo.bActive )
// continue;
//Create the new merc //Create the new merc
SOLDIERCREATE_STRUCT CreateStruct; SOLDIERCREATE_STRUCT CreateStruct;
CreateStruct.bTeam = SavedSoldierInfo.bTeam; CreateStruct.bTeam = SavedSoldierInfo.bTeam;
@@ -6643,7 +6638,6 @@ BOOLEAN LoadSoldierStructure( HWFILE hFile )
if( !TacticalCreateSoldier( &CreateStruct, &ubId ) ) if( !TacticalCreateSoldier( &CreateStruct, &ubId ) )
return( FALSE ); return( FALSE );
// Load the pMercPath // Load the pMercPath
if( !LoadMercPathToSoldierStruct( hFile, ubId ) ) if( !LoadMercPathToSoldierStruct( hFile, ubId ) )
return( FALSE ); return( FALSE );
@@ -6693,53 +6687,50 @@ BOOLEAN LoadSoldierStructure( HWFILE hFile )
// ResetIMPCharactersEyesAndMouthOffsets( Menptr[ cnt ].ubProfile ); // ResetIMPCharactersEyesAndMouthOffsets( Menptr[ cnt ].ubProfile );
//} //}
//if the saved game version is before x, calculate the amount of money paid to mercs
if( guiCurrentSaveGameVersion < 83 )
{
//if the soldier is someone
if( Menptr[ cnt ].ubProfile != NO_PROFILE )
{
if( Menptr[cnt].ubWhatKindOfMercAmI == MERC_TYPE__MERC )
{
gMercProfiles[ Menptr[ cnt ].ubProfile ].uiTotalCostToDate = gMercProfiles[ Menptr[ cnt ].ubProfile ].sSalary * gMercProfiles[ Menptr[ cnt ].ubProfile ].iMercMercContractLength;
}
else
{
gMercProfiles[ Menptr[ cnt ].ubProfile ].uiTotalCostToDate = gMercProfiles[ Menptr[ cnt ].ubProfile ].sSalary * Menptr[ cnt ].iTotalContractLength;
}
}
}
#ifdef GERMAN
// Fix neutral flags
if ( guiCurrentSaveGameVersion < 94 )
{
if ( Menptr[ cnt].bTeam == OUR_TEAM && Menptr[ cnt ].aiData.bNeutral && Menptr[ cnt ].bAssignment != ASSIGNMENT_POW )
{
// turn off neutral flag
Menptr[ cnt].aiData.bNeutral = FALSE;
}
}
#endif
//#ifdef JA2UB
//if the soldier has the NON weapon version of the merc knofe or merc umbrella
//ConvertWeapons( &Menptr[ cnt ] );
//#endif
// JA2Gold: fix next-to-previous attacker value
if ( guiCurrentSaveGameVersion < 99 ) if ( guiCurrentSaveGameVersion < 99 )
{ {
Menptr[ cnt ].ubNextToPreviousAttackerID = NOBODY; //if the saved game version is before x, calculate the amount of money paid to mercs
} if( guiCurrentSaveGameVersion < 83 )
{
//if the soldier is someone
if( Menptr[ cnt ].ubProfile != NO_PROFILE )
{
if( Menptr[cnt].ubWhatKindOfMercAmI == MERC_TYPE__MERC )
{
gMercProfiles[ Menptr[ cnt ].ubProfile ].uiTotalCostToDate = gMercProfiles[ Menptr[ cnt ].ubProfile ].sSalary * gMercProfiles[ Menptr[ cnt ].ubProfile ].iMercMercContractLength;
}
else
{
gMercProfiles[ Menptr[ cnt ].ubProfile ].uiTotalCostToDate = gMercProfiles[ Menptr[ cnt ].ubProfile ].sSalary * Menptr[ cnt ].iTotalContractLength;
}
}
}
#ifdef GERMAN
// Fix neutral flags
if ( guiCurrentSaveGameVersion < 94 )
{
if ( Menptr[ cnt].bTeam == OUR_TEAM && Menptr[ cnt ].aiData.bNeutral && Menptr[ cnt ].bAssignment != ASSIGNMENT_POW )
{
// turn off neutral flag
Menptr[ cnt].aiData.bNeutral = FALSE;
}
}
#endif
//#ifdef JA2UB
//if the soldier has the NON weapon version of the merc knofe or merc umbrella
//ConvertWeapons( &Menptr[ cnt ] );
//#endif
// JA2Gold: fix next-to-previous attacker value
Menptr[cnt].ubNextToPreviousAttackerID = NOBODY;
}
} }
} }
// Fix robot // Fix robot
if ( guiCurrentSaveGameVersion <= 87 ) if ( guiCurrentSaveGameVersion <= 87 )
{ {
SOLDIERTYPE * pSoldier;
if ( gMercProfiles[ ROBOT ].inv[ VESTPOS ] == SPECTRA_VEST ) if ( gMercProfiles[ ROBOT ].inv[ VESTPOS ] == SPECTRA_VEST )
{ {
// update this // update this
@@ -6747,7 +6738,8 @@ BOOLEAN LoadSoldierStructure( HWFILE hFile )
gMercProfiles[ ROBOT ].inv[ HELMETPOS ] = SPECTRA_HELMET_18; gMercProfiles[ ROBOT ].inv[ HELMETPOS ] = SPECTRA_HELMET_18;
gMercProfiles[ ROBOT ].inv[ LEGPOS ] = SPECTRA_LEGGINGS_18; gMercProfiles[ ROBOT ].inv[ LEGPOS ] = SPECTRA_LEGGINGS_18;
gMercProfiles[ ROBOT ].bAgility = 50; gMercProfiles[ ROBOT ].bAgility = 50;
pSoldier = FindSoldierByProfileID( ROBOT, FALSE );
SOLDIERTYPE* pSoldier = FindSoldierByProfileID( ROBOT, FALSE );
if ( pSoldier ) if ( pSoldier )
{ {
pSoldier->inv[ VESTPOS ].usItem = SPECTRA_VEST_18; pSoldier->inv[ VESTPOS ].usItem = SPECTRA_VEST_18;
@@ -3499,9 +3499,8 @@ void HandleMouseInCompatableItemForMapSectorInventory( INT32 iCurrentSlot )
fMapPanelDirty = TRUE; fMapPanelDirty = TRUE;
#endif #endif
} }
fChangedInventorySlots = FALSE;
return; fChangedInventorySlots = FALSE;
} }
void ResetMapSectorInventoryPoolHighLights( void ) void ResetMapSectorInventoryPoolHighLights( void )
@@ -3509,15 +3508,13 @@ void ResetMapSectorInventoryPoolHighLights( void )
INT32 iCounter = 0; INT32 iCounter = 0;
// now reset the highlight list for the map sector inventory // now reset the highlight list for the map sector inventory
for ( iCounter = 0; iCounter < MAP_INVENTORY_POOL_SLOT_COUNT; iCounter++ ) for ( iCounter = 0; iCounter < MAP_INVENTORY_POOL_SLOT_COUNT; ++iCounter )
{ {
if ( fMapInventoryItemCompatable[ iCounter ] ) if ( fMapInventoryItemCompatable[ iCounter ] )
{ {
fMapInventoryItemCompatable[ iCounter ] = FALSE; fMapInventoryItemCompatable[ iCounter ] = FALSE;
} }
} }
return;
} }
void HandleMapSectorInventory( void ) void HandleMapSectorInventory( void )
{ {
@@ -3527,8 +3524,6 @@ void HandleMapSectorInventory( void )
{ {
HandleMouseInCompatableItemForMapSectorInventory( iCurrentlyHighLightedItem ); HandleMouseInCompatableItemForMapSectorInventory( iCurrentlyHighLightedItem );
} }
return;
} }
@@ -3548,10 +3543,6 @@ BOOLEAN IsMapScreenWorldItemVisibleInMapInventory( WORLDITEM *pWorldItem )
{ {
return ( TRUE ); return ( TRUE );
} }
else
{
return( FALSE );
}
} }
return( FALSE ); return( FALSE );
@@ -3577,8 +3568,7 @@ void CheckGridNoOfItemsInMapScreenMapInventory()
UINT32 uiNumFlagsNotSet = 0; UINT32 uiNumFlagsNotSet = 0;
INT32 iTotalNumberItems = GetTotalNumberOfItems( ); INT32 iTotalNumberItems = GetTotalNumberOfItems( );
for( iCnt=0; iCnt<iTotalNumberItems; ++iCnt)
for( iCnt=0; iCnt<iTotalNumberItems; iCnt++)
{ {
if( ( TileIsOutOfBounds(pInventoryPoolList[ iCnt ].sGridNo) )&& !( pInventoryPoolList[ iCnt ].usFlags & WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT ) ) if( ( TileIsOutOfBounds(pInventoryPoolList[ iCnt ].sGridNo) )&& !( pInventoryPoolList[ iCnt ].usFlags & WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT ) )
{ {
@@ -3586,13 +3576,13 @@ void CheckGridNoOfItemsInMapScreenMapInventory()
pInventoryPoolList[ iCnt ].usFlags |= WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT; pInventoryPoolList[ iCnt ].usFlags |= WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT;
//count the number //count the number
uiNumFlagsNotSet++; ++uiNumFlagsNotSet;
} }
} }
//loop through all the UNSEEN items //loop through all the UNSEEN items
for( iCnt=0; iCnt<(INT32)uiNumberOfUnSeenItems; iCnt++) for( iCnt=0; iCnt<(INT32)uiNumberOfUnSeenItems; ++iCnt)
{ {
if (TileIsOutOfBounds(pUnSeenItems[ iCnt ].sGridNo) && !( pUnSeenItems[ iCnt ].usFlags & WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT ) ) if (TileIsOutOfBounds(pUnSeenItems[ iCnt ].sGridNo) && !( pUnSeenItems[ iCnt ].usFlags & WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT ) )
{ {
@@ -3600,7 +3590,7 @@ void CheckGridNoOfItemsInMapScreenMapInventory()
pUnSeenItems[ iCnt ].usFlags |= WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT; pUnSeenItems[ iCnt ].usFlags |= WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT;
//count the number //count the number
uiNumFlagsNotSet++; ++uiNumFlagsNotSet;
} }
} }
+1 -1
View File
@@ -6834,7 +6834,7 @@ void ShowDiseaseOnMap()
sYCorner = (INT16)(MAP_VIEW_START_Y + (sMapY * MAP_GRID_Y)); sYCorner = (INT16)(MAP_VIEW_START_Y + (sMapY * MAP_GRID_Y));
SetFontForeground( FONT_MCOLOR_WHITE ); SetFontForeground( FONT_MCOLOR_WHITE );
swprintf( sString, L"%4.2f%%", 100 * pSectorInfo->fInfectionSeverity ); swprintf( sString, L"%4.1f%%", 100 * pSectorInfo->fInfectionSeverity );
FindFontCenterCoordinates( sXCorner, sYCorner, MAP_GRID_X, MAP_GRID_Y, sString, MapItemsFont, &usXPos, &usYPos ); FindFontCenterCoordinates( sXCorner, sYCorner, MAP_GRID_X, MAP_GRID_Y, sString, MapItemsFont, &usXPos, &usYPos );
+35 -36
View File
@@ -336,14 +336,11 @@ extern int gCivPreservedTempFileVersion[256];
BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile ) BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile )
{ {
UNDERGROUND_SECTORINFO *TempNode = gpUndergroundSectorInfoHead; UNDERGROUND_SECTORINFO *TempNode = gpUndergroundSectorInfoHead;
INT16 sMapX;
INT16 sMapY;
UINT32 uiPercentage; UINT32 uiPercentage;
UINT32 iCounter = 0; UINT32 iCounter = 0;
// HACK FOR GABBY // HACK FOR GABBY
if ( (gTacticalStatus.uiFlags & LOADING_SAVED_GAME) && guiCurrentSaveGameVersion < 81 ) if ( guiCurrentSaveGameVersion < 81 && (gTacticalStatus.uiFlags & LOADING_SAVED_GAME) )
{ {
if ( gMercProfiles[ GABBY ].bMercStatus != MERC_IS_DEAD ) if ( gMercProfiles[ GABBY ].bMercStatus != MERC_IS_DEAD )
{ {
@@ -372,9 +369,9 @@ BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile )
// //
//First look through the above ground sectors //First look through the above ground sectors
for( sMapY=1; sMapY<=16; sMapY++ ) for ( INT16 sMapY = 1; sMapY < MAP_WORLD_Y - 1; ++sMapY )
{ {
for( sMapX=1; sMapX<=16; sMapX++ ) for ( INT16 sMapX = 1; sMapX < MAP_WORLD_X - 1; ++sMapX )
{ {
if( SectorInfo[ SECTOR( sMapX,sMapY) ].uiFlags & SF_ITEM_TEMP_FILE_EXISTS ) if( SectorInfo[ SECTOR( sMapX,sMapY) ].uiFlags & SF_ITEM_TEMP_FILE_EXISTS )
{ {
@@ -384,13 +381,14 @@ BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile )
//sync up the temp file data to the sector structure data //sync up the temp file data to the sector structure data
SynchronizeItemTempFileVisbleItemsToSectorInfoVisbleItems( sMapX, sMapY, 0, TRUE ); SynchronizeItemTempFileVisbleItemsToSectorInfoVisbleItems( sMapX, sMapY, 0, TRUE );
if (guiCurrentSaveGameVersion != SAVE_GAME_VERSION) // Flugente: commented out, as the update now happens in SynchronizeItemTempFileVisbleItemsToSectorInfoVisbleItems, which will save us one loading routine per inventory
/*if (guiCurrentSaveGameVersion != SAVE_GAME_VERSION)
{ {
for (int z = 0; z < 4; ++z) for (int z = 0; z < 4; ++z)
{ {
UpdateWorldItemsTempFile(sMapX, sMapY, z); UpdateWorldItemsTempFile(sMapX, sMapY, z);
} }
} }*/
} }
if( SectorInfo[ SECTOR( sMapX,sMapY) ].uiFlags & SF_ROTTING_CORPSE_TEMP_FILE_EXISTS ) if( SectorInfo[ SECTOR( sMapX,sMapY) ].uiFlags & SF_ROTTING_CORPSE_TEMP_FILE_EXISTS )
@@ -437,7 +435,7 @@ BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile )
if ( !RetrieveTempFileFromSavedGame( hFile, SF_CIV_PRESERVED_TEMP_FILE_EXISTS, sMapX, sMapY, 0 ) ) if ( !RetrieveTempFileFromSavedGame( hFile, SF_CIV_PRESERVED_TEMP_FILE_EXISTS, sMapX, sMapY, 0 ) )
return FALSE; return FALSE;
if ( (gTacticalStatus.uiFlags & LOADING_SAVED_GAME) && guiCurrentSaveGameVersion < 78 ) if ( guiCurrentSaveGameVersion < 78 && (gTacticalStatus.uiFlags & LOADING_SAVED_GAME) )
{ {
CHAR8 pMapName[ 128 ]; CHAR8 pMapName[ 128 ];
@@ -447,7 +445,6 @@ BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile )
// turn off the flag // turn off the flag
SectorInfo[ SECTOR( sMapX,sMapY) ].uiFlags &= (~SF_CIV_PRESERVED_TEMP_FILE_EXISTS); SectorInfo[ SECTOR( sMapX,sMapY) ].uiFlags &= (~SF_CIV_PRESERVED_TEMP_FILE_EXISTS);
} }
gCivPreservedTempFileVersion[SECTOR( sMapX,sMapY)] = guiCurrentSaveGameVersion; gCivPreservedTempFileVersion[SECTOR( sMapX,sMapY)] = guiCurrentSaveGameVersion;
@@ -464,11 +461,10 @@ BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile )
if ( !RetrieveTempFileFromSavedGame( hFile, SF_LIGHTING_EFFECTS_TEMP_FILE_EXISTS, sMapX, sMapY, 0 ) ) if ( !RetrieveTempFileFromSavedGame( hFile, SF_LIGHTING_EFFECTS_TEMP_FILE_EXISTS, sMapX, sMapY, 0 ) )
return FALSE; return FALSE;
} }
//if any other file is to be saved //if any other file is to be saved
iCounter++; ++iCounter;
//update the progress bar //update the progress bar
uiPercentage = (iCounter * 100) / (255); uiPercentage = (iCounter * 100) / (255);
@@ -476,8 +472,7 @@ BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile )
RenderProgressBar( 0, uiPercentage ); RenderProgressBar( 0, uiPercentage );
} }
} }
//then look throught all the underground sectors //then look throught all the underground sectors
while( TempNode ) while( TempNode )
{ {
@@ -496,7 +491,6 @@ BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile )
return FALSE; return FALSE;
} }
if( TempNode->uiFlags & SF_MAP_MODIFICATIONS_TEMP_FILE_EXISTS ) if( TempNode->uiFlags & SF_MAP_MODIFICATIONS_TEMP_FILE_EXISTS )
{ {
if ( !RetrieveTempFileFromSavedGame( hFile, SF_MAP_MODIFICATIONS_TEMP_FILE_EXISTS, TempNode->ubSectorX, TempNode->ubSectorY, TempNode->ubSectorZ ) ) if ( !RetrieveTempFileFromSavedGame( hFile, SF_MAP_MODIFICATIONS_TEMP_FILE_EXISTS, TempNode->ubSectorX, TempNode->ubSectorY, TempNode->ubSectorZ ) )
@@ -533,7 +527,8 @@ BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile )
{ {
if ( !RetrieveTempFileFromSavedGame( hFile, SF_CIV_PRESERVED_TEMP_FILE_EXISTS, TempNode->ubSectorX, TempNode->ubSectorY, TempNode->ubSectorZ ) ) if ( !RetrieveTempFileFromSavedGame( hFile, SF_CIV_PRESERVED_TEMP_FILE_EXISTS, TempNode->ubSectorX, TempNode->ubSectorY, TempNode->ubSectorZ ) )
return FALSE; return FALSE;
if ( (gTacticalStatus.uiFlags & LOADING_SAVED_GAME) && guiCurrentSaveGameVersion < 78 )
if ( guiCurrentSaveGameVersion < 78 && (gTacticalStatus.uiFlags & LOADING_SAVED_GAME) )
{ {
CHAR8 pMapName[ 128 ]; CHAR8 pMapName[ 128 ];
@@ -543,9 +538,7 @@ BOOLEAN LoadMapTempFilesFromSavedGameFile( HWFILE hFile )
// turn off the flag // turn off the flag
TempNode->uiFlags &= (~SF_CIV_PRESERVED_TEMP_FILE_EXISTS); TempNode->uiFlags &= (~SF_CIV_PRESERVED_TEMP_FILE_EXISTS);
} }
} }
if( TempNode->uiFlags & SF_SMOKE_EFFECTS_TEMP_FILE_EXISTS ) if( TempNode->uiFlags & SF_SMOKE_EFFECTS_TEMP_FILE_EXISTS )
@@ -3312,17 +3305,13 @@ UINT32 GetNumberOfVisibleWorldItemsFromSectorStructureForSector( INT16 sMapX, IN
void SetNumberOfVisibleWorldItemsInSectorStructureForSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ, UINT32 uiNumberOfItems ) void SetNumberOfVisibleWorldItemsInSectorStructureForSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ, UINT32 uiNumberOfItems )
{ {
UNDERGROUND_SECTORINFO *pSector=NULL;
//if the sector is above ground //if the sector is above ground
if( bMapZ == 0 ) if( bMapZ == 0 )
{ {
SectorInfo[ SECTOR( sMapX, sMapY ) ].uiNumberOfWorldItemsInTempFileThatCanBeSeenByPlayer = uiNumberOfItems;
}
else else
{ {
//find the underground sector //find the underground sector
pSector = FindUnderGroundSector( sMapX, sMapY, bMapZ ); UNDERGROUND_SECTORINFO* pSector = FindUnderGroundSector( sMapX, sMapY, bMapZ );
if( pSector != NULL ) if( pSector != NULL )
{ {
//get the number of items //get the number of items
@@ -3365,20 +3354,30 @@ void SynchronizeItemTempFileVisbleItemsToSectorInfoVisbleItems( INT16 sMapX, INT
// now load into mem // now load into mem
LoadWorldItemsFromTempItemFile( sMapX, sMapY, bMapZ, pTotalSectorList ); LoadWorldItemsFromTempItemFile( sMapX, sMapY, bMapZ, pTotalSectorList );
}
// now run through list and // now run through list and
//for( iCounter = 0; ( UINT32 )( iCounter )< uiTotalNumberOfRealItems; iCounter++ ) //for( iCounter = 0; ( UINT32 )( iCounter )< uiTotalNumberOfRealItems; iCounter++ )
for( iCounter = 0; iCounter < uiTotalNumberOfItems; iCounter++ ) for ( iCounter = 0; iCounter < uiTotalNumberOfItems; ++iCounter )
{
// if visible to player, then state fact
if( IsMapScreenWorldItemVisibleInMapInventory( &pTotalSectorList[ iCounter ] ) )
{ {
uiItemCount += pTotalSectorList[ iCounter ].object.ubNumberOfObjects; // if visible to player, then state fact
if ( IsMapScreenWorldItemVisibleInMapInventory( &pTotalSectorList[iCounter] ) )
{
uiItemCount += pTotalSectorList[iCounter].object.ubNumberOfObjects;
}
}
// Flugente: if we load a game, we would save the data again in UpdateWorldItemsTempFile.
// But that function simply loads the data again and writes it. If we do the saving here, we can at least save the entire 'load it again' part
if ( fLoadingGame && guiCurrentSaveGameVersion != SAVE_GAME_VERSION )
{
int backup = guiCurrentSaveGameVersion;
guiCurrentSaveGameVersion = SAVE_GAME_VERSION;
SaveWorldItemsToTempItemFile( sMapX, sMapY, bMapZ, uiTotalNumberOfItems, pTotalSectorList );
guiCurrentSaveGameVersion = backup;
} }
} }
#ifdef JA2BETAVERSION #ifdef JA2BETAVERSION
if( fLoadingGame && guiCurrentSaveGameVersion >= 86 ) if( fLoadingGame && guiCurrentSaveGameVersion >= 86 )
{ {
UINT32 uiReported = GetNumberOfVisibleWorldItemsFromSectorStructureForSector( sMapX, sMapY, bMapZ ); UINT32 uiReported = GetNumberOfVisibleWorldItemsFromSectorStructureForSector( sMapX, sMapY, bMapZ );
@@ -3386,7 +3385,7 @@ void SynchronizeItemTempFileVisbleItemsToSectorInfoVisbleItems( INT16 sMapX, INT
if( uiItemCount != uiReported ) if( uiItemCount != uiReported )
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"SynchronizeItemTempFile() Error! Reported %d, should be %d", uiReported, uiItemCount ); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"SynchronizeItemTempFile() Error! Reported %d, should be %d", uiReported, uiItemCount );
} }
#endif #endif
//record the number of items //record the number of items
SetNumberOfVisibleWorldItemsInSectorStructureForSector( sMapX, sMapY, bMapZ, uiItemCount ); SetNumberOfVisibleWorldItemsInSectorStructureForSector( sMapX, sMapY, bMapZ, uiItemCount );