From 57add9a45cfa8149586e9af7fd2fa1fcd2064272 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Oct 2022 12:10:01 +0200 Subject: [PATCH] - fixed some warnings and updated vectors.h --- src/common/cutscenes/playmve.cpp | 4 +-- .../libsmackerdec/src/SmackerDecoder.cpp | 4 +-- src/common/utility/vectors.h | 32 +++++++++++++++---- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/common/cutscenes/playmve.cpp b/src/common/cutscenes/playmve.cpp index 403daa531..70b56b43a 100644 --- a/src/common/cutscenes/playmve.cpp +++ b/src/common/cutscenes/playmve.cpp @@ -126,7 +126,7 @@ bool InterplayDecoder::FillSamples(void *buff, int len) audio.Packets.pop_front(); plock.unlock(); - int nSamples = pkt.nSize; + int nSamples = (int)pkt.nSize; const uint8_t *samplePtr = pkt.pData.get(); if (audio.bCompressed) { @@ -153,7 +153,7 @@ bool InterplayDecoder::FillSamples(void *buff, int len) audio.samples[audio.nWrite++] = predictor[ch]; // toggle channel - ch ^= stereo; + ch ^= stereo ? 1 : 0; } } else if (audio.nBitDepth == 8) diff --git a/src/common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp b/src/common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp index 57eb4bd15..ff69f3b2c 100644 --- a/src/common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp +++ b/src/common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp @@ -732,7 +732,7 @@ void SmackerDecoder::GetNextFrame() framePacketData.pop_front(); flock.unlock(); - uint32_t frameSize = pkt.size; + uint32_t frameSize = (uint32_t)pkt.size; uint8_t frameFlag = frameFlags[currentFrame]; const uint8_t *packetDataPtr = pkt.data.get(); @@ -1235,7 +1235,7 @@ uint32_t SmackerDecoder::GetAudioData(uint32_t trackIndex, int16_t *audioBuffer) track->bytesReadThisFrame = 0; const uint8_t *packetDataPtr = pkt.data.get(); - uint32_t size = pkt.size; + uint32_t size = (uint32_t)pkt.size; DecodeAudio(packetDataPtr, size, *track); diff --git a/src/common/utility/vectors.h b/src/common/utility/vectors.h index 073c946c7..017d1a520 100644 --- a/src/common/utility/vectors.h +++ b/src/common/utility/vectors.h @@ -577,7 +577,7 @@ struct TVector3 } up = n ^right; - right.MakeUnit();; + right.MakeUnit(); up.MakeUnit(); } @@ -665,6 +665,7 @@ struct TVector3 template struct TVector4 { + typedef TVector2 Vector2; typedef TVector3 Vector3; vec_t X, Y, Z, W; @@ -723,6 +724,29 @@ struct TVector4 return X != other.X || Y != other.Y || Z != other.Z || W != other.W; } + // returns the XY fields as a 2D-vector. + const Vector2& XY() const + { + return *reinterpret_cast(this); + } + + Vector2& XY() + { + return *reinterpret_cast(this); + } + + // returns the XY fields as a 2D-vector. + const Vector3& XYZ() const + { + return *reinterpret_cast(this); + } + + Vector3& XYZ() + { + return *reinterpret_cast(this); + } + + // Test for approximate equality bool ApproximatelyEquals(const TVector4 &other) const { @@ -838,12 +862,6 @@ struct TVector4 return *this; } - // returns the XYZ fields as a 3D-vector. - Vector3 XYZ() const - { - return{ X, Y, Z }; - } - // Add a 4D vector and a 3D vector. friend TVector4 operator+ (const TVector4 &v4, const Vector3 &v3) {