Skip to content

Commit 536a3a4

Browse files
committed
fix: add safeopen parameter to load song function
1 parent e805663 commit 536a3a4

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

scripts/open_song_nbs/open_song_nbs.gml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function open_song_nbs(fn, sounds_path = "") {
1+
function open_song_nbs(fn, sounds_path = "", safeopen) {
22

33
var str, ca, cb, a, b, hei, byte1, byte2, song_first_custom_index, custom_index_diff
44

@@ -24,6 +24,10 @@ function open_song_nbs(fn, sounds_path = "") {
2424
buffer_read_short()
2525
}
2626
} else {
27+
if (safeopen) {
28+
message("This file doesn't look like a valid song!", "Error")
29+
return
30+
}
2731
if (language != 1) {if (show_oldwarning) message("Warning: You are opening an older NBS file. Saving this file will make it incompatible with older Note Block Studio versions.","Warning")}
2832
else {if (show_oldwarning) message("警告:你正在打开旧版的 NBS 文件。保存此文件会使其与旧版 Note Block Studio 不兼容。","警告")}
2933
song_nbs_version = 0

0 commit comments

Comments
 (0)