mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Disable loading room editor if the current house is damaged beyond repair, and re-enable loading a different house.
This commit is contained in:
@@ -106,6 +106,7 @@ Boolean ReadScoresFromDisk (void);
|
||||
|
||||
Boolean CreateNewHouse (void); // --- House.c
|
||||
Boolean InitializeEmptyHouse (void);
|
||||
Boolean InitializeEmptyHouseInEditor (void);
|
||||
SInt16 RealRoomNumberCount (void);
|
||||
SInt16 GetFirstRoomNumber (void);
|
||||
void WhereDoesGliderBegin (Rect *, SInt16);
|
||||
|
@@ -205,24 +205,26 @@ Boolean CreateNewHouse (void)
|
||||
// Initializes all the structures for an empty (new) house.
|
||||
|
||||
#ifndef COMPILEDEMO
|
||||
|
||||
Boolean InitializeEmptyHouse (void)
|
||||
{
|
||||
houseType *thisHousePtr;
|
||||
Str255 tempStr;
|
||||
|
||||
|
||||
if (thisHouse != nil)
|
||||
thisHouse.Dispose();
|
||||
|
||||
thisHouse = NewHandle(sizeof(houseType) - sizeof(roomType)).StaticCast<houseType>();
|
||||
|
||||
|
||||
const size_t houseSizeNoRooms = sizeof(sizeof(houseType) - sizeof(roomType));
|
||||
thisHouse = NewHandle(houseSizeNoRooms).StaticCast<houseType>();
|
||||
|
||||
if (thisHouse == nil)
|
||||
{
|
||||
YellowAlert(kYellowUnaccounted, 1);
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
thisHousePtr = *thisHouse;
|
||||
|
||||
|
||||
thisHousePtr->version = kHouseVersion;
|
||||
thisHousePtr->firstRoom = -1;
|
||||
thisHousePtr->timeStamp = 0L;
|
||||
@@ -230,17 +232,17 @@ Boolean InitializeEmptyHouse (void)
|
||||
thisHousePtr->initial.h = 32;
|
||||
thisHousePtr->initial.v = 32;
|
||||
ZeroHighScores();
|
||||
|
||||
|
||||
GetLocalizedString(11, tempStr);
|
||||
PasStringCopy(tempStr, thisHousePtr->banner);
|
||||
GetLocalizedString(12, tempStr);
|
||||
PasStringCopy(tempStr, thisHousePtr->trailer);
|
||||
thisHousePtr->hasGame = false;
|
||||
thisHousePtr->nRooms = 0;
|
||||
|
||||
|
||||
wardBitSet = false;
|
||||
phoneBitSet = false;
|
||||
|
||||
|
||||
numberRooms = 0;
|
||||
mapLeftRoom = 60;
|
||||
mapTopRoom = 50;
|
||||
@@ -251,10 +253,17 @@ Boolean InitializeEmptyHouse (void)
|
||||
UpdateMapWindow();
|
||||
noRoomAtAll = true;
|
||||
fileDirty = true;
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
Boolean InitializeEmptyHouseInEditor (void)
|
||||
{
|
||||
if (!InitializeEmptyHouse())
|
||||
return (false);
|
||||
|
||||
UpdateMenus(false);
|
||||
ReflectCurrentRoom(true);
|
||||
|
||||
return (true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -170,6 +170,9 @@ Boolean OpenHouse (Boolean read)
|
||||
Boolean readOK = ReadHouse(houseStream, theHousesSpecs[thisHouseIndex].m_dir != PortabilityLayer::VirtualDirectories::kGameData);
|
||||
houseStream->Close();
|
||||
|
||||
if (!readOK)
|
||||
CloseHouse();
|
||||
|
||||
return readOK;
|
||||
}
|
||||
|
||||
@@ -1964,7 +1967,10 @@ Boolean ReadHouse (GpIOStream *houseStream, bool untrusted)
|
||||
#endif
|
||||
|
||||
if (thisHouse != nil)
|
||||
{
|
||||
thisHouse.Dispose();
|
||||
thisHouse = nil;
|
||||
}
|
||||
|
||||
if (byteCount < houseType::kBinaryDataSize)
|
||||
{
|
||||
|
@@ -72,12 +72,12 @@ void UpdateMenusNonEditMode (void)
|
||||
DisableMenuItem(gameMenu, iOpenSavedGame);
|
||||
if (houseOpen)
|
||||
{
|
||||
EnableMenuItem(gameMenu, iLoadHouse);
|
||||
EnableMenuItem(optionsMenu, iEditor);
|
||||
EnableMenuItem(optionsMenu, iHighScores);
|
||||
}
|
||||
else
|
||||
{
|
||||
DisableMenuItem(gameMenu, iLoadHouse);
|
||||
DisableMenuItem(optionsMenu, iEditor);
|
||||
DisableMenuItem(optionsMenu, iHighScores);
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ void UpdateMenusNonEditMode (void)
|
||||
EnableMenuItem(gameMenu, iNewGame);
|
||||
EnableMenuItem(gameMenu, iTwoPlayer);
|
||||
EnableMenuItem(gameMenu, iOpenSavedGame);
|
||||
EnableMenuItem(gameMenu, iLoadHouse);
|
||||
EnableMenuItem(optionsMenu, iEditor);
|
||||
EnableMenuItem(optionsMenu, iHighScores);
|
||||
}
|
||||
if (demoHouseIndex == -1)
|
||||
@@ -515,7 +515,7 @@ void DoHouseMenu (short theItem)
|
||||
case iNewHouse:
|
||||
if (CreateNewHouse())
|
||||
{
|
||||
whoCares = InitializeEmptyHouse();
|
||||
whoCares = InitializeEmptyHouseInEditor();
|
||||
whoCares = WriteHouse(false); // Save initial house so it's not an empty file if reloaded immediately
|
||||
OpenCloseEditWindows();
|
||||
}
|
||||
|
Reference in New Issue
Block a user