Esempio n. 1
0
void ExtractAndUpdateMapInfo()
{
    UINT16 str[10];
    INT32 temp;
    BOOLEAN fUpdateLight1 = FALSE;
    //extract light1 colors
    temp = min( GetNumericStrictValueFromField( 1 ), 255 );
    if( temp != -1 && temp != gEditorLightColor.peRed )
    {
        fUpdateLight1 = TRUE;
        gEditorLightColor.peRed = (UINT8)temp;
    }
    temp = min( GetNumericStrictValueFromField( 2 ), 255 );
    if( temp != -1 && temp != gEditorLightColor.peGreen )
    {
        fUpdateLight1 = TRUE;
        gEditorLightColor.peGreen = (UINT8)temp;
    }
    temp = min( GetNumericStrictValueFromField( 3 ), 255 );
    if( temp != -1 && temp != gEditorLightColor.peBlue )
    {
        fUpdateLight1 = TRUE;
        gEditorLightColor.peBlue = (UINT8)temp;
    }
    if( fUpdateLight1 )
    {
        gfEditorForceShadeTableRebuild = TRUE;
        LightSetColors(	&gEditorLightColor, 1 );
        gfEditorForceShadeTableRebuild = FALSE;
    }

    //extract radius
    temp = max( min( GetNumericStrictValueFromField( 4 ), 8 ), 1 );
    if( temp != -1 )
        gsLightRadius = (INT16)temp;
    temp = max( min( GetNumericStrictValueFromField( 5 ), 15 ), 1 );
    if( temp != -1 && temp != gusLightLevel )
    {
        gusLightLevel = (UINT16)temp;
        gfRenderWorld = TRUE;
        ubAmbientLightLevel = (UINT8)(EDITOR_LIGHT_MAX - gusLightLevel);
        LightSetBaseLevel( ubAmbientLightLevel );
        LightSpriteRenderAll();
    }

    temp = (INT8)GetNumericStrictValueFromField( 6 );
    if( temp == -1 )
        gMapInformation.ubRestrictedScrollID = 0;
    else
        gMapInformation.ubRestrictedScrollID = (UINT8)temp;

    //set up fields for exitgrid information
    Get16BitStringFromField( 7, str );
    if( str[0] >= 'a' && str[0] <= 'z' )
        str[0] -= 32; //uppercase it!
    if( str[0] >= 'A' && str[0] <= 'Z' &&
            str[1] >= '0' && str[1] <= '9' )
    {   //only update, if coordinate is valid.
        gExitGrid.ubGotoSectorY = (UINT8)(str[0] - 'A' + 1);
        gExitGrid.ubGotoSectorX = (UINT8)(str[1] - '0');
        if( str[2] >= '0' && str[2] <= '9' )
            gExitGrid.ubGotoSectorX = (UINT8)(gExitGrid.ubGotoSectorX * 10 + str[2] - '0' );
        gExitGrid.ubGotoSectorX = (UINT8)max( min( gExitGrid.ubGotoSectorX, 16 ), 1 );
        gExitGrid.ubGotoSectorY = (UINT8)max( min( gExitGrid.ubGotoSectorY, 16 ), 1 );
    }
    gExitGrid.ubGotoSectorZ    = (UINT8)max( min( GetNumericStrictValueFromField( 8 ), 3 ), 0 );
    gExitGrid.usGridNo					 = (UINT16)max( min( GetNumericStrictValueFromField( 9 ), 25600 ), 0 );

    UpdateMapInfoFields();
}
void ExtractAndUpdateDoorInfo()
{
	LEVELNODE* pNode;
	INT32 num;
	DOOR door;
	BOOLEAN fCursor = FALSE;
	BOOLEAN fCursorExists = FALSE;

	memset( &door, 0, sizeof( DOOR ) );

	door.sGridNo = (INT16)iDoorMapIndex;

	num = min( GetNumericStrictValueFromField( 0 ), NUM_LOCKS-1 );
	door.ubLockID = (UINT8)num;
	SetInputFieldStringWithNumericStrictValue( 0, num );
	if( num >= 0 )
		fCursor = TRUE;

	num = min( max( GetNumericStrictValueFromField( 1 ), 0 ), 10 );
	door.ubTrapID = (UINT8)num;
	SetInputFieldStringWithNumericStrictValue( 1, num );
	if( num )
		fCursor = TRUE;

	num = min( max( GetNumericStrictValueFromField( 2 ), 0 ), 20 );
	if( door.ubTrapID && !num )
		num = 1;  //Can't have a trap without a traplevel!
	door.ubTrapLevel = (UINT8)num;
	SetInputFieldStringWithNumericStrictValue( 2, num );
	if( num )
		fCursor = TRUE;

	if( ButtonList[ iDoorButton[ DOOR_LOCKED ] ]->uiFlags & BUTTON_CLICKED_ON )
	{
		door.fLocked = TRUE;
	}
	else
	{
		door.fLocked = FALSE;
	}

	//Find out if we have a rotating key cursor (we will either add one or remove one)
	pNode = gpWorldLevelData[ iDoorMapIndex ].pTopmostHead;
	while( pNode )
	{
		if( pNode->usIndex == ROTATINGKEY1 )
		{
			fCursorExists = TRUE;
			break;
		}
		pNode = pNode->pNext;
	}
	if( fCursor )
	{ //we have a valid door, so add it (or replace existing)
		if( !fCursorExists )
			AddTopmostToHead( iDoorMapIndex, ROTATINGKEY1 );
		//If the door already exists, the new information will replace it.
		AddDoorInfoToTable( &door );
	}
	else
	{ //if a door exists here, remove it.
		if( fCursorExists )
			RemoveAllTopmostsOfTypeRange( iDoorMapIndex, ROTATINGKEY, ROTATINGKEY );
		RemoveDoorInfoFromTable( iDoorMapIndex );
	}

}