From a7322c1131848264194fdfaddc5d6987e713c7a8 Mon Sep 17 00:00:00 2001 From: Richard Tollerton Date: Sat, 22 Oct 2022 13:51:12 -0500 Subject: [PATCH 1/3] Add various move constructors Commit 93b8564b requires move constructors for many classes which do not presently exist; they seem simple enough to add. Fixes #708. --- neo/renderer/BinaryImage.h | 11 +++++++++++ neo/swf/SWF.h | 1 + neo/swf/SWF_Bitstream.cpp | 27 +++++++++++++++++++++++++++ neo/swf/SWF_Bitstream.h | 1 + neo/swf/SWF_Dictionary.cpp | 26 ++++++++++++++++++++++++++ 5 files changed, 66 insertions(+) diff --git a/neo/renderer/BinaryImage.h b/neo/renderer/BinaryImage.h index 31445f47..30e39298 100644 --- a/neo/renderer/BinaryImage.h +++ b/neo/renderer/BinaryImage.h @@ -104,6 +104,17 @@ private: memcpy( data, other.data, other.dataSize ); return *this; } + idBinaryImageData& operator=( idBinaryImageData&& other ) + { + if( this == &other ) + { + return *this; + } + dataSize = other.dataSize; + data = other.data; + other.data = NULL; + return *this; + } void Free() { if( data != NULL ) diff --git a/neo/swf/SWF.h b/neo/swf/SWF.h index 418fa063..8339c871 100644 --- a/neo/swf/SWF.h +++ b/neo/swf/SWF.h @@ -50,6 +50,7 @@ public: idSWFDictionaryEntry(); ~idSWFDictionaryEntry(); idSWFDictionaryEntry& operator=( idSWFDictionaryEntry& other ); + idSWFDictionaryEntry& operator=( idSWFDictionaryEntry&& other ); swfDictType_t type; const idMaterial* material; diff --git a/neo/swf/SWF_Bitstream.cpp b/neo/swf/SWF_Bitstream.cpp index 7cb3d490..68d16985 100644 --- a/neo/swf/SWF_Bitstream.cpp +++ b/neo/swf/SWF_Bitstream.cpp @@ -84,6 +84,33 @@ idSWFBitStream& idSWFBitStream::operator=( idSWFBitStream& other ) return *this; } +/* +======================== +idSWFBitStream::operator= +======================== +*/ +idSWFBitStream& idSWFBitStream::operator=( idSWFBitStream&& other ) +{ + Free(); + free = other.free; + startp = other.startp; + readp = other.readp; + endp = other.endp; + currentBit = other.currentBit; + currentByte = other.currentByte; + if( other.free ) + { + // this is actually quite dangerous, but we need to do this + // because these things are copied around inside idList + other.free = false; + } + other.readp = NULL; + other.endp = NULL; + other.currentBit = 0; + other.currentByte = 0; + return *this; +} + /* ======================== idSWFBitStream::Free diff --git a/neo/swf/SWF_Bitstream.h b/neo/swf/SWF_Bitstream.h index 873fa49e..6951682b 100644 --- a/neo/swf/SWF_Bitstream.h +++ b/neo/swf/SWF_Bitstream.h @@ -43,6 +43,7 @@ public: } idSWFBitStream& operator=( idSWFBitStream& other ); + idSWFBitStream& operator=( idSWFBitStream&& other ); void Load( const byte* data, uint32 len, bool copy ); void Free(); diff --git a/neo/swf/SWF_Dictionary.cpp b/neo/swf/SWF_Dictionary.cpp index ecd6b119..21521972 100644 --- a/neo/swf/SWF_Dictionary.cpp +++ b/neo/swf/SWF_Dictionary.cpp @@ -88,6 +88,32 @@ idSWFDictionaryEntry& idSWFDictionaryEntry::operator=( idSWFDictionaryEntry& oth return *this; } +/* +======================== +idSWF::idSWFDictionaryEntry::operator= (move) +======================== +*/ +idSWFDictionaryEntry& idSWFDictionaryEntry::operator=( idSWFDictionaryEntry&& other ) +{ + type = other.type; + material = other.material; + shape = other.shape; + sprite = other.sprite; + font = other.font; + text = other.text; + edittext = other.edittext; + imageSize = other.imageSize; + imageAtlasOffset = other.imageAtlasOffset; + other.type = SWF_DICT_NULL; + other.material = NULL; + other.shape = NULL; + other.sprite = NULL; + other.font = NULL; + other.text = NULL; + other.edittext = NULL; + return *this; +} + /* ======================== idSWF::AddDictionaryEntry From bc8882b8a2d3b170ad152190a0448915f698dd0c Mon Sep 17 00:00:00 2001 From: Richard Tollerton Date: Sat, 22 Oct 2022 13:53:11 -0500 Subject: [PATCH 2/3] Cinematic.cpp: Revert removal of void from METHODDEF(void), etc. In fd6c589d, all instances of (void) were replaced by (). However, the libjpeg defines `METHODDEF`, `LOCAL`, `GLOBAL`, and `EXTERN` (see `jmorecfg.h`) are occasionally used in code as if they are functions: ``` METHODDEF(void) METHODDEF void init_source( j_decompress_ptr cinfo ) ``` fd6c589d therefore breaks these builds when `USE_NEWER_JPEG` is defined, because several function definitions are missing return types. --- neo/renderer/Cinematic.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/neo/renderer/Cinematic.cpp b/neo/renderer/Cinematic.cpp index a9f2b6ae..761bf4ad 100644 --- a/neo/renderer/Cinematic.cpp +++ b/neo/renderer/Cinematic.cpp @@ -2808,7 +2808,7 @@ fill_input_buffer( j_decompress_ptr cinfo ) */ #ifdef USE_NEWER_JPEG - METHODDEF() + METHODDEF(void) #else METHODDEF void #endif @@ -2836,7 +2836,7 @@ init_source( j_decompress_ptr cinfo ) */ #ifdef USE_NEWER_JPEG - METHODDEF() + METHODDEF(void) #else METHODDEF void #endif @@ -2876,7 +2876,7 @@ skip_input_data( j_decompress_ptr cinfo, long num_bytes ) */ #ifdef USE_NEWER_JPEG - METHODDEF() + METHODDEF(void) #else METHODDEF void #endif @@ -2887,7 +2887,7 @@ term_source( j_decompress_ptr cinfo ) } #ifdef USE_NEWER_JPEG - GLOBAL() + GLOBAL(void) #else GLOBAL void #endif From 822ff7d8603cd64f7293cb61d58392fbf6506f2a Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 26 Oct 2022 10:59:22 +0200 Subject: [PATCH 3/3] Astyle --- neo/renderer/Cinematic.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/neo/renderer/Cinematic.cpp b/neo/renderer/Cinematic.cpp index 761bf4ad..f22a57f6 100644 --- a/neo/renderer/Cinematic.cpp +++ b/neo/renderer/Cinematic.cpp @@ -2808,7 +2808,7 @@ fill_input_buffer( j_decompress_ptr cinfo ) */ #ifdef USE_NEWER_JPEG - METHODDEF(void) + METHODDEF( void ) #else METHODDEF void #endif @@ -2836,7 +2836,7 @@ init_source( j_decompress_ptr cinfo ) */ #ifdef USE_NEWER_JPEG - METHODDEF(void) + METHODDEF( void ) #else METHODDEF void #endif @@ -2876,7 +2876,7 @@ skip_input_data( j_decompress_ptr cinfo, long num_bytes ) */ #ifdef USE_NEWER_JPEG - METHODDEF(void) + METHODDEF( void ) #else METHODDEF void #endif @@ -2887,7 +2887,7 @@ term_source( j_decompress_ptr cinfo ) } #ifdef USE_NEWER_JPEG - GLOBAL(void) + GLOBAL( void ) #else GLOBAL void #endif