Beispiel #1
0
float SmoothSailingCallback(
        float   inElapsedSinceLastCall,
        float   inElapsedTimeSinceLastFlightLoop,
        int     inCounter,
        void    *inRefcon) {

    /* get altitude - it's used in a number of places */
    float alt_agl = XPLMGetDataf( ref_alt_agl );
    float alt_msl = XPLMGetDataf( ref_alt_msl );
    
    /* only reset time if we think there's a reason to do it (set elsewhere)
     * and if the plane is not in the air */
    if( reset_time && alt_agl < 1 ) {
        resetTime();
    }
    else {
        reset_time = false;
    }

    setVisibility();
    setCloudBase( alt_agl, alt_msl );
    setWind( alt_agl, alt_msl );
    setTurbulence();

    return CALLBACK_INTERVAL;
}
Beispiel #2
0
void climate_setState(DateTime theDate)
//
//  Input:   theDate = simulation date
//  Output:  none
//  Purpose: sets climate variables for current date.
//
{
    if ( Fclimate.mode == USE_FILE ) updateFileValues(theDate);
    if ( Temp.dataSource != NO_TEMP ) setTemp(theDate);
    setEvap(theDate);
    setWind(theDate);
}
Beispiel #3
0
void Application::reset(){
	tank1->setHealth(5);
	tank2->setHealth(5);
	tank1->setPositionX(TANK1_POS_X);
	tank1->setPositionY(TANK1_POS_Y);
	tank2->setPositionX(TANK2_POS_X);
	tank2->setPositionY(TANK2_POS_Y);
	toChangeTurn = false;
	firedMissile = false;
	player1Turn = true;
	player2Turn = false;
	terrain->reloadTexture();
	setWind(0);
}
Beispiel #4
0
void climate_setState(DateTime theDate)
//
//  Input:   theDate = simulation date
//  Output:  none
//  Purpose: sets climate variables for current date.
//
{
    if ( Fclimate.mode == USE_FILE ) updateFileValues(theDate);
    if ( Temp.dataSource != NO_TEMP ) setTemp(theDate);
    setEvap(theDate);
    setWind(theDate);
    Adjust.rainFactor = Adjust.rain[datetime_monthOfYear(theDate)-1];          //(5.1.007)
    Adjust.hydconFactor = Adjust.hydcon[datetime_monthOfYear(theDate)-1];      //(5.1.008)
    setNextEvapDate(theDate);                                                  //(5.1.008)
}
Beispiel #5
0
void WeatherPlugin::element_end(const char *el)
{
    if (!strcmp(el, "obst")){
        setLocation(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "lsup")){
        setUpdated(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "sunr") && m_bCC){
        setSun_raise(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "suns") && m_bCC){
        setSun_set(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "vis") && m_bCC){
        setVisibility(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "tmp") && m_bCC){
        setTemperature(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "flik") && m_bCC){
        setFeelsLike(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "devp") && m_bCC){
        setDewPoint(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "hmid") && m_bCC){
        setHumidity(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "low") && m_day){
        setMinT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "hi") && m_day){
        setMaxT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "t")){
        if (!m_bBar && !m_bWind && !m_bUv){
			if (m_bCC){
				setConditions(m_data.c_str());
			}else{
				setDayConditions(m_day, m_data.c_str());
			}
		}
        if (m_bWind && m_bCC)
            setWind(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "icon")){
		if (m_bCC){
			setIcon(atol(m_data.c_str()));
		}else{
			setDayIcon(m_day, m_data.c_str());
		}
        m_data = "";
        return;
    }
    if (!strcmp(el, "ut")){
        setUT(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "up")){
        setUP(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "us")){
        setUS(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "gust") && m_bCC){
        setWindGust(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "bar")){
        m_bBar = false;
        return;
    }
    if (!strcmp(el, "cc")){
        m_bCC = false;
        return;
    }
    if (!strcmp(el, "r") && m_bBar && m_bCC){
        unsigned long v = 0;
        for (const char *p = m_data.c_str(); *p; p++){
            if (*p == '.')
                break;
            if (*p == ',')
                continue;
            v = (v * 10) + (*p - '0');
        }
        setPressure(v);
        return;
    }
    if (!strcmp(el, "d") && m_bBar && m_bCC){
		setPressureD(m_data.c_str());
		m_data = "";
		return;
	}
    if (!strcmp(el, "wind")){
        m_bWind = false;
        return;
    }
    if (!strcmp(el, "s") && m_bWind && m_bCC){
        setWind_speed(atol(m_data.c_str()));
        return;
    }
    if (!strcmp(el, "uv")){
        m_bUv = false;
        return;
    }
}
Beispiel #6
0
void Application::handleReceivedData(){
	static bool goUp = false;
	static bool goDown = false;
	//server part
	if((isServer && player2Turn) && server != NULL){
		if (server->clientConnected()) {	
			if (server->receiveData(&receivedData, PACKET_SIZE)) {
				if(receivedData.type == 1){	
					if(receivedData.data > player2->tank->getPositionX()){
						player2->tank->moveRight();
						player2->tankAnimation->runForward();
					}
					if(receivedData.data < player2->tank->getPositionX()){
						player2->tank->moveLeft();
						player2->tankAnimation->runBackward();
					}
				}
				if(receivedData.type == 2){
					if(receivedData.data){
						tank2->fire();
						firedMissile = true;
					}
				}
				if(receivedData.type == 3){
					if(receivedData.data){
						player2->tank->weapon->incDegrees();
						player2->weaponAnimation->runForward();
					}
				}
				if(receivedData.type == 4){
					if(receivedData.data){
						player2->tank->weapon->decDegrees();
						player2->weaponAnimation->runBackward();
					}
				}
				if(receivedData.type == 5){
					setWind(receivedData.data);
				}
			}		
		}
	}
	//client part
	else if((isClient && player1Turn) && client != NULL){
		if (client->receiveData(&receivedData, PACKET_SIZE)){
			if(receivedData.type == 1){
				if(receivedData.data > player1->tank->getPositionX()){
					player1->tank->moveRight();
					player1->tankAnimation->runForward();
				}
				else if(receivedData.data < player1->tank->getPositionX()){
					player1->tank->moveLeft();
					player1->tankAnimation->runBackward();
				}	
			}
				
			if(receivedData.type == 2){
				if(receivedData.data){
					tank1->fire();
					firedMissile = true;
				}
			}
			if(receivedData.type == 3){
				if(receivedData.data){
					player1->tank->weapon->decDegrees();
					player1->weaponAnimation->runForward();
				}
			}
			if(receivedData.type == 4){
				if(receivedData.data){
					player1->tank->weapon->incDegrees();
					player1->weaponAnimation->runBackward();
				}
			}
			if(receivedData.type == 5){
				setWind(receivedData.data);
			}
			if(receivedData.type == 6){
				if(receivedData.data){
					reset();
				}
			}
		}
	}
}
Beispiel #7
0
/***************************************************************
*
*	ascent:
*	This function creates the predicted path of the balloon in 
*	the ascent
*
***************************************************************/
void Predictor::ascent ( )
{
	PredictedNode older, newer;
	int n(0);
	double h(SPLIT), z(0), zPrime(0), uPrime1(0), vPrime1(0), uPrime2(0), vPrime2(0);
	list<WindNode>::iterator movewind = _balloon->getWindTable().begin();

	//sets z to the current altitude of the balloon
	z = _balloon->getLatestPoint().getAlt();

	//moves the wind list iterator into the correct position based on altitude
	while ( movewind != _balloon->getWindTable().end() &&
		(*movewind).getAlt() < _balloon->getLatestPoint().getAlt() )
		++movewind;

	//set incoming point interval
	setInterval();

	//wind check to overwrite
	if ( movewind != _balloon->getWindTable().begin() )
	{
		--movewind;
		if ( (*(movewind)).getNoaa() )
			setWind( (*(movewind)).getAlt() );
		++movewind;
	}

	zPrime = _ascentRate;

	//sets older to the most recent point from the balloon
	older.setAltPre ( _balloon->getLatestPoint().getAlt() );
	older.setLatPre ( _balloon->getLatestPoint().getLat() );
	older.setLonPre ( _balloon->getLatestPoint().getLon() );
	older.setTimePre( _balloon->getLatestPoint().getTime() );

	//clears the last predicted point list
	_balloon->getPrePointAscent().clear();

	//loops while the predicted altitude(z) is less than the burst altitude
	while( older.getAltPre() < getBurstAlt() )
	{
		//move the wind list iterator into a new position if necessary
		if ( movewind != _balloon->getWindTable().end() && older.getAltPre() > (*movewind).getAlt() )
		{
			++movewind;
		}

		if ( movewind == _balloon->getWindTable().end() )
			--movewind;
		
		//sets the predicted node to be stored
		newer.setAltPre( older.getAltPre() + ( _ascentRate * _balloon->getInterval() ) * MULTIPLE );
		newer.setLatPre( older.getLatPre() + ( latVelocity( (*movewind).getLatVelocity(), older.getAltPre () ) * _balloon->getInterval() ) * MULTIPLE );
		newer.setLonPre( older.getLonPre() + ( lonVelocity( (*movewind).getLonVelocity(), older.getAltPre (), older.getLatPre() ) * _balloon->getInterval() ) * MULTIPLE );
		newer.setTimePre( older.getTimePre() + ( _balloon->getInterval() ) );

		//stores the predicted point in the Predicted points list
		_balloon->getPrePointAscent().push_back( newer );
		older = newer;
	}
}
void WeatherPlugin::element_end(const char *el)
{
    if (!strcmp(el, "day")){
        if ((*getMinT(m_day) == 0) || (*getMaxT(m_day) == 0))
            m_day--;
        return;
    }
    if (!strcmp(el, "obst")){
        setLocation(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "lsup")){
        setUpdated(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "sunr") && (m_day == 0)){
        setSun_raise(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "suns") && (m_day == 0)){
        setSun_set(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "vis") && m_bCC){
        setVisibility(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "tmp") && m_bCC){
        setTemperature(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "flik") && m_bCC){
        setFeelsLike(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "dewp") && m_bCC){
        setDewPoint(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "ppcp") && (m_day == 1) ) {
        if (((m_bDayPart == 'd') && m_bDayForecastIsValid) || ((m_bDayPart == 'n') && ! m_bDayForecastIsValid )){
    	    setPrecipitation(atol(m_data.c_str()));
    	    m_data = "";
    	    return;
	}
    }	
    if (!strcmp(el, "hmid") && m_bCC){
        setHumidity(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "low") && m_day){
        if (m_data == "N/A")
            m_data = "";
        setMinT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "hi") && m_day){
        if (m_data == "N/A")
            m_data = "-255";
        setMaxT(m_day, m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "t")){
        if (!m_bBar && !m_bWind && !m_bUv && !m_bMoon){
            if (m_bCC){
                setConditions(m_data.c_str());
            }else{
                setDayConditions(m_day, m_data.c_str());
		if ((m_data == "N/A") && (m_bDayPart == 'd')) 
		    m_bDayForecastIsValid = false;
            }
        }
        if (m_bWind && m_bCC)
            setWind(m_data.c_str());
        if (m_bUv && m_bCC)
            setUV_Description(m_data.c_str());
        if (m_bMoon && m_bCC)
            setMoonPhase(m_data.c_str());

        m_data = "";
        return;
    }
    if (!strcmp(el, "i")) {
        if (m_bUv && m_bCC)
            setUV_Intensity(strtol(m_data.c_str(),NULL,10));
        m_data = "";
        return;
    }
    if (!strcmp(el, "icon")){
        if (m_bMoon && m_bCC) {
            setMoonIcon(atol(m_data.c_str()));
        } else if (m_bCC){
            setIcon(atoul(m_data.c_str()));
        }else{
            setDayIcon(m_day, m_data.c_str());
        }
        m_data = "";
        return;
    }
    if (!strcmp(el, "ut")){
        setUT(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "up")){
        setUP(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "us")){
        setUS(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "ud")){
        setUD(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "gust") && m_bCC){
        setWindGust(atol(m_data.c_str()));
        m_data = "";
        return;
    }
    if (!strcmp(el, "bar")){
        m_bBar = false;
        return;
    }
    if (!strcmp(el, "cc")){
        m_bCC = false;
        return;
    }
    if (!strcmp(el, "r") && m_bBar && m_bCC){
        unsigned long v = 0;
        for (const char *p = m_data.c_str(); *p; p++){
            if (*p == '.')
                break;
            if (*p == ',')
                continue;
            v = (v * 10) + (*p - '0');
        }
        setPressure(v);
        return;
    }
    if (!strcmp(el, "d") && m_bBar && m_bCC){
        setPressureD(m_data.c_str());
        m_data = "";
        return;
    }
    if (!strcmp(el, "wind")){
        m_bWind = false;
        return;
    }
    if (!strcmp(el, "s") && m_bWind && m_bCC){
        setWind_speed(atol(m_data.c_str()));
        return;
    }
    if (!strcmp(el, "uv")){
        m_bUv = false;
        return;
    }
    if (!strcmp(el, "moon")){
        m_bMoon = false;
        return;
    }
}
Beispiel #9
0
void WeatherPlugin::element_end(const char *el)
{
	if (!strcmp(el, "obst")){
		setLocation(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "lsup")){
		setUpdated(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "sunr")){
		setSun_raise(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "suns")){
		setSun_set(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "tmp")){
		setTemperature(atol(m_data.c_str()));
		m_data = "";
		return;
	}
	if (!strcmp(el, "hmid")){
		setHumidity(atol(m_data.c_str()));
		m_data = "";
		return;
	}
	if (!strcmp(el, "t")){
		if (!m_bBar && !m_bWind && !m_bUv)
			setConditions(m_data.c_str());
		if (m_bWind)
			setWind(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "icon")){
		setIcon(atol(m_data.c_str()));
		m_data = "";
		return;
	}
	if (!strcmp(el, "ut")){
		setUT(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "up")){
		setUP(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "us")){
		setUS(m_data.c_str());
		m_data = "";
		return;
	}
	if (!strcmp(el, "bar")){
		m_bBar = false;
		return;
	}
	if (!strcmp(el, "r") && m_bBar){
		unsigned long v = 0;
		for (const char *p = m_data.c_str(); *p; p++){
			if (*p == '.')
				break;
			if (*p == ',')
				continue;
			v = (v * 10) + (*p - '0');
		}
		setPressure(v);
		return;
	}
	if (!strcmp(el, "wind")){
		m_bWind = false;
		return;
	}
	if (!strcmp(el, "s") && m_bWind){
		setWind_speed(atol(m_data.c_str()));
		return;
	}
	if (!strcmp(el, "uv")){
		m_bUv = false;
		return;
	}
}