1 #include "FileMan.h"
2 #include "Types.h"
3 #include "Map_Information.h"
4 #include "Soldier_Init_List.h"
5 #include "Random.h"
6 #include "WorldDef.h"
7 #include "RenderWorld.h"
8 #include "EditorMercs.h"
9 #include "Exit_Grids.h"
10 #include "Isometric_Utils.h"
11 #include "Animation_Data.h"
12 #include "Road_Smoothing.h"
13 #include "Weapons.h"
14 #include "Environment.h"
15 #include "Lighting.h"
16 #include "Animated_ProgressBar.h"
17 #include "Debug.h"
18 #include "World_Items.h"
19 
20 
21 BOOLEAN gfWorldLoaded;
22 
23 struct MAPCREATE_STRUCT;
24 MAPCREATE_STRUCT gMapInformation;
25 
26 //Current minor map version updater.
27 #define MINOR_MAP_VERSION 25
28 UINT8 gubMinorMapVersion = MINOR_MAP_VERSION;
29 
30 // MINOR_MAP_VERSION Log -- Created by Kris Morness, November 14, 1997
31 // Version 0 -- Kris -- obsolete November 14, 1997
32 //   The newly created soldier information had a couple bugs regarding initialization
33 //   Bug 1)  Soldier placements without detailed slots weren't initialized.
34 //   Bug 2)  The attitude variable was accidentally being generated like attributes
35 //           which usually put it completely out of range.
36 // Version 1 -- Kris -- obsolete January 7, 1998
37 //   Bug 3)  New changes to the wall decals, made the currently existing ones in the world
38 //           unpredictable, and are automatically removed, so new ones can be used.
39 // Version 2 -- Kris -- obsolete February 3, 1998
40 //   Bug 4)  Enemy mercs now have a color code assignment which defaults to army.
41 // Version 3 -- Kris -- obsolete February 9, 1998
42 //   Bug 5)  Move entry points down if they are too high.
43 // Version 4 -- Kris -- obsolete February 25, 1998
44 //   Bug 6)  Change all doors to FIRSTDOOR
45 // Version 5 -- Kris -- obsolete March 4, 1998
46 //   Bug 7)  Remove all exit grids (the format has changed)
47 // Version 6 -- Kris -- obsolete March 9, 1998
48 //   Bug 8)  Change droppable status of merc items so that they are all undroppable.
49 // Version 7 -- Kris -- obsolete April 14, 1998
50 //   Bug 9)  Priority placements have been dropped in favor of splitting it into two categories.
51 //           The first is Detailed placements, and the second is priority existance.  So, all
52 //           current detailed placements will also have priority existance.
53 // Version 8 -- Kris -- obsolete April 16, 1998
54 //   MAJOR CONFLICT RESULTING IN A MAJOR VERSION UPDATE 2.00!
55 //   Bug 10) Padding on detailed placements is uninitialized.  Clear it.
56 // Version 9 -- Kris -- obsolete April 26, 1998
57 //   This version requires no auto updating, but external code has adjusted the size of the mapedgepoint
58 //   arraysize from UINT8 to UINT16.  See Map Edgepoints.c.
59 //   Bug 11) Convert all wheelchaired placement bodytypes to cows.  Result of change in the animation database.
60 // Version 11 -- Kris -- obsolete May 2, 1998
61 //   Added new center entry point.  Need to initialize the original padding to -1.
62 
63 
64 //EntryPoints can't be placed on the top two gridnos in a map.  So all we do in this case
65 //is return the closest gridno.  Returns TRUE if the mapindex changes.
ValidateEntryPointGridNo(INT16 * sGridNo)66 BOOLEAN ValidateEntryPointGridNo( INT16 *sGridNo )
67 {
68 	INT16 sWorldX, sWorldY;
69 	INT16 sTopLimit, sBottomLimit;
70 
71 	if( *sGridNo < 0 )
72 		return FALSE; //entry point is non-existant
73 
74 	sTopLimit = 80;
75 	sBottomLimit = gsBottomY - gsTopY - 40;
76 
77 	//Get screen coordinates for current gridno
78 	GetAbsoluteScreenXYFromMapPos(*sGridNo, &sWorldX, &sWorldY);
79 
80 	if( sWorldY < sTopLimit )
81 	{
82 		*sGridNo = GetMapPosFromAbsoluteScreenXY(sWorldX, sTopLimit);
83 	}
84 	else if( sWorldY > sBottomLimit )
85 	{
86 		*sGridNo = GetMapPosFromAbsoluteScreenXY(sWorldX, sBottomLimit);
87 	}
88 	else
89 	{
90 		return FALSE; //already valid
91 	}
92 
93 	return TRUE; //modified
94 }
95 
96 
SaveMapInformation(HWFILE fp)97 void SaveMapInformation( HWFILE fp )
98 {
99 	gMapInformation.ubMapVersion = MINOR_MAP_VERSION;
100 	FileWrite(fp, &gMapInformation, sizeof(MAPCREATE_STRUCT));
101 }
102 
103 
LoadMapInformation(HWFILE const f)104 void LoadMapInformation(HWFILE const f)
105 {
106 	FileRead(f, &gMapInformation, sizeof(gMapInformation));
107 
108 	// ATE: OK, do some handling here for basement level scroll restrictions
109 	// Calcuate world scrolling restrictions
110 	InitRenderParams( gMapInformation.ubRestrictedScrollID );
111 }
112 
113 
114 //This will automatically update obsolete map versions to the new ones.  This will even
115 //work in the game itself, but would require conversion to happen every time.  This is completely
116 //transparent to the rest of the game, but in the editor, obsolete versions will be updated upon
117 //loading and won't be permanently updated until the map is saved, regardless of changes.
UpdateOldVersionMap(void)118 static void UpdateOldVersionMap(void)
119 {
120 #if 0
121 	//This code is no longer needed since the major version update from 1.0 to 4.0
122 	//However, I am keeping it in for reference.
123 	INT32 i;
124 	LEVELNODE *pStruct;
125 	//VERSION 0 -- obsolete November 14, 1997
126 	if( gMapInformation.ubMapVersion == 0 )
127 	{
128 		//Soldier information contained two fixable bugs.
129 		gMapInformation.ubMapVersion++;
130 		FOR_EACH_SOLDIERINITNODE(curr)
131 		{
132 			//Bug #01)  Nodes without detailed slots weren't initialized.
133 			if( !curr->pBasicPlacement->fDetailedPlacement )
134 				curr->pDetailedPlacement = NULL;
135 			//Bug #02)  The attitude variable was accidentally being generated like attributes
136 			//					which put it completely out of range.
137 			if( curr->pBasicPlacement->bAttitude > 7 )
138 				curr->pBasicPlacement->bAttitude = (INT8)Random(8);
139 		}
140 	}
141 	//VERSION 1 -- obsolete January 7, 1998
142 	if( gMapInformation.ubMapVersion == 1 )
143 	{
144 		gMapInformation.ubMapVersion++;
145 		//Bug #03)  Removing all wall decals from map, because of new changes to the slots
146 		//					as well as certain decals found commonly in illegal places.
147 		for( i = 0; i < WORLD_MAX; i++ )
148 		{
149 			RemoveAllStructsOfTypeRange( i, FIRSTWALLDECAL, LASTWALLDECAL );
150 			RemoveAllStructsOfTypeRange( i, FIFTHWALLDECAL, SIXTHWALLDECAL );
151 		}
152 	}
153 	//VERSION 2 -- obsolete February 3, 1998
154 	if( gMapInformation.ubMapVersion == 2 )
155 	{
156 		gMapInformation.ubMapVersion++;
157 		CFOR_EACH_SOLDIERINITNODE(curr)
158 		{
159 			//Bug #04)  Assign enemy mercs default army color code if applicable
160 			if( curr->pBasicPlacement->bTeam == ENEMY_TEAM && !curr->pBasicPlacement->ubSoldierClass )
161 			{
162 				if( !curr->pDetailedPlacement )
163 				{
164 					curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_ARMY;
165 				}
166 				else if( curr->pDetailedPlacement && curr->pDetailedPlacement->ubProfile == NO_PROFILE )
167 				{
168 					curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_ARMY;
169 					curr->pDetailedPlacement->ubSoldierClass = SOLDIER_CLASS_ARMY;
170 				}
171 			}
172 		}
173 	}
174 	//VERSION 3 -- obsolete February 9, 1998
175 	if( gMapInformation.ubMapVersion == 3 )
176 	{
177 		gMapInformation.ubMapVersion++;
178 		//Bug #05)  Move entry points down if necessary.
179 		ValidateEntryPointGridNo( &gMapInformation.sNorthGridNo );
180 		ValidateEntryPointGridNo( &gMapInformation.sEastGridNo );
181 		ValidateEntryPointGridNo( &gMapInformation.sSouthGridNo );
182 		ValidateEntryPointGridNo( &gMapInformation.sWestGridNo );
183 	}
184 	//VERSION 4 -- obsolete February 25, 1998
185 	if( gMapInformation.ubMapVersion == 4 )
186 	{
187 		gMapInformation.ubMapVersion++;
188 		//6)  Change all doors to FIRSTDOOR
189 		for( i = 0; i < WORLD_MAX; i++ )
190 		{
191 			//NOTE:  Here are the index values for the various doors
192 			//DOOR   OPEN   CLOSED
193 			//FIRST   916      912
194 			//SECOND  936      932
195 			//THIRD   956      952
196 			//FOURTH  976      972
197 			pStruct = gpWorldLevelData[ i ].pStructHead;
198 			while( pStruct )
199 			{
200 				//outside topleft
201 				if( pStruct->usIndex == 932 || pStruct->usIndex == 952 || pStruct->usIndex == 972 )
202 				{
203 					ReplaceStructIndex( i, pStruct->usIndex, 912 );
204 					break;
205 				}
206 				else if( pStruct->usIndex == 936 || pStruct->usIndex == 956 || pStruct->usIndex == 976 )
207 				{
208 					ReplaceStructIndex( i, pStruct->usIndex, 916 );
209 					break;
210 				}
211 				//outside topright
212 				else if( pStruct->usIndex == 927 || pStruct->usIndex == 947 || pStruct->usIndex == 967 )
213 				{
214 					ReplaceStructIndex( i, pStruct->usIndex, 907 );
215 					break;
216 				}
217 				else if( pStruct->usIndex == 931 || pStruct->usIndex == 951 || pStruct->usIndex == 971 )
218 				{
219 					ReplaceStructIndex( i, pStruct->usIndex, 911 );
220 					break;
221 				}
222 				//inside topleft
223 				else if( pStruct->usIndex == 942 || pStruct->usIndex == 962 || pStruct->usIndex == 982 )
224 				{
225 					ReplaceStructIndex( i, pStruct->usIndex, 922 );
226 					break;
227 				}
228 				else if( pStruct->usIndex == 946 || pStruct->usIndex == 966 || pStruct->usIndex == 986 )
229 				{
230 					ReplaceStructIndex( i, pStruct->usIndex, 926 );
231 					break;
232 				}
233 				//inside topright
234 				else if( pStruct->usIndex == 937 || pStruct->usIndex == 957 || pStruct->usIndex == 977 )
235 				{
236 					ReplaceStructIndex( i, pStruct->usIndex, 917 );
237 					break;
238 				}
239 				else if( pStruct->usIndex == 941 || pStruct->usIndex == 961 || pStruct->usIndex == 981 )
240 				{
241 					ReplaceStructIndex( i, pStruct->usIndex, 921 );
242 					break;
243 				}
244 				pStruct = pStruct->pNext;
245 			}
246 		}
247 	}
248 	//VERSION 5 -- obsolete March 4, 1998
249 	if( gMapInformation.ubMapVersion == 5 )
250 	{
251 		gMapInformation.ubMapVersion++;
252 		//Bug 7)  Remove all exit grids (the format has changed)
253 		for( i = 0; i < WORLD_MAX; i++ )
254 			RemoveExitGridFromWorld( i );
255 	}
256 	//VERSION 6 -- obsolete March 9, 1998
257 	if( gMapInformation.ubMapVersion == 6 )
258 	{ //Bug 8)  Change droppable status of merc items so that they are all undroppable.
259 		gMapInformation.ubMapVersion++;
260 		CFOR_EACH_SOLDIERINITNODE(curr)
261 		{
262 			//Bug #04)  Assign enemy mercs default army color code if applicable
263 			if( curr->pDetailedPlacement )
264 			{
265 				for( i = 0; i < NUM_INV_SLOTS; i++ )
266 				{ //make all items undroppable, even if it is empty.  This will allow for
267 					//random item generation, while empty, droppable slots are locked as empty
268 					//during random item generation.
269 					curr->pDetailedPlacement->Inv[ i ].fFlags |= OBJECT_UNDROPPABLE;
270 				}
271 			}
272 		}
273 	}
274 	//VERSION 7 -- obsolete April 14, 1998
275 	if( gMapInformation.ubMapVersion == 7 )
276 	{
277 		gMapInformation.ubMapVersion++;
278 		//Bug 9)  Priority placements have been dropped in favor of splitting it into two categories.
279 		//				The first is Detailed placements, and the second is priority existance.  So, all
280 		//				current detailed placements will also have priority existance.
281 		CFOR_EACH_SOLDIERINITNODE(curr)
282 		{
283 			if( curr->pDetailedPlacement )
284 			{
285 				curr->pBasicPlacement->fPriorityExistance = TRUE;
286 			}
287 		}
288 	}
289 
290 	if( gMapInformation.ubMapVersion == 14 )
291 	{ //Toast all of the ambiguous road pieces that ended up wrapping the byte.
292 		LEVELNODE *pStruct, *pStruct2;
293 		INT32 i;
294 		for( i = 0; i < WORLD_MAX; i++ )
295 		{
296 			pStruct = gpWorldLevelData[ i ].pObjectHead;
297 			if( pStruct && pStruct->usIndex == 1078 && i < WORLD_MAX-2 && i >= 320 )
298 			{ //This is the only detectable road piece that we can repair.
299 				pStruct2 = gpWorldLevelData[ i+1 ].pObjectHead;
300 				if( pStruct2 && pStruct2->usIndex == 1081 )
301 				{
302 					RemoveObject( i, pStruct->usIndex );
303 					RemoveObject( i+1, pStruct->usIndex+1 );
304 					RemoveObject( i+2, pStruct->usIndex+2 );
305 					RemoveObject( i-160, pStruct->usIndex-160 );
306 					RemoveObject( i-159, pStruct->usIndex-159 );
307 					RemoveObject( i-158, pStruct->usIndex-158 );
308 					RemoveObject( i-320, pStruct->usIndex-320 );
309 					RemoveObject( i-319, pStruct->usIndex-319 );
310 					RemoveObject( i-318, pStruct->usIndex-318 );
311 					AddObjectToTail( i, 1334 );
312 					AddObjectToTail( i-160, 1335 );
313 					AddObjectToTail( i-320, 1336 );
314 					AddObjectToTail( i+1, 1337 );
315 					AddObjectToTail( i-159, 1338 );
316 					AddObjectToTail( i-319, 1339 );
317 					AddObjectToTail( i+2, 1340 );
318 					AddObjectToTail( i-158, 1341 );
319 					AddObjectToTail( i-318, 1342 );
320 				}
321 			}
322 			else if( pStruct && pStruct->usIndex >= 1079 && pStruct->usIndex < 1115 )
323 			{
324 				RemoveObject( i, pStruct->usIndex );
325 			}
326 		}
327 	}
328 
329 	if( gMapInformation.ubMapVersion <= 7 )
330 	{
331 		if( gfEditMode )
332 		{
333 			SLOGE("Currently loaded map is corrupt! Allowing the map to load anyway!" );
334 		}
335 		else
336 		{
337 			if( gbWorldSectorZ )
338 			{
339 				SLOGA("Currently loaded map (%c%d_b%d.dat) is invalid -- less than the minimum supported version.", gWorldSectorY + 'A' - 1, gWorldSectorX, gbWorldSectorZ);
340 			}
341 			else if( !gbWorldSectorZ )
342 			{
343 				SLOGA("Currently loaded map (%c%d.dat) is invalid -- less than the minimum supported version.", gWorldSectorY + 'A' - 1, gWorldSectorX);
344 			}
345 		}
346 	}
347 	//VERSION 8 -- obsolete April 18, 1998
348 	if( gMapInformation.ubMapVersion == 8 )
349 	{
350 		gMapInformation.ubMapVersion++;
351 		//Bug 10) Padding on detailed placements is uninitialized.  Clear it.
352 		CFOR_EACH_SOLDIERINITNODE(curr)
353 		{
354 			if (!curr->pDetailedPlacement) continue;
355 			SOLDIERCREATE_STRUCT& dp = *curr->pDetailedPlacement;
356 			dp.ubScheduleID       = 0;
357 			dp.fUseGivenVehicle   = 0;
358 			dp.bUseGivenVehicleID = 0;
359 			dp.fHasKeys           = 0;
360 		}
361 	}
362 	//Version 9 -- Kris -- obsolete April 27, 1998
363 	if( gMapInformation.ubMapVersion == 9 )
364 	{
365 		gMapInformation.ubMapVersion++;
366 		CFOR_EACH_SOLDIERINITNODE(curr)
367 		{
368 			//Bug 11) Convert all wheelchaired placement bodytypes to cows.  Result of change in the animation database.
369 			if( curr->pDetailedPlacement && curr->pDetailedPlacement->bBodyType == CRIPPLECIV )
370 			{
371 				curr->pDetailedPlacement->bBodyType = COW;
372 				curr->pBasicPlacement->bBodyType = COW;
373 			}
374 		}
375 	}
376 	if( gMapInformation.ubMapVersion < 12 )
377 	{
378 		gMapInformation.ubMapVersion = 12;
379 		gMapInformation.sCenterGridNo = -1;
380 	}
381 	if( gMapInformation.ubMapVersion < 13 )
382 	{	//replace all merc ammo inventory slots status value with the max ammo that the clip can hold.
383 		INT32 i, cnt;
384 		OBJECTTYPE *pItem;
385 		gMapInformation.ubMapVersion++;
386 		CFOR_EACH_SOLDIERINITNODE(curr)
387 		{
388 			if( curr->pDetailedPlacement )
389 			{
390 				for ( i = 0; i < NUM_INV_SLOTS; i++ )
391 				{
392 					pItem = &curr->pDetailedPlacement->Inv[ i ];
393 					if( GCM->getItem(pItem->usItem)->isAmmo() )
394 					{
395 						for( cnt = 0; cnt < pItem->ubNumberOfObjects; cnt++ )
396 						{
397 							pItem->ubShotsLeft[ cnt ] = Magazine[ GCM->getItem(pItem->usItem)->getClassIndex() ].ubMagSize;
398 						}
399 					}
400 				}
401 			}
402 		}
403 	}
404 	if( gMapInformation.ubMapVersion < 14 )
405 	{
406 		gMapInformation.ubMapVersion++;
407 			if( !gfCaves && !gfBasement )
408 			{
409 				ReplaceObsoleteRoads();
410 			}
411 	}
412 	if( gMapInformation.ubMapVersion < 15 )
413 	{ //Do nothing.  The object layer was expanded from 1 byte to 2 bytes, effecting the
414 		//size of the maps.  This was due to the fact that the ROADPIECES tileset contains
415 		//over 300 pieces, hence requiring a size increase of the tileset subindex for this
416 		//layer only.
417 	}
418 #endif //end of MAJOR VERSION 3.0 obsolete code
419 	if( gMapInformation.ubMapVersion < 16 )
420 	{
421 		gMapInformation.ubMapVersion = 16;
422 		gMapInformation.sIsolatedGridNo = -1;
423 	}
424 	if( gMapInformation.ubMapVersion < 17 )
425 	{
426 		gMapInformation.ubMapVersion = 17;
427 	}
428 	if( gMapInformation.ubMapVersion < 18 )
429 	{
430 		// replace useless crowbars with proper ones
431 		gMapInformation.ubMapVersion = 18;
432 		FOR_EACH_WORLD_ITEM(wi)
433 		{
434 			OBJECTTYPE& o = wi.o;
435 			if (o.usItem == JAR_ELIXIR) o.usItem = CROWBAR;
436 		}
437 	}
438 	if( gMapInformation.ubMapVersion < 19 )
439 	{
440 		//Do nothing, this is used to force regenerate the map edgepoints in map edgepoints.c
441 		gMapInformation.ubMapVersion = 19;
442 	}
443 	if( gMapInformation.ubMapVersion < 20 )
444 	{
445 		//validate the map entry points as the world boundaries have changed.
446 		gMapInformation.ubMapVersion = 20;
447 		ValidateEntryPointGridNo( &gMapInformation.sNorthGridNo );
448 		ValidateEntryPointGridNo( &gMapInformation.sEastGridNo );
449 		ValidateEntryPointGridNo( &gMapInformation.sSouthGridNo );
450 		ValidateEntryPointGridNo( &gMapInformation.sWestGridNo );
451 		ValidateEntryPointGridNo( &gMapInformation.sCenterGridNo );
452 		ValidateEntryPointGridNo( &gMapInformation.sIsolatedGridNo );
453 	}
454 	if( gMapInformation.ubMapVersion < 21 )
455 	{
456 		//override any item slots being locked if there is no item in that slot.
457 		//Laymen terms:  If any items slots are locked to be empty, make them empty but available
458 		//for random item generation.
459 		gMapInformation.ubMapVersion = 21;
460 		CFOR_EACH_SOLDIERINITNODE(curr)
461 		{
462 			if( curr->pDetailedPlacement )
463 			{
464 				INT32 i;
465 				for( i = 0; i < NUM_INV_SLOTS; i++ )
466 				{
467 					if( !curr->pDetailedPlacement->Inv[ i ].usItem )
468 					{
469 						if( curr->pDetailedPlacement->Inv[ i ].fFlags & OBJECT_UNDROPPABLE )
470 						{
471 							if( curr->pDetailedPlacement->Inv[ i ].fFlags & OBJECT_NO_OVERWRITE )
472 							{
473 								curr->pDetailedPlacement->Inv[ i ].fFlags &= ~OBJECT_NO_OVERWRITE;
474 							}
475 						}
476 					}
477 				}
478 			}
479 		}
480 	}
481 	if( gMapInformation.ubMapVersion < 22 )
482 	{ //Allow map edgepoints to be regenerated as new system has been reenabled.
483 		gMapInformation.ubMapVersion = 22;
484 	}
485 	if( gMapInformation.ubMapVersion < 23 )
486 	{ //Allow map edgepoints to be regenerated as new system has been reenabled.
487 		gMapInformation.ubMapVersion = 23;
488 		if (giCurrentTilesetID == CAVES_1) //cave/mine tileset only
489 		{ //convert all civilians to miners which use uniforms and more masculine body types.
490 			CFOR_EACH_SOLDIERINITNODE(curr)
491 			{
492 				if( curr->pBasicPlacement->bTeam == CIV_TEAM && !curr->pDetailedPlacement )
493 				{
494 					curr->pBasicPlacement->ubSoldierClass = SOLDIER_CLASS_MINER;
495 					curr->pBasicPlacement->bBodyType      = BODY_RANDOM;
496 				}
497 			}
498 		}
499 	}
500 	if( gMapInformation.ubMapVersion < 25 )
501 	{
502 		gMapInformation.ubMapVersion = 25;
503 		if( gfCaves )
504 		{
505 			LightSetBaseLevel( 13 );
506 		}
507 	}
508 }
509 
510 
AutoCalculateItemNoOverwriteStatus(void)511 static void AutoCalculateItemNoOverwriteStatus(void)
512 {
513 	INT32 i;
514 	OBJECTTYPE *pItem;
515 
516 	//Recalculate the "no overwrite" status flag on all items.  There are two different cases:
517 	//1)  If detailed placement has item, the item "no overwrite" flag is set
518 	//2)  If detailed placement doesn't have item, but item is set to drop (forced empty slot),
519 	//    the "no overwrite" flag is set.
520 	CFOR_EACH_SOLDIERINITNODE(curr)
521 	{
522 		if( curr->pDetailedPlacement )
523 		{
524 			for( i = 0; i < NUM_INV_SLOTS; i++ )
525 			{
526 				pItem = &curr->pDetailedPlacement->Inv[ i ];
527 				if( pItem->usItem != NONE )
528 				{
529 					//case 1 (see above)
530 					pItem->fFlags |= OBJECT_NO_OVERWRITE;
531 				}
532 				else if( !(pItem->fFlags & OBJECT_UNDROPPABLE) )
533 				{
534 					//case 2 (see above)
535 					pItem->fFlags |= OBJECT_NO_OVERWRITE;
536 				}
537 			}
538 		}
539 	}
540 }
541 
ValidateAndUpdateMapVersionIfNecessary()542 void ValidateAndUpdateMapVersionIfNecessary()
543 {
544 	//Older versions of mercs may require updating due to past bug fixes, new changes, etc.
545 	if( gMapInformation.ubMapVersion < MINOR_MAP_VERSION )
546 	{
547 		SetRelativeStartAndEndPercentage( 0, 92, 93, L"Updating older map version..." );
548 		RenderProgressBar( 0, 0 );
549 		UpdateOldVersionMap();
550 	}
551 	else if( gMapInformation.ubMapVersion > MINOR_MAP_VERSION )
552 	{
553 		//we may have a problem...
554 		SLOGW("Map version is greater than the current version (old ja2.exe?)" );
555 	}
556 	AutoCalculateItemNoOverwriteStatus() ;
557 }
558 
559 #include "Summary_Info.h"
560 //This function is used to avoid conflicts between minor version updates and sector summary info.
561 //By updating the summary info in conjunction with minor version updates, we can avoid these conflicts
562 //and really prevent major map updates.
UpdateSummaryInfo(SUMMARYFILE * pSummary)563 void UpdateSummaryInfo( SUMMARYFILE *pSummary )
564 {
565 	if( pSummary->MapInfo.ubMapVersion == MINOR_MAP_VERSION )
566 		return;
567 	if( pSummary->MapInfo.ubMapVersion < 9 )
568 	{
569 		//See bug 10
570 		pSummary->ubCivSchedules = 0;
571 	}
572 	if( pSummary->MapInfo.ubMapVersion < 12 )
573 	{
574 		pSummary->MapInfo.sCenterGridNo = -1;
575 	}
576 	if( pSummary->MapInfo.ubMapVersion < 16 )
577 	{
578 		pSummary->MapInfo.sIsolatedGridNo = -1;
579 	}
580 }
581 
582 
583 #ifdef WITH_UNITTESTS
584 #include "gtest/gtest.h"
585 
TEST(MapInformation,asserts)586 TEST(MapInformation, asserts)
587 {
588 	EXPECT_EQ(sizeof(MAPCREATE_STRUCT), 100u);
589 }
590 
591 #endif
592