2020-08-22 22:30:12 -04:00
|
|
|
/*!
|
|
|
|
* @file main.cpp
|
|
|
|
* Main for the game. Launches the runtime.
|
|
|
|
*/
|
2020-10-11 19:55:29 -04:00
|
|
|
|
|
|
|
#include <string>
|
2020-08-22 22:30:12 -04:00
|
|
|
#include "runtime.h"
|
|
|
|
#include "common/versions.h"
|
2020-10-01 12:27:07 -04:00
|
|
|
#include "third-party/spdlog/include/spdlog/spdlog.h"
|
|
|
|
#include "third-party/spdlog/include/spdlog/sinks/basic_file_sink.h"
|
2020-10-11 19:55:29 -04:00
|
|
|
#include "third-party/spdlog/include/spdlog/sinks/stdout_color_sinks.h"
|
2020-08-22 22:30:12 -04:00
|
|
|
|
2020-10-11 19:55:29 -04:00
|
|
|
void setup_logging(bool verbose) {
|
|
|
|
spdlog::set_level(spdlog::level::debug);
|
|
|
|
if (verbose) {
|
|
|
|
auto game_logger = spdlog::stdout_color_mt("GOAL Runtime");
|
2020-10-06 18:18:59 -04:00
|
|
|
spdlog::set_default_logger(game_logger);
|
2020-10-06 18:03:33 -04:00
|
|
|
spdlog::flush_on(spdlog::level::info);
|
2020-10-11 19:55:29 -04:00
|
|
|
spdlog::set_pattern("%v");
|
|
|
|
spdlog::info("Verbose logging enabled");
|
|
|
|
} else {
|
|
|
|
auto game_logger = spdlog::basic_logger_mt("GOAL Runtime", "logs/runtime.log");
|
|
|
|
spdlog::set_default_logger(game_logger);
|
|
|
|
spdlog::flush_on(spdlog::level::debug);
|
|
|
|
printf("OpenGOAL Runtime %d.%d\n", versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR);
|
|
|
|
}
|
|
|
|
}
|
2020-10-06 18:03:33 -04:00
|
|
|
|
2020-10-11 19:55:29 -04:00
|
|
|
int main(int argc, char** argv) {
|
|
|
|
bool verbose = false;
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
if (std::string("-v") == argv[i]) {
|
|
|
|
verbose = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_logging(verbose);
|
|
|
|
|
|
|
|
while (true) {
|
2020-08-22 22:30:12 -04:00
|
|
|
// run the runtime in a loop so we can reset the game and have it restart cleanly
|
2020-10-09 00:39:12 -04:00
|
|
|
spdlog::info("OpenGOAL Runtime {}.{}", versions::GOAL_VERSION_MAJOR,
|
|
|
|
versions::GOAL_VERSION_MINOR);
|
2020-10-01 18:08:23 -04:00
|
|
|
|
2020-09-06 16:58:25 -04:00
|
|
|
if (exec_runtime(argc, argv) == 2) {
|
|
|
|
return 0;
|
|
|
|
}
|
2020-08-22 22:30:12 -04:00
|
|
|
}
|
|
|
|
return 0;
|
2020-10-01 12:27:58 -04:00
|
|
|
}
|