summary refs log tree commit diff stats
path: root/main.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-01-18 16:49:54 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-01-18 16:49:54 -0500
commitda3bc860f66d34f233028e819beee32dd1c43dd8 (patch)
tree8cc7f5ad0a8dad69ea5c3ae0405f803d3ba80051 /main.cpp
parent46db0368fbee4cfba97178837e62f4469c4fa884 (diff)
downloadsap-da3bc860f66d34f233028e819beee32dd1c43dd8.tar.gz
sap-da3bc860f66d34f233028e819beee32dd1c43dd8.tar.bz2
sap-da3bc860f66d34f233028e819beee32dd1c43dd8.zip
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.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..6ac8ee9 --- /dev/null +++ b/main.cpp
@@ -0,0 +1,45 @@
1#include "sap.h"
2#include <iostream>
3#include <ctime>
4#include <cstdlib>
5
6extern "C" {
7#include <libavformat/avformat.h>
8}
9
10int main(int argc, char** argv)
11{
12 Magick::InitializeMagick(nullptr);
13 av_register_all();
14
15 std::random_device randomDevice;
16 std::mt19937 rng(randomDevice());
17
18 // We also have to seed the C-style RNG because librawr uses it.
19 srand(time(NULL));
20 rand(); rand(); rand(); rand();
21
22 if (argc != 2)
23 {
24 std::cout << "usage: sap [configfile]" << std::endl;
25 return -1;
26 }
27
28 std::string configfile(argv[1]);
29
30 try
31 {
32 sap bot(configfile, rng);
33
34 try
35 {
36 bot.run();
37 } catch (const std::exception& ex)
38 {
39 std::cout << "Error running bot: " << ex.what() << std::endl;
40 }
41 } catch (const std::exception& ex)
42 {
43 std::cout << "Error initializing bot: " << ex.what() << std::endl;
44 }
45}