Refactored out the main_loop so that it's not tightly coupled inside builder, and in the process found I was accidentally copying GUI and GameEngine because Builder wasn't using a &ref for them. Now they don't have a copy constructor to catch that.
This commit is contained in:
parent
a7c5de6ac3
commit
fff182b457
7 changed files with 27 additions and 34 deletions
22
builder.cpp
22
builder.cpp
|
@ -33,7 +33,6 @@ Builder::Builder(GUI &g, GameEngine &engine)
|
|||
}
|
||||
|
||||
FILE *start_command(string &build_cmd) {
|
||||
println(">>>>>>>>> start_command {}", build_cmd);
|
||||
FILE *build_out = popen(build_cmd.c_str(), "r");
|
||||
dbc::check(build_out != nullptr, "Failed to run command.");
|
||||
return build_out;
|
||||
|
@ -51,11 +50,6 @@ string read_line(FILE *build_out, bool &done_out) {
|
|||
}
|
||||
}
|
||||
|
||||
bool end_build(FILE *build_out, GUI &gui, string &build_cmd) {
|
||||
int rc = pclose(build_out);
|
||||
return rc == 0;
|
||||
}
|
||||
|
||||
MatchResult Builder::parse_line(const string &line) {
|
||||
std::regex err_re("(.*?):([0-9]+):([0-9]+):\\s*(.*?):\\s*(.*)\n*");
|
||||
|
||||
|
@ -76,24 +70,12 @@ MatchResult Builder::parse_line(const string &line) {
|
|||
}
|
||||
}
|
||||
|
||||
void Builder::run() {
|
||||
int rc = gui.main_loop(game, [&] {
|
||||
event(GO);
|
||||
return 0;
|
||||
});
|
||||
|
||||
if(rc != 0) println("ERROR IN GUI");
|
||||
|
||||
event(QUIT);
|
||||
}
|
||||
|
||||
void Builder::building(BuildEvent ev) {
|
||||
println(">>> BUILDING");
|
||||
// check if there's output
|
||||
if(build_done) {
|
||||
bool good = end_build(build_out, gui, build_cmd);
|
||||
int rc = pclose(build_out);
|
||||
|
||||
if(good) {
|
||||
if(rc == 0) {
|
||||
gui.build_works();
|
||||
} else {
|
||||
// BUG: make it not play two sounds
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue