//EntryPoints can't be placed on the top two gridnos in a map. So all we do in this case //is return the closest gridno. Returns TRUE if the mapindex changes. BOOLEAN ValidateEntryPointGridNo( INT32 *sGridNo ) { INT16 sXMapPos, sYMapPos; INT16 sWorldX, sWorldY; INT32 iNewMapX, iNewMapY; INT32 sTopLimit, sBottomLimit; if ( TileIsOutOfBounds( *sGridNo ) ) return FALSE; //entry point is non-existant ConvertGridNoToXY( *sGridNo, &sXMapPos, &sYMapPos ); sTopLimit = 80; sBottomLimit = gsBRY - gsTLY - 40; //Get screen coordinates for current gridno GetWorldXYAbsoluteScreenXY( sXMapPos, sYMapPos, &sWorldX, &sWorldY); if( sWorldY < sTopLimit ) { GetFromAbsoluteScreenXYWorldXY( &iNewMapX, &iNewMapY, sWorldX, sTopLimit ); } else if( sWorldY > sBottomLimit ) { GetFromAbsoluteScreenXYWorldXY( &iNewMapX, &iNewMapY, sWorldX, sBottomLimit ); } else { return FALSE; //already valid } *sGridNo = MAPROWCOLTOPOS( iNewMapY/10, iNewMapX/10 ); return TRUE; //modified }
//DBrot: More Rooms void SetTileRangeRoomNum( SGPRect *pSelectRegion, UINT8 usRoomNum ) { INT32 cnt1, cnt2; for ( cnt1 = pSelectRegion->iTop; cnt1 <= pSelectRegion->iBottom; cnt1++ ) { for ( cnt2 = pSelectRegion->iLeft; cnt2 <= pSelectRegion->iRight; cnt2++ ) { gusWorldRoomInfo[ MAPROWCOLTOPOS( cnt1, cnt2 ) ] = usRoomNum; } } }
BOOLEAN RemoveSpecialTileRange( SGPRect *pSelectRegion ) { INT32 cnt1, cnt2; for ( cnt1 = pSelectRegion->iTop; cnt1 <= pSelectRegion->iBottom; cnt1++ ) { for ( cnt2 = pSelectRegion->iLeft; cnt2 <= pSelectRegion->iRight; cnt2++ ) { RemoveObject( MAPROWCOLTOPOS( cnt1, cnt2 ), SPECIALTILE_MAPEXIT ); } } return( TRUE ); }
// @@ATECLIP TO WORLD! void SetRecalculateWireFrameFlagRadius(INT16 sX, INT16 sY, INT16 sRadius) { INT16 sCountX, sCountY; UINT32 uiTile; for(sCountY=sY-sRadius; sCountY < (sY+sRadius+2); sCountY++) { for(sCountX=sX-sRadius; sCountX < (sX+sRadius+2); sCountX++) { uiTile=MAPROWCOLTOPOS(sCountY, sCountX); gpWorldLevelData[uiTile].uiFlags |= MAPELEMENT_RECALCULATE_WIREFRAMES; } } }
void GetGridNoForViewPort( const INT32& ubX, const INT32& ubY, INT32& sGridNo ) { sGridNo = MAPROWCOLTOPOS( ubY, ubX ); }
void UpdateCursorAreas() { INT32 x, y, iMapIndex; RemoveCursors(); EnsureSelectionType(); //Determine if the mouse is currently in the world. if( gViewportRegion.uiFlags & MSYS_MOUSE_IN_AREA && GetMouseXY( &sGridX, &sGridY ) ) { iMapIndex = MAPROWCOLTOPOS( sGridY, sGridX ); if( gpBuildingLayoutList ) { gSelectRegion.iLeft = gSelectRegion.iRight = sGridX; gSelectRegion.iTop = gSelectRegion.iBottom = sGridY; fValidCursor = TRUE; DrawBuildingLayout( iMapIndex ); } else switch( gusSelectionType ) { case SMALLSELECTION: gSelectRegion.iLeft = gSelectRegion.iRight = sGridX; gSelectRegion.iTop = gSelectRegion.iBottom = sGridY; fValidCursor = TRUE; break; case MEDIUMSELECTION: case LARGESELECTION: case XLARGESELECTION: //The mouse mode value reflects the size of the cursor. gSelectRegion.iTop = sGridY - gusSelectionType; gSelectRegion.iBottom = sGridY + gusSelectionType; gSelectRegion.iLeft = sGridX - gusSelectionType; gSelectRegion.iRight = sGridX + gusSelectionType; ValidateSelectionRegionBoundaries(); fValidCursor = TRUE; break; case LINESELECTION: fValidCursor = HandleAreaSelection(); ForceAreaSelectionWidth(); ValidateSelectionRegionBoundaries(); break; case AREASELECTION: fValidCursor = HandleAreaSelection(); break; } } //Draw all of the area cursors here. if( fValidCursor ) { if( iDrawMode == DRAW_MODE_ENEMY || iDrawMode == DRAW_MODE_CREATURE || iDrawMode == DRAW_MODE_REBEL || iDrawMode == DRAW_MODE_CIVILIAN || iDrawMode == DRAW_MODE_SCHEDULEACTION ) { iMapIndex = gSelectRegion.iTop * WORLD_COLS + gSelectRegion.iLeft; if( !IsLocationSittable( iMapIndex, gfRoofPlacement ) && iDrawMode != DRAW_MODE_SCHEDULEACTION || !IsLocationSittableExcludingPeople( iMapIndex, gfRoofPlacement ) && iDrawMode == DRAW_MODE_SCHEDULEACTION ) { if( sBadMarker != iMapIndex ) { RemoveBadMarker(); if( gfRoofPlacement && FlatRoofAboveGridNo( iMapIndex ) ) { AddTopmostToTail( iMapIndex + ROOF_OFFSET, BADMARKER1 ); sBadMarker = (INT16)(iMapIndex + ROOF_OFFSET ); } else { AddTopmostToTail( (iMapIndex), BADMARKER1 ); sBadMarker = (INT16)(iMapIndex); } } } else { RemoveBadMarker(); if( gfRoofPlacement && FlatRoofAboveGridNo( iMapIndex ) ) { AddTopmostToTail( iMapIndex + ROOF_OFFSET, FIRSTPOINTERS5 ); gfUsingOffset = TRUE; } else AddTopmostToTail( iMapIndex, FIRSTPOINTERS1 ); } } else for( y = gSelectRegion.iTop; y <= gSelectRegion.iBottom; y++ ) { for( x = gSelectRegion.iLeft; x <= gSelectRegion.iRight; x++ ) { iMapIndex = y * WORLD_COLS + x; AddTopmostToTail( iMapIndex, FIRSTPOINTERS1 ); } } } }