diff --git a/src/client/component/motd.cpp b/src/client/component/motd.cpp index 5e80551..fc02cb3 100644 --- a/src/client/component/motd.cpp +++ b/src/client/component/motd.cpp @@ -15,7 +15,7 @@ namespace motd { std::string motd_resource = utils::nt::load_resource(DW_MOTD); std::future> motd_future; - std::string marketing_featured_msg_str; + std::string marketing_featured_msg; } std::string get_text() @@ -33,15 +33,15 @@ namespace motd utils::hook::detour marketing_get_message_hook; - bool marketing_get_message_stub(int controllerIndex, int locationID, char* messageText, int messageTextLength) + bool marketing_get_message_stub(int controller, int location, char* message, int max_length) { - if(marketing_featured_msg_str.empty()) return false; + if (marketing_featured_msg.empty()) return false; - strncpy(messageText, marketing_featured_msg_str.data(), messageTextLength); + strncpy_s(message, marketing_featured_msg.length() + 1, marketing_featured_msg.data(), max_length); return true; } - + class component final : public component_interface { public: @@ -49,25 +49,25 @@ namespace motd { motd_future = utils::http::get_data_async("https://xlabs.dev/s1/motd.txt"); std::thread([]() - { - auto data = utils::http::get_data("https://xlabs.dev/s1/motd.png"); - if(data) { - images::override_texture("iotd_image", data.value()); - } - - auto featured_optional = utils::http::get_data("https://xlabs.dev/s1/featured.json"); - if (featured_optional) - { - marketing_featured_msg_str = featured_optional.value(); - } - - }).detach(); + auto data = utils::http::get_data("https://xlabs.dev/s1/motd.png"); + if (data) + { + images::override_texture("iotd_image", data.value()); + } + + auto featured_optional = utils::http::get_data("https://xlabs.dev/s1/featured_msg.json"); + if (featured_optional) + { + marketing_featured_msg = featured_optional.value(); + } + + }).detach(); } - + void post_unpack() override { - marketing_get_message_hook.create(0x140126930, marketing_get_message_stub); // not sure why but in s1x, client doesnt ask for maketing messages from demonware even with marketing_active set to true + marketing_get_message_hook.create(0x140126930, marketing_get_message_stub); // not sure why but in s1x, client doesnt ask for maketing messages from demonware even though marketing_active set to true } }; }