MC::LoadFakeRng(ents) => {
let superuser = cs.superuser
.ok_or(ME::SuperuserAuthorisationRequired)?;
- config().fake_rng.set(ents, superuser)?;
+ config().game_rng.set_fake(ents, superuser)?;
Fine
}
}
player_info_pane,
ptoken: form.ptoken.clone(),
links: (&*ig.links).into(),
- fake_rng: config().fake_rng.is_fake(),
+ fake_rng: config().game_rng.is_fake(),
load: serde_json::to_string(&DataLoad {
players: load_players,
last_log_ts: timestamp_abbrev.unwrap_or_default(),
pub sendmail: String,
pub debug_js_inject: Arc<String>,
pub check_bundled_sources: bool,
- pub fake_rng: RngWrap,
+ pub game_rng: RngWrap,
}
impl TryFrom<ServerConfigSpec> for WholeServerConfig {
debug_js_inject_file, check_bundled_sources, fake_rng,
} = spec;
- let fake_rng = fake_rng.start();
+ let game_rng = fake_rng.make_game_rng();
if let Some(cd) = change_directory {
env::set_current_dir(&cd)
http_port, public_url, sse_wildcard_url, rocket_workers,
template_dir, nwtemplate_dir, wasm_dir,
bundled_sources, shapelibs, sendmail,
- debug_js_inject, check_bundled_sources, fake_rng,
+ debug_js_inject, check_bundled_sources, game_rng,
};
WholeServerConfig {
server: Arc::new(server),
pub struct FakeRngSpec(Option<Vec<String>>);
impl FakeRngSpec {
- pub fn start(self) -> RngWrap { RngWrap( match self.0 {
+ pub fn make_game_rng(self) -> RngWrap { RngWrap( match self.0 {
None => None,
Some(ents) => Some(Arc::new(Mutex::new(FakeRng {
i: 0,
pub fn is_fake(&self) -> bool { self.0.is_some() }
#[throws(MgmtError)]
- pub fn set(&self, v: Vec<String>, _: AuthorisationSuperuser) {
+ pub fn set_fake(&self, v: Vec<String>, _: AuthorisationSuperuser) {
let mut fake = self.0.as_ref().ok_or(ME::RngIsReal)?.lock();
fake.i = 0;
fake.ents = v;
}
#[throws(as Option)]
- fn next(&self) -> String {
+ fn next_fake(&self) -> String {
let mut fake = self.0.as_ref()?.lock();
let e = fake.ents.get(fake.i)?.clone();
fake.i += 1;
e
}
- pub fn shuffle<T:Copy>(&self, slice: &mut [T]) { match self.next() {
+ pub fn shuffle<T:Copy>(&self, slice: &mut [T]) { match self.next_fake() {
None => {
let mut rng = thread_rng();
slice.shuffle(&mut rng);