mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-22 23:27:46 +00:00
Move some constants to common module
This commit is contained in:
parent
fb05caaa31
commit
0069196e3c
9 changed files with 13 additions and 21 deletions
|
@ -1,8 +1,7 @@
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
CHAR_NAME_MAX_LENGTH,
|
common::{CHAR_NAME_MAX_LENGTH, read_string},
|
||||||
common::read_string,
|
|
||||||
lobby::ipc::CharacterDetails,
|
lobby::ipc::CharacterDetails,
|
||||||
packet::{IpcSegment, ReadWriteIpcSegment},
|
packet::{IpcSegment, ReadWriteIpcSegment},
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,6 +14,12 @@ use crate::config::get_config;
|
||||||
|
|
||||||
pub mod custom_ipc;
|
pub mod custom_ipc;
|
||||||
|
|
||||||
|
/// An invalid actor/object id.
|
||||||
|
pub const INVALID_OBJECT_ID: u32 = 0xE0000000;
|
||||||
|
|
||||||
|
/// Maxmimum length of a character's name.
|
||||||
|
pub const CHAR_NAME_MAX_LENGTH: usize = 32;
|
||||||
|
|
||||||
pub(crate) fn read_string(byte_stream: Vec<u8>) -> String {
|
pub(crate) fn read_string(byte_stream: Vec<u8>) -> String {
|
||||||
let str = String::from_utf8(byte_stream).unwrap();
|
let str = String::from_utf8(byte_stream).unwrap();
|
||||||
str.trim_matches(char::from(0)).to_string() // trim \0 from the end of strings
|
str.trim_matches(char::from(0)).to_string() // trim \0 from the end of strings
|
||||||
|
|
|
@ -26,11 +26,6 @@ pub mod packet;
|
||||||
/// Logic server-specific code.
|
/// Logic server-specific code.
|
||||||
pub mod login;
|
pub mod login;
|
||||||
|
|
||||||
pub const INVALID_OBJECT_ID: u32 = 0xE0000000;
|
|
||||||
|
|
||||||
/// Maxmimum length of a character's name.
|
|
||||||
pub const CHAR_NAME_MAX_LENGTH: usize = 32;
|
|
||||||
|
|
||||||
pub fn setup_default_environment() -> Environment<'static> {
|
pub fn setup_default_environment() -> Environment<'static> {
|
||||||
let mut env = Environment::new();
|
let mut env = Environment::new();
|
||||||
env.add_template("admin.html", include_str!("../templates/admin.html"))
|
env.add_template("admin.html", include_str!("../templates/admin.html"))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
|
|
||||||
use crate::CHAR_NAME_MAX_LENGTH;
|
use crate::common::CHAR_NAME_MAX_LENGTH;
|
||||||
|
|
||||||
use super::{read_string, write_string};
|
use super::{read_string, write_string};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
|
|
||||||
use crate::CHAR_NAME_MAX_LENGTH;
|
use crate::common::CHAR_NAME_MAX_LENGTH;
|
||||||
|
|
||||||
use super::{read_string, write_string};
|
use super::{read_string, write_string};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
INVALID_OBJECT_ID,
|
common::{CustomizeData, INVALID_OBJECT_ID, timestamp_secs},
|
||||||
common::{CustomizeData, timestamp_secs},
|
|
||||||
config::get_config,
|
config::get_config,
|
||||||
packet::{PacketSegment, SegmentType},
|
packet::{PacketSegment, SegmentType},
|
||||||
world::ipc::{
|
world::ipc::{
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
|
|
||||||
use crate::CHAR_NAME_MAX_LENGTH;
|
use crate::common::{CHAR_NAME_MAX_LENGTH, CustomizeData, read_string, write_string};
|
||||||
use crate::common::{CustomizeData, read_string, write_string};
|
|
||||||
|
|
||||||
use super::StatusEffect;
|
use super::StatusEffect;
|
||||||
use super::position::Position;
|
use super::position::Position;
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
|
|
||||||
use crate::{
|
use crate::common::{CHAR_NAME_MAX_LENGTH, read_string, write_string};
|
||||||
CHAR_NAME_MAX_LENGTH,
|
|
||||||
common::{read_string, write_string},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
|
|
||||||
use crate::{
|
use crate::common::{CHAR_NAME_MAX_LENGTH, read_string, write_string};
|
||||||
CHAR_NAME_MAX_LENGTH,
|
|
||||||
common::{read_string, write_string},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[brw(repr = u8)]
|
#[brw(repr = u8)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue