2013-05-25 00:51:02 +02:00
|
|
|
/*
|
|
|
|
Minetest
|
|
|
|
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2013-05-25 00:51:02 +02:00
|
|
|
#include "cpp_api/s_base.h"
|
2013-08-11 04:09:45 +02:00
|
|
|
#include "cpp_api/s_entity.h"
|
2013-05-25 00:51:02 +02:00
|
|
|
#include "cpp_api/s_env.h"
|
|
|
|
#include "cpp_api/s_inventory.h"
|
2017-09-26 00:11:20 +02:00
|
|
|
#include "cpp_api/s_modchannels.h"
|
2013-08-11 04:09:45 +02:00
|
|
|
#include "cpp_api/s_node.h"
|
|
|
|
#include "cpp_api/s_player.h"
|
|
|
|
#include "cpp_api/s_server.h"
|
2014-09-06 02:08:51 +02:00
|
|
|
#include "cpp_api/s_security.h"
|
2022-05-02 20:55:04 +02:00
|
|
|
#include "cpp_api/s_async.h"
|
|
|
|
|
|
|
|
struct PackedValue;
|
2013-05-25 00:51:02 +02:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-01-21 15:02:08 +01:00
|
|
|
/* Scripting <-> Server Game Interface */
|
2013-05-25 00:51:02 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
2017-01-21 15:02:08 +01:00
|
|
|
class ServerScripting:
|
2014-09-06 02:08:51 +02:00
|
|
|
virtual public ScriptApiBase,
|
|
|
|
public ScriptApiDetached,
|
|
|
|
public ScriptApiEntity,
|
|
|
|
public ScriptApiEnv,
|
2017-09-26 00:11:20 +02:00
|
|
|
public ScriptApiModChannels,
|
2014-09-06 02:08:51 +02:00
|
|
|
public ScriptApiNode,
|
|
|
|
public ScriptApiPlayer,
|
|
|
|
public ScriptApiServer,
|
|
|
|
public ScriptApiSecurity
|
2013-05-25 00:51:02 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-01-21 15:02:08 +01:00
|
|
|
ServerScripting(Server* server);
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2013-08-11 04:09:45 +02:00
|
|
|
// use ScriptApiBase::loadMod() to load mods
|
2013-05-25 00:51:02 +02:00
|
|
|
|
2022-05-02 20:55:04 +02:00
|
|
|
// Initialize async engine, call this AFTER loading all mods
|
|
|
|
void initAsync();
|
|
|
|
|
|
|
|
// Global step handler to collect async results
|
|
|
|
void stepAsync();
|
|
|
|
|
|
|
|
// Pass job to async threads
|
|
|
|
u32 queueAsync(std::string &&serialized_func,
|
|
|
|
PackedValue *param, const std::string &mod_origin);
|
|
|
|
|
2013-05-25 00:51:02 +02:00
|
|
|
private:
|
2013-08-11 04:09:45 +02:00
|
|
|
void InitializeModApi(lua_State *L, int top);
|
2022-05-02 20:55:04 +02:00
|
|
|
|
|
|
|
static void InitializeAsync(lua_State *L, int top);
|
|
|
|
|
|
|
|
AsyncEngine asyncEngine;
|
2013-05-25 00:51:02 +02:00
|
|
|
};
|