better Minf info

png-branch
an 2019-03-06 03:42:54 -05:00
parent 7d0dc07e0b
commit 978e5b878e
3 changed files with 36 additions and 28 deletions

View File

@ -957,7 +957,7 @@ Static Map Info is 88 bytes.
| ---- | ---- | ------ |
| `EnvCode` | `u16` | `0` |
| `PhysicsId` | `u16` | `2` |
| `MusicId` | `u16` | `4` |
| `LandscapeId` | `u16` | `4` |
| `MissionFlags` | `u16` | `6` |
| `EnvFlags` | `u16` | `8` |
| `Name` | `u8[66]` | `18` |
@ -965,6 +965,14 @@ Static Map Info is 88 bytes.
- `EnvCode` is a preset number for texture collections and some other things
such as media (liquid) presets.
- `PhysicsId` used to be used for specifying three physics models: one for the
Forge editor, one for the game, and one for low-gravity. However, the first one
ended up being useless and the third was made into a map flag instead which
simply modifies the current physics model. This should always be set to `1` by
new editors.
- `LandscapeId` is the landscape number to use for the sky. This starts at `0`,
since it's an offset into the landscape collections. If `DataVersion` is
`DataM1`, then this is used as the music index instead.
- `MissionFlags` is a Mission Flags bit field.
- `EnvFlags` is an Environment Flags bit field.
- `Name` is the level name, intended to be 65 bytes, but one padding byte is

View File

@ -193,11 +193,6 @@ fn main() -> ResultS<()>
StoreTrue,
"wad: Dump all known chunks");
arg!("--wad-dump-unknown",
opt.wad_unknown,
StoreTrue,
"wad: Dump all unknown chunks");
arg!("--wad-write-header",
opt.wad_header,
StoreTrue,
@ -261,7 +256,6 @@ struct Options
shp_seq: bool,
snd_dump: bool,
snd_write: bool,
wad_unknown: bool,
wad_wrt_all: bool,
wad_header: bool,
}

View File

@ -50,9 +50,9 @@ pub fn read_minf(b: &[u8]) -> ResultS<Minf>
{
read_data! {
88, BE in b =>
env_code = u16[0];
physi_id = u16[2];
music_id = u16[4];
texture_id = u16[0];
physics_id = u16[2];
skypict_id = u16[4];
missi_flags = u16[6];
envir_flags = u16[8];
level_name = mac_roman_cstr[18..84];
@ -63,8 +63,8 @@ pub fn read_minf(b: &[u8]) -> ResultS<Minf>
let envir_flags = flag_ok!(EnvFlags, envir_flags)?;
let entry_flags = flag_ok!(EntFlags, entry_flags)?;
Ok(Minf{env_code, physi_id, music_id, missi_flags, envir_flags, entry_flags,
level_name})
Ok(Minf{texture_id, physics_id, skypict_id, missi_flags, envir_flags,
entry_flags, level_name})
}
/// Reads an old `Minf` chunk.
@ -495,8 +495,22 @@ impl Default for PolyType
fn default() -> Self {PolyType::Normal}
}
impl Default for Minf
{
fn default() -> Self
{
Minf{texture_id: 0,
physics_id: 1,
skypict_id: 0,
missi_flags: MsnFlags::empty(),
envir_flags: EnvFlags::empty(),
entry_flags: EntFlags::Solo,
level_name: "Map".to_string()}
}
}
/// A point in world-space.
#[derive(Clone, Default, PartialEq, serde::Serialize)]
#[derive(Clone, Debug, Default, PartialEq, serde::Serialize)]
pub struct Point
{
pub x: Unit,
@ -683,12 +697,12 @@ pub struct Note
}
/// Static map information.
#[derive(Debug, Default, PartialEq, serde::Serialize)]
#[derive(Debug, PartialEq, serde::Serialize)]
pub struct Minf
{
pub env_code: u16,
pub physi_id: u16,
pub music_id: u16,
pub texture_id: u16,
pub physics_id: u16,
pub skypict_id: u16,
pub missi_flags: MsnFlags,
pub envir_flags: EnvFlags,
pub entry_flags: EntFlags,
@ -757,7 +771,7 @@ bitflags! {
bitflags! {
/// Static environment flags.
#[derive(Default, serde::Serialize)]
#[derive(serde::Serialize)]
pub struct EnvFlags: u16
{
const Vacuum = 1;
@ -776,7 +790,7 @@ bitflags! {
bitflags! {
/// Static entry point flags.
#[derive(Default, serde::Serialize)]
#[derive(serde::Serialize)]
pub struct EntFlags: u32
{
const Solo = 1;
@ -792,7 +806,7 @@ bitflags! {
bitflags! {
/// Static mission flags.
#[derive(Default, serde::Serialize)]
#[derive(serde::Serialize)]
pub struct MsnFlags: u16
{
const Extermination = 1;
@ -922,14 +936,6 @@ c_enum! {
}
}
impl std::fmt::Debug for Point
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
{
write!(f, "({}, {})", self.x, self.y)
}
}
pub const TICKS_PER_SECOND: u16 = 30;
const OLD_LIGHT_DEFINITIONS: [Light; 8] = [