mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-01-01 08:37:42 +00:00
slight cleanup
This commit is contained in:
parent
a203af7e7b
commit
6d9ed16668
2
build.rs
2
build.rs
|
@ -5,7 +5,7 @@ use std::env;
|
|||
|
||||
fn main() {
|
||||
// let dest = PathBuf::from(&env::var("OUT_DIR").unwrap());
|
||||
let target = env::var("TARGET").unwrap_or_else(|e| panic!(e));
|
||||
let target = env::var("TARGET").unwrap_or_else(|e| panic!("{}", e));
|
||||
let is_android = cfg!(target_os = "android") || (cfg!(target_os = "linux") && target.contains("android")); // hack
|
||||
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
|
|
@ -8,7 +8,6 @@ use crate::framework::graphics;
|
|||
use crate::map::WaterRegionType;
|
||||
use crate::player::Player;
|
||||
use crate::shared_game_state::SharedGameState;
|
||||
use crate::framework::graphics::BlendMode;
|
||||
|
||||
const TENSION: f32 = 0.03;
|
||||
const DAMPENING: f32 = 0.01;
|
||||
|
@ -116,8 +115,8 @@ impl WaterRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
impl GameEntity<(&Player)> for WaterRenderer {
|
||||
fn tick(&mut self, state: &mut SharedGameState, (player): (&Player)) -> GameResult<()> {
|
||||
impl GameEntity<&Player> for WaterRenderer {
|
||||
fn tick(&mut self, state: &mut SharedGameState, player: &Player) -> GameResult<()> {
|
||||
let player_x = player.x as f32 / 512.0 + 8.0;
|
||||
let player_y = player.y as f32 / 512.0 + 8.0;
|
||||
|
||||
|
|
|
@ -479,7 +479,7 @@ pub fn load_gl(gl_context: &mut GLContext) -> &'static Gl {
|
|||
|
||||
let gl = gl::Gles2::load_with(|ptr| (gl_context.get_proc_address)(&mut gl_context.user_data, ptr));
|
||||
|
||||
let version = unsafe {
|
||||
let version = {
|
||||
let p = gl.GetString(gl::VERSION);
|
||||
if p.is_null() {
|
||||
"unknown".to_owned()
|
||||
|
|
43
src/map.rs
43
src/map.rs
|
@ -7,13 +7,13 @@ use byteorder::{ReadBytesExt, LE};
|
|||
|
||||
use crate::common::{Color, Rect};
|
||||
use crate::encoding::read_cur_shift_jis;
|
||||
use crate::framework::context::Context;
|
||||
use crate::framework::error::GameError::ResourceLoadError;
|
||||
use crate::framework::error::{GameError, GameResult};
|
||||
use crate::shared_game_state::TileSize;
|
||||
use crate::stage::{StageData, PxPackScroll, PxPackStageData};
|
||||
use crate::str;
|
||||
use crate::framework::filesystem;
|
||||
use crate::framework::context::Context;
|
||||
use crate::shared_game_state::TileSize;
|
||||
use crate::stage::{PxPackScroll, PxPackStageData, StageData};
|
||||
use crate::str;
|
||||
|
||||
static SUPPORTED_PXM_VERSIONS: [u8; 1] = [0x10];
|
||||
static SUPPORTED_PXE_VERSIONS: [u8; 2] = [0, 0x10];
|
||||
|
@ -67,7 +67,12 @@ impl Map {
|
|||
Ok(Map { width, height, tiles, attrib, tile_size: TileSize::Tile16x16 })
|
||||
}
|
||||
|
||||
pub fn load_pxpack<R: io::Read>(mut map_data: R, root: &str, data: &mut StageData, ctx: &mut Context) -> GameResult<Map> {
|
||||
pub fn load_pxpack<R: io::Read>(
|
||||
mut map_data: R,
|
||||
root: &str,
|
||||
data: &mut StageData,
|
||||
ctx: &mut Context,
|
||||
) -> GameResult<Map> {
|
||||
let mut magic = [0u8; 16];
|
||||
|
||||
map_data.read_exact(&mut magic)?;
|
||||
|
@ -95,7 +100,7 @@ impl Map {
|
|||
}
|
||||
|
||||
Ok(chars.iter().collect())
|
||||
};
|
||||
}
|
||||
|
||||
fn skip_string<R: io::Read>(map_data: &mut R) -> GameResult {
|
||||
let bytes = map_data.read_u8()? as u32;
|
||||
|
@ -104,7 +109,7 @@ impl Map {
|
|||
}
|
||||
|
||||
Ok(())
|
||||
};
|
||||
}
|
||||
|
||||
let map_name = read_string(&mut map_data)?;
|
||||
skip_string(&mut map_data)?; // left, right, up, down
|
||||
|
@ -131,9 +136,15 @@ impl Map {
|
|||
map_data.read_u8()?; // ignored
|
||||
let scroll_bg = PxPackScroll::from(map_data.read_u8()?);
|
||||
|
||||
if tileset_fg == "" { tileset_fg = data.tileset.filename() }
|
||||
if tileset_mg == "" { tileset_mg = data.tileset.filename() }
|
||||
if tileset_bg == "" { tileset_bg = data.tileset.filename() }
|
||||
if tileset_fg == "" {
|
||||
tileset_fg = data.tileset.filename()
|
||||
}
|
||||
if tileset_mg == "" {
|
||||
tileset_mg = data.tileset.filename()
|
||||
}
|
||||
if tileset_bg == "" {
|
||||
tileset_bg = data.tileset.filename()
|
||||
}
|
||||
|
||||
let mut tiles = Vec::new();
|
||||
let mut attrib = [0u8; 0x100];
|
||||
|
@ -189,7 +200,10 @@ impl Map {
|
|||
if size_bg != 0 {
|
||||
map_data.read_u8()?;
|
||||
tiles.resize(size_fg as usize + size_mg as usize + size_bg as usize, 0u8);
|
||||
map_data.read_exact(&mut tiles[(size_fg as usize + size_mg as usize)..(size_fg as usize + size_mg as usize + size_bg as usize)])?;
|
||||
map_data.read_exact(
|
||||
&mut tiles
|
||||
[(size_fg as usize + size_mg as usize)..(size_fg as usize + size_mg as usize + size_bg as usize)],
|
||||
)?;
|
||||
}
|
||||
|
||||
if let Ok(mut attrib_data) = filesystem::open(ctx, [root, "Stage/", &tileset_fg, ".pxa"].join("")) {
|
||||
|
@ -250,7 +264,10 @@ impl Map {
|
|||
};
|
||||
}
|
||||
} else {
|
||||
log::warn!("No tile attribute data found for foreground tileset {}, collision might be broken.", tileset_fg);
|
||||
log::warn!(
|
||||
"No tile attribute data found for foreground tileset {}, collision might be broken.",
|
||||
tileset_fg
|
||||
);
|
||||
}
|
||||
|
||||
if map_name != "" {
|
||||
|
@ -269,7 +286,7 @@ impl Map {
|
|||
size_mg: (width_mg, height_mg),
|
||||
size_bg: (width_bg, height_bg),
|
||||
offset_mg: size_fg,
|
||||
offset_bg: size_fg + size_mg
|
||||
offset_bg: size_fg + size_mg,
|
||||
});
|
||||
|
||||
Ok(Map { width: width_fg, height: height_fg, tiles, attrib, tile_size: TileSize::Tile8x8 })
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use num_traits::clamp;
|
||||
|
||||
use crate::caret::CaretType;
|
||||
use crate::common::{Condition, Direction, Flag, Rect};
|
||||
use crate::npc::list::NPCList;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::ops::Div;
|
||||
|
||||
use bitvec::array::BitArray;
|
||||
use bitvec::vec::BitVec;
|
||||
use chrono::{Datelike, Local};
|
||||
|
||||
|
|
Loading…
Reference in a new issue