diff --git a/Aquaria/Hair.cpp b/Aquaria/Hair.cpp index 8944623..e7111bc 100644 --- a/Aquaria/Hair.cpp +++ b/Aquaria/Hair.cpp @@ -148,7 +148,7 @@ void Hair::updatePositions() void Hair::exertForce(const Vector &force, float dt, int usePerc) { const Vector f = force * dt; - for (int i = hairNodes.size()-1; i >= 1; i--) + for (size_t i = hairNodes.size(); i --> 1; ) { switch (usePerc) { diff --git a/Aquaria/ScriptedEntity.cpp b/Aquaria/ScriptedEntity.cpp index 802b806..34d16f3 100644 --- a/Aquaria/ScriptedEntity.cpp +++ b/Aquaria/ScriptedEntity.cpp @@ -46,7 +46,6 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E layer = LR_ENTITIES; surfaceMoveDir = 1; this->position = position; - numSegments = 0; reverseSegments = false; manaBallAmount = 1; this->name = scriptName; @@ -189,7 +188,6 @@ void ScriptedEntity::registerNewPart(RenderObject *r, const std::string &name) void ScriptedEntity::initSegments(int numSegments, int minDist, int maxDist, std::string bodyTex, std::string tailTex, int w, int h, float taper, bool reverseSegments) { this->reverseSegments = reverseSegments; - this->numSegments = numSegments; this->minDist = minDist; this->maxDist = maxDist; segments.resize(numSegments); @@ -502,7 +500,7 @@ void ScriptedEntity::onUpdate(float dt) debugLog(name + " : update : " + script->getLastError()); } - if (numSegments > 0) + if (!segments.empty()) { updateSegments(position, reverseSegments); updateAlpha(alpha.x); diff --git a/Aquaria/Segmented.cpp b/Aquaria/Segmented.cpp index 0f232b9..7e6cc0f 100644 --- a/Aquaria/Segmented.cpp +++ b/Aquaria/Segmented.cpp @@ -38,7 +38,6 @@ void Segmented::initSegments(const Vector &position) { for (size_t i = 0; i < segments.size(); i++) segments[i]->position = position; - numSegments = segments.size(); } void Segmented::destroySegments(float life) diff --git a/Aquaria/Segmented.h b/Aquaria/Segmented.h index 7ab31c9..246b33d 100644 --- a/Aquaria/Segmented.h +++ b/Aquaria/Segmented.h @@ -40,7 +40,6 @@ protected: void updateSegment(int i, const Vector &diff); void destroySegments(float life = 0.01f); std::vector lastPositions; - int numSegments; std::vector segments; }; diff --git a/Aquaria/Shot.cpp b/Aquaria/Shot.cpp index a799196..7be823f 100644 --- a/Aquaria/Shot.cpp +++ b/Aquaria/Shot.cpp @@ -309,7 +309,7 @@ void loadShotCallback(const std::string &filename, void *param) ShotData shotData; std::string ident; - int first = filename.find_last_of('/')+1; + size_t first = filename.find_last_of('/')+1; ident = filename.substr(first, filename.find_last_of('.')-first); stringToLower(ident); debugLog(ident); @@ -385,7 +385,7 @@ void Shot::applyShotData(const ShotData& shotData) if (shotData.numSegs > 0) { segments.resize(shotData.numSegs); - for (int i = segments.size()-1; i >=0 ; i--) + for (size_t i = segments.size(); i --> 0; ) { Quad *flame = new Quad; flame->setTexture(shotData.segTexture); @@ -669,7 +669,7 @@ void Shot::hitEntity(Entity *e, Bone *b) void Shot::noSegs() { - if (numSegments > 0) + if (!segments.empty()) { destroySegments(); } diff --git a/Aquaria/Shot.h b/Aquaria/Shot.h index cc323de..8c0ff15 100644 --- a/Aquaria/Shot.h +++ b/Aquaria/Shot.h @@ -149,7 +149,7 @@ protected: bool updateScript; private: - unsigned int shotIdx; + size_t shotIdx; }; #endif diff --git a/Aquaria/SteamRender.cpp b/Aquaria/SteamRender.cpp index cf53be9..3d72fe2 100644 --- a/Aquaria/SteamRender.cpp +++ b/Aquaria/SteamRender.cpp @@ -44,12 +44,12 @@ void SteamRender::onRender(const RenderState& rs) const if (p->active) { - int w2 = p->rect.getWidth()/2; + const float w2 = p->rect.getWidth()/2; if (true) { - const int sz = p->nodes.size()-1; - for (int n = 0; n < sz; n++) + const size_t sz = p->nodes.size()-1; + for (size_t n = 0; n < sz; n++) { const PathNode *n1 = &p->nodes[n]; const PathNode *n2 = &p->nodes[n+1]; diff --git a/Aquaria/Strand.cpp b/Aquaria/Strand.cpp index dbe9d48..6638daa 100644 --- a/Aquaria/Strand.cpp +++ b/Aquaria/Strand.cpp @@ -51,7 +51,7 @@ void Strand::onUpdate(float dt) void Strand::onRender(const RenderState& rs) const { - const int numSegments = segments.size(); + const size_t numSegments = segments.size(); if (numSegments == 0) return; glTranslatef(-position.x, -position.y, 0); @@ -71,8 +71,8 @@ void Strand::onRender(const RenderState& rs) const glColor4ub(r>>8, g>>8, b>>8, a>>8); glVertex2f(position.x, position.y); glVertex2f(segments[0]->position.x, segments[0]->position.y); - const int colorLimit = numSegments<50 ? numSegments : 50; - int i; + const size_t colorLimit = numSegments<50 ? numSegments : 50; + size_t i; for (i = 1; i < colorLimit; i++) { r -= dr; diff --git a/Aquaria/Web.cpp b/Aquaria/Web.cpp index e6d353c..cb26d09 100644 --- a/Aquaria/Web.cpp +++ b/Aquaria/Web.cpp @@ -61,7 +61,7 @@ void Web::setExistence(float t) existence = t; } -int Web::addPoint(const Vector &point) +size_t Web::addPoint(const Vector &point) { points.push_back(point); return points.size()-1; @@ -81,7 +81,7 @@ Vector Web::getPoint(size_t pt) const return v; } -int Web::getNumPoints() +size_t Web::getNumPoints() const { return points.size(); } diff --git a/Aquaria/Web.h b/Aquaria/Web.h index 56a6459..cfd2b52 100644 --- a/Aquaria/Web.h +++ b/Aquaria/Web.h @@ -29,11 +29,11 @@ class Web : public RenderObject { public: Web(); - int addPoint(const Vector &point = Vector(0,0)); + size_t addPoint(const Vector &point = Vector(0,0)); void setPoint(size_t pt, const Vector &v); Vector getPoint(size_t pt) const; void setParentEntity(Entity *e); - int getNumPoints(); + size_t getNumPoints() const; typedef std::list Webs; static Webs webs; static void killAllWebs(); diff --git a/BBGE/Vector.cpp b/BBGE/Vector.cpp index ad163ae..77d3558 100644 --- a/BBGE/Vector.cpp +++ b/BBGE/Vector.cpp @@ -230,7 +230,7 @@ void VectorPath::splice(const VectorPath &path, int sz) } } -void VectorPath::removeNodes(unsigned int startInclusive, unsigned int endInclusive) +void VectorPath::removeNodes(size_t startInclusive, size_t endInclusive) { // end iterator is exclusive, so max. end + 1 pathNodes.erase(pathNodes.begin() + startInclusive, pathNodes.begin() + std::min(pathNodes.size(), endInclusive+1)); diff --git a/BBGE/Vector.h b/BBGE/Vector.h index 81e3f26..9145213 100644 --- a/BBGE/Vector.h +++ b/BBGE/Vector.h @@ -391,7 +391,7 @@ public: void calculatePercentages(); float getLength(); void realPercentageCalc(); - void removeNodes(unsigned int startInclusive, unsigned int endInclusive); + void removeNodes(size_t startInclusive, size_t endInclusive); float getSubSectionLength(int startIncl, int endIncl); protected: std::vector pathNodes;