Fix classique titles display
[ryzomcore.git] / ryzom / client / src / time_client.h
bloba91c49d167aa155d3b44df5fbf613b812ab8a57e
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2012 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef CL_TIME_CLIENT_H
24 #define CL_TIME_CLIENT_H
27 /////////////
28 // INCLUDE //
29 /////////////
30 // Misc.
31 #include "nel/misc/types_nl.h"
32 #include "nel/misc/time_nl.h"
33 // Game Share
34 #include "game_share/time_weather_season/time_and_season.h"
35 #include "client_cfg.h"
37 ///////////
38 // USING //
39 ///////////
40 using NLMISC::TTime;
42 class CClientDate;
44 ////////////
45 // GLOBAL //
46 ////////////
47 extern sint64 T0; // Time for the last frame.
48 extern sint64 T1; // Time for the current frame.
49 extern sint64 TS; // Time since the really first Frame.
50 extern sint64 DT64; // Diff time with current and last frame in ms.
51 extern float DT; // Diff time with current and last frame in sec.
52 extern TTime TSend; // Next Time to send motions.
53 extern TTime DTSend; // Delta of time to generate the next time to send motions.
54 extern double TimeInSec; // Time for the current frame in second.
55 extern double FirstTimeInSec; // Game local origin time
58 extern TTime LCT;
59 extern TTime LocalTimeStep;
60 extern TTime CurrentPacketTime;
61 extern uint8 CurrentPacket;
62 extern uint8 LastPacketReceived;
64 extern NLMISC::TGameCycle LastGameCycle;
66 extern CRyzomTime RT;
68 extern CClientDate SmoothedClientDate;
70 ///////////
71 // CLASS //
72 ///////////
73 class CPacketInfos
75 public:
76 uint8 Num;
77 TTime Min;
78 TTime Max;
80 CPacketInfos() {}
81 CPacketInfos(uint8 num, TTime min, TTime max)
83 Num = num;
84 Min = min;
85 Max = max;
89 /** A representation of time in the client
90 * \author Nicolas Vizerie
91 * \author Nevrax France
92 * \date 2003
94 class CClientDate
96 public:
97 sint32 Day;
98 float Hour;
99 CClientDate(sint32 day = 0, float hour = 0.f) : Day(day), Hour(hour) {}
102 // 'less' comparison between 2 dates
103 inline bool operator < (const CClientDate &lhs, const CClientDate &rhs)
105 if (lhs.Day != rhs.Day) return lhs.Day < rhs.Day;
106 return lhs.Hour < rhs.Hour;
108 // equality between 2 dates
109 inline bool operator == (const CClientDate &lhs, const CClientDate &rhs)
111 return lhs.Day == rhs.Day && lhs.Hour == rhs.Hour;
114 ///////////////
115 // FUNCTIONS //
116 ///////////////
117 void removePacketTime(uint8 numPacket);
119 void insertPacketTime(uint8 numPacket, TTime time);
120 void ackPacketTimeBefore(uint8 ackPacketNumber);
122 void removePacket(uint8 numPacket);
123 /// Insert the packet received information in a list.
124 void insertPacket(const CPacketInfos &packetInfos);
125 /// Return the sent time for a given packet or 0 if the packet is not found
126 TTime getSentPacketTime(uint8 numPacket);
128 // Initialize interface properties linked to the client time
129 void initClientTime();
131 // Release interface properties linked to the client time
132 void releaseClientTime();
134 // This update T0, T1, DT64, DT, TS & TimeInSec
135 void updateClientTime();
137 // update smoothed time (useful for sky animation)
138 void updateSmoothedTime();
140 inline NLMISC::TTime ryzomGetLocalTime()
142 return NLMISC::CTime::getLocalTime();
145 inline NLMISC::TTicks ryzomGetPerformanceTime()
147 return NLMISC::CTime::getPerformanceTime();
151 class CTickRange
153 public:
154 NLMISC::TGameCycle StartTick;
155 NLMISC::TGameCycle EndTick;
156 public:
157 CTickRange(NLMISC::TGameCycle startTick = 0, NLMISC::TGameCycle endTick = 0) : StartTick(startTick), EndTick(endTick) {}
158 void extend(const CTickRange &other)
160 StartTick = std::min(StartTick, other.StartTick);
161 EndTick = std::max(EndTick, other.EndTick);
163 bool isEmpty() const { return StartTick == EndTick; }
166 #endif // CL_TIME_CLIENT_H
168 /* End of time_client.h */