diff --git a/Editor/LoadScreen.cpp b/Editor/LoadScreen.cpp index 8483b3af..6a70e1b8 100644 --- a/Editor/LoadScreen.cpp +++ b/Editor/LoadScreen.cpp @@ -87,6 +87,8 @@ INT32 iLastFileClicked; INT32 iLastClickTime; CHAR16 gzFilename[31]; +extern INT16 gsSelSectorX; +extern INT16 gsSelSectorY; FDLG_LIST *FileList = NULL; @@ -861,6 +863,8 @@ void InitErrorCatchDialog() gfErrorCatch = FALSE; } +extern BOOLEAN ReEvaluateWorld( const STR8 puiFilename ); + //Because loading and saving the map takes a few seconds, we want to post a message //on the screen and then update it which requires passing the screen back to the main loop. //When we come back for the next frame, we then actually save or load the map. So this @@ -937,7 +941,8 @@ UINT32 ProcessFileIO() RemoveMercsInSector( ); - if( !LoadWorld( ubNewFilename ) ) + //CHRISL: What happens if we EvaluateWorld at this point? + if( !ReEvaluateWorld( ubNewFilename ) || !LoadWorld( ubNewFilename ) ) { //Want to override crash, so user can do something else. EnableUndo(); SetPendingNewScreen( LOADSAVE_SCREEN ); diff --git a/Editor/Sector Summary.cpp b/Editor/Sector Summary.cpp index 4811c5f5..6d331346 100644 --- a/Editor/Sector Summary.cpp +++ b/Editor/Sector Summary.cpp @@ -2493,7 +2493,9 @@ void WriteSectorSummaryUpdate( STR8 puiFilename, UINT8 ubLevel, SUMMARYFILE *pSu fwrite( pSummaryFileInfo, 1, sizeof( SUMMARYFILE ), fp ); fclose( fp ); - gusNumEntriesWithOutdatedOrNoSummaryInfo--; + //CHRISL: + if(gusNumEntriesWithOutdatedOrNoSummaryInfo > 0) + gusNumEntriesWithOutdatedOrNoSummaryInfo--; UpdateMasterProgress(); //extract the sector information out of the filename. @@ -2576,22 +2578,27 @@ void LoadSummary( STR8 pSector, UINT8 ubLevel, FLOAT dMajorMapVersion ) if( !fp ) { gusNumEntriesWithOutdatedOrNoSummaryInfo++; + //CHRISL: Maybe take things a step further. Rather then doing a version update, why not wait to do the update until + // we actually try to access the map? After all, there is really no need to update the maps if we don't make any + // changes to them. //CHRISL: These will force an update basically every time the editor is loaded. What's the point of that? // instead, we should look at the dMajorMapVersion for this map and only load if we need to //ADB don't forget that these might need to be updated!!! - if(dMajorMapVersion < gdMajorMapVersion) +/* if(dMajorMapVersion < gdMajorMapVersion) { gusNumberOfMapsToBeForceUpdated++; gfMustForceUpdateAllMaps = TRUE; - } + }*/ return; } fread( &temp, 1, sizeof( SUMMARYFILE ), fp ); - if( temp.ubSummaryVersion < MINIMUMVERSION || dMajorMapVersion < gdMajorMapVersion ) + //CHRISL: Again, this basically forces the maps to be updated whether we actually access the map or not. Why don't we just + // update the map when the map actually needs to be loaded? +/* if( temp.ubSummaryVersion < MINIMUMVERSION || dMajorMapVersion < gdMajorMapVersion ) { gusNumberOfMapsToBeForceUpdated++; gfMustForceUpdateAllMaps = TRUE; - } + }*/ temp.dMajorMapVersion = dMajorMapVersion; UpdateSummaryInfo( &temp ); //even if the info is outdated (but existing), allocate the structure, but indicate that the info @@ -2785,6 +2792,68 @@ void ExtractTempFilename() swprintf( gszDisplayName, L"test.dat" ); } +BOOLEAN ReEvaluateWorld( const STR8 puiFilename ) +{ + STRING512 DataDir; + STRING512 MapsDir; + FLOAT dMajorVersion; + UINT8 dMinorVersion; + UINT8 ubLevel = 0; + CHAR8 name[50]; + HWFILE hfile; + UINT32 uiNumBytesRead; + + GetFileManCurrentDirectory( DataDir ); + sprintf( MapsDir, "%s\\Maps", DataDir ); + + if( gbSectorLevels[gsSelSectorX-1][gsSelSectorY-1] & GROUND_LEVEL_MASK ) + ubLevel = 0; + else if( gbSectorLevels[gsSelSectorX-1][gsSelSectorY-1] & BASEMENT1_LEVEL_MASK ) + ubLevel = 1; + else if( gbSectorLevels[gsSelSectorX-1][gsSelSectorY-1] & BASEMENT2_LEVEL_MASK ) + ubLevel = 2; + else if( gbSectorLevels[gsSelSectorX-1][gsSelSectorY-1] & BASEMENT3_LEVEL_MASK ) + ubLevel = 3; + else if( gbSectorLevels[gsSelSectorX-1][gsSelSectorY-1] & ALTERNATE_GROUND_MASK ) + ubLevel = 4; + else if( gbSectorLevels[gsSelSectorX-1][gsSelSectorY-1] & ALTERNATE_B1_MASK ) + ubLevel = 5; + else if( gbSectorLevels[gsSelSectorX-1][gsSelSectorY-1] & ALTERNATE_B2_MASK ) + ubLevel = 6; + else if( gbSectorLevels[gsSelSectorX-1][gsSelSectorY-1] & ALTERNATE_B3_MASK ) + ubLevel = 7; + + SetFileManCurrentDirectory( MapsDir ); + hfile = FileOpen( puiFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); + if( hfile ) + { + FileRead( hfile, &dMajorVersion, sizeof( FLOAT ), &uiNumBytesRead ); + FileRead( hfile, &dMinorVersion, sizeof( UINT8 ), &uiNumBytesRead ); + FileClose( hfile ); + } + SetFileManCurrentDirectory( DataDir ); + + if(dMajorVersion < gdMajorMapVersion || dMinorVersion < gubMinorMapVersion) + gfMajorUpdate = TRUE; + else + gfMajorUpdate = FALSE; + + //CHRISL: If gfMajorUpdate is ever set TRUE, the code will load a map, update it, then save the map... THEN it will + // reload the map so you can look at it. But I'm thinking the only time we should actually update the actual map + // file is when we intentionally save the file. So, for now, make sure this flag is always FALSE. + gfMajorUpdate = FALSE; + + sprintf( name, "%c%d", (gsSelSectorY-1) + 'A', gsSelSectorX ); + if( !EvaluateWorld( name, ubLevel ) ) + { + gfMajorUpdate = FALSE; + return FALSE; + } + + gfMajorUpdate = FALSE; + return TRUE; +} + void ApologizeOverrideAndForceUpdateEverything() { INT32 x, y; diff --git a/Editor/Summary Info.h b/Editor/Summary Info.h index 2895b26c..1a469470 100644 --- a/Editor/Summary Info.h +++ b/Editor/Summary Info.h @@ -103,6 +103,7 @@ extern void WriteSectorSummaryUpdate( STR8 puiFilename, UINT8 ubLevel, SUMMARYFI extern BOOLEAN gfMustForceUpdateAllMaps; extern BOOLEAN gfMajorUpdate; +BOOLEAN ReEvaluateWorld( const STR8 puiFilename ); void ApologizeOverrideAndForceUpdateEverything(); void ClearSummaryInfo(); diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index fa385bd1..37478116 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -873,7 +873,7 @@ void MapInvenPoolSlots(MOUSE_REGION * pRegion, INT32 iReason ) { if ( gpItemPointer == NULL ) { - //fShowMapInventoryPool = FALSE; + fShowMapInventoryPool = FALSE; } // else do nothing } diff --git a/Tactical/Map Information.cpp b/Tactical/Map Information.cpp index 60156a88..71706f02 100644 --- a/Tactical/Map Information.cpp +++ b/Tactical/Map Information.cpp @@ -564,6 +564,14 @@ void UpdateOldVersionMap() LightSetBaseLevel( 13 ); } } + if( gMapInformation.ubMapVersion < 26 ) + { //Allow map edgepoints to be regenerated as new system has been reenabled. + gMapInformation.ubMapVersion = 26; + } + if( gMapInformation.ubMapVersion < 27 ) + { //Allow map edgepoints to be regenerated as new system has been reenabled. + gMapInformation.ubMapVersion = 27; + } } void AutoCalculateItemNoOverwriteStatus() diff --git a/TileEngine/worlddef.cpp b/TileEngine/worlddef.cpp index d21b284e..1ec810ea 100644 --- a/TileEngine/worlddef.cpp +++ b/TileEngine/worlddef.cpp @@ -2445,6 +2445,7 @@ BOOLEAN EvaluateWorld( STR8 pSector, UINT8 ubLevel ) LOADDATA( &mapInfo, pBuffer, sizeof( MAPCREATE_STRUCT ) ); memcpy( &pSummary->MapInfo, &mapInfo, sizeof( MAPCREATE_STRUCT ) ); + pSummary->MapInfo.ubMapVersion = gubMinorMapVersion; if( uiFlags & MAP_FULLSOLDIER_SAVED ) {