Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
scripting_server.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6#include "cpp_api/s_base.h"
7#include "cpp_api/s_entity.h"
8#include "cpp_api/s_env.h"
11#include "cpp_api/s_node.h"
12#include "cpp_api/s_player.h"
13#include "cpp_api/s_server.h"
14#include "cpp_api/s_security.h"
15#include "cpp_api/s_async.h"
16
17struct PackedValue;
18
19/*****************************************************************************/
20/* Scripting <-> Server Game Interface */
21/*****************************************************************************/
22
24 virtual public ScriptApiBase,
25 public ScriptApiDetached,
26 public ScriptApiEntity,
27 public ScriptApiEnv,
29 public ScriptApiNode,
30 public ScriptApiPlayer,
31 public ScriptApiServer,
33{
34public:
36
37 void loadBuiltin();
38 // use ScriptApiBase::loadMod() to load mods
39
40 // Save globals that are copied into other Lua envs
41 void saveGlobals();
42
43 // Initialize async engine, call this AFTER loading all mods
44 void initAsync();
45
46 // Global step handler to collect async results
47 void stepAsync();
48
49 // Pass job to async threads
50 u32 queueAsync(std::string &&serialized_func,
51 PackedValue *param, const std::string &mod_origin);
52
53protected:
54 // from ScriptApiSecurity:
55 bool checkPathInternal(const std::string &abs_path, bool write_required,
56 bool *write_allowed) override {
58 abs_path, write_required, write_allowed);
59 }
60 bool modNamesAreTrusted() override { return true; }
61
62private:
63 void InitializeModApi(lua_State *L, int top);
64
65 static void InitializeAsync(lua_State *L, int top);
66
68};
Definition s_async.h:67
Definition s_base.h:64
lua_State * getStack()
Definition s_base.h:143
Definition s_inventory.h:14
Definition s_entity.h:17
Definition s_env.h:18
Definition s_modchannels.h:12
Definition s_node.h:18
Definition s_player.h:19
Definition s_security.h:28
static bool checkPathWithGamedef(lua_State *L, const std::string &abs_path, bool write_required, bool *write_allowed)
Definition s_security.cpp:607
Definition s_server.h:12
Definition scripting_server.h:33
void loadBuiltin()
Definition scripting_server.cpp:79
bool modNamesAreTrusted() override
Specify if the mod names during init time(!) can be trusted.
Definition scripting_server.h:60
u32 queueAsync(std::string &&serialized_func, PackedValue *param, const std::string &mod_origin)
Definition scripting_server.cpp:123
ServerScripting(Server *server)
Definition scripting_server.cpp:40
void InitializeModApi(lua_State *L, int top)
Definition scripting_server.cpp:130
AsyncEngine asyncEngine
Definition scripting_server.h:67
void saveGlobals()
Definition scripting_server.cpp:85
void initAsync()
Definition scripting_server.cpp:102
bool checkPathInternal(const std::string &abs_path, bool write_required, bool *write_allowed) override
Should check if the given path may be accessed.
Definition scripting_server.h:55
static void InitializeAsync(lua_State *L, int top)
Definition scripting_server.cpp:169
void stepAsync()
Definition scripting_server.cpp:118
Definition server.h:166
Definition activeobjectmgr.cpp:11
A packed value can be a primitive like a string or number but also a table including all of its conte...
Definition c_packer.h:72