Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unidokkan/log.h>
- #include <unidokkan/hook.h>
- #include <string>
- #include <dokkan/crypto.h>
- #include <nlohmann/json.hpp>
- #include <unidokkan/database.h>
- #include <parallel_hashmap/phmap.h>
- bool ShowEventsBanners(NetworkResponse *response) {
- using namespace std::string_view_literals;
- using json = nlohmann::json;
- UD_LOGI("Event List Translator : In functions");
- constexpr std::string_view kGetQuests = R"SQL(SELECT
- quests.id,
- quests.name
- FROM
- quests)SQL"sv;
- json quests_list = UniDokkan::Database::select(kGetQuests);
- phmap::parallel_flat_hash_map<int, json> quests_list_keyed = UniDokkan::Database::selectKeyedInt(kGetQuests, 0);
- for (auto &event0 : response->jsonBody["eventkagi_events"]) {
- std::string current_id2 = to_string(event0["id"]);
- std::string current_id = current_id2.substr(0, 3);
- for (auto &quest0 : event0["quests"]) {
- std::string current_quest_id = to_string(quest0["id"]);
- int current_quest_id_INT = std::stoi(current_quest_id);
- std::string current_quest_name = quests_list_keyed[current_quest_id_INT]["name"].get<std::string>();
- quest0["name"] = current_quest_name;
- }
- event0["banner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_list_banner_" + current_id + ".png";
- event0["event_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_top_banner_" + current_id + ".png";
- event0["minibanner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_event_banner_" + current_id + ".png";
- }
- for (auto &event1 : response->jsonBody["eventkagi_z_battle_stages"]) {
- std::string current_id = to_string(event1["id"]);
- event1["banner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/zbattle_list_banner_" + current_id + ".png";
- }
- for (auto &event2 : response->jsonBody["events"]) {
- std::string current_id2 = to_string(event2["id"]);
- std::string current_id = current_id2.substr(0, 3);
- for (auto &quest2 : event2["quests"]) {
- std::string current_quest_id = to_string(quest2["id"]);
- int current_quest_id_INT = std::stoi(current_quest_id);
- std::string current_quest_name = quests_list_keyed[current_quest_id_INT]["name"].get<std::string>();
- quest2["name"] = current_quest_name;
- }
- event2["banner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_list_banner_" + current_id + ".png";
- event2["event_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_top_banner_" + current_id + ".png";
- event2["minibanner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/quest_event_banner_" + current_id + ".png";
- }
- for (auto &event3 : response->jsonBody["z_battle_stages"]) {
- std::string current_id = to_string(event3["id"]);
- event3["banner_image"] = "https://www.baoulettes.fr/DokkanEvent/image/zbattle_list_banner_" + current_id + ".png";
- }
- return true;
- }
- extern "C" {
- int unidokkan_init_v2(HookLib* hook_lib) {
- hook_lib->addResponseHook("^/events$", ShowEventsBanners);
- if (!hook_lib) {
- UD_LOGI("Event List Translator : Crashed");
- return 1;
- }
- UD_LOGI("Event List Translator : Loaded");
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment