Can now use /CPL to reload lua source

This commit is contained in:
2021-12-15 14:18:19 -05:00
parent c689422206
commit e0001127c7
11 changed files with 115 additions and 13 deletions

View File

@@ -446,6 +446,25 @@ void SourceDB::init(lua_State *L) {
}
}
void SourceDB::serialize_source(const util::LuaSourceVec &sv, StreamBuffer *sb) {
sb->write_int32(sv.size());
for (const auto &pair : sv) {
sb->write_string(pair.first);
sb->write_string(pair.second);
}
}
void SourceDB::deserialize_source(util::LuaSourceVec *sv, StreamBuffer *sb) {
sv->clear();
int count = sb->read_int32();
if ((count < 0) || (count > 10000)) throw StreamCorruption();
for (int i = 0; i < count; i++) {
std::string fn = sb->read_string();
std::string code = sb->read_string();
sv->emplace_back(fn, code);
}
}
// These should go away eventually. They're for debugging.
LuaDefine(coroutine_setnextid, "c") {
LuaArg co, lid;