mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Load more config data from files (instead of hardcoded)
This commit is contained in:
1 parent
0e048a17b1
commit
a540cf6d8f
17 files changed
+244
-42
No files matched your search
@@ -1,14 +1,19 @@
|
||||
use polariton_server::operations::SimpleFunc;
|
||||
use polariton::operation::{ParameterTable, Typed};
|
||||
use polariton::operation::ParameterTable;
|
||||
use rand::Rng;
|
||||
use rc_core::ConfigProvider;
|
||||
|
||||
const MESSAGE_PARAM_KEY: u8 = 2;
|
||||
const DISPLAY_TIME_PARAM_KEY: u8 = 15;
|
||||
|
||||
pub(super) fn dev_message_provider() -> SimpleFunc<8, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
SimpleFunc::new(|params, _| {
|
||||
pub(super) fn dev_message_provider(conf: &rc_core::ConfigImpl) -> SimpleFunc<8, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
||||
let messages = conf.login_messages();
|
||||
SimpleFunc::new(move |params, _| {
|
||||
let mut params = params.to_dict();
|
||||
params.insert(MESSAGE_PARAM_KEY, Typed::Bytes(Vec::from("No jam was harmed in the reverse-engineering of this game".as_bytes()).into()));
|
||||
params.insert(DISPLAY_TIME_PARAM_KEY, Typed::Int(60 /* seconds??? */));
|
||||
let index = rand::rng().random::<u32>();
|
||||
let dev_msg = messages.get(index as _);
|
||||
params.insert(MESSAGE_PARAM_KEY, dev_msg.message);
|
||||
params.insert(DISPLAY_TIME_PARAM_KEY, dev_msg.display_time);
|
||||
Ok(params.into())
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user