From da3bc860f66d34f233028e819beee32dd1c43dd8 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 18 Jan 2018 16:49:54 -0500 Subject: Modernized project This rewrite brings the codebase of this project more in line with the format of the other bots, including things like C++ randomization, better abstraction, use of exceptions, etc. Notably, any FFMPEG objects that get allocated are wrapped in simple objects so that they get properly destroyed if an exception is thrown. Some more error detection and cleanliness stuff can probably be done but my wrists really hurt. Also updated librawr, and thus also removed the yaml-cpp submodule. --- main.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 main.cpp (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..6ac8ee9 --- /dev/null +++ b/main.cpp @@ -0,0 +1,45 @@ +#include "sap.h" +#include +#include +#include + +extern "C" { +#include +} + +int main(int argc, char** argv) +{ + Magick::InitializeMagick(nullptr); + av_register_all(); + + std::random_device randomDevice; + std::mt19937 rng(randomDevice()); + + // We also have to seed the C-style RNG because librawr uses it. + srand(time(NULL)); + rand(); rand(); rand(); rand(); + + if (argc != 2) + { + std::cout << "usage: sap [configfile]" << std::endl; + return -1; + } + + std::string configfile(argv[1]); + + try + { + sap bot(configfile, rng); + + try + { + bot.run(); + } catch (const std::exception& ex) + { + std::cout << "Error running bot: " << ex.what() << std::endl; + } + } catch (const std::exception& ex) + { + std::cout << "Error initializing bot: " << ex.what() << std::endl; + } +} -- cgit 1.4.1