From 45181f25fedcf479be39de67710052a24c82f264 Mon Sep 17 00:00:00 2001 From: Death Killer <884052+deathkiller@users.noreply.github.com> Date: Sun, 19 Jan 2025 15:40:55 +0100 Subject: [PATCH] Refactoring --- Sources/Jazz2/Actors/Enemies/Bosses/Bolly.cpp | 6 ++-- .../Jazz2/Actors/Enemies/Bosses/Uterus.cpp | 10 +++---- .../Jazz2/Actors/Multiplayer/RemoteActor.cpp | 10 +++---- .../Multiplayer/RemotePlayerOnServer.cpp | 10 +++---- Sources/Jazz2/Actors/Player.cpp | 6 ++-- Sources/Jazz2/Actors/Solid/Bridge.cpp | 14 ++++----- Sources/Jazz2/Compatibility/JJ2Level.cpp | 2 +- Sources/Jazz2/Compatibility/JJ2Strings.cpp | 2 +- Sources/Jazz2/Compatibility/JJ2Tileset.cpp | 4 +-- Sources/Jazz2/ContentResolver.cpp | 2 +- Sources/Jazz2/LevelHandler.cpp | 4 +-- .../Jazz2/Multiplayer/MultiLevelHandler.cpp | 8 ++--- Sources/Jazz2/UI/Cinematics.cpp | 6 ++-- Sources/Jazz2/UI/DiscordRpcClient.cpp | 2 +- Sources/Jazz2/UI/Font.cpp | 8 ++--- Sources/Jazz2/UI/HUD.cpp | 6 ++-- Sources/Jazz2/UI/Menu/InGameMenu.cpp | 2 +- .../Jazz2/UI/Menu/InputDiagnosticsSection.cpp | 4 +-- Sources/Jazz2/UI/Menu/MainMenu.cpp | 2 +- .../Jazz2/UI/Menu/RemapControlsSection.cpp | 4 +-- .../Jazz2/UI/Menu/StartGameOptionsSection.cpp | 2 +- Sources/Shared/Common.h | 11 ------- Sources/Shared/Containers/ArrayView.h | 1 - Sources/Shared/Containers/DateTime.cpp | 10 +++---- Sources/Shared/Containers/GrowableArray.h | 1 - Sources/Shared/Containers/SequenceHelpers.h | 6 +--- Sources/Shared/Containers/SmallVector.h | 29 +++++++++---------- Sources/Shared/Core/Backward.h | 4 +-- Sources/Shared/Core/ITraceSink.h | 4 +-- Sources/Shared/Core/Logger.h | 12 ++++---- Sources/Shared/IO/FileSystem.cpp | 8 ++--- Sources/Shared/IO/MemoryStream.cpp | 14 +++++---- Sources/Shared/Utf8.cpp | 2 +- .../Backends/Android/AndroidInputManager.cpp | 6 ++-- .../nCine/Backends/Uwp/UwpInputManager.cpp | 4 +-- Sources/nCine/Graphics/GfxCapabilities.cpp | 2 +- Sources/nCine/Input/JoyMapping.cpp | 10 +++---- 37 files changed, 110 insertions(+), 128 deletions(-) diff --git a/Sources/Jazz2/Actors/Enemies/Bosses/Bolly.cpp b/Sources/Jazz2/Actors/Enemies/Bosses/Bolly.cpp index cfe8beaa..6eee71b1 100644 --- a/Sources/Jazz2/Actors/Enemies/Bosses/Bolly.cpp +++ b/Sources/Jazz2/Actors/Enemies/Bosses/Bolly.cpp @@ -24,7 +24,7 @@ namespace Jazz2::Actors::Bosses /*if (_turret != nullptr) { _turret->SetState(ActorState::IsDestroyed, true); }*/ - for (std::int32_t i = 0; i < static_cast(arraySize(_chain)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(_chain)); i++) { if (_chain[i] != nullptr) { _chain[i]->SetState(ActorState::IsDestroyed, true); } @@ -160,7 +160,7 @@ namespace Jazz2::Actors::Bosses }*/ float distance = 30.0f; - for (std::int32_t i = 0; i < static_cast(arraySize(_chain)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(_chain)); i++) { if (_chain[i] != nullptr) { float angle = sinf(_chainPhase - i * 0.08f) * 1.2f + fPiOver2; @@ -186,7 +186,7 @@ namespace Jazz2::Actors::Bosses bool Bolly::OnPerish(ActorBase* collider) { - Explosion::Create(_levelHandler, Vector3i((std::int32_t)_pos.X, (std::int32_t)_pos.Y, _renderer.layer() + 2), Explosion::Type::Large); + Explosion::Create(_levelHandler, Vector3i(std::int32_t(_pos.X), std::int32_t(_pos.Y), _renderer.layer() + 2), Explosion::Type::Large); CreateDeathDebris(collider); _levelHandler->PlayCommonSfx("Splat"_s, Vector3f(_pos.X, _pos.Y, 0.0f)); diff --git a/Sources/Jazz2/Actors/Enemies/Bosses/Uterus.cpp b/Sources/Jazz2/Actors/Enemies/Bosses/Uterus.cpp index 431321bc..1caedac3 100644 --- a/Sources/Jazz2/Actors/Enemies/Bosses/Uterus.cpp +++ b/Sources/Jazz2/Actors/Enemies/Bosses/Uterus.cpp @@ -17,7 +17,7 @@ namespace Jazz2::Actors::Bosses Uterus::~Uterus() { - for (std::int32_t i = 0; i < static_cast(arraySize(_shields)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(_shields)); i++) { if (_shields[i] != nullptr) { _shields[i]->SetState(ActorState::IsDestroyed, true); } @@ -63,12 +63,12 @@ namespace Jazz2::Actors::Bosses _hasShield = true; - for (std::int32_t i = 0; i < static_cast(arraySize(_shields)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(_shields)); i++) { _shields[i] = std::make_shared(); - _shields[i]->Phase = (fTwoPi * i / static_cast(arraySize(_shields))); + _shields[i]->Phase = (fTwoPi * i / std::int32_t(arraySize(_shields))); _shields[i]->OnActivated(ActorActivationDetails( _levelHandler, - Vector3i((std::int32_t)_pos.X, (std::int32_t)_pos.Y, _renderer.layer() + 2) + Vector3i(std::int32_t(_pos.X), std::int32_t(_pos.Y), _renderer.layer() + 2) )); _levelHandler->AddActor(_shields[i]); } @@ -144,7 +144,7 @@ namespace Jazz2::Actors::Bosses if (_hasShield) { std::int32_t shieldCount = 0; - for (std::int32_t i = 0; i < static_cast(arraySize(_shields)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(_shields)); i++) { if (_shields[i] != nullptr) { if (_shields[i]->GetHealth() > 0) { if (_shields[i]->FallTime <= 0.0f) { diff --git a/Sources/Jazz2/Actors/Multiplayer/RemoteActor.cpp b/Sources/Jazz2/Actors/Multiplayer/RemoteActor.cpp index c6dfb047..471d17b6 100644 --- a/Sources/Jazz2/Actors/Multiplayer/RemoteActor.cpp +++ b/Sources/Jazz2/Actors/Multiplayer/RemoteActor.cpp @@ -18,7 +18,7 @@ namespace Jazz2::Actors::Multiplayer Clock& c = nCine::clock(); std::uint64_t now = c.now() * 1000 / c.frequency(); - for (std::int32_t i = 0; i < static_cast(arraySize(_stateBuffer)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(_stateBuffer)); i++) { _stateBuffer[i].Time = now - arraySize(_stateBuffer) + i; _stateBuffer[i].Pos = Vector2f(details.Pos.X, details.Pos.Y); } @@ -34,7 +34,7 @@ namespace Jazz2::Actors::Multiplayer std::int32_t nextIdx = _stateBufferPos - 1; if (nextIdx < 0) { - nextIdx += static_cast(arraySize(_stateBuffer)); + nextIdx += std::int32_t(arraySize(_stateBuffer)); } if (renderTime <= _stateBuffer[nextIdx].Time) { @@ -42,7 +42,7 @@ namespace Jazz2::Actors::Multiplayer while (true) { prevIdx = nextIdx - 1; if (prevIdx < 0) { - prevIdx += static_cast(arraySize(_stateBuffer)); + prevIdx += std::int32_t(arraySize(_stateBuffer)); } if (prevIdx == _stateBufferPos || _stateBuffer[prevIdx].Time <= renderTime) { @@ -104,7 +104,7 @@ namespace Jazz2::Actors::Multiplayer // Actor was hidden before, reset state buffer to disable interpolation std::int32_t stateBufferPrevPos = _stateBufferPos - 1; if (stateBufferPrevPos < 0) { - stateBufferPrevPos += static_cast(arraySize(_stateBuffer)); + stateBufferPrevPos += std::int32_t(arraySize(_stateBuffer)); } std::int64_t renderTime = now - ServerDelay; @@ -116,7 +116,7 @@ namespace Jazz2::Actors::Multiplayer } _stateBufferPos++; - if (_stateBufferPos >= static_cast(arraySize(_stateBuffer))) { + if (_stateBufferPos >= std::int32_t(arraySize(_stateBuffer))) { _stateBufferPos = 0; } } diff --git a/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.cpp b/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.cpp index 653651ef..f11b9efc 100644 --- a/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.cpp +++ b/Sources/Jazz2/Actors/Multiplayer/RemotePlayerOnServer.cpp @@ -17,7 +17,7 @@ namespace Jazz2::Actors::Multiplayer { Clock& c = nCine::clock(); std::uint64_t now = c.now() * 1000 / c.frequency(); - for (std::int32_t i = 0; i < static_cast(arraySize(_stateBuffer)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(_stateBuffer)); i++) { _stateBuffer[i].Time = now - arraySize(_stateBuffer) + i; _stateBuffer[i].Pos = Vector2f(details.Pos.X, details.Pos.Y); } @@ -38,7 +38,7 @@ namespace Jazz2::Actors::Multiplayer std::int32_t nextIdx = _stateBufferPos - 1; if (nextIdx < 0) { - nextIdx += static_cast(arraySize(_stateBuffer)); + nextIdx += std::int32_t(arraySize(_stateBuffer)); } if (renderTime <= _stateBuffer[nextIdx].Time) { @@ -46,7 +46,7 @@ namespace Jazz2::Actors::Multiplayer while (true) { prevIdx = nextIdx - 1; if (prevIdx < 0) { - prevIdx += static_cast(arraySize(_stateBuffer)); + prevIdx += std::int32_t(arraySize(_stateBuffer)); } if (prevIdx == _stateBufferPos || _stateBuffer[prevIdx].Time <= renderTime) { @@ -112,7 +112,7 @@ namespace Jazz2::Actors::Multiplayer // Actor was hidden before, reset state buffer to disable interpolation std::int32_t stateBufferPrevPos = _stateBufferPos - 1; if (stateBufferPrevPos < 0) { - stateBufferPrevPos += static_cast(arraySize(_stateBuffer)); + stateBufferPrevPos += std::int32_t(arraySize(_stateBuffer)); } std::int64_t renderTime = now - ServerDelay; @@ -124,7 +124,7 @@ namespace Jazz2::Actors::Multiplayer } _stateBufferPos++; - if (_stateBufferPos >= static_cast(arraySize(_stateBuffer))) { + if (_stateBufferPos >= std::int32_t(arraySize(_stateBuffer))) { _stateBufferPos = 0; } diff --git a/Sources/Jazz2/Actors/Player.cpp b/Sources/Jazz2/Actors/Player.cpp index d0182da6..1e4103a0 100644 --- a/Sources/Jazz2/Actors/Player.cpp +++ b/Sources/Jazz2/Actors/Player.cpp @@ -3261,7 +3261,7 @@ namespace Jazz2::Actors } // Preload all weapons - for (std::int32_t i = 0; i < static_cast(arraySize(_weaponAmmo)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(_weaponAmmo)); i++) { if (_weaponAmmo[i] != 0) { PreloadMetadataAsync(String("Weapon/"_s + WeaponNames[i])); } @@ -3329,7 +3329,7 @@ namespace Jazz2::Actors levelHandler->SetAmbientLight(this, _checkpointLight); std::int32_t weaponCount = src.ReadVariableInt32(); - RETURN_ASSERT_MSG(weaponCount == static_cast(arraySize(_weaponAmmoCheckpoint)), "Weapon count mismatch"); + RETURN_ASSERT_MSG(weaponCount == std::int32_t(arraySize(_weaponAmmoCheckpoint)), "Weapon count mismatch"); _currentWeapon = (WeaponType)src.ReadVariableInt32(); src.Read(_weaponAmmoCheckpoint, sizeof(_weaponAmmoCheckpoint)); src.Read(_weaponUpgradesCheckpoint, sizeof(_weaponUpgradesCheckpoint)); @@ -3363,7 +3363,7 @@ namespace Jazz2::Actors dest.WriteVariableInt32(_gemsTotal[1]); dest.WriteVariableInt32(_gemsTotal[2]); dest.WriteVariableInt32(_gemsTotal[3]); - dest.WriteVariableInt32(static_cast(arraySize(_weaponAmmoCheckpoint))); + dest.WriteVariableInt32(std::int32_t(arraySize(_weaponAmmoCheckpoint))); dest.WriteVariableInt32((std::int32_t)_currentWeapon); dest.Write(_weaponAmmoCheckpoint, sizeof(_weaponAmmoCheckpoint)); dest.Write(_weaponUpgradesCheckpoint, sizeof(_weaponUpgradesCheckpoint)); diff --git a/Sources/Jazz2/Actors/Solid/Bridge.cpp b/Sources/Jazz2/Actors/Solid/Bridge.cpp index 8f15bd75..2df87f33 100644 --- a/Sources/Jazz2/Actors/Solid/Bridge.cpp +++ b/Sources/Jazz2/Actors/Solid/Bridge.cpp @@ -49,13 +49,13 @@ namespace Jazz2::Actors::Solid switch (_bridgeType) { default: - case BridgeType::Rope: async_await RequestMetadataAsync("Bridge/Rope"_s); _widths = PieceWidthsRope; _widthsCount = static_cast(arraySize(PieceWidthsRope)); break; - case BridgeType::Stone: async_await RequestMetadataAsync("Bridge/Stone"_s); _widths = PieceWidthsStone; _widthsCount = static_cast(arraySize(PieceWidthsStone)); break; - case BridgeType::Vine: async_await RequestMetadataAsync("Bridge/Vine"_s); _widths = PieceWidthsVine; _widthsCount = static_cast(arraySize(PieceWidthsVine)); _widthOffset = 8; break; - case BridgeType::StoneRed: async_await RequestMetadataAsync("Bridge/StoneRed"_s); _widths = PieceWidthsStoneRed; _widthsCount = static_cast(arraySize(PieceWidthsStoneRed)); break; - case BridgeType::Log: async_await RequestMetadataAsync("Bridge/Log"_s); _widths = PieceWidthsLog; _widthsCount = static_cast(arraySize(PieceWidthsLog)); break; - case BridgeType::Gem: async_await RequestMetadataAsync("Bridge/Gem"_s); _widths = PieceWidthsGem; _widthsCount = static_cast(arraySize(PieceWidthsGem)); break; - case BridgeType::Lab: async_await RequestMetadataAsync("Bridge/Lab"_s); _widths = PieceWidthsLab; _widthsCount = static_cast(arraySize(PieceWidthsLab)); _widthOffset = 12; break; + case BridgeType::Rope: async_await RequestMetadataAsync("Bridge/Rope"_s); _widths = PieceWidthsRope; _widthsCount = std::int32_t(arraySize(PieceWidthsRope)); break; + case BridgeType::Stone: async_await RequestMetadataAsync("Bridge/Stone"_s); _widths = PieceWidthsStone; _widthsCount = std::int32_t(arraySize(PieceWidthsStone)); break; + case BridgeType::Vine: async_await RequestMetadataAsync("Bridge/Vine"_s); _widths = PieceWidthsVine; _widthsCount = std::int32_t(arraySize(PieceWidthsVine)); _widthOffset = 8; break; + case BridgeType::StoneRed: async_await RequestMetadataAsync("Bridge/StoneRed"_s); _widths = PieceWidthsStoneRed; _widthsCount = std::int32_t(arraySize(PieceWidthsStoneRed)); break; + case BridgeType::Log: async_await RequestMetadataAsync("Bridge/Log"_s); _widths = PieceWidthsLog; _widthsCount = std::int32_t(arraySize(PieceWidthsLog)); break; + case BridgeType::Gem: async_await RequestMetadataAsync("Bridge/Gem"_s); _widths = PieceWidthsGem; _widthsCount = std::int32_t(arraySize(PieceWidthsGem)); break; + case BridgeType::Lab: async_await RequestMetadataAsync("Bridge/Lab"_s); _widths = PieceWidthsLab; _widthsCount = std::int32_t(arraySize(PieceWidthsLab)); _widthOffset = 12; break; } SetAnimation(AnimState::Default); diff --git a/Sources/Jazz2/Compatibility/JJ2Level.cpp b/Sources/Jazz2/Compatibility/JJ2Level.cpp index 2335b18c..85df5c91 100644 --- a/Sources/Jazz2/Compatibility/JJ2Level.cpp +++ b/Sources/Jazz2/Compatibility/JJ2Level.cpp @@ -958,7 +958,7 @@ namespace Jazz2::Compatibility bool allZeroes = true; if (tileEvent.Converted.Type != EventType::Empty) { - for (std::int32_t i = 0; i < static_cast(arraySize(tileEvent.Converted.Params)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(tileEvent.Converted.Params)); i++) { if (tileEvent.Converted.Params[i] != 0) { allZeroes = false; break; diff --git a/Sources/Jazz2/Compatibility/JJ2Strings.cpp b/Sources/Jazz2/Compatibility/JJ2Strings.cpp index e2f509ef..0938526a 100644 --- a/Sources/Jazz2/Compatibility/JJ2Strings.cpp +++ b/Sources/Jazz2/Compatibility/JJ2Strings.cpp @@ -259,7 +259,7 @@ namespace Jazz2::Compatibility } else { buffer[j++] = '\f'; } - std::int32_t colorIndex2 = colorIndex % (static_cast(arraySize(DefaultFontColors)) + 1); + std::int32_t colorIndex2 = colorIndex % (std::int32_t(arraySize(DefaultFontColors)) + 1); if (colorIndex2 == 0) { buffer[j++] = '['; buffer[j++] = '/'; diff --git a/Sources/Jazz2/Compatibility/JJ2Tileset.cpp b/Sources/Jazz2/Compatibility/JJ2Tileset.cpp index 702f7e2b..8441aa57 100644 --- a/Sources/Jazz2/Compatibility/JJ2Tileset.cpp +++ b/Sources/Jazz2/Compatibility/JJ2Tileset.cpp @@ -206,14 +206,14 @@ namespace Jazz2::Compatibility std::memcpy(palette, _palette, sizeof(_palette)); bool hasAlphaChannel = false; - for (std::int32_t i = 1; i < static_cast(arraySize(palette)); i++) { + for (std::int32_t i = 1; i < std::int32_t(arraySize(palette)); i++) { if ((palette[i] & 0xff000000) != 0) { hasAlphaChannel = true; break; } } if (!hasAlphaChannel) { - for (std::int32_t i = 1; i < static_cast(arraySize(palette)); i++) { + for (std::int32_t i = 1; i < std::int32_t(arraySize(palette)); i++) { palette[i] |= 0xff000000; } } diff --git a/Sources/Jazz2/ContentResolver.cpp b/Sources/Jazz2/ContentResolver.cpp index 397f9bb1..edae5314 100644 --- a/Sources/Jazz2/ContentResolver.cpp +++ b/Sources/Jazz2/ContentResolver.cpp @@ -1639,7 +1639,7 @@ namespace Jazz2 95, 92, 88, 15, 15 }; - constexpr std::int32_t StopsPerGem = (static_cast(arraySize(PaletteStops)) / GemColorCount) - 1; + constexpr std::int32_t StopsPerGem = (std::int32_t(arraySize(PaletteStops)) / GemColorCount) - 1; // Start to fill palette texture from the second row (right after base palette) std::int32_t src = 0, dst = ColorsPerPalette; diff --git a/Sources/Jazz2/LevelHandler.cpp b/Sources/Jazz2/LevelHandler.cpp index 8d65e976..0ac668b6 100644 --- a/Sources/Jazz2/LevelHandler.cpp +++ b/Sources/Jazz2/LevelHandler.cpp @@ -438,7 +438,7 @@ namespace Jazz2 { std::int32_t playerCount = levelInit.GetPlayerCount(); - for (std::int32_t i = 0; i < static_cast(arraySize(levelInit.PlayerCarryOvers)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(levelInit.PlayerCarryOvers)); i++) { if (levelInit.PlayerCarryOvers[i].Type == PlayerType::None) { continue; } @@ -1968,7 +1968,7 @@ namespace Jazz2 const JoyMappedState* joyStates[UI::ControlScheme::MaxConnectedGamepads]; std::int32_t joyStatesCount = 0; - for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < static_cast(arraySize(joyStates)); i++) { + for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < std::int32_t(arraySize(joyStates)); i++) { if (input.isJoyMapped(i)) { joyStates[joyStatesCount++] = &input.joyMappedState(i); } diff --git a/Sources/Jazz2/Multiplayer/MultiLevelHandler.cpp b/Sources/Jazz2/Multiplayer/MultiLevelHandler.cpp index 7745e4a2..a32d6201 100644 --- a/Sources/Jazz2/Multiplayer/MultiLevelHandler.cpp +++ b/Sources/Jazz2/Multiplayer/MultiLevelHandler.cpp @@ -377,7 +377,7 @@ namespace Jazz2::Multiplayer std::int32_t prevIdx = it->second.StateBufferPos - 1; while (prevIdx < 0) { - prevIdx += static_cast(arraySize(it->second.StateBuffer)); + prevIdx += std::int32_t(arraySize(it->second.StateBuffer)); } auto posPrev = WorldPosToScreenSpace(it->second.StateBuffer[prevIdx].Pos); @@ -1200,7 +1200,7 @@ namespace Jazz2::Multiplayer return; } - for (std::int32_t i = 0; i < static_cast(arraySize(levelInit.PlayerCarryOvers)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(levelInit.PlayerCarryOvers)); i++) { if (levelInit.PlayerCarryOvers[i].Type == PlayerType::None) { continue; } @@ -2043,7 +2043,7 @@ namespace Jazz2::Multiplayer LevelHandler::PrepareNextLevelInitialization(levelInit); // Initialize only local players - for (std::int32_t i = 1; i < static_cast(arraySize(levelInit.PlayerCarryOvers)); i++) { + for (std::int32_t i = 1; i < std::int32_t(arraySize(levelInit.PlayerCarryOvers)); i++) { levelInit.PlayerCarryOvers[i].Type = PlayerType::None; } } @@ -2443,7 +2443,7 @@ namespace Jazz2::Multiplayer } playerState.StateBufferPos++; - if (playerState.StateBufferPos >= static_cast(arraySize(playerState.StateBuffer))) { + if (playerState.StateBufferPos >= std::int32_t(arraySize(playerState.StateBuffer))) { playerState.StateBufferPos = 0; } diff --git a/Sources/Jazz2/UI/Cinematics.cpp b/Sources/Jazz2/UI/Cinematics.cpp index 48e6bbc2..69e2a9e7 100644 --- a/Sources/Jazz2/UI/Cinematics.cpp +++ b/Sources/Jazz2/UI/Cinematics.cpp @@ -170,14 +170,14 @@ namespace Jazz2::UI std::uint32_t totalOffset = s->GetPosition(); while (totalOffset < s->GetSize()) { - for (std::int32_t i = 0; i < static_cast(arraySize(_decompressedStreams)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(_decompressedStreams)); i++) { std::int32_t bytesLeft = s->ReadValue(); totalOffset += 4 + bytesLeft; _compressedStreams[i].FetchFromStream(*s, bytesLeft); } } - for (std::int32_t i = 0; i < static_cast(arraySize(_decompressedStreams)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(_decompressedStreams)); i++) { // Skip first two bytes (0x78 0xDA) _compressedStreams[i].Seek(2, SeekOrigin::Begin); _decompressedStreams[i].Open(_compressedStreams[i]); @@ -325,7 +325,7 @@ namespace Jazz2::UI const JoyMappedState* joyStates[UI::ControlScheme::MaxConnectedGamepads]; std::int32_t joyStatesCount = 0; - for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < static_cast(arraySize(joyStates)); i++) { + for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < std::int32_t(arraySize(joyStates)); i++) { if (input.isJoyMapped(i)) { joyStates[joyStatesCount++] = &input.joyMappedState(i); } diff --git a/Sources/Jazz2/UI/DiscordRpcClient.cpp b/Sources/Jazz2/UI/DiscordRpcClient.cpp index b3a54bbb..e220611c 100644 --- a/Sources/Jazz2/UI/DiscordRpcClient.cpp +++ b/Sources/Jazz2/UI/DiscordRpcClient.cpp @@ -111,7 +111,7 @@ namespace Jazz2::UI } bool isConnected = false; - for (std::int32_t j = 0; j < static_cast(arraySize(RpcPaths)); j++) { + for (std::int32_t j = 0; j < std::int32_t(arraySize(RpcPaths)); j++) { for (std::int32_t i = 0; i < 10; i++) { formatString(addr.sun_path, sizeof(addr.sun_path), RpcPaths[j].data(), tempPath.data(), i); if (::connect(_sockFd, (struct sockaddr*)&addr, sizeof(addr)) >= 0) { diff --git a/Sources/Jazz2/UI/Font.cpp b/Sources/Jazz2/UI/Font.cpp index de0424d0..f7865983 100644 --- a/Sources/Jazz2/UI/Font.cpp +++ b/Sources/Jazz2/UI/Font.cpp @@ -284,7 +284,7 @@ namespace Jazz2::UI if (cursor.first == ']') { break; } - if (paramLength < static_cast(arraySize(param)) - 1) { + if (paramLength < std::int32_t(arraySize(param)) - 1) { param[paramLength++] = (char)cursor.first; } idx = cursor.second; @@ -412,7 +412,7 @@ namespace Jazz2::UI if (cursor.first == ']') { break; } - if (paramLength < static_cast(arraySize(param)) - 1) { + if (paramLength < std::int32_t(arraySize(param)) - 1) { param[paramLength++] = (char)cursor.first; } idx = cursor.second; @@ -444,7 +444,7 @@ namespace Jazz2::UI if (cursor.first == ']') { break; } - if (paramLength < static_cast(arraySize(param)) - 1) { + if (paramLength < std::int32_t(arraySize(param)) - 1) { param[paramLength++] = (char)cursor.first; } idx = cursor.second; @@ -493,7 +493,7 @@ namespace Jazz2::UI if (uvRect.W > 0 && uvRect.H > 0) { if (useRandomColor) { - const Colorf& newColor = RandomColors[charOffset % static_cast(arraySize(RandomColors))]; + const Colorf& newColor = RandomColors[charOffset % std::int32_t(arraySize(RandomColors))]; color = Colorf(newColor.R, newColor.G, newColor.B, color.A); } diff --git a/Sources/Jazz2/UI/HUD.cpp b/Sources/Jazz2/UI/HUD.cpp index af77e134..94451e85 100644 --- a/Sources/Jazz2/UI/HUD.cpp +++ b/Sources/Jazz2/UI/HUD.cpp @@ -1098,7 +1098,7 @@ namespace Jazz2::UI } float angle = -fPiOver2; - for (std::int32_t i = 0, j = 0; i < static_cast(arraySize(player->_weaponAmmo)); i++) { + for (std::int32_t i = 0, j = 0; i < std::int32_t(arraySize(player->_weaponAmmo)); i++) { if (player->_weaponAmmo[i] != 0) { float x = cosf(angle) * distance; float y = sinf(angle) * distance; @@ -1233,7 +1233,7 @@ namespace Jazz2::UI { std::int32_t weaponCount = 0; - for (std::int32_t i = 0; i < static_cast(arraySize(player->_weaponAmmo)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(player->_weaponAmmo)); i++) { if (player->_weaponAmmo[i] != 0) { weaponCount++; } @@ -1406,7 +1406,7 @@ namespace Jazz2::UI Color colors[RgbLights::ColorsSize] {}; if (auto captionTile = _levelHandler->_tileMap->GetCaptionTile()) { - for (std::int32_t i = 0; i < static_cast(arraySize(KeyLayout)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(KeyLayout)); i++) { std::int32_t x = KeyLayout[i] % AURA_KEYBOARD_WIDTH; std::int32_t y = KeyLayout[i] / AURA_KEYBOARD_WIDTH; Color tileColor = captionTile[y * 32 + x]; diff --git a/Sources/Jazz2/UI/Menu/InGameMenu.cpp b/Sources/Jazz2/UI/Menu/InGameMenu.cpp index 8018fab0..6e188514 100644 --- a/Sources/Jazz2/UI/Menu/InGameMenu.cpp +++ b/Sources/Jazz2/UI/Menu/InGameMenu.cpp @@ -508,7 +508,7 @@ namespace Jazz2::UI::Menu const JoyMappedState* joyStates[UI::ControlScheme::MaxConnectedGamepads]; std::int32_t joyStatesCount = 0; - for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < static_cast(arraySize(joyStates)); i++) { + for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < std::int32_t(arraySize(joyStates)); i++) { if (input.isJoyMapped(i)) { joyStates[joyStatesCount++] = &input.joyMappedState(i); } diff --git a/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.cpp b/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.cpp index 498f504a..2b7abcf9 100644 --- a/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.cpp +++ b/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.cpp @@ -33,7 +33,7 @@ namespace Jazz2::UI::Menu bool shouldExit = false; const JoyMappedState* joyStates[ControlScheme::MaxConnectedGamepads]; std::int32_t jc = 0; - for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && jc < static_cast(arraySize(joyStates)); i++) { + for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && jc < std::int32_t(arraySize(joyStates)); i++) { if (input.isJoyMapped(i)) { joyStates[jc] = &input.joyMappedState(i); if (joyStates[jc]->isButtonPressed(ButtonName::Start) && joyStates[jc]->isButtonPressed(ButtonName::Back)) { @@ -77,7 +77,7 @@ namespace Jazz2::UI::Menu const JoyMappedState* joyStates[ControlScheme::MaxConnectedGamepads]; std::int32_t jc = 0; - for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && jc < static_cast(arraySize(joyStates)); i++) { + for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && jc < std::int32_t(arraySize(joyStates)); i++) { if (input.isJoyPresent(i)) { jc++; } diff --git a/Sources/Jazz2/UI/Menu/MainMenu.cpp b/Sources/Jazz2/UI/Menu/MainMenu.cpp index cd6520ec..ce5fe7a5 100644 --- a/Sources/Jazz2/UI/Menu/MainMenu.cpp +++ b/Sources/Jazz2/UI/Menu/MainMenu.cpp @@ -612,7 +612,7 @@ namespace Jazz2::UI::Menu const JoyMappedState* joyStates[UI::ControlScheme::MaxConnectedGamepads]; std::int32_t joyStatesCount = 0; - for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < static_cast(arraySize(joyStates)); i++) { + for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < std::int32_t(arraySize(joyStates)); i++) { if (input.isJoyMapped(i)) { joyStates[joyStatesCount++] = &input.joyMappedState(i); } diff --git a/Sources/Jazz2/UI/Menu/RemapControlsSection.cpp b/Sources/Jazz2/UI/Menu/RemapControlsSection.cpp index d404735c..610ebb0d 100644 --- a/Sources/Jazz2/UI/Menu/RemapControlsSection.cpp +++ b/Sources/Jazz2/UI/Menu/RemapControlsSection.cpp @@ -75,7 +75,7 @@ namespace Jazz2::UI::Menu MappingTarget newTarget; const JoyMappedState* joyStates[UI::ControlScheme::MaxConnectedGamepads]; std::int32_t joyStatesCount = 0; - for (std::uint32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < static_cast(arraySize(joyStates)) && waitingForInput; i++) { + for (std::uint32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < std::int32_t(arraySize(joyStates)) && waitingForInput; i++) { if (input.isJoyMapped(i)) { joyStates[joyStatesCount] = &input.joyMappedState(i); auto& prevState = _joyStatesLast[joyStatesCount]; @@ -491,7 +491,7 @@ namespace Jazz2::UI::Menu const JoyMappedState* joyStates[UI::ControlScheme::MaxConnectedGamepads]; std::int32_t joyStatesCount = 0; - for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < static_cast(arraySize(joyStates)); i++) { + for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && joyStatesCount < std::int32_t(arraySize(joyStates)); i++) { if (input.isJoyMapped(i)) { _joyStatesLast[joyStatesCount++] = input.joyMappedState(i); } diff --git a/Sources/Jazz2/UI/Menu/StartGameOptionsSection.cpp b/Sources/Jazz2/UI/Menu/StartGameOptionsSection.cpp index eef34b2e..fb19b5f6 100644 --- a/Sources/Jazz2/UI/Menu/StartGameOptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/StartGameOptionsSection.cpp @@ -294,7 +294,7 @@ namespace Jazz2::UI::Menu const StringView difficultyTypes[] = { _("Easy"), _("Medium"), _("Hard") }; float spacing = (contentBounds.W >= 400 ? 100.0f : 70.0f); - for (std::int32_t j = 0; j < static_cast(arraySize(difficultyTypes)); j++) { + for (std::int32_t j = 0; j < std::int32_t(arraySize(difficultyTypes)); j++) { if (_selectedDifficulty == j) { _root->DrawElement(MenuGlow, 0, center.X + (j - 1) * spacing, center.Y + 28.0f, IMenuContainer::MainLayer, Alignment::Center, Colorf(1.0f, 1.0f, 1.0f, 0.2f), (Utf8::GetLength(difficultyTypes[j]) + 3) * 0.4f, 2.2f, true, true); diff --git a/Sources/Shared/Common.h b/Sources/Shared/Common.h index 9bd8f8e5..2a320b14 100644 --- a/Sources/Shared/Common.h +++ b/Sources/Shared/Common.h @@ -6,17 +6,6 @@ #include #include -#if !defined(countof) && !defined(DOXYGEN_GENERATING_OUTPUT) -# if defined(__cplusplus) - namespace Death { namespace Implementation { - template char(*__ArrayCountOfHelper(T(&)[N]))[N]; - }} -# define countof(a) (sizeof(*Death::Implementation::__ArrayCountOfHelper(a))) -# else -# define countof(a) (sizeof(a) / sizeof(a[0])) -# endif -#endif - #ifdef DOXYGEN_GENERATING_OUTPUT /** @brief Mark an enum as a set of flags */ #define DEATH_ENUM_FLAGS(type) diff --git a/Sources/Shared/Containers/ArrayView.h b/Sources/Shared/Containers/ArrayView.h index fe379423..8ba5e454 100644 --- a/Sources/Shared/Containers/ArrayView.h +++ b/Sources/Shared/Containers/ArrayView.h @@ -27,7 +27,6 @@ #include "../Asserts.h" #include "../Base/Move.h" -#include #include #include diff --git a/Sources/Shared/Containers/DateTime.cpp b/Sources/Shared/Containers/DateTime.cpp index 44383932..145e9da0 100644 --- a/Sources/Shared/Containers/DateTime.cpp +++ b/Sources/Shared/Containers/DateTime.cpp @@ -512,13 +512,13 @@ namespace Death { namespace Containers { bool success2 = false; #if defined(DEATH_TARGET_WINDOWS) wchar_t buffer[64]; - std::int32_t bufferLength = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SSHORTDATE, buffer, static_cast(arraySize(buffer))); + std::int32_t bufferLength = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SSHORTDATE, buffer, int(arraySize(buffer))); if (bufferLength > 0) { if (buffer[bufferLength - 1] == '\0') { bufferLength--; } buffer[bufferLength++] = ' '; - std::int32_t timeLength = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_STIMEFORMAT, buffer + bufferLength, static_cast(arraySize(buffer)) - bufferLength); + std::int32_t timeLength = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_STIMEFORMAT, buffer + bufferLength, int(arraySize(buffer)) - bufferLength); if (timeLength > 0) { bufferLength += timeLength; if (buffer[bufferLength - 1] == '\0') { @@ -660,7 +660,7 @@ namespace Death { namespace Containers { bool success2 = false; #if defined(DEATH_TARGET_WINDOWS) wchar_t buffer[64]; - std::int32_t bufferLength = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SSHORTDATE, buffer, static_cast(arraySize(buffer))); + std::int32_t bufferLength = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SSHORTDATE, buffer, int(arraySize(buffer))); if (bufferLength > 0) { if (buffer[bufferLength - 1] == '\0') { bufferLength--; @@ -669,7 +669,7 @@ namespace Death { namespace Containers { if (format2Length > 0) { success2 = TryParseFormat(dt, input + j, inputLength - j, format2, format2Length, endIndex); if (!success2) { - std::int32_t bufferLength = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SLONGDATE, buffer, static_cast(arraySize(buffer))); + std::int32_t bufferLength = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SLONGDATE, buffer, int(arraySize(buffer))); if (bufferLength > 0) { if (buffer[bufferLength - 1] == '\0') { bufferLength--; @@ -710,7 +710,7 @@ namespace Death { namespace Containers { bool success2 = false; #if defined(DEATH_TARGET_WINDOWS) wchar_t buffer[64]; - std::int32_t bufferLength = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_STIMEFORMAT, buffer, static_cast(arraySize(buffer))); + std::int32_t bufferLength = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_STIMEFORMAT, buffer, int(arraySize(buffer))); if (bufferLength > 0) { if (buffer[bufferLength - 1] == '\0') { bufferLength--; diff --git a/Sources/Shared/Containers/GrowableArray.h b/Sources/Shared/Containers/GrowableArray.h index 751b5ab0..b1634dfd 100644 --- a/Sources/Shared/Containers/GrowableArray.h +++ b/Sources/Shared/Containers/GrowableArray.h @@ -25,7 +25,6 @@ #include "Array.h" -//#include #include #include diff --git a/Sources/Shared/Containers/SequenceHelpers.h b/Sources/Shared/Containers/SequenceHelpers.h index 8c88a5a9..b7682887 100644 --- a/Sources/Shared/Containers/SequenceHelpers.h +++ b/Sources/Shared/Containers/SequenceHelpers.h @@ -23,8 +23,6 @@ #pragma once -#ifndef DOXYGEN_GENERATING_OUTPUT - #include "../Common.h" namespace Death { namespace Containers { namespace Implementation { @@ -43,6 +41,4 @@ namespace Death { namespace Containers { namespace Implementation { template<> struct GenerateSequence<1> { typedef Sequence<0> Type; }; template<> struct GenerateSequence<0> { typedef Sequence<> Type; }; -}}} - -#endif \ No newline at end of file +}}} \ No newline at end of file diff --git a/Sources/Shared/Containers/SmallVector.h b/Sources/Shared/Containers/SmallVector.h index db81d5a3..8e10a16c 100644 --- a/Sources/Shared/Containers/SmallVector.h +++ b/Sources/Shared/Containers/SmallVector.h @@ -1269,6 +1269,18 @@ namespace Death { namespace Containers { extern template class SmallVectorBase; #endif +#ifndef DOXYGEN_GENERATING_OUTPUT + template + inline void swap(Death::Containers::SmallVectorImpl& lhs, Death::Containers::SmallVectorImpl& rhs) { + lhs.swap(rhs); + } + + template + inline void swap(Death::Containers::SmallVector& lhs, Death::Containers::SmallVector& rhs) { + lhs.swap(rhs); + } +#endif + namespace Implementation { template struct ArrayViewConverter> { @@ -1288,19 +1300,4 @@ namespace Death { namespace Containers { template struct ErasedArrayViewConverter> : ArrayViewConverter> {}; } -}} - -#ifndef DOXYGEN_GENERATING_OUTPUT -namespace std -{ - template - inline void swap(Death::Containers::SmallVectorImpl& lhs, Death::Containers::SmallVectorImpl& rhs) { - lhs.swap(rhs); - } - - template - inline void swap(Death::Containers::SmallVector& lhs, Death::Containers::SmallVector& rhs) { - lhs.swap(rhs); - } -} -#endif \ No newline at end of file +}} \ No newline at end of file diff --git a/Sources/Shared/Core/Backward.h b/Sources/Shared/Core/Backward.h index 5fde2716..670b8535 100644 --- a/Sources/Shared/Core/Backward.h +++ b/Sources/Shared/Core/Backward.h @@ -4595,7 +4595,7 @@ namespace Death { namespace Backward { static bool WriteMinidumpWithException(std::size_t requestingThreadId, ExceptionContext* ctx) { wchar_t processPath[MAX_PATH]; - if (!::GetModuleFileNameW(NULL, processPath, static_cast(Containers::arraySize(processPath)))) { + if (!::GetModuleFileNameW(NULL, processPath, DWORD(arraySize(processPath)))) { return false; } @@ -4623,7 +4623,7 @@ namespace Death { namespace Backward { std::int32_t pathPrefixLength = swprintf_s(minidumpPath, L"%s\\CrashDumps\\", processPathLength > 0 ? processPath : L"."); ::CreateDirectory(minidumpPath, NULL); TryEnableFileCompression(minidumpPath); - swprintf_s(minidumpPath + pathPrefixLength, countof(minidumpPath) - pathPrefixLength, L"%s (%02i-%02i-%02i-%02i-%02i-%02i).dmp", &processPath[processPathLength], lt.wYear % 100, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond); + swprintf_s(minidumpPath + pathPrefixLength, arraySize(minidumpPath) - pathPrefixLength, L"%s (%02i-%02i-%02i-%02i-%02i-%02i).dmp", &processPath[processPathLength], lt.wYear % 100, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute, lt.wSecond); HANDLE dumpFile = ::CreateFile(minidumpPath, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); if (dumpFile != INVALID_HANDLE_VALUE) { diff --git a/Sources/Shared/Core/ITraceSink.h b/Sources/Shared/Core/ITraceSink.h index 01c0bf20..1afbf170 100644 --- a/Sources/Shared/Core/ITraceSink.h +++ b/Sources/Shared/Core/ITraceSink.h @@ -42,12 +42,12 @@ namespace Death namespace Trace { /** - @brief Registers the sink and initializes logger if no sink was attached before + @brief Registers the sink and initializes the event logger if no sink was attached before */ void AttachSink(ITraceSink* sink); /** - @brief Unregisters the sink and uninitializes logger if no sink left + @brief Unregisters the sink and uninitializes the event logger if no sink left */ void DetachSink(ITraceSink* sink); diff --git a/Sources/Shared/Core/Logger.h b/Sources/Shared/Core/Logger.h index 6da98af8..15a8a15d 100644 --- a/Sources/Shared/Core/Logger.h +++ b/Sources/Shared/Core/Logger.h @@ -741,7 +741,7 @@ namespace Death { namespace Trace { TransitEvent& operator=(TransitEvent const& other) = delete; TransitEvent(TransitEvent&& other) noexcept - : Timestamp(other.Timestamp), Message(std::move(other.Message)), FlushFlag(other.FlushFlag), Level(other.Level) + : Timestamp(other.Timestamp), Message(Death::move(other.Message)), FlushFlag(other.FlushFlag), Level(other.Level) { } @@ -749,7 +749,7 @@ namespace Death { namespace Trace { { if (this != &other) { Timestamp = other.Timestamp; - Message = std::move(other.Message); + Message = Death::move(other.Message); FlushFlag = other.FlushFlag; Level = other.Level; } @@ -771,7 +771,7 @@ namespace Death { namespace Trace { TransitEventBuffer& operator=(TransitEventBuffer const&) = delete; TransitEventBuffer(TransitEventBuffer&& other) noexcept - : _capacity(other._capacity), _storage(std::move(other._storage)), _mask(other._mask), + : _capacity(other._capacity), _storage(Death::move(other._storage)), _mask(other._mask), _readerPos(other._readerPos), _writerPos(other._writerPos) { other._capacity = 0; @@ -784,7 +784,7 @@ namespace Death { namespace Trace { { if (this != &other) { _capacity = other._capacity; - _storage = std::move(other._storage); + _storage = Death::move(other._storage); _mask = other._mask; _readerPos = other._readerPos; _writerPos = other._writerPos; @@ -849,10 +849,10 @@ namespace Death { namespace Trace { // The reader position and mask are used to handle the circular buffer's wraparound. std::size_t currentSize = size(); for (std::size_t i = 0; i < currentSize; ++i) { - newStorage[i] = std::move(_storage[(_readerPos + i) & _mask]); + newStorage[i] = Death::move(_storage[(_readerPos + i) & _mask]); } - _storage = std::move(newStorage); + _storage = Death::move(newStorage); _capacity = newCapacity; _mask = _capacity - 1; _writerPos = currentSize; diff --git a/Sources/Shared/IO/FileSystem.cpp b/Sources/Shared/IO/FileSystem.cpp index 7d1cb740..3bc1e122 100644 --- a/Sources/Shared/IO/FileSystem.cpp +++ b/Sources/Shared/IO/FileSystem.cpp @@ -879,7 +879,7 @@ namespace Death { namespace IO { String FileSystem::CombinePath(std::initializer_list paths) { - return CombinePath(Containers::arrayView(paths)); + return CombinePath(arrayView(paths)); } StringView FileSystem::GetDirectoryName(StringView path) @@ -989,7 +989,7 @@ namespace Death { namespace IO { #if defined(DEATH_TARGET_WINDOWS) wchar_t buffer[MaxPathLength]; - DWORD length = ::GetFullPathNameW(Utf8::ToUtf16(path), static_cast(arraySize(buffer)), buffer, nullptr); + DWORD length = ::GetFullPathNameW(Utf8::ToUtf16(path), DWORD(arraySize(buffer)), buffer, nullptr); if (length == 0) { return {}; } @@ -1178,7 +1178,7 @@ namespace Death { namespace IO { #elif defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT) wchar_t path[MaxPathLength + 1]; // Returns size *without* the null terminator - const std::size_t size = ::GetModuleFileNameW(NULL, path, static_cast(arraySize(path))); + const std::size_t size = ::GetModuleFileNameW(NULL, path, DWORD(arraySize(path))); return Utf8::FromUtf16(arrayView(path, size)); #else return {}; @@ -2535,7 +2535,7 @@ namespace Death { namespace IO { } } - return Containers::Array{data, size, MapDeleter{hFile, hMap}}; + return Array{data, size, MapDeleter{hFile, hMap}}; # endif } #endif diff --git a/Sources/Shared/IO/MemoryStream.cpp b/Sources/Shared/IO/MemoryStream.cpp index 4968d69f..b3715276 100644 --- a/Sources/Shared/IO/MemoryStream.cpp +++ b/Sources/Shared/IO/MemoryStream.cpp @@ -3,6 +3,8 @@ #include +using namespace Death::Containers; + namespace Death { namespace IO { //###==##====#=====--==~--~=~- --- -- - - - - @@ -12,7 +14,7 @@ namespace Death { namespace IO { _size = 0; if (initialCapacity > 0) { - Containers::arrayReserve(_buffer, initialCapacity); + arrayReserve(_buffer, initialCapacity); } } @@ -28,12 +30,12 @@ namespace Death { namespace IO { _size = bufferSize; } - MemoryStream::MemoryStream(Containers::ArrayView buffer) + MemoryStream::MemoryStream(ArrayView buffer) : MemoryStream(buffer.data(), static_cast(buffer.size())) { } - MemoryStream::MemoryStream(Containers::ArrayView buffer) + MemoryStream::MemoryStream(ArrayView buffer) : MemoryStream(buffer.data(), static_cast(buffer.size())) { } @@ -91,7 +93,7 @@ namespace Death { namespace IO { if (bytesToWrite > 0 && (_mode == AccessMode::Writable || _mode == AccessMode::Growable)) { if (_mode == AccessMode::Growable && _size < _pos + bytesToWrite) { _size = _pos + bytesToWrite; - Containers::arrayResize(_buffer, Containers::NoInit, _size); + arrayResize(_buffer, Containers::NoInit, _size); } bytesWritten = (_pos + bytesToWrite > _size ? (_size - _pos) : bytesToWrite); @@ -122,7 +124,7 @@ namespace Death { namespace IO { void MemoryStream::ReserveCapacity(std::int64_t bytes) { if (_mode == AccessMode::Growable) { - Containers::arrayReserve(_buffer, _pos + bytes); + arrayReserve(_buffer, _pos + bytes); } } @@ -133,7 +135,7 @@ namespace Death { namespace IO { if (_size < _pos + bytesToRead) { if (_mode == AccessMode::Growable) { _size = _pos + bytesToRead; - Containers::arrayResize(_buffer, Containers::NoInit, _size); + arrayResize(_buffer, Containers::NoInit, _size); } else { bytesToRead = static_cast(_size - _pos); } diff --git a/Sources/Shared/Utf8.cpp b/Sources/Shared/Utf8.cpp index 8af29f76..e924412d 100644 --- a/Sources/Shared/Utf8.cpp +++ b/Sources/Shared/Utf8.cpp @@ -132,7 +132,7 @@ namespace Death { namespace Utf8 { const std::size_t lengthNeeded = (sourceSize == 0 ? 0 : ::MultiByteToWideChar(CP_UTF8, 0, source, sourceSize, nullptr, 0) - (sourceSize == -1 ? 1 : 0)); // Create the array with a sentinel null terminator. If size is zero, this is just a single null terminator. - Containers::Array result { Containers::NoInit, lengthNeeded + 1 }; + Containers::Array result{Containers::NoInit, lengthNeeded + 1}; result[lengthNeeded] = L'\0'; if (sourceSize != 0) ::MultiByteToWideChar(CP_UTF8, 0, source, sourceSize, result.data(), (std::int32_t)lengthNeeded); diff --git a/Sources/nCine/Backends/Android/AndroidInputManager.cpp b/Sources/nCine/Backends/Android/AndroidInputManager.cpp index 2e05f0f9..53b9943f 100644 --- a/Sources/nCine/Backends/Android/AndroidInputManager.cpp +++ b/Sources/nCine/Backends/Android/AndroidInputManager.cpp @@ -808,13 +808,13 @@ namespace nCine::Backends joyState.hasDPad_ = true; if (__ANDROID_API__ >= 19 && AndroidJniHelper::SdkVersion() >= 19) { int buttonsToCheck[4]; - for (int i = 0; i < countof(buttonsToCheck); i++) { + for (int i = 0; i < arraySize(buttonsToCheck); i++) { buttonsToCheck[i] = AKEYCODE_DPAD_UP + i; } - inputDevice.hasKeys(buttonsToCheck, countof(buttonsToCheck), checkedButtons); + inputDevice.hasKeys(buttonsToCheck, arraySize(buttonsToCheck), checkedButtons); - for (int i = 0; i < countof(buttonsToCheck); i++) { + for (int i = 0; i < arraySize(buttonsToCheck); i++) { if (!checkedButtons[i]) { joyState.hasDPad_ = false; LOGI("Device (%d, %d) - D-Pad not detected", deviceId, joyId); diff --git a/Sources/nCine/Backends/Uwp/UwpInputManager.cpp b/Sources/nCine/Backends/Uwp/UwpInputManager.cpp index 86303b93..27595aa5 100644 --- a/Sources/nCine/Backends/Uwp/UwpInputManager.cpp +++ b/Sources/nCine/Backends/Uwp/UwpInputManager.cpp @@ -523,7 +523,7 @@ namespace nCine::Backends winrtWGI::GamepadButtons::None /*Guide*/ }; - for (std::int32_t i = 0; i < countof(Mapping); i++) { + for (std::int32_t i = 0; i < arraySize(Mapping); i++) { if (Mapping[i] == winrtWGI::GamepadButtons::None) { continue; } @@ -553,7 +553,7 @@ namespace nCine::Backends }; unsigned char hatState = 0; - for (std::int32_t i = 0; i < countof(Mapping); i++) { + for (std::int32_t i = 0; i < arraySize(Mapping); i++) { bool isPressed = (buttons & Mapping[i]) != winrtWGI::GamepadButtons::None; if (isPressed) { hatState |= (1 << i); diff --git a/Sources/nCine/Graphics/GfxCapabilities.cpp b/Sources/nCine/Graphics/GfxCapabilities.cpp index 29931624..f14069cf 100644 --- a/Sources/nCine/Graphics/GfxCapabilities.cpp +++ b/Sources/nCine/Graphics/GfxCapabilities.cpp @@ -126,7 +126,7 @@ namespace nCine , "GL_OES_compressed_ETC1_RGB8_texture", #endif }; - static_assert(static_cast(arraySize(ExtensionNames)) == (int)GLExtensions::Count, "GLExtensions count mismatch"); + static_assert(std::int32_t(arraySize(ExtensionNames)) == (int)GLExtensions::Count, "GLExtensions count mismatch"); checkGLExtensions(ExtensionNames, glExtensions_, (int)GLExtensions::Count); diff --git a/Sources/nCine/Input/JoyMapping.cpp b/Sources/nCine/Input/JoyMapping.cpp index 7730fc2a..3b75483d 100644 --- a/Sources/nCine/Input/JoyMapping.cpp +++ b/Sources/nCine/Input/JoyMapping.cpp @@ -525,7 +525,7 @@ namespace nCine mapping.isValid = true; - for (std::int32_t i = 0; i < static_cast(arraySize(AndroidAxisNameMapping)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(AndroidAxisNameMapping)); i++) { mapping.desc.axes[i].name = AndroidAxisNameMapping[i]; if (mapping.desc.axes[i].name == AxisName::LeftTrigger || mapping.desc.axes[i].name == AxisName::RightTrigger) { mapping.desc.axes[i].min = 0.0f; @@ -539,11 +539,11 @@ namespace nCine for (std::int32_t i = 0; i < AndroidButtonCount; i++) { mapping.desc.buttons[i] = (ButtonName)i; } - for (std::int32_t i = AndroidButtonCount; i < static_cast(arraySize(mapping.desc.buttons)); i++) { + for (std::int32_t i = AndroidButtonCount; i < std::int32_t(arraySize(mapping.desc.buttons)); i++) { mapping.desc.buttons[i] = ButtonName::Unknown; } - for (std::int32_t i = 0; i < static_cast(arraySize(AndroidDpadButtonNameMapping)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(AndroidDpadButtonNameMapping)); i++) { mapping.desc.hats[i] = AndroidDpadButtonNameMapping[i]; } } @@ -846,7 +846,7 @@ namespace nCine { std::int32_t axisIndex = -1; - for (std::int32_t i = 0; i < static_cast(arraySize(AxesStrings)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(AxesStrings)); i++) { if (value == AxesStrings[i]) { axisIndex = i; break; @@ -860,7 +860,7 @@ namespace nCine { std::int32_t buttonIndex = -1; - for (std::int32_t i = 0; i < static_cast(arraySize(ButtonsStrings)); i++) { + for (std::int32_t i = 0; i < std::int32_t(arraySize(ButtonsStrings)); i++) { if (value == ButtonsStrings[i]) { buttonIndex = i; break;