diff --git a/Aquaria/AquariaComboBox.cpp b/Aquaria/AquariaComboBox.cpp index 803af98..4b5ba97 100644 --- a/Aquaria/AquariaComboBox.cpp +++ b/Aquaria/AquariaComboBox.cpp @@ -84,7 +84,7 @@ void AquariaComboBox::setScroll(size_t sc) std::string AquariaComboBox::getSelectedItemString() { - if (selectedItem >= 0 && selectedItem < items.size()) + if (selectedItem < items.size()) return items[selectedItem]; return ""; } diff --git a/Aquaria/Continuity.cpp b/Aquaria/Continuity.cpp index 1fef254..101ff74 100644 --- a/Aquaria/Continuity.cpp +++ b/Aquaria/Continuity.cpp @@ -495,7 +495,7 @@ void Continuity::setFishPoison(float m, float t) std::string Continuity::getIEString(IngredientData *data, size_t i) { - if (i < 0 || i >= data->effects.size()) return ""; + if (i >= data->effects.size()) return ""; IngredientEffect fx = data->effects[i]; IngredientEffectType useType = fx.type; @@ -2284,7 +2284,7 @@ void Continuity::loadPetData() PetData *Continuity::getPetData(size_t idx) { - if (idx < 0 || idx >= petData.size()) + if (idx >= petData.size()) { std::ostringstream os; os << "getPetData(" << idx << ") index out of range"; diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index e7543a7..5c495f3 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -2875,7 +2875,7 @@ void DSQ::prevSaveSlotPage() if (saveSlots.empty()) return; user.data.savePage--; - if (user.data.savePage < 0) + if (user.data.savePage > maxPages) user.data.savePage = maxPages; createSaveSlotPage(); diff --git a/Aquaria/SceneEditor.cpp b/Aquaria/SceneEditor.cpp index e4d9e69..fc1ecbf 100644 --- a/Aquaria/SceneEditor.cpp +++ b/Aquaria/SceneEditor.cpp @@ -1468,7 +1468,7 @@ void SceneEditor::mouseButtonLeft() { Path *p = getSelectedPath(); editingPath = p; - if (p && selectedNode >= 0 && selectedNode < p->nodes.size()) + if (p && selectedNode < p->nodes.size()) { if (core->getShiftState()) { @@ -2317,7 +2317,7 @@ void nextEntityPage() void prevEntityPage() { game->sceneEditor.entityPageNum--; - if (game->sceneEditor.entityPageNum < 0) + if (game->sceneEditor.entityPageNum >= game->entityGroups.size()) game->sceneEditor.entityPageNum = game->entityGroups.size()-1; createEntityPage(); @@ -2540,12 +2540,9 @@ void SceneEditor::doPrevElement() { int oldCur = curElement; curElement--; - if (curElement < 0) + if (curElement >= game->elementTemplates.size()) curElement = dsq->game->elementTemplates.size()-1; - if (curElement < 0) - return; - if (dsq->game->elementTemplates[curElement].idx < 1024) { placer->setTexture(dsq->game->elementTemplates[curElement].gfx); @@ -3106,8 +3103,7 @@ void SceneEditor::update(float dt) } break; case ES_MOVING: - if (selectedIdx >= 0) - dsq->game->getPath(selectedIdx)->nodes[selectedNode].position = dsq->getGameCursorPosition() + cursorOffset; + dsq->game->getPath(selectedIdx)->nodes[selectedNode].position = dsq->getGameCursorPosition() + cursorOffset; break; case ES_ROTATING: case ES_MAX: diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 3518fea..481d36f 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -8484,7 +8484,7 @@ luaFunc(setGemBlink) size_t gemId = lua_tointeger(L, 1); bool result = false; - if(gemId >= 0 && gemId < dsq->continuity.gems.size()) + if(gemId < dsq->continuity.gems.size()) { Continuity::Gems::iterator it = dsq->continuity.gems.begin(); std::advance(it, gemId); @@ -8501,7 +8501,7 @@ luaFunc(setGemBlink) luaFunc(removeGem) { size_t gemId = lua_tointeger(L, 1); - if(gemId >= 0 && gemId < dsq->continuity.gems.size()) + if(gemId < dsq->continuity.gems.size()) { Continuity::Gems::iterator it = dsq->continuity.gems.begin(); std::advance(it, gemId); diff --git a/Aquaria/ScriptedEntity.cpp b/Aquaria/ScriptedEntity.cpp index 4ae58be..a692a80 100644 --- a/Aquaria/ScriptedEntity.cpp +++ b/Aquaria/ScriptedEntity.cpp @@ -199,7 +199,7 @@ void ScriptedEntity::initSegments(int numSegments, int minDist, int maxDist, std this->minDist = minDist; this->maxDist = maxDist; segments.resize(numSegments); - for (size_t i = segments.size()-1; i >= 0 ; i--) + for (size_t i = segments.size(); i-- >= 0 ; ) { Quad *q = new Quad; if (i == segments.size()-1) diff --git a/BBGE/BitmapFont.cpp b/BBGE/BitmapFont.cpp index 4323334..1e43482 100644 --- a/BBGE/BitmapFont.cpp +++ b/BBGE/BitmapFont.cpp @@ -281,12 +281,9 @@ void BitmapText::onUpdate(float dt) Vector BitmapText::getColorIndex(size_t i, size_t j) { Vector c(1,1,1); - if (!(i < 0 || j < 0)) + if ( i < colorIndices.size() && j < colorIndices[i].size()) { - if ( i < colorIndices.size() && j < colorIndices[i].size()) - { - c = colorIndices[i][j]; - } + c = colorIndices[i][j]; } return c; } diff --git a/BBGE/ParticleManager.cpp b/BBGE/ParticleManager.cpp index b6e24ae..ac67281 100644 --- a/BBGE/ParticleManager.cpp +++ b/BBGE/ParticleManager.cpp @@ -207,14 +207,16 @@ void ParticleManager::nextFree(int jump) void ParticleManager::prevFree(int jump) { - free -= jump; - if (free < 0) - free += size; + if(free < jump) { + free = free + size - jump; + } else { + free -= jump; + } } -void ParticleManager::setFree(int free) +void ParticleManager::setFree(size_t free) { - if (free != -1) + if (free != ~0UL) { this->free = free; } diff --git a/BBGE/Particles.h b/BBGE/Particles.h index 9f8b244..7ce9503 100644 --- a/BBGE/Particles.h +++ b/BBGE/Particles.h @@ -217,7 +217,7 @@ public: void endParticle(Particle *p); - void setFree(int free); + void setFree(size_t free); int getFree() { return free; } int getNumActive() { return numActive; } diff --git a/BBGE/Quad.cpp b/BBGE/Quad.cpp index 87abfb7..2ae330f 100644 --- a/BBGE/Quad.cpp +++ b/BBGE/Quad.cpp @@ -106,7 +106,7 @@ void Quad::createGrid(int xd, int yd) void Quad::setDrawGridAlpha(size_t x, size_t y, float alpha) { - if (x < xDivs && x >= 0 && y < yDivs && y >= 0) + if (x < xDivs && y < yDivs) { drawGrid[x][y].z = alpha; } diff --git a/BBGE/SkeletalSprite.cpp b/BBGE/SkeletalSprite.cpp index b292bd0..597605b 100644 --- a/BBGE/SkeletalSprite.cpp +++ b/BBGE/SkeletalSprite.cpp @@ -1093,7 +1093,7 @@ void SkeletalSprite::prevAnimation() { stopAnimation(); animLayers[0].currentAnimation--; - if (animLayers[0].currentAnimation < 0) + if (animLayers[0].currentAnimation >= animations.size()) animLayers[0].currentAnimation = animations.size()-1; } @@ -1878,7 +1878,7 @@ void SkeletalSprite::selectNextBone() selectedBone--; if(selectedBone == oldsel) break; - if (selectedBone < 0) + if (selectedBone >= bones.size()) selectedBone = bones.size()-1; } while (!bones[selectedBone]->selectable);