-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proper implementation of the adjustments for the new schema
- Loading branch information
1 parent
0dae7f7
commit a15b5de
Showing
8 changed files
with
58,029 additions
and
147,967 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
use std::marker::PhantomData; | ||
|
||
use cs2_schema_declaration::{ | ||
MemoryHandle, | ||
Ptr, | ||
SchemaValue, | ||
}; | ||
|
||
// UtlRBTree has the following layout: | ||
// pub struct UtlRBTree<T> { | ||
// pub elements: Ptr<[UtlRBTreeNode<T>]> = 0x08, | ||
// pub start_node: i16 = 0x18, | ||
// pub entry_count: u16 = 0x1A, | ||
// } | ||
pub struct UtlRBTree<T> { | ||
memory: MemoryHandle, | ||
_dummy: PhantomData<T>, | ||
} | ||
|
||
impl<T> UtlRBTree<T> { | ||
pub fn elements(&self) -> anyhow::Result<Ptr<[UtlRBTreeNode<T>]>> { | ||
self.memory.reference_schema(0x08) | ||
} | ||
|
||
pub fn start_node(&self) -> anyhow::Result<u16> { | ||
self.memory.reference_schema(0x18) | ||
} | ||
|
||
pub fn entry_count(&self) -> anyhow::Result<u16> { | ||
self.memory.reference_schema(0x1A) | ||
} | ||
} | ||
|
||
impl<T: SchemaValue> UtlRBTree<T> { | ||
pub fn value(&self) -> anyhow::Result<T> { | ||
self.memory.reference_schema(0x08) | ||
} | ||
} | ||
|
||
impl<T: SchemaValue> SchemaValue for UtlRBTree<T> { | ||
fn value_size() -> Option<u64> { | ||
Some(0x20) | ||
} | ||
|
||
fn from_memory(memory: MemoryHandle) -> anyhow::Result<Self> { | ||
Ok(Self { | ||
memory, | ||
_dummy: Default::default(), | ||
}) | ||
} | ||
} | ||
|
||
/// UtlRBTreeNode has the following layout: | ||
/// struct UtlRBTreeNode<T> { | ||
/// pub left: i16, // 0x0000 | ||
/// pub right: i16, // 0x0002 | ||
/// pub parent: i16 // 0x0004 | ||
/// pub tag: i16, // 0x0006 | ||
/// pub value: T // 0x0008 | ||
/// } | ||
/// N is most likel 256 (u8) large | ||
pub struct UtlRBTreeNode<T> { | ||
memory: MemoryHandle, | ||
_dummy: PhantomData<T>, | ||
} | ||
|
||
impl<T> UtlRBTreeNode<T> { | ||
pub fn left_node(&self) -> anyhow::Result<i16> { | ||
self.memory.reference_schema(0x00) | ||
} | ||
|
||
pub fn right_node(&self) -> anyhow::Result<i16> { | ||
self.memory.reference_schema(0x02) | ||
} | ||
|
||
pub fn parent_node(&self) -> anyhow::Result<i16> { | ||
self.memory.reference_schema(0x04) | ||
} | ||
|
||
pub fn tag(&self) -> anyhow::Result<i16> { | ||
self.memory.reference_schema(0x06) | ||
} | ||
} | ||
|
||
impl<T: SchemaValue> UtlRBTreeNode<T> { | ||
pub fn value(&self) -> anyhow::Result<T> { | ||
self.memory.reference_schema(0x08) | ||
} | ||
} | ||
|
||
impl<T: SchemaValue> SchemaValue for UtlRBTreeNode<T> { | ||
fn value_size() -> Option<u64> { | ||
Some(T::value_size().expect("T to have a size") + 0x08) | ||
} | ||
|
||
fn from_memory(memory: MemoryHandle) -> anyhow::Result<Self> { | ||
Ok(Self { | ||
memory, | ||
_dummy: Default::default(), | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.