1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 // #include "game_share/property_manager_template.h"
24 // #include "game_share/property_manager_container_template.h"
25 #include "game_share/cdb.h"
26 #include "game_share/cdb_leaf.h"
27 #include "game_share/cdb_branch.h"
28 #include "game_share/cdb_synchronised.h"
30 using namespace NLMISC
;
33 CMirrorPropValue
< float > CWeather::_RyzomTime
;
34 CMirrorPropValue
< uint8
> CWeather::_DayCycle
;
36 //-----------------------------------------------
38 //-----------------------------------------------
41 NL_ALLOC_CONTEXT(WTHR_INIT
);
42 WeatherCfg
.load( WeatherFileName
);
47 CPropertyManager
* manager
= CContainerPropertyEmiter::getPropertyManager( string("RyzomTime") );
50 manager
= new CSpecializedPropertyManager
<float>( "RyzomTime", 0);
51 CContainerPropertyEmiter::addPropertyManager( manager
);
53 static_cast<CSpecializedPropertyManager
<float> *>(manager
)->addProperty( RYZOMID::World
, &_RyzomTime
);
55 manager
= CContainerPropertyEmiter::getPropertyManager( string("DayCycle") );
58 manager
= new CSpecializedPropertyManager
<uint8
>( "DayCycle", 0);
59 CContainerPropertyEmiter::addPropertyManager( manager
);
61 static_cast<CSpecializedPropertyManager
<uint8
> *>(manager
)->addProperty( RYZOMID::World
, &_DayCycle
);
64 //-----------------------------------------------
66 //-----------------------------------------------
67 void CWeather::updateRyzomTime()
69 uint32 Time
= (uint32
) ( CTickEventHandler::getGameTime() + 500) % ( (uint32
) ( WeatherCfg
.RealDayLength
) );
70 float RyzomTime
= Time
* WeatherCfg
.NumHours
/ WeatherCfg
.RealDayLength
;
71 _RyzomTime
= RyzomTime
;
73 if( ( RyzomTime
< WeatherCfg
.DawnTransitionStartHour
) || ( RyzomTime
> WeatherCfg
.NightTransitionEndHour
) )
77 else if( RyzomTime
< WeatherCfg
.DawnTransitionEndHour
)
81 else if( RyzomTime
< WeatherCfg
.NightTransitionStartHour
)
91 static string
DawnString("dawn");
92 static string
DayString("day");
93 static string
TwilightString("twilight");
94 static string
NightString("night");
95 static string
UnknownString("Unknown");
97 //-----------------------------------------------
98 // get string of day cycle
99 //-----------------------------------------------
100 const std::string
& CWeather::toString( uint8 c
)
109 return TwilightString
;
113 return UnknownString
;