Save entities to JSON, and make custom level building a little faster (#2973)

This will create a folder like `decompiler_out/jak1/entities` and save a
JSON file per level with all the actors.

Also, it should hopefully make custom level building a little faster.
This commit is contained in:
water111
2023-09-09 17:06:39 -04:00
committed by GitHub
parent 8154c4659d
commit 74250a22f7
12 changed files with 479 additions and 53 deletions
+10 -6
View File
@@ -827,7 +827,7 @@ std::string LinkedObjectFile::print_scripts() {
if ((label.offset & 7) == 2) {
// result += to_form_script(seg, word_idx, already_printed)->toStringPretty(0, 100) +
// "\n";
result += pretty_print::to_string(to_form_script(seg, word_idx, already_printed)) + "\n";
result += pretty_print::to_string(to_form_script(seg, word_idx, &already_printed)) + "\n";
}
}
}
@@ -838,7 +838,7 @@ std::string LinkedObjectFile::print_scripts() {
/*!
* Is the object pointed to the empty list?
*/
bool LinkedObjectFile::is_empty_list(int seg, int byte_idx) {
bool LinkedObjectFile::is_empty_list(int seg, int byte_idx) const {
ASSERT((byte_idx % 4) == 0);
auto& word = words_by_seg.at(seg).at(byte_idx / 4);
return word.kind() == LinkedWord::EMPTY_PTR;
@@ -849,7 +849,9 @@ bool LinkedObjectFile::is_empty_list(int seg, int byte_idx) {
* Note : this takes the address of the car of the pair. which is perhaps a bit confusing
* (in GOAL, this would be (&-> obj car))
*/
goos::Object LinkedObjectFile::to_form_script(int seg, int word_idx, std::vector<bool>& seen) {
goos::Object LinkedObjectFile::to_form_script(int seg,
int word_idx,
std::vector<bool>* seen) const {
// the object to currently print. to start off, create pair from the car address we've been given.
int goal_print_obj = word_idx * 4 + 2;
@@ -863,11 +865,13 @@ goos::Object LinkedObjectFile::to_form_script(int seg, int word_idx, std::vector
// loop until we run out of things to add
for (;;) {
// check the thing to print is a a pair.
// check the thing to print is a pair.
if ((goal_print_obj & 7) == 2) {
// first convert the car (again, with (&-> obj car))
fill.as_pair()->car = to_form_script_object(seg, goal_print_obj - 2, seen);
seen.at(goal_print_obj / 4) = true;
if (seen) {
seen->at(goal_print_obj / 4) = true;
}
auto cdr_addr = goal_print_obj + 2;
@@ -940,7 +944,7 @@ bool LinkedObjectFile::is_string(int seg, int byte_idx) const {
*/
goos::Object LinkedObjectFile::to_form_script_object(int seg,
int byte_idx,
std::vector<bool>& seen) {
std::vector<bool>* seen) const {
goos::Object result;
switch (byte_idx & 7) {