Skip to content

Commit

Permalink
Merge remote-tracking branch 'open-goal/master' into h/j2-pilot-speeches
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser committed Dec 2, 2023
2 parents 6bbc1fe + a3af379 commit d17d10e
Show file tree
Hide file tree
Showing 146 changed files with 31,595 additions and 5,338 deletions.
4 changes: 4 additions & 0 deletions common/custom_data/TFrag3Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void ShrubDraw::serialize(Serializer& ser) {
ser.from_ptr(&num_triangles);
ser.from_ptr(&first_index_index);
ser.from_ptr(&num_indices);
ser.from_ptr(&proto_idx);
}

void InstancedStripDraw::serialize(Serializer& ser) {
Expand Down Expand Up @@ -416,6 +417,9 @@ void ShrubTree::serialize(Serializer& ser) {
for (auto& draw : static_draws) {
draw.serialize(ser);
}

ser.from_ptr(&has_per_proto_visibility_toggle);
ser.from_string_vector(&proto_names);
}

void BVH::serialize(Serializer& ser) {
Expand Down
8 changes: 7 additions & 1 deletion common/custom_data/Tfrag3Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace tfrag3 {
// - if changing any large things (vertices, vis, bvh, colors, textures) update get_memory_usage
// - if adding a new category to the memory usage, update extract_level to print it.

constexpr int TFRAG3_VERSION = 38;
constexpr int TFRAG3_VERSION = 39;

enum MemoryUsageCategory {
TEXTURE,
Expand Down Expand Up @@ -219,6 +219,8 @@ struct ShrubDraw {

// for debug counting.
u32 num_triangles = 0;

u16 proto_idx = 0;
void serialize(Serializer& ser);
};

Expand Down Expand Up @@ -430,6 +432,10 @@ struct ShrubTree {
std::vector<ShrubGpuVertex> vertices; // mesh vertices
} unpacked;

// jak 2 and later can toggle on and off visibility per proto by name
bool has_per_proto_visibility_toggle = false;
std::vector<std::string> proto_names;

void serialize(Serializer& ser);
void memory_usage(MemoryUsageTracker* tracker) const;
void unpack();
Expand Down
4 changes: 2 additions & 2 deletions common/formatter/rules/rule_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct FormFormattingConfig {
bool combine_first_two_lines =
false; // NOTE - basically hang, but will probably stick around after hang is gone, may be
// redundant (inline_until_index!)
std::function<std::optional<int>(const std::vector<std::string>& curr_lines)> inline_until_index =
[](std::vector<std::string> curr_lines) { return std::nullopt; };
std::function<std::optional<int>(const std::vector<std::string>& /*curr_lines*/)>
inline_until_index = [](std::vector<std::string> /*curr_lines*/) { return std::nullopt; };
bool has_constant_pairs = false;
bool prevent_inlining = false; // TODO - duplicate of below
std::function<bool(FormFormattingConfig, int num_refs)> should_prevent_inlining =
Expand Down
1 change: 1 addition & 0 deletions common/util/FontUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ static std::vector<ReplaceInfo> s_replace_info_jak2 = {
{"O~Y~-28H~-4V'~-9H'~Z", "Ő"},
{"U~Y~-27H~-4V'~-12H'~Z", "Ű"},
{"o~Y~-28H~-4V'~-9H'~Z", "ő"},
{"u~Y~-28H~-4V'~-9H'~Z", "ű"},
{"E~Y~-22H~-11Vº~Z", "Ė"},
{"e~Y~-25H~-5Vº~Z", "ė"},
{"C~Y~-27H~-10Vˇ~Z", "Č"},
Expand Down
14 changes: 12 additions & 2 deletions crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@ files:
translation: /game/assets/jak1/text/game_custom_text_%locale%.json
- source: /game/assets/jak1/subtitle/subtitle_lines_en-US.json
translation: /game/assets/jak1/subtitle/subtitle_lines_%locale%.json
excluded_target_languages:
- fr
- de
- es-ES
- it
- ja
- en-GB
- source: /game/assets/jak2/text/game_custom_text_en-US.json
translation: /game/assets/jak2/text/game_custom_text_%locale%.json
- source: /game/assets/jak2/subtitle/subtitle_lines_en-US.json
translation: /game/assets/jak2/subtitle/subtitle_lines_%locale%.json
excluded_target_languages:
- "fr"
- "de"
- "es-ES"
- "it"
- "ja"
- "ko"
- "en-GB"
- source: /game/assets/jak2/text/game_custom_text_en-US.json
translation: /game/assets/jak2/text/game_custom_text_%locale%.json
1 change: 1 addition & 0 deletions decompiler/config/jak1/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,7 @@
(catalan #x1119)
(icelandic #x111a)
(polish #x111b)
(lithuanian #x111c)
(scene-0 #x1200)
(scene-255 #x12ff)
(hint-0 #x1300)
Expand Down
21 changes: 12 additions & 9 deletions decompiler/config/jak2/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -7413,6 +7413,9 @@
(progress-mouse-options-horz-sens #x129d)
(progress-mouse-options-vert-sens #x129e)
(progress-mouse-options-player-movement #x129f)
(progress-shadows #x12a0)
(progress-shadows-normal #x12a1)
(progress-shadows-extended #x12a2)
(progress-input-options-auto-hide-cursor #x1300)
(progress-menu-reassign-binds #x1301)
(progress-reassign-binds-controller #x1302)
Expand Down Expand Up @@ -12938,11 +12941,11 @@
:flag-assert #xf00000060
(:methods
(new (symbol type float float float shadow-flags float) _type_) ;; 0
(clear-offset-bit (shadow-control) int) ;; 9
(set-offset-bit (shadow-control) int) ;; 10
(enable-draw (shadow-control) int) ;; 9
(disable-draw (shadow-control) int) ;; 10
(set-top-plane-offset (shadow-control float) int) ;; 11
(set-bottom-plane-offset (shadow-control float) int) ;; 12
(shadow-control-method-13 (_type_ vector float float float) none) ;; 13 ;; (unused-13 (_type_) none) ;; 13
(probe-line-for-shadow (_type_ vector float float float) none) ;; 13 ;; (unused-13 (_type_) none) ;; 13
(shadow-control-method-14 (_type_ vector vector float float float) none) ;; 14 ;; (update-direction-from-time-of-day (_type_) none) ;; 14
)
)
Expand Down Expand Up @@ -33069,10 +33072,10 @@
(actor-group (pointer actor-group) :offset-assert 480)
(actor-group-count int32 :offset-assert 484)
(neck joint-mod :offset-assert 488)
(on-notice symbol :offset-assert 492)
(on-active symbol :offset-assert 496)
(on-hostile symbol :offset-assert 500)
(on-death symbol :offset-assert 504)
(on-notice pair :offset-assert 492)
(on-active pair :offset-assert 496)
(on-hostile pair :offset-assert 500)
(on-death pair :offset-assert 504)
(idle-anim-player idle-control :inline :offset-assert 512)
(rand-gen symbol :offset-assert 528)
)
Expand Down Expand Up @@ -50010,8 +50013,8 @@
(vehicle-method-99 (_type_ float) none) ;; 99
(vehicle-method-100 (_type_ float vehicle-physics-work) none) ;; 100
(vehicle-method-101 (_type_) none) ;; 101
(vehicle-method-102 (_type_) none) ;; 102
(vehicle-method-103 (_type_) none) ;; 103
(shadow-enable (_type_) none) ;; 102
(shadow-disable (_type_) none) ;; 103
(vehicle-method-104 (_type_) none) ;; 104
(vehicle-method-105 (_type_) symbol) ;; 105
(vehicle-method-106 (_type_) none) ;; 106
Expand Down
3 changes: 2 additions & 1 deletion decompiler/config/jak2/ntsc_v1/type_casts.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -3152,7 +3152,8 @@
[872, "f1", "float"],
[22, "v1", "float"],
["_stack_", 56, "handle"],
["_stack_", 16, "float"]
["_stack_", 16, "float"],
[792, "t1", "sound-name"]
],
"target-bomb1-fire-shot": [
[12, "v1", "handle"],
Expand Down
12 changes: 12 additions & 0 deletions decompiler/config/jak2/ntsc_v1/var_names.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4625,5 +4625,17 @@
"vars": {
"s5-0": "play-sound?"
}
},
"(method 135 enemy)": {
"args": ["this", "sound"],
"vars": {
"gp-0": ["name", "sound-name"],
"v1-0": "sound-type"
}
},
"(code target-darkjak-running-attack)": {
"vars": {
"t1-3": ["imp-sound", "sound-name"]
}
}
}
27 changes: 15 additions & 12 deletions decompiler/data/TextureDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,23 @@ void TextureDB::replace_textures(const fs::path& path) {
fs::path base_path(path);
for (auto& tex : textures) {
fs::path full_path = base_path / tpage_names.at(tex.second.page) / (tex.second.name + ".png");
if (fs::exists(full_path)) {
lg::info("Replacing {}", full_path.string().c_str());
int w, h;
auto data = stbi_load(full_path.string().c_str(), &w, &h, 0, 4); // rgba channels
if (!data) {
lg::warn("failed to load PNG file: {}", full_path.string().c_str());
if (!fs::exists(full_path)) {
full_path = base_path / "_all" / (tex.second.name + ".png");
if (!fs::exists(full_path))
continue;
}
tex.second.rgba_bytes.resize(w * h);
memcpy(tex.second.rgba_bytes.data(), data, w * h * 4);
tex.second.w = w;
tex.second.h = h;
stbi_image_free(data);
}
lg::info("Replacing {}", tpage_names.at(tex.second.page) + "/" + (tex.second.name));
int w, h;
auto data = stbi_load(full_path.string().c_str(), &w, &h, 0, 4); // rgba channels
if (!data) {
lg::warn("failed to load PNG file: {}", full_path.string().c_str());
continue;
}
tex.second.rgba_bytes.resize(w * h);
memcpy(tex.second.rgba_bytes.data(), data, w * h * 4);
tex.second.w = w;
tex.second.h = h;
stbi_image_free(data);
}
}

Expand Down
16 changes: 14 additions & 2 deletions decompiler/level_extractor/extract_shrub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ void make_draws(tfrag3::Level& lev,
std::vector<std::vector<u32>> indices_regrouped_by_draw;
std::unordered_map<u32, std::vector<u32>> static_draws_by_tex;
size_t global_vert_counter = 0;
for (auto& proto : protos) {
for (u32 proto_idx = 0; proto_idx < protos.size(); proto_idx++) {
auto& proto = protos[proto_idx];
// packed_vert_indices[frag][draw] = {start, end}
std::vector<std::vector<std::pair<int, int>>> packed_vert_indices;

Expand Down Expand Up @@ -509,7 +510,9 @@ void make_draws(tfrag3::Level& lev,
std::vector<u32>* verts_to_add_to = nullptr;
if (existing_draws_in_tex != static_draws_by_tex.end()) {
for (auto idx : existing_draws_in_tex->second) {
if (tree_out.static_draws.at(idx).mode == mode) {
auto& candidate_draw_out = tree_out.static_draws.at(idx);
if (candidate_draw_out.mode == mode && (!tree_out.has_per_proto_visibility_toggle ||
candidate_draw_out.proto_idx == proto_idx)) {
draw_to_add_to = &tree_out.static_draws[idx];
verts_to_add_to = &indices_regrouped_by_draw[idx];
}
Expand All @@ -523,6 +526,9 @@ void make_draws(tfrag3::Level& lev,
draw_to_add_to = &tree_out.static_draws.back();
draw_to_add_to->mode = mode;
draw_to_add_to->tree_tex_id = idx_in_lev_data;
if (tree_out.has_per_proto_visibility_toggle) {
draw_to_add_to->proto_idx = proto_idx;
}
verts_to_add_to = &indices_regrouped_by_draw.emplace_back();
}

Expand Down Expand Up @@ -573,10 +579,16 @@ void extract_shrub(const shrub_types::DrawableTreeInstanceShrub* tree,
bool dump_level,
GameVersion version) {
auto& tree_out = out.shrub_trees.emplace_back();

if (version > GameVersion::Jak1) {
tree_out.has_per_proto_visibility_toggle = true;
}

auto& protos = tree->info.prototype_inline_array_shrub;
std::vector<ShrubProtoInfo> proto_info;
for (auto& proto : protos.data) {
proto_info.push_back(extract_proto(proto, tex_db, map, version));
tree_out.proto_names.push_back(proto.name);
}

for (auto& arr : tree->discovered_arrays) {
Expand Down
9 changes: 8 additions & 1 deletion game/assets/jak1/game_subtitle.gp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,14 @@
:lines-base "game/assets/jak1/subtitle/subtitle_lines_en-US.json"
:meta "game/assets/jak1/subtitle/subtitle_meta_pl-PL.json"
:meta-base "game/assets/jak1/subtitle/subtitle_meta_en-US.json")
(file-json
:language-id 20
:text-version "jak1-v2"
:lines "game/assets/jak1/subtitle/subtitle_lines_lt-LT.json"
:lines-base "game/assets/jak1/subtitle/subtitle_lines_en-US.json"
:meta "game/assets/jak1/subtitle/subtitle_meta_lt-LT.json"
:meta-base "game/assets/jak1/subtitle/subtitle_meta_en-US.json")
)



1 change: 1 addition & 0 deletions game/assets/jak1/game_text.gp
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
(file-json 16 jak1-v2 "common" '("game/assets/jak1/text/game_custom_text_is-IS.json"))
(file-json 19 jak1-v2 "common" '("game/assets/jak1/text/game_custom_text_pl-PL.json"
"game/assets/jak1/text/game_base_text_pl-PL.json"))
(file-json 20 jak1-v2 "common" '("game/assets/jak1/text/game_custom_text_lt-LT.json"))
)
2 changes: 1 addition & 1 deletion game/assets/jak1/subtitle/subtitle_lines_it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,7 @@
"FISHERMAN": "PESCATORE",
"FLUT-FLUT": "FLUT-FLUT",
"GAMBLER": "GIOCATORE D'AZZARDO",
"GEOLOGIST": "GEOLOGIST",
"GEOLOGIST": "GEOLOGA",
"GOL": "GOL",
"GORDY": "GORDY",
"JAK": "JAK",
Expand Down
Loading

0 comments on commit d17d10e

Please sign in to comment.