mirror of
https://github.com/softdorothy/GliderPRO.git
synced 2024-11-26 02:49:20 +00:00
1 line
28 KiB
C
1 line
28 KiB
C
|
//============================================================================
//----------------------------------------------------------------------------
// HouseLegal.c
//----------------------------------------------------------------------------
//============================================================================
#include <NumberFormatting.h>
#include <StringCompare.h>
#include "Externs.h"
#include "ObjectEdit.h"
#include "RectUtils.h"
void WrapBannerAndTrailer (void);
void ValidateNumberOfRooms (void);
void CheckDuplicateFloorSuite (void);
void CompressHouse (void);
void LopOffExtraRooms (void);
void ValidateRoomNumbers (void);
void CountUntitledRooms (void);
void CheckRoomNameLength (void);
void MakeSureNumObjectsJives (void);
void KeepAllObjectsLegal (void);
void CheckForStaircasePairs (void);
short houseErrors, wasRoom;
Boolean isHouseChecks;
extern short numberRooms;
//============================================================== Functions
//-------------------------------------------------------------- KeepObjectLegal
// Does a test of the current object active for any illegal bounds<64>
// or values. It corrects the erros and returns true if any changes<65>
// were made.
Boolean KeepObjectLegal (void)
{
objectType *theObject;
Rect bounds, roomRect;
short direction, dist;
char wasState;
Boolean unchanged;
unchanged = true;
#ifndef COMPILEDEMO
theObject = &thisRoom->objects[objActive];
if (objActive == kInitialGliderSelected)
{
wasState = HGetState((Handle)thisHouse);
HLock((Handle)thisHouse);
if ((*thisHouse)->initial.h < 0)
(*thisHouse)->initial.h = 0;
if ((*thisHouse)->initial.v < 0)
(*thisHouse)->initial.v = 0;
if ((*thisHouse)->initial.h > (kRoomWide - kGliderWide))
(*thisHouse)->initial.h = kRoomWide - kGliderWide;
if ((*thisHouse)->initial.v > (kTileHigh - kGliderHigh))
(*thisHouse)->initial.v = kTileHigh - kGliderHigh;
HSetState((Handle)thisHouse, wasState);
return (true);
}
QSetRect(&roomRect, 0, 0, kRoomWide, kTileHigh);
switch (theObject->what)
{
case kFloorVent:
case kCeilingVent:
case kFloorBlower:
case kCeilingBlower:
case kSewerGrate:
case kLeftFan:
case kRightFan:
case kTaper:
case kCandle:
case kStubby:
case kTiki:
case kBBQ:
case kInvisBlower:
case kGrecoVent:
case kSewerBlower:
case kLiftArea:
GetObjectRect(&thisRoom->objects[objActive], &bounds);
if (ForceRectInRect(&bounds, &roomRect))
{
theObject->data.a.topLeft.h = bounds.left;
theObject->data.a.topLeft.v = bounds.top;
unchanged = false;
if (theObject->what == kLiftArea)
{
theObject->data.a.distance = RectWide(&bounds);
theObject->data.a.tall = RectTall(&bounds) / 2;
}
}
if ((theObject->what == kStubby) && (theObject->data.a.topLeft.h % 2 == 0))
{
theObject->data.a.topLeft.h--;
unchanged = false;
}
if (((theObject->what == kTaper) || (theObject->what == kCandle) ||
(theObject->what == kTiki) || (theObject->what == kBBQ)) &&
(theObject->data.a.topLeft.h % 2 != 0))
{
theObject->data.a.topLeft.h--;
unchanged = false;
}
if ((theObject->what == kFloorVent) && (theObject->data.a.topLeft.v != kFloorVentTop))
{
theObject->data.a.topLeft.v = kFloorVentTop;
theObject->data.a.distance += 2;
}
if ((theObject->what == kFloorBlower) &&
(theObject->data.a.topLeft.v != kFloorBlowerTop))
{
theObject->data.a.topLeft.v = kFloorBlowerTop;
theObject->data.a.distance += 2;
}
if ((theObject->what == kSewerGrate) &&
(theObject->data.a.topLeft.v != kSewerGrateTop))
{
theObject->data.a.topLeft.v = kSewerGrateTop;
theObject->data.a.distance += 2;
}
if ((theObject->what == kFloorTrans) &&
(theObject->data.a.topLeft.v != kFloorTransTop))
{
theObject->data.a.topLeft.v = kFloorTransTop;
theObject->data.a.distance += 2;
}
if (ObjectHasHandle(&direction, &dist))
{
switch (direction)
{
case kAbove:
dist = bounds.top - dist;
if ((theObject->what == kFloorVent) ||
(theObject->what == kFloorBlower
|