Stop channeling printbuffers to stdostream. Instead, provide an invocation CHANNEL_PRINTS.
This commit is contained in:
@@ -33,6 +33,7 @@ enum class AccessKind {
|
||||
PROBE_LUA_CALL,
|
||||
CONNECT_TO_SERVER,
|
||||
VALIDATE_LUA_EXPR,
|
||||
CHANNEL_PRINTS,
|
||||
};
|
||||
|
||||
class DrivenEngine;
|
||||
|
||||
@@ -270,6 +270,13 @@ public:
|
||||
retpk->write_bytes(errmsg);
|
||||
break;
|
||||
}
|
||||
case AccessKind::CHANNEL_PRINTS: {
|
||||
world_to_asynchronous();
|
||||
if (print_channeler_.channel(world_->get_printbuffer(actor_id_), retpk)) {
|
||||
send_invocation(print_channeler_.invocation(actor_id_));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
util::dprint("Invalid event_access: ", int(kind));
|
||||
}
|
||||
@@ -305,11 +312,6 @@ public:
|
||||
world_to_asynchronous();
|
||||
}
|
||||
}
|
||||
|
||||
// Channel print statements.
|
||||
if (print_channeler_.channel(world_->get_printbuffer(actor_id_), stdostream())) {
|
||||
send_invocation(print_channeler_.invocation(actor_id_));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -63,6 +63,9 @@ public:
|
||||
// Export stuff to the graphics engine.
|
||||
set_visible_world_and_actor(master_.get(), admin_id_);
|
||||
|
||||
// Reset the print channeler.
|
||||
print_channeler_.reset();
|
||||
|
||||
// Trigger the loading of the lua source.
|
||||
rescan_lua_source(true);
|
||||
}
|
||||
@@ -194,6 +197,12 @@ public:
|
||||
retpk->write_bytes(errmsg);
|
||||
break;
|
||||
}
|
||||
case AccessKind::CHANNEL_PRINTS: {
|
||||
if (print_channeler_.channel(master_->get_printbuffer(admin_id_), retpk)) {
|
||||
master_->invoke(print_channeler_.invocation(admin_id_));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
stdostream() << "Invalid event_access: " << int(kind) << std::endl;
|
||||
}
|
||||
@@ -220,11 +229,6 @@ public:
|
||||
do_command(console_.get_command());
|
||||
}
|
||||
|
||||
// Anything in the administrator printbuffer should go to stdostream.
|
||||
if (print_channeler_.channel(master_->get_printbuffer(admin_id_), stdostream())) {
|
||||
master_->invoke(print_channeler_.invocation(admin_id_));
|
||||
}
|
||||
|
||||
// Check for new incoming channels, set up client structures.
|
||||
while (true) {
|
||||
SharedChannel chan = new_incoming_channel();
|
||||
|
||||
@@ -91,7 +91,7 @@ void LuaConsole::add(eng::string line) {
|
||||
// Try to parse the lua expression
|
||||
{
|
||||
LuaVar result;
|
||||
LuaDefStack LS(lua_state_, result);
|
||||
LuaExtStack LS(lua_state_, result);
|
||||
eng::string errmsg = LS.load(result, partial, "stdin");
|
||||
if (errmsg.empty()) {
|
||||
words_.push_back(lua_mode);
|
||||
|
||||
@@ -17,8 +17,7 @@ struct PrintBufferCore : public eng::opnew {
|
||||
// Line number of the first unchecked line in the buffer. All line
|
||||
// numbers including this one and beyond are unchecked.
|
||||
// "Unchecked" lines are lines in a non-authoritative model
|
||||
// that haven't been verified through difference transmission.
|
||||
|
||||
// that haven't been verified through difference transmission
|
||||
int first_unchecked_;
|
||||
|
||||
// Constructor.
|
||||
@@ -180,13 +179,15 @@ void PrintBuffer::patch(StreamBuffer *sb, DebugCollector *dbc) {
|
||||
}
|
||||
}
|
||||
|
||||
bool PrintChanneler::channel(const PrintBuffer *printbuffer, std::ostream &ostream) {
|
||||
bool PrintChanneler::channel(const PrintBuffer *printbuffer, StreamBuffer *sb) {
|
||||
if (printbuffer == nullptr) return false;
|
||||
if (printbuffer->first_line() > line_) {
|
||||
line_ = printbuffer->first_line();
|
||||
}
|
||||
while (line_ < printbuffer->first_unchecked()) {
|
||||
ostream << "|" << printbuffer->nth(line_) << std::endl;
|
||||
sb->write_bytes("|");
|
||||
sb->write_bytes(printbuffer->nth(line_));
|
||||
sb->write_bytes("\n");
|
||||
line_ += 1;
|
||||
}
|
||||
return line_ > printbuffer->first_line();
|
||||
|
||||
@@ -152,7 +152,7 @@ public:
|
||||
// Copy any new lines from the printbuffer to the stdostream.
|
||||
// Update the current line number. Return true if the printbuffer
|
||||
// contains any lines that have already been channeled.
|
||||
bool channel(const PrintBuffer *pb, std::ostream &ostream);
|
||||
bool channel(const PrintBuffer *pb, StreamBuffer *sb);
|
||||
|
||||
// Generate an invocation that removes unnecessary lines from the
|
||||
// printbuffer.
|
||||
|
||||
Reference in New Issue
Block a user