Forráskód Böngészése

Fixed 64bit compile on GCC / OS X.

Lasse Öörni 12 éve
szülő
commit
85415e5cb3

+ 2 - 2
Engine/Audio/SoundSource.cpp

@@ -329,7 +329,7 @@ void SoundSource::SetPlayPositionLockless(signed char* pos)
         pos = end;
     
     position_ = pos;
-    timePosition_ = (float)((int)pos - (int)sound_->GetStart()) / (sound_->GetSampleSize() * sound_->GetFrequency());
+    timePosition_ = ((float)(int)(size_t)(pos - sound_->GetStart())) / (sound_->GetSampleSize() * sound_->GetFrequency());
 }
 
 void SoundSource::Update(float timeStep)
@@ -490,7 +490,7 @@ void SoundSource::Mix(int* dest, unsigned samples, int mixRate, bool stereo, boo
     
     // Update the time position
     if (!sound_->IsCompressed())
-        timePosition_ = (float)((int)position_ - (int)sound_->GetStart()) / (sound_->GetSampleSize() * sound_->GetFrequency());
+        timePosition_ = ((float)(int)(size_t)(position_ - sound_->GetStart())) / (sound_->GetSampleSize() * sound_->GetFrequency());
     else
         timePosition_ += ((float)samples / (float)mixRate) * frequency_ / sound_->GetFrequency();
 }

+ 2 - 2
Engine/Container/ArrayPtr.h

@@ -152,7 +152,7 @@ public:
     /// Return pointer to the RefCount structure.
     RefCount* RefCountPtr() const { return refCount_; }
     /// Return hash value for HashSet & HashMap.
-    unsigned ToHash() const { return ((unsigned)ptr_) / sizeof(T); }
+    unsigned ToHash() const { return ((unsigned)(size_t)ptr_) / sizeof(T); }
     
 private:
     /// Prevent direct assignment from a shared array pointer of different type.
@@ -365,7 +365,7 @@ public:
     /// Return pointer to RefCount structure.
     RefCount* RefCountPtr() const { return refCount_; }
     /// Return hash value for HashSet & HashMap.
-    unsigned ToHash() const { return ((unsigned)ptr_) / sizeof(T); }
+    unsigned ToHash() const { return ((unsigned)(size_t)ptr_) / sizeof(T); }
     
 private:
     /// Prevent direct assignment from a weak array pointer of different type.

+ 4 - 4
Engine/Container/Hash.h

@@ -28,13 +28,13 @@ namespace Urho3D
 /// Pointer hash function.
 template <class T> unsigned MakeHash(T* value)
 {
-    return ((unsigned)value) / sizeof(T);
+    return ((unsigned)(size_t)value) / sizeof(T);
 }
 
 /// Const pointer hash function.
 template <class T> unsigned MakeHash(const T* value)
 {
-    return ((unsigned)value) / sizeof(T);
+    return ((unsigned)(size_t)value) / sizeof(T);
 }
 
 /// Generic hash function.
@@ -46,13 +46,13 @@ template <class T> unsigned MakeHash(const T& value)
 /// Void pointer hash function.
 template<> inline unsigned MakeHash(void* value)
 {
-    return (unsigned)value;
+    return (unsigned)(size_t)value;
 }
 
 /// Const void pointer hash function.
 template<> inline unsigned MakeHash(const void* value)
 {
-    return (unsigned)value;
+    return (unsigned)(size_t)value;
 }
 
 /// Long long hash function.

+ 2 - 2
Engine/Container/Ptr.h

@@ -134,7 +134,7 @@ public:
     /// Return pointer to the RefCount structure.
     RefCount* RefCountPtr() const { return ptr_ ? ptr_->RefCountPtr() : 0; }
     /// Return hash value for HashSet & HashMap.
-    unsigned ToHash() const { return ((unsigned)ptr_) / sizeof(T); }
+    unsigned ToHash() const { return ((unsigned)(size_t)ptr_) / sizeof(T); }
     
 private:
     /// Prevent direct assignment from a shared pointer of another type.
@@ -363,7 +363,7 @@ public:
     /// Return pointer to the RefCount structure.
     RefCount* RefCountPtr() const { return refCount_; }
     /// Return hash value for HashSet & HashMap.
-    unsigned ToHash() const { return ((unsigned)ptr_) / sizeof(T); }
+    unsigned ToHash() const { return ((unsigned)(size_t)ptr_) / sizeof(T); }
     
 private:
     /// Prevent direct assignment from a weak pointer of different type.

+ 1 - 1
Engine/Core/StringUtils.cpp

@@ -346,7 +346,7 @@ Vector4 ToVector4(const char* source, bool allowMissingCoords)
 
 String ToString(void* value)
 {
-    return ToStringHex((int)value);
+    return ToStringHex((unsigned)(size_t)value);
 }
 
 String ToStringHex(unsigned value)

+ 7 - 4
Engine/Graphics/Batch.cpp

@@ -213,7 +213,7 @@ void Batch::Prepare(View* view, bool setModelTransform) const
     }
     
     // Set camera shader parameters
-    unsigned cameraHash = overrideView_ ? (unsigned)camera_ + 4 : (unsigned)camera_;
+    unsigned cameraHash = overrideView_ ? (unsigned)(size_t)camera_ + 4 : (unsigned)(size_t)camera_;
     if (graphics->NeedParameterUpdate(SP_CAMERA, (void*)cameraHash))
     {
         // Calculate camera rotation just once
@@ -301,7 +301,7 @@ void Batch::Prepare(View* view, bool setModelTransform) const
     // Set zone-related shader parameters
     BlendMode blend = graphics->GetBlendMode();
     Zone* fogColorZone = (blend == BLEND_ADD || blend == BLEND_ADDALPHA) ? renderer->GetDefaultZone() : zone_;
-    unsigned zoneHash = (unsigned)zone_ + (unsigned)fogColorZone;
+    unsigned zoneHash = (unsigned)(size_t)zone_ + (unsigned)(size_t)fogColorZone;
     if (zone_ && graphics->NeedParameterUpdate(SP_ZONE, (void*)zoneHash))
     {
         graphics->SetShaderParameter(VSP_AMBIENTSTARTCOLOR, zone_->GetAmbientStartColor());
@@ -719,8 +719,11 @@ void BatchGroup::Draw(View* view) const
 
 unsigned BatchGroupKey::ToHash() const
 {
-    return ((unsigned)zone_) / sizeof(Zone) + ((unsigned)lightQueue_) / sizeof(LightBatchQueue) + ((unsigned)pass_) / sizeof(Pass)
-        + ((unsigned)material_) / sizeof(Material) + ((unsigned)geometry_) / sizeof(Geometry);
+    return ((unsigned)(size_t)zone_) / sizeof(Zone) +
+        ((unsigned)(size_t)lightQueue_) / sizeof(LightBatchQueue) +
+        ((unsigned)(size_t)pass_) / sizeof(Pass) +
+        ((unsigned)(size_t)material_) / sizeof(Material) +
+        ((unsigned)(size_t)geometry_) / sizeof(Geometry);
 }
 
 void BatchQueue::Clear(int maxSortedInstances)

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

@@ -1154,7 +1154,7 @@ void Graphics::SetShaderParameter(StringHash param, const Matrix3x4& matrix)
 
 bool Graphics::NeedParameterUpdate(ShaderParameterGroup group, const void* source)
 {
-    if ((unsigned)shaderParameterSources_[group] == M_MAX_UNSIGNED || shaderParameterSources_[group] != source)
+    if ((unsigned)(size_t)shaderParameterSources_[group] == M_MAX_UNSIGNED || shaderParameterSources_[group] != source)
     {
         shaderParameterSources_[group] = source;
         return true;
@@ -1923,7 +1923,7 @@ void Graphics::FreeScratchBuffer(void* buffer)
         }
     }
     
-    LOGWARNING("Reserved scratch buffer " + ToStringHex((unsigned)buffer) + " not found");
+    LOGWARNING("Reserved scratch buffer " + ToStringHex((unsigned)(size_t)buffer) + " not found");
 }
 
 void Graphics::CleanupScratchBuffers()

+ 1 - 1
Engine/Network/Network.h

@@ -39,7 +39,7 @@ class Scene;
 /// MessageConnection hash function.
 template <class T> unsigned MakeHash(kNet::MessageConnection* value)
 {
-    return ((unsigned)value) >> 9;
+    return ((unsigned)(size_t)value) >> 9;
 }
 
 /// %Network subsystem. Manages client-server communications using the UDP protocol.

+ 1 - 1
Engine/Resource/Image.cpp

@@ -126,7 +126,7 @@ struct DDSurfaceDesc2
     unsigned dwWidth_;
     union
     {
-        long lPitch_;
+        unsigned lPitch_;
         unsigned dwLinearSize_;
     };
     union