mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-24 21:37:46 +00:00
Add support for writing chardat files
This commit is contained in:
parent
dccc4e3586
commit
09c0d199f2
1 changed files with 16 additions and 2 deletions
|
@ -1,9 +1,9 @@
|
||||||
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
use std::io::Cursor;
|
use std::io::{BufWriter, Cursor};
|
||||||
|
|
||||||
use binrw::BinRead;
|
use binrw::{BinRead, BinWrite};
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
|
|
||||||
use crate::gamedata::MemoryBuffer;
|
use crate::gamedata::MemoryBuffer;
|
||||||
|
@ -150,4 +150,18 @@ impl CharDat {
|
||||||
|
|
||||||
Some(CharDat::read(&mut cursor).ok()?)
|
Some(CharDat::read(&mut cursor).ok()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Writes a new dat file
|
||||||
|
pub fn write_to_buffer(&self) -> Option<MemoryBuffer> {
|
||||||
|
let mut buffer = MemoryBuffer::new();
|
||||||
|
|
||||||
|
{
|
||||||
|
let cursor = Cursor::new(&mut buffer);
|
||||||
|
let mut writer = BufWriter::new(cursor);
|
||||||
|
|
||||||
|
self.write_le(&mut writer).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(buffer)
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue