From c45aaf62b78c955600e9016ba31332eb2b1ab986 Mon Sep 17 00:00:00 2001 From: Louvenarde Date: Sat, 21 Oct 2023 19:38:12 +0200 Subject: [PATCH 1/3] Signed/Unsigned fixes --- src/Components/Modules/AssetInterfaces/IXAnimParts.cpp | 8 ++++---- src/Game/Structs.hpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp b/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp index e8b9860c..0a9bd565 100644 --- a/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp +++ b/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp @@ -14,7 +14,7 @@ namespace Assets if (asset->names) { - for (char i = 0; i < asset->boneCount[Game::PART_TYPE_ALL]; ++i) + for (unsigned char i = 0; i < asset->boneCount[Game::PART_TYPE_ALL]; ++i) { builder->addScriptString(asset->names[i]); } @@ -22,7 +22,7 @@ namespace Assets if (asset->notify) { - for (char i = 0; i < asset->notifyCount; ++i) + for (unsigned char i = 0; i < asset->notifyCount; ++i) { builder->addScriptString(asset->notify[i].name); } @@ -165,7 +165,7 @@ namespace Assets unsigned short* destTagnames = buffer->dest(); buffer->saveArray(asset->names, asset->boneCount[Game::PART_TYPE_ALL]); - for (char i = 0; i < asset->boneCount[Game::PART_TYPE_ALL]; ++i) + for (unsigned char i = 0; i < asset->boneCount[Game::PART_TYPE_ALL]; ++i) { builder->mapScriptString(destTagnames[i]); } @@ -181,7 +181,7 @@ namespace Assets Game::XAnimNotifyInfo* destNotetracks = buffer->dest(); buffer->saveArray(asset->notify, asset->notifyCount); - for (char i = 0; i < asset->notifyCount; ++i) + for (unsigned char i = 0; i < asset->notifyCount; ++i) { builder->mapScriptString(destNotetracks[i].name); } diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 4b72f36d..21842c63 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -1044,8 +1044,8 @@ namespace Game unsigned __int16 randomDataIntCount; unsigned __int16 numframes; char flags; - char boneCount[10]; - char notifyCount; + unsigned char boneCount[10]; + unsigned char notifyCount; char assetType; bool isDefault; unsigned int randomDataShortCount; From defdca0b93988a18aa98a3b55e96a745f5e8384f Mon Sep 17 00:00:00 2001 From: Louvenarde Date: Sat, 21 Oct 2023 19:38:40 +0200 Subject: [PATCH 2/3] Bump iW4OF --- deps/iw4-open-formats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/iw4-open-formats b/deps/iw4-open-formats index 6af596a0..aaf4455b 160000 --- a/deps/iw4-open-formats +++ b/deps/iw4-open-formats @@ -1 +1 @@ -Subproject commit 6af596a010eebf727e5d914bf9a01903c14ae128 +Subproject commit aaf4455bdac1ccd07c6eeeac993b7800124244c0 From fd5e229219dbc484576e741773947d9a7dea5c19 Mon Sep 17 00:00:00 2001 From: Louvenarde Date: Sat, 21 Oct 2023 19:52:15 +0200 Subject: [PATCH 3/3] Handle edge cases for IW4x dedicated server (increases stability) --- src/Components/Modules/Download.cpp | 12 ++++++++++++ src/Components/Modules/MapRotation.cpp | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 282f6e86..04990301 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -437,6 +437,12 @@ namespace Components static std::optional 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(); @@ -586,6 +592,12 @@ namespace Components Utils::String::Replace(url, "\\", "/"); + if (url.size() <= 5) + { + mg_http_reply(c, 403, "Content-Type: text/html\r\n", "%s", "400 - Bad requestt"); + return {}; + } + url = url.substr(6); // Strip /file Utils::String::Replace(url, "%20", " "); 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(); }