diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 7f043862..68bf350a 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -250,23 +250,6 @@ namespace Components // DB_AddXAsset Utils::Hook(0x5BB650, AssetHandler::AddAssetStub, HOOK_JUMP).Install()->Quick(); - Command::Add("listassets", [] (Command::Params params) - { - if (params.Length() < 2) return; - - Game::XAssetType type = Game::DB_GetXAssetNameType(params[1]); - - if (type != Game::XAssetType::ASSET_TYPE_INVALID) - { - Game::DB_EnumXAssets(type, [] (Game::XAssetHeader header, void* data) - { - Game::XAssetType type = *static_cast(data); - Game::XAsset asset = { type, header }; - Logger::Print("%s\n", Game::DB_GetXAssetName(&asset)); - }, &type, false); - } - }); - // Register asset interfaces AssetHandler::RegisterInterface(new Assets::IXModel()); AssetHandler::RegisterInterface(new Assets::IMapEnts()); diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index 811433d3..c4af1c1b 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -34,17 +34,29 @@ namespace Components void Command::Add(const char* name, Command::Callback* callback) { - Command::FunctionMap[Utils::StrToLower(name)] = callback; - Command::AddRaw(name, Command::MainCallback); + std::string command = Utils::StrToLower(name); + + if (Command::FunctionMap.find(command) == Command::FunctionMap.end()) + { + Command::AddRaw(name, Command::MainCallback); + } + + Command::FunctionMap[command] = callback; } void Command::AddSV(const char* name, Command::Callback* callback) { - Command::FunctionMapSV[Utils::StrToLower(name)] = callback; - Command::AddRawSV(name, Command::MainCallbackSV); + std::string command = Utils::StrToLower(name); - // If the main command is registered as Cbuf_AddServerText, the command will be redirected to the SV handler - Command::AddRaw(name, Game::Cbuf_AddServerText); + if (Command::FunctionMapSV.find(command) == Command::FunctionMapSV.end()) + { + Command::AddRawSV(name, Command::MainCallbackSV); + + // If the main command is registered as Cbuf_AddServerText, the command will be redirected to the SV handler + Command::AddRaw(name, Game::Cbuf_AddServerText); + } + + Command::FunctionMapSV[command] = callback; } void Command::AddRaw(const char* name, void(*callback)()) diff --git a/src/Components/Modules/Toast.cpp b/src/Components/Modules/Toast.cpp index 417c90a4..7e1510eb 100644 --- a/src/Components/Modules/Toast.cpp +++ b/src/Components/Modules/Toast.cpp @@ -14,8 +14,6 @@ namespace Components void Toast::Draw(UIToast* toast) { -#pragma warning(push) -#pragma warning(disable: 4244) if (!toast) return; int width = Renderer::Width(); @@ -50,7 +48,7 @@ namespace Components int diffH = Renderer::Height() / 5; int diff = Game::Com_Milliseconds() - startTime; double scale = 1.0 - ((1.0 * diff) / (1.0 * slideTime)); - diffH *= scale; + diffH = static_cast(diffH* scale); height += diffH; } @@ -63,7 +61,7 @@ namespace Components int diffH = Renderer::Height() / 5; int diff = (startTime + duration) - Game::Com_Milliseconds(); double scale = 1.0 - ((1.0 * diff) / (1.0 * slideTime)); - diffH *= scale; + diffH = static_cast(diffH* scale); height += diffH; } @@ -88,6 +86,9 @@ namespace Components bWidth += (bWidth % 2); bHeight += (bHeight % 2); +#pragma warning(push) +#pragma warning(disable: 4244) + // Corners Game::R_AddCmdDrawStretchPic(width / 2 - bWidth / 2, height - bHeight / 2, cornerSize, cornerSize, 0, 0, 0.5f, 0.5f, color, circle); // Top-Left Game::R_AddCmdDrawStretchPic(width / 2 + bWidth / 2 - cornerSize, height - bHeight / 2, cornerSize, cornerSize, 0.5f, 0, 0, 0.5f, color, circle); // Top-Right @@ -111,6 +112,7 @@ namespace Components int rightText = width / 2 + bWidth / 2 - cornerSize - aCorners - iOffsetLeft; Game::R_AddCmdDrawText(toast->Title.data(), 0x7FFFFFFF, font, leftText + (rightText - leftText) / 2 - titleSize / 2 + cornerSize, height - bHeight / 2 + cornerSize * 2 + 7, 1.0f, 1.0f, 0, wColor, 0); // Title Game::R_AddCmdDrawText(toast->Desc.data(), 0x7FFFFFFF, font, leftText + (rightText - leftText) / 2 - descrSize / 2 + cornerSize, height - bHeight / 2 + cornerSize * 2 + 33, 1.0f, 1.0f, 0, wColor, 0); // Description + #pragma warning(pop) } diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index f5fd68c6..1625d0d1 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -582,7 +582,8 @@ namespace Components { Game::DB_EnumXAssets(type, [] (Game::XAssetHeader header, void* data) { - Logger::Print("%s\n", Game::DB_GetXAssetNameHandlers[*(Game::XAssetType*)data](&header)); + Game::XAsset asset = { *reinterpret_cast(data), header }; + Logger::Print("%s\n", Game::DB_GetXAssetName(&asset)); }, &type, false); } });