diff --git a/Source/Editor/Cooker/GameCooker.cpp b/Source/Editor/Cooker/GameCooker.cpp
index b2831e2dd..7c7baf943 100644
--- a/Source/Editor/Cooker/GameCooker.cpp
+++ b/Source/Editor/Cooker/GameCooker.cpp
@@ -61,8 +61,8 @@ namespace GameCookerImpl
MMethod* Internal_OnProgress = nullptr;
MMethod* Internal_OnCollectAssets = nullptr;
- bool IsRunning = false;
- bool IsThreadRunning = false;
+ volatile bool IsRunning = false;
+ volatile bool IsThreadRunning = false;
int64 CancelFlag = 0;
int64 CancelThreadFlag = 0;
ConditionVariable ThreadCond;
diff --git a/Source/Engine/Animations/Animations.cpp b/Source/Engine/Animations/Animations.cpp
index a9e727d9d..679039b5c 100644
--- a/Source/Engine/Animations/Animations.cpp
+++ b/Source/Engine/Animations/Animations.cpp
@@ -102,7 +102,7 @@ void AnimationsSystem::Execute(TaskGraph* graph)
UnscaledTime = tickData.UnscaledTime.GetTotalSeconds();
#if USE_EDITOR
- // If debug flow is registered, then warm it up (eg. static cached method inside DebugFlow_ManagedWrapper) so it doesn;'t crash on highly multi-threaded code
+ // If debug flow is registered, then warm it up (eg. static cached method inside DebugFlow_ManagedWrapper) so it doesn't crash on highly multi-threaded code
if (Animations::DebugFlow.IsBinded())
Animations::DebugFlow(nullptr, nullptr, 0, 0);
#endif
diff --git a/Source/Engine/Animations/SceneAnimations/SceneAnimation.cpp b/Source/Engine/Animations/SceneAnimations/SceneAnimation.cpp
index 9fd1e6810..a64bb013a 100644
--- a/Source/Engine/Animations/SceneAnimations/SceneAnimation.cpp
+++ b/Source/Engine/Animations/SceneAnimations/SceneAnimation.cpp
@@ -131,11 +131,7 @@ Asset::LoadResult SceneAnimation::load()
auto& track = Tracks[i];
track.Type = (Track::Types)stream.ReadByte();
- // [Deprecated on 13.07.2019 expires on 13.11.2019]
- if (version == 6184 || version == 6183)
- track.Flag = Track::Flags::None;
- else
- track.Flag = (Track::Flags)stream.ReadByte();
+ track.Flag = (Track::Flags)stream.ReadByte();
stream.ReadInt32(&track.ParentIndex);
stream.ReadInt32(&track.ChildrenCount);
stream.ReadString(&track.Name, -13);
diff --git a/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.cpp b/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.cpp
index 1890b568d..c55fdd83c 100644
--- a/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.cpp
+++ b/Source/Engine/Animations/SceneAnimations/SceneAnimationPlayer.cpp
@@ -267,13 +267,8 @@ void SceneAnimationPlayer::Restore(SceneAnimation* anim, int32 stateIndexOffset)
switch (track.Type)
{
case SceneAnimation::Track::Types::Actor:
- case SceneAnimation::Track::Types::CameraCut:
- {
- auto& state = _tracks[stateIndexOffset + track.TrackStateIndex];
- state.ManagedObject = state.Object ? state.Object.GetOrCreateManagedInstance() : nullptr;
- break;
- }
case SceneAnimation::Track::Types::Script:
+ case SceneAnimation::Track::Types::CameraCut:
{
auto& state = _tracks[stateIndexOffset + track.TrackStateIndex];
state.ManagedObject = state.Object ? state.Object.GetOrCreateManagedInstance() : nullptr;
diff --git a/Source/Engine/Content/Assets/Model.cpp b/Source/Engine/Content/Assets/Model.cpp
index d15553da3..97036f1b0 100644
--- a/Source/Engine/Content/Assets/Model.cpp
+++ b/Source/Engine/Content/Assets/Model.cpp
@@ -61,7 +61,7 @@ public:
// [ThreadPoolTask]
bool HasReference(Object* resource) const override
{
- return _asset == resource || (_asset && _asset == resource);
+ return _asset == resource;
}
protected:
diff --git a/Source/Engine/Content/Assets/SkinnedModel.cpp b/Source/Engine/Content/Assets/SkinnedModel.cpp
index abd94b511..095076926 100644
--- a/Source/Engine/Content/Assets/SkinnedModel.cpp
+++ b/Source/Engine/Content/Assets/SkinnedModel.cpp
@@ -54,7 +54,7 @@ public:
// [ThreadPoolTask]
bool HasReference(Object* resource) const override
{
- return _asset == resource || (_asset && _asset == resource);
+ return _asset == resource;
}
protected:
diff --git a/Source/Engine/Core/Collections/CollectionPoolCache.h b/Source/Engine/Core/Collections/CollectionPoolCache.h
index d575c0b25..25af8231e 100644
--- a/Source/Engine/Core/Collections/CollectionPoolCache.h
+++ b/Source/Engine/Core/Collections/CollectionPoolCache.h
@@ -61,6 +61,17 @@ public:
T* Value;
+ ScopeCache() = delete;
+ ScopeCache(const ScopeCache& other) = delete;
+ ScopeCache& operator=(const ScopeCache& other) = delete;
+ ScopeCache& operator=(ScopeCache&& other) noexcept = delete;
+
+ ScopeCache(ScopeCache&& other) noexcept
+ {
+ Value = other.Value;
+ other.Value = nullptr;
+ }
+
~ScopeCache()
{
_pool->Release(Value);
diff --git a/Source/Engine/Core/Math/BoundingBox.h b/Source/Engine/Core/Math/BoundingBox.h
index 92dd3bcc3..d37469fc1 100644
--- a/Source/Engine/Core/Math/BoundingBox.h
+++ b/Source/Engine/Core/Math/BoundingBox.h
@@ -123,7 +123,7 @@ public:
/// Sets the size of the box.
///
/// The box size to set.
- void SetSize(const Vector3 value)
+ void SetSize(const Vector3& value)
{
Vector3 center;
GetCenter(center);
diff --git a/Source/Engine/Core/Math/CollisionsHelper.cpp b/Source/Engine/Core/Math/CollisionsHelper.cpp
index 00ff0ea9b..f15f75b80 100644
--- a/Source/Engine/Core/Math/CollisionsHelper.cpp
+++ b/Source/Engine/Core/Math/CollisionsHelper.cpp
@@ -1221,61 +1221,54 @@ ContainmentType CollisionsHelper::SphereContainsBox(const BoundingSphere& sphere
if (!BoxIntersectsSphere(box, sphere))
return ContainmentType::Disjoint;
- const float radiussquared = sphere.Radius * sphere.Radius;
+ const float radiusSquared = sphere.Radius * sphere.Radius;
+
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
-
- if (vector.LengthSquared() > radiussquared)
+ if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
-
- if (vector.LengthSquared() > radiussquared)
+ if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
-
- if (vector.LengthSquared() > radiussquared)
+ if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
-
- if (vector.LengthSquared() > radiussquared)
+ if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
-
- if (vector.LengthSquared() > radiussquared)
+ if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
-
- if (vector.LengthSquared() > radiussquared)
+ if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
-
- if (vector.LengthSquared() > radiussquared)
+ if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
-
- if (vector.LengthSquared() > radiussquared)
+ if (vector.LengthSquared() > radiusSquared)
return ContainmentType::Intersects;
return ContainmentType::Contains;
diff --git a/Source/Engine/Core/Math/CollisionsHelper.cs b/Source/Engine/Core/Math/CollisionsHelper.cs
index 7d85d2407..460a14184 100644
--- a/Source/Engine/Core/Math/CollisionsHelper.cs
+++ b/Source/Engine/Core/Math/CollisionsHelper.cs
@@ -1425,61 +1425,54 @@ namespace FlaxEngine
if (!BoxIntersectsSphere(ref box, ref sphere))
return ContainmentType.Disjoint;
- float radiussquared = sphere.Radius * sphere.Radius;
+ float radiusSquared = sphere.Radius * sphere.Radius;
+
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
-
- if (vector.LengthSquared > radiussquared)
+ if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
-
- if (vector.LengthSquared > radiussquared)
+ if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
-
- if (vector.LengthSquared > radiussquared)
+ if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Maximum.Z;
-
- if (vector.LengthSquared > radiussquared)
+ if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
-
- if (vector.LengthSquared > radiussquared)
+ if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Maximum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
-
- if (vector.LengthSquared > radiussquared)
+ if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Maximum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
-
- if (vector.LengthSquared > radiussquared)
+ if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
vector.X = sphere.Center.X - box.Minimum.X;
vector.Y = sphere.Center.Y - box.Minimum.Y;
vector.Z = sphere.Center.Z - box.Minimum.Z;
-
- if (vector.LengthSquared > radiussquared)
+ if (vector.LengthSquared > radiusSquared)
return ContainmentType.Intersects;
return ContainmentType.Contains;
diff --git a/Source/Engine/Graphics/Models/Mesh.cpp b/Source/Engine/Graphics/Models/Mesh.cpp
index 3ae9b969f..ccd5bc456 100644
--- a/Source/Engine/Graphics/Models/Mesh.cpp
+++ b/Source/Engine/Graphics/Models/Mesh.cpp
@@ -446,7 +446,6 @@ void Mesh::Draw(const RenderContext& renderContext, const DrawInfo& info, float
drawCall.Geometry.VertexBuffersOffsets[2] = 0;
if (info.VertexColors && info.VertexColors[_lodIndex])
{
- drawCall.Geometry.VertexBuffers[2] = info.VertexColors[_lodIndex];
// TODO: cache vertexOffset within the model LOD per-mesh
uint32 vertexOffset = 0;
for (int32 meshIndex = 0; meshIndex < _index; meshIndex++)
diff --git a/Source/Engine/Graphics/RenderBuffers.cpp b/Source/Engine/Graphics/RenderBuffers.cpp
index 0788738c6..82e5a3821 100644
--- a/Source/Engine/Graphics/RenderBuffers.cpp
+++ b/Source/Engine/Graphics/RenderBuffers.cpp
@@ -154,7 +154,6 @@ bool RenderBuffers::Init(int32 width, int32 height)
_aspectRatio = static_cast(width) / height;
_viewport = Viewport(0, 0, static_cast(width), static_cast(height));
LastEyeAdaptationTime = 0;
- LastEyeAdaptationTime = 0;
return result;
}
diff --git a/Source/Engine/Graphics/RenderTools.cpp b/Source/Engine/Graphics/RenderTools.cpp
index 142906192..8a6d12349 100644
--- a/Source/Engine/Graphics/RenderTools.cpp
+++ b/Source/Engine/Graphics/RenderTools.cpp
@@ -489,8 +489,7 @@ int32 MipLevelsCount(int32 width, bool useMipLevels)
int32 result = 1;
while (width > 1)
{
- if (width > 1)
- width >>= 1;
+ width >>= 1;
result++;
}
diff --git a/Source/Engine/Graphics/Textures/StreamingTexture.cpp b/Source/Engine/Graphics/Textures/StreamingTexture.cpp
index 801b7a19b..87ad4d048 100644
--- a/Source/Engine/Graphics/Textures/StreamingTexture.cpp
+++ b/Source/Engine/Graphics/Textures/StreamingTexture.cpp
@@ -114,7 +114,7 @@ bool StreamingTexture::Create(const TextureHeader& header)
{
// Ensure that streaming doesn't go too low because the hardware expects the texture to be min in size of compressed texture block
int32 lastMip = header.MipLevels - 1;
- while (header.Width >> lastMip < 4 && header.Height >> lastMip < 4)
+ while ((header.Width >> lastMip) < 4 && (header.Height >> lastMip) < 4)
lastMip--;
_minMipCountBlockCompressed = header.MipLevels - lastMip + 1;
}
diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp
index 5d1efa5e7..ed2a13ae0 100644
--- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp
+++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp
@@ -180,7 +180,7 @@ void GPUContextDX11::ClearUA(GPUBuffer* buf, const Vector4& value)
void GPUContextDX11::ResetRenderTarget()
{
- if (_rtCount > 0 || _uaOutput || _rtDepth)
+ if (_rtCount != 0 || _uaOutput || _rtDepth)
{
_omDirtyFlag = true;
_rtCount = 0;
diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp
index 25c9ad7ee..42b51f993 100644
--- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp
+++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp
@@ -730,7 +730,7 @@ void GPUContextDX12::ClearUA(GPUBuffer* buf, const Vector4& value)
void GPUContextDX12::ResetRenderTarget()
{
- if (_rtDepth != nullptr || _rtCount != 0 || _rtDepth)
+ if (_rtDepth || _rtCount != 0)
{
_rtDirtyFlag = false;
_psDirtyFlag = true;
diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUTextureDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUTextureDX12.cpp
index 1044ff41b..147189e6a 100644
--- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUTextureDX12.cpp
+++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUTextureDX12.cpp
@@ -589,7 +589,7 @@ void GPUTextureDX12::initHandles()
}
if (useUAV)
{
- if (isCubeMap || isArray)
+ if (isCubeMap)
{
uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
uavDesc.Texture2DArray.ArraySize = arraySize;
diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp
index 1b19b88b1..1ad2c948b 100644
--- a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp
+++ b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp
@@ -845,7 +845,7 @@ void GPUContextVulkan::ClearUA(GPUBuffer* buf, const Vector4& value)
void GPUContextVulkan::ResetRenderTarget()
{
- if (_rtDepth != nullptr || _rtCount != 0 || _rtDepth)
+ if (_rtDepth || _rtCount != 0)
{
_rtDirtyFlag = true;
_psDirtyFlag = true;
@@ -999,12 +999,9 @@ void GPUContextVulkan::BindIB(GPUBuffer* indexBuffer)
void GPUContextVulkan::BindSampler(int32 slot, GPUSampler* sampler)
{
- ASSERT(slot >= 0 && slot < GPU_MAX_SR_BINDED);
+ ASSERT(slot >= GPU_STATIC_SAMPLERS_COUNT && slot < GPU_MAX_SAMPLER_BINDED);
const auto handle = sampler ? ((GPUSamplerVulkan*)sampler)->Sampler : nullptr;
- if (_samplerHandles[slot] != handle)
- {
- _samplerHandles[slot] = handle;
- }
+ _samplerHandles[slot] = handle;
}
void GPUContextVulkan::UpdateCB(GPUConstantBuffer* cb, const void* data)
diff --git a/Source/Engine/Networking/Drivers/ENetDriver.cpp b/Source/Engine/Networking/Drivers/ENetDriver.cpp
index 32ddfde01..6025c406a 100644
--- a/Source/Engine/Networking/Drivers/ENetDriver.cpp
+++ b/Source/Engine/Networking/Drivers/ENetDriver.cpp
@@ -1,21 +1,18 @@
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
-//
+
// TODO: Check defines so we can disable ENet
#include "ENetDriver.h"
-
#include "Engine/Networking/NetworkConfig.h"
#include "Engine/Networking/NetworkChannelType.h"
#include "Engine/Networking/NetworkEvent.h"
#include "Engine/Networking/NetworkPeer.h"
-
#include "Engine/Core/Log.h"
#include "Engine/Core/Collections/Array.h"
#define ENET_IMPLEMENTATION
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include
-
#undef _WINSOCK_DEPRECATED_NO_WARNINGS
#undef SendMessage
@@ -24,15 +21,15 @@ ENetPacketFlag ChannelTypeToPacketFlag(const NetworkChannelType channel)
int flag = 0; // Maybe use ENET_PACKET_FLAG_NO_ALLOCATE?
// Add reliable flag when it is "reliable" channel
- if(channel > NetworkChannelType::UnreliableOrdered)
+ if (channel > NetworkChannelType::UnreliableOrdered)
flag |= ENET_PACKET_FLAG_RELIABLE;
// Use unsequenced flag when the flag is unreliable. We have to sequence all other packets.
- if(channel == NetworkChannelType::Unreliable)
+ if (channel == NetworkChannelType::Unreliable)
flag |= ENET_PACKET_FLAG_UNSEQUENCED;
// Note that all reliable channels are exactly the same. TODO: How to handle unordered reliable packets...?
-
+
return static_cast(flag);
}
@@ -48,7 +45,7 @@ void SendPacketToPeer(ENetPeer* peer, const NetworkChannelType channelType, cons
ENetPacket* packet = enet_packet_create(message.Buffer, message.Length, flag);
// And send it!
- enet_peer_send (peer, 0, packet);
+ enet_peer_send(peer, 0, packet);
// TODO: To reduce latency, we can use `enet_host_flush` to flush all packets. Maybe some API, like NetworkManager::FlushQueues()?
}
@@ -59,7 +56,8 @@ void ENetDriver::Initialize(NetworkPeer* host, const NetworkConfig& config)
_config = config;
_peerMap = Dictionary();
- if (enet_initialize () != 0) {
+ if (enet_initialize() != 0)
+ {
LOG(Error, "Failed to initialize ENet driver!");
}
@@ -68,39 +66,39 @@ void ENetDriver::Initialize(NetworkPeer* host, const NetworkConfig& config)
void ENetDriver::Dispose()
{
- if(_peer)
+ if (_peer)
enet_peer_disconnect_now((ENetPeer*)_peer, 0);
enet_host_destroy((ENetHost*)_host);
-
+
enet_deinitialize();
-
+
_peerMap.Clear();
_peerMap = {};
-
+
_peer = nullptr;
_host = nullptr;
-
+
LOG(Info, "ENet driver stopped!");
}
bool ENetDriver::Listen()
{
- ENetAddress address = {0};
+ ENetAddress address = { 0 };
address.port = _config.Port;
address.host = ENET_HOST_ANY;
// Set host address if needed
- if(_config.Address != String("any"))
+ if (_config.Address != String("any"))
enet_address_set_host(&address, _config.Address.ToStringAnsi().GetText());
-
+
// Create ENet host
_host = enet_host_create(&address, _config.ConnectionsLimit, 1, 0, 0);
- if(_host == nullptr)
+ if (_host == nullptr)
{
LOG(Error, "Failed to initialize ENet host!");
return false;
}
-
+
LOG(Info, "Created ENet server!");
return true;
}
@@ -109,21 +107,21 @@ bool ENetDriver::Connect()
{
LOG(Info, "Connecting using ENet...");
- ENetAddress address = {0};
+ ENetAddress address = { 0 };
address.port = _config.Port;
enet_address_set_host(&address, _config.Address.ToStringAnsi().GetText());
// Create ENet host
_host = enet_host_create(nullptr, 1, 1, 0, 0);
- if(_host == nullptr)
+ if (_host == nullptr)
{
LOG(Error, "Failed to initialize ENet host!");
return false;
}
-
+
// Create ENet peer/connect to the server
_peer = enet_host_connect((ENetHost*)_host, &address, 1, 0);
- if(_peer == nullptr)
+ if (_peer == nullptr)
{
LOG(Error, "Failed to create ENet host!");
enet_host_destroy((ENetHost*)_host);
@@ -135,13 +133,11 @@ bool ENetDriver::Connect()
void ENetDriver::Disconnect()
{
- ASSERT(_peer != nullptr);
-
- if(_peer)
+ if (_peer)
{
enet_peer_disconnect_now((ENetPeer*)_peer, 0);
_peer = nullptr;
-
+
LOG(Info, "Disconnected");
}
}
@@ -149,9 +145,9 @@ void ENetDriver::Disconnect()
void ENetDriver::Disconnect(const NetworkConnection& connection)
{
const int connectionId = connection.ConnectionId;
-
+
void* peer = nullptr;
- if(_peerMap.TryGet(connectionId, peer))
+ if (_peerMap.TryGet(connectionId, peer))
{
enet_peer_disconnect_now((ENetPeer*)peer, 0);
_peerMap.Remove(connectionId);
@@ -167,39 +163,39 @@ bool ENetDriver::PopEvent(NetworkEvent* eventPtr)
ENetEvent event;
const int result = enet_host_service((ENetHost*)_host, &event, 0);
- if(result < 0)
+ if (result < 0)
LOG(Error, "Failed to check ENet events!");
-
- if(result > 0)
+
+ if (result > 0)
{
// Copy sender data
const uint32 connectionId = enet_peer_get_id(event.peer);
eventPtr->Sender = NetworkConnection();
eventPtr->Sender.ConnectionId = connectionId;
-
- switch(event.type)
+
+ switch (event.type)
{
case ENET_EVENT_TYPE_CONNECT:
eventPtr->EventType = NetworkEventType::Connected;
- if(IsServer())
+ if (IsServer())
_peerMap.Add(connectionId, event.peer);
break;
-
+
case ENET_EVENT_TYPE_DISCONNECT:
eventPtr->EventType = NetworkEventType::Disconnected;
-
- if(IsServer())
+
+ if (IsServer())
_peerMap.Remove(connectionId);
break;
-
+
case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT:
eventPtr->EventType = NetworkEventType::Timeout;
-
- if(IsServer())
+
+ if (IsServer())
_peerMap.Remove(connectionId);
break;
-
+
case ENET_EVENT_TYPE_RECEIVE:
eventPtr->EventType = NetworkEventType::Message;
@@ -208,8 +204,9 @@ bool ENetDriver::PopEvent(NetworkEvent* eventPtr)
eventPtr->Message.Length = event.packet->dataLength;
Memory::CopyItems(eventPtr->Message.Buffer, event.packet->data, event.packet->dataLength);
break;
-
- default: break;
+
+ default:
+ break;
}
return true; // Event
}
@@ -220,7 +217,7 @@ bool ENetDriver::PopEvent(NetworkEvent* eventPtr)
void ENetDriver::SendMessage(const NetworkChannelType channelType, const NetworkMessage& message)
{
ASSERT(IsServer() == false);
-
+
SendPacketToPeer((ENetPeer*)_peer, channelType, message);
}
@@ -231,20 +228,20 @@ void ENetDriver::SendMessage(NetworkChannelType channelType, const NetworkMessag
ENetPeer* peer = *(ENetPeer**)_peerMap.TryGet(target.ConnectionId);
ASSERT(peer != nullptr);
ASSERT(peer->state == ENET_PEER_STATE_CONNECTED);
-
+
SendPacketToPeer(peer, channelType, message);
}
void ENetDriver::SendMessage(const NetworkChannelType channelType, const NetworkMessage& message, const Array& targets)
{
ASSERT(IsServer());
-
- for(NetworkConnection target : targets)
+
+ for (NetworkConnection target : targets)
{
ENetPeer* peer = *(ENetPeer**)_peerMap.TryGet(target.ConnectionId);
ASSERT(peer != nullptr);
ASSERT(peer->state == ENET_PEER_STATE_CONNECTED);
-
+
SendPacketToPeer(peer, channelType, message);
}
}
diff --git a/Source/Engine/Particles/ParticleEffect.cpp b/Source/Engine/Particles/ParticleEffect.cpp
index 7b8f599fe..7f78e408c 100644
--- a/Source/Engine/Particles/ParticleEffect.cpp
+++ b/Source/Engine/Particles/ParticleEffect.cpp
@@ -31,9 +31,9 @@ void ParticleEffectParameter::Init(ParticleEffect* effect, int32 emitterIndex, i
bool ParticleEffectParameter::IsValid() const
{
return _effect->ParticleSystem &&
+ _effect->Instance.Emitters.Count() > _emitterIndex &&
_effect->ParticleSystem->Emitters[_emitterIndex] &&
- _effect->ParticleSystem->Emitters[_emitterIndex]->Graph.Parameters.Count() > _paramIndex &&
- _effect->Instance.Emitters.Count() > _emitterIndex;
+ _effect->ParticleSystem->Emitters[_emitterIndex]->Graph.Parameters.Count() > _paramIndex;
}
ParticleEmitter* ParticleEffectParameter::GetEmitter() const
diff --git a/Source/Engine/Platform/Base/FileSystemBase.cpp b/Source/Engine/Platform/Base/FileSystemBase.cpp
index 4eeeee6e2..5758c2f11 100644
--- a/Source/Engine/Platform/Base/FileSystemBase.cpp
+++ b/Source/Engine/Platform/Base/FileSystemBase.cpp
@@ -103,7 +103,6 @@ bool FileSystemBase::IsRelative(const StringView& path)
const bool isRooted =
(path.Length() >= 2 && StringUtils::IsAlpha(path[0]) && path[1] == ':') ||
path.StartsWith(StringView(TEXT("\\\\"), 2), StringSearchCase::CaseSensitive) ||
- path.StartsWith('/') ||
path.StartsWith('\\') ||
path.StartsWith('/');
return !isRooted;
diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp
index f24ca5545..636c4daf0 100644
--- a/Source/Engine/Render2D/Render2D.cpp
+++ b/Source/Engine/Render2D/Render2D.cpp
@@ -1941,7 +1941,8 @@ void Render2D::DrawTexturedTriangles(GPUTexture* t, const Span& vertice
void Render2D::DrawTexturedTriangles(GPUTexture* t, const Span& vertices, const Span& uvs, const Span& colors)
{
RENDER2D_CHECK_RENDERING_STATE;
- CHECK(vertices.Length() == uvs.Length() == colors.Length())
+ CHECK(vertices.Length() == uvs.Length());
+ CHECK(vertices.Length() == colors.Length());
Render2DDrawCall& drawCall = DrawCalls.AddOne();
drawCall.Type = DrawCallType::FillTexture;
diff --git a/Source/Engine/Renderer/RenderList.cpp b/Source/Engine/Renderer/RenderList.cpp
index 67aaf4778..be1f035fc 100644
--- a/Source/Engine/Renderer/RenderList.cpp
+++ b/Source/Engine/Renderer/RenderList.cpp
@@ -636,7 +636,7 @@ DRAW:
auto& drawCall = DrawCalls[list.Indices[batch.StartIndex]];
int32 vbCount = 0;
- while (drawCall.Geometry.VertexBuffers[vbCount] && vbCount < ARRAY_COUNT(drawCall.Geometry.VertexBuffers))
+ while (vbCount < ARRAY_COUNT(drawCall.Geometry.VertexBuffers) && drawCall.Geometry.VertexBuffers[vbCount])
{
vb[vbCount] = drawCall.Geometry.VertexBuffers[vbCount];
vbOffsets[vbCount] = drawCall.Geometry.VertexBuffersOffsets[vbCount];
@@ -687,7 +687,7 @@ DRAW:
auto& drawCall = batch.DrawCall;
int32 vbCount = 0;
- while (drawCall.Geometry.VertexBuffers[vbCount] && vbCount < ARRAY_COUNT(drawCall.Geometry.VertexBuffers))
+ while (vbCount < ARRAY_COUNT(drawCall.Geometry.VertexBuffers) && drawCall.Geometry.VertexBuffers[vbCount])
{
vb[vbCount] = drawCall.Geometry.VertexBuffers[vbCount];
vbOffsets[vbCount] = drawCall.Geometry.VertexBuffersOffsets[vbCount];
diff --git a/Source/Engine/Renderer/VolumetricFogPass.cpp b/Source/Engine/Renderer/VolumetricFogPass.cpp
index 2a2322ea8..42df902ed 100644
--- a/Source/Engine/Renderer/VolumetricFogPass.cpp
+++ b/Source/Engine/Renderer/VolumetricFogPass.cpp
@@ -113,7 +113,8 @@ bool VolumetricFogPass::Init(RenderContext& renderContext, GPUContext* context,
// Check if already prepared for this frame
if (renderContext.Buffers->LastFrameVolumetricFog == Engine::FrameCount)
{
- fog->GetVolumetricFogOptions(options);
+ if (fog)
+ fog->GetVolumetricFogOptions(options);
return false;
}
diff --git a/Source/Engine/Scripting/ManagedCLR/MUtils.cpp b/Source/Engine/Scripting/ManagedCLR/MUtils.cpp
index 8a0c181b4..5f894f17e 100644
--- a/Source/Engine/Scripting/ManagedCLR/MUtils.cpp
+++ b/Source/Engine/Scripting/ManagedCLR/MUtils.cpp
@@ -175,8 +175,6 @@ VariantType MUtils::UnboxVariantType(MonoType* monoType)
return VariantType(VariantType::Float);
if (klass == mono_get_double_class() || monoType->type == MONO_TYPE_R8)
return VariantType(VariantType::Double);
- if (klass == mono_get_double_class() || monoType->type == MONO_TYPE_BOOLEAN)
- return VariantType(VariantType::Double);
if (klass == mono_get_string_class() || monoType->type == MONO_TYPE_STRING)
return VariantType(VariantType::String);
if (klass == mono_get_intptr_class() || klass == mono_get_uintptr_class() || monoType->type == MONO_TYPE_PTR)
diff --git a/Source/Engine/Serialization/JsonWriter.cpp b/Source/Engine/Serialization/JsonWriter.cpp
index 1a5586fd4..9b01a0111 100644
--- a/Source/Engine/Serialization/JsonWriter.cpp
+++ b/Source/Engine/Serialization/JsonWriter.cpp
@@ -417,10 +417,7 @@ void JsonWriter::SceneObject(::SceneObject* obj)
}
else
{
- if (prefab)
- LOG(Warning, "Failed to load prefab {0}.", prefab->ToString());
- else
- LOG(Warning, "Missing prefab with id={0}.", obj->GetPrefabID());
+ LOG(Warning, "Missing prefab with id={0}.", obj->GetPrefabID());
}
}
diff --git a/Source/Engine/Serialization/MemoryReadStream.h b/Source/Engine/Serialization/MemoryReadStream.h
index 9c01c2f97..79ee845cb 100644
--- a/Source/Engine/Serialization/MemoryReadStream.h
+++ b/Source/Engine/Serialization/MemoryReadStream.h
@@ -78,7 +78,6 @@ public:
/// The pointer to the data in memory.
void* Read(uint32 bytes)
{
- ASSERT(bytes >= 0);
ASSERT(GetLength() - GetPosition() >= bytes);
const auto result = (void*)_position;
_position += bytes;
diff --git a/Source/Engine/Serialization/MemoryWriteStream.cpp b/Source/Engine/Serialization/MemoryWriteStream.cpp
index 3b602a53a..a902ee6b0 100644
--- a/Source/Engine/Serialization/MemoryWriteStream.cpp
+++ b/Source/Engine/Serialization/MemoryWriteStream.cpp
@@ -131,8 +131,6 @@ void MemoryWriteStream::SetPosition(uint32 seek)
void MemoryWriteStream::WriteBytes(const void* data, uint32 bytes)
{
- ASSERT(bytes >= 0);
-
// Calculate current position
const uint32 position = GetPosition();
diff --git a/Source/Engine/Serialization/Stream.cpp b/Source/Engine/Serialization/Stream.cpp
index 5e6176a03..298799a05 100644
--- a/Source/Engine/Serialization/Stream.cpp
+++ b/Source/Engine/Serialization/Stream.cpp
@@ -72,8 +72,6 @@ void ReadStream::ReadString(String* data)
}
data->ReserveSpace(length);
- if (length == 0)
- return;
Char* ptr = data->Get();
ASSERT(ptr != nullptr);
Read(ptr, length);
@@ -92,8 +90,6 @@ void ReadStream::ReadString(String* data, int16 lock)
}
data->ReserveSpace(length);
- if (length == 0)
- return;
Char* ptr = data->Get();
ASSERT(ptr != nullptr);
Read(ptr, length);
diff --git a/Source/Engine/Utilities/StringUtils.cs b/Source/Engine/Utilities/StringUtils.cs
index 57c018fb7..f9b3ab9a4 100644
--- a/Source/Engine/Utilities/StringUtils.cs
+++ b/Source/Engine/Utilities/StringUtils.cs
@@ -147,7 +147,6 @@ namespace FlaxEngine
{
bool isRooted = (path.Length >= 2 && char.IsLetterOrDigit(path[0]) && path[1] == ':') ||
path.StartsWith("\\\\") ||
- path.StartsWith("/") ||
path.StartsWith("\\") ||
path.StartsWith("/");
return !isRooted;