Skip to content

Commit d93bc95

Browse files
committed
fix script command searching
1 parent 25fda1f commit d93bc95

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

rpgmaker_scraper.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
#include <fstream>
88
#include <iomanip>
99

10+
// debug
11+
static constexpr bool is_debugging = false;
12+
static constexpr uint32_t debug_map_id = 5;
13+
static constexpr uint32_t debug_event_id = 130;
14+
1015
using colors = logger::console_colors;
1116

1217
void RPGMakerScraper::load() {
@@ -56,12 +61,17 @@ void RPGMakerScraper::load() {
5661
void RPGMakerScraper::scrape_maps() {
5762

5863
for (const auto &[map_id, name] : map_info_names) {
64+
// allow easy debugging
65+
if (is_debugging && map_id != debug_map_id) {
66+
continue;
67+
}
68+
5969
// give hacky visual progress
6070
progress_status =
6171
utils::format_string(R"(scraping Map%03d...)", map_id);
6272
log_colored_nnl(colors::WHITE, colors::BLACK, "%s", progress_status.data());
6373

64-
log_colored_nnl(colors::WHITE, colors::BLACK, "%s",
74+
log_colored_nnl(colors::WHITE, colors::BLACK, "%s",
6575
std::string(progress_status.length(), '\b').data());
6676

6777
// check if the current map we're scraping exists
@@ -109,6 +119,10 @@ void RPGMakerScraper::scrape_variables() {
109119
for (const auto &[map_id, events] : all_events) {
110120
// go over every event
111121
for (const auto &event : events) {
122+
// allow easy debugging
123+
if (is_debugging && event.id != debug_event_id) {
124+
continue;
125+
}
112126
// go over event page in each event
113127
for (size_t page_num = 0, page_count = event.pages.size(); page_num < page_count; ++page_num) {
114128
const auto &page = event.pages[page_num];
@@ -463,7 +477,11 @@ bool RPGMakerScraper::scrape_command_script(ResultInformation &result_info, cons
463477

464478
constexpr uint32_t expected_param_count = 1;
465479

466-
if (!command.parameters.size() != expected_param_count) {
480+
if (command.parameters.size() != expected_param_count) {
481+
return false;
482+
}
483+
484+
if (!std::holds_alternative<std::string>(command.parameters[0])) {
467485
return false;
468486
}
469487

rpgmaker_types.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Command::Command(const json &command_json) {
2525
code = static_cast<CommandCode>(command_json["code"].get<uint32_t>());
2626

2727
for (const auto &parameter : command_json["parameters"]) {
28+
if (parameter.is_null() || parameter.empty()) {
29+
continue;
30+
}
2831
if (parameter.is_number_integer()) {
2932
parameters.emplace_back(parameter.get<uint32_t>());
3033
continue;

0 commit comments

Comments
 (0)