1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-22 13:42:47 +00:00

map: use GameResult

This commit is contained in:
Alula 2020-08-28 06:55:45 +02:00
parent b680db9114
commit 0ace1831e2
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA

View file

@ -3,6 +3,10 @@ use std::io::{Error, ErrorKind};
use byteorder::{LE, ReadBytesExt};
use crate::ggez::GameError::ResourceLoadError;
use crate::ggez::GameResult;
use crate::str;
pub struct Map {
pub width: usize,
pub height: usize,
@ -11,13 +15,13 @@ pub struct Map {
}
impl Map {
pub fn load_from<R: io::Read>(mut map_data: R, mut attrib_data: R) -> io::Result<Self> {
pub fn load_from<R: io::Read>(mut map_data: R, mut attrib_data: R) -> GameResult<Self> {
let mut magic = [0; 3];
map_data.read_exact(&mut magic)?;
if &magic != b"PXM" {
return Err(Error::new(ErrorKind::InvalidData, "Invalid magic"));
return Err(ResourceLoadError(str!( "Invalid magic")));
}
map_data.read_i8()?; // unused