1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-04 02:24:12 +02:00

remove the need to clone text entries

This commit is contained in:
Robin Appelman 2019-08-12 14:19:07 +02:00
commit 1b9befd165
3 changed files with 66 additions and 43 deletions

View file

@ -16,7 +16,7 @@ pub struct FixedUserdataSize {
#[derive(Debug)]
pub struct StringTable {
pub name: String,
pub entries: Vec<StringTableEntry>,
pub entries: Vec<(u16, StringTableEntry)>,
pub max_entries: u16,
pub fixed_userdata_size: Option<FixedUserdataSize>,
pub client_entries: Option<Vec<StringTableEntry>>,
@ -36,7 +36,11 @@ impl BitRead<LittleEndian> for StringTable {
fn read(stream: &mut Stream) -> ReadResult<Self> {
let name = stream.read()?;
let entry_count = stream.read_int(16)?;
let entries = stream.read_sized(entry_count as usize)?;
let mut entries = Vec::with_capacity(entry_count as usize);
for index in 0..entry_count {
entries.push((index, stream.read()?))
}
let client_entries = if stream.read_bool()? {
let count = stream.read_int(16)?;