Don't partially delete house when overwriting the current house

This commit is contained in:
elasota
2021-03-07 05:07:48 -05:00
parent 55ec6c516c
commit fe4a8a55c6
3 changed files with 14 additions and 1 deletions

View File

@@ -48,6 +48,9 @@ Boolean CheckFileError (short resultCode, const PLPasStr &fileName)
case PLErrors::kOutOfMemory:
stringIndex = 7;
break;
case PLErrors::kFileIsBusy:
stringIndex = 12;
break;
default:
stringIndex = 1;
break;

View File

@@ -18,6 +18,7 @@
#include "House.h"
#include "MacFileInfo.h"
#include "PLStandardColors.h"
#include "PLStringCompare.h"
#include "PLTimeTaggedVOSEvent.h"
#include "RectUtils.h"
#include "ResourceManager.h"
@@ -32,6 +33,7 @@ void UpdateGoToDialog (Dialog *);
int16_t GoToFilter (void *context, Dialog *dial, const TimeTaggedVOSEvent *evt);
extern PortabilityLayer::IResourceArchive *houseResFork;
extern PortabilityLayer::CompositeFile *houseCFile;
houseHand thisHouse;
@@ -115,7 +117,14 @@ Boolean CreateNewHouse (void)
theSpec.m_name[0] = static_cast<uint8_t>(savePathLength);
memcpy(theSpec.m_name + 1, savePath, savePathLength);
if (fm->FileExists(theSpec.m_dir, theSpec.m_name))
// Don't try to overwrite the current house - The GPF will probably be locked anyway
if (houseCFile && theSpec.m_dir == houseCFile->GetDirectory() && !StrCmp::CompareCaseInsensitive(theSpec.m_name, houseCFile->GetFileName()))
{
CheckFileError(PLErrors::kFileIsBusy, theSpec.m_name);
return (false);
}
if (fm->CompositeFileExists(theSpec.m_dir, theSpec.m_name))
{
if (!fm->DeleteCompositeFile(theSpec.m_dir, theSpec.m_name))
{