GliderPRO/Sources/House.c

1 line
20 KiB
C
Raw Normal View History

//============================================================================ //---------------------------------------------------------------------------- // House.c //---------------------------------------------------------------------------- //============================================================================ #include <Navigation.h> #include <NumberFormatting.h> #include <Resources.h> #include <Sound.h> #include "DialogUtils.h" #include "Externs.h" #include "House.h" #include "RectUtils.h" #define kGoToDialogID 1043 void UpdateGoToDialog (DialogPtr); pascal Boolean GoToFilter (DialogPtr, EventRecord *, short *); houseHand thisHouse; linksPtr linksList; Str32 thisHouseName; short srcLocations[kMaxRoomObs]; short destLocations[kMaxRoomObs]; short wasFloor, wasSuite; retroLink retroLinkList[kMaxRoomObs]; Boolean houseUnlocked; extern gameType smallGame; extern short numberRooms, mapLeftRoom, mapTopRoom, numStarsRemaining; extern Boolean houseOpen, noRoomAtAll; extern Boolean twoPlayerGame, wardBitSet, phoneBitSet; //============================================================== Functions //-------------------------------------------------------------- CreateNewHouse // Called to create a new house file. #ifndef COMPILEDEMO Boolean CreateNewHouse (void) { AEKeyword theKeyword; DescType actualType; Size actualSize; NavReplyRecord theReply; NavDialogOptions dialogOptions; FSSpec tempSpec; FSSpec theSpec; OSErr theErr; theErr = NavGetDefaultDialogOptions(&dialogOptions); theErr = NavPutFile(nil, &theReply, &dialogOptions, nil, 'gliH', 'ozm5', nil); if (theErr == userCanceledErr) return false; if (!theReply.validRecord) return (false); theErr = AEGetNthPtr(&(theReply.selection), 1, typeFSS, &theKeyword, &actualType, &theSpec, sizeof(FSSpec), &actualSize); if (theReply.replacing) { theErr = FSMakeFSSpec(theSpec.vRefNum, theSpec.parID, theSpec.name, &tempSpec); if (!CheckFileError(theErr, theSpec.name)) return (false); theErr = FSpDelete(&tempSpec); if (!CheckFileError(theErr, theSpec.name)) return (false); } if (houseOpen) { if (!CloseHouse()) return (false); } theErr = FSpCreate(&theSpec, 'ozm5', 'gliH', theReply.keyScript); if (!CheckFileError(theErr, "\pNew House")) return (false); HCreateResFile(theSpec.vRefNum, theSpec.parID, theSpec.name); if (ResError() != noErr) YellowAlert(kYellowFailedResCreate, ResError()); PasStringCopy(theSpec.name, thisHouseName); AddExtraHouse(&theSpec); BuildHouseList(); InitCursor(); if (!OpenHouse()) return (false); return (true); } #endif //-------------------------------------------------------------- InitializeEmptyHouse // Initializes all the structures for an empty (new) house. #ifndef COMPILEDEMO Boolean InitializeEmptyHouse (void) { houseType *thisHousePtr; Str255 tempStr; if (thisHouse != nil) DisposeHandle((Handle)thisHouse); thisHouse = (houseHand)NewHandle(sizeof(houseType)); if (thisHouse == nil) { YellowAlert(kYellowUnaccounted, 1); return (false); } HLock((Handle)thisHouse); thisHousePtr = *thisHouse; thisHousePtr->version = kHouseVersion; thisHousePtr->firstRoom = -1; thisHousePtr->timeStamp = 0L; thisHousePtr->flags = 0L; 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; HUnlock((Handle)thisHouse); numberRooms = 0; mapLeftRoom = 60; mapTopRoom = 50; thisRoomNumber = kRoomIsEmpty; previousRoom = -1; houseUnlocked = true; OpenMapWindow(); UpdateMapWindow(); noRoomAtAll = true; fileDirty = true; UpdateMenus(false); ReflectCurrentRoom(true); return (true); } #endif //-------------------------------------------------------------- RealRoomNumberCount // Returns the real number of rooms