1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-05 19:31:04 +00:00
luanti/src/script/scripting_server.h
y5nw f390137d6e
Add API to cancel async jobs (#14602)
* Implement API to cancel async jobs

Co-authored-by: sfan5 <sfan5@live.de>

* update AsyncJob:cancel documentation from review

* Use IPC to unblock async

* review

* review async unblocking

* review

* Apply suggestions from code review

Co-authored-by: sfan5 <sfan5@live.de>

* minor licensing

---------

Co-authored-by: y5nw <y5nw@protonmail.com>
Co-authored-by: sfan5 <sfan5@live.de>
2025-08-26 12:40:31 +02:00

60 lines
1.7 KiB
C++

// Luanti
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
#pragma once
#include "cpp_api/s_base.h"
#include "cpp_api/s_entity.h"
#include "cpp_api/s_env.h"
#include "cpp_api/s_inventory.h"
#include "cpp_api/s_modchannels.h"
#include "cpp_api/s_node.h"
#include "cpp_api/s_player.h"
#include "cpp_api/s_server.h"
#include "cpp_api/s_security.h"
#include "cpp_api/s_async.h"
struct PackedValue;
/*****************************************************************************/
/* Scripting <-> Server Game Interface */
/*****************************************************************************/
class ServerScripting:
virtual public ScriptApiBase,
public ScriptApiAsync,
public ScriptApiDetached,
public ScriptApiEntity,
public ScriptApiEnv,
public ScriptApiModChannels,
public ScriptApiNode,
public ScriptApiPlayer,
public ScriptApiServer,
public ScriptApiSecurity
{
public:
ServerScripting(Server* server);
void loadBuiltin();
// use ScriptApiBase::loadMod() to load mods
// Save globals that are copied into other Lua envs
void saveGlobals();
// Initialize async engine, call this AFTER loading all mods
void initAsync() override;
protected:
// from ScriptApiSecurity:
bool checkPathInternal(const std::string &abs_path, bool write_required,
bool *write_allowed) override {
return ScriptApiSecurity::checkPathWithGamedef(getStack(),
abs_path, write_required, write_allowed);
}
bool modNamesAreTrusted() override { return true; }
private:
void InitializeModApi(lua_State *L, int top);
static void InitializeAsync(lua_State *L, int top);
};