mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-04-04 05:25:37 +08:00
Fix UtlTsHash::elements
bug causing missing schema entries
This commit is contained in:
parent
ce25283e79
commit
9765aff73f
src
@ -28,7 +28,7 @@ pub struct Class {
|
||||
pub name: String,
|
||||
pub module_name: String,
|
||||
pub parent: Option<Box<Class>>,
|
||||
pub metadata: Vec<ClassMetadata>,
|
||||
pub metadata: Option<Vec<ClassMetadata>>,
|
||||
pub fields: Vec<ClassField>,
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ fn read_class_binding(
|
||||
.map(Box::new)
|
||||
});
|
||||
|
||||
let metadata = read_class_binding_metadata(process, &binding)?;
|
||||
let metadata = read_class_binding_metadata(process, &binding).map(Some)?;
|
||||
let fields = read_class_binding_fields(process, &binding)?;
|
||||
|
||||
debug!(
|
||||
@ -108,7 +108,7 @@ fn read_class_binding(
|
||||
binding_ptr.to_umem(),
|
||||
module_name,
|
||||
parent.as_ref().map(|parent| parent.name.clone()),
|
||||
metadata.len(),
|
||||
metadata.as_ref().map(|metadata| metadata.len()).unwrap_or(0),
|
||||
fields.len()
|
||||
);
|
||||
|
||||
@ -159,7 +159,7 @@ fn read_class_binding_metadata(
|
||||
binding: &SchemaClassBinding,
|
||||
) -> Result<Vec<ClassMetadata>> {
|
||||
if binding.static_metadata.is_null() {
|
||||
return Ok(Vec::new());
|
||||
return Err(Error::Other("class metadata is null"));
|
||||
}
|
||||
|
||||
(0..binding.static_metadata_count)
|
||||
|
@ -64,7 +64,9 @@ impl CodeGen for SchemaMap {
|
||||
writeln!(fmt, "// Parent: {}", parent_name)?;
|
||||
writeln!(fmt, "// Fields count: {}", class.fields.len())?;
|
||||
|
||||
write_metadata(fmt, &class.metadata)?;
|
||||
if let Some(metadata) = &class.metadata {
|
||||
write_metadata(fmt, metadata)?;
|
||||
}
|
||||
|
||||
fmt.block(
|
||||
&format!("public static class {}", sanitize_name(&class.name)),
|
||||
@ -152,7 +154,9 @@ impl CodeGen for SchemaMap {
|
||||
writeln!(fmt, "// Parent: {}", parent_name)?;
|
||||
writeln!(fmt, "// Fields count: {}", class.fields.len())?;
|
||||
|
||||
write_metadata(fmt, &class.metadata)?;
|
||||
if let Some(metadata) = &class.metadata {
|
||||
write_metadata(fmt, metadata)?;
|
||||
}
|
||||
|
||||
fmt.block(
|
||||
&format!("namespace {}", sanitize_name(&class.name)),
|
||||
@ -198,6 +202,8 @@ impl CodeGen for SchemaMap {
|
||||
|
||||
let metadata: Vec<_> = class
|
||||
.metadata
|
||||
.as_ref()
|
||||
.unwrap_or(&vec![])
|
||||
.iter()
|
||||
.map(|metadata| match metadata {
|
||||
ClassMetadata::NetworkChangeCallback { name } => json!({
|
||||
@ -319,7 +325,9 @@ impl CodeGen for SchemaMap {
|
||||
writeln!(fmt, "// Parent: {}", parent_name)?;
|
||||
writeln!(fmt, "// Fields count: {}", class.fields.len())?;
|
||||
|
||||
write_metadata(fmt, &class.metadata)?;
|
||||
if let Some(metadata) = &class.metadata {
|
||||
write_metadata(fmt, metadata)?;
|
||||
}
|
||||
|
||||
fmt.block(
|
||||
&format!("pub mod {}", sanitize_name(&class.name)),
|
||||
|
@ -74,19 +74,19 @@ pub struct UtlTsHash<T: HashData, K: HashKey = u64> {
|
||||
|
||||
impl<T: HashData, K: HashKey> UtlTsHash<T, K> {
|
||||
pub fn elements(&self, process: &mut IntoProcessInstanceArcBox<'_>) -> Result<Vec<T>> {
|
||||
let block_size = self.entry.blocks_per_blob as usize;
|
||||
let num_blocks = self.entry.block_alloc_size as usize;
|
||||
|
||||
let mut element_ptr = self.buckets.unallocated_data;
|
||||
|
||||
let mut list = Vec::with_capacity(num_blocks);
|
||||
let min_size =
|
||||
(self.entry.blocks_per_blob as usize).min(self.entry.block_alloc_size as usize);
|
||||
|
||||
let mut list = Vec::with_capacity(min_size);
|
||||
|
||||
while !element_ptr.is_null() {
|
||||
let element = element_ptr.read(process)?;
|
||||
|
||||
for i in 0..num_blocks {
|
||||
if i >= block_size || list.len() >= block_size {
|
||||
break;
|
||||
for i in 0..min_size {
|
||||
if list.len() >= self.entry.block_alloc_size as usize {
|
||||
return Ok(list);
|
||||
}
|
||||
|
||||
list.push(element.block_list[i].data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user