1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-29 03:33:48 +00:00

Fix some more warnings

This commit is contained in:
Valentin Ochs 2017-01-14 18:23:53 +01:00
parent fe0ab0418b
commit 4dc7e27ee6
11 changed files with 24 additions and 29 deletions

View file

@ -84,7 +84,7 @@ void AquariaComboBox::setScroll(size_t sc)
std::string AquariaComboBox::getSelectedItemString() std::string AquariaComboBox::getSelectedItemString()
{ {
if (selectedItem >= 0 && selectedItem < items.size()) if (selectedItem < items.size())
return items[selectedItem]; return items[selectedItem];
return ""; return "";
} }

View file

@ -495,7 +495,7 @@ void Continuity::setFishPoison(float m, float t)
std::string Continuity::getIEString(IngredientData *data, size_t i) 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]; IngredientEffect fx = data->effects[i];
IngredientEffectType useType = fx.type; IngredientEffectType useType = fx.type;
@ -2284,7 +2284,7 @@ void Continuity::loadPetData()
PetData *Continuity::getPetData(size_t idx) PetData *Continuity::getPetData(size_t idx)
{ {
if (idx < 0 || idx >= petData.size()) if (idx >= petData.size())
{ {
std::ostringstream os; std::ostringstream os;
os << "getPetData(" << idx << ") index out of range"; os << "getPetData(" << idx << ") index out of range";

View file

@ -2875,7 +2875,7 @@ void DSQ::prevSaveSlotPage()
if (saveSlots.empty()) return; if (saveSlots.empty()) return;
user.data.savePage--; user.data.savePage--;
if (user.data.savePage < 0) if (user.data.savePage > maxPages)
user.data.savePage = maxPages; user.data.savePage = maxPages;
createSaveSlotPage(); createSaveSlotPage();

View file

@ -1468,7 +1468,7 @@ void SceneEditor::mouseButtonLeft()
{ {
Path *p = getSelectedPath(); Path *p = getSelectedPath();
editingPath = p; editingPath = p;
if (p && selectedNode >= 0 && selectedNode < p->nodes.size()) if (p && selectedNode < p->nodes.size())
{ {
if (core->getShiftState()) if (core->getShiftState())
{ {
@ -2317,7 +2317,7 @@ void nextEntityPage()
void prevEntityPage() void prevEntityPage()
{ {
game->sceneEditor.entityPageNum--; game->sceneEditor.entityPageNum--;
if (game->sceneEditor.entityPageNum < 0) if (game->sceneEditor.entityPageNum >= game->entityGroups.size())
game->sceneEditor.entityPageNum = game->entityGroups.size()-1; game->sceneEditor.entityPageNum = game->entityGroups.size()-1;
createEntityPage(); createEntityPage();
@ -2540,12 +2540,9 @@ void SceneEditor::doPrevElement()
{ {
int oldCur = curElement; int oldCur = curElement;
curElement--; curElement--;
if (curElement < 0) if (curElement >= game->elementTemplates.size())
curElement = dsq->game->elementTemplates.size()-1; curElement = dsq->game->elementTemplates.size()-1;
if (curElement < 0)
return;
if (dsq->game->elementTemplates[curElement].idx < 1024) if (dsq->game->elementTemplates[curElement].idx < 1024)
{ {
placer->setTexture(dsq->game->elementTemplates[curElement].gfx); placer->setTexture(dsq->game->elementTemplates[curElement].gfx);
@ -3106,8 +3103,7 @@ void SceneEditor::update(float dt)
} }
break; break;
case ES_MOVING: 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; break;
case ES_ROTATING: case ES_ROTATING:
case ES_MAX: case ES_MAX:

View file

@ -8484,7 +8484,7 @@ luaFunc(setGemBlink)
size_t gemId = lua_tointeger(L, 1); size_t gemId = lua_tointeger(L, 1);
bool result = false; 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(); Continuity::Gems::iterator it = dsq->continuity.gems.begin();
std::advance(it, gemId); std::advance(it, gemId);
@ -8501,7 +8501,7 @@ luaFunc(setGemBlink)
luaFunc(removeGem) luaFunc(removeGem)
{ {
size_t gemId = lua_tointeger(L, 1); 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(); Continuity::Gems::iterator it = dsq->continuity.gems.begin();
std::advance(it, gemId); std::advance(it, gemId);

View file

@ -199,7 +199,7 @@ void ScriptedEntity::initSegments(int numSegments, int minDist, int maxDist, std
this->minDist = minDist; this->minDist = minDist;
this->maxDist = maxDist; this->maxDist = maxDist;
segments.resize(numSegments); 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; Quad *q = new Quad;
if (i == segments.size()-1) if (i == segments.size()-1)

View file

@ -281,12 +281,9 @@ void BitmapText::onUpdate(float dt)
Vector BitmapText::getColorIndex(size_t i, size_t j) Vector BitmapText::getColorIndex(size_t i, size_t j)
{ {
Vector c(1,1,1); 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; return c;
} }

View file

@ -207,14 +207,16 @@ void ParticleManager::nextFree(int jump)
void ParticleManager::prevFree(int jump) void ParticleManager::prevFree(int jump)
{ {
free -= jump; if(free < jump) {
if (free < 0) free = free + size - jump;
free += size; } else {
free -= jump;
}
} }
void ParticleManager::setFree(int free) void ParticleManager::setFree(size_t free)
{ {
if (free != -1) if (free != ~0UL)
{ {
this->free = free; this->free = free;
} }

View file

@ -217,7 +217,7 @@ public:
void endParticle(Particle *p); void endParticle(Particle *p);
void setFree(int free); void setFree(size_t free);
int getFree() { return free; } int getFree() { return free; }
int getNumActive() { return numActive; } int getNumActive() { return numActive; }

View file

@ -106,7 +106,7 @@ void Quad::createGrid(int xd, int yd)
void Quad::setDrawGridAlpha(size_t x, size_t y, float alpha) 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; drawGrid[x][y].z = alpha;
} }

View file

@ -1093,7 +1093,7 @@ void SkeletalSprite::prevAnimation()
{ {
stopAnimation(); stopAnimation();
animLayers[0].currentAnimation--; animLayers[0].currentAnimation--;
if (animLayers[0].currentAnimation < 0) if (animLayers[0].currentAnimation >= animations.size())
animLayers[0].currentAnimation = animations.size()-1; animLayers[0].currentAnimation = animations.size()-1;
} }
@ -1878,7 +1878,7 @@ void SkeletalSprite::selectNextBone()
selectedBone--; selectedBone--;
if(selectedBone == oldsel) if(selectedBone == oldsel)
break; break;
if (selectedBone < 0) if (selectedBone >= bones.size())
selectedBone = bones.size()-1; selectedBone = bones.size()-1;
} }
while (!bones[selectedBone]->selectable); while (!bones[selectedBone]->selectable);