From e94d9788d08101a09be6e94bea7931fc8e53946f Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 4 Sep 2016 13:06:44 +0200 Subject: [PATCH] Fix code analysis warnings --- src/Components/Modules/AntiCheat.cpp | 1 - .../Modules/AssetInterfaces/IGfxImage.cpp | 2 +- .../Modules/AssetInterfaces/IPhysPreset.cpp | 2 -- src/Components/Modules/Bans.cpp | 1 - src/Components/Modules/Download.cpp | 7 ------- src/Components/Modules/News.cpp | 1 - src/Components/Modules/Node.cpp | 5 ----- src/Components/Modules/RCon.cpp | 1 - src/Components/Modules/Window.cpp | 1 - src/Utils/IO.cpp | 16 ++++++++++++---- src/Utils/IO.hpp | 2 +- 11 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index 2e81dd88..1c2616ab 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -163,7 +163,6 @@ namespace Components if ((Game::Sys_Milliseconds() - lastCheck) > 1000 * 70) { - // TODO: Move that elsewhere if (HANDLE h = OpenProcess(PROCESS_VM_READ, TRUE, GetCurrentProcessId())) { #ifdef DEBUG_DETECTIONS diff --git a/src/Components/Modules/AssetInterfaces/IGfxImage.cpp b/src/Components/Modules/AssetInterfaces/IGfxImage.cpp index feb08f60..862da050 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxImage.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxImage.cpp @@ -5,7 +5,7 @@ namespace Assets void IGfxImage::Load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) { Game::GfxImage* image = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_IMAGE, name.data()).image; - if (image) return; // TODO: Check for default? + if (image) return; image = builder->GetAllocator()->Allocate(); if (!image) diff --git a/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp b/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp index 304cb60b..763cc95e 100644 --- a/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp +++ b/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp @@ -13,8 +13,6 @@ namespace Assets buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL); - // TODO: I think we have to write them, even if they are NULL - if (asset->name) { buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name)); diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index d1bdd371..76d1b069 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -110,7 +110,6 @@ namespace Components { Bans::AccessMutex.lock(); - // TODO: Read bans FileSystem::File bans("bans.json"); if (bans.Exists()) diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 8b9fae2c..8fb6bd36 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -542,13 +542,6 @@ namespace Components } else { -// Utils::Hook(0x5AC6E9, [] () -// { -// // TODO: Perform moddownload here -// -// Game::CL_DownloadsComplete(0); -// }, HOOK_CALL).Install()->Quick(); - QuickPatch::OnFrame([] { if (Download::CLDownload.Running) diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index 755ed14b..627d26ac 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -155,7 +155,6 @@ namespace Components Localization::Set("MPUI_MOTD_TEXT", data); } - // TODO: Implement update checks here! if (!Loader::PerformingUnitTests()) { while (!News::Terminate) diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index 7c6e8e6f..b2a0fc33 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -768,11 +768,6 @@ namespace Components Node::AddNode(address); } } - else - { - // TODO: Implement client handshake stuff - // Nvm, clients can simply ignore that i guess - } }); Command::Add("listnodes", [] (Command::Params) diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index 450caae0..04eeddce 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -45,7 +45,6 @@ namespace Components } }); - // TODO: Maybe execute that for clients as well, when we use triangular natting. if (!Dedicated::IsEnabled()) return; // Load public key diff --git a/src/Components/Modules/Window.cpp b/src/Components/Modules/Window.cpp index e1f30658..4a755f37 100644 --- a/src/Components/Modules/Window.cpp +++ b/src/Components/Modules/Window.cpp @@ -143,7 +143,6 @@ namespace Components if (Window::CursorVisible) { - // TODO: Apply custom cursor SetCursor(LoadCursor(NULL, IDC_ARROW)); while ((value = ShowCursor(TRUE)) < 0); diff --git a/src/Utils/IO.cpp b/src/Utils/IO.cpp index d953c06a..5fdf05a4 100644 --- a/src/Utils/IO.cpp +++ b/src/Utils/IO.cpp @@ -48,9 +48,9 @@ namespace Utils return buffer; } - void CreateDirectory(std::string dir) + bool CreateDirectory(std::string dir) { - char opath[MAX_PATH]; + char opath[MAX_PATH] = { 0 }; char *p; size_t len; @@ -70,7 +70,10 @@ namespace Utils if (_access(opath, 0)) { - _mkdir(opath); + if (_mkdir(opath) == -1) + { + return false; + } } *p = L'\\'; @@ -79,8 +82,13 @@ namespace Utils if (_access(opath, 0)) { - _mkdir(opath); + if (_mkdir(opath) == -1) + { + return false; + } } + + return true; } } } diff --git a/src/Utils/IO.hpp b/src/Utils/IO.hpp index bc91be09..817eb7d4 100644 --- a/src/Utils/IO.hpp +++ b/src/Utils/IO.hpp @@ -5,6 +5,6 @@ namespace Utils bool FileExists(std::string file); void WriteFile(std::string file, std::string data); std::string ReadFile(std::string file); - void CreateDirectory(std::string dir); + bool CreateDirectory(std::string dir); } }