summaryrefslogtreecommitdiff
path: root/tools/jsonproc/jsonproc.cpp
diff options
context:
space:
mode:
authorDennis <dhilhorst2000@gmail.com>2021-07-10 18:23:20 +0200
committerGitHub <noreply@github.com>2021-07-10 11:23:20 -0500
commit92a8e55fdd348a88a365eb389181d8e29da6dad9 (patch)
tree2467ef22cb8cf75bdf056143fab3fac4a68ef404 /tools/jsonproc/jsonproc.cpp
parent386299d1f401cb939e6fe3ea16d0ca57731b2648 (diff)
Decompiled some item related functions (#42)
* decompile sub_8091290 * decompile sub_80912c8 * rename functions / struct field * more names * decompile 80913A0 * decompile GetItemMove * decompile sub_80913E0 * rename function * decompile CanSellItem function * rename inventory struct * add some item check functions * fix renaming stuff * this file shouldnt have been here * forgot merge conflict * decompile more item functions * rename some stuff * fix HM/TM naming * Update src/code_801AFA4.c Use enum value for USED_TM * Fix incorrect value Co-authored-by: Seth Barberee <seth.barberee@gmail.com>
Diffstat (limited to 'tools/jsonproc/jsonproc.cpp')
-rw-r--r--tools/jsonproc/jsonproc.cpp218
1 files changed, 109 insertions, 109 deletions
diff --git a/tools/jsonproc/jsonproc.cpp b/tools/jsonproc/jsonproc.cpp
index 2ba5fd0..5372194 100644
--- a/tools/jsonproc/jsonproc.cpp
+++ b/tools/jsonproc/jsonproc.cpp
@@ -1,109 +1,109 @@
-// jsonproc.cpp
-
-#include "jsonproc.h"
-
-#include <map>
-
-#include <string>
-using std::string; using std::to_string;
-
-#include <inja.hpp>
-using namespace inja;
-using json = nlohmann::json;
-
-std::map<string, string> customVars;
-
-void set_custom_var(string key, string value)
-{
- customVars[key] = value;
-}
-
-string get_custom_var(string key)
-{
- return customVars[key];
-}
-
-int main(int argc, char *argv[])
-{
- if (argc != 4)
- FATAL_ERROR("USAGE: jsonproc <json-filepath> <template-filepath> <output-filepath>\n");
-
- string jsonfilepath = argv[1];
- string templateFilepath = argv[2];
- string outputFilepath = argv[3];
-
- Environment env;
-
- // Add custom command callbacks.
- env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) {
- return "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n";
- });
-
- env.add_callback("subtract", 2, [](Arguments& args) {
- int minuend = args.at(0)->get<int>();
- int subtrahend = args.at(1)->get<int>();
-
- return minuend - subtrahend;
- });
-
- env.add_callback("setVar", 2, [=](Arguments& args) {
- string key = args.at(0)->get<string>();
- string value = args.at(1)->get<string>();
- set_custom_var(key, value);
- return "";
- });
-
- env.add_callback("setVarInt", 2, [=](Arguments& args) {
- string key = args.at(0)->get<string>();
- string value = to_string(args.at(1)->get<int>());
- set_custom_var(key, value);
- return "";
- });
-
- env.add_callback("getVar", 1, [=](Arguments& args) {
- string key = args.at(0)->get<string>();
- return get_custom_var(key);
- });
-
- env.add_callback("concat", 2, [](Arguments& args) {
- string first = args.at(0)->get<string>();
- string second = args.at(1)->get<string>();
- return first + second;
- });
-
- env.add_callback("removePrefix", 2, [](Arguments& args) {
- string rawValue = args.at(0)->get<string>();
- string prefix = args.at(1)->get<string>();
- string::size_type i = rawValue.find(prefix);
- if (i != 0)
- return rawValue;
-
- return rawValue.erase(0, prefix.length());
- });
-
- env.add_callback("removeSuffix", 2, [](Arguments& args) {
- string rawValue = args.at(0)->get<string>();
- string suffix = args.at(1)->get<string>();
- string::size_type i = rawValue.rfind(suffix);
- if (i == string::npos)
- return rawValue;
-
- return rawValue.substr(0, i);
- });
-
- // single argument is a json object
- env.add_callback("isEmpty", 1, [](Arguments& args) {
- return args.at(0)->empty();
- });
-
- try
- {
- env.write_with_json_file(templateFilepath, jsonfilepath, outputFilepath);
- }
- catch (const std::exception& e)
- {
- FATAL_ERROR("JSONPROC_ERROR: %s\n", e.what());
- }
-
- return 0;
-}
+// jsonproc.cpp
+
+#include "jsonproc.h"
+
+#include <map>
+
+#include <string>
+using std::string; using std::to_string;
+
+#include <inja.hpp>
+using namespace inja;
+using json = nlohmann::json;
+
+std::map<string, string> customVars;
+
+void set_custom_var(string key, string value)
+{
+ customVars[key] = value;
+}
+
+string get_custom_var(string key)
+{
+ return customVars[key];
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc != 4)
+ FATAL_ERROR("USAGE: jsonproc <json-filepath> <template-filepath> <output-filepath>\n");
+
+ string jsonfilepath = argv[1];
+ string templateFilepath = argv[2];
+ string outputFilepath = argv[3];
+
+ Environment env;
+
+ // Add custom command callbacks.
+ env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) {
+ return "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n";
+ });
+
+ env.add_callback("subtract", 2, [](Arguments& args) {
+ int minuend = args.at(0)->get<int>();
+ int subtrahend = args.at(1)->get<int>();
+
+ return minuend - subtrahend;
+ });
+
+ env.add_callback("setVar", 2, [=](Arguments& args) {
+ string key = args.at(0)->get<string>();
+ string value = args.at(1)->get<string>();
+ set_custom_var(key, value);
+ return "";
+ });
+
+ env.add_callback("setVarInt", 2, [=](Arguments& args) {
+ string key = args.at(0)->get<string>();
+ string value = to_string(args.at(1)->get<int>());
+ set_custom_var(key, value);
+ return "";
+ });
+
+ env.add_callback("getVar", 1, [=](Arguments& args) {
+ string key = args.at(0)->get<string>();
+ return get_custom_var(key);
+ });
+
+ env.add_callback("concat", 2, [](Arguments& args) {
+ string first = args.at(0)->get<string>();
+ string second = args.at(1)->get<string>();
+ return first + second;
+ });
+
+ env.add_callback("removePrefix", 2, [](Arguments& args) {
+ string rawValue = args.at(0)->get<string>();
+ string prefix = args.at(1)->get<string>();
+ string::size_type i = rawValue.find(prefix);
+ if (i != 0)
+ return rawValue;
+
+ return rawValue.erase(0, prefix.length());
+ });
+
+ env.add_callback("removeSuffix", 2, [](Arguments& args) {
+ string rawValue = args.at(0)->get<string>();
+ string suffix = args.at(1)->get<string>();
+ string::size_type i = rawValue.rfind(suffix);
+ if (i == string::npos)
+ return rawValue;
+
+ return rawValue.substr(0, i);
+ });
+
+ // single argument is a json object
+ env.add_callback("isEmpty", 1, [](Arguments& args) {
+ return args.at(0)->empty();
+ });
+
+ try
+ {
+ env.write_with_json_file(templateFilepath, jsonfilepath, outputFilepath);
+ }
+ catch (const std::exception& e)
+ {
+ FATAL_ERROR("JSONPROC_ERROR: %s\n", e.what());
+ }
+
+ return 0;
+}