SpaceManiac / SpacemanDMM

A BYOND language smartness provider, map renderer, and more.
https://marketplace.visualstudio.com/items?itemName=platymuus.dm-langclient
GNU General Public License v3.0
83 stars 83 forks source link

[Check fix] Map Renderer does not check DMI file versions, outputting "error loading icon" #277

Open Gesugao-san opened 3 years ago

Gesugao-san commented 3 years ago

My OS specifications

OS: Windows 20H2 (build 19042.1110) ├ BYOND: 514.1561 (Beta) └ WSL: Ubuntu 20.04.2 LTS StrongDMM: v1.9.1 [revision: e1a3ea8] └ StrongDMM Launcher: (v1.1.0) [01693a4]

Description of the problem itself

I was trying to compile an old Space Station 13 build called "OpenSS13" to try to upload it to a web map. Faced with the fact that when opening this map (of course, after analyzing the contents by viewing the file in text format, and changing the extension from ".dmp" to ".dmm"), StrongDDM simply crashes without explaining the reasons, began to sort out all possible reasons.

How I was able to deal with this problem

The clue was that when trying to render the map, the Map Renderer from SpacemanDMM indicated that it could not open one particular file → "Icons/wall.dmi".

Backtrace

root@Gesu-PC:/mnt/c/Users/Public/Documents/Projects/GitHub/openss13# export RUST_BACKTRACE=full
root@Gesu-PC:/mnt/c/Users/Public/Documents/Projects/GitHub/openss13# './../SpacemanDMM/target/release/dmm-tools' 'minimap' './_ss13h_new.dmm'
parsing spacestation13.dme
./_ss13h_new.dmm
    rendering from 1,1,1 to 100,100,8
    generating z=1
error loading icon: Icons/wall.dmi
  incorrect PNG signature, it''s no PNG or corrupted
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', src/dreammaker/dmi.rs:427:69
stack backtrace:
   0:     0x564d2de729d5 - std::backtrace_rs::backtrace::libunwind::trace::ha5edb8ba5c6b7a6c
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x564d2de729d5 - std::backtrace_rs::backtrace::trace_unsynchronized::h0de86d320a827db2
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x564d2de729d5 - std::sys_common::backtrace::_print_fmt::h97b9ad6f0a1380ff
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x564d2de729d5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h14be7eb08f97fe80
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x564d2dd51d1f - core::fmt::write::h2ca8877d3e0e52de
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/fmt/mod.rs:1094:17
   5:     0x564d2de721b4 - std::io::Write::write_fmt::h64f5987220b618f4
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/io/mod.rs:1584:15
   6:     0x564d2de71c8b - std::sys_common::backtrace::_print::h7f1a4097308f2e0a
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x564d2de71c8b - std::sys_common::backtrace::print::h1f799fc2ca7f5035
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x564d2de71c8b - std::panicking::default_hook::{{closure}}::hf38436e8a3ce1071
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:208:50
   9:     0x564d2de71005 - std::panicking::default_hook::he2f8f3fae11ed1dd
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:225:9
  10:     0x564d2de71005 - std::panicking::rust_panic_with_hook::h79a18548bd90c7d4
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:591:17
  11:     0x564d2de8c678 - std::panicking::begin_panic_handler::{{closure}}::h212a72cc08e25126
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:497:13
  12:     0x564d2de8c5ec - std::sys_common::backtrace::__rust_end_short_backtrace::hbd6897dd42bc0fcd
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:141:18
  13:     0x564d2de8c59d - rust_begin_unwind
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:493:5
  14:     0x564d2dce7120 - core::panicking::panic_fmt::h77ecd04e9b1dd84d
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/panicking.rs:92:14
  15:     0x564d2dce7812 - core::result::unwrap_failed::hcbdf25d28ce8f0ca
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/result.rs:1355:5
  16:     0x564d2de19936 - dreammaker::dmi::Metadata::from_file::h25c9127ab4244cc5
  17:     0x564d2dd64e04 - dmm_tools::icon_cache::load::h0e336245dcb66a96
  18:     0x564d2dd72b7f - dmm_tools::minimap::generate::h8de6c452d04fe0bb
  19:     0x564d2dd08ab6 - dmm_tools::run::{{closure}}::{{closure}}::hffb01489b367a23e
  20:     0x564d2dd0b80b - dmm_tools::run::{{closure}}::h1fb85c6842a74c22
  21:     0x564d2dd077e2 - dmm_tools::main::h5932087c80914194
  22:     0x564d2dd87983 - std::sys_common::backtrace::__rust_begin_short_backtrace::hdc246333700c669c
  23:     0x564d2dd0c211 - main
  24:     0x7f8a384880b3 - __libc_start_main
  25:     0x564d2dcf5d0e - _start
  26:                0x0 - <unknown>
root@Gesu-PC:/mnt/c/Users/Public/Documents/Projects/GitHub/openss13#

After I tried to modify and save problematic file, DreamMaker informed me that this file is in the old format (DMI v3 instead of DMI v4):

dreammaker_sviGiCbuQK

With which I agreed by re-saving the file.

The suggested solution

Research the difference between the two formats and introduce a version check for each ".dmi" file.


Post Scriptum

But after saving the file, when you try to use Map Renderer again, it still gives an error, no longer specifying the file... But I think that if you resave all the ".dmi" files in this way, the problem will go away.

root@Gesu-PC:/mnt/c/Users/Public/Documents/Projects/GitHub/openss13# export RUST_BACKTRACE=full
root@Gesu-PC:/mnt/c/Users/Public/Documents/Projects/GitHub/openss13# './../SpacemanDMM/target/release/dmm-tools' 'minimap' './_ss13h_new.dmm'
parsing spacestation13.dme
./_ss13h_new.dmm
    rendering from 1,1,1 to 100,100,8
    generating z=1
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', src/dreammaker/dmi.rs:427:69
stack backtrace:
   0:     0x564424b319d5 - std::backtrace_rs::backtrace::libunwind::trace::ha5edb8ba5c6b7a6c
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x564424b319d5 - std::backtrace_rs::backtrace::trace_unsynchronized::h0de86d320a827db2
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x564424b319d5 - std::sys_common::backtrace::_print_fmt::h97b9ad6f0a1380ff
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x564424b319d5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h14be7eb08f97fe80
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x564424a10d1f - core::fmt::write::h2ca8877d3e0e52de
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/fmt/mod.rs:1094:17
   5:     0x564424b311b4 - std::io::Write::write_fmt::h64f5987220b618f4
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/io/mod.rs:1584:15
   6:     0x564424b30c8b - std::sys_common::backtrace::_print::h7f1a4097308f2e0a
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x564424b30c8b - std::sys_common::backtrace::print::h1f799fc2ca7f5035
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x564424b30c8b - std::panicking::default_hook::{{closure}}::hf38436e8a3ce1071
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:208:50
   9:     0x564424b30005 - std::panicking::default_hook::he2f8f3fae11ed1dd
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:225:9
  10:     0x564424b30005 - std::panicking::rust_panic_with_hook::h79a18548bd90c7d4
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:591:17
  11:     0x564424b4b678 - std::panicking::begin_panic_handler::{{closure}}::h212a72cc08e25126
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:497:13
  12:     0x564424b4b5ec - std::sys_common::backtrace::__rust_end_short_backtrace::hbd6897dd42bc0fcd
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/sys_common/backtrace.rs:141:18
  13:     0x564424b4b59d - rust_begin_unwind
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/std/src/panicking.rs:493:5
  14:     0x5644249a6120 - core::panicking::panic_fmt::h77ecd04e9b1dd84d
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/panicking.rs:92:14
  15:     0x5644249a6812 - core::result::unwrap_failed::hcbdf25d28ce8f0ca
                               at /rustc/53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b/library/core/src/result.rs:1355:5
  16:     0x564424ad8936 - dreammaker::dmi::Metadata::from_file::h25c9127ab4244cc5
  17:     0x564424a23e04 - dmm_tools::icon_cache::load::h0e336245dcb66a96
  18:     0x564424a31b7f - dmm_tools::minimap::generate::h8de6c452d04fe0bb
  19:     0x5644249c7ab6 - dmm_tools::run::{{closure}}::{{closure}}::hffb01489b367a23e
  20:     0x5644249ca80b - dmm_tools::run::{{closure}}::h1fb85c6842a74c22
  21:     0x5644249c67e2 - dmm_tools::main::h5932087c80914194
  22:     0x564424a46983 - std::sys_common::backtrace::__rust_begin_short_backtrace::hdc246333700c669c
  23:     0x5644249cb211 - main
  24:     0x7f83a838d0b3 - __libc_start_main
  25:     0x5644249b4d0e - _start
  26:                0x0 - <unknown>
root@Gesu-PC:/mnt/c/Users/Public/Documents/Projects/GitHub/openss13#
Gesugao-san commented 3 years ago

Here is a alleged example of the visual difference between the two ".dmi" file formats that VS Code was able to show.

"Icons/turfs.dmi" image

Gesugao-san commented 3 years ago

"Icons/ammo.dmi" image

Gesugao-san commented 3 years ago

"Icons/Doorf.dmi" image

Gesugao-san commented 3 years ago

"Icons/ghost.dmi" image

Gesugao-san commented 3 years ago

"Icons/hi_pipe.dmi" image

Gesugao-san commented 3 years ago

"Icons/human.dmi" image

Gesugao-san commented 3 years ago

"Icons/meteor.dmi" image

Gesugao-san commented 3 years ago

"Icons/shards.dmi" image

Gesugao-san commented 3 years ago

"Icons/table.dmi" image

Gesugao-san commented 3 years ago

"Icons/zone_sel.dmi" image

SpaceManiac commented 3 years ago

It is true that SpacemanDMM does not currently support the v3 format. Neither does almost any tool other than DreamMaker itself. It is not well-documented, and it is used exclusively by historical codebases. I might be able to accept a PR which adds support but it is not really worth my time to implement myself.

Here is a alleged example of the visual difference between the two ".dmi" file formats that VS Code was able to show.

I'm surprised your VS Code can show the v3 format. Mine cannot. Do you have any extensions which might explain this?

Gesugao-san commented 3 years ago

It is true that SpacemanDMM does not currently support the v3 format. Neither does almost any tool other than DreamMaker itself. It is not well-documented, and it is used exclusively by historical codebases. I might be able to accept a PR which adds support but it is not really worth my time to implement myself.

I understand that, I just wish that people who do not know anything about the versions of the DMI could receive a warning asking them to check this version through the DreamMaker.

Here is a alleged example of the visual difference between the two ".dmi" file formats that VS Code was able to show.

I'm surprised your VS Code can show the v3 format. Mine cannot. Do you have any extensions which might explain this?

And yes, the VS Code was able to show such a difference not for all files. I think that some extension from this extension pack was able to display the DMI file:

https://marketplace.visualstudio.com/items?itemName=Goonstation.goonstation-extpack image

Gesugao-san commented 3 years ago

I'm surprised your VS Code can show the v3 format. Mine cannot.

@SpaceManiac How to make the VS Code display dmi files: image

SpaceManiac commented 3 years ago

How to make the ViS Code display dmi files:

I use this with success for v4 .dmi files because the previewer is able to interpret them as .png files, but it doesn't understand the v3 format.

Gesugao-san commented 3 years ago

How to make the ViS Code display dmi files:

I use this with success for v4 .dmi files because the previewer is able to interpret them as .png files, but it doesn't understand the v3 format.

Only part of the v3 files is not displayed for me.