Skip to content

Commit

Permalink
Merge pull request #5 from SMJSGaming/main
Browse files Browse the repository at this point in the history
Removed UB and removed the GDI incompat
  • Loading branch information
SorkoPiko authored Oct 2, 2024
2 parents af577e0 + 4dc7bbe commit cfe809c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
11 changes: 2 additions & 9 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"geode": "3.7.1",
"geode": "3.8.1",
"gd": {
"win": "2.206",
"android": "2.206",
Expand Down Expand Up @@ -45,12 +45,5 @@
"slider": true
}
}
},
"incompatibilities": [
{
"id": "smjs.gdintercept",
"version": "*",
"importance": "breaking"
}
]
}
}
14 changes: 9 additions & 5 deletions src/hooks/GeodeWeb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ using namespace geode::prelude;

static std::vector<size_t> handledReqs;

web::WebTask WebRequest_send(web::WebRequest* request, const std::string_view method, const std::string_view url) {
web::WebTask WebRequest_send(web::WebRequest* request, const std::string_view methodView, const std::string_view urlView) {
const size_t id = request->getID();
const std::string method(methodView);
const std::string url(urlView);

if (url.find("://www.boomlings.com") != std::string::npos) {
auto downloadLevel = false;
if (url.find("://www.boomlings.com/database/downloadGJLevel22.php") != std::string::npos) {
downloadLevel = true;
}
if (const auto time = RequestStutter::getRequestTime(downloadLevel); time > 0 && std::find(handledReqs.begin(), handledReqs.end(), request->getID()) == handledReqs.end()) {
handledReqs.push_back(request->getID());
if (const auto time = RequestStutter::getRequestTime(downloadLevel); time > 0 && std::find(handledReqs.begin(), handledReqs.end(), id) == handledReqs.end()) {
handledReqs.push_back(id);

const auto req = new web::WebRequest(*request);
const auto returnTask = web::WebTask::run([method, url, req, time](auto progress, auto cancelled) -> web::WebTask::Result {

return web::WebTask::run([method, url, req, time](auto progress, auto cancelled) -> web::WebTask::Result {
std::this_thread::sleep_for(std::chrono::milliseconds(time));

const web::WebResponse* response = nullptr;
Expand Down Expand Up @@ -47,7 +52,6 @@ web::WebTask WebRequest_send(web::WebRequest* request, const std::string_view me
}

}, fmt::format("NRL {} {}", method, url));
return returnTask;
}
}
return request->send(method, url);
Expand Down

0 comments on commit cfe809c

Please sign in to comment.