From c241c0ea7beea3898feffb22564a34184399c7d3 Mon Sep 17 00:00:00 2001 From: Flugente Date: Tue, 31 Mar 2015 18:36:19 +0000 Subject: [PATCH] Fix: if a map was saved before entry points had been defined, it could not be loaded again. This has been fixed, and we also print out a warning to that a mapper can fix the map. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7802 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Handle UI.cpp | 21 ++++++++++----------- Tactical/Map Information.cpp | 7 +++++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp index f3e8346b..abcbd0d7 100644 --- a/Tactical/Handle UI.cpp +++ b/Tactical/Handle UI.cpp @@ -6759,7 +6759,6 @@ void SetInterfaceHeightLevel( ) { INT16 sHeight; static INT16 sOldHeight = 0; - INT32 sGridNo; if( gfBasement || gfCaves ) { @@ -6769,25 +6768,25 @@ void SetInterfaceHeightLevel( ) return; } - // ATE: Use an entry point to determine what height to use.... if( gMapInformation.sNorthGridNo != NOWHERE ) - sGridNo = gMapInformation.sNorthGridNo; + sHeight = gpWorldLevelData[gMapInformation.sNorthGridNo].sHeight; else if( gMapInformation.sEastGridNo != NOWHERE ) - sGridNo = gMapInformation.sEastGridNo; + sHeight = gpWorldLevelData[gMapInformation.sEastGridNo].sHeight; else if( gMapInformation.sSouthGridNo != NOWHERE ) - sGridNo = gMapInformation.sSouthGridNo; + sHeight = gpWorldLevelData[gMapInformation.sSouthGridNo].sHeight; else if( gMapInformation.sWestGridNo != NOWHERE ) - sGridNo = gMapInformation.sWestGridNo; + sHeight = gpWorldLevelData[gMapInformation.sWestGridNo].sHeight; + else if ( gMapInformation.sCenterGridNo != NOWHERE ) + sHeight = gpWorldLevelData[gMapInformation.sCenterGridNo].sHeight; else { - Assert(0); - return; + // we're merely interested in the terrain height. If the map has no entry points at all, we will have other problems than rooftops, so just use height of 0 and be done with it + // however, print out a warning, so that a mapper can fix this! + ScreenMsg( MSG_FONT_YELLOW, MSG_ERROR, L"Map has no entry points - please fix this!" ); + sHeight = 0; } - - sHeight = gpWorldLevelData[ sGridNo ].sHeight; - if ( sHeight != sOldHeight ) { gsRenderHeight = sHeight; diff --git a/Tactical/Map Information.cpp b/Tactical/Map Information.cpp index afa97737..de4fc1a9 100644 --- a/Tactical/Map Information.cpp +++ b/Tactical/Map Information.cpp @@ -171,6 +171,13 @@ BOOLEAN MAPCREATE_STRUCT::Save(HWFILE hFile, FLOAT dMajorMapVersion, UINT8 ubMin pData = &OldMapCreateStruct; uiBytesToWrite = sizeof(_OLD_MAPCREATE_STRUCT); } + + // a map without entry points would be fatal in a campaign, so print out a warning to the maper + if ( sNorthGridNo == NOWHERE && sEastGridNo == NOWHERE && sSouthGridNo == NOWHERE && sWestGridNo == NOWHERE && sCenterGridNo == NOWHERE ) + { + ScreenMsg( MSG_FONT_YELLOW, MSG_ERROR, L"Map has no entry points - please fix this!" ); + } + UINT32 uiBytesWritten = 0; FileWrite(hFile, pData, uiBytesToWrite, &uiBytesWritten); if(uiBytesToWrite == uiBytesWritten)