Пример #1
0
bool CEnvironment::SetWeatherFX(shared_str name)
{
	if (bWFX)				return false;
	if (name.size()){
		EnvsMapIt it		= WeatherFXs.find(name);
		R_ASSERT3			(it!=WeatherFXs.end(),"Invalid weather effect name.",*name);
		EnvVec* PrevWeather = CurrentWeather; VERIFY(PrevWeather);
		CurrentWeather		= &it->second;
		CurrentWeatherName	= it->first;

		float rewind_tm		= WFX_TRANS_TIME*fTimeFactor;
		float start_tm		= fGameTime+rewind_tm;
		float current_length;
		float current_weight;
		if (Current[0]->exec_time>Current[1]->exec_time){
			float x			= fGameTime>Current[0]->exec_time?fGameTime-Current[0]->exec_time:(DAY_LENGTH-Current[0]->exec_time)+fGameTime;
			current_length	= (DAY_LENGTH-Current[0]->exec_time)+Current[1]->exec_time;
			current_weight	= x/current_length; 
		}else{
			current_length	= Current[1]->exec_time-Current[0]->exec_time;
			current_weight	= (fGameTime-Current[0]->exec_time)/current_length; 
		}
		clamp				(current_weight,0.f,1.f);

		std::sort			(CurrentWeather->begin(),CurrentWeather->end(),sort_env_etl_pred);
		CEnvDescriptor* C0	= CurrentWeather->at(0);
		CEnvDescriptor* C1	= CurrentWeather->at(1);
		CEnvDescriptor* CE	= CurrentWeather->at(CurrentWeather->size()-2);
		CEnvDescriptor* CT	= CurrentWeather->at(CurrentWeather->size()-1);
		C0->copy			(*Current[0]);	C0->exec_time = NormalizeTime(fGameTime-((rewind_tm/(Current[1]->exec_time-fGameTime))*current_length-rewind_tm));
		C1->copy			(*Current[1]);	C1->exec_time = NormalizeTime(start_tm);
		for (EnvIt t_it=CurrentWeather->begin()+2; t_it!=CurrentWeather->end()-1; t_it++)
			(*t_it)->exec_time= NormalizeTime(start_tm+(*t_it)->exec_time_loaded);
		SelectEnv			(PrevWeather,WFX_end_desc[0],CE->exec_time);
		SelectEnv			(PrevWeather,WFX_end_desc[1],WFX_end_desc[0]->exec_time+0.5f);
		CT->copy			(*WFX_end_desc[0]);CT->exec_time = NormalizeTime(CE->exec_time+rewind_tm);
		wfx_time			= TimeDiff(fGameTime,CT->exec_time);
		bWFX				= true;

		// sort wfx envs
		std::sort			(CurrentWeather->begin(),CurrentWeather->end(),sort_env_pred);

		Current[0]			= C0;
		Current[1]			= C1;
#ifdef WEATHER_LOGGING
		Msg					("Starting WFX: '%s' - %3.2f sec",*name,wfx_time);
		for (EnvIt l_it=CurrentWeather->begin(); l_it!=CurrentWeather->end(); l_it++)
			Msg				(". Env: '%s' Tm: %3.2f",*(*l_it)->sect_name,(*l_it)->exec_time);
#endif
	}else{
#ifndef _EDITOR
		FATAL				("! Empty weather effect name");
#endif
	}
	return true;
}
Пример #2
0
timevalue *IncrTime(timevalue *Time, timevalue *Incr) {
    NormalizeTime(Time);
    NormalizeTime(Incr);
    
    Time->Seconds += Incr->Seconds;
    if ((Time->Fraction += Incr->Fraction) >= FullSEC) {
        Time->Seconds++;
        Time->Fraction -= FullSEC;
    }
    return Time;
}
Пример #3
0
timevalue *DecrTime(timevalue *Time, timevalue *Decr) {
    NormalizeTime(Time);
    NormalizeTime(Decr);

    Time->Seconds -= Decr->Seconds;
    if (Time->Fraction >= Decr->Fraction)
        Time->Fraction -= Decr->Fraction;
    else {
        Time->Seconds--;
        Time->Fraction += (FullSEC - Decr->Fraction);
    }
    return Time;
}
Пример #4
0
dat CmpTime(timevalue *T1, timevalue *T2) {
    NormalizeTime(T1);
    NormalizeTime(T2);
    
    if (T1->Seconds > T2->Seconds)
	return (dat)1;
    if (T1->Seconds < T2->Seconds)
	return (dat)-1;
    if (T1->Fraction > T2->Fraction)
        return (dat)1;
    if (T1->Fraction < T2->Fraction)
	    return (dat)-1;
    return (dat)0;
}
Пример #5
0
bool CEnvironment::StartWeatherFXFromTime(shared_str name, float time)
{
	if(!SetWeatherFX(name))				
		return false;

	for (EnvIt it=CurrentWeather->begin(); it!=CurrentWeather->end(); it++)
		(*it)->exec_time = NormalizeTime((*it)->exec_time - wfx_time + time);

	wfx_time = time;
	return true;
}
Пример #6
0
RakNet::TimeUS GetTimeUS_Windows( void )
{
	if ( initialized == false)
	{
		initialized = true;

		// Save the current process
#if !defined(_WIN32_WCE)
//		HANDLE mProc = GetCurrentProcess();

		// Get the current Affinity
#if _MSC_VER >= 1400 && defined (_M_X64)
//		GetProcessAffinityMask(mProc, (PDWORD_PTR)&mProcMask, (PDWORD_PTR)&mSysMask);
#else
//		GetProcessAffinityMask(mProc, &mProcMask, &mSysMask);
#endif
//		mThread = GetCurrentThread();

#endif // _WIN32_WCE
	}	

	// 9/26/2010 In China running LuDaShi, QueryPerformanceFrequency has to be called every time because CPU clock speeds can be different
	RakNet::TimeUS curTime;
	LARGE_INTEGER PerfVal;
	LARGE_INTEGER yo1;

	QueryPerformanceFrequency( &yo1 );
	QueryPerformanceCounter( &PerfVal );

	__int64 quotient, remainder;
	quotient=((PerfVal.QuadPart) / yo1.QuadPart);
	remainder=((PerfVal.QuadPart) % yo1.QuadPart);
	curTime = (RakNet::TimeUS) quotient*(RakNet::TimeUS)1000000 + (remainder*(RakNet::TimeUS)1000000 / yo1.QuadPart);

#if defined(GET_TIME_SPIKE_LIMIT) && GET_TIME_SPIKE_LIMIT>0
	return NormalizeTime(curTime);
#else
	return curTime;
#endif // #if defined(GET_TIME_SPIKE_LIMIT) && GET_TIME_SPIKE_LIMIT>0
}
Пример #7
0
VENet::TimeUS GetTimeUS_Linux( void )
{
    timeval tp;
    if ( initialized == false)
    {
        gettimeofday( &tp, 0 );
        initialized=true;
        initialTime = ( tp.tv_sec ) * (VENet::TimeUS) 1000000 + ( tp.tv_usec );
    }

    // GCC
    VENet::TimeUS curTime;
    gettimeofday( &tp, 0 );

    curTime = ( tp.tv_sec ) * (VENet::TimeUS) 1000000 + ( tp.tv_usec );

#if defined(GET_TIME_SPIKE_LIMIT) && GET_TIME_SPIKE_LIMIT>0
    return NormalizeTime(curTime - initialTime);
#else
return curTime - initialTime;
#endif
}
Пример #8
0
RakNet::TimeUS GetTimeUS_Linux( void )
{
	timeval tp;
	if ( initialized == false)
	{
		gettimeofday( &tp, 0 );
		initialized=true;
		// I do this because otherwise RakNet::Time in milliseconds won't work as it will underflow when dividing by 1000 to do the conversion
		initialTime = ( tp.tv_sec ) * (RakNet::TimeUS) 1000000 + ( tp.tv_usec );
	}

	// GCC
	RakNet::TimeUS curTime;
	gettimeofday( &tp, 0 );

	curTime = ( tp.tv_sec ) * (RakNet::TimeUS) 1000000 + ( tp.tv_usec );

#if defined(GET_TIME_SPIKE_LIMIT) && GET_TIME_SPIKE_LIMIT>0
	return NormalizeTime(curTime - initialTime);
#else
	return curTime - initialTime;
#endif // #if defined(GET_TIME_SPIKE_LIMIT) && GET_TIME_SPIKE_LIMIT>0
}
Пример #9
0
void CEnvironment::ChangeGameTime(float game_time)
{
	fGameTime				= NormalizeTime(fGameTime + game_time);
};
Пример #10
0
ECode CSqlDate::SetTime(
    /* [in] */ Int64 milliseconds)
{
    return Date::SetTime(NormalizeTime(milliseconds));
}
Пример #11
0
ECode CSqlDate::constructor(
    /* [in] */ Int64 theDate)
{
    return Date::constructor(NormalizeTime(theDate));
}