From 265b18571c20a6fd6ea0023cd862a22140768fb9 Mon Sep 17 00:00:00 2001 From: badlogic Date: Thu, 24 May 2018 15:30:58 +0200 Subject: [PATCH] Fixed all warnings on MSVC, fixed up usage of int instead of size_t, fixed some signatures. --- spine-c/spine-c-unit-tests/memory/KMemory.cpp | 2 ++ .../teamcity/teamcity_messages.cpp | 2 ++ spine-c/spine-c/include/spine/extension.h | 2 +- spine-c/spine-c/src/spine/Bone.c | 2 +- spine-c/spine-c/src/spine/Json.c | 2 +- spine-c/spine-c/src/spine/SkeletonJson.c | 2 +- .../spine-cpp/include/spine/AnimationState.h | 26 ++++++++-------- .../include/spine/AnimationStateData.h | 4 --- .../include/spine/AttachmentTimeline.h | 8 ++--- spine-cpp/spine-cpp/include/spine/Event.h | 2 +- spine-cpp/spine-cpp/include/spine/HashMap.h | 7 ++++- .../spine-cpp/include/spine/LinkedMesh.h | 4 +-- spine-cpp/spine-cpp/include/spine/MathUtil.h | 8 ++--- .../spine-cpp/include/spine/MeshAttachment.h | 4 +-- .../include/spine/RegionAttachment.h | 2 +- .../spine-cpp/include/spine/SkeletonJson.h | 6 ++-- spine-cpp/spine-cpp/include/spine/Skin.h | 26 ++++++++-------- .../spine-cpp/include/spine/SpineObject.h | 4 +++ spine-cpp/spine-cpp/include/spine/String.h | 3 ++ .../include/spine/VertexAttachment.h | 12 ++++---- spine-cpp/spine-cpp/include/spine/Vertices.h | 2 +- .../spine-cpp/src/spine/AnimationState.cpp | 30 +++++++++---------- .../src/spine/AnimationStateData.cpp | 17 ----------- spine-cpp/spine-cpp/src/spine/Atlas.cpp | 6 ++-- .../src/spine/AtlasAttachmentLoader.cpp | 17 +++++------ .../src/spine/AttachmentTimeline.cpp | 8 ++--- spine-cpp/spine-cpp/src/spine/Event.cpp | 2 +- .../spine-cpp/src/spine/EventTimeline.cpp | 2 +- .../src/spine/IkConstraintTimeline.cpp | 2 +- spine-cpp/spine-cpp/src/spine/Json.cpp | 2 +- spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp | 2 +- spine-cpp/spine-cpp/src/spine/MathUtil.cpp | 22 +++++++------- .../spine-cpp/src/spine/MeshAttachment.cpp | 4 +-- .../spine-cpp/src/spine/PathConstraint.cpp | 2 +- .../spine-cpp/src/spine/RegionAttachment.cpp | 2 +- spine-cpp/spine-cpp/src/spine/Skeleton.cpp | 12 ++++---- .../spine-cpp/src/spine/SkeletonBinary.cpp | 4 +-- .../spine-cpp/src/spine/SkeletonBounds.cpp | 20 ++++++------- .../spine-cpp/src/spine/SkeletonJson.cpp | 22 +++++++------- spine-cpp/spine-cpp/src/spine/Skin.cpp | 14 ++++----- spine-cpp/spine-cpp/src/spine/SpineObject.cpp | 8 +++++ .../spine-cpp/src/spine/Triangulator.cpp | 2 +- .../spine-cpp/src/spine/VertexAttachment.cpp | 20 ++++++------- spine-sfml/cpp/example/main.cpp | 8 ++--- 44 files changed, 180 insertions(+), 178 deletions(-) diff --git a/spine-c/spine-c-unit-tests/memory/KMemory.cpp b/spine-c/spine-c-unit-tests/memory/KMemory.cpp index a21cbafba..85a268a2c 100755 --- a/spine-c/spine-c-unit-tests/memory/KMemory.cpp +++ b/spine-c/spine-c-unit-tests/memory/KMemory.cpp @@ -8,6 +8,8 @@ #include "KMemory.h" // last include +#pragma warning(disable:4996) + /////////////////////////////////////////////////////////////////////////////// // // KANJI_DUMP_LEAKED_MEM will print out the memory block that was leaked. diff --git a/spine-c/spine-c-unit-tests/teamcity/teamcity_messages.cpp b/spine-c/spine-c-unit-tests/teamcity/teamcity_messages.cpp index 6f88d1ee9..1f2ae01d8 100755 --- a/spine-c/spine-c-unit-tests/teamcity/teamcity_messages.cpp +++ b/spine-c/spine-c-unit-tests/teamcity/teamcity_messages.cpp @@ -20,6 +20,8 @@ #include "teamcity_messages.h" +#pragma warning(disable:4996) + using namespace std; namespace JetBrains { diff --git a/spine-c/spine-c/include/spine/extension.h b/spine-c/spine-c/include/spine/extension.h index da971f35c..d5ec7f3c4 100644 --- a/spine-c/spine-c/include/spine/extension.h +++ b/spine-c/spine-c/include/spine/extension.h @@ -96,7 +96,7 @@ #define RAD_DEG (180 / PI) #define ABS(A) ((A) < 0? -(A): (A)) -#define SIGNUM(A) ((A) < 0? -1: (A) > 0 ? 1 : 0) +#define SIGNUM(A) ((A) < 0? -1.0f: (A) > 0 ? 1.0f : 0.0f) #ifdef __STDC_VERSION__ #define FMOD(A,B) fmodf(A, B) diff --git a/spine-c/spine-c/src/spine/Bone.c b/spine-c/spine-c/src/spine/Bone.c index 96d43cb6d..2165e49ec 100644 --- a/spine-c/spine-c/src/spine/Bone.c +++ b/spine-c/spine-c/src/spine/Bone.c @@ -166,7 +166,7 @@ void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rota za *= s; zc *= s; s = SQRT(za * za + zc * zc); - r = PI / 2 + atan2(zc, za); + r = PI / 2 + ATAN2(zc, za); zb = COS(r) * s; zd = SIN(r) * s; la = COS_DEG(shearX) * scaleX; diff --git a/spine-c/spine-c/src/spine/Json.c b/spine-c/spine-c/src/spine/Json.c index c260bb39f..fc04c245d 100644 --- a/spine-c/spine-c/src/spine/Json.c +++ b/spine-c/spine-c/src/spine/Json.c @@ -147,7 +147,7 @@ static const char* parse_number (Json *item, const char* num) { if (ptr != num) { /* Parse success, number found. */ - item->valueFloat = result; + item->valueFloat = (float)result; item->valueInt = (int)result; item->type = Json_Number; return ptr; diff --git a/spine-c/spine-c/src/spine/SkeletonJson.c b/spine-c/spine-c/src/spine/SkeletonJson.c index 16428ddf7..4bf8c6e4e 100644 --- a/spine-c/spine-c/src/spine/SkeletonJson.c +++ b/spine-c/spine-c/src/spine/SkeletonJson.c @@ -93,7 +93,7 @@ static float toColor (const char* value, int index) { char *error; int color; - if (index >= strlen(value) / 2) + if ((size_t)index >= strlen(value) / 2) return -1; value += index * 2; diff --git a/spine-cpp/spine-cpp/include/spine/AnimationState.h b/spine-cpp/spine-cpp/include/spine/AnimationState.h index a1056a4c9..5eaa5e2fc 100644 --- a/spine-cpp/spine-cpp/include/spine/AnimationState.h +++ b/spine-cpp/spine-cpp/include/spine/AnimationState.h @@ -198,7 +198,7 @@ namespace Spine { void setMixDuration(float inValue); - float getMixBlend(); + MixBlend getMixBlend(); void setMixBlend(MixBlend blend); /// @@ -319,10 +319,10 @@ namespace Spine { /// Removes all animations from the tracks, leaving skeletons in their previous pose. /// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose, /// rather than leaving them in their previous pose. - void clearTrack(int trackIndex); + void clearTrack(size_t trackIndex); /// Sets an animation by name. setAnimation(int, Animation, bool) - TrackEntry* setAnimation(int trackIndex, const String& animationName, bool loop); + TrackEntry* setAnimation(size_t trackIndex, const String& animationName, bool loop); /// Sets the current animation for a track, discarding any queued animations. /// @param loop If true, the animation will repeat. @@ -331,11 +331,11 @@ namespace Spine { /// @return /// A track entry to allow further customization of animation playback. References to the track entry must not be kept /// after AnimationState.Dispose. - TrackEntry* setAnimation(int trackIndex, Animation* animation, bool loop); + TrackEntry* setAnimation(size_t trackIndex, Animation* animation, bool loop); /// Queues an animation by name. /// addAnimation(int, Animation, bool, float) - TrackEntry* addAnimation(int trackIndex, const String& animationName, bool loop, float delay); + TrackEntry* addAnimation(size_t trackIndex, const String& animationName, bool loop, float delay); /// Adds an animation to be played delay seconds after the current or last queued animation /// for a track. If the track is empty, it is equivalent to calling setAnimation. @@ -345,11 +345,11 @@ namespace Spine { /// /// @return A track entry to allow further customization of animation playback. References to the track entry must not be kept /// after AnimationState.Dispose - TrackEntry* addAnimation(int trackIndex, Animation* animation, bool loop, float delay); + TrackEntry* addAnimation(size_t trackIndex, Animation* animation, bool loop, float delay); /// /// Sets an empty animation for a track, discarding any queued animations, and mixes to it over the specified mix duration. - TrackEntry* setEmptyAnimation(int trackIndex, float mixDuration); + TrackEntry* setEmptyAnimation(size_t trackIndex, float mixDuration); /// /// Adds an empty animation to be played after the current or last queued animation for a track, and mixes to it over the @@ -361,14 +361,14 @@ namespace Spine { /// @param mixDuration Mix duration. /// @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation /// duration of the previous track minus any mix duration plus the negative delay. - TrackEntry* addEmptyAnimation(int trackIndex, float mixDuration, float delay); + TrackEntry* addEmptyAnimation(size_t trackIndex, float mixDuration, float delay); /// /// Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration. void setEmptyAnimations(float mixDuration); /// @return The track entry for the animation currently playing on the track, or NULL if no animation is currently playing. - TrackEntry* getCurrent(int trackIndex); + TrackEntry* getCurrent(size_t trackIndex); AnimationStateData* getData(); @@ -405,7 +405,7 @@ namespace Spine { static Animation* getEmptyAnimation(); - static void applyRotateTimeline(RotateTimeline* rotateTimeline, Skeleton& skeleton, float time, float alpha, MixBlend pose, Vector& timelinesRotation, int i, bool firstFrame); + static void applyRotateTimeline(RotateTimeline* rotateTimeline, Skeleton& skeleton, float time, float alpha, MixBlend pose, Vector& timelinesRotation, size_t i, bool firstFrame); /// Returns true when all mixing from entries are complete. bool updateMixingFrom(TrackEntry* to, float delta); @@ -415,13 +415,13 @@ namespace Spine { void queueEvents(TrackEntry* entry, float animationTime); /// Sets the active TrackEntry for a given track number. - void setCurrent(int index, TrackEntry* current, bool interrupt); + void setCurrent(size_t index, TrackEntry* current, bool interrupt); - TrackEntry* expandToIndex(int index); + TrackEntry* expandToIndex(size_t index); /// Object-pooling version of new TrackEntry. Obtain an unused TrackEntry from the pool and clear/initialize its values. /// @param last May be NULL. - TrackEntry* newTrackEntry(int trackIndex, Animation* animation, bool loop, TrackEntry* last); + TrackEntry* newTrackEntry(size_t trackIndex, Animation* animation, bool loop, TrackEntry* last); /// Dispose all track entries queued after the given TrackEntry. void disposeNext(TrackEntry* entry); diff --git a/spine-cpp/spine-cpp/include/spine/AnimationStateData.h b/spine-cpp/spine-cpp/include/spine/AnimationStateData.h index 39c9368a3..ad745c448 100644 --- a/spine-cpp/spine-cpp/include/spine/AnimationStateData.h +++ b/spine-cpp/spine-cpp/include/spine/AnimationStateData.h @@ -79,10 +79,6 @@ namespace Spine { bool operator==(const AnimationPair &other) const; }; - struct HashAnimationPair : public SpineObject { - std::size_t operator()(const Spine::AnimationStateData::AnimationPair& val) const; - }; - SkeletonData* _skeletonData; float _defaultMix; HashMap _animationToMixTime; diff --git a/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h b/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h index 66748eb79..ac356df5d 100644 --- a/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h +++ b/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h @@ -58,13 +58,13 @@ namespace Spine { /// Sets the time and value of the specified keyframe. void setFrame(int frameIndex, float time, const String& attachmentName); - int getSlotIndex(); - void setSlotIndex(int inValue); + size_t getSlotIndex(); + void setSlotIndex(size_t inValue); const Vector& getFrames(); const Vector& getAttachmentNames(); - int getFrameCount(); + size_t getFrameCount(); private: - int _slotIndex; + size_t _slotIndex; Vector _frames; Vector _attachmentNames; }; diff --git a/spine-cpp/spine-cpp/include/spine/Event.h b/spine-cpp/spine-cpp/include/spine/Event.h index 9e6ab13a7..c0263771a 100644 --- a/spine-cpp/spine-cpp/include/spine/Event.h +++ b/spine-cpp/spine-cpp/include/spine/Event.h @@ -59,7 +59,7 @@ public: float getFloatValue(); - void setFloatValue(int inValue); + void setFloatValue(float inValue); const String &getStringValue(); diff --git a/spine-cpp/spine-cpp/include/spine/HashMap.h b/spine-cpp/spine-cpp/include/spine/HashMap.h index 7f9e714c7..273fd9e9e 100755 --- a/spine-cpp/spine-cpp/include/spine/HashMap.h +++ b/spine-cpp/spine-cpp/include/spine/HashMap.h @@ -35,6 +35,9 @@ #include #include + // Required for new with line number and file name in MSVC +#pragma warning(disable:4291) + namespace Spine { template class HashMap : public SpineObject { @@ -143,8 +146,10 @@ public: V operator[](const K &key) { Entry *entry = find(key); if (entry) return entry->_value; - else + else { assert(false); + return 0; + } } Entries getEntries() const { diff --git a/spine-cpp/spine-cpp/include/spine/LinkedMesh.h b/spine-cpp/spine-cpp/include/spine/LinkedMesh.h index 3dba61ca4..d3a2392f4 100644 --- a/spine-cpp/spine-cpp/include/spine/LinkedMesh.h +++ b/spine-cpp/spine-cpp/include/spine/LinkedMesh.h @@ -43,12 +43,12 @@ class LinkedMesh : public SpineObject { friend class SkeletonJson; public: - LinkedMesh(MeshAttachment *mesh, const String &skin, int slotIndex, const String &parent); + LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent); private: MeshAttachment *_mesh; String _skin; - int _slotIndex; + size_t _slotIndex; String _parent; }; } diff --git a/spine-cpp/spine-cpp/include/spine/MathUtil.h b/spine-cpp/spine-cpp/include/spine/MathUtil.h index 2c9eece34..99983ad82 100644 --- a/spine-cpp/spine-cpp/include/spine/MathUtil.h +++ b/spine-cpp/spine-cpp/include/spine/MathUtil.h @@ -52,7 +52,7 @@ public: template static inline T max(T a, T b) { return a > b ? a : b; } - static int sign(float val); + static float sign(float val); static float clamp(float x, float lower, float upper); @@ -106,8 +106,8 @@ struct PowInterpolation: public Interpolation { } float apply(float a) { - if (a <= 0.5f) return MathUtil::pow(a * 2, power) / 2; - return MathUtil::pow((a - 1) * 2, power) / (power % 2 == 0 ? -2 : 2) + 1; + if (a <= 0.5f) return MathUtil::pow(a * 2.0f, (float)power) / 2.0f; + return MathUtil::pow((a - 1.0f) * 2.0f, (float)power) / (power % 2 == 0 ? -2.0f : 2.0f) + 1.0f; } int power; @@ -118,7 +118,7 @@ struct PowOutInterpolation: public Interpolation { } float apply(float a) { - return MathUtil::pow(a - 1, power) * (power % 2 == 0 ? -1 : 1) + 1; + return MathUtil::pow(a - 1, (float)power) * (power % 2 == 0 ? -1.0f : 1.0f) + 1.0f; } int power; diff --git a/spine-cpp/spine-cpp/include/spine/MeshAttachment.h b/spine-cpp/spine-cpp/include/spine/MeshAttachment.h index cdc4b7860..793638cd9 100644 --- a/spine-cpp/spine-cpp/include/spine/MeshAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/MeshAttachment.h @@ -52,7 +52,7 @@ namespace Spine { virtual bool applyDeform(VertexAttachment* sourceAttachment); int getHullLength(); - void setHullLength(float inValue); + void setHullLength(int inValue); Vector& getRegionUVs(); @@ -81,7 +81,7 @@ namespace Spine { void setRegionV2(float inValue); bool getRegionRotate(); - void setRegionRotate(float inValue); + void setRegionRotate(bool inValue); float getRegionOffsetX(); void setRegionOffsetX(float inValue); diff --git a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h index 5b8f1098a..58d81353c 100644 --- a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h @@ -62,7 +62,7 @@ namespace Spine { /// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8. /// @param offset The worldVertices index to begin writing values. /// @param stride The number of worldVertices entries between the value pairs written. - void computeWorldVertices(Bone& bone, Vector& worldVertices, int offset, int stride = 2); + void computeWorldVertices(Bone& bone, Vector& worldVertices, size_t offset, size_t stride = 2); float getX(); void setX(float inValue); diff --git a/spine-cpp/spine-cpp/include/spine/SkeletonJson.h b/spine-cpp/spine-cpp/include/spine/SkeletonJson.h index 04bcc213a..948b07feb 100644 --- a/spine-cpp/spine-cpp/include/spine/SkeletonJson.h +++ b/spine-cpp/spine-cpp/include/spine/SkeletonJson.h @@ -77,13 +77,13 @@ private: const bool _ownsLoader; String _error; - static float toColor(const char *value, int index); + static float toColor(const char *value, size_t index); - static void readCurve(Json *frame, CurveTimeline *timeline, int frameIndex); + static void readCurve(Json *frame, CurveTimeline *timeline, size_t frameIndex); Animation *readAnimation(Json *root, SkeletonData *skeletonData); - void readVertices(Json *attachmentMap, VertexAttachment *attachment, int verticesLength); + void readVertices(Json *attachmentMap, VertexAttachment *attachment, size_t verticesLength); void setError(Json *root, const String &value1, const String &value2); }; diff --git a/spine-cpp/spine-cpp/include/spine/Skin.h b/spine-cpp/spine-cpp/include/spine/Skin.h index 7a080dde1..e22256a95 100644 --- a/spine-cpp/spine-cpp/include/spine/Skin.h +++ b/spine-cpp/spine-cpp/include/spine/Skin.h @@ -51,11 +51,11 @@ public: public: struct Entry { - int _slotIndex; + size_t _slotIndex; String _name; Attachment *_attachment; - Entry(int slotIndex, const String &name, Attachment *attachment) : + Entry(size_t slotIndex, const String &name, Attachment *attachment) : _slotIndex(slotIndex), _name(name), _attachment(attachment) { @@ -68,8 +68,8 @@ public: public: bool hasNext() { while(true) { - if (_slotIndex >= (int) _buckets.size()) return false; - if (_bucketIndex >= (int) _buckets[_slotIndex].size()) { + if (_slotIndex >= _buckets.size()) return false; + if (_bucketIndex >= _buckets[_slotIndex].size()) { _bucketIndex = 0; ++_slotIndex; continue; @@ -90,15 +90,15 @@ public: private: Vector< Vector > &_buckets; - int _slotIndex; - int _bucketIndex; + size_t _slotIndex; + size_t _bucketIndex; }; - void put(int slotIndex, const String &attachmentName, Attachment *attachment); + void put(size_t slotIndex, const String &attachmentName, Attachment *attachment); - Attachment *get(int slotIndex, const String &attachmentName); + Attachment *get(size_t slotIndex, const String &attachmentName); - void remove(int slotIndex, const String &attachmentName); + void remove(size_t slotIndex, const String &attachmentName); Entries getEntries(); @@ -118,20 +118,20 @@ public: /// Adds an attachment to the skin for the specified slot index and name. /// If the name already exists for the slot, the previous value is replaced. - void addAttachment(int slotIndex, const String &name, Attachment *attachment); + void addAttachment(size_t slotIndex, const String &name, Attachment *attachment); /// Returns the attachment for the specified slot index and name, or NULL. - Attachment *getAttachment(int slotIndex, const String &name); + Attachment *getAttachment(size_t slotIndex, const String &name); /// Finds the skin keys for a given slot. The results are added to the passed array of names. /// @param slotIndex The target slotIndex. To find the slot index, use Skeleton::findSlotIndex or SkeletonData::findSlotIndex /// @param names Found skin key names will be added to this array. - void findNamesForSlot(int slotIndex, Vector &names); + void findNamesForSlot(size_t slotIndex, Vector &names); /// Finds the attachments for a given slot. The results are added to the passed array of Attachments. /// @param slotIndex The target slotIndex. To find the slot index, use Skeleton::findSlotIndex or SkeletonData::findSlotIndex /// @param attachments Found Attachments will be added to this array. - void findAttachmentsForSlot(int slotIndex, Vector &attachments); + void findAttachmentsForSlot(size_t slotIndex, Vector &attachments); const String &getName(); diff --git a/spine-cpp/spine-cpp/include/spine/SpineObject.h b/spine-cpp/spine-cpp/include/spine/SpineObject.h index c01aa7811..da5039c09 100644 --- a/spine-cpp/spine-cpp/include/spine/SpineObject.h +++ b/spine-cpp/spine-cpp/include/spine/SpineObject.h @@ -42,6 +42,10 @@ public: void *operator new(size_t sz, void *ptr); + void operator delete(void *p, const char *file, int line); + + void operator delete(void *p, void *mem); + void operator delete(void *p); virtual ~SpineObject(); diff --git a/spine-cpp/spine-cpp/include/spine/String.h b/spine-cpp/spine-cpp/include/spine/String.h index 189726ba3..f780b0972 100644 --- a/spine-cpp/spine-cpp/include/spine/String.h +++ b/spine-cpp/spine-cpp/include/spine/String.h @@ -37,6 +37,9 @@ #include #include +// Required for sprintf on MSVC +#pragma warning(disable:4996) + namespace Spine { class String : public SpineObject { public: diff --git a/spine-cpp/spine-cpp/include/spine/VertexAttachment.h b/spine-cpp/spine-cpp/include/spine/VertexAttachment.h index 7015b12ea..c3188d23f 100644 --- a/spine-cpp/spine-cpp/include/spine/VertexAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/VertexAttachment.h @@ -59,7 +59,7 @@ namespace Spine { /// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + count. /// @param offset The worldVertices index to begin writing values. /// @param stride The number of worldVertices entries between the value pairs written. - void computeWorldVertices(Slot& slot, int start, int count, Vector& worldVertices, int offset, int stride = 2); + void computeWorldVertices(Slot& slot, size_t start, size_t count, Vector& worldVertices, size_t offset, size_t stride = 2); /// @return true if a deform originally applied to the specified attachment should be applied to this attachment. virtual bool applyDeform(VertexAttachment* sourceAttachment); @@ -67,17 +67,17 @@ namespace Spine { /// Gets a unique ID for this attachment. int getId(); - Vector& getBones(); + Vector& getBones(); Vector& getVertices(); - int getWorldVerticesLength(); - void setWorldVerticesLength(int inValue); + size_t getWorldVerticesLength(); + void setWorldVerticesLength(size_t inValue); protected: - Vector _bones; + Vector _bones; Vector _vertices; - int _worldVerticesLength; + size_t _worldVerticesLength; private: const int _id; diff --git a/spine-cpp/spine-cpp/include/spine/Vertices.h b/spine-cpp/spine-cpp/include/spine/Vertices.h index d9e4f1d23..0ae9d3b9a 100644 --- a/spine-cpp/spine-cpp/include/spine/Vertices.h +++ b/spine-cpp/spine-cpp/include/spine/Vertices.h @@ -36,7 +36,7 @@ namespace Spine { class Vertices : public SpineObject { public: - Vector _bones; + Vector _bones; Vector _vertices; }; } diff --git a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp index 57f55b4bb..6637ef245 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp @@ -141,7 +141,7 @@ TrackEntry *TrackEntry::getMixingFrom() { return _mixingFrom; } void TrackEntry::setMixBlend(MixBlend blend) { _mixBlend = blend; } -float TrackEntry::getMixBlend() { return _mixBlend; } +MixBlend TrackEntry::getMixBlend() { return _mixBlend; } void TrackEntry::resetRotationDirections() { _timelinesRotation.clear(); @@ -276,7 +276,7 @@ void EventQueue::drain() { AnimationState &state = _state; // Don't cache _eventQueueEntries.size() so callbacks can queue their own events (eg, call setAnimation in AnimationState_Complete). - for (int i = 0; i < _eventQueueEntries.size(); ++i) { + for (size_t i = 0; i < _eventQueueEntries.size(); ++i) { EventQueueEntry *queueEntry = &_eventQueueEntries[i]; TrackEntry *trackEntry = queueEntry->_entry; @@ -323,7 +323,7 @@ AnimationState::AnimationState(AnimationStateData *data) : } AnimationState::~AnimationState() { - for (int i = 0; i < _tracks.size(); i++) { + for (size_t i = 0; i < _tracks.size(); i++) { TrackEntry* entry = _tracks[i]; if (entry) { TrackEntry* from = entry->_mixingFrom; @@ -492,7 +492,7 @@ void AnimationState::clearTracks() { _queue->drain(); } -void AnimationState::clearTrack(int trackIndex) { +void AnimationState::clearTrack(size_t trackIndex) { if (trackIndex >= _tracks.size()) { return; } @@ -523,14 +523,14 @@ void AnimationState::clearTrack(int trackIndex) { _queue->drain(); } -TrackEntry *AnimationState::setAnimation(int trackIndex, const String &animationName, bool loop) { +TrackEntry *AnimationState::setAnimation(size_t trackIndex, const String &animationName, bool loop) { Animation *animation = _data->_skeletonData->findAnimation(animationName); assert(animation != NULL); return setAnimation(trackIndex, animation, loop); } -TrackEntry *AnimationState::setAnimation(int trackIndex, Animation *animation, bool loop) { +TrackEntry *AnimationState::setAnimation(size_t trackIndex, Animation *animation, bool loop) { assert(animation != NULL); bool interrupt = true; @@ -556,14 +556,14 @@ TrackEntry *AnimationState::setAnimation(int trackIndex, Animation *animation, b return entry; } -TrackEntry *AnimationState::addAnimation(int trackIndex, const String &animationName, bool loop, float delay) { +TrackEntry *AnimationState::addAnimation(size_t trackIndex, const String &animationName, bool loop, float delay) { Animation *animation = _data->_skeletonData->findAnimation(animationName); assert(animation != NULL); return addAnimation(trackIndex, animation, loop, delay); } -TrackEntry *AnimationState::addAnimation(int trackIndex, Animation *animation, bool loop, float delay) { +TrackEntry *AnimationState::addAnimation(size_t trackIndex, Animation *animation, bool loop, float delay) { assert(animation != NULL); TrackEntry *last = expandToIndex(trackIndex); @@ -599,14 +599,14 @@ TrackEntry *AnimationState::addAnimation(int trackIndex, Animation *animation, b return entry; } -TrackEntry *AnimationState::setEmptyAnimation(int trackIndex, float mixDuration) { +TrackEntry *AnimationState::setEmptyAnimation(size_t trackIndex, float mixDuration) { TrackEntry *entry = setAnimation(trackIndex, AnimationState::getEmptyAnimation(), false); entry->_mixDuration = mixDuration; entry->_trackEnd = mixDuration; return entry; } -TrackEntry *AnimationState::addEmptyAnimation(int trackIndex, float mixDuration, float delay) { +TrackEntry *AnimationState::addEmptyAnimation(size_t trackIndex, float mixDuration, float delay) { if (delay <= 0) { delay -= mixDuration; } @@ -630,7 +630,7 @@ void AnimationState::setEmptyAnimations(float mixDuration) { _queue->drain(); } -TrackEntry *AnimationState::getCurrent(int trackIndex) { +TrackEntry *AnimationState::getCurrent(size_t trackIndex) { return trackIndex >= _tracks.size() ? NULL : _tracks[trackIndex]; } @@ -669,7 +669,7 @@ Animation *AnimationState::getEmptyAnimation() { } void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleton &skeleton, float time, float alpha, - MixBlend blend, Vector &timelinesRotation, int i, bool firstFrame) { + MixBlend blend, Vector &timelinesRotation, size_t i, bool firstFrame) { if (firstFrame) { timelinesRotation[i] = 0; } @@ -897,7 +897,7 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) { } } -void AnimationState::setCurrent(int index, TrackEntry *current, bool interrupt) { +void AnimationState::setCurrent(size_t index, TrackEntry *current, bool interrupt) { TrackEntry *from = expandToIndex(index); _tracks[index] = current; @@ -920,7 +920,7 @@ void AnimationState::setCurrent(int index, TrackEntry *current, bool interrupt) _queue->start(current); // triggers animationsChanged } -TrackEntry *AnimationState::expandToIndex(int index) { +TrackEntry *AnimationState::expandToIndex(size_t index) { if (index < _tracks.size()) { return _tracks[index]; } @@ -932,7 +932,7 @@ TrackEntry *AnimationState::expandToIndex(int index) { return NULL; } -TrackEntry *AnimationState::newTrackEntry(int trackIndex, Animation *animation, bool loop, TrackEntry *last) { +TrackEntry *AnimationState::newTrackEntry(size_t trackIndex, Animation *animation, bool loop, TrackEntry *last) { TrackEntry *entryP = _trackEntryPool.obtain(); // Pooling TrackEntry &entry = *entryP; diff --git a/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp b/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp index 9c1fa4384..e89b68090 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp @@ -81,20 +81,3 @@ AnimationStateData::AnimationPair::AnimationPair(Animation *a1, Animation *a2) : bool AnimationStateData::AnimationPair::operator==(const AnimationPair &other) const { return _a1->_name == other._a1->_name && _a2->_name == other._a2->_name; } - -std::size_t -AnimationStateData::HashAnimationPair::operator()(const Spine::AnimationStateData::AnimationPair &val) const { - std::size_t h1 = 7; - size_t strlen = val._a1->_name.length(); - for (int i = 0; i < strlen; ++i) { - h1 = h1 * 31 + val._a1->_name.buffer()[i]; - } - - std::size_t h2 = 7; - strlen = val._a2->_name.length(); - for (int i = 0; i < strlen; ++i) { - h2 = h2 * 31 + val._a2->_name.buffer()[i]; - } - - return (((h1 << 5) + h1) ^ h2); -} diff --git a/spine-cpp/spine-cpp/src/spine/Atlas.cpp b/spine-cpp/spine-cpp/src/spine/Atlas.cpp index 198cad58d..648376fd6 100644 --- a/spine-cpp/spine-cpp/src/spine/Atlas.cpp +++ b/spine-cpp/spine-cpp/src/spine/Atlas.cpp @@ -172,7 +172,7 @@ void Atlas::load(const char *begin, int length, const char *dir) { region->name = String(mallocString(&str), true); assert(readValue(&begin, end, &str)); - region->rotate = equals(&str, "true"); + region->rotate = equals(&str, "true") ? true : false; assert(readTuple(&begin, end, tuple) == 2); region->x = toInt(tuple); @@ -222,8 +222,8 @@ void Atlas::load(const char *begin, int length, const char *dir) { region->originalHeight = toInt(tuple + 1); readTuple(&begin, end, tuple); - region->offsetX = toInt(tuple); - region->offsetY = toInt(tuple + 1); + region->offsetX = (float)toInt(tuple); + region->offsetY = (float)toInt(tuple + 1); assert(readValue(&begin, end, &str)); diff --git a/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp b/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp index e937dc547..1c266f1e0 100644 --- a/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp +++ b/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp @@ -59,10 +59,10 @@ RegionAttachment *AtlasAttachmentLoader::newRegionAttachment(Skin &skin, const S attachment.setUVs(region.u, region.v, region.u2, region.v2, region.rotate); attachment._regionOffsetX = region.offsetX; attachment._regionOffsetY = region.offsetY; - attachment._regionWidth = region.width; - attachment._regionHeight = region.height; - attachment._regionOriginalWidth = region.originalWidth; - attachment._regionOriginalHeight = region.originalHeight; + attachment._regionWidth = (float)region.width; + attachment._regionHeight = (float)region.height; + attachment._regionOriginalWidth = (float)region.originalWidth; + attachment._regionOriginalHeight = (float)region.originalHeight; return attachmentP; } @@ -83,10 +83,10 @@ MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const Strin attachment._regionRotate = region.rotate; attachment._regionOffsetX = region.offsetX; attachment._regionOffsetY = region.offsetY; - attachment._regionWidth = region.width; - attachment._regionHeight = region.height; - attachment._regionOriginalWidth = region.originalWidth; - attachment._regionOriginalHeight = region.originalHeight; + attachment._regionWidth = (float)region.width; + attachment._regionHeight = (float)region.height; + attachment._regionOriginalWidth = (float)region.originalWidth; + attachment._regionOriginalHeight = (float)region.originalHeight; return attachmentP; } @@ -108,7 +108,6 @@ ClippingAttachment *AtlasAttachmentLoader::newClippingAttachment(Skin &skin, con } AtlasRegion *AtlasAttachmentLoader::findRegion(const String &name) { - AtlasRegion *ret; return _atlas->findRegion(name); } diff --git a/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp b/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp index 554fa980c..301f66738 100644 --- a/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp +++ b/spine-cpp/spine-cpp/src/spine/AttachmentTimeline.cpp @@ -97,11 +97,11 @@ void AttachmentTimeline::setFrame(int frameIndex, float time, const String &atta _attachmentNames[frameIndex] = attachmentName; } -int AttachmentTimeline::getSlotIndex() { +size_t AttachmentTimeline::getSlotIndex() { return _slotIndex; } -void AttachmentTimeline::setSlotIndex(int inValue) { +void AttachmentTimeline::setSlotIndex(size_t inValue) { _slotIndex = inValue; } @@ -113,6 +113,6 @@ const Vector &AttachmentTimeline::getAttachmentNames() { return _attachmentNames; } -int AttachmentTimeline::getFrameCount() { - return static_cast(_frames.size()); +size_t AttachmentTimeline::getFrameCount() { + return _frames.size(); } diff --git a/spine-cpp/spine-cpp/src/spine/Event.cpp b/spine-cpp/spine-cpp/src/spine/Event.cpp index d7fd00d5f..67d5fe918 100644 --- a/spine-cpp/spine-cpp/src/spine/Event.cpp +++ b/spine-cpp/spine-cpp/src/spine/Event.cpp @@ -62,7 +62,7 @@ float Event::getFloatValue() { return _floatValue; } -void Event::setFloatValue(int inValue) { +void Event::setFloatValue(float inValue) { _floatValue = inValue; } diff --git a/spine-cpp/spine-cpp/src/spine/EventTimeline.cpp b/spine-cpp/spine-cpp/src/spine/EventTimeline.cpp index a5aa0bdcb..3c6bed1a6 100644 --- a/spine-cpp/spine-cpp/src/spine/EventTimeline.cpp +++ b/spine-cpp/spine-cpp/src/spine/EventTimeline.cpp @@ -69,7 +69,7 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector if (lastTime > time) { // Fire events after last time for looped animations. - apply(skeleton, lastTime, std::numeric_limits::max(), pEvents, alpha, blend, direction); + apply(skeleton, lastTime, std::numeric_limits::max(), pEvents, alpha, blend, direction); lastTime = -1.0f; } else if (lastTime >= _frames[frameCount - 1]) { // Last time is after last frame. diff --git a/spine-cpp/spine-cpp/src/spine/IkConstraintTimeline.cpp b/spine-cpp/spine-cpp/src/spine/IkConstraintTimeline.cpp index 73dea4a09..a836b6def 100644 --- a/spine-cpp/spine-cpp/src/spine/IkConstraintTimeline.cpp +++ b/spine-cpp/spine-cpp/src/spine/IkConstraintTimeline.cpp @@ -120,5 +120,5 @@ void IkConstraintTimeline::setFrame(int frameIndex, float time, float mix, int b frameIndex *= ENTRIES; _frames[frameIndex] = time; _frames[frameIndex + MIX] = mix; - _frames[frameIndex + BEND_DIRECTION] = bendDirection; + _frames[frameIndex + BEND_DIRECTION] = (float)bendDirection; } diff --git a/spine-cpp/spine-cpp/src/spine/Json.cpp b/spine-cpp/spine-cpp/src/spine/Json.cpp index 19c528a50..bd082bb14 100644 --- a/spine-cpp/spine-cpp/src/spine/Json.cpp +++ b/spine-cpp/spine-cpp/src/spine/Json.cpp @@ -376,7 +376,7 @@ const char *Json::parseNumber(Json *item, const char *num) { if (ptr != num) { /* Parse success, number found. */ - item->_valueFloat = result; + item->_valueFloat = (float)result; item->_valueInt = static_cast(result); item->_type = JSON_NUMBER; return ptr; diff --git a/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp b/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp index 46bf8569f..f4c0f193c 100644 --- a/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp +++ b/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp @@ -34,7 +34,7 @@ using namespace Spine; -LinkedMesh::LinkedMesh(MeshAttachment *mesh, const String &skin, int slotIndex, const String &parent) : +LinkedMesh::LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent) : _mesh(mesh), _skin(skin), _slotIndex(slotIndex), diff --git a/spine-cpp/spine-cpp/src/spine/MathUtil.cpp b/spine-cpp/spine-cpp/src/spine/MathUtil.cpp index 59d53ee8b..9536b8939 100644 --- a/spine-cpp/spine-cpp/src/spine/MathUtil.cpp +++ b/spine-cpp/spine-cpp/src/spine/MathUtil.cpp @@ -37,8 +37,8 @@ float MathUtil::abs(float v) { return ((v) < 0 ? -(v) : (v)); } -int MathUtil::sign(float v) { - return ((v) < 0 ? -1 : (v) > 0 ? 1 : 0); +float MathUtil::sign(float v) { + return ((v) < 0 ? -1.0f : (v) > 0 ? 1.0f : 0.0f); } float MathUtil::clamp(float x, float min, float max) { @@ -46,41 +46,41 @@ float MathUtil::clamp(float x, float min, float max) { } float MathUtil::fmod(float a, float b) { - return ::fmod(a, b); + return (float)::fmod(a, b); } /// Returns atan2 in radians, faster but less accurate than Math.Atan2. Average error of 0.00231 radians (0.1323 /// degrees), largest error of 0.00488 radians (0.2796 degrees). float MathUtil::atan2(float y, float x) { - return ::atan2(y, x); + return (float)::atan2(y, x); } /// Returns the cosine in radians from a lookup table. float MathUtil::cos(float radians) { - return ::cos(radians); + return (float)::cos(radians); } /// Returns the sine in radians from a lookup table. float MathUtil::sin(float radians) { - return ::sin(radians); + return (float)::sin(radians); } float MathUtil::sqrt(float v) { - return ::sqrt(v); + return (float)::sqrt(v); } float MathUtil::acos(float v) { - return ::acos(v); + return (float)::acos(v); } /// Returns the sine in radians from a lookup table. float MathUtil::sinDeg(float degrees) { - return ::sin(degrees * DEG_RAD); + return (float)::sin(degrees * DEG_RAD); } /// Returns the cosine in radians from a lookup table. float MathUtil::cosDeg(float degrees) { - return ::cos(degrees * DEG_RAD); + return (float)::cos(degrees * DEG_RAD); } /* Need to pass 0 as an argument, so VC++ doesn't error with C2124 */ @@ -109,5 +109,5 @@ float MathUtil::randomTriangular(float min, float max, float mode) { } float MathUtil::pow(float a, float b) { - return ::pow(a, b); + return (float)::pow(a, b); } diff --git a/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp b/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp index fc6027d1a..ad811b3e1 100644 --- a/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp @@ -83,7 +83,7 @@ int MeshAttachment::getHullLength() { return _hullLength; } -void MeshAttachment::setHullLength(float inValue) { +void MeshAttachment::setHullLength(int inValue) { _hullLength = inValue; } @@ -151,7 +151,7 @@ bool MeshAttachment::getRegionRotate() { return _regionRotate; } -void MeshAttachment::setRegionRotate(float inValue) { +void MeshAttachment::setRegionRotate(bool inValue) { _regionRotate = inValue; } diff --git a/spine-cpp/spine-cpp/src/spine/PathConstraint.cpp b/spine-cpp/spine-cpp/src/spine/PathConstraint.cpp index 361afeb51..c52f401e9 100644 --- a/spine-cpp/spine-cpp/src/spine/PathConstraint.cpp +++ b/spine-cpp/spine-cpp/src/spine/PathConstraint.cpp @@ -147,7 +147,7 @@ void PathConstraint::update() { offsetRotation *= p.getA() * p.getD() - p.getB() * p.getC() > 0 ? DEG_RAD : -DEG_RAD; } - for (int i = 0, p = 3; i < boneCount; i++, p += 3) { + for (size_t i = 0, p = 3; i < boneCount; i++, p += 3) { Bone *boneP = _bones[i]; Bone &bone = *boneP; bone._worldX += (boneX - bone._worldX) * translateMix; diff --git a/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp b/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp index fc67a6f4e..6eb4a9112 100644 --- a/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp @@ -122,7 +122,7 @@ void RegionAttachment::setUVs(float u, float v, float u2, float v2, bool rotate) } } -void RegionAttachment::computeWorldVertices(Bone &bone, Vector &worldVertices, int offset, int stride) { +void RegionAttachment::computeWorldVertices(Bone &bone, Vector &worldVertices, size_t offset, size_t stride) { assert(worldVertices.size() >= (offset + 8)); float x = bone.getWorldX(), y = bone.getWorldY(); diff --git a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp index 04a3a29cd..cb220857a 100644 --- a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp @@ -401,7 +401,7 @@ void Skeleton::getBounds(float &outX, float &outY, float &outWidth, float &outHe for (size_t i = 0; i < _drawOrder.size(); ++i) { Slot *slot = _drawOrder[i]; - int verticesLength = 0; + size_t verticesLength = 0; Attachment *attachment = slot->getAttachment(); if (attachment != NULL && attachment->getRTTI().instanceOf(RegionAttachment::rtti)) { @@ -423,7 +423,7 @@ void Skeleton::getBounds(float &outX, float &outY, float &outWidth, float &outHe mesh->computeWorldVertices(*slot, 0, verticesLength, outVertexBuffer, 0); } - for (int ii = 0; ii < verticesLength; ii += 2) { + for (size_t ii = 0; ii < verticesLength; ii += 2) { float vx = outVertexBuffer[ii]; float vy = outVertexBuffer[ii + 1]; @@ -570,9 +570,9 @@ void Skeleton::sortPathConstraint(PathConstraint *constraint) { _updateCache.add(constraint); - for (int i = 0; i < boneCount; i++) + for (size_t i = 0; i < boneCount; i++) sortReset(constrained[i]->getChildren()); - for (int i = 0; i < boneCount; i++) + for (size_t i = 0; i < boneCount; i++) constrained[i]->_sorted = true; } @@ -615,12 +615,12 @@ void Skeleton::sortPathConstraintAttachment(Skin *skin, int slotIndex, Bone &slo void Skeleton::sortPathConstraintAttachment(Attachment *attachment, Bone &slotBone) { if (attachment == NULL || !attachment->getRTTI().instanceOf(PathAttachment::rtti)) return; - Vector &pathBones = static_cast(attachment)->getBones(); + Vector &pathBones = static_cast(attachment)->getBones(); if (pathBones.size() == 0) sortBone(&slotBone); else { for (size_t i = 0, n = pathBones.size(); i < n;) { - int nn = pathBones[i++]; + size_t nn = pathBones[i++]; nn += i; while (i < nn) { sortBone(_bones[pathBones[i++]]); diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp index 529ff5e87..348b91b22 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp @@ -269,7 +269,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons } /* Skins. */ - for (int i = skeletonData->_defaultSkin ? 1 : 0; i < skeletonData->_skins.size(); ++i) { + for (size_t i = skeletonData->_defaultSkin ? 1 : 0; i < skeletonData->_skins.size(); ++i) { String skinName(readString(input), true); skeletonData->_skins[i] = readSkin(input, skinName, skeletonData, nonessential); } @@ -583,7 +583,7 @@ void SkeletonBinary::readVertices(DataInput *input, VertexAttachment *attachment } Vector &vertices = attachment->getVertices(); - Vector &bones = attachment->getBones(); + Vector &bones = attachment->getBones(); vertices.ensureCapacity(verticesLength * 3 * 3); bones.ensureCapacity(verticesLength * 3); diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp index b41180b2c..e47359a24 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp @@ -73,7 +73,7 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) { Polygon &polygon = *polygonP; - int count = boundingBox->getWorldVerticesLength(); + size_t count = boundingBox->getWorldVerticesLength(); polygon._count = count; if (polygon._vertices.size() < count) { polygon._vertices.setSize(count, 0); @@ -84,10 +84,10 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) { if (updateAabb) { aabbCompute(); } else { - _minX = std::numeric_limits::min(); - _minY = std::numeric_limits::min(); - _maxX = std::numeric_limits::max(); - _maxY = std::numeric_limits::max(); + _minX = std::numeric_limits::min(); + _minY = std::numeric_limits::min(); + _maxX = std::numeric_limits::max(); + _maxY = std::numeric_limits::max(); } } @@ -210,12 +210,12 @@ float SkeletonBounds::getHeight() { } void SkeletonBounds::aabbCompute() { - float minX = std::numeric_limits::min(); - float minY = std::numeric_limits::min(); - float maxX = std::numeric_limits::max(); - float maxY = std::numeric_limits::max(); + float minX = std::numeric_limits::min(); + float minY = std::numeric_limits::min(); + float maxX = std::numeric_limits::max(); + float maxY = std::numeric_limits::max(); - for (int i = 0, n = static_cast(_polygons.size()); i < n; ++i) { + for (size_t i = 0, n = _polygons.size(); i < n; ++i) { Polygon *polygon = _polygons[i]; Vector &vertices = polygon->_vertices; for (int ii = 0, nn = polygon->_count; ii < nn; ii += 2) { diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp index 961b16b8c..4b525902f 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp @@ -322,8 +322,8 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) { return NULL; } - data->_local = Json::getInt(constraintMap, "local", 0); - data->_relative = Json::getInt(constraintMap, "relative", 0); + data->_local = Json::getInt(constraintMap, "local", 0) ? true : false; + data->_relative = Json::getInt(constraintMap, "relative", 0) ? true : false; data->_offsetRotation = Json::getFloat(constraintMap, "rotation", 0); data->_offsetX = Json::getFloat(constraintMap, "x", 0) * _scale; data->_offsetY = Json::getFloat(constraintMap, "y", 0) * _scale; @@ -549,7 +549,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) { } } } else { - mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1); + mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1) ? true : false; LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh, String(Json::getString( attachmentMap, @@ -575,8 +575,8 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) { PathAttachment *pathAttatchment = static_cast(attachment); int vertexCount = 0; - pathAttatchment->_closed = Json::getInt(attachmentMap, "closed", 0); - pathAttatchment->_constantSpeed = Json::getInt(attachmentMap, "constantSpeed", 1); + pathAttatchment->_closed = Json::getInt(attachmentMap, "closed", 0) ? true : false; + pathAttatchment->_constantSpeed = Json::getInt(attachmentMap, "constantSpeed", 1) ? true : false; vertexCount = Json::getInt(attachmentMap, "vertexCount", 0); readVertices(attachmentMap, pathAttatchment, vertexCount << 1); @@ -684,7 +684,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) { return skeletonData; } -float SkeletonJson::toColor(const char *value, int index) { +float SkeletonJson::toColor(const char *value, size_t index) { char digits[3]; char *error; int color; @@ -706,7 +706,7 @@ float SkeletonJson::toColor(const char *value, int index) { return color / (float) 255; } -void SkeletonJson::readCurve(Json *frame, CurveTimeline *timeline, int frameIndex) { +void SkeletonJson::readCurve(Json *frame, CurveTimeline *timeline, size_t frameIndex) { Json *curve = Json::getItem(frame, "curve"); if (!curve) { return; @@ -727,7 +727,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) { Vector timelines; float duration = 0; - int frameIndex; + size_t frameIndex; Json *valueMap; int timelinesCount = 0; @@ -950,7 +950,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) { /** Path constraint timelines. */ for (constraintMap = paths ? paths->_child : 0; constraintMap; constraintMap = constraintMap->_next) { - int constraintIndex = 0, i; + size_t constraintIndex = 0, i; Json *timelineMap; PathConstraintData *data = skeletonData->findPathConstraint(constraintMap->_name); @@ -1096,7 +1096,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) { Vector unchanged; unchanged.ensureCapacity(skeletonData->_slots.size() - offsets->_size); unchanged.setSize(skeletonData->_slots.size() - offsets->_size, 0); - int originalIndex = 0, unchangedIndex = 0; + size_t originalIndex = 0, unchangedIndex = 0; drawOrder2.ensureCapacity(skeletonData->_slots.size()); drawOrder2.setSize(skeletonData->_slots.size(), 0); @@ -1164,7 +1164,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) { return new(__FILE__, __LINE__) Animation(String(root->_name), timelines, duration); } -void SkeletonJson::readVertices(Json *attachmentMap, VertexAttachment *attachment, int verticesLength) { +void SkeletonJson::readVertices(Json *attachmentMap, VertexAttachment *attachment, size_t verticesLength) { Json *entry; int i, n, nn, entrySize; Vector vertices; diff --git a/spine-cpp/spine-cpp/src/spine/Skin.cpp b/spine-cpp/spine-cpp/src/spine/Skin.cpp index b4f05f846..4e7524339 100644 --- a/spine-cpp/spine-cpp/src/spine/Skin.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skin.cpp @@ -42,7 +42,7 @@ using namespace Spine; Skin::AttachmentMap::AttachmentMap() { } -void Skin::AttachmentMap::put(int slotIndex, const String &attachmentName, Attachment *attachment) { +void Skin::AttachmentMap::put(size_t slotIndex, const String &attachmentName, Attachment *attachment) { if (slotIndex >= _buckets.size()) _buckets.setSize(slotIndex + 1, Vector()); Vector &bucket = _buckets[slotIndex]; @@ -54,13 +54,13 @@ void Skin::AttachmentMap::put(int slotIndex, const String &attachmentName, Attac } } -Attachment *Skin::AttachmentMap::get(int slotIndex, const String &attachmentName) { +Attachment *Skin::AttachmentMap::get(size_t slotIndex, const String &attachmentName) { if (slotIndex >= _buckets.size()) return NULL; int existing = findInBucket(_buckets[slotIndex], attachmentName); return existing >= 0 ? _buckets[slotIndex][existing]._attachment : NULL; } -void Skin::AttachmentMap::remove(int slotIndex, const String &attachmentName) { +void Skin::AttachmentMap::remove(size_t slotIndex, const String &attachmentName) { if (slotIndex >= _buckets.size()) return; int existing = findInBucket(_buckets[slotIndex], attachmentName); if (existing >= 0) _buckets[slotIndex].removeAt(existing); @@ -88,16 +88,16 @@ Skin::~Skin() { } } -void Skin::addAttachment(int slotIndex, const String &name, Attachment *attachment) { +void Skin::addAttachment(size_t slotIndex, const String &name, Attachment *attachment) { assert(attachment); _attachments.put(slotIndex, name, attachment); } -Attachment *Skin::getAttachment(int slotIndex, const String &name) { +Attachment *Skin::getAttachment(size_t slotIndex, const String &name) { return _attachments.get(slotIndex, name); } -void Skin::findNamesForSlot(int slotIndex, Vector &names) { +void Skin::findNamesForSlot(size_t slotIndex, Vector &names) { Skin::AttachmentMap::Entries entries = _attachments.getEntries(); while (entries.hasNext()) { Skin::AttachmentMap::Entry &entry = entries.next(); @@ -107,7 +107,7 @@ void Skin::findNamesForSlot(int slotIndex, Vector &names) { } } -void Skin::findAttachmentsForSlot(int slotIndex, Vector &attachments) { +void Skin::findAttachmentsForSlot(size_t slotIndex, Vector &attachments) { Skin::AttachmentMap::Entries entries = _attachments.getEntries(); while (entries.hasNext()) { Skin::AttachmentMap::Entry &entry = entries.next(); diff --git a/spine-cpp/spine-cpp/src/spine/SpineObject.cpp b/spine-cpp/spine-cpp/src/spine/SpineObject.cpp index 6d6d945d2..c512f6483 100644 --- a/spine-cpp/spine-cpp/src/spine/SpineObject.cpp +++ b/spine-cpp/spine-cpp/src/spine/SpineObject.cpp @@ -41,6 +41,14 @@ void *SpineObject::operator new(size_t sz, void *ptr) { return ptr; } +void SpineObject::operator delete(void *p, const char *file, int line) { + SpineExtension::free(p, file, line); +} + +void SpineObject::operator delete(void *p, void *mem) { + SpineExtension::free(p, __FILE__, __LINE__); +} + void SpineObject::operator delete(void *p) { SpineExtension::free(p, __FILE__, __LINE__); } diff --git a/spine-cpp/spine-cpp/src/spine/Triangulator.cpp b/spine-cpp/spine-cpp/src/spine/Triangulator.cpp index b5dc1906e..94c752561 100644 --- a/spine-cpp/spine-cpp/src/spine/Triangulator.cpp +++ b/spine-cpp/spine-cpp/src/spine/Triangulator.cpp @@ -221,7 +221,7 @@ Vector *> &Triangulator::decompose(Vector &vertices, Vector float secondX = p[2], secondY = p[3]; int winding0 = winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY); - for (int ii = 0; ii < n; ++ii) { + for (size_t ii = 0; ii < n; ++ii) { if (ii == i) { continue; } diff --git a/spine-cpp/spine-cpp/src/spine/VertexAttachment.cpp b/spine-cpp/spine-cpp/src/spine/VertexAttachment.cpp index b6748acc0..8aeae1698 100644 --- a/spine-cpp/spine-cpp/src/spine/VertexAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/VertexAttachment.cpp @@ -49,13 +49,13 @@ void VertexAttachment::computeWorldVertices(Slot &slot, Vector &worldVert computeWorldVertices(slot, 0, _worldVerticesLength, worldVertices, 0); } -void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Vector &worldVertices, int offset, - int stride) { +void VertexAttachment::computeWorldVertices(Slot &slot, size_t start, size_t count, Vector &worldVertices, size_t offset, + size_t stride) { count = offset + (count >> 1) * stride; Skeleton &skeleton = slot._bone._skeleton; Vector *deformArray = &slot.getAttachmentVertices(); Vector *vertices = &_vertices; - Vector &bones = _bones; + Vector &bones = _bones; if (bones.size() == 0) { if (deformArray->size() > 0) { vertices = deformArray; @@ -65,7 +65,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve float x = bone._worldX; float y = bone._worldY; float a = bone._a, b = bone._b, c = bone._c, d = bone._d; - for (int vv = start, w = offset; w < count; vv += 2, w += stride) { + for (size_t vv = start, w = offset; w < count; vv += 2, w += stride) { float vx = (*vertices)[vv]; float vy = (*vertices)[vv + 1]; worldVertices[w] = vx * a + vy * b + x; @@ -75,7 +75,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve } int v = 0, skip = 0; - for (int i = 0; i < start; i += 2) { + for (size_t i = 0; i < start; i += 2) { int n = bones[v]; v += n + 1; skip += n; @@ -83,7 +83,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve Vector &skeletonBones = skeleton.getBones(); if (deformArray->size() == 0) { - for (int w = offset, b = skip * 3; w < count; w += stride) { + for (size_t w = offset, b = skip * 3; w < count; w += stride) { float wx = 0, wy = 0; int n = bones[v++]; n += v; @@ -100,7 +100,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve worldVertices[w + 1] = wy; } } else { - for (int w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) { + for (size_t w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) { float wx = 0, wy = 0; int n = bones[v++]; n += v; @@ -127,7 +127,7 @@ int VertexAttachment::getId() { return _id; } -Vector &VertexAttachment::getBones() { +Vector &VertexAttachment::getBones() { return _bones; } @@ -135,11 +135,11 @@ Vector &VertexAttachment::getVertices() { return _vertices; } -int VertexAttachment::getWorldVerticesLength() { +size_t VertexAttachment::getWorldVerticesLength() { return _worldVerticesLength; } -void VertexAttachment::setWorldVerticesLength(int inValue) { +void VertexAttachment::setWorldVerticesLength(size_t inValue) { _worldVerticesLength = inValue; } diff --git a/spine-sfml/cpp/example/main.cpp b/spine-sfml/cpp/example/main.cpp index ce8415a86..ac37f6d51 100644 --- a/spine-sfml/cpp/example/main.cpp +++ b/spine-sfml/cpp/example/main.cpp @@ -453,10 +453,10 @@ void test (SkeletonData* skeletonData, Atlas* atlas) { int main () { DebugExtension dbgExtension; - // SpineExtension::setInstance(&dbgExtension); + SpineExtension::setInstance(&dbgExtension); - // testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f); - // testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f); + testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f); + testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f); testcase(spineboy, "data/spineboy-ess.json", "data/spineboy-ess.skel", "data/spineboy.atlas", 0.6f); testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl.atlas", 0.5f); testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f); @@ -465,6 +465,6 @@ int main () { testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f); testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins.atlas", 1.4f); testcase(stretchyman, "data/stretchyman-pro.json", "data/stretchyman-pro.skel", "data/stretchyman.atlas", 0.6f); - // dbgExtension.reportLeaks(); + dbgExtension.reportLeaks(); return 0; }