diff --git a/README.md b/README.md index 229b8703..bddb8f83 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,9 @@ | `-nosteam` | Disable friends feature and do not update Steam about the game's current status just like an invisible mode. | | `-unprotect-dvars` | Allow the server to modify saved/archive dvars. | | `-zonebuilder` | Start the interactive zonebuilder tool console instead of starting the game. | +| `-disable-notifies` | Disable "Anti-CFG" checks | +| `-disable-mongoose` | Disable Mongoose HTTP server | +| `-disable-rate-limit-check` | Disable RCon rate limit checks | ## Disclaimer diff --git a/deps/iw4-open-formats b/deps/iw4-open-formats index fa074d9b..45405b08 160000 --- a/deps/iw4-open-formats +++ b/deps/iw4-open-formats @@ -1 +1 @@ -Subproject commit fa074d9ba5f61c200db05878bb9fba5ee37a8994 +Subproject commit 45405b08ed2afc0929cb332bfe4288b467ab0ed8 diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index ef93603f..42269ba9 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -21,7 +21,8 @@ namespace Components { 0xf4d2c30b712ac6e3, 0xf7e33c4081337fa3, - 0x6f5597f103cc50e9 + 0x6f5597f103cc50e9, + 0xecd542eee54ffccf, }; bool Auth::HasAccessToReservedSlot; diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 282f6e86..43433425 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -435,8 +435,41 @@ namespace Components MongooseLogBuffer.push_back(c); } - static std::optional InfoHandler([[maybe_unused]] mg_connection* c, [[maybe_unused]] const mg_http_message* hm) + void Download::ReplyError(mg_connection* connection, int code) { + std::string msg{}; + switch(code) + { + case 400: + msg = "Bad request"; + break; + + case 403: + msg = "Forbidden"; + break; + + case 404: + msg = "Not found"; + break; + } + + mg_http_reply(connection, code, "Content-Type: text/plain\r\n", "%s", msg.c_str()); + } + + void Download::Reply(mg_connection* connection, const std::string& contentType, const std::string& data) + { + const auto formatted = std::format("Content-Type: {}\r\n", contentType); + mg_http_reply(connection, 200, formatted.c_str(), "%s", data.c_str()); + } + + std::optional Download::InfoHandler([[maybe_unused]] mg_connection* c, [[maybe_unused]] const mg_http_message* hm) + { + if (!(*Game::com_sv_running)->current.enabled) + { + // Game is not running ,cannot return info + return std::nullopt; + } + const auto status = ServerInfo::GetInfo(); const auto host = ServerInfo::GetHostInfo(); @@ -486,7 +519,7 @@ namespace Components return { out }; } - static std::optional ListHandler([[maybe_unused]] mg_connection* c, [[maybe_unused]] const mg_http_message* hm) + std::optional Download::ListHandler([[maybe_unused]] mg_connection* c, [[maybe_unused]] const mg_http_message* hm) { static nlohmann::json jsonList; static std::filesystem::path fsGamePre; @@ -534,7 +567,7 @@ namespace Components return { out }; } - static std::optional MapHandler([[maybe_unused]] mg_connection* c, [[maybe_unused]] const mg_http_message* hm) + std::optional Download::MapHandler([[maybe_unused]] mg_connection* c, [[maybe_unused]] const mg_http_message* hm) { static std::string mapNamePre; static nlohmann::json jsonList; @@ -580,12 +613,18 @@ namespace Components return { out }; } - static std::optional FileHandler(mg_connection* c, const mg_http_message* hm) + std::optional Download::FileHandler(mg_connection* c, const mg_http_message* hm) { std::string url(hm->uri.ptr, hm->uri.len); Utils::String::Replace(url, "\\", "/"); + if (url.size() <= 5) + { + ReplyError(c, 400); + return {}; + } + url = url.substr(6); // Strip /file Utils::String::Replace(url, "%20", " "); @@ -608,7 +647,7 @@ namespace Components if ((!Maps::GetUserMap()->isValid() && !Party::IsInUserMapLobby()) || !isValidFile) { - mg_http_reply(c, 403, "Content-Type: text/html\r\n", "%s", "403 - Forbidden"); + ReplyError(c, 403); return {}; } @@ -618,7 +657,7 @@ namespace Components { if ((!url.ends_with(".iwd") && url != "mod.ff") || url.find("_svr_") != std::string::npos) { - mg_http_reply(c, 403, "Content-Type: text/html\r\n", "%s", "403 - Forbidden"); + ReplyError(c, 403); return {}; } } @@ -629,7 +668,7 @@ namespace Components std::string file; if ((!isMap && fsGame.empty()) || !Utils::IO::ReadFile(path, &file)) { - mg_http_reply(c, 404, "Content-Type: text/html\r\n", "404 - Not Found %s", path.data()); + ReplyError(c, 404); } else { @@ -644,7 +683,7 @@ namespace Components return {}; } - static std::optional ServerListHandler([[maybe_unused]] mg_connection* c, [[maybe_unused]] const mg_http_message* hm) + std::optional Download::ServerListHandler([[maybe_unused]] mg_connection* c, [[maybe_unused]] const mg_http_message* hm) { std::vector servers; @@ -661,7 +700,7 @@ namespace Components return { out }; } - static void EventHandler(mg_connection* c, const int ev, void* ev_data, [[maybe_unused]] void* fn_data) + void Download::EventHandler(mg_connection* c, const int ev, void* ev_data, [[maybe_unused]] void* fn_data) { using callback = std::function(mg_connection*, const mg_http_message*)>; @@ -693,7 +732,7 @@ namespace Components { if (const auto reply = i->second(c, hm)) { - mg_http_reply(c, 200, "Content-Type: application/json\r\n", "%s", reply.value().data()); + Reply(c, "application/json", reply.value()); } handled = true; diff --git a/src/Components/Modules/Download.hpp b/src/Components/Modules/Download.hpp index 84ee7584..b4e4dde1 100644 --- a/src/Components/Modules/Download.hpp +++ b/src/Components/Modules/Download.hpp @@ -1,5 +1,9 @@ #pragma once + +struct mg_connection; +struct mg_http_message; + namespace Components { class Download : public Component @@ -71,6 +75,7 @@ namespace Components this->valid_ = false; } } + }; class FileDownload @@ -100,5 +105,14 @@ namespace Components static bool DownloadFile(ClientDownload* download, unsigned int index); static void LogFn(char c, void* param); + static void ReplyError(mg_connection* connection, int code); + static void Reply(mg_connection* connection, const std::string& contentType, const std::string& data); + + static std::optional FileHandler(mg_connection* c, const mg_http_message* hm); + static void EventHandler(mg_connection* c, const int ev, void* ev_data, void* fn_data); + static std::optional ListHandler(mg_connection* c, const mg_http_message* hm); + static std::optional InfoHandler(mg_connection* c, const mg_http_message* hm); + static std::optional ServerListHandler(mg_connection* c, const mg_http_message* hm); + static std::optional MapHandler(mg_connection* c, const mg_http_message* hm); }; } diff --git a/src/Components/Modules/MapRotation.cpp b/src/Components/Modules/MapRotation.cpp index 0648a28f..98148978 100644 --- a/src/Components/Modules/MapRotation.cpp +++ b/src/Components/Modules/MapRotation.cpp @@ -208,7 +208,6 @@ namespace Components nlohmann::json MapRotation::to_json() { - assert(!DedicatedRotation.empty()); return DedicatedRotation.to_json(); } diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 66fb86d1..fd496edb 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -17,8 +17,8 @@ namespace Components { - bool ServerList::SortAsc = true; - int ServerList::SortKey = static_cast>(Column::Ping); + bool ServerList::SortAsc = false; + int ServerList::SortKey = static_cast>(Column::Players); unsigned int ServerList::CurrentServer = 0; ServerList::Container ServerList::RefreshContainer; diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index 89bb812a..f06153ed 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -1929,9 +1929,12 @@ namespace Components AssetHandler::Relocate(buffer + 0x20, buffer + 0x18, 0x30); AssetHandler::Relocate(buffer + 0x51, buffer + 0x48, 5); AssetHandler::Relocate(buffer + 0x58, buffer + 0x50, 0x10); - + + Game::Material* material = reinterpret_cast(buffer); // fix statebit - reinterpret_cast(buffer)->stateBitsEntry[47] = codol_material[0x50]; + material->stateBitsEntry[47] = codol_material[0x50]; + //check to fix distortion + if (material->info.sortKey == 44) material->info.sortKey = 43; } else if (Zones::ZoneVersion >= 359) { @@ -1975,6 +1978,9 @@ namespace Components // yes it was lol memcpy(&material->info.drawSurf.packed, material359.drawSurfBegin, 8); + //adding this here, situation as with later ff versions + if (material->info.sortKey == 44) material->info.sortKey = 43; + memcpy(&material->info.surfaceTypeBits, &material359.drawSurf[0], 6); // copies both surfaceTypeBits and hashIndex //material->drawSurf[8] = material359.drawSurf[0]; //material->drawSurf[9] = material359.drawSurf[1]; @@ -2025,6 +2031,9 @@ namespace Components int sunDiff = 8; // Stuff that is part of the sunflare we would overwrite std::memmove(buffer + 348 + sunDiff, buffer + 1316 + sunDiff, 280 - sunDiff); AssetHandler::Relocate(buffer + 1316, buffer + 348, 280); + + //all codol zones are like this pretty certain + reinterpret_cast(buffer)->sortKeyDistortion = 43; } return result; diff --git a/src/Steam/Steam.cpp b/src/Steam/Steam.cpp index e55b8c1f..37ec9361 100644 --- a/src/Steam/Steam.cpp +++ b/src/Steam/Steam.cpp @@ -130,7 +130,7 @@ namespace Steam } else { - Proxy::SetMod("IW4y: Modern Warfare 2"); + Proxy::SetMod("IW4x: Modern Warfare 2"); Proxy::RunGame(); }