1b075c4faedfd0af4022a791f21e7e8ac16b19b5
[oweals/minetest.git] / src / daynightratio.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef DAYNIGHTRATIO_HEADER
21 #define DAYNIGHTRATIO_HEADER
22
23 inline u32 time_to_daynight_ratio(u32 time_of_day)
24 {
25         s32 t = time_of_day%24000;
26         if(t < 4500 || t >= 19500)
27                 return 150;
28         else if(t < 4750 || t >= 19250)
29                 return 250;
30         else if(t < 5000 || t >= 19000)
31                 return 350;
32         else if(t < 5250 || t >= 18750)
33                 return 500;
34         else if(t < 5500 || t >= 18500)
35                 return 675;
36         else if(t < 5750 || t >= 18250)
37                 return 875;
38         else
39                 return 1000;
40 }
41
42 #endif
43