Handle refactor

This commit is contained in:
elasota
2019-12-29 23:14:37 -05:00
parent 9cf539eb52
commit fb105bd338
37 changed files with 365 additions and 240 deletions

View File

@@ -5,6 +5,7 @@
//============================================================================
#include "PLKeyEncoding.h"
#include "PLControlDefinitions.h"
#include "PLNumberFormatting.h"
#include "PLResources.h"
#include "PLSound.h"
@@ -42,7 +43,7 @@ void DoAbout (void)
Str255 longVersion;
StringPtr messagePtr;
VersRecHndl version;
Handle itemHandle;
ControlHandle itemHandle;
short itemType, hit, wasResFile;
ModalFilterUPP aboutFilterUPP;
@@ -55,7 +56,7 @@ void DoAbout (void)
// if (aboutDialog == nil)
// RedAlert(kErrDialogDidntLoad);
version = (VersRecHndl)GetResource('vers', 1);
version = GetResource('vers', 1).StaticCast<VersionRecord>();
if (version != nil)
{
messagePtr = (**version).shortVersion + 1 + (**version).shortVersion[0];
@@ -109,7 +110,7 @@ static void HiLiteOkayButton (void)
if (thePict != nil)
{
DrawPicture(thePict, &okayButtonBounds);
DisposeHandle((Handle)thePict);
thePict.Dispose();
okayButtIsHiLit = true;
}
@@ -131,7 +132,7 @@ static void UnHiLiteOkayButton (void)
if (thePict != nil)
{
DrawPicture(thePict, &okayButtonBounds);
DisposeHandle((Handle)thePict);
thePict.Dispose();
okayButtIsHiLit = false;
}

View File

@@ -25,15 +25,19 @@ typedef struct
BEInt16_t resID;
BEInt16_t reserved;
} frame[1];
} acurRec, *acurPtr, **acurHandle;
} acurRec;
typedef THandle<acurRec> acurHandle;
typedef struct
{
struct
{
Handle cursorHdl;
THandle<CCursor> cursorHdl;
} frame[1];
} compiledAcurRec, *compiledAcurPtr, **compiledAcurHandle;
} compiledAcurRec;
typedef THandle<compiledAcurRec> compiledAcurHandle;
Boolean GetColorCursors (acurHandle, compiledAcurHandle);
@@ -73,7 +77,7 @@ Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCu
}
else // But, if the cursor loaded ok
{ // add it to our list or cursor handles
(*compiledBallCursH)->frame[i].cursorHdl = (Handle)cursHdl;
(*compiledBallCursH)->frame[i].cursorHdl = cursHdl;
SetCCursor((CCrsrHandle)(*compiledBallCursH)->frame[i].cursorHdl);
}
}
@@ -93,10 +97,10 @@ void InitAnimatedCursor (acurHandle ballCursH)
useColor = thisMac.hasColor;
if (ballCursH == nil)
ballCursH = reinterpret_cast<acurHandle>(GetResource('acur', 128));
ballCursH = GetResource('acur', 128).StaticCast<acurRec>();
if (ballCursH && ballCursH != animCursorH)
{
compiledBallCursorH = (compiledAcurHandle)NewHandle(sizeof(compiledAcurRec) * (*ballCursH)->n);
compiledBallCursorH = NewHandle(sizeof(compiledAcurRec) * (*ballCursH)->n).StaticCast<compiledAcurRec>();
if (!compiledBallCursorH)
RedAlert(kErrFailedResourceLoad);
@@ -120,7 +124,7 @@ void InitAnimatedCursor (acurHandle ballCursH)
void LoadCursors (void)
{
InitAnimatedCursor((acurHandle)GetResource('acur', rAcurID));
InitAnimatedCursor(GetResource('acur', rAcurID).StaticCast<acurRec>());
}
//-------------------------------------------------------------- DisposCursors
@@ -147,16 +151,16 @@ void DisposCursors (void)
for (i = 0; i < j; i++)
{
if ((*compiledAnimCursorH)->frame[i].cursorHdl != nil)
DisposeHandle((Handle)(*compiledAnimCursorH)->frame[i].cursorHdl);
(*compiledAnimCursorH)->frame[i].cursorHdl.Dispose();
}
}
DisposeHandle((Handle)compiledAnimCursorH);
compiledAnimCursorH.Dispose();
compiledAnimCursorH = nil;
}
if (animCursorH != nil)
{
DisposeHandle((Handle)animCursorH);
animCursorH.Dispose();
animCursorH = nil;
}
}

View File

@@ -140,7 +140,7 @@ void GetDialogRect (Rect *bounds, short dialogID)
DialogTHndl dlogHandle;
Byte wasState;
dlogHandle = (DialogTHndl)GetResource('DLOG', dialogID);
dlogHandle = GetResource('DLOG', dialogID).StaticCast<DialogTemplate>();
if (dlogHandle != nil)
{
*bounds = (**dlogHandle).boundsRect;
@@ -331,15 +331,15 @@ void ZoomOutAlertRect (short alertID)
void FlashDialogButton (DialogPtr theDialog, short itemNumber)
{
Rect itemRect;
Handle itemHandle;
UInt32 dummyLong;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
UInt32 dummyLong;
short itemType;
GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemRect);
HiliteControl((ControlHandle)itemHandle, kControlButtonPart);
HiliteControl(itemHandle, kControlButtonPart);
Delay(8, &dummyLong);
HiliteControl((ControlHandle)itemHandle, 0);
HiliteControl(itemHandle, 0);
}
//-------------------------------------------------------------- DrawDefaultButton
@@ -348,9 +348,9 @@ void FlashDialogButton (DialogPtr theDialog, short itemNumber)
void DrawDefaultButton (DialogPtr theDialog)
{
Rect itemRect;
Handle itemHandle;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, 1, &itemType, &itemHandle, &itemRect);
InsetRect(&itemRect, -4, -4);
@@ -364,9 +364,9 @@ void DrawDefaultButton (DialogPtr theDialog)
void GetDialogString (DialogPtr theDialog, short item, StringPtr theString)
{
Rect itemRect;
Handle itemHandle;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
GetDialogItemText(itemHandle, theString);
@@ -377,9 +377,9 @@ void GetDialogString (DialogPtr theDialog, short item, StringPtr theString)
void SetDialogString (DialogPtr theDialog, short item, const PLPasStr &theString)
{
Rect itemRect;
Handle itemHandle;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
SetDialogItemText(itemHandle, theString);
@@ -390,10 +390,10 @@ void SetDialogString (DialogPtr theDialog, short item, const PLPasStr &theString
short GetDialogStringLen (DialogPtr theDialog, short item)
{
Rect itemRect;
Str255 theString;
Handle itemHandle;
short itemType;
Rect itemRect;
Str255 theString;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
GetDialogItemText(itemHandle, theString);
@@ -406,12 +406,12 @@ short GetDialogStringLen (DialogPtr theDialog, short item)
void GetDialogItemValue (DialogPtr theDialog, short item, short *theState)
{
Rect itemRect;
Handle itemHandle;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
*theState = GetControlValue((ControlHandle)itemHandle);
*theState = GetControlValue(itemHandle);
}
//-------------------------------------------------------------- SetDialogItemValue
@@ -420,12 +420,12 @@ void GetDialogItemValue (DialogPtr theDialog, short item, short *theState)
void SetDialogItemValue (DialogPtr theDialog, short item, short theState)
{
Rect itemRect;
Handle itemHandle;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
SetControlValue((ControlHandle)itemHandle, theState);
SetControlValue(itemHandle, theState);
}
//-------------------------------------------------------------- ToggleDialogItemValue
@@ -433,17 +433,17 @@ void SetDialogItemValue (DialogPtr theDialog, short item, short theState)
void ToggleDialogItemValue (DialogPtr theDialog, short item)
{
Rect itemRect;
Handle itemHandle;
short itemType, theState;
Rect itemRect;
ControlHandle itemHandle;
short itemType, theState;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
theState = GetControlValue((ControlHandle)itemHandle);
theState = GetControlValue(itemHandle);
if (theState == 0)
theState = 1;
else
theState = 0;
SetControlValue((ControlHandle)itemHandle, theState);
SetControlValue(itemHandle, theState);
}
//-------------------------------------------------------------- SetDialogNumToStr
@@ -452,10 +452,10 @@ void ToggleDialogItemValue (DialogPtr theDialog, short item)
void SetDialogNumToStr (DialogPtr theDialog, short item, long theNumber)
{
Str255 theString;
Rect itemRect;
Handle itemHandle;
short itemType;
Str255 theString;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
NumToString(theNumber, theString);
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
@@ -468,10 +468,10 @@ void SetDialogNumToStr (DialogPtr theDialog, short item, long theNumber)
void GetDialogNumFromStr (DialogPtr theDialog, short item, long *theNumber)
{
Str255 theString;
Rect itemRect;
Handle itemHandle;
short itemType;
Str255 theString;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
GetDialogItemText(itemHandle, theString);
@@ -483,8 +483,8 @@ void GetDialogNumFromStr (DialogPtr theDialog, short item, long *theNumber)
void GetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
{
Handle itemHandle;
short itemType;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, theRect);
}
@@ -495,9 +495,9 @@ void GetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
void SetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
{
Rect oldRect;
Handle itemHandle;
short itemType;
Rect oldRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &oldRect);
OffsetRect(&oldRect, theRect->left - oldRect.left, theRect->top - oldRect.top);
@@ -509,9 +509,9 @@ void SetDialogItemRect (DialogPtr theDialog, short item, Rect *theRect)
void OffsetDialogItemRect (DialogPtr theDialog, short item, short h, short v)
{
Rect oldRect;
Handle itemHandle;
short itemType;
Rect oldRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &oldRect);
OffsetRect(&oldRect, h, v);
@@ -525,18 +525,18 @@ void OffsetDialogItemRect (DialogPtr theDialog, short item, short h, short v)
void SelectFromRadioGroup (DialogPtr dial, short which, short first, short last)
{
Rect iRect;
Handle iHandle;
short iType, i;
Rect iRect;
ControlHandle iHandle;
short iType, i;
for (i = first; i <= last; i++)
{
GetDialogItem(dial, i, &iType, &iHandle, &iRect);
SetControlValue((ControlHandle)iHandle, (short)false);
SetControlValue(iHandle, (short)false);
}
GetDialogItem(dial, which, &iType, &iHandle, &iRect);
SetControlValue((ControlHandle)iHandle, (short)true);
SetControlValue(iHandle, (short)true);
}
//-------------------------------------------------------------- AddMenuToPopUp
@@ -558,12 +558,12 @@ void AddMenuToPopUp (DialogPtr theDialog, short whichItem, MenuHandle theMenu)
void GetPopUpMenuValue (DialogPtr theDialog, short whichItem, short *value)
{
Rect iRect;
Handle iHandle;
short iType;
Rect iRect;
ControlHandle iHandle;
short iType;
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
*value = GetControlValue((ControlHandle)iHandle);
*value = GetControlValue(iHandle);
}
//-------------------------------------------------------------- SetPopUpMenuValue
@@ -571,12 +571,12 @@ void GetPopUpMenuValue (DialogPtr theDialog, short whichItem, short *value)
void SetPopUpMenuValue (DialogPtr theDialog, short whichItem, short value)
{
Rect iRect;
Handle iHandle;
short iType;
Rect iRect;
ControlHandle iHandle;
short iType;
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
SetControlValue((ControlHandle)iHandle, value);
SetControlValue(iHandle, value);
}
//-------------------------------------------------------------- MyEnableControl
@@ -584,12 +584,12 @@ void SetPopUpMenuValue (DialogPtr theDialog, short whichItem, short value)
void MyEnableControl (DialogPtr theDialog, short whichItem)
{
Rect iRect;
Handle iHandle;
short iType;
Rect iRect;
ControlHandle iHandle;
short iType;
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
HiliteControl((ControlHandle)iHandle, kActive);
HiliteControl(iHandle, kActive);
}
//-------------------------------------------------------------- MyDisableControl
@@ -597,12 +597,12 @@ void MyEnableControl (DialogPtr theDialog, short whichItem)
void MyDisableControl (DialogPtr theDialog, short whichItem)
{
Rect iRect;
Handle iHandle;
short iType;
Rect iRect;
ControlHandle iHandle;
short iType;
GetDialogItem(theDialog, whichItem, &iType, &iHandle, &iRect);
HiliteControl((ControlHandle)iHandle, kInactive);
HiliteControl(iHandle, kInactive);
}
//-------------------------------------------------------------- DrawDialogUserText
@@ -612,10 +612,10 @@ void MyDisableControl (DialogPtr theDialog, short whichItem)
void DrawDialogUserText (DialogPtr dial, short item, StringPtr text, Boolean invert)
{
Rect iRect;
Handle iHandle;
Str255 newString, stringCopy;
short iType, textLong, i, inset;
Rect iRect;
ControlHandle iHandle;
Str255 newString, stringCopy;
short iType, textLong, i, inset;
TextFont(applFont);
TextSize(9);
@@ -651,10 +651,10 @@ void DrawDialogUserText (DialogPtr dial, short item, StringPtr text, Boolean inv
void DrawDialogUserText2 (DialogPtr dial, short item, StringPtr text)
{
Rect iRect;
Handle iHandle;
Str255 stringCopy;
short iType;
Rect iRect;
ControlHandle iHandle;
Str255 stringCopy;
short iType;
TextFont(applFont);
TextSize(9);
@@ -673,10 +673,10 @@ void DrawDialogUserText2 (DialogPtr dial, short item, StringPtr text)
void LoadDialogPICT (DialogPtr theDialog, short item, short theID)
{
Rect iRect;
Handle iHandle;
PicHandle thePict;
short iType;
Rect iRect;
ControlHandle iHandle;
PicHandle thePict;
short iType;
GetDialogItem(theDialog, item, &iType, &iHandle, &iRect);
thePict = GetPicture(theID);
@@ -689,9 +689,9 @@ void LoadDialogPICT (DialogPtr theDialog, short item, short theID)
void FrameDialogItem (DialogPtr theDialog, short item)
{
Rect itemRect;
Handle itemHandle;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
FrameRect(&itemRect);
@@ -702,10 +702,10 @@ void FrameDialogItem (DialogPtr theDialog, short item)
void FrameDialogItemC (DialogPtr theDialog, short item, long color)
{
RGBColor theRGBColor, wasColor;
Rect itemRect;
Handle itemHandle;
short itemType;
RGBColor theRGBColor, wasColor;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
GetForeColor(&wasColor);
@@ -720,9 +720,9 @@ void FrameDialogItemC (DialogPtr theDialog, short item, long color)
void FrameOvalDialogItem (DialogPtr theDialog, short item)
{
Rect itemRect;
Handle itemHandle;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
FrameOval(&itemRect);
@@ -734,9 +734,9 @@ void FrameOvalDialogItem (DialogPtr theDialog, short item)
void BorderDialogItem (DialogPtr theDialog, short item, short sides)
{
Rect itemRect;
Handle itemHandle;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
// 1 = left
// 2 = top
@@ -775,9 +775,9 @@ void BorderDialogItem (DialogPtr theDialog, short item, short sides)
void ShadowDialogItem (DialogPtr theDialog, short item, short thickness)
{
Rect itemRect;
Handle itemHandle;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
PenSize(thickness, thickness);
@@ -793,9 +793,9 @@ void ShadowDialogItem (DialogPtr theDialog, short item, short thickness)
void EraseDialogItem (DialogPtr theDialog, short item)
{
Rect itemRect;
Handle itemHandle;
short itemType;
Rect itemRect;
ControlHandle itemHandle;
short itemType;
GetDialogItem(theDialog, item, &itemType, &itemHandle, &itemRect);
EraseRect(&itemRect);

View File

@@ -199,7 +199,9 @@ typedef struct
roomType rooms[1]; // 348 * nRooms
static const size_t kBinaryDataSize = 866;
} houseType, *housePtr, **houseHand; // total = 866 +
} houseType, *housePtr; // total = 866 +
typedef THandle<houseType> houseHand;
typedef struct
{
@@ -277,7 +279,10 @@ typedef struct
Boolean top;
Boolean right;
Boolean bottom;
} boundsType, *boundsPtr, **boundsHand;
} boundsType, *boundsPtr;
typedef THandle<boundsType> boundsHand;
typedef struct
{

View File

@@ -120,9 +120,9 @@ Boolean InitializeEmptyHouse (void)
Str255 tempStr;
if (thisHouse != nil)
DisposeHandle((Handle)thisHouse);
thisHouse.Dispose();
thisHouse = (houseHand)NewHandle(sizeof(houseType));
thisHouse = NewHandle(sizeof(houseType)).StaticCast<houseType>();
if (thisHouse == nil)
{

View File

@@ -51,19 +51,19 @@ extern Boolean phoneBitSet, bannerStarCountOn;
void LoopMovie (void)
{
Handle theLoop;
UserData theUserData;
short theCount;
THandle<long> theLoop;
UserData theUserData;
short theCount;
theLoop = NewHandle(sizeof(long));
(** (long **) theLoop) = 0;
theLoop = NewHandle(sizeof(long)).StaticCast<long>();
(**theLoop) = 0;
theUserData = GetMovieUserData(theMovie);
theCount = CountUserDataType(theUserData, 'LOOP');
while (theCount--)
{
RemoveUserData(theUserData, 'LOOP', 1);
}
AddUserData(theUserData, theLoop, 'LOOP');
AddUserData(theUserData, theLoop.StaticCast<void>(), 'LOOP');
}
//-------------------------------------------------------------- OpenHouseMovie
@@ -119,11 +119,11 @@ void OpenHouseMovie (void)
if (theErr != PLErrors::kNone)
{
YellowAlert(kYellowQTMovieNotLoaded, theErr);
DisposeHandle(spaceSaver);
spaceSaver.Dispose();
CloseHouseMovie();
return;
}
DisposeHandle(spaceSaver);
spaceSaver.Dispose();
theErr = PrerollMovie(theMovie, 0, 0x000F0000);
if (theErr != PLErrors::kNone)
@@ -642,12 +642,12 @@ Boolean ReadHouse (void)
#endif
if (thisHouse != nil)
DisposeHandle((Handle)thisHouse);
thisHouse.Dispose();
// GP: Correct for padding
const size_t alignmentPadding = sizeof(houseType) - sizeof(roomType) - houseType::kBinaryDataSize;
thisHouse = (houseHand)NewHandle(byteCount + alignmentPadding);
thisHouse = NewHandle(byteCount + alignmentPadding).StaticCast<houseType>();
if (thisHouse == nil)
{
YellowAlert(kYellowNoMemory, 10);
@@ -767,7 +767,7 @@ Boolean WriteHouse (Boolean checkIt)
if (checkIt)
CheckHouseForProblems();
byteCount = GetHandleSize((Handle)thisHouse);
byteCount = GetHandleSize(thisHouse.StaticCast<void>());
if (fileDirty)
{

View File

@@ -616,7 +616,7 @@ void ValidateNumberOfRooms (void)
char wasState;
reportsRooms = (long)(*thisHouse)->nRooms;
countedRooms = (GetHandleSize((Handle)thisHouse) -
countedRooms = (GetHandleSize(thisHouse.StaticCast<void>()) -
sizeof(houseType)) / sizeof(roomType);
if (reportsRooms != countedRooms)
{
@@ -737,7 +737,7 @@ void LopOffExtraRooms (void)
{
r = (*thisHouse)->nRooms - count;
newSize = sizeof(houseType) + (sizeof(roomType) * (long)r);
if (SetHandleSize((Handle)thisHouse, newSize) != PLErrors::kNone) // resize house handle (shrink)
if (SetHandleSize(thisHouse.StaticCast<void>(), newSize) != PLErrors::kNone) // resize house handle (shrink)
{
ForeColor(redColor);
GetLocalizedString(16, message);

View File

@@ -20,7 +20,7 @@
#define kDiagCursorID 131
extern Rect **mirrorRects;
extern THandle<Rect> mirrorRects;
extern WindowPtr mapWindow, toolsWindow, linkWindow;
extern WindowPtr menuWindow;
extern Rect shieldRect, boardSrcRect, localRoomsDest[];

View File

@@ -165,14 +165,14 @@ void LoadGraphicPlus (short resID, Rect *theRect)
thePicture = GetPicture(resID);
if (thePicture == nil)
{
thePicture = (PicHandle)GetResource('Date', resID);
thePicture = GetResource('Date', resID).StaticCast<Picture>();
if (thePicture == nil)
{
return;
}
}
DrawPicture(thePicture, theRect);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
}
//-------------------------------------------------------------- RedrawMapContents

View File

@@ -261,7 +261,7 @@ PLError_t LoadMusicSounds (void)
return PLErrors::kOutOfMemory;
BlockMove((Ptr)(static_cast<Byte*>(*theSound) + 20L), theMusicData[i], soundDataSize);
DisposeHandle(theSound);
theSound.Dispose();
}
return (theErr);
}

View File

@@ -1158,7 +1158,7 @@ void DrawCalendar (Rect *theRect)
QOffsetRect(&bounds, -bounds.left, -bounds.top);
QOffsetRect(&bounds, theRect->left, theRect->top);
DrawPicture(thePicture, &bounds);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
SetPort((GrafPtr)backSrcMap);
TextFace(bold);
@@ -1191,7 +1191,7 @@ void DrawBulletin (Rect *theRect)
QOffsetRect(&bounds, -bounds.left, -bounds.top);
QOffsetRect(&bounds, theRect->left, theRect->top);
DrawPicture(thePicture, &bounds);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
SetGraphicsPort(wasCPort);
}
@@ -1246,7 +1246,7 @@ void DrawPictObject (short what, Rect *theRect)
bounds = srcRects[what];
QOffsetRect(&bounds, theRect->left, theRect->top);
DrawPicture(thePicture, &bounds);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
SetGraphicsPort(wasCPort);
}

View File

@@ -526,7 +526,7 @@ void PlayGame (void)
QOffsetRect(&bounds, -bounds.left, -bounds.top);
QOffsetRect(&bounds, hOffset, 0);
DrawPicture(thePicture, &bounds);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
}
#else
// ShowMenuBarOld(); // TEMP
@@ -576,7 +576,7 @@ void PlayGame (void)
QOffsetRect(&bounds, -bounds.left, -bounds.top);
QOffsetRect(&bounds, hOffset, 0);
DrawPicture(thePicture, &bounds);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
SetGraphicsPort(wasCPort);
}

View File

@@ -29,13 +29,12 @@ void RenderStars (void);
void RenderBands (void);
void RenderShreds (void);
void CopyRectsQD (void);
void CopyRectsAssm (void);
Rect work2MainRects[kMaxGarbageRects];
Rect back2WorkRects[kMaxGarbageRects];
Rect shieldRect;
Rect **mirrorRects;
THandle<Rect> mirrorRects;
Point shieldPt;
long nextFrame;
short numWork2Main, numBack2Work;
@@ -151,7 +150,7 @@ void DrawReflection (gliderPtr thisGlider, Boolean oneOrTwo)
SetPort((GrafPtr)workSrcMap);
long numMirrorRects = GetHandleSize(reinterpret_cast<Handle>(mirrorRects)) / sizeof(Rect);
long numMirrorRects = GetHandleSize(mirrorRects.StaticCast<void>()) / sizeof(Rect);
for (long i = 0; i < numMirrorRects; i++)
{
@@ -743,16 +742,16 @@ void AddToMirrorRegion (Rect *theRect)
{
if (mirrorRects == nil)
{
mirrorRects = reinterpret_cast<Rect**>(NewHandle(sizeof(Rect)));
mirrorRects = NewHandle(sizeof(Rect)).StaticCast<Rect>();
if (mirrorRects != nil)
**mirrorRects = *theRect;
}
else
{
const long oldSize = GetHandleSize(reinterpret_cast<Handle>(mirrorRects));
const long oldSize = GetHandleSize(mirrorRects.StaticCast<void>());
const long newSize = oldSize + sizeof(Rect);
if (SetHandleSize(reinterpret_cast<Handle>(mirrorRects), newSize) == PLErrors::kNone)
if (SetHandleSize(mirrorRects.StaticCast<void>(), newSize) == PLErrors::kNone)
(*mirrorRects)[oldSize / sizeof(Rect)] = *theRect;
}
hasMirror = true;
@@ -763,7 +762,7 @@ void AddToMirrorRegion (Rect *theRect)
void ZeroMirrorRegion (void)
{
if (mirrorRects != nil)
DisposeHandle(reinterpret_cast<Handle>(mirrorRects));
mirrorRects.Dispose();
mirrorRects = nil;
hasMirror = false;
}

View File

@@ -194,7 +194,7 @@ Boolean CreateNewRoom (short h, short v)
if (availableRoom == -1) // found no available rooms
{
howMuch = sizeof(roomType); // add new room to end of house
theErr = PtrAndHand((Ptr)thisRoom, (Handle)thisHouse, howMuch);
theErr = PtrAndHand((Ptr)thisRoom, thisHouse.StaticCast<void>(), howMuch);
if (theErr != PLErrors::kNone)
{
YellowAlert(kYellowUnaccounted, theErr);
@@ -260,7 +260,7 @@ void ReadyBackground (short theID, short *theTiles)
thePicture = GetPicture(theID);
if (thePicture == nil)
{
thePicture = (PicHandle)GetResource('Date', theID);
thePicture = GetResource('Date', theID).StaticCast<Picture>();
if (thePicture == nil)
{
YellowAlert(kYellowNoBackground, 0);
@@ -271,7 +271,7 @@ void ReadyBackground (short theID, short *theTiles)
dest = (*thePicture)->picFrame.ToRect();
QOffsetRect(&dest, -dest.left, -dest.top);
DrawPicture(thePicture, &dest);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
QSetRect(&src, 0, 0, kTileWide, kTileHigh);
QSetRect(&dest, 0, 0, kTileWide, kTileHigh);
@@ -895,7 +895,7 @@ short GetOriginalBounding (short theID)
boundsHand boundsRes;
short boundCode;
boundsRes = (boundsHand)GetResource('bnds', theID);
boundsRes = GetResource('bnds', theID).StaticCast<boundsType>();
if (boundsRes == nil)
{
if (PictIDExists(theID))
@@ -913,7 +913,7 @@ short GetOriginalBounding (short theID)
boundCode += 4;
if ((*boundsRes)->bottom)
boundCode += 8;
DisposeHandle((Handle)boundsRes);
boundsRes.Dispose();
}
return (boundCode);

View File

@@ -134,7 +134,7 @@ void LoadGraphicSpecial (short resID)
thePicture = GetPicture(resID);
if (thePicture == nil)
{
thePicture = (PicHandle)GetResource('Date', resID);
thePicture = GetResource('Date', resID).StaticCast<Picture>();
if (thePicture == nil)
{
thePicture = GetPicture(2000);
@@ -146,8 +146,8 @@ void LoadGraphicSpecial (short resID)
bounds = (*thePicture)->picFrame.ToRect();
OffsetRect(&bounds, -bounds.left, -bounds.top);
DrawPicture(thePicture, &bounds);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
}
//-------------------------------------------------------------- DrawRoomBackground

View File

@@ -839,16 +839,16 @@ Boolean PictIDExists (short theID)
thePicture = GetPicture(theID);
if (thePicture == nil)
{
thePicture = (PicHandle)GetResource('Date', theID);
thePicture = GetResource('Date', theID).StaticCast<Picture>();
if (thePicture == nil)
{
foundIt = false;
}
else
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
}
else
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
// foundIt = false;
// numPicts = Count1Resources('PICT');
@@ -880,8 +880,8 @@ short GetFirstPICT (void)
resHandle = Get1IndResource('PICT', 1);
if (resHandle != nil)
{
const PortabilityLayer::ResourceCompiledRef *resRef = PortabilityLayer::ResourceManager::GetInstance()->ResourceForHandle(reinterpret_cast<PortabilityLayer::MMHandleBlock*>(resHandle));
DisposeHandle(resHandle);
const PortabilityLayer::ResourceCompiledRef *resRef = PortabilityLayer::ResourceManager::GetInstance()->ResourceForHandle(resHandle.MMBlock());
resHandle.Dispose();
return resRef->m_resID;
}
else

View File

@@ -228,13 +228,13 @@ PLError_t LoadTriggerSound (short soundID)
theSoundData[kMaxSounds - 1] = NewPtr(soundDataSize);
if (theSoundData[kMaxSounds - 1] == nil)
{
DisposeHandle(theSound);
theSound.Dispose();
theErr = PLErrors::kOutOfMemory;
}
else
{
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[kMaxSounds - 1], soundDataSize);
DisposeHandle(theSound);
theSound.Dispose();
}
}
}
@@ -275,7 +275,7 @@ PLError_t LoadBufferSounds (void)
return (PLErrors::kOutOfMemory);
BlockMove((Ptr)((Byte*)(*theSound) + 20L), theSoundData[i], soundDataSize);
DisposeHandle(theSound);
theSound.Dispose();
}
theSoundData[kMaxSounds - 1] = nil;

View File

@@ -84,7 +84,7 @@ void InitScoreboardMap (void)
QOffsetRect(&bounds, -bounds.left, -bounds.top);
QOffsetRect(&bounds, hOffset, 0);
DrawPicture(thePicture, &bounds);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
QSetRect(&badgeSrcRect, 0, 0, 32, 66); // 2144 pixels
theErr = CreateOffScreenGWorld(&badgeSrcMap, &badgeSrcRect, kPreferredPixelFormat);

View File

@@ -289,7 +289,7 @@ void CreatePointers (void)
else
{
BlockMove(*tempHandle, demoData, kDemoLength);
DisposeHandle(tempHandle);
tempHandle.Dispose();
}
#endif
}

View File

@@ -288,7 +288,7 @@ void LoadGraphic (short resID)
OffsetRect(&bounds, -bounds.left, -bounds.top);
DrawPicture(thePicture, &bounds);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
}
//-------------------------------------------------------------- LoadScaledGraphic
@@ -304,7 +304,7 @@ void LoadScaledGraphic (short resID, Rect *theRect)
if (thePicture == nil)
RedAlert(kErrFailedGraphicLoad);
DrawPicture(thePicture, theRect);
DisposeHandle((Handle)thePicture);
thePicture.Dispose();
}
//-------------------------------------------------------------- LargeIconPlot