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