]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/lua_api/l_base.h
Merge remote-tracking branch 'origin/master'
[dragonfireclient.git] / src / script / lua_api / l_base.h
1 /*
2 Minetest
3 Copyright (C) 2013 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 Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser 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 L_BASE_H_
21 #define L_BASE_H_
22
23 #include "biome.h"
24 #include "common/c_types.h"
25
26 extern "C" {
27 #include "lua.h"
28 }
29
30 extern struct EnumString es_BiomeTerrainType[];
31
32 class ScriptApi;
33 class Server;
34 class Environment;
35
36 typedef class ModApiBase {
37
38 public:
39         ModApiBase();
40
41         virtual bool Initialize(lua_State* L, int top) = 0;
42         virtual ~ModApiBase() {};
43
44 protected:
45         static Server* getServer(      lua_State* L);
46         static Environment* getEnv(    lua_State* L);
47         static bool registerFunction(   lua_State* L,
48                                                                         const char* name,
49                                                                         lua_CFunction fct,
50                                                                         int top
51                                                                         );
52 } ModApiBase;
53
54 #if (defined(WIN32) || defined(_WIN32_WCE))
55 #define NO_MAP_LOCK_REQUIRED
56 #else
57 #include "main.h"
58 #include "profiler.h"
59 #define NO_MAP_LOCK_REQUIRED ScopeProfiler nolocktime(g_profiler,"Scriptapi: unlockable time",SPT_ADD)
60 //#define NO_ENVLOCK_REQUIRED assert(getServer(L).m_env_mutex.IsLocked() == false)
61 #endif
62
63 #endif /* L_BASE_H_ */