mirror of
https://github.com/1dot13/source.git
synced 2026-08-05 14:00:23 +02:00
- Improved tactical save code (by tazpn)
o After some investigation I determined that the one of the files in the temp folder was being written to repeatedly and on top of that opening and closing over a 1500 times o Instead of writing to in memory arrays before writing to disk its opening many temporary files and appending data to them repeatedly o I rewrote part of the code so that it only opened the files once and wrote to them and would create them fresh when it did. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4665 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -921,6 +921,7 @@ BOOLEAN AddItemsToUnLoadedSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ, INT32 sG
|
||||
}
|
||||
|
||||
extern BOOLEAN gfInMeanwhile;
|
||||
extern BOOLEAN EnableModifiedFileSetCache(BOOLEAN value);
|
||||
|
||||
BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
{
|
||||
@@ -942,6 +943,7 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
BOOLEAN cacheResetValue = EnableModifiedFileSetCache(TRUE);
|
||||
|
||||
//Save the Blood, smell and the revealed status for map elements
|
||||
SaveBloodSmellAndRevealedStatesFromMapToTempFile();
|
||||
@@ -949,12 +951,11 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
// handle all reachable before save
|
||||
HandleAllReachAbleItemsInTheSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ );
|
||||
|
||||
|
||||
|
||||
//Save the Items to the the file
|
||||
if( !SaveWorldItemsToTempItemFile( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, guiNumWorldItems, gWorldItems ) )
|
||||
{
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("SaveCurrentSectorsInformationToTempItemFile: failed in SaveWorldItemsToTempItemFile()" ) );
|
||||
EnableModifiedFileSetCache(cacheResetValue);
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -962,6 +963,7 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
if( !SaveRottingCorpsesToTempCorpseFile( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) )
|
||||
{
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("SaveCurrentSectorsInformationToTempItemFile: failed in SaveRottingCorpsesToTempCorpseFile()" ) );
|
||||
EnableModifiedFileSetCache(cacheResetValue);
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -969,6 +971,7 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
if( !SaveDoorTableToDoorTableTempFile( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) )
|
||||
{
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("SaveCurrentSectorsInformationToTempItemFile: failed in SaveDoorTableToDoorTableTempFile()" ) );
|
||||
EnableModifiedFileSetCache(cacheResetValue);
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -976,6 +979,7 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
if( !SaveRevealedStatusArrayToRevealedTempFile( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) )
|
||||
{
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("SaveCurrentSectorsInformationToTempItemFile: failed in SaveRevealedStatusArrayToRevealedTempFile()" ) );
|
||||
EnableModifiedFileSetCache(cacheResetValue);
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -983,6 +987,7 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
if( !SaveDoorStatusArrayToDoorStatusTempFile( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) )
|
||||
{
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("SaveCurrentSectorsInformationToTempItemFile: failed in SaveDoorStatusArrayToDoorStatusTempFile()" ) );
|
||||
EnableModifiedFileSetCache(cacheResetValue);
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -990,6 +995,7 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
if( !NewWayOfSavingEnemyAndCivliansToTempFile( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, TRUE, FALSE ) )
|
||||
{
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("SaveCurrentSectorsInformationToTempItemFile: failed in NewWayOfSavingEnemyAndCivliansToTempFile( Enemy, Creature Team )" ) );
|
||||
EnableModifiedFileSetCache(cacheResetValue);
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -997,6 +1003,7 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
if( !NewWayOfSavingEnemyAndCivliansToTempFile( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, FALSE, FALSE ) )
|
||||
{
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("SaveCurrentSectorsInformationToTempItemFile: failed in NewWayOfSavingEnemyAndCivliansToTempFile( Civ Team )" ) );
|
||||
EnableModifiedFileSetCache(cacheResetValue);
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -1004,6 +1011,7 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
if( !SaveSmokeEffectsToMapTempFile( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) )
|
||||
{
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("SaveCurrentSectorsInformationToTempItemFile: failed in SaveSmokeEffectsToMapTempFile" ) );
|
||||
EnableModifiedFileSetCache(cacheResetValue);
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -1011,6 +1019,7 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
if( !SaveLightEffectsToMapTempFile( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ) )
|
||||
{
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("SaveCurrentSectorsInformationToTempItemFile: failed in SaveLightEffectsToMapTempFile" ) );
|
||||
EnableModifiedFileSetCache(cacheResetValue);
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
@@ -1026,6 +1035,7 @@ BOOLEAN SaveCurrentSectorsInformationToTempItemFile( )
|
||||
//Save the time the player was last in the sector
|
||||
SetLastTimePlayerWasInSector();
|
||||
|
||||
EnableModifiedFileSetCache(cacheResetValue);
|
||||
|
||||
if( fShouldBeInMeanwhile )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user