2023-10-19 19:42:33 -04:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// DATAPACK
|
|
|
|
|
//
|
|
|
|
|
// Invocations contain a field 'datapack' which contains additional
|
|
|
|
|
// data for the invocation, packed up in a serialized format. Executing
|
|
|
|
|
// the invocation involves unpacking the datapack.
|
|
|
|
|
//
|
|
|
|
|
// The actual contents of the datapack depends on the type of invocation:
|
|
|
|
|
//
|
2025-06-13 21:03:13 -04:00
|
|
|
// AccessKind::INVALID:
|
2023-10-19 19:42:33 -04:00
|
|
|
//
|
|
|
|
|
// Nothing.
|
|
|
|
|
//
|
2025-06-13 21:03:13 -04:00
|
|
|
// AccessKind::LUA_CALL:
|
2024-08-29 17:45:05 -04:00
|
|
|
//
|
|
|
|
|
// A lua function call. The class name, the function name, and then
|
|
|
|
|
// the function arguments.
|
2024-02-07 15:59:17 -05:00
|
|
|
//
|
2025-06-13 21:03:13 -04:00
|
|
|
// AccessKind::INVOKE_LUA_EXPR:
|
2023-10-19 19:42:33 -04:00
|
|
|
//
|
|
|
|
|
// A block of lua source code, in plaintext.
|
|
|
|
|
//
|
2025-06-13 21:03:13 -04:00
|
|
|
// AccessKind::INVOKE_FLUSH_PRINTS:
|
2023-10-19 19:42:33 -04:00
|
|
|
//
|
|
|
|
|
// Line number in ascii.
|
|
|
|
|
//
|
2025-06-13 21:03:13 -04:00
|
|
|
// AccessKind::INVOKE_TICK:
|
2023-10-19 19:42:33 -04:00
|
|
|
//
|
|
|
|
|
// Nothing.
|
|
|
|
|
//
|
2025-06-13 21:03:13 -04:00
|
|
|
// AccessKind::INVOKE_LUA_SOURCE:
|
2023-10-19 19:42:33 -04:00
|
|
|
//
|
|
|
|
|
// Packaged lua sourcecode. See drvutil::package_lua_source.
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2026-02-25 01:58:19 -05:00
|
|
|
#pragma once
|
2021-07-19 15:32:34 -04:00
|
|
|
|
2022-02-23 23:08:28 -05:00
|
|
|
#include "wrap-string.hpp"
|
|
|
|
|
#include "wrap-map.hpp"
|
|
|
|
|
#include "wrap-deque.hpp"
|
2021-07-19 15:32:34 -04:00
|
|
|
#include "streambuffer.hpp"
|
2024-09-02 21:48:24 -04:00
|
|
|
#include "enginewrapper.hpp"
|
2021-07-19 15:32:34 -04:00
|
|
|
|
|
|
|
|
|
2023-10-23 20:57:47 -04:00
|
|
|
class Invocation : public eng::opnew {
|
2021-07-19 15:32:34 -04:00
|
|
|
public:
|
|
|
|
|
private:
|
2025-06-13 21:03:13 -04:00
|
|
|
AccessKind kind_;
|
2021-07-19 15:32:34 -04:00
|
|
|
int64_t actor_;
|
|
|
|
|
int64_t place_;
|
2023-10-19 19:42:33 -04:00
|
|
|
eng::string datapack_;
|
2021-07-19 15:32:34 -04:00
|
|
|
public:
|
|
|
|
|
Invocation();
|
2025-06-13 21:03:13 -04:00
|
|
|
Invocation(AccessKind kind, int64_t actor, int64_t place, std::string_view datapack);
|
2021-11-16 12:20:11 -05:00
|
|
|
|
2025-06-13 21:03:13 -04:00
|
|
|
bool valid() const { return kind_ != AccessKind::INVALID; }
|
|
|
|
|
AccessKind kind() const { return kind_; }
|
2021-07-19 15:32:34 -04:00
|
|
|
int64_t actor() const { return actor_; }
|
|
|
|
|
int64_t place() const { return place_; }
|
2023-10-19 19:42:33 -04:00
|
|
|
const eng::string &datapack() const { return datapack_; }
|
2021-07-19 15:32:34 -04:00
|
|
|
|
|
|
|
|
void serialize(StreamBuffer *sb) const;
|
|
|
|
|
void deserialize(StreamBuffer *sb);
|
2021-11-11 16:23:11 -05:00
|
|
|
|
2023-04-10 16:00:47 -04:00
|
|
|
eng::string debug_string() const;
|
2021-07-19 15:32:34 -04:00
|
|
|
};
|
|
|
|
|
|
2023-10-23 20:57:47 -04:00
|
|
|
using UniqueInvocation = std::unique_ptr<Invocation>;
|
|
|
|
|
|
2022-02-24 02:17:41 -05:00
|
|
|
class InvocationQueue : public eng::deque<Invocation> {
|
2021-07-19 15:32:34 -04:00
|
|
|
};
|