- handle seed in args
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include <utility>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "file_input.h"
|
||||
#include "file_output.h"
|
||||
#include "console_input.h"
|
||||
@ -15,7 +16,8 @@ feature proc_args(int argc, char **argv,
|
||||
std::unique_ptr<cursor> &curse,
|
||||
std::unique_ptr<input> &in,
|
||||
std::unique_ptr<display> &out,
|
||||
std::unique_ptr<logger> &log) {
|
||||
std::unique_ptr<logger> &log,
|
||||
std::unique_ptr<RNG> &rng) {
|
||||
feature result = 0;
|
||||
std::string str;
|
||||
std::string fn_fin;
|
||||
@ -122,6 +124,16 @@ feature proc_args(int argc, char **argv,
|
||||
out = std::make_unique<curses_output>(curse);
|
||||
}
|
||||
|
||||
if (result & FEATURE_SEED) {
|
||||
std::istringstream iss {seed};
|
||||
unsigned int tmp;
|
||||
iss >> tmp;
|
||||
if (!iss.good())
|
||||
return FEATURE_PANIC_SEED;
|
||||
|
||||
rng = std::make_unique<RNG>(tmp);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -153,6 +165,9 @@ void panic_args(feature panic) {
|
||||
cerr << "Something must have went really, really, wrong..."
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
else if (panic & FEATURE_PANIC_SEED) {
|
||||
cerr << "Invalid seed" << endl;
|
||||
} else
|
||||
cerr << "Something must have went really, really, wrong..."
|
||||
<< endl;
|
||||
|
Reference in New Issue
Block a user