diff --git a/src/h1/xsk/assembler.cpp b/src/h1/xsk/assembler.cpp index 83d50e41..6fed6206 100644 --- a/src/h1/xsk/assembler.cpp +++ b/src/h1/xsk/assembler.cpp @@ -94,7 +94,7 @@ void assembler::assemble(const std::string& file, std::vector& dat if (opcode(inst->opcode) == opcode::OP_endswitch) { - switchnum = static_cast(std::stoul(inst->data[0])); + switchnum = static_cast(std::stoi(inst->data[0])); inst->size += 7 * switchnum; } @@ -129,7 +129,7 @@ void assembler::assemble_function(const gsc::function_ptr& func) stack_->write(func->size); - func->id = func->name.substr(0, 3) == "_ID" ? std::stoul(func->name.substr(3)) : resolver::token_id(func->name); + func->id = func->name.substr(0, 3) == "_ID" ? std::stoi(func->name.substr(3)) : resolver::token_id(func->name); stack_->write(func->id); if (func->id == 0) diff --git a/src/h1/xsk/decompiler.hpp b/src/h1/xsk/decompiler.hpp index 0b0af2a6..b23c6267 100644 --- a/src/h1/xsk/decompiler.hpp +++ b/src/h1/xsk/decompiler.hpp @@ -28,7 +28,6 @@ private: void decompile_statements(const gsc::function_ptr& func); void decompile_expr(); void decompile_block(const gsc::stmt_list_ptr& block); - void decompile_nulls(const gsc::stmt_list_ptr& block); void decompile_search_infinite(const gsc::stmt_list_ptr& block); void decompile_search_loop(const gsc::stmt_list_ptr& block); void decompile_search_switch(const gsc::stmt_list_ptr& block); diff --git a/src/h1/xsk/resolver.cpp b/src/h1/xsk/resolver.cpp index 93b28c10..c47cd061 100644 --- a/src/h1/xsk/resolver.cpp +++ b/src/h1/xsk/resolver.cpp @@ -322,7 +322,7 @@ const std::array opcode_list { std::uint8_t(opcode::OP_waitFrame), "WAITFRAME" }, }}; -const std::array function_list +const std::array function_list {{ { 0x001, "_func_001" }, { 0x002, "_func_002" }, @@ -370,7 +370,7 @@ const std::array function_list { 0x02C, "_func_02C" }, { 0x02D, "_func_02D" }, { 0x02E, "_func_02E" }, - { 0x02F, "_func_02F" }, + { 0x02F, "isdefined" }, { 0x030, "_func_030" }, { 0x031, "_func_031" }, { 0x032, "_func_032" }, @@ -764,7 +764,7 @@ const std::array function_list { 0x1B6, "_func_1B6" }, { 0x1B7, "_func_1B7" }, { 0x1B8, "_func_1B8" }, - { 0x1B9, "_func_1B9" }, + { 0x1B9, "getnextarraykey" }, { 0x1BA, "_func_1BA" }, { 0x1BB, "_func_1BB" }, { 0x1BC, "_func_1BC" }, @@ -791,7 +791,7 @@ const std::array function_list { 0x1D1, "_func_1D1" }, { 0x1D2, "_func_1D2" }, { 0x1D3, "_func_1D3" }, - { 0x1D4, "_func_1D4" }, + { 0x1D4, "getfirstarraykey" }, { 0x1D5, "_func_1D5" }, { 0x1D6, "_func_1D6" }, { 0x1D7, "_func_1D7" }, @@ -1094,9 +1094,17 @@ const std::array function_list { 0x300, "_func_300" }, { 0x301, "_func_301" }, { 0x302, "_func_302" }, + { 0x303, "_func_303" }, + { 0x304, "_func_304" }, + { 0x305, "_func_305" }, + { 0x306, "_func_306" }, + { 0x307, "_func_307" }, + { 0x308, "_func_308" }, + { 0x309, "_func_309" }, + { 0x30A, "_func_30A" }, }}; -const std::array method_list +const std::array method_list {{ { 0x8000, "_meth_8000" }, { 0x8001, "_meth_8001" }, @@ -2506,6 +2514,13 @@ const std::array method_list { 0x857D, "_meth_857D" }, { 0x857E, "_meth_857E" }, { 0x857F, "_meth_857F" }, + { 0x8580, "_meth_8580" }, + { 0x8581, "_meth_8581" }, + { 0x8582, "_meth_8582" }, + { 0x8583, "_meth_8583" }, + { 0x8584, "_meth_8584" }, + { 0x8585, "_meth_8585" }, + { 0x8586, "_meth_8586" }, }}; const std::array file_list diff --git a/src/h2/xsk/assembler.cpp b/src/h2/xsk/assembler.cpp index 36dfce75..fb31b91a 100644 --- a/src/h2/xsk/assembler.cpp +++ b/src/h2/xsk/assembler.cpp @@ -94,7 +94,7 @@ void assembler::assemble(const std::string& file, std::vector& dat if (opcode(inst->opcode) == opcode::OP_endswitch) { - switchnum = static_cast(std::stoul(inst->data[0])); + switchnum = static_cast(std::stoi(inst->data[0])); inst->size += 7 * switchnum; } @@ -129,7 +129,7 @@ void assembler::assemble_function(const gsc::function_ptr& func) stack_->write(func->size); - func->id = func->name.substr(0, 3) == "_ID" ? std::stoul(func->name.substr(3)) : resolver::token_id(func->name); + func->id = func->name.substr(0, 3) == "_ID" ? std::stoi(func->name.substr(3)) : resolver::token_id(func->name); stack_->write(func->id); if (func->id == 0) diff --git a/src/h2/xsk/decompiler.hpp b/src/h2/xsk/decompiler.hpp index 2fbdb1af..337a5312 100644 --- a/src/h2/xsk/decompiler.hpp +++ b/src/h2/xsk/decompiler.hpp @@ -28,7 +28,6 @@ private: void decompile_statements(const gsc::function_ptr& func); void decompile_expr(); void decompile_block(const gsc::stmt_list_ptr& block); - void decompile_nulls(const gsc::stmt_list_ptr& block); void decompile_search_infinite(const gsc::stmt_list_ptr& block); void decompile_search_loop(const gsc::stmt_list_ptr& block); void decompile_search_switch(const gsc::stmt_list_ptr& block); diff --git a/src/iw5/xsk/assembler.cpp b/src/iw5/xsk/assembler.cpp index 2067b4ae..518cb31f 100644 --- a/src/iw5/xsk/assembler.cpp +++ b/src/iw5/xsk/assembler.cpp @@ -94,7 +94,7 @@ void assembler::assemble(const std::string& file, std::vector& dat if (opcode(inst->opcode) == opcode::OP_endswitch) { - switchnum = static_cast(std::stoul(inst->data[0])); + switchnum = static_cast(std::stoi(inst->data[0])); inst->size += 7 * switchnum; } @@ -129,7 +129,7 @@ void assembler::assemble_function(const gsc::function_ptr& func) stack_->write(func->size); - func->id = func->name.substr(0, 3) == "_ID" ? std::stoul(func->name.substr(3)) : resolver::token_id(func->name); + func->id = func->name.substr(0, 3) == "_ID" ? std::stoi(func->name.substr(3)) : resolver::token_id(func->name); stack_->write(func->id); if (func->id == 0) diff --git a/src/iw5/xsk/decompiler.hpp b/src/iw5/xsk/decompiler.hpp index 1c3936a1..f4b5e0fb 100644 --- a/src/iw5/xsk/decompiler.hpp +++ b/src/iw5/xsk/decompiler.hpp @@ -28,7 +28,6 @@ private: void decompile_statements(const gsc::function_ptr& func); void decompile_expr(); void decompile_block(const gsc::stmt_list_ptr& block); - void decompile_nulls(const gsc::stmt_list_ptr& block); void decompile_search_infinite(const gsc::stmt_list_ptr& block); void decompile_search_loop(const gsc::stmt_list_ptr& block); void decompile_search_switch(const gsc::stmt_list_ptr& block); diff --git a/src/iw6/xsk/assembler.cpp b/src/iw6/xsk/assembler.cpp index 602d59c5..9ba0243a 100644 --- a/src/iw6/xsk/assembler.cpp +++ b/src/iw6/xsk/assembler.cpp @@ -94,7 +94,7 @@ void assembler::assemble(const std::string& file, std::vector& dat if (opcode(inst->opcode) == opcode::OP_endswitch) { - switchnum = static_cast(std::stoul(inst->data[0])); + switchnum = static_cast(std::stoi(inst->data[0])); inst->size += 7 * switchnum; } @@ -129,7 +129,7 @@ void assembler::assemble_function(const gsc::function_ptr& func) stack_->write(func->size); - func->id = func->name.substr(0, 3) == "_ID" ? std::stoul(func->name.substr(3)) : resolver::token_id(func->name); + func->id = func->name.substr(0, 3) == "_ID" ? std::stoi(func->name.substr(3)) : resolver::token_id(func->name); stack_->write(func->id); if (func->id == 0) diff --git a/src/iw6/xsk/decompiler.hpp b/src/iw6/xsk/decompiler.hpp index cae06199..a22c90da 100644 --- a/src/iw6/xsk/decompiler.hpp +++ b/src/iw6/xsk/decompiler.hpp @@ -28,7 +28,6 @@ private: void decompile_statements(const gsc::function_ptr& func); void decompile_expr(); void decompile_block(const gsc::stmt_list_ptr& block); - void decompile_nulls(const gsc::stmt_list_ptr& block); void decompile_search_infinite(const gsc::stmt_list_ptr& block); void decompile_search_loop(const gsc::stmt_list_ptr& block); void decompile_search_switch(const gsc::stmt_list_ptr& block); diff --git a/src/iw7/xsk/assembler.cpp b/src/iw7/xsk/assembler.cpp index d310c914..9cf1ded4 100644 --- a/src/iw7/xsk/assembler.cpp +++ b/src/iw7/xsk/assembler.cpp @@ -94,7 +94,7 @@ void assembler::assemble(const std::string& file, std::vector& dat if (opcode(inst->opcode) == opcode::OP_endswitch) { - switchnum = static_cast(std::stoul(inst->data[0])); + switchnum = static_cast(std::stoi(inst->data[0])); inst->size += 7 * switchnum; } @@ -129,7 +129,7 @@ void assembler::assemble_function(const gsc::function_ptr& func) stack_->write(func->size); - func->id = func->name.substr(0, 3) == "_ID" ? std::stoul(func->name.substr(3)) : resolver::token_id(func->name); + func->id = func->name.substr(0, 3) == "_ID" ? std::stoi(func->name.substr(3)) : resolver::token_id(func->name); stack_->write(func->id); if (func->id == 0) diff --git a/src/iw7/xsk/decompiler.hpp b/src/iw7/xsk/decompiler.hpp index 63711da5..5c2cb694 100644 --- a/src/iw7/xsk/decompiler.hpp +++ b/src/iw7/xsk/decompiler.hpp @@ -28,7 +28,6 @@ private: void decompile_statements(const gsc::function_ptr& func); void decompile_expr(); void decompile_block(const gsc::stmt_list_ptr& block); - void decompile_nulls(const gsc::stmt_list_ptr& block); void decompile_search_infinite(const gsc::stmt_list_ptr& block); void decompile_search_loop(const gsc::stmt_list_ptr& block); void decompile_search_switch(const gsc::stmt_list_ptr& block); diff --git a/src/s1/xsk/assembler.cpp b/src/s1/xsk/assembler.cpp index 4ebbce83..ebcf3f56 100644 --- a/src/s1/xsk/assembler.cpp +++ b/src/s1/xsk/assembler.cpp @@ -94,7 +94,7 @@ void assembler::assemble(const std::string& file, std::vector& dat if (opcode(inst->opcode) == opcode::OP_endswitch) { - switchnum = static_cast(std::stoul(inst->data[0])); + switchnum = static_cast(std::stoi(inst->data[0])); inst->size += 7 * switchnum; } @@ -129,7 +129,7 @@ void assembler::assemble_function(const gsc::function_ptr& func) stack_->write(func->size); - func->id = func->name.substr(0, 3) == "_ID" ? std::stoul(func->name.substr(3)) : resolver::token_id(func->name); + func->id = func->name.substr(0, 3) == "_ID" ? std::stoi(func->name.substr(3)) : resolver::token_id(func->name); stack_->write(func->id); if (func->id == 0) diff --git a/src/s1/xsk/decompiler.hpp b/src/s1/xsk/decompiler.hpp index c9a46e4e..380b6a95 100644 --- a/src/s1/xsk/decompiler.hpp +++ b/src/s1/xsk/decompiler.hpp @@ -28,7 +28,6 @@ private: void decompile_statements(const gsc::function_ptr& func); void decompile_expr(); void decompile_block(const gsc::stmt_list_ptr& block); - void decompile_nulls(const gsc::stmt_list_ptr& block); void decompile_search_infinite(const gsc::stmt_list_ptr& block); void decompile_search_loop(const gsc::stmt_list_ptr& block); void decompile_search_switch(const gsc::stmt_list_ptr& block); diff --git a/src/s2/xsk/assembler.cpp b/src/s2/xsk/assembler.cpp index 29d775df..8dd3b538 100644 --- a/src/s2/xsk/assembler.cpp +++ b/src/s2/xsk/assembler.cpp @@ -94,7 +94,7 @@ void assembler::assemble(const std::string& file, std::vector& dat if (opcode(inst->opcode) == opcode::OP_endswitch) { - switchnum = static_cast(std::stoul(inst->data[0])); + switchnum = static_cast(std::stoi(inst->data[0])); inst->size += 7 * switchnum; } @@ -129,7 +129,7 @@ void assembler::assemble_function(const gsc::function_ptr& func) stack_->write(func->size); - func->id = func->name.substr(0, 3) == "_ID" ? std::stoul(func->name.substr(3)) : resolver::token_id(func->name); + func->id = func->name.substr(0, 3) == "_ID" ? std::stoi(func->name.substr(3)) : resolver::token_id(func->name); stack_->write(func->id); if (func->id == 0) diff --git a/src/s2/xsk/decompiler.hpp b/src/s2/xsk/decompiler.hpp index a02fbde5..a0989b38 100644 --- a/src/s2/xsk/decompiler.hpp +++ b/src/s2/xsk/decompiler.hpp @@ -28,7 +28,6 @@ private: void decompile_statements(const gsc::function_ptr& func); void decompile_expr(); void decompile_block(const gsc::stmt_list_ptr& block); - void decompile_nulls(const gsc::stmt_list_ptr& block); void decompile_search_infinite(const gsc::stmt_list_ptr& block); void decompile_search_loop(const gsc::stmt_list_ptr& block); void decompile_search_switch(const gsc::stmt_list_ptr& block); diff --git a/src/utils/xsk/gsc/nodetree.hpp b/src/utils/xsk/gsc/nodetree.hpp index 0f5dc85f..4440f485 100644 --- a/src/utils/xsk/gsc/nodetree.hpp +++ b/src/utils/xsk/gsc/nodetree.hpp @@ -1605,7 +1605,12 @@ struct node_stmt_list : public node { if(is_expr) { - if(stmts.size() > 0) return stmts[0].as_node->print(); + if(stmts.size() > 0) + { + auto s = stmts[0].as_node->print(); + s.pop_back(); + return s; + } else return ""; } @@ -1654,7 +1659,7 @@ struct node_stmt_call : public node node_stmt_call(const location& loc, expr_call_ptr expr) : node(node_t::stmt_call, loc), expr(std::move(expr)) {} - auto print()->std::string override + auto print() -> std::string override { return expr->print() + ";"; }; @@ -1670,7 +1675,7 @@ struct node_stmt_assign : public node node_stmt_assign(const location& loc, expr_assign_ptr expr) : node(node_t::stmt_assign, loc), expr(std::move(expr)) {} - auto print()->std::string override + auto print() -> std::string override { return expr->print() + ";"; }; @@ -1954,7 +1959,7 @@ struct node_stmt_for : public node } else { - data += "for ( " + pre_expr.as_node->print() + " " + expr.as_node->print() + "; " + post_expr.as_assign->expr->print() + " )"; + data += "for ( " + pre_expr.as_node->print() + "; " + expr.as_node->print() + "; " + post_expr.as_node->print() + " )"; data += "\n"; }