summaryrefslogtreecommitdiff
path: root/referee.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'referee.cpp')
-rw-r--r--referee.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/referee.cpp b/referee.cpp
index 2701e78..d215c3d 100644
--- a/referee.cpp
+++ b/referee.cpp
@@ -30,9 +30,9 @@ Referee::Referee(const string_view execname, const vector<string> &players)
exit(1);
}
- proc.writeLine(to_string(players.size()));
+ proc.writeLine(to_string(players.size()), false);
for (const string &p : players) {
- proc.writeLine(p);
+ proc.writeLine(p, false);
}
}
@@ -86,7 +86,7 @@ Referee::Event Referee::nextEvent() {
cout << reftag << "write <" << line << ">" << endl;
}
- if (!proc.writeLine(line)) {
+ if (!proc.writeLine(line, false)) {
cout << reftag << "Referee exited unexpectedly after 'read' command!" << endl;
exit(1);
}
@@ -102,7 +102,18 @@ Referee::Event Referee::nextEvent() {
exit(1);
}
- return WriteEvent{player, command.substr(afterIndex)};
+ return WriteEvent{player, false, command.substr(afterIndex)};
+ } else if (command.substr(0, 11) == "writemaybe ") {
+ int player;
+ size_t afterIndex;
+ tie(player, afterIndex) = getPlayer(command, "writemaybe", 11);
+
+ if (afterIndex == string::npos) {
+ cout << reftag << "Protocol violation in 'writemaybe' command: no line!" << endl;
+ exit(1);
+ }
+
+ return WriteEvent{player, true, command.substr(afterIndex)};
} else if (command.substr(0, 8) == "gamelog ") {
int player;
size_t afterIndex;
@@ -150,7 +161,7 @@ Referee::Event Referee::nextEvent() {
}
proc.terminate();
- return ErrorEvent{player, command.substr(6)};
+ return ErrorEvent{player, command.substr(afterIndex)};
} else {
cout << reftag << "Protocol violation: unknown command '" << command << "'!" << endl;
exit(1);