From b3e3f9379efc32ae86e6d7b0afb6e2b75f2cc7f6 Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Wed, 28 Jun 2023 14:13:47 +0100 Subject: [PATCH] fix some jak 1 hint subtitles not showing up (#2782) There is one instance of the same hint being played for different IDs which was breaking things. --- common/serialization/subtitles/subtitles_ser.cpp | 2 +- common/serialization/subtitles/subtitles_ser.h | 2 +- goal_src/jak1/pc/subtitle.gc | 14 ++++++-------- goalc/compiler/Compiler.cpp | 8 ++++---- goalc/compiler/compilation/Macro.cpp | 12 ++++++++++-- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/common/serialization/subtitles/subtitles_ser.cpp b/common/serialization/subtitles/subtitles_ser.cpp index ae2e947e9..4d02585b4 100644 --- a/common/serialization/subtitles/subtitles_ser.cpp +++ b/common/serialization/subtitles/subtitles_ser.cpp @@ -523,7 +523,7 @@ void parse_subtitle_json(GameSubtitleDB& db, const GameSubtitleDefinitionFile& f } // Now hints for (const auto& [hint_name, hint_info] : meta_file.hints) { - GameSubtitleSceneInfo scene(SubtitleSceneKind::Hint); + GameSubtitleSceneInfo scene(SubtitleSceneKind::HintNamed); scene.set_name(hint_name); /*scene.m_sorting_group = db.m_subtitle_groups->find_group(hint_name); scene.m_sorting_group_idx = db.m_subtitle_groups->find_group_index(scene.m_sorting_group);*/ diff --git a/common/serialization/subtitles/subtitles_ser.h b/common/serialization/subtitles/subtitles_ser.h index 35aad008f..74b49ffe5 100644 --- a/common/serialization/subtitles/subtitles_ser.h +++ b/common/serialization/subtitles/subtitles_ser.h @@ -152,7 +152,7 @@ class GameSubtitleSceneInfo { bool operator<(const SubtitleLine& other) const { return (frame < other.frame); } }; - GameSubtitleSceneInfo(SubtitleSceneKind kind) : m_kind(kind) {} + GameSubtitleSceneInfo(SubtitleSceneKind kind) : m_kind(kind), m_id(0), m_sorting_group_idx(-1) {} const std::string& name() const { return m_name; } const std::vector& lines() const { return m_lines; } diff --git a/goal_src/jak1/pc/subtitle.gc b/goal_src/jak1/pc/subtitle.gc index 13f5fa205..1381867b8 100644 --- a/goal_src/jak1/pc/subtitle.gc +++ b/goal_src/jak1/pc/subtitle.gc @@ -191,13 +191,14 @@ (defmethod get-scene-by-name subtitle-text-info ((obj subtitle-text-info) (kind pc-subtitle-channel) (name string)) "get a subtitle scene info with the corresponding name. #f = none found" - ;; invalid kind so return invalid scene. - (if (or (not name) (= kind (pc-subtitle-channel invalid))) + ;; invalid name so return invalid scene. + (if (not name) (return (the subtitle-text #f))) (dotimes (i (-> obj length)) ;; name and kind matches, return that! - (when (and (= kind (-> obj data i kind)) (string= (-> obj data i name) name)) + (when (and (or (= kind (pc-subtitle-channel invalid)) (= kind (-> obj data i kind))) + (string= (-> obj data i name) name)) (return (-> obj data i)) ) ) @@ -207,13 +208,10 @@ (defmethod get-scene-by-text-id subtitle-text-info ((obj subtitle-text-info) (kind pc-subtitle-channel) (id text-id)) "get a subtitle scene info with the corresponding name. #f = none found" - ;; invalid kind so return invalid scene. - (if (= kind (pc-subtitle-channel invalid)) - (return (the subtitle-text #f))) - (dotimes (i (-> obj length)) ;; name and kind matches, return that! - (when (and (= kind (-> obj data i kind)) (= (-> obj data i id) id)) + (when (and (or (= kind (pc-subtitle-channel invalid)) (= kind (-> obj data i kind))) + (= (-> obj data i id) id)) (return (-> obj data i)) ) ) diff --git a/goalc/compiler/Compiler.cpp b/goalc/compiler/Compiler.cpp index 7c500c70b..6078c3329 100644 --- a/goalc/compiler/Compiler.cpp +++ b/goalc/compiler/Compiler.cpp @@ -202,8 +202,8 @@ Val* Compiler::compile_error_guard(const goos::Object& code, Env* env) { lg::print(fg(fmt::color::yellow) | fmt::emphasis::bold, "Code:\n"); auto code_str = pretty_print::to_string(code, 120); - if (code_str.size() > 120 * 35) { - code_str = code_str.substr(0, 120 * 35) + "..."; + if (code_str.size() > 120 * 30) { + code_str = code_str.substr(0, 120 * 30) + "..."; } lg::print("{}\n", code_str); @@ -229,8 +229,8 @@ Val* Compiler::compile_error_guard(const goos::Object& code, Env* env) { lg::print(fg(fmt::color::yellow) | fmt::emphasis::bold, "Code:\n"); auto code_str = pretty_print::to_string(code, 120); - if (code_str.size() > 120 * 35) { - code_str = code_str.substr(0, 120 * 35) + "..."; + if (code_str.size() > 120 * 30) { + code_str = code_str.substr(0, 120 * 30) + "..."; } lg::print("{}\n", code_str); diff --git a/goalc/compiler/compilation/Macro.cpp b/goalc/compiler/compilation/Macro.cpp index 5a178b23e..b0d02b0db 100644 --- a/goalc/compiler/compilation/Macro.cpp +++ b/goalc/compiler/compilation/Macro.cpp @@ -52,7 +52,11 @@ Val* Compiler::compile_goos_macro(const goos::Object& o, bool good_info = false; auto info = m_goos.reader.db.get_info_for(o, &good_info); lg::print(fg(fmt::color::yellow) | fmt::emphasis::bold, "Code:\n"); - lg::print("{}\n", pretty_print::to_string(goos_result, 120)); + auto code_str = pretty_print::to_string(goos_result, 120); + if (code_str.size() > 120 * 30) { + code_str = code_str.substr(0, 120 * 30) + "..."; + } + lg::print("{}\n", code_str); lg::print(fg(fmt::color::yellow) | fmt::emphasis::bold, "From macro: "); lg::print(fg(fmt::color::orange), "{}\n", name.print()); if (good_info) { @@ -70,7 +74,11 @@ Val* Compiler::compile_goos_macro(const goos::Object& o, bool good_info = false; auto info = m_goos.reader.db.get_info_for(o, &good_info); lg::print(fg(fmt::color::yellow) | fmt::emphasis::bold, "Code:\n"); - lg::print("{}\n", pretty_print::to_string(goos_result, 120)); + auto code_str = pretty_print::to_string(goos_result, 120); + if (code_str.size() > 120 * 30) { + code_str = code_str.substr(0, 120 * 30) + "..."; + } + lg::print("{}\n", code_str); lg::print(fg(fmt::color::yellow) | fmt::emphasis::bold, "From macro: "); lg::print(fg(fmt::color::orange), "{}\n", name.print()); if (good_info) {