Changes related to ray-collision, and luprex global variable stuff
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include "traceback.hpp"
|
||||
#include "pprint.hpp"
|
||||
#include "util.hpp"
|
||||
#include "serializelua.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -1101,31 +1100,10 @@ std::ostream *World::lthread_print_stream() const {
|
||||
}
|
||||
}
|
||||
|
||||
void World::set_global(LuaCoreStack &LS0, const eng::string &gvar, LuaSlot value) {
|
||||
lua_State *L = LS0.state();
|
||||
LuaVar globaldb, copy;
|
||||
LuaExtStack LS(L, globaldb, copy);
|
||||
|
||||
// Serialize then deserialize the data, to produce a copy.
|
||||
StreamBuffer sb;
|
||||
eng::string error = serialize_lua(LS, value, &sb);
|
||||
if (!error.empty()) {
|
||||
luaL_error(L, "%s", error.c_str());
|
||||
return;
|
||||
}
|
||||
eng::string serialized(sb.view());
|
||||
error = deserialize_lua(LS, copy, &sb);
|
||||
if (!error.empty()) {
|
||||
luaL_error(L, "%s", error.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the copy in the globalDB.
|
||||
LS.rawget(globaldb, LuaRegistry, "globaldb");
|
||||
LS.rawset(globaldb, gvar, copy);
|
||||
|
||||
void World::set_global(const eng::string &gvar, std::string_view value) {
|
||||
// Store the serialized blob.
|
||||
gvname_to_serial_[gvar] = serialized;
|
||||
//
|
||||
gvname_to_serial_[gvar] = value;
|
||||
|
||||
// Implement the tracking so that we can rapidly determine which global
|
||||
// variables need to be difference transmitted.
|
||||
@@ -1147,6 +1125,15 @@ void World::set_global(LuaCoreStack &LS0, const eng::string &gvar, LuaSlot value
|
||||
}
|
||||
}
|
||||
|
||||
const eng::string &World::get_global(const eng::string &gvar) {
|
||||
static eng::string empty;
|
||||
auto iter = gvname_to_serial_.find(gvar);
|
||||
if (iter == gvname_to_serial_.end()) {
|
||||
return empty;
|
||||
} else {
|
||||
return iter->second;
|
||||
}
|
||||
}
|
||||
|
||||
void World::serialize(StreamBuffer *sb) {
|
||||
assert(stack_is_clear());
|
||||
|
||||
Reference in New Issue
Block a user