Skip to content

Commit d2f2cca

Browse files
committed
2 parents 385346e + 8179d0a commit d2f2cca

File tree

68 files changed

+4632
-4039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+4632
-4039
lines changed

CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ if(WIN32)
195195
elseif(APPLE)
196196
set(CURL_USE_SECTRANSP ON) # native macOS SSL support
197197
else()
198+
if(STATICALLY_LINK)
199+
set(OPENSSL_USE_STATIC_LIBS TRUE)
200+
endif()
198201
set(CURL_USE_OPENSSL ON) # not native, but seems to be the best choice for linux
199202
endif()
200203
include_directories(third-party/curl/include)

common/formatter/formatter.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void apply_formatting_config(
8686
// circumstance, we do NOT do this sort of thing when formatting normal forms (cond/case pairs
8787
// are another similar situation)
8888
if (curr_node.formatting_config.has_constant_pairs) {
89-
for (int i = 0; i < curr_node.refs.size(); i++) {
89+
for (int i = 0; i < (int)curr_node.refs.size(); i++) {
9090
auto& child_ref = curr_node.refs.at(i);
9191
const auto type = child_ref.metadata.node_type;
9292
if (constant_types.find(type) == constant_types.end() &&
@@ -107,7 +107,7 @@ void apply_formatting_config(
107107
curr_node.formatting_config.indentation_width = hang_indentation_width(curr_node);
108108
}
109109
// iterate through the refs
110-
for (int i = 0; i < curr_node.refs.size(); i++) {
110+
for (int i = 0; i < (int)curr_node.refs.size(); i++) {
111111
auto& ref = curr_node.refs.at(i);
112112
if (!ref.token) {
113113
// If the child has a pre-defined configuration at that index, we pass it along
@@ -211,7 +211,7 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
211211
//
212212
// This means we may combine elements onto the same line in this step.
213213
std::vector<std::string> form_lines = {};
214-
for (int i = 0; i < curr_node.refs.size(); i++) {
214+
for (int i = 0; i < (int)curr_node.refs.size(); i++) {
215215
const auto& ref = curr_node.refs.at(i);
216216
// Add new line entry
217217
if (ref.token) {
@@ -227,20 +227,20 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
227227
// If it's not a token, we have to recursively build up the form
228228
// TODO - add the cursor_pos here
229229
const auto& lines = apply_formatting(ref, {}, cursor_pos);
230-
for (int i = 0; i < lines.size(); i++) {
230+
for (int i = 0; i < (int)lines.size(); i++) {
231231
const auto& line = lines.at(i);
232232
form_lines.push_back(fmt::format(
233233
"{}{}", str_util::repeat(ref.formatting_config.parent_mutable_extra_indent, " "),
234234
line));
235235
}
236236
}
237237
// If we are hanging forms, combine the first two forms onto the same line
238-
if (i == curr_node.refs.size() - 1 && form_lines.size() > 1 &&
238+
if (i == (int)curr_node.refs.size() - 1 && form_lines.size() > 1 &&
239239
(curr_node.formatting_config.hang_forms ||
240240
curr_node.formatting_config.combine_first_two_lines)) {
241241
form_lines.at(0) += fmt::format(" {}", form_lines.at(1));
242242
form_lines.erase(form_lines.begin() + 1);
243-
} else if ((i + 1) < curr_node.refs.size()) {
243+
} else if ((i + 1) < (int)curr_node.refs.size()) {
244244
const auto& next_ref = curr_node.refs.at(i + 1);
245245
// combine the next inline comment or constant pair
246246
if ((next_ref.metadata.node_type == "comment" && next_ref.metadata.is_inline) ||
@@ -267,7 +267,7 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
267267
// Consolidate any lines if the configuration requires it
268268
if (curr_node.formatting_config.inline_until_index != -1) {
269269
std::vector<std::string> new_form_lines = {};
270-
for (int i = 0; i < form_lines.size(); i++) {
270+
for (int i = 0; i < (int)form_lines.size(); i++) {
271271
if (i < curr_node.formatting_config.inline_until_index) {
272272
if (new_form_lines.empty()) {
273273
new_form_lines.push_back(form_lines.at(i));
@@ -296,7 +296,7 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
296296
if (inline_form) {
297297
form_lines = {fmt::format("{}", fmt::join(form_lines, " "))};
298298
} else {
299-
for (int i = 0; i < form_lines.size(); i++) {
299+
for (int i = 0; i < (int)form_lines.size(); i++) {
300300
if (i > 0) {
301301
auto& line = form_lines.at(i);
302302
line = fmt::format("{}{}",

common/formatter/rules/formatting_rules.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ bool should_insert_blank_line(const FormatterTreeNode& containing_node,
3939
return false;
4040
}
4141
// If the next form is a comment and is inline, don't insert a comment
42-
if ((index + 1) < containing_node.refs.size() &&
42+
if ((index + 1) < (int)containing_node.refs.size() &&
4343
containing_node.refs.at(index + 1).metadata.is_comment &&
4444
containing_node.refs.at(index + 1).metadata.is_inline) {
4545
return false;

common/formatter/rules/rule_config.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ FormFormattingConfig new_binding_rule() {
2222
auto binding_list_config = std::make_shared<FormFormattingConfig>();
2323
binding_list_config->hang_forms = false;
2424
binding_list_config->indentation_width = 1;
25-
binding_list_config->indentation_width_for_index = [](FormFormattingConfig cfg, int index) {
25+
binding_list_config->indentation_width_for_index = [](FormFormattingConfig /*cfg*/, int index) {
2626
if (index == 0) {
2727
return 0;
2828
}
2929
return 4;
3030
};
31-
binding_list_config->should_prevent_inlining = [](FormFormattingConfig config, int num_refs) {
31+
binding_list_config->should_prevent_inlining = [](FormFormattingConfig /*config*/, int num_refs) {
3232
// Only prevent inlining a binding list, if there are more than 1 bindings
3333
if (num_refs > 1) {
3434
return true;

common/formatter/rules/rule_config.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ struct FormFormattingConfig {
1717
2; // 2 for a flow // TODO - also remove this, prefer storing the first node's width in the
1818
// metadata on the first pass, that's basically all this does
1919
std::function<int(FormFormattingConfig, int)> indentation_width_for_index =
20-
[](FormFormattingConfig config, int index) { return config.indentation_width; };
20+
[](FormFormattingConfig config, int /*index*/) { return config.indentation_width; };
2121
bool combine_first_two_lines =
2222
false; // NOTE - basically hang, but will probably stick around after hang is gone
2323
int inline_until_index = -1;
2424
bool has_constant_pairs = false;
2525
bool prevent_inlining = false;
2626
std::function<bool(FormFormattingConfig, int num_refs)> should_prevent_inlining =
27-
[](FormFormattingConfig config, int num_refs) { return config.prevent_inlining; };
27+
[](FormFormattingConfig config, int /*num_refs*/) { return config.prevent_inlining; };
2828
int parent_mutable_extra_indent = 0;
2929
std::unordered_map<int, std::shared_ptr<FormFormattingConfig>> index_configs = {};
3030
};

common/type_system/TypeSystem.cpp

+30-8
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,15 @@ MethodInfo TypeSystem::override_method(Type* type,
544544
throw_typesystem_error("Trying to override a method that has no parent declaration");
545545
}
546546
// use the existing ID.
547-
return type->add_method({existing_info.id, existing_info.name, existing_info.type,
548-
type->get_name(), existing_info.no_virtual, false, true, docstring});
547+
return type->add_method({existing_info.id,
548+
existing_info.name,
549+
existing_info.type,
550+
type->get_name(),
551+
existing_info.no_virtual,
552+
false,
553+
true,
554+
docstring,
555+
{}});
549556
}
550557

551558
MethodInfo TypeSystem::declare_method(const std::string& type_name,
@@ -596,8 +603,15 @@ MethodInfo TypeSystem::declare_method(Type* type,
596603
}
597604

598605
// use the existing ID.
599-
return type->add_method(
600-
{existing_info.id, method_name, ts, type->get_name(), no_virtual, true, false, docstring});
606+
return type->add_method({existing_info.id,
607+
method_name,
608+
ts,
609+
type->get_name(),
610+
no_virtual,
611+
true,
612+
false,
613+
docstring,
614+
{}});
601615
} else {
602616
if (got_existing) {
603617
// make sure we aren't changing anything.
@@ -627,8 +641,15 @@ MethodInfo TypeSystem::declare_method(Type* type,
627641
return existing_info;
628642
} else {
629643
// add a new method!
630-
return type->add_method({get_next_method_id(type), method_name, ts, type->get_name(),
631-
no_virtual, false, false, docstring});
644+
return type->add_method({get_next_method_id(type),
645+
method_name,
646+
ts,
647+
type->get_name(),
648+
no_virtual,
649+
false,
650+
false,
651+
docstring,
652+
{}});
632653
}
633654
}
634655
}
@@ -736,7 +757,8 @@ MethodInfo TypeSystem::add_new_method(Type* type,
736757

737758
return existing;
738759
} else {
739-
return type->add_new_method({0, "new", ts, type->get_name(), false, false, false, docstring});
760+
return type->add_new_method(
761+
{0, "new", ts, type->get_name(), false, false, false, docstring, {}});
740762
}
741763
}
742764

@@ -2089,7 +2111,7 @@ std::optional<std::string> find_best_field_in_structure(const TypeSystem& ts,
20892111
if (end_field == -1) {
20902112
end_field = st->fields().size();
20912113
}
2092-
for (size_t i = start_field; i < end_field; ++i) {
2114+
for (size_t i = start_field; i < (size_t)end_field; ++i) {
20932115
const auto& field = st->fields().at(i);
20942116
auto type = ts.lookup_type(field.type());
20952117
if (field.is_dynamic() || field.offset() > offset || field.user_placed() != want_fixed) {

common/type_system/deftype.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ void declare_method(Type* type,
457457
void declare_state_methods(Type* type,
458458
TypeSystem* type_system,
459459
const goos::Object& def,
460-
StructureDefResult& struct_def) {
460+
StructureDefResult& /*struct_def*/) {
461461
for_each_in_list(def, [&](const goos::Object& _obj) {
462462
auto obj = &_obj;
463463
// either state-name or (state-name args...) or (state-name "docstring" args...)

common/util/FontUtils.cpp

+44-1
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,13 @@ static std::vector<ReplaceInfo> s_replace_info_jak1 = {
550550
{"E~Y~-6H~+2V,~Z", "Ę"},
551551
{"L~Y~-16H~+0V/~Z", "Ł"},
552552
{"Z~Y~-21H~-5Vº~Z", "Ż"},
553+
{"E~Y~-20H~-5Vº~Z", "Ė"},
554+
{"C~Y~-20H~-4Vˇ~Z", "Č"},
555+
{"S~Y~-22H~-4Vˇ~Z", "Š"},
556+
{"Z~Y~-22H~-4Vˇ~Z", "Ž"},
557+
{"U~Y~-13H~+2V,~Z", "Ų"},
558+
{"U~Y~-18H~-10V-~Z", "Ū"},
559+
{"I~Y~-8H~+1V,~Z", "Į"},
553560

554561
// tildes
555562
{"N~Y~-22H~-4V<TIL>~Z", "Ñ"},
@@ -919,6 +926,42 @@ static std::vector<ReplaceInfo> s_replace_info_jak2 = {
919926
{"N~Y~-6Hº~Z~+10H", ""},
920927
{"~+4Vç~-4V", ",c"},
921928

929+
// added for translations TODO - check these for jak 2
930+
{"O~Y~-25H~-1V/~Z", "Ø"},
931+
{"o~Y~-23H~+4V/~Z", "ø"},
932+
{"A~Y~-13H~+8V,~Z", "Ą"},
933+
{"a~Y~-8H~+6V,~Z", "ą"},
934+
{"E~Y~-6H~+8V,~Z", "Ę"},
935+
{"e~Y~-10H~+7V,~Z", "ę"},
936+
{"L~Y~-21H~+0V/~Z", "Ł"},
937+
{"l~Y~-16H~+0V/~Z", "ł"}, // TODO - this one is ugly, font character addition (small slash)
938+
{"Z~Y~-25H~-11Vº~Z", "Ż"},
939+
{"z~Y~-23H~-5Vº~Z", "ż"},
940+
{"a~Y~-25H~-5Vº~Z", "å"},
941+
{"S~Y~-21H~-5V'~Z", "Ś"},
942+
{"s~Y~-25H~-5V'~Z", "ś"},
943+
{"n~Y~-25H~-5V'~Z", "ń"},
944+
{"c~Y~-25H~-5V'~Z", "ć"},
945+
{"o~Y~-24H~-4V<TIL>~Z", "õ"},
946+
{"a~Y~-24H~-4V<TIL>~Z", "ã"},
947+
{"O~Y~-28H~-4V'~-9H'~Z", "Ő"},
948+
{"U~Y~-27H~-4V'~-12H'~Z", "Ű"},
949+
{"o~Y~-28H~-4V'~-9H'~Z", "ő"},
950+
{"E~Y~-22H~-11Vº~Z", "Ė"},
951+
{"e~Y~-25H~-5Vº~Z", "ė"},
952+
{"C~Y~-27H~-10Vˇ~Z", "Č"},
953+
{"c~Y~-25H~-5Vˇ~Z", "č"},
954+
{"S~Y~-24H~-10Vˇ~Z", "Š"},
955+
{"s~Y~-22H~-4Vˇ~Z", "š"},
956+
{"Z~Y~-25H~-10Vˇ~Z", "Ž"},
957+
{"z~Y~-23H~-4Vˇ~Z", "ž"},
958+
{"U~Y~-15H~+5V,~Z", "Ų"},
959+
{"u~Y~-15H~+5V,~Z", "ų"},
960+
{"U~Y~-20H~-18V-~Z", "Ū"},
961+
{"u~Y~-18H~-15V-~Z", "ū"},
962+
{"I~Y~-8H~+4V,~Z", "Į"},
963+
{"i~Y~-8H~+4V,~Z", "į"},
964+
922965
// tildes
923966
{"N~Y~-22H~-4V<TIL>~Z", "Ñ"},
924967
{"n~Y~-24H~-4V<TIL>~Z", "ñ"},
@@ -942,7 +985,7 @@ static std::vector<ReplaceInfo> s_replace_info_jak2 = {
942985
{"A~Y~-20H~-4V^~Z", "Â"},
943986
{"a~Y~-24H~-5V^~Z", "â"},
944987
{"E~Y~-20H~-5V^~Z", "Ê"},
945-
{"e~Y~-25H~-4V^~Zt", "ê"},
988+
{"e~Y~-25H~-4V^~Z", "ê"},
946989
{"I~Y~-19H~-5V^~Z", "Î"},
947990
{"i~Y~-19H~-8V^~Z", "î"},
948991
{"O~Y~-20H~-4V^~Z", "Ô"},

crowdin.yml

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ files:
1010
- "it"
1111
- "ja"
1212
- "en-GB"
13+
- source: /game/assets/jak2/text/game_custom_text_en-US.json
14+
translation: /game/assets/jak2/text/game_custom_text_%locale%.json

custom_levels/jak1/test-zone/test-zone.jsonc

+13-11
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636

3737
// All art groups you want to use in your custom level. Will add their models and corresponding textures to the FR3 file.
3838
// Note: You will still have to add them to your level's .gd file.
39-
"art_groups": ["plat-ag"],
39+
// Removed so that the release builds don't have to double-decompile the game
40+
// "art_groups": ["plat-ag"],
41+
"art_groups": [],
4042

4143
// Any textures you want to include in your custom level. This is mainly useful for things such as the zoomer HUD,
4244
// which is not in the common level files and has no art group associated with it.
@@ -103,16 +105,16 @@
103105
"lump": {
104106
"name": "test-eco"
105107
}
106-
},
107-
{
108-
"trans": [-7.41, 3.5, 28.42], // translation
109-
"etype": "plat", // actor type
110-
"game_task": 0, // associated game task (for powercells, etc)
111-
"quat": [0, 0, 0, 1], // quaternion
112-
"bsphere": [-7.41, 3.5, 28.42, 10], // bounding sphere
113-
"lump": {
114-
"name": "test-plat"
115-
}
116108
}
109+
// {
110+
// "trans": [-7.41, 3.5, 28.42], // translation
111+
// "etype": "plat", // actor type
112+
// "game_task": 0, // associated game task (for powercells, etc)
113+
// "quat": [0, 0, 0, 1], // quaternion
114+
// "bsphere": [-7.41, 3.5, 28.42, 10], // bounding sphere
115+
// "lump": {
116+
// "name": "test-plat"
117+
// }
118+
// }
117119
]
118120
}

custom_levels/jak2/test-zone/test-zone.jsonc

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
"base_id": 100,
3636

3737
// All art groups you want to use in your custom level. Will add their models and corresponding textures to the FR3 file.
38-
"art_groups": ["prsn-torture-ag"],
38+
// Removed so that the release builds don't have to double-decompile the game
39+
//"art_groups": ["prsn-torture-ag"],
40+
"art_groups": [],
3941

4042
// Any textures you want to include in your custom level.
4143
// This is mainly useful for textures which are not in the common level files and have no art group associated with them.

decompiler/Disasm/InstructionDecode.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ struct OpcodeFields {
3737
uint32_t sa() { return (data >> 6) & 0x1f; }
3838

3939
// 0 - 5
40+
// TODO - remove once we update clang-format
41+
// clang-format off
4042
uint32_t function() { return (data)&0x3f; }
43+
// clang-format on
4144

4245
////////////////
4346
// Immediates //

decompiler/ObjectFile/ObjectFileDB_IR2.cpp

+22-2
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,20 @@ Value try_lookup(const std::unordered_map<Key, Value>& map, const Key& key) {
510510
}
511511
}
512512

513+
const std::string* find_file_override_for_art_group(const Config& config,
514+
const std::string& obj_name,
515+
const std::string& type_name) {
516+
// find file override for this type
517+
auto it_file = config.art_group_file_override.find(obj_name);
518+
if (it_file != config.art_group_file_override.end()) {
519+
auto it_type = it_file->second.find(type_name);
520+
if (it_type != it_file->second.end()) {
521+
return &it_type->second;
522+
}
523+
}
524+
return nullptr;
525+
}
526+
513527
/*!
514528
* Analyze registers and determine the type in each register at each instruction.
515529
* - Figure out the type of each function, from configs.
@@ -550,15 +564,21 @@ void ObjectFileDB::ir2_type_analysis_pass(int seg, const Config& config, ObjectF
550564
if (func.guessed_name.kind == FunctionName::FunctionKind::V_STATE) {
551565
if (config.art_group_type_remap.find(func.guessed_name.type_name) !=
552566
config.art_group_type_remap.end()) {
553-
func.ir2.env.set_art_group(config.art_group_type_remap.at(func.guessed_name.type_name));
567+
auto ag_override =
568+
find_file_override_for_art_group(config, obj_name, func.guessed_name.type_name);
569+
func.ir2.env.set_art_group(
570+
ag_override ? *ag_override
571+
: config.art_group_type_remap.at(func.guessed_name.type_name));
554572
} else {
555573
func.ir2.env.set_art_group(func.guessed_name.type_name + "-ag");
556574
}
557575
} else if (func.guessed_name.kind == FunctionName::FunctionKind::NV_STATE ||
558576
func.type.try_get_tag("behavior").has_value()) {
559577
std::string type = func.type.get_tag("behavior");
560578
if (config.art_group_type_remap.find(type) != config.art_group_type_remap.end()) {
561-
func.ir2.env.set_art_group(config.art_group_type_remap.at(type));
579+
auto ag_override = find_file_override_for_art_group(config, obj_name, type);
580+
func.ir2.env.set_art_group(ag_override ? *ag_override
581+
: config.art_group_type_remap.at(type));
562582
} else {
563583
func.ir2.env.set_art_group(type + "-ag");
564584
}

decompiler/config.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ Config make_config_via_json(nlohmann::json& json) {
297297
auto art_info_json = read_json_file_from_config(json, "art_info_file");
298298
config.art_group_type_remap =
299299
art_info_json.at("type_remap").get<std::unordered_map<std::string, std::string>>();
300+
if (art_info_json.contains("file_override")) {
301+
config.art_group_file_override =
302+
art_info_json.at("file_override")
303+
.get<std::unordered_map<std::string, std::unordered_map<std::string, std::string>>>();
304+
}
300305
config.joint_node_hacks =
301306
art_info_json.at("joint_node_hacks").get<std::unordered_map<std::string, std::string>>();
302307

0 commit comments

Comments
 (0)