Improve consistency of naming in 'invoke/access' pipeline.
This commit is contained in:
@@ -217,7 +217,7 @@ void UlxLuaCallLibrary::LuaCallInvoke(UObject *context, AActor *place)
|
|||||||
ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context);
|
ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
if (NotInitialized(sb)) return;
|
if (NotInitialized(sb)) return;
|
||||||
mode->LuaCallEnd(InvocationKind::LUA_INVOKE, place);
|
mode->LuaCallEnd(AccessKind::INVOKE_LUA_CALL, place);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ bool UlxLuaCallLibrary::LuaCallProbe(UObject *context, AActor *place, UlxLuaValu
|
|||||||
ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context);
|
ALuprexGameModeBase *mode = ALuprexGameModeBase::FromContext(context);
|
||||||
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
FlxStreamBuffer &sb = mode->LuaCallGetBuffer();
|
||||||
if (NotInitialized(sb)) return false;
|
if (NotInitialized(sb)) return false;
|
||||||
ReturnArray = mode->LuaCallEnd(InvocationKind::LUA_PROBE, place);
|
ReturnArray = mode->LuaCallEnd(AccessKind::PROBE_LUA_CALL, place);
|
||||||
if ((ReturnArray == nullptr) || (ReturnArray->Length() < 1))
|
if ((ReturnArray == nullptr) || (ReturnArray->Length() < 1))
|
||||||
{
|
{
|
||||||
UE_LOG(LogLuprexIntegration, Error, TEXT("corruption in lua_probe"));
|
UE_LOG(LogLuprexIntegration, Error, TEXT("corruption in lua_probe"));
|
||||||
|
|||||||
@@ -175,14 +175,14 @@ void ALuprexGameModeBase::UpdatePossessedTangible() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UlxLuaValues *ALuprexGameModeBase::LuaCallEnd(InvocationKind kind, int64 place_id) {
|
UlxLuaValues *ALuprexGameModeBase::LuaCallEnd(AccessKind kind, int64 place_id) {
|
||||||
std::string_view datapk = LuaCallBuffer.view();
|
std::string_view datapk = LuaCallBuffer.view();
|
||||||
FlxLockedWrapper w(LockableWrapper);
|
FlxLockedWrapper w(LockableWrapper);
|
||||||
if (place_id == 0) place_id = w.GetActor();
|
if (place_id == 0) place_id = w.GetActor();
|
||||||
uint32_t retpklen;
|
uint32_t retpklen;
|
||||||
const char *retpk;
|
const char *retpk;
|
||||||
w->play_call_function(w.Get(), kind, place_id, datapk.size(), datapk.data(), &retpklen, &retpk);
|
w->play_access(w.Get(), kind, place_id, datapk.size(), datapk.data(), &retpklen, &retpk);
|
||||||
if (kind == InvocationKind::LUA_PROBE)
|
if (kind == AccessKind::PROBE_LUA_CALL)
|
||||||
{
|
{
|
||||||
UlxLuaValues *Result = NewObject<UlxLuaValues>(this);
|
UlxLuaValues *Result = NewObject<UlxLuaValues>(this);
|
||||||
Result->Initialize(std::string_view(retpk, retpklen));
|
Result->Initialize(std::string_view(retpk, retpklen));
|
||||||
@@ -191,11 +191,11 @@ UlxLuaValues *ALuprexGameModeBase::LuaCallEnd(InvocationKind kind, int64 place_i
|
|||||||
else return nullptr;
|
else return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
UlxLuaValues *ALuprexGameModeBase::LuaCallEnd(InvocationKind kind) {
|
UlxLuaValues *ALuprexGameModeBase::LuaCallEnd(AccessKind kind) {
|
||||||
return LuaCallEnd(kind, int64(0));
|
return LuaCallEnd(kind, int64(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
UlxLuaValues *ALuprexGameModeBase::LuaCallEnd(InvocationKind kind, AActor *place) {
|
UlxLuaValues *ALuprexGameModeBase::LuaCallEnd(AccessKind kind, AActor *place) {
|
||||||
if (place == nullptr) {
|
if (place == nullptr) {
|
||||||
return LuaCallEnd(kind, int64(0));
|
return LuaCallEnd(kind, int64(0));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -108,9 +108,9 @@ public:
|
|||||||
//
|
//
|
||||||
FlxStreamBuffer &LuaCallBegin() { LuaCallBuffer.clear(); return LuaCallBuffer; }
|
FlxStreamBuffer &LuaCallBegin() { LuaCallBuffer.clear(); return LuaCallBuffer; }
|
||||||
FlxStreamBuffer &LuaCallGetBuffer() { return LuaCallBuffer; }
|
FlxStreamBuffer &LuaCallGetBuffer() { return LuaCallBuffer; }
|
||||||
UlxLuaValues *LuaCallEnd(InvocationKind kind);
|
UlxLuaValues *LuaCallEnd(AccessKind kind);
|
||||||
UlxLuaValues *LuaCallEnd(InvocationKind kind, int64 place_id);
|
UlxLuaValues *LuaCallEnd(AccessKind kind, int64 place_id);
|
||||||
UlxLuaValues *LuaCallEnd(InvocationKind kind, AActor *place);
|
UlxLuaValues *LuaCallEnd(AccessKind kind, AActor *place);
|
||||||
void LuaCallClear() { LuaCallBuffer.clear(); }
|
void LuaCallClear() { LuaCallBuffer.clear(); }
|
||||||
|
|
||||||
// Execute a debugging command, typed on the GUI.
|
// Execute a debugging command, typed on the GUI.
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ enum DrvAction {
|
|||||||
PLAY_NOTIFY_CLOSE,
|
PLAY_NOTIFY_CLOSE,
|
||||||
PLAY_NOTIFY_ACCEPT,
|
PLAY_NOTIFY_ACCEPT,
|
||||||
PLAY_UPDATE,
|
PLAY_UPDATE,
|
||||||
PLAY_CALL_FUNCTION,
|
PLAY_ACCESS,
|
||||||
PLAY_RELEASE,
|
PLAY_RELEASE,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ inline static const char *action_string(DrvAction act) {
|
|||||||
case PLAY_NOTIFY_CLOSE: return "PLAY_NOTIFY_CLOSE";
|
case PLAY_NOTIFY_CLOSE: return "PLAY_NOTIFY_CLOSE";
|
||||||
case PLAY_NOTIFY_ACCEPT: return "PLAY_NOTIFY_ACCEPT";
|
case PLAY_NOTIFY_ACCEPT: return "PLAY_NOTIFY_ACCEPT";
|
||||||
case PLAY_UPDATE: return "PLAY_UPDATE";
|
case PLAY_UPDATE: return "PLAY_UPDATE";
|
||||||
case PLAY_CALL_FUNCTION: return "PLAY_CALL_FUNCTION";
|
case PLAY_ACCESS: return "PLAY_ACCESS";
|
||||||
case PLAY_RELEASE: return "PLAY_RELEASE";
|
case PLAY_RELEASE: return "PLAY_RELEASE";
|
||||||
default: return "unknown";
|
default: return "unknown";
|
||||||
}
|
}
|
||||||
@@ -475,11 +475,11 @@ void DrivenEngine::drv_update(double clock) {
|
|||||||
event_update();
|
event_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrivenEngine::drv_call_function(InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk, uint32_t *retpklen, const char **retpk) {
|
void DrivenEngine::drv_access(AccessKind kind, int64_t place, uint32_t datapklen, const char *datapk, uint32_t *retpklen, const char **retpk) {
|
||||||
// This next line is a hack, because the DrivenEngine is not supposed to care about 'kind'.
|
// This next line is a hack, because the DrivenEngine is not supposed to care about 'kind'.
|
||||||
if (kind == InvocationKind::LUA_SOURCE) rescan_lua_source_ = false;
|
if (kind == AccessKind::INVOKE_LUA_SOURCE) rescan_lua_source_ = false;
|
||||||
call_function_retpk_.clear();
|
call_function_retpk_.clear();
|
||||||
event_call_function(kind, place, std::string_view(datapk, datapklen), &call_function_retpk_);
|
event_access(kind, place, std::string_view(datapk, datapklen), &call_function_retpk_);
|
||||||
if (retpklen != nullptr) {
|
if (retpklen != nullptr) {
|
||||||
std::string_view view = call_function_retpk_.view();
|
std::string_view view = call_function_retpk_.view();
|
||||||
*retpklen = view.size();
|
*retpklen = view.size();
|
||||||
@@ -811,28 +811,28 @@ static void replay_update(EngineWrapper *w) {
|
|||||||
////////////////////////
|
////////////////////////
|
||||||
|
|
||||||
|
|
||||||
void play_call_function(EngineWrapper *w, InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk, uint32_t *retpklen, const char **retpk) {
|
void play_access(EngineWrapper *w, AccessKind kind, int64_t place, uint32_t datapklen, const char *datapk, uint32_t *retpklen, const char **retpk) {
|
||||||
assert(w->rlog == nullptr);
|
assert(w->rlog == nullptr);
|
||||||
if (w->wlog != nullptr) {
|
if (w->wlog != nullptr) {
|
||||||
w->wlog->write_cmd_hash(PLAY_CALL_FUNCTION, eng::memhash());
|
w->wlog->write_cmd_hash(PLAY_ACCESS, eng::memhash());
|
||||||
w->wlog->write_uint8(int64_t(kind));
|
w->wlog->write_uint8(int64_t(kind));
|
||||||
w->wlog->write_int64(place);
|
w->wlog->write_int64(place);
|
||||||
w->wlog->write_string(std::string_view(datapk, datapklen));
|
w->wlog->write_string(std::string_view(datapk, datapklen));
|
||||||
w->wlog->flush();
|
w->wlog->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
w->engine->drv_call_function(kind, place, datapklen, datapk, retpklen, retpk);
|
w->engine->drv_access(kind, place, datapklen, datapk, retpklen, retpk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void replay_call_function(EngineWrapper *w) {
|
void replay_access(EngineWrapper *w) {
|
||||||
InvocationKind kind = InvocationKind(w->rlog->read_uint8());
|
AccessKind kind = AccessKind(w->rlog->read_uint8());
|
||||||
int64_t place = w->rlog->read_int64();
|
int64_t place = w->rlog->read_int64();
|
||||||
std::string srcpack = w->rlog->read_string();
|
std::string srcpack = w->rlog->read_string();
|
||||||
if (!w->rlog->good()) {
|
if (!w->rlog->good()) {
|
||||||
return reset_wrapper(w, "replay log corrupt in replay_call_function_lua_call");
|
return reset_wrapper(w, "replay log corrupt in replay_access");
|
||||||
}
|
}
|
||||||
|
|
||||||
w->engine->drv_call_function(kind, place, srcpack.size(), srcpack.c_str(), nullptr, nullptr);
|
w->engine->drv_access(kind, place, srcpack.size(), srcpack.c_str(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -903,7 +903,7 @@ static void replaycore_step(EngineWrapper *w) {
|
|||||||
case PLAY_NOTIFY_CLOSE: replay_notify_close(w); return;
|
case PLAY_NOTIFY_CLOSE: replay_notify_close(w); return;
|
||||||
case PLAY_NOTIFY_ACCEPT: replay_notify_accept(w); return;
|
case PLAY_NOTIFY_ACCEPT: replay_notify_accept(w); return;
|
||||||
case PLAY_UPDATE: replay_update(w); return;
|
case PLAY_UPDATE: replay_update(w); return;
|
||||||
case PLAY_CALL_FUNCTION: replay_call_function(w); return;
|
case PLAY_ACCESS: replay_access(w); return;
|
||||||
case PLAY_RELEASE: release(w); return;
|
case PLAY_RELEASE: release(w); return;
|
||||||
default: return reset_wrapper(w, "Replay log corrupt in command dispatcher");
|
default: return reset_wrapper(w, "Replay log corrupt in command dispatcher");
|
||||||
}
|
}
|
||||||
@@ -958,7 +958,7 @@ static void init_engine_wrapper_helper(EngineWrapper *w) {
|
|||||||
w->play_notify_close = play_notify_close;
|
w->play_notify_close = play_notify_close;
|
||||||
w->play_notify_accept = play_notify_accept;
|
w->play_notify_accept = play_notify_accept;
|
||||||
w->play_update = play_update;
|
w->play_update = play_update;
|
||||||
w->play_call_function = play_call_function;
|
w->play_access = play_access;
|
||||||
|
|
||||||
w->replay_initialize = replaycore_initialize;
|
w->replay_initialize = replaycore_initialize;
|
||||||
w->replay_step = replaycore_step;
|
w->replay_step = replaycore_step;
|
||||||
|
|||||||
@@ -147,13 +147,13 @@ public:
|
|||||||
//
|
//
|
||||||
virtual void event_init(std::string_view srcpk, int argc, char *argv[]) = 0;
|
virtual void event_init(std::string_view srcpk, int argc, char *argv[]) = 0;
|
||||||
|
|
||||||
// The call-function callback. This is invoked whenever drv_call_function
|
// The call-function callback. This is invoked whenever drv_access
|
||||||
// is called. This is the main entry point for "general" access into the
|
// is called. This is the main entry point for "general" access into the
|
||||||
// DrivenEngine. The datapk parameter can contain any arbitrary data needed
|
// DrivenEngine. The datapk parameter can contain any arbitrary data needed
|
||||||
// by the call. If the call wants to return anything, it can write the
|
// by the call. If the call wants to return anything, it can write the
|
||||||
// return data into the retpk datapack.
|
// return data into the retpk datapack.
|
||||||
//
|
//
|
||||||
virtual void event_call_function(InvocationKind kind, int64_t place, std::string_view datapk, StreamBuffer *retpk) {};
|
virtual void event_access(AccessKind kind, int64_t place, std::string_view datapk, StreamBuffer *retpk) {};
|
||||||
|
|
||||||
// The update callback. You may override this in a subclass.
|
// The update callback. You may override this in a subclass.
|
||||||
// This will be called whenever anything changes.
|
// This will be called whenever anything changes.
|
||||||
@@ -296,7 +296,7 @@ public:
|
|||||||
void drv_notify_close(uint32_t chid, uint32_t len, const char *data);
|
void drv_notify_close(uint32_t chid, uint32_t len, const char *data);
|
||||||
uint32_t drv_notify_accept(uint32_t port);
|
uint32_t drv_notify_accept(uint32_t port);
|
||||||
void drv_update(double clock);
|
void drv_update(double clock);
|
||||||
void drv_call_function(InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk, uint32_t *retpklen, const char **retpk);
|
void drv_access(AccessKind kind, int64_t place, uint32_t datapklen, const char *datapk, uint32_t *retpklen, const char **retpk);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Find a currently-unused channel ID. Channel IDs
|
// Find a currently-unused channel ID. Channel IDs
|
||||||
|
|||||||
@@ -20,14 +20,14 @@
|
|||||||
#define DRV_ERRMSG_SIZE 8192
|
#define DRV_ERRMSG_SIZE 8192
|
||||||
#define DRV_SHORTSTRING_SIZE 65536
|
#define DRV_SHORTSTRING_SIZE 65536
|
||||||
|
|
||||||
enum class InvocationKind {
|
enum class AccessKind {
|
||||||
INVALID,
|
INVALID,
|
||||||
LUA_INVOKE,
|
INVOKE_LUA_CALL,
|
||||||
LUA_PROBE,
|
INVOKE_LUA_EXPR,
|
||||||
LUA_EXPR,
|
INVOKE_FLUSH_PRINTS,
|
||||||
LUA_SOURCE,
|
INVOKE_TICK,
|
||||||
FLUSH_PRINTS,
|
INVOKE_LUA_SOURCE,
|
||||||
TICK,
|
PROBE_LUA_CALL,
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrivenEngine;
|
class DrivenEngine;
|
||||||
@@ -212,7 +212,7 @@ struct EngineWrapper {
|
|||||||
// This is the main pathway for blueprints, or the unreal C++ code,
|
// This is the main pathway for blueprints, or the unreal C++ code,
|
||||||
// to change the state of the world.
|
// to change the state of the world.
|
||||||
//
|
//
|
||||||
void (*play_call_function)(EngineWrapper *w, InvocationKind kind, int64_t place, uint32_t datapklen, const char *datapk, uint32_t *retpklen, const char **retpk);
|
void (*play_access)(EngineWrapper *w, AccessKind kind, int64_t place, uint32_t datapklen, const char *datapk, uint32_t *retpklen, const char **retpk);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
#include "invocation.hpp"
|
#include "invocation.hpp"
|
||||||
|
|
||||||
Invocation::Invocation() : kind_(InvocationKind::INVALID), actor_(0), place_(0) {}
|
Invocation::Invocation() : kind_(AccessKind::INVALID), actor_(0), place_(0) {}
|
||||||
|
|
||||||
Invocation::Invocation(InvocationKind kind, int64_t actor, int64_t place, std::string_view datapack)
|
Invocation::Invocation(AccessKind kind, int64_t actor, int64_t place, std::string_view datapack)
|
||||||
: kind_(kind), actor_(actor), place_(place), datapack_(datapack) {}
|
: kind_(kind), actor_(actor), place_(place), datapack_(datapack) {}
|
||||||
|
|
||||||
|
|
||||||
void Invocation::serialize(StreamBuffer *sb) const {
|
void Invocation::serialize(StreamBuffer *sb) const {
|
||||||
sb->write_uint8(int64_t(kind_));
|
sb->write_uint8(int64_t(kind_));
|
||||||
@@ -20,7 +20,7 @@ void Invocation::serialize(StreamBuffer *sb) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Invocation::deserialize(StreamBuffer *sb) {
|
void Invocation::deserialize(StreamBuffer *sb) {
|
||||||
kind_ = InvocationKind(sb->read_uint8());
|
kind_ = AccessKind(sb->read_uint8());
|
||||||
actor_ = sb->read_int64();
|
actor_ = sb->read_int64();
|
||||||
place_ = sb->read_int64();
|
place_ = sb->read_int64();
|
||||||
datapack_ = sb->read_string();
|
datapack_ = sb->read_string();
|
||||||
@@ -30,13 +30,13 @@ eng::string Invocation::debug_string() const {
|
|||||||
eng::ostringstream oss;
|
eng::ostringstream oss;
|
||||||
oss << "inv[";
|
oss << "inv[";
|
||||||
switch (kind_) {
|
switch (kind_) {
|
||||||
case InvocationKind::INVALID: oss << "invalid"; break;
|
case AccessKind::INVALID: oss << "invalid"; break;
|
||||||
case InvocationKind::LUA_INVOKE: oss << "lua_invoke"; break;
|
case AccessKind::INVOKE_LUA_CALL: oss << "lua_invoke"; break;
|
||||||
case InvocationKind::LUA_PROBE: oss << "lua_probe"; break;
|
case AccessKind::INVOKE_LUA_EXPR: oss << "lua_expr"; break;
|
||||||
case InvocationKind::LUA_EXPR: oss << "lua_expr"; break;
|
case AccessKind::INVOKE_FLUSH_PRINTS: oss << "flush_prints"; break;
|
||||||
case InvocationKind::LUA_SOURCE: oss << "lua_source"; break;
|
case AccessKind::INVOKE_TICK: oss << "tick"; break;
|
||||||
case InvocationKind::FLUSH_PRINTS: oss << "flush_prints"; break;
|
case AccessKind::INVOKE_LUA_SOURCE: oss << "lua_source"; break;
|
||||||
case InvocationKind::TICK: oss << "tick"; break;
|
case AccessKind::PROBE_LUA_CALL: oss << "lua_probe"; break;
|
||||||
default: oss << "UNKNOWN"; break;
|
default: oss << "UNKNOWN"; break;
|
||||||
}
|
}
|
||||||
oss << " a=" << actor_;
|
oss << " a=" << actor_;
|
||||||
|
|||||||
@@ -8,28 +8,28 @@
|
|||||||
//
|
//
|
||||||
// The actual contents of the datapack depends on the type of invocation:
|
// The actual contents of the datapack depends on the type of invocation:
|
||||||
//
|
//
|
||||||
// InvocationKind::INVALID:
|
// AccessKind::INVALID:
|
||||||
//
|
//
|
||||||
// Nothing.
|
// Nothing.
|
||||||
//
|
//
|
||||||
// InvocationKind::LUA_CALL:
|
// AccessKind::LUA_CALL:
|
||||||
//
|
//
|
||||||
// A lua function call. The class name, the function name, and then
|
// A lua function call. The class name, the function name, and then
|
||||||
// the function arguments.
|
// the function arguments.
|
||||||
//
|
//
|
||||||
// InvocationKind::LUA_EXPR:
|
// AccessKind::INVOKE_LUA_EXPR:
|
||||||
//
|
//
|
||||||
// A block of lua source code, in plaintext.
|
// A block of lua source code, in plaintext.
|
||||||
//
|
//
|
||||||
// InvocationKind::FLUSH_PRINTS:
|
// AccessKind::INVOKE_FLUSH_PRINTS:
|
||||||
//
|
//
|
||||||
// Line number in ascii.
|
// Line number in ascii.
|
||||||
//
|
//
|
||||||
// InvocationKind::TICK:
|
// AccessKind::INVOKE_TICK:
|
||||||
//
|
//
|
||||||
// Nothing.
|
// Nothing.
|
||||||
//
|
//
|
||||||
// InvocationKind::LUA_SOURCE:
|
// AccessKind::INVOKE_LUA_SOURCE:
|
||||||
//
|
//
|
||||||
// Packaged lua sourcecode. See drvutil::package_lua_source.
|
// Packaged lua sourcecode. See drvutil::package_lua_source.
|
||||||
//
|
//
|
||||||
@@ -48,16 +48,16 @@
|
|||||||
class Invocation : public eng::opnew {
|
class Invocation : public eng::opnew {
|
||||||
public:
|
public:
|
||||||
private:
|
private:
|
||||||
InvocationKind kind_;
|
AccessKind kind_;
|
||||||
int64_t actor_;
|
int64_t actor_;
|
||||||
int64_t place_;
|
int64_t place_;
|
||||||
eng::string datapack_;
|
eng::string datapack_;
|
||||||
public:
|
public:
|
||||||
Invocation();
|
Invocation();
|
||||||
Invocation(InvocationKind kind, int64_t actor, int64_t place, std::string_view datapack);
|
Invocation(AccessKind kind, int64_t actor, int64_t place, std::string_view datapack);
|
||||||
|
|
||||||
bool valid() const { return kind_ != InvocationKind::INVALID; }
|
bool valid() const { return kind_ != AccessKind::INVALID; }
|
||||||
InvocationKind kind() const { return kind_; }
|
AccessKind kind() const { return kind_; }
|
||||||
int64_t actor() const { return actor_; }
|
int64_t actor() const { return actor_; }
|
||||||
int64_t place() const { return place_; }
|
int64_t place() const { return place_; }
|
||||||
const eng::string &datapack() const { return datapack_; }
|
const eng::string &datapack() const { return datapack_; }
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
|
|
||||||
void send_invocation(const Invocation &inv) {
|
void send_invocation(const Invocation &inv) {
|
||||||
if (channel_ == nullptr) {
|
if (channel_ == nullptr) {
|
||||||
if ((!world_->is_authoritative()) && (inv.kind() == InvocationKind::LUA_SOURCE)) {
|
if ((!world_->is_authoritative()) && (inv.kind() == AccessKind::INVOKE_LUA_SOURCE)) {
|
||||||
// We have a client model, but no client connection. That means we're
|
// We have a client model, but no client connection. That means we're
|
||||||
// in the process of shutting down a client model. The client model
|
// in the process of shutting down a client model. The client model
|
||||||
// is supposed to linger until the lua source is reread. Once we have
|
// is supposed to linger until the lua source is reread. Once we have
|
||||||
@@ -179,7 +179,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void do_luainvoke_command(std::string_view cmd) override {
|
virtual void do_luainvoke_command(std::string_view cmd) override {
|
||||||
send_invocation(Invocation(InvocationKind::LUA_EXPR, actor_id_, actor_id_, cmd));
|
send_invocation(Invocation(AccessKind::INVOKE_LUA_EXPR, actor_id_, actor_id_, cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void do_luaprobe_command(std::string_view cmd) override {
|
virtual void do_luaprobe_command(std::string_view cmd) override {
|
||||||
@@ -246,9 +246,9 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void event_call_function(InvocationKind kind, int64_t place_id, std::string_view datapk, StreamBuffer *retpk) override {
|
virtual void event_access(AccessKind kind, int64_t place_id, std::string_view datapk, StreamBuffer *retpk) override {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case InvocationKind::LUA_PROBE: {
|
case AccessKind::PROBE_LUA_CALL: {
|
||||||
world_to_asynchronous();
|
world_to_asynchronous();
|
||||||
world_->probe_lua_call(actor_id_, place_id, datapk, retpk);
|
world_->probe_lua_call(actor_id_, place_id, datapk, retpk);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void do_luainvoke_command(std::string_view cmd) override {
|
virtual void do_luainvoke_command(std::string_view cmd) override {
|
||||||
master_->invoke(Invocation(InvocationKind::LUA_EXPR, admin_id_, admin_id_, cmd));
|
master_->invoke(Invocation(AccessKind::INVOKE_LUA_EXPR, admin_id_, admin_id_, cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void do_luaprobe_command(std::string_view cmd) override {
|
virtual void do_luaprobe_command(std::string_view cmd) override {
|
||||||
@@ -193,9 +193,9 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void event_call_function(InvocationKind kind, int64_t place_id, std::string_view datapk, StreamBuffer *retpk) override {
|
virtual void event_access(AccessKind kind, int64_t place_id, std::string_view datapk, StreamBuffer *retpk) override {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case InvocationKind::LUA_PROBE: {
|
case AccessKind::PROBE_LUA_CALL: {
|
||||||
master_->snapshot();
|
master_->snapshot();
|
||||||
master_->probe_lua_call(admin_id_, place_id, datapk, retpk);
|
master_->probe_lua_call(admin_id_, place_id, datapk, retpk);
|
||||||
master_->rollback();
|
master_->rollback();
|
||||||
@@ -258,7 +258,7 @@ public:
|
|||||||
|
|
||||||
// If the clock has advanced far enough, tick the master model.
|
// If the clock has advanced far enough, tick the master model.
|
||||||
if (clock >= next_tick_) {
|
if (clock >= next_tick_) {
|
||||||
master_->invoke(Invocation(InvocationKind::TICK, 0, 0, ""));
|
master_->invoke(Invocation(AccessKind::INVOKE_TICK, 0, 0, ""));
|
||||||
for (UniqueClient &client : clients_) {
|
for (UniqueClient &client : clients_) {
|
||||||
client->async_diff_ = true;
|
client->async_diff_ = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ bool PrintChanneler::channel(const PrintBuffer *printbuffer, std::ostream &ostre
|
|||||||
Invocation PrintChanneler::invocation(int64_t actor_id) {
|
Invocation PrintChanneler::invocation(int64_t actor_id) {
|
||||||
char buf[80];
|
char buf[80];
|
||||||
sprintf(buf, "%" PRId64, line_);
|
sprintf(buf, "%" PRId64, line_);
|
||||||
return Invocation(InvocationKind::FLUSH_PRINTS, actor_id, actor_id, buf);
|
return Invocation(AccessKind::INVOKE_FLUSH_PRINTS, actor_id, actor_id, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaDefine(unittests_printbuffer, "", "some unit tests") {
|
LuaDefine(unittests_printbuffer, "", "some unit tests") {
|
||||||
|
|||||||
@@ -742,19 +742,19 @@ void World::run_unittests() {
|
|||||||
|
|
||||||
void World::invoke(const Invocation &inv) {
|
void World::invoke(const Invocation &inv) {
|
||||||
switch (inv.kind()) {
|
switch (inv.kind()) {
|
||||||
case InvocationKind::LUA_INVOKE:
|
case AccessKind::INVOKE_LUA_CALL:
|
||||||
invoke_lua_call(inv.actor(), inv.place(), inv.datapack());
|
invoke_lua_call(inv.actor(), inv.place(), inv.datapack());
|
||||||
break;
|
break;
|
||||||
case InvocationKind::LUA_EXPR:
|
case AccessKind::INVOKE_LUA_EXPR:
|
||||||
invoke_lua_expr(inv.actor(), inv.place(), inv.datapack());
|
invoke_lua_expr(inv.actor(), inv.place(), inv.datapack());
|
||||||
break;
|
break;
|
||||||
case InvocationKind::FLUSH_PRINTS:
|
case AccessKind::INVOKE_FLUSH_PRINTS:
|
||||||
invoke_flush_prints(inv.actor(), inv.place(), inv.datapack());
|
invoke_flush_prints(inv.actor(), inv.place(), inv.datapack());
|
||||||
break;
|
break;
|
||||||
case InvocationKind::TICK:
|
case AccessKind::INVOKE_TICK:
|
||||||
invoke_tick(inv.actor(), inv.place(), inv.datapack());
|
invoke_tick(inv.actor(), inv.place(), inv.datapack());
|
||||||
break;
|
break;
|
||||||
case InvocationKind::LUA_SOURCE:
|
case AccessKind::INVOKE_LUA_SOURCE:
|
||||||
invoke_lua_source(inv.actor(), inv.place(), inv.datapack());
|
invoke_lua_source(inv.actor(), inv.place(), inv.datapack());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class Driver {
|
|||||||
std::string err = drvutil::package_lua_source(".", &oss);
|
std::string err = drvutil::package_lua_source(".", &oss);
|
||||||
if_error_print_and_exit(err);
|
if_error_print_and_exit(err);
|
||||||
std::string_view ossv = oss.view();
|
std::string_view ossv = oss.view();
|
||||||
engw.play_call_function(&engw, InvocationKind::LUA_SOURCE, 0, ossv.size(), ossv.data(), nullptr, nullptr);
|
engw.play_access(&engw, AccessKind::INVOKE_LUA_SOURCE, 0, ossv.size(), ossv.data(), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user