1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-22 04:37:46 +00:00

Improve log documentation

This commit is contained in:
Joshua Goins 2023-12-02 20:26:34 -05:00
parent 67eab58c24
commit c79cfc3df6

View file

@ -21,7 +21,7 @@ pub struct ChatLogHeader {
#[binrw] #[binrw]
#[brw(repr = u8)] #[brw(repr = u8)]
#[derive(Debug)] #[derive(Debug)]
enum EventFilter { pub enum EventFilter {
SystemMessages = 3, SystemMessages = 3,
Unknown = 20, Unknown = 20,
ProgressionMessage = 64, ProgressionMessage = 64,
@ -35,7 +35,7 @@ enum EventFilter {
#[binrw] #[binrw]
#[derive(Debug)] #[derive(Debug)]
#[brw(repr = u8)] #[brw(repr = u8)]
enum EventChannel { pub enum EventChannel {
System = 0, System = 0,
ServerAnnouncement = 3, ServerAnnouncement = 3,
Unknown1 = 50, Unknown1 = 50,
@ -52,26 +52,32 @@ enum EventChannel {
#[derive(Debug)] #[derive(Debug)]
#[allow(dead_code)] #[allow(dead_code)]
#[brw(little)] #[brw(little)]
/// Represents an entry in the chat log
pub struct ChatLogEntry { pub struct ChatLogEntry {
timestamp: u32, timestamp: u32,
filter: EventFilter, /// The event filter
channel: EventChannel, pub filter: EventFilter,
/// The event channel
pub channel: EventChannel,
#[br(temp)] #[br(temp)]
#[bw(calc = 1)] #[bw(calc = 1)]
_garbage: u32, _garbage: u32,
/// The message
#[brw(ignore)] #[brw(ignore)]
message: String, pub message: String,
} }
#[derive(Debug)] #[derive(Debug)]
#[allow(dead_code)] #[allow(dead_code)]
/// Chat log, which contains previously recorded messages from other players
pub struct ChatLog { pub struct ChatLog {
entries: Vec<ChatLogEntry>, pub entries: Vec<ChatLogEntry>,
} }
impl ChatLog { impl ChatLog {
/// Reads an existing LOG file
pub fn from_existing(buffer: ByteSpan) -> Option<ChatLog> { pub fn from_existing(buffer: ByteSpan) -> Option<ChatLog> {
let mut cursor = Cursor::new(buffer); let mut cursor = Cursor::new(buffer);