diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 45 |
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 | |||
6 | extern "C" { | ||
7 | #include <libavformat/avformat.h> | ||
8 | } | ||
9 | |||
10 | int 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 | } | ||