Skip to content

Commit

Permalink
decomp3: spawn target, add merc and particle buckets and some tempo…
Browse files Browse the repository at this point in the history
…rary hacks (#3445)

This includes all the collision stuff needed to spawn `target`,
decompiles the sparticle code and adds some of the PC hacks needed for
merc to run (it doesn't work quite right and looks bad, likely due to a
combination of code copied from Jak 2 and the time of day hacks).

There are a bunch of temporary hacks (see commits) in place to prevent
the game from crashing quite as much, but it is still extremely prone to
doing so due to lots of missing functions/potentially bad decomp.

---------

Co-authored-by: water <[email protected]>
  • Loading branch information
Hat-Kid and water111 authored Apr 5, 2024
1 parent a7efd59 commit 93afb02
Show file tree
Hide file tree
Showing 581 changed files with 117,212 additions and 3,664 deletions.
10 changes: 5 additions & 5 deletions common/formatter/formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void apply_formatting_config(
// Find the maximum number of columns
int max_columns = 0;
for (const auto& field : curr_node.refs) {
if (field.refs.size() > max_columns) {
if ((int)field.refs.size() > max_columns) {
max_columns = field.refs.size();
}
}
Expand All @@ -156,7 +156,7 @@ void apply_formatting_config(
for (int col = 0; col < max_columns; col++) {
column_max_widths.push_back(0);
for (const auto& field : curr_node.refs) {
if (field.refs.size() > col) {
if ((int)field.refs.size() > col) {
const auto width = get_total_form_inlined_width(field.refs.at(col));
if (width > column_max_widths.at(col)) {
column_max_widths[col] = width;
Expand Down Expand Up @@ -271,7 +271,7 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
val = comments::format_block_comment(ref.token_str());
}
form_lines.push_back(val);
if (!curr_node.metadata.is_top_level && i == curr_node.refs.size() - 1 &&
if (!curr_node.metadata.is_top_level && i == (int)curr_node.refs.size() - 1 &&
(ref.metadata.is_comment)) {
// if there's an inline comment at the end of a form, we have to force the paren to the next
// line and do a new-line paren this is ugly, but we have no choice!
Expand Down Expand Up @@ -354,9 +354,9 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,

// Add any column padding
if (!curr_node.formatting_config.list_element_column_widths.empty()) {
for (int i = 0; i < form_lines.size(); i++) {
for (int i = 0; i < (int)form_lines.size(); i++) {
const auto& token = form_lines.at(i);
if (i < form_lines.size() - 1) {
if (i < (int)form_lines.size() - 1) {
form_lines[i] = str_util::pad_right(
token, curr_node.formatting_config.list_element_column_widths.at(i), ' ');
}
Expand Down
2 changes: 1 addition & 1 deletion common/util/Trie.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@ std::vector<T*> Trie<T>::get_all_nodes() const {
std::vector<T*> result;
m_root.get_all_children(result);
return result;
}
}
2 changes: 1 addition & 1 deletion common/util/string_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ std::string titlize(const std::string& str) {
}

std::string pad_right(const std::string& input, const int width, const char padding_char) {
if (input.length() >= width) {
if ((int)input.length() >= width) {
return input; // No need to pad if input length is already greater or equal to width
} else {
int padding_width = width - input.length();
Expand Down
8 changes: 8 additions & 0 deletions decompiler/IR2/FormExpressionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5505,6 +5505,14 @@ FormElement* ConditionElement::make_generic(const Env& env,
casted);
}

case IR2_Condition::Kind::LEQ_ZERO_UNSIGNED: {
auto casted = make_casts_if_needed(source_forms, types, TypeSpec("uint"), pool, env);
auto zero = pool.form<SimpleAtomElement>(SimpleAtom::make_int_constant(0));
casted.push_back(zero);
return pool.alloc_element<GenericElement>(GenericOperator::make_fixed(FixedOperatorKind::LEQ),
casted);
}

case IR2_Condition::Kind::GEQ_ZERO_SIGNED: {
return make_geq_zero_signed_check_generic(env, pool, source_forms, types);
}
Expand Down
2 changes: 1 addition & 1 deletion decompiler/analysis/find_skelgroups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ void inspect_cloth_data_jak3(LetElement* let, DefskelgroupElement::StaticInfo& i
auto array_set = dynamic_cast<SetFormFormElement*>(when_body->at(0));
if (array_set) {
// get elements
auto elts = when_body->elts().size() - 2;
auto elts = (int)when_body->elts().size() - 2;
for (int i = 0; i < elts; i++) {
auto parms_form = dynamic_cast<SetFormFormElement*>(when_body->at(i + 1));
if (parms_form) {
Expand Down
Loading

0 comments on commit 93afb02

Please sign in to comment.