2
0
Эх сурвалжийг харах

Added more assertions.
Fixed out-of-bounds array access in GLShaderProcessor.
Fixed PortAudio output mode.
SharedPtr::RawPtr() renamed to Get() and WeakPtr::ToShared() to Lock().

Lasse Öörni 14 жил өмнө
parent
commit
7eed016fd8
39 өөрчлөгдсөн 155 нэмэгдсэн , 136 устгасан
  1. 5 5
      Engine/Audio/Audio.cpp
  2. 9 9
      Engine/Audio/Sound.cpp
  3. 1 1
      Engine/Audio/Sound.h
  4. 1 1
      Engine/Audio/SoundSource.cpp
  5. 14 14
      Engine/Container/ArrayPtr.h
  6. 14 14
      Engine/Container/Ptr.h
  7. 14 10
      Engine/Container/RefCounted.cpp
  8. 1 0
      Engine/Core/Object.cpp
  9. 5 0
      Engine/Core/Object.h
  10. 2 2
      Engine/Engine/APITemplates.h
  11. 1 1
      Engine/Engine/GraphicsAPI.cpp
  12. 1 1
      Engine/Engine/ResourceAPI.cpp
  13. 3 3
      Engine/Engine/ScriptAPI.cpp
  14. 2 2
      Engine/Engine/UIAPI.cpp
  15. 1 1
      Engine/Graphics/AnimatedModel.cpp
  16. 1 1
      Engine/Graphics/Direct3D9/D3D9IndexBuffer.cpp
  17. 1 1
      Engine/Graphics/Direct3D9/D3D9Shader.cpp
  18. 2 2
      Engine/Graphics/Direct3D9/D3D9ShaderVariation.cpp
  19. 2 2
      Engine/Graphics/Direct3D9/D3D9VertexBuffer.cpp
  20. 3 3
      Engine/Graphics/Geometry.cpp
  21. 4 4
      Engine/Graphics/Model.cpp
  22. 5 5
      Engine/Graphics/OcclusionBuffer.cpp
  23. 5 5
      Engine/Graphics/OpenGL/OGLIndexBuffer.cpp
  24. 1 1
      Engine/Graphics/OpenGL/OGLShaderVariation.cpp
  25. 2 2
      Engine/Graphics/OpenGL/OGLTexture2D.cpp
  26. 2 2
      Engine/Graphics/OpenGL/OGLTextureCube.cpp
  27. 6 6
      Engine/Graphics/OpenGL/OGLVertexBuffer.cpp
  28. 2 2
      Engine/IO/FileSystem.cpp
  29. 7 7
      Engine/Physics/CollisionShape.cpp
  30. 9 9
      Engine/Resource/Image.cpp
  31. 2 2
      Engine/Resource/ResourceCache.cpp
  32. 2 2
      Engine/Resource/XMLFile.cpp
  33. 3 3
      Engine/Scene/Node.cpp
  34. 8 0
      Engine/Scene/Serializable.h
  35. 2 2
      Engine/Script/ScriptFile.cpp
  36. 6 6
      Engine/UI/UI.cpp
  37. 2 1
      Tools/GLShaderProcessor/GLShaderProcessor.cpp
  38. 2 2
      Tools/NormalMapTool/NormalMapTool.cpp
  39. 2 2
      Tools/RampGenerator/RampGenerator.cpp

+ 5 - 5
Engine/Audio/Audio.cpp

@@ -318,7 +318,7 @@ bool Audio::SetMode(int bufferLengthMSec, int mixRate, bool stereo, bool interpo
     outputParams.suggestedLatency = bufferLengthMSec / 1000.0;
     outputParams.hostApiSpecificStreamInfo = 0;
     
-    if (Pa_OpenStream(&stream_, 0, &outputParams, mixRate, fragmentSize, 0, AudioCallback, this) != paNoError)
+    if (Pa_OpenStream(&stream_, 0, &outputParams, mixRate, fragmentSize_, 0, AudioCallback, this) != paNoError)
     {
         LOGERROR("Failed to open audio stream");
         return false;
@@ -401,7 +401,7 @@ void Audio::Stop()
     
     #ifdef USE_OPENGL
     Pa_StopStream(stream_);
-    else
+    #else
     ((AudioStream*)stream_)->StopPlayback();
     #endif
     
@@ -496,15 +496,15 @@ void Audio::MixOutput(void *dest, unsigned samples)
             clipSamples <<= 1;
         
         // Clear clip buffer
-        memset(clipBuffer_.RawPtr(), 0, clipSamples * sizeof(int));
-        int* clipPtr = clipBuffer_.RawPtr();
+        memset(clipBuffer_.Get(), 0, clipSamples * sizeof(int));
+        int* clipPtr = clipBuffer_.Get();
         
         // Mix samples to clip buffer
         for (PODVector<SoundSource*>::Iterator i = soundSources_.Begin(); i != soundSources_.End(); ++i)
             (*i)->Mix(clipPtr, workSamples, mixRate_, stereo_, interpolate_);
         
         // Copy output from clip buffer to destination
-        clipPtr = clipBuffer_.RawPtr();
+        clipPtr = clipBuffer_.Get();
         short* destPtr = (short*)dest;
         while (clipSamples--)
             *destPtr++ = Clamp(*clipPtr++, -32768, 32767);

+ 9 - 9
Engine/Audio/Sound.cpp

@@ -102,11 +102,11 @@ bool Sound::LoadOggVorbis(Deserializer& source)
 {
     unsigned dataSize = source.GetSize();
     SharedArrayPtr<signed char> data(new signed char[dataSize]);
-    source.Read(data.RawPtr(), dataSize);
+    source.Read(data.Get(), dataSize);
     
     // Check for validity of data
     int error;
-    stb_vorbis* vorbis = stb_vorbis_open_memory((unsigned char*)data.RawPtr(), dataSize, &error, 0);
+    stb_vorbis* vorbis = stb_vorbis_open_memory((unsigned char*)data.Get(), dataSize, &error, 0);
     if (!vorbis)
     {
         LOGERROR("Could not read Ogg Vorbis data from " + source.GetName());
@@ -199,7 +199,7 @@ bool Sound::LoadWav(Deserializer& source)
     unsigned length = header.dataLength_;
     SetSize(length);
     SetFormat(header.frequency_, header.bits_ == 16, header.channels_ == 2);
-    source.Read(data_.RawPtr(), length);
+    source.Read(data_.Get(), length);
     
     // Convert 8-bit audio to signed
     if (!sixteenBit_)
@@ -215,7 +215,7 @@ bool Sound::LoadRaw(Deserializer& source)
 {
     unsigned dataSize = source.GetSize();
     SetSize(dataSize);
-    return source.Read(data_.RawPtr(), dataSize) == dataSize;
+    return source.Read(data_.Get(), dataSize) == dataSize;
 }
 
 void Sound::SetSize(unsigned dataSize)
@@ -237,7 +237,7 @@ void Sound::SetData(const void* data, unsigned dataSize)
         return;
     
     SetSize(dataSize);
-    memcpy(data_.RawPtr(), data, dataSize);
+    memcpy(data_.Get(), data, dataSize);
 }
 
 void Sound::SetFormat(unsigned frequency, bool sixteenBit, bool stereo)
@@ -256,7 +256,7 @@ void Sound::SetLooped(bool enable)
     {
         if (!compressed_)
         {
-            end_ = data_.RawPtr() + dataSize_;
+            end_ = data_.Get() + dataSize_;
             looped_ = false;
             
             FixInterpolation();
@@ -280,8 +280,8 @@ void Sound::SetLoop(unsigned repeatOffset, unsigned endOffset)
         repeatOffset &= -sampleSize;
         endOffset &= -sampleSize;
         
-        repeat_ = data_.RawPtr() + repeatOffset;
-        end_ = data_.RawPtr() + endOffset;
+        repeat_ = data_.Get() + repeatOffset;
+        end_ = data_.Get() + endOffset;
         looped_ = true;
         
         FixInterpolation();
@@ -314,7 +314,7 @@ void* Sound::AllocateDecoder()
         return 0;
     
     int error;
-    stb_vorbis* vorbis = stb_vorbis_open_memory((unsigned char*)data_.RawPtr(), dataSize_, &error, 0);
+    stb_vorbis* vorbis = stb_vorbis_open_memory((unsigned char*)data_.Get(), dataSize_, &error, 0);
     return vorbis;
 }
 

+ 1 - 1
Engine/Audio/Sound.h

@@ -71,7 +71,7 @@ public:
     void FreeDecoder(void* Decoder);
     
     /// Return sound data start
-    signed char* GetStart() const { return data_.RawPtr(); }
+    signed char* GetStart() const { return data_.Get(); }
     /// Return loop start
     signed char* GetRepeat() const { return repeat_; }
     /// Return sound data end

+ 1 - 1
Engine/Audio/SoundSource.cpp

@@ -236,7 +236,7 @@ void SoundSource::SetAutoRemove(bool enable)
 
 bool SoundSource::IsPlaying() const
 {
-    return sound_.RawPtr() != 0;
+    return sound_.Get() != 0;
 }
 
 void SoundSource::SetPlayPosition(signed char* pos)

+ 14 - 14
Engine/Container/ArrayPtr.h

@@ -124,7 +124,7 @@ public:
     {
         Release();
         
-        ptr_ = static_cast<T*>(rhs.RawPtr());
+        ptr_ = static_cast<T*>(rhs.Get());
         refCount_ = rhs.RefCountPtr();
         if (refCount_)
             ++(refCount_->refs_);
@@ -135,7 +135,7 @@ public:
     {
         Release();
         
-        ptr_ = dynamic_cast<T*>(rhs.RawPtr());
+        ptr_ = dynamic_cast<T*>(rhs.Get());
         if (ptr_)
         {
             refCount_ = rhs.RefCountPtr();
@@ -151,7 +151,7 @@ public:
     /// Check if the pointer is not null
     bool NotNull() const { return ptr_ != 0; }
     /// Return the raw pointer
-    T* RawPtr() const { return ptr_; }
+    T* Get() const { return ptr_; }
     /// Return the array's reference count, or 0 if the pointer is null
     unsigned Refs() const { return refCount_ ? refCount_->refs_ : 0; }
     /// Return the array's weak reference count, or 0 if the pointer is null
@@ -223,7 +223,7 @@ public:
     
     /// Construct from a shared array pointer
     WeakArrayPtr(const SharedArrayPtr<T>& rhs) :
-        ptr_(rhs.RawPtr()),
+        ptr_(rhs.Get()),
         refCount_(rhs.RefCountPtr())
     {
         if (refCount_)
@@ -248,12 +248,12 @@ public:
     /// Assign from a shared array pointer
     WeakArrayPtr<T>& operator = (const SharedArrayPtr<T>& rhs)
     {
-        if (ptr_ == rhs.RawPtr() && refCount_ == rhs.RefCountPtr())
+        if (ptr_ == rhs.Get() && refCount_ == rhs.RefCountPtr())
             return *this;
         
         Release();
         
-        ptr_ = rhs.RawPtr();
+        ptr_ = rhs.Get();
         refCount_ = rhs.RefCountPtr();
         if (refCount_)
             ++(refCount_->weakRefs_);
@@ -278,7 +278,7 @@ public:
     }
     
     /// Convert to shared array pointer. If expired, return a null shared array pointer
-    SharedArrayPtr<T> ToShared() const
+    SharedArrayPtr<T> Lock() const
     {
         if (Expired())
             return SharedArrayPtr<T>();
@@ -287,7 +287,7 @@ public:
     }
     
     /// Return raw pointer. If expired, return null
-    T* RawPtr() const
+    T* Get() const
     {
         if (Expired())
             return 0;
@@ -298,7 +298,7 @@ public:
     /// Point to the array
     T* operator -> () const
     {
-        T* rawPtr = RawPtr();
+        T* rawPtr = Get();
         assert(rawPtr);
         return rawPtr;
     }
@@ -306,7 +306,7 @@ public:
     /// Dereference the array
     T& operator * () const
     {
-        T* rawPtr = RawPtr();
+        T* rawPtr = Get();
         assert(rawPtr);
         return *rawPtr;
     }
@@ -314,7 +314,7 @@ public:
     /// Subscript the array
     T& operator [] (const int index)
     {
-        T* rawPtr = RawPtr();
+        T* rawPtr = Get();
         assert(rawPtr);
         return (*rawPtr)[index];
     }
@@ -328,7 +328,7 @@ public:
     /// Return true if points to an array which is not expired
     operator bool () const { return !Expired(); }
     /// Convert to a raw pointer, null if array is expired
-    operator T* () const { return RawPtr(); }
+    operator T* () const { return Get(); }
     
     /// Reset to null and release the weak reference
     void Reset()
@@ -341,7 +341,7 @@ public:
     {
         Release();
         
-        ptr_ = static_cast<T*>(rhs.RawPtr());
+        ptr_ = static_cast<T*>(rhs.Get());
         refCount_ = rhs.refCount_;
         if (refCount_)
             ++(refCount_->weakRefs_);
@@ -352,7 +352,7 @@ public:
     {
         Release();
         
-        ptr_ = dynamic_cast<T*>(rhs.RawPtr());
+        ptr_ = dynamic_cast<T*>(rhs.Get());
         if (ptr_)
         {
             refCount_ = rhs.refCount_;

+ 14 - 14
Engine/Container/Ptr.h

@@ -117,7 +117,7 @@ public:
     {
         Release();
         
-        ptr_ = static_cast<T*>(rhs.RawPtr());
+        ptr_ = static_cast<T*>(rhs.Get());
         if (ptr_)
             ptr_->AddRef();
     }
@@ -127,7 +127,7 @@ public:
     {
         Release();
         
-        ptr_ = dynamic_cast<T*>(rhs.RawPtr());
+        ptr_ = dynamic_cast<T*>(rhs.Get());
         if (ptr_)
             ptr_->AddRef();
     }
@@ -137,7 +137,7 @@ public:
     /// Check if the pointer is not null
     bool NotNull() const { return ptr_ != 0; }
     /// Return the raw pointer
-    T* RawPtr() const { return ptr_; }
+    T* Get() const { return ptr_; }
     /// Return the object's reference count, or 0 if the pointer is null
     unsigned Refs() const { return ptr_ ? ptr_->Refs() : 0; }
     /// Return the object's weak reference count, or 0 if the pointer is null
@@ -194,7 +194,7 @@ public:
     
     /// Construct from a shared pointer
     WeakPtr(const SharedPtr<T>& rhs) :
-        ptr_(rhs.RawPtr()),
+        ptr_(rhs.Get()),
         refCount_(rhs.RefCountPtr())
     {
         if (refCount_)
@@ -228,12 +228,12 @@ public:
     /// Assign from a shared pointer
     WeakPtr<T>& operator = (const SharedPtr<T>& rhs)
     {
-        if (ptr_ == rhs.RawPtr() && refCount_ == rhs.RefCountPtr())
+        if (ptr_ == rhs.Get() && refCount_ == rhs.RefCountPtr())
             return *this;
         
         Release();
         
-        ptr_ = rhs.RawPtr();
+        ptr_ = rhs.Get();
         refCount_ = rhs.RefCountPtr();
         if (refCount_)
             ++(refCount_->weakRefs_);
@@ -276,7 +276,7 @@ public:
     }
     
     /// Convert to a shared pointer. If expired, return a null shared pointer
-    SharedPtr<T> ToShared() const
+    SharedPtr<T> Lock() const
     {
         if (Expired())
             return SharedPtr<T>();
@@ -285,7 +285,7 @@ public:
     }
     
     /// Return raw pointer. If expired, return null
-    T* RawPtr() const
+    T* Get() const
     {
         if (Expired())
             return 0;
@@ -296,7 +296,7 @@ public:
     /// Point to the object
     T* operator -> () const
     {
-        T* rawPtr = RawPtr();
+        T* rawPtr = Get();
         assert(rawPtr);
         return rawPtr;
     }
@@ -304,7 +304,7 @@ public:
     /// Dereference the object
     T& operator * () const
     {
-        T* rawPtr = RawPtr();
+        T* rawPtr = Get();
         assert(rawPtr);
         return *rawPtr;
     }
@@ -312,7 +312,7 @@ public:
     /// Subscript the object if applicable
     T& operator [] (const int index)
     {
-        T* rawPtr = RawPtr();
+        T* rawPtr = Get();
         assert(rawPtr);
         return (*rawPtr)[index];
     }
@@ -326,7 +326,7 @@ public:
     /// Return true if points to an object which is not expired
     operator bool () const { return !Expired(); }
     /// Convert to a raw pointer, null if the object is expired
-    operator T* () const { return RawPtr(); }
+    operator T* () const { return Get(); }
     
     /// Reset to null and release the weak reference
     void Reset()
@@ -339,7 +339,7 @@ public:
     {
         Release();
         
-        ptr_ = static_cast<T*>(rhs.RawPtr());
+        ptr_ = static_cast<T*>(rhs.Get());
         refCount_ = rhs.refCount_;
         if (refCount_)
             ++(refCount_->weakRefs_);
@@ -350,7 +350,7 @@ public:
     {
         Release();
         
-        ptr_ = dynamic_cast<T*>(rhs.RawPtr());
+        ptr_ = dynamic_cast<T*>(rhs.Get());
         if (ptr_)
         {
             refCount_ = rhs.refCount_;

+ 14 - 10
Engine/Container/RefCounted.cpp

@@ -23,6 +23,8 @@
 
 #include "RefCounted.h"
 
+#include <cassert>
+
 RefCounted::RefCounted() :
     refCount_(new RefCount())
 {
@@ -32,16 +34,16 @@ RefCounted::RefCounted() :
 
 RefCounted::~RefCounted()
 {
-    if (refCount_)
-    {
-        // Mark object as expired, release the self weak ref and delete the refcount if no other weak refs exist
-        refCount_->expired_ = true;
-        --(refCount_->weakRefs_);
-        if (!refCount_->weakRefs_)
-            delete refCount_;
-        
-        refCount_ = 0;
-    }
+    assert(refCount_);
+    assert(refCount_->refs_ == 0);
+    
+    // Mark object as expired, release the self weak ref and delete the refcount if no other weak refs exist
+    refCount_->expired_ = true;
+    --(refCount_->weakRefs_);
+    if (!refCount_->weakRefs_)
+        delete refCount_;
+    
+    refCount_ = 0;
 }
 
 void RefCounted::AddRef()
@@ -51,6 +53,8 @@ void RefCounted::AddRef()
 
 void RefCounted::ReleaseRef()
 {
+    assert(refCount_->refs_ > 0);
+    
     --(refCount_->refs_);
     if (!refCount_->refs_)
         delete this;

+ 1 - 0
Engine/Core/Object.cpp

@@ -29,6 +29,7 @@
 Object::Object(Context* context) :
     context_(context)
 {
+    assert(context_);
 }
 
 Object::~Object()

+ 5 - 0
Engine/Core/Object.h

@@ -114,6 +114,7 @@ public:
     ObjectFactory(Context* context) :
         context_(context)
     {
+        assert(context_);
     }
     
     /// Create an object. Implemented in templated subclasses
@@ -163,6 +164,7 @@ public:
         receiver_(receiver),
         userData_(0)
     {
+        assert(receiver_);
     }
     
     /// Construct with specified receiver and userdata
@@ -170,6 +172,7 @@ public:
         receiver_(receiver),
         userData_(userData)
     {
+        assert(receiver_);
     }
     
     /// Destruct
@@ -201,6 +204,7 @@ public:
         EventHandler(receiver),
         function_(function)
     {
+        assert(function_);
     }
     
     /// Construct with receiver and function pointers and userdata
@@ -208,6 +212,7 @@ public:
         EventHandler(receiver, userData),
         function_(function)
     {
+        assert(function_);
     }
     
     /// Invoke event handler function

+ 2 - 2
Engine/Engine/APITemplates.h

@@ -448,7 +448,7 @@ static Node* NodeGetChild(unsigned index, Node* ptr)
         return 0;
     }
     else
-        return children[index].RawPtr();
+        return children[index].Get();
 }
 
 static CScriptArray* NodeGetChildrenWithScript(bool recursive, Node* ptr)
@@ -472,7 +472,7 @@ static CScriptArray* NodeGetChildrenWithClassName(const String& className, bool
         {
             if ((*j)->GetType() == ScriptInstance::GetTypeStatic())
             {
-                ScriptInstance* instance = static_cast<ScriptInstance*>(j->RawPtr());
+                ScriptInstance* instance = static_cast<ScriptInstance*>(j->Get());
                 if (instance->GetClassName() == className)
                     ret.Push(node);
             }

+ 1 - 1
Engine/Engine/GraphicsAPI.cpp

@@ -257,7 +257,7 @@ static Material* MaterialClone(const String& cloneName, Material* ptr)
     // The shared pointer will go out of scope, so have to increment the reference count
     // (here an auto handle can not be used)
     clonedMaterial->AddRef();
-    return clonedMaterial.RawPtr();
+    return clonedMaterial.Get();
 }
 
 static void RegisterMaterial(asIScriptEngine* engine)

+ 1 - 1
Engine/Engine/ResourceAPI.cpp

@@ -45,7 +45,7 @@ static File* ResourceCacheGetFile(const String& name, ResourceCache* ptr)
     // (here an auto handle can not be used)
     if (file)
         file->AddRef();
-    return file.RawPtr();
+    return file.Get();
 }
 
 static void ResourceCacheReleaseResource(const String& type, const String& name, bool force, ResourceCache* ptr)

+ 3 - 3
Engine/Engine/ScriptAPI.cpp

@@ -54,7 +54,7 @@ static asIScriptObject* NodeCreateScriptObjectWithFile(ScriptFile* file, const S
     {
         if ((*i)->GetType() == ScriptInstance::GetTypeStatic())
         {
-            ScriptInstance* instance = static_cast<ScriptInstance*>(i->RawPtr());
+            ScriptInstance* instance = static_cast<ScriptInstance*>(i->Get());
             asIScriptObject* object = instance->GetScriptObject();
             if (!object)
             {
@@ -91,7 +91,7 @@ asIScriptObject* NodeGetScriptObject(Node* ptr)
     {
         if ((*i)->GetType() == ScriptInstance::GetTypeStatic())
         {
-            ScriptInstance* instance = static_cast<ScriptInstance*>(i->RawPtr());
+            ScriptInstance* instance = static_cast<ScriptInstance*>(i->Get());
             asIScriptObject* object = instance->GetScriptObject();
             if (object)
                 return object;
@@ -108,7 +108,7 @@ asIScriptObject* NodeGetNamedScriptObject(const String& className, Node* ptr)
     {
         if ((*i)->GetType() == ScriptInstance::GetTypeStatic())
         {
-            ScriptInstance* instance = static_cast<ScriptInstance*>(i->RawPtr());
+            ScriptInstance* instance = static_cast<ScriptInstance*>(i->Get());
             if (instance->GetClassName() == className)
             {
                 asIScriptObject* object = instance->GetScriptObject();

+ 2 - 2
Engine/Engine/UIAPI.cpp

@@ -418,7 +418,7 @@ static UIElement* UILoadLayout(XMLFile* file, UI* ptr)
     SharedPtr<UIElement> root = ptr->LoadLayout(file);
     if (root)
         root->AddRef();
-    return root.RawPtr();
+    return root.Get();
 }
 
 static UIElement* UILoadLayoutWithStyle(XMLFile* file, XMLFile* styleFile, UI* ptr)
@@ -426,7 +426,7 @@ static UIElement* UILoadLayoutWithStyle(XMLFile* file, XMLFile* styleFile, UI* p
     SharedPtr<UIElement> root = ptr->LoadLayout(file, styleFile);
     if (root)
         root->AddRef();
-    return root.RawPtr();
+    return root.Get();
 }
 
 static void RegisterUI(asIScriptEngine* engine)

+ 1 - 1
Engine/Graphics/AnimatedModel.cpp

@@ -529,7 +529,7 @@ AnimationState* AnimatedModel::GetAnimationState(StringHash animationNameHash) c
 
 AnimationState* AnimatedModel::GetAnimationState(unsigned index) const
 {
-    return index < animationStates_.Size() ? animationStates_[index].RawPtr() : 0;
+    return index < animationStates_.Size() ? animationStates_[index].Get() : 0;
 }
 
 void AnimatedModel::SetSkeleton(const Skeleton& skeleton, bool createBones)

+ 1 - 1
Engine/Graphics/Direct3D9/D3D9IndexBuffer.cpp

@@ -162,7 +162,7 @@ void* IndexBuffer::Lock(unsigned start, unsigned count, LockMode mode)
         }
     }
     else
-        hwData = fallbackData_.RawPtr() + start * indexSize_;
+        hwData = fallbackData_.Get() + start * indexSize_;
     
     locked_ = true;
     return hwData;

+ 1 - 1
Engine/Graphics/Direct3D9/D3D9Shader.cpp

@@ -143,7 +143,7 @@ bool Shader::Load(Deserializer& source)
         if (dataSize)
         {
             SharedArrayPtr<unsigned char> byteCode(new unsigned char[dataSize]);
-            source.Read(byteCode.RawPtr(), dataSize);
+            source.Read(byteCode.Get(), dataSize);
             variation->SetByteCode(byteCode);
         }
         

+ 2 - 2
Engine/Graphics/Direct3D9/D3D9ShaderVariation.cpp

@@ -56,14 +56,14 @@ bool ShaderVariation::Create()
     if (shaderType_ == VS)
     {
         if (!device || FAILED(device->CreateVertexShader(
-            (const DWORD*)byteCode_.RawPtr(),
+            (const DWORD*)byteCode_.Get(),
             (IDirect3DVertexShader9**)&object_)))
             failed_ = true;
     }
     else
     {
         if (!device || FAILED(device->CreatePixelShader(
-            (const DWORD*)byteCode_.RawPtr(),
+            (const DWORD*)byteCode_.Get(),
             (IDirect3DPixelShader9**)&object_)))
             failed_ = true;
     }

+ 2 - 2
Engine/Graphics/Direct3D9/D3D9VertexBuffer.cpp

@@ -226,7 +226,7 @@ void* VertexBuffer::Lock(unsigned start, unsigned count, LockMode mode)
         }
     }
     else
-        hwData = fallbackData_.RawPtr() + start * vertexSize_;
+        hwData = fallbackData_.Get() + start * vertexSize_;
     
     locked_ = true;
     return hwData;
@@ -258,7 +258,7 @@ void VertexBuffer::ResetMorphRange(void* lockedMorphRange)
     if (!lockedMorphRange || !morphRangeResetData_)
         return;
     
-    memcpy(lockedMorphRange, morphRangeResetData_.RawPtr(), morphRangeCount_ * vertexSize_);
+    memcpy(lockedMorphRange, morphRangeResetData_.Get(), morphRangeCount_ * vertexSize_);
 }
 
 void VertexBuffer::ClearDataLost()

+ 3 - 3
Engine/Graphics/Geometry.cpp

@@ -198,7 +198,7 @@ void Geometry::GetRawData(const unsigned char*& vertexData, unsigned& vertexSize
 {
     if (rawVertexData_)
     {
-        vertexData = rawVertexData_.RawPtr();
+        vertexData = rawVertexData_.Get();
         vertexSize = 3 * sizeof(float);
     }
     else
@@ -209,7 +209,7 @@ void Geometry::GetRawData(const unsigned char*& vertexData, unsigned& vertexSize
     
     if (rawIndexData_ && indexBuffer_)
     {
-        indexData = rawIndexData_.RawPtr();
+        indexData = rawIndexData_.Get();
         indexSize = indexBuffer_->GetIndexSize();
     }
     else
@@ -224,7 +224,7 @@ float Geometry::GetDistance(const Ray& ray)
     if (!rawIndexData_ || !rawVertexData_ || !indexBuffer_)
         return M_INFINITY;
     
-    return ray.Distance(rawVertexData_.RawPtr(), 3 * sizeof(float), rawIndexData_.RawPtr(), indexBuffer_->GetIndexSize(), indexStart_, indexCount_);
+    return ray.Distance(rawVertexData_.Get(), 3 * sizeof(float), rawIndexData_.Get(), indexBuffer_->GetIndexSize(), indexStart_, indexCount_);
 }
 
 void Geometry::GetPositionBufferIndex()

+ 4 - 4
Engine/Graphics/Model.cpp

@@ -119,13 +119,13 @@ bool Model::Load(Deserializer& source)
             if (morphCount)
             {
                 SharedArrayPtr<unsigned char> morphResetData(new unsigned char[morphCount * vertexSize]);
-                memcpy(morphResetData.RawPtr(), &data[morphStart * vertexSize], morphCount * vertexSize);
+                memcpy(morphResetData.Get(), &data[morphStart * vertexSize], morphCount * vertexSize);
                 buffer->SetMorphRangeResetData(morphResetData);
             }
             
             // Copy the raw position data for CPU-side operations
             SharedArrayPtr<unsigned char> rawVertexData(new unsigned char[3 * sizeof(float) * vertexCount]);
-            float* rawDest = (float*)rawVertexData.RawPtr();
+            float* rawDest = (float*)rawVertexData.Get();
             for (unsigned i = 0; i < vertexCount; ++i)
             {
                 float* rawSrc = (float*)&data[i * vertexSize];
@@ -160,7 +160,7 @@ bool Model::Load(Deserializer& source)
             
             // Copy the raw index data for CPU-side operations
             SharedArrayPtr<unsigned char> rawIndexData(new unsigned char[indexSize * indexCount]);
-            memcpy(rawIndexData.RawPtr(), data, indexSize * indexCount);
+            memcpy(rawIndexData.Get(), data, indexSize * indexCount);
             rawIndexDatas.Push(rawIndexData);
             
             buffer->Unlock();
@@ -362,7 +362,7 @@ bool Model::Save(Serializer& dest)
             if (j->second_.elementMask_ & MASK_TANGENT)
                 vertexSize += sizeof(Vector3);
             
-            dest.Write(j->second_.morphData_.RawPtr(), vertexSize * j->second_.vertexCount_);
+            dest.Write(j->second_.morphData_.Get(), vertexSize * j->second_.vertexCount_);
         }
     }
     

+ 5 - 5
Engine/Graphics/OcclusionBuffer.cpp

@@ -79,7 +79,7 @@ bool OcclusionBuffer::SetSize(int width, int height)
     height_ = height;
     // Reserve extra memory in case 3D clipping is not exact
     fullBuffer_ = new int[width * (height + 2)];
-    buffer_ = fullBuffer_.RawPtr() + 1 * width;
+    buffer_ = fullBuffer_.Get() + 1 * width;
     mipBuffers_.Clear();
     
     // Build buffers for mip levels
@@ -220,7 +220,7 @@ void OcclusionBuffer::BuildDepthHierarchy()
         for (int y = 0; y < height; ++y)
         {
             int* src = buffer_ + (y * 2) * width_;
-            DepthValue* dest = mipBuffers_[0].RawPtr() + y * width;
+            DepthValue* dest = mipBuffers_[0].Get() + y * width;
             DepthValue* end = dest + width;
             
             if (y * 2 + 1 < height_)
@@ -264,8 +264,8 @@ void OcclusionBuffer::BuildDepthHierarchy()
         
         for (int y = 0; y < height; ++y)
         {
-            DepthValue* src = mipBuffers_[i - 1].RawPtr() + (y * 2) * prevWidth;
-            DepthValue* dest = mipBuffers_[i].RawPtr() + y * width;
+            DepthValue* src = mipBuffers_[i - 1].Get() + (y * 2) * prevWidth;
+            DepthValue* dest = mipBuffers_[i].Get() + y * width;
             DepthValue* end = dest + width;
             
             if (y * 2 + 1 < prevHeight)
@@ -388,7 +388,7 @@ bool OcclusionBuffer::IsVisible(const BoundingBox& worldSpaceBox) const
             int left = rect.left_ >> shift;
             int right = rect.right_ >> shift;
             
-            DepthValue* buffer = mipBuffers_[i].RawPtr();
+            DepthValue* buffer = mipBuffers_[i].Get();
             DepthValue* row = buffer + (rect.top_ >> shift) * width;
             DepthValue* endRow = buffer + (rect.bottom_ >> shift) * width;
             bool allOccluded = true;

+ 5 - 5
Engine/Graphics/OpenGL/OGLIndexBuffer.cpp

@@ -57,7 +57,7 @@ void IndexBuffer::OnDeviceLost()
         if (hwData)
         {
             saveData_ = new unsigned char[indexCount_ * indexSize_];
-            memcpy(saveData_.RawPtr(), hwData, indexCount_ * indexSize_);
+            memcpy(saveData_.Get(), hwData, indexCount_ * indexSize_);
         }
         Unlock();
         Release();
@@ -71,7 +71,7 @@ void IndexBuffer::OnDeviceReset()
         Create();
         if (saveData_)
         {
-            SetData(saveData_.RawPtr());
+            SetData(saveData_.Get());
             saveData_.Reset();
         }
     }
@@ -122,7 +122,7 @@ bool IndexBuffer::SetData(const void* data)
     }
     else if (fallbackData_)
     {
-        memcpy(fallbackData_.RawPtr(), data, indexCount_ * indexSize_);
+        memcpy(fallbackData_.Get(), data, indexCount_ * indexSize_);
         return true;
     }
     
@@ -154,7 +154,7 @@ bool IndexBuffer::SetDataRange(const void* data, unsigned start, unsigned count)
     }
     else if (fallbackData_)
     {
-        memcpy(fallbackData_.RawPtr() + start * indexSize_, data, indexCount_ * indexSize_);
+        memcpy(fallbackData_.Get() + start * indexSize_, data, indexCount_ * indexSize_);
         return true;
     }
     
@@ -198,7 +198,7 @@ void* IndexBuffer::Lock(unsigned start, unsigned count, LockMode mode)
         hwData = (unsigned char*)hwData + start * indexSize_;
     }
     else
-        hwData = fallbackData_.RawPtr() + start * indexSize_;
+        hwData = fallbackData_.Get() + start * indexSize_;
     
     locked_ = true;
     return hwData;

+ 1 - 1
Engine/Graphics/OpenGL/OGLShaderVariation.cpp

@@ -90,7 +90,7 @@ bool ShaderVariation::Create()
         shaderCode += "#define " + defines_[i] + "\n";
     if (!defines_.Empty())
         shaderCode += "\n";
-    shaderCode += String(sourceCode_.RawPtr(), sourceCodeLength_);
+    shaderCode += String(sourceCode_.Get(), sourceCodeLength_);
     
     const char* shaderCStr = shaderCode.CString();
     glShaderSource(object_, 1, &shaderCStr, 0);

+ 2 - 2
Engine/Graphics/OpenGL/OGLTexture2D.cpp

@@ -86,7 +86,7 @@ void Texture2D::OnDeviceLost()
             int levelWidth = GetLevelWidth(i);
             int levelHeight = GetLevelHeight(i);
             SharedArrayPtr<unsigned char> savedLevel(new unsigned char[GetDataSize(levelWidth, levelHeight)]);
-            GetData(i, savedLevel.RawPtr());
+            GetData(i, savedLevel.Get());
             savedLevels_.Push(savedLevel);
         }
     }
@@ -109,7 +109,7 @@ void Texture2D::OnDeviceReset()
             {
                 int levelWidth = GetLevelWidth(i);
                 int levelHeight = GetLevelHeight(i);
-                SetData(i, 0, 0, levelWidth, levelHeight, savedLevels_[i].RawPtr());
+                SetData(i, 0, 0, levelWidth, levelHeight, savedLevels_[i].Get());
             }
             savedLevels_.Clear();
         }

+ 2 - 2
Engine/Graphics/OpenGL/OGLTextureCube.cpp

@@ -74,7 +74,7 @@ void TextureCube::OnDeviceLost()
                 int levelWidth = GetLevelWidth(i);
                 int levelHeight = GetLevelHeight(i);
                 SharedArrayPtr<unsigned char> savedLevel(new unsigned char[GetDataSize(levelWidth, levelHeight)]);
-                GetData((CubeMapFace)face, i, savedLevel.RawPtr());
+                GetData((CubeMapFace)face, i, savedLevel.Get());
                 savedLevels_.Push(savedLevel);
             }
         }
@@ -98,7 +98,7 @@ void TextureCube::OnDeviceReset()
                 unsigned level = i / 6;
                 int levelWidth = GetLevelWidth(level);
                 int levelHeight = GetLevelHeight(level);
-                SetData(face, level, 0, 0, levelWidth, levelHeight, savedLevels_[i].RawPtr());
+                SetData(face, level, 0, 0, levelWidth, levelHeight, savedLevels_[i].Get());
             }
             savedLevels_.Clear();
         }

+ 6 - 6
Engine/Graphics/OpenGL/OGLVertexBuffer.cpp

@@ -144,7 +144,7 @@ void VertexBuffer::OnDeviceLost()
         if (hwData)
         {
             saveData_ = new unsigned char[vertexCount_ * vertexSize_];
-            memcpy(saveData_.RawPtr(), hwData, vertexCount_ * vertexSize_);
+            memcpy(saveData_.Get(), hwData, vertexCount_ * vertexSize_);
         }
         Unlock();
         Release();
@@ -158,7 +158,7 @@ void VertexBuffer::OnDeviceReset()
         Create();
         if (saveData_)
         {
-            SetData(saveData_.RawPtr());
+            SetData(saveData_.Get());
             saveData_.Reset();
         }
     }
@@ -219,7 +219,7 @@ bool VertexBuffer::SetData(const void* data)
     }
     else if (fallbackData_)
     {
-        memcpy(fallbackData_.RawPtr(), data, vertexCount_ * vertexSize_);
+        memcpy(fallbackData_.Get(), data, vertexCount_ * vertexSize_);
         return true;
     }
     
@@ -251,7 +251,7 @@ bool VertexBuffer::SetDataRange(const void* data, unsigned start, unsigned count
     }
     else if (fallbackData_)
     {
-        memcpy(fallbackData_.RawPtr() + start * vertexSize_, data, vertexCount_ * vertexSize_);
+        memcpy(fallbackData_.Get() + start * vertexSize_, data, vertexCount_ * vertexSize_);
         return true;
     }
     
@@ -313,7 +313,7 @@ void* VertexBuffer::Lock(unsigned start, unsigned count, LockMode mode)
         hwData = (unsigned char*)hwData + start * vertexSize_;
     }
     else
-        hwData = fallbackData_.RawPtr() + start * vertexSize_;
+        hwData = fallbackData_.Get() + start * vertexSize_;
     
     locked_ = true;
     return hwData;
@@ -348,7 +348,7 @@ void VertexBuffer::ResetMorphRange(void* lockedMorphRange)
     if (!lockedMorphRange || !morphRangeResetData_)
         return;
     
-    memcpy(lockedMorphRange, morphRangeResetData_.RawPtr(), morphRangeCount_ * vertexSize_);
+    memcpy(lockedMorphRange, morphRangeResetData_.Get(), morphRangeCount_ * vertexSize_);
 }
 
 void VertexBuffer::ClearDataLost()

+ 2 - 2
Engine/IO/FileSystem.cpp

@@ -219,8 +219,8 @@ bool FileSystem::Copy(const String& srcFileName, const String& destFileName)
     unsigned fileSize = srcFile->GetSize();
     SharedArrayPtr<unsigned char> buffer(new unsigned char[fileSize]);
     
-    unsigned bytesRead = srcFile->Read(buffer.RawPtr(), fileSize);
-    unsigned bytesWritten = destFile->Write(buffer.RawPtr(), fileSize);
+    unsigned bytesRead = srcFile->Read(buffer.Get(), fileSize);
+    unsigned bytesWritten = destFile->Write(buffer.Get(), fileSize);
     return bytesRead == fileSize && bytesWritten == fileSize;
 }
 

+ 7 - 7
Engine/Physics/CollisionShape.cpp

@@ -177,7 +177,7 @@ TriangleMeshData::TriangleMeshData(Model* model, bool makeConvexHull, float thic
         StanHull::HullDesc desc;
         desc.SetHullFlag(StanHull::QF_TRIANGLES);
         desc.mVcount = originalVertexCount;
-        desc.mVertices = (float*)originalVertices.RawPtr();
+        desc.mVertices = (float*)originalVertices.Get();
         desc.mVertexStride = 3 * sizeof(float);
         desc.mSkinWidth = thickness;
         
@@ -190,19 +190,19 @@ TriangleMeshData::TriangleMeshData(Model* model, bool makeConvexHull, float thic
         
         // Copy vertex data
         vertexData_ = new Vector3[vertexCount];
-        memcpy(vertexData_.RawPtr(), result.mOutputVertices, vertexCount * sizeof(Vector3));
+        memcpy(vertexData_.Get(), result.mOutputVertices, vertexCount * sizeof(Vector3));
         
         // Copy index data
         indexData_ = new unsigned[indexCount];
-        memcpy(indexData_.RawPtr(), result.mIndices, indexCount * sizeof(unsigned));
+        memcpy(indexData_.Get(), result.mIndices, indexCount * sizeof(unsigned));
         
         lib.ReleaseResult(result);
     }
     
     triMesh_ = dGeomTriMeshDataCreate();
     
-    dGeomTriMeshDataBuildSingle(triMesh_, vertexData_.RawPtr(), sizeof(Vector3), vertexCount,
-        indexData_.RawPtr(), indexCount, 3 * sizeof(unsigned));
+    dGeomTriMeshDataBuildSingle(triMesh_, vertexData_.Get(), sizeof(Vector3), vertexCount,
+        indexData_.Get(), indexCount, 3 * sizeof(unsigned));
     
     indexCount_ = indexCount;
 }
@@ -281,7 +281,7 @@ HeightfieldData::HeightfieldData(Model* model, IntVector2 numPoints, float thick
     
     heightfield_ = dGeomHeightfieldDataCreate();
     
-    dGeomHeightfieldDataBuildSingle(heightfield_, heightData_.RawPtr(), 0, (box.max_.x_ - box.min_.x_) * scale.x_,
+    dGeomHeightfieldDataBuildSingle(heightfield_, heightData_.Get(), 0, (box.max_.x_ - box.min_.x_) * scale.x_,
         (box.max_.z_ - box.min_.z_) * scale.z_, numPoints.x_, numPoints.y_, 1.0f, 0.0f, thickness, 0);
     dGeomHeightfieldDataSetBounds(heightfield_, box.min_.y_ * scale.y_, box.max_.y_ * scale.y_);
 }
@@ -713,7 +713,7 @@ void CollisionShape::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
         
     case dTriMeshClass:
         {
-            TriangleMeshData* data = static_cast<TriangleMeshData*>(geometryData_.RawPtr());
+            TriangleMeshData* data = static_cast<TriangleMeshData*>(geometryData_.Get());
             if (!data)
                 return;
             

+ 9 - 9
Engine/Resource/Image.cpp

@@ -235,7 +235,7 @@ bool Image::Load(Deserializer& source)
         if (!numCompressedLevels_)
             numCompressedLevels_ = 1;
         SetMemoryUse(dataSize);
-        source.Read(data_.RawPtr(), dataSize);
+        source.Read(data_.Get(), dataSize);
     }
     
     return true;
@@ -261,7 +261,7 @@ void Image::SetSize(int width, int height, unsigned components)
 
 void Image::SetData(const unsigned char* pixelData)
 {
-    memcpy(data_.RawPtr(), pixelData, width_ * height_ * components_);
+    memcpy(data_.Get(), pixelData, width_ * height_ * components_);
 }
 
 bool Image::SaveBMP(const String& fileName)
@@ -280,7 +280,7 @@ bool Image::SaveBMP(const String& fileName)
     }
     
     if (data_)
-        return stbi_write_bmp(fileName.CString(), width_, height_, components_, data_.RawPtr()) != 0;
+        return stbi_write_bmp(fileName.CString(), width_, height_, components_, data_.Get()) != 0;
     else
         return false;
 }
@@ -301,7 +301,7 @@ bool Image::SaveTGA(const String& fileName)
     }
     
     if (data_)
-        return stbi_write_tga(fileName.CString(), width_, height_, components_, data_.RawPtr()) != 0;
+        return stbi_write_tga(fileName.CString(), width_, height_, components_, data_.Get()) != 0;
     else
         return false;
 }
@@ -311,8 +311,8 @@ unsigned char* Image::GetImageData(Deserializer& source, int& width, int& height
     unsigned dataSize = source.GetSize();
     
     SharedArrayPtr<unsigned char> buffer(new unsigned char[dataSize]);
-    source.Read(buffer.RawPtr(), dataSize);
-    return stbi_load_from_memory(buffer.RawPtr(), dataSize, &width, &height, (int *)&components, 0);
+    source.Read(buffer.Get(), dataSize);
+    return stbi_load_from_memory(buffer.Get(), dataSize, &width, &height, (int *)&components, 0);
 }
 
 void Image::FreeImageData(unsigned char* pixelData)
@@ -347,8 +347,8 @@ SharedPtr<Image> Image::GetNextLevel() const
     SharedPtr<Image> mipImage(new Image(context_));
     mipImage->SetSize(widthOut, heightOut, components_);
     
-    const unsigned char* pixelDataIn = data_.RawPtr();
-    unsigned char* pixelDataOut = mipImage->data_.RawPtr();
+    const unsigned char* pixelDataIn = data_.Get();
+    unsigned char* pixelDataOut = mipImage->data_.Get();
     
     // 1D case
     if (height_ == 1 || width_ == 1)
@@ -494,7 +494,7 @@ CompressedLevel Image::GetCompressedLevel(unsigned index) const
         
         level.rowSize_ = ((level.width_ + 3) / 4) * level.blockSize_;
         level.rows_ = ((level.height_ + 3) / 4);
-        level.data_ = data_.RawPtr() + offset;
+        level.data_ = data_.Get() + offset;
         level.dataSize_ = level.rows_ * level.rowSize_;
         
         if (offset + level.dataSize_ > GetMemoryUse())

+ 2 - 2
Engine/Resource/ResourceCache.cpp

@@ -285,7 +285,7 @@ bool ResourceCache::ReloadResource(Resource* resource)
     bool success = false;
     SharedPtr<File> file = GetFile(resource->GetName());
     if (file)
-        success = resource->Load(*(file.RawPtr()));
+        success = resource->Load(*(file.Get()));
     
     if (success)
     {
@@ -377,7 +377,7 @@ Resource* ResourceCache::GetResource(ShortStringHash type, StringHash nameHash)
     
     LOGDEBUG("Loading resource " + name);
     resource->SetName(file->GetName());
-    if (!resource->Load(*(file.RawPtr())))
+    if (!resource->Load(*(file.Get())))
         return 0;
     
     // Store to cache

+ 2 - 2
Engine/Resource/XMLFile.cpp

@@ -58,13 +58,13 @@ bool XMLFile::Load(Deserializer& source)
         return false;
     
     SharedArrayPtr<char> buffer(new char[dataSize + 1]);
-    if (source.Read(buffer.RawPtr(), dataSize) != dataSize)
+    if (source.Read(buffer.Get(), dataSize) != dataSize)
         return false;
     
     buffer[dataSize] = 0;
     
     document_->Clear();
-    document_->Parse(buffer.RawPtr());
+    document_->Parse(buffer.Get());
     if (document_->Error())
     {
         document_->ClearError();

+ 3 - 3
Engine/Scene/Node.cpp

@@ -463,7 +463,7 @@ void Node::RemoveChild(Node* node)
     
     for (Vector<SharedPtr<Node> >::Iterator i = children_.Begin(); i != children_.End(); ++i)
     {
-        if (i->RawPtr() == node)
+        if (i->Get() == node)
         {
             RemoveChild(i);
             return;
@@ -633,7 +633,7 @@ void Node::GetChildrenWithComponent(PODVector<Node*>& dest, ShortStringHash type
 
 Node* Node::GetChild(unsigned index) const
 {
-    return index < children_.Size() ? children_[index].RawPtr() : 0;
+    return index < children_.Size() ? children_[index].Get() : 0;
 }
 
 Node* Node::GetChild(const String& name, bool recursive) const
@@ -693,7 +693,7 @@ bool Node::HasComponent(ShortStringHash type) const
 
 Component* Node::GetComponent(unsigned index) const
 {
-    return index < components_.Size() ? components_[index].RawPtr() : 0;
+    return index < components_.Size() ? components_[index].Get() : 0;
 }
 
 Component* Node::GetComponent(ShortStringHash type, unsigned index) const

+ 8 - 0
Engine/Scene/Serializable.h

@@ -105,11 +105,14 @@ public:
         getFunction_(getFunction),
         setFunction_(setFunction)
     {
+        assert(getFunction_);
+        assert(setFunction_);
     }
     
     /// Invoke getter function
     virtual void Get(Serializable* ptr, Variant& dest)
     {
+        assert(ptr);
         T* classPtr = static_cast<T*>(ptr);
         dest = (classPtr->*getFunction_)();
     }
@@ -117,6 +120,7 @@ public:
     /// Invoke setter function
     virtual void Set(Serializable* ptr, const Variant& value)
     {
+        assert(ptr);
         T* classPtr = static_cast<T*>(ptr);
         (classPtr->*setFunction_)(value.Get<U>());
     }
@@ -139,11 +143,14 @@ public:
         getFunction_(getFunction),
         setFunction_(setFunction)
     {
+        assert(getFunction_);
+        assert(setFunction_);
     }
     
     /// Invoke getter function
     virtual void Get(Serializable* ptr, Variant& dest)
     {
+        assert(ptr);
         T* classPtr = static_cast<T*>(ptr);
         dest = (classPtr->*getFunction_)();
     }
@@ -151,6 +158,7 @@ public:
     /// Invoke setter function
     virtual void Set(Serializable* ptr, const Variant& value)
     {
+        assert(ptr);
         T* classPtr = static_cast<T*>(ptr);
         (classPtr->*setFunction_)(value.Get<U>());
     }

+ 2 - 2
Engine/Script/ScriptFile.cpp

@@ -336,7 +336,7 @@ bool ScriptFile::AddScriptSection(asIScriptEngine* engine, Deserializer& source)
     
     unsigned dataSize = source.GetSize();
     SharedArrayPtr<char> buffer(new char[dataSize]);
-    source.Read((void*)buffer.RawPtr(), dataSize);
+    source.Read((void*)buffer.Get(), dataSize);
     
     // Pre-parse for includes
     // Adapted from Angelscript's scriptbuilder add-on
@@ -437,7 +437,7 @@ bool ScriptFile::AddScriptSection(asIScriptEngine* engine, Deserializer& source)
     }
     
     // Then add this section
-    if (scriptModule_->AddScriptSection(source.GetName().CString(), (const char*)buffer.RawPtr(), dataSize) < 0)
+    if (scriptModule_->AddScriptSection(source.GetName().CString(), (const char*)buffer.Get(), dataSize) < 0)
     {
         LOGERROR("Failed to add script section " + source.GetName());
         return false;

+ 6 - 6
Engine/UI/UI.cpp

@@ -194,8 +194,8 @@ void UI::Update(float timeStep)
                 using namespace DragDropTest;
                 
                 VariantMap eventData;
-                eventData[P_SOURCE] = (void*)dragElement_.RawPtr();
-                eventData[P_TARGET] = (void*)element.RawPtr();
+                eventData[P_SOURCE] = (void*)dragElement_.Get();
+                eventData[P_TARGET] = (void*)element.Get();
                 eventData[P_ACCEPT] = accept;
                 SendEvent(E_DRAGDROPTEST, eventData);
                 accept = eventData[P_ACCEPT].GetBool();
@@ -523,7 +523,7 @@ void UI::GetElementAt(UIElement*& result, UIElement* current, const IntVector2&
     for (PODVector<UIElement*>::ConstIterator i = children.Begin(); i != children.End(); ++i)
     {
         UIElement* element = *i;
-        if (element != cursor_.RawPtr() && element->IsVisible())
+        if (element != cursor_.Get() && element->IsVisible())
         {
             if (element->IsInside(position, true))
             {
@@ -656,7 +656,7 @@ void UI::HandleMouseButtonDown(StringHash eventType, VariantMap& eventData)
         using namespace UIMouseClick;
         
         VariantMap eventData;
-        eventData[UIMouseClick::P_ELEMENT] = (void*)element.RawPtr();
+        eventData[UIMouseClick::P_ELEMENT] = (void*)element.Get();
         eventData[UIMouseClick::P_X] = pos.x_;
         eventData[UIMouseClick::P_Y] = pos.y_;
         eventData[UIMouseClick::P_BUTTON] = button;
@@ -701,8 +701,8 @@ void UI::HandleMouseButtonUp(StringHash eventType, VariantMap& eventData)
                             using namespace DragDropFinish;
                             
                             VariantMap eventData;
-                            eventData[P_SOURCE] = (void*)dragElement_.RawPtr();
-                            eventData[P_TARGET] = (void*)target.RawPtr();
+                            eventData[P_SOURCE] = (void*)dragElement_.Get();
+                            eventData[P_TARGET] = (void*)target.Get();
                             eventData[P_ACCEPT] = accept;
                             SendEvent(E_DRAGDROPFINISH, eventData);
                         }

+ 2 - 1
Tools/GLShaderProcessor/GLShaderProcessor.cpp

@@ -495,7 +495,8 @@ void ProcessVariations(const Shader& baseShader, XMLElement& shaders)
         ErrorExit("Could not open output file " + glslOutFileName);
     for (unsigned i = 0; i < glslCode_.Size(); ++i)
     {
-        outFile.Write(&glslCode_[i][0], glslCode_[i].Length());
+        if (!glslCode_[i].Empty())
+            outFile.Write(&glslCode_[i][0], glslCode_[i].Length());
         outFile.WriteByte(10);
     }
     outFile.Close();

+ 2 - 2
Tools/NormalMapTool/NormalMapTool.cpp

@@ -70,7 +70,7 @@ void Run(const Vector<String>& arguments)
     
     SharedArrayPtr<unsigned char> buffer(new unsigned char[image.GetWidth() * image.GetHeight() * 4]);
     unsigned char* srcData = image.GetData();
-    unsigned char* destData = buffer.RawPtr();
+    unsigned char* destData = buffer.Get();
     
     for (int y = 0; y < image.GetHeight(); ++y)
     {
@@ -91,7 +91,7 @@ void Run(const Vector<String>& arguments)
     }
     
     String tempDestName = arguments[0].Split('.')[0] + ".tga";
-    stbi_write_tga(tempDestName.CString(), image.GetWidth(), image.GetHeight(), 4, buffer.RawPtr());
+    stbi_write_tga(tempDestName.CString(), image.GetWidth(), image.GetHeight(), 4, buffer.Get());
     
     String command = "texconv -f DXT5 -ft DDS -if NONE " + tempDestName;
     int ret = system(command.CString());

+ 2 - 2
Tools/RampGenerator/RampGenerator.cpp

@@ -80,7 +80,7 @@ void Run(const Vector<String>& arguments)
         data[0] = 255;
         data[width - 1] = 0;
         
-        stbi_write_tga(tempDestName.CString(), width, 1, 1, data.RawPtr());
+        stbi_write_tga(tempDestName.CString(), width, 1, 1, data.Get());
     }
     
     if (dimensions == 2)
@@ -113,7 +113,7 @@ void Run(const Vector<String>& arguments)
             data[x * width + (width - 1)] = 0;
         }
         
-        stbi_write_tga(tempDestName.CString(), width, width, 1, data.RawPtr());
+        stbi_write_tga(tempDestName.CString(), width, width, 1, data.Get());
     }
     
     String command = "texconv -f R8G8B8 -ft PNG -if NONE " + tempDestName;