]> git.lizzy.rs Git - minetest.git/blob - src/environment.h
added dedicated server build without irrlicht
[minetest.git] / src / environment.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010 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 ENVIRONMENT_HEADER
21 #define ENVIRONMENT_HEADER
22
23 /*
24         This class is the game's environment.
25         It contains:
26         - The map
27         - Players
28         - Other objects
29         - The current time in the game, etc.
30 */
31
32 #include <list>
33 #include "common_irrlicht.h"
34 #include "player.h"
35 #include "map.h"
36 #include <ostream>
37
38 class Environment
39 {
40 public:
41         // Environment will delete the map passed to the constructor
42         Environment(Map *map, std::ostream &dout);
43         ~Environment();
44         /*
45                 This can do anything to the environment, such as removing
46                 timed-out players.
47                 Also updates Map's timers.
48         */
49         void step(f32 dtime);
50
51         Map & getMap();
52
53         /*
54                 Environment deallocates players after use.
55         */
56         void addPlayer(Player *player);
57         void removePlayer(u16 peer_id);
58 #ifndef SERVER
59         LocalPlayer * getLocalPlayer();
60 #endif
61         Player * getPlayer(u16 peer_id);
62         core::list<Player*> getPlayers();
63         void printPlayers(std::ostream &o);
64
65 #ifndef SERVER
66         void updateMeshes(v3s16 blockpos);
67         void expireMeshes(bool only_daynight_diffed);
68 #endif
69         void setDayNightRatio(u32 r);
70         u32 getDayNightRatio();
71
72 private:
73         Map *m_map;
74         core::list<Player*> m_players;
75         // Debug output goes here
76         std::ostream &m_dout;
77         u32 m_daynight_ratio;
78 };
79
80 #endif
81