From 25d3019d1a7d50d89f7e2b8b32fee0ac27001c31 Mon Sep 17 00:00:00 2001 From: Ahmed Samy Date: Thu, 14 Nov 2013 00:02:47 +0200 Subject: [PATCH] force use of template version of std::min/max --- src/client/creature.cpp | 16 +++++++-------- src/client/effect.cpp | 2 +- src/client/game.h | 2 +- src/client/lightview.cpp | 2 +- src/client/localplayer.cpp | 4 ++-- src/client/map.cpp | 4 ++-- src/client/mapview.cpp | 20 +++++++++---------- src/client/minimap.cpp | 2 +- src/client/protocolgameparse.cpp | 2 +- src/client/thingtype.cpp | 12 +++++------ src/client/tile.cpp | 4 ++-- src/client/uiitem.cpp | 4 ++-- src/client/uimap.cpp | 2 +- src/client/uiprogressrect.cpp | 12 +++++------ src/framework/core/adaptativeframecounter.cpp | 2 +- src/framework/graphics/bitmapfont.cpp | 2 +- src/framework/graphics/framebuffer.cpp | 4 ++-- 17 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/client/creature.cpp b/src/client/creature.cpp index ffd29814..6ca550c8 100644 --- a/src/client/creature.cpp +++ b/src/client/creature.cpp @@ -70,13 +70,13 @@ void Creature::draw(const Point& dest, float scaleFactor, bool animate, LightVie if(m_showTimedSquare && animate) { g_painter->setColor(m_timedSquareColor); - g_painter->drawBoundingRect(Rect(dest + (animationOffset - getDisplacement() + 2)*scaleFactor, Size(28, 28)*scaleFactor), std::max((int)(2*scaleFactor), 1)); + g_painter->drawBoundingRect(Rect(dest + (animationOffset - getDisplacement() + 2)*scaleFactor, Size(28, 28)*scaleFactor), std::max((int)(2*scaleFactor), 1)); g_painter->setColor(Color::white); } if(m_showStaticSquare && animate) { g_painter->setColor(m_staticSquareColor); - g_painter->drawBoundingRect(Rect(dest + (animationOffset - getDisplacement())*scaleFactor, Size(Otc::TILE_PIXELS, Otc::TILE_PIXELS)*scaleFactor), std::max((int)(2*scaleFactor), 1)); + g_painter->drawBoundingRect(Rect(dest + (animationOffset - getDisplacement())*scaleFactor, Size(Otc::TILE_PIXELS, Otc::TILE_PIXELS)*scaleFactor), std::max((int)(2*scaleFactor), 1)); g_painter->setColor(Color::white); } @@ -171,7 +171,7 @@ void Creature::internalDrawOutfit(Point dest, float scaleFactor, bool animateWal // when creature is an effect we cant render the first and last animation phase, // instead we should loop in the phases between if(m_outfit.getCategory() == ThingCategoryEffect) { - animationPhases = std::max(1, animationPhases-2); + animationPhases = std::max(1, animationPhases-2); animateTicks = Otc::INVISIBLE_TICKS_PER_FRAME; } @@ -372,7 +372,7 @@ void Creature::updateJump() int nextT, i = 1; do { - nextT = stdext::round((-b + std::sqrt(std::max(b*b + 4*a*(roundHeight+diff*i), 0.0)) * diff) / (2*a)); + nextT = stdext::round((-b + std::sqrt(std::max(b*b + 4*a*(roundHeight+diff*i), 0.0)) * diff) / (2*a)); ++i; if(nextT < halfJumpDuration) @@ -556,7 +556,7 @@ void Creature::updateWalk() int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f); // needed for paralyze effect - m_walkedPixels = std::max(m_walkedPixels, totalPixelsWalked); + m_walkedPixels = std::max(m_walkedPixels, totalPixelsWalked); // update walk animation and offsets updateWalkAnimation(totalPixelsWalked); @@ -820,7 +820,7 @@ int Creature::getStepDuration(bool ignoreDiagonal, Otc::Direction dir) if(g_game.getFeature(Otc::GameNewSpeedLaw) && hasSpeedFormula()) { int formulatedSpeed = 1; if(speed > -m_speedFormula[Otc::SpeedFormulaB]) { - formulatedSpeed = std::max(1, (int)floor((m_speedFormula[Otc::SpeedFormulaA] * log((speed / 2) + formulatedSpeed = std::max(1, (int)floor((m_speedFormula[Otc::SpeedFormulaA] * log((speed / 2) + m_speedFormula[Otc::SpeedFormulaB]) + m_speedFormula[Otc::SpeedFormulaC]) + 0.5)); } interval = std::floor(interval / (double)formulatedSpeed); @@ -835,7 +835,7 @@ int Creature::getStepDuration(bool ignoreDiagonal, Otc::Direction dir) if(g_game.getProtocolVersion() <= 810) factor = 2; - interval = std::max(interval, g_game.getServerBeat()); + interval = std::max(interval, g_game.getServerBeat()); if(!ignoreDiagonal && (m_lastStepDirection == Otc::NorthWest || m_lastStepDirection == Otc::NorthEast || m_lastStepDirection == Otc::SouthWest || m_lastStepDirection == Otc::SouthEast)) @@ -887,7 +887,7 @@ int Creature::getExactSize(int layer, int xPattern, int yPattern, int zPattern, continue; for(layer = 0; layer < getLayers(); ++layer) - exactSize = std::max(exactSize, Thing::getExactSize(layer, xPattern, yPattern, zPattern, animationPhase)); + exactSize = std::max(exactSize, Thing::getExactSize(layer, xPattern, yPattern, zPattern, animationPhase)); } return exactSize; diff --git a/src/client/effect.cpp b/src/client/effect.cpp index 4fb1e777..81dd9b0d 100644 --- a/src/client/effect.cpp +++ b/src/client/effect.cpp @@ -31,7 +31,7 @@ void Effect::draw(const Point& dest, float scaleFactor, bool animate, LightView int animationPhase = 0; if(animate) - animationPhase = std::min((int)(m_animationTimer.ticksElapsed() / m_phaseDuration), getAnimationPhases() - 1); + animationPhase = std::min((int)(m_animationTimer.ticksElapsed() / m_phaseDuration), getAnimationPhases() - 1); rawGetThingType()->draw(dest, scaleFactor, 0, 0, 0, 0, animationPhase, lightView); } diff --git a/src/client/game.h b/src/client/game.h index a142374b..c9bdc317 100644 --- a/src/client/game.h +++ b/src/client/game.h @@ -287,7 +287,7 @@ public: bool isFollowing() { return !!m_followingCreature; } bool isConnectionOk() { return m_protocolGame && m_protocolGame->getElapsedTicksSinceLastRead() < 5000; } - int getPing() { return m_ping >= 0 ? std::max(m_ping, m_pingTimer.elapsed_millis()) : -1; } + int getPing() { return m_ping >= 0 ? std::max(m_ping, m_pingTimer.elapsed_millis()) : -1; } ContainerPtr getContainer(int index) { return m_containers[index]; } std::map getContainers() { return m_containers; } std::map getVips() { return m_vips; } diff --git a/src/client/lightview.cpp b/src/client/lightview.cpp index ff63c177..b347e8c8 100644 --- a/src/client/lightview.cpp +++ b/src/client/lightview.cpp @@ -50,7 +50,7 @@ TexturePtr LightView::generateLightBubble(float centerFactor) for(int x = 0; x < bubbleDiameter; x++) { for(int y = 0; y < bubbleDiameter; y++) { float radius = std::sqrt((bubbleRadius - x)*(bubbleRadius - x) + (bubbleRadius - y)*(bubbleRadius - y)); - float intensity = std::max(std::min((bubbleRadius-radius)/(float)(bubbleRadius-centerRadius), 1.0f), 0.0f); + float intensity = std::max(std::min((bubbleRadius-radius)/(float)(bubbleRadius-centerRadius), 1.0f), 0.0f); // light intensity varies inversely with the square of the distance intensity = intensity * intensity; diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp index f03b5eb8..933084d6 100644 --- a/src/client/localplayer.cpp +++ b/src/client/localplayer.cpp @@ -58,7 +58,7 @@ LocalPlayer::LocalPlayer() void LocalPlayer::lockWalk(int millis) { - m_walkLockExpiration = std::max(m_walkLockExpiration, (ticks_t) g_clock.millis() + millis); + m_walkLockExpiration = std::max(m_walkLockExpiration, (ticks_t) g_clock.millis() + millis); } bool LocalPlayer::canWalk(Otc::Direction direction) @@ -263,7 +263,7 @@ void LocalPlayer::updateWalk() { int stepDuration = getStepDuration(); float walkTicksPerPixel = getStepDuration(true) / 32.0f; - int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f); + int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f); // update walk animation and offsets updateWalkAnimation(totalPixelsWalked); diff --git a/src/client/map.cpp b/src/client/map.cpp index e4f5adb3..d6bcba4f 100644 --- a/src/client/map.cpp +++ b/src/client/map.cpp @@ -138,7 +138,7 @@ void Map::addThing(const ThingPtr& thing, const Position& pos, int stackPos) int y = 12 - 48 * t / (float)Otc::ANIMATED_TEXT_DURATION; offset += Point(0, y); } - offset.y = std::min(offset.y, 12); + offset.y = std::min(offset.y, 12); animatedText->setOffset(offset); } m_animatedTexts.push_back(animatedText); @@ -615,7 +615,7 @@ int Map::getFirstAwareFloor() int Map::getLastAwareFloor() { if(m_centralPosition.z > Otc::SEA_FLOOR) - return std::min(m_centralPosition.z+Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::MAX_Z); + return std::min(m_centralPosition.z+Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::MAX_Z); else return Otc::SEA_FLOOR; } diff --git a/src/client/mapview.cpp b/src/client/mapview.cpp index 2a3830d7..36246a0b 100644 --- a/src/client/mapview.cpp +++ b/src/client/mapview.cpp @@ -159,7 +159,7 @@ void MapView::draw(const Rect& rect) } if(m_shaderSwitchDone && m_shader && m_fadeInTime > 0) - fadeOpacity = std::min(m_fadeTimer.timeElapsed() / m_fadeInTime, 1.0f); + fadeOpacity = std::min(m_fadeTimer.timeElapsed() / m_fadeInTime, 1.0f); Rect srcRect = calcFramebufferSource(rect.size()); Point drawOffset = srcRect.topLeft(); @@ -311,7 +311,7 @@ void MapView::updateVisibleTilesCache(int start) // loop through / diagonals beginning at top left and going to top right for(int diagonal = 0; diagonal < numDiagonals && !stop; ++diagonal) { // loop current diagonal tiles - int advance = std::max(diagonal - m_drawDimension.height(), 0); + int advance = std::max(diagonal - m_drawDimension.height(), 0); for(int iy = diagonal - advance, ix = advance; iy >= 0 && ix < m_drawDimension.width() && !stop; --iy, ++ix) { // only start really looking tiles in the desired start if(m_updateTilesPos < start) { @@ -364,10 +364,10 @@ void MapView::updateVisibleTilesCache(int start) }; for(int i=0;i<4;++i) { - int sx = std::max(lines[i].left(), area.left()); - int ex = std::min(lines[i].right(), area.right()); - int sy = std::max(lines[i].top(), area.top()); - int ey = std::min(lines[i].bottom(), area.bottom()); + int sx = std::max(lines[i].left(), area.left()); + int ex = std::min(lines[i].right(), area.right()); + int sy = std::max(lines[i].top(), area.top()); + int ey = std::min(lines[i].bottom(), area.bottom()); for(int qx=sx;qx<=ex;++qx) for(int qy=sy;qy<=ey;++qy) m_spiral[count++] = Point(qx, qy); @@ -608,7 +608,7 @@ int MapView::calcFirstVisibleFloor() // limits to underground floors while under sea level if(cameraPosition.z > Otc::SEA_FLOOR) - firstFloor = std::max(cameraPosition.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::UNDERGROUND_FLOOR); + firstFloor = std::max(cameraPosition.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::UNDERGROUND_FLOOR); // loop in 3x3 tiles around the camera for(int ix = -1; ix <= 1 && firstFloor < cameraPosition.z; ++ix) { @@ -644,7 +644,7 @@ int MapView::calcFirstVisibleFloor() } // just ensure the that the floor is in the valid range - z = std::min(std::max(z, 0), (int)Otc::MAX_Z); + z = std::min(std::max(z, 0), (int)Otc::MAX_Z); return z; } @@ -666,10 +666,10 @@ int MapView::calcLastVisibleFloor() } if(m_lockedFirstVisibleFloor != -1) - z = std::max(m_lockedFirstVisibleFloor, z); + z = std::max(m_lockedFirstVisibleFloor, z); // just ensure the that the floor is in the valid range - z = std::min(std::max(z, 0), (int)Otc::MAX_Z); + z = std::min(std::max(z, 0), (int)Otc::MAX_Z); return z; } diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp index 50649de1..8de14518 100644 --- a/src/client/minimap.cpp +++ b/src/client/minimap.cpp @@ -200,7 +200,7 @@ void Minimap::updateTile(const Position& pos, const TilePtr& tile) minimapTile.flags |= MinimapTileNotWalkable; if(!tile->isPathable()) minimapTile.flags |= MinimapTileNotPathable; - minimapTile.speed = std::min((int)std::ceil(tile->getGroundSpeed() / 10.0f), 255); + minimapTile.speed = std::min((int)std::ceil(tile->getGroundSpeed() / 10.0f), 255); } if(minimapTile != MinimapTile()) { diff --git a/src/client/protocolgameparse.cpp b/src/client/protocolgameparse.cpp index 332598c8..d1bfa5c8 100644 --- a/src/client/protocolgameparse.cpp +++ b/src/client/protocolgameparse.cpp @@ -1701,7 +1701,7 @@ void ProtocolGame::setMapDescription(const InputMessagePtr& msg, int x, int y, i if(z > Otc::SEA_FLOOR) { startz = z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE; - endz = std::min(z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::MAX_Z); + endz = std::min(z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::MAX_Z); zstep = 1; } else { diff --git a/src/client/thingtype.cpp b/src/client/thingtype.cpp index 5a1b2287..822b6b03 100644 --- a/src/client/thingtype.cpp +++ b/src/client/thingtype.cpp @@ -129,7 +129,7 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS uint8 width = fin->getU8(); uint8 height = fin->getU8(); m_size = Size(width, height); - m_exactSize = (width > 1 || height > 1) ? std::min((int)fin->getU8(), std::max(width * 32, height * 32)) : 32; + m_exactSize = (width > 1 || height > 1) ? std::min((int)fin->getU8(), std::max(width * 32, height * 32)) : 32; m_layers = fin->getU8(); m_numPatternX = fin->getU8(); m_numPatternY = fin->getU8(); @@ -280,10 +280,10 @@ const TexturePtr& ThingType::getTexture(int animationPhase) for(int y = framePos.y; y < framePos.y + m_size.height() * Otc::TILE_PIXELS; ++y) { uint8 *p = fullImage->getPixel(x,y); if(p[3] != 0x00) { - drawRect.setTop (std::min(y, (int)drawRect.top())); - drawRect.setLeft (std::min(x, (int)drawRect.left())); - drawRect.setBottom(std::max(y, (int)drawRect.bottom())); - drawRect.setRight (std::max(x, (int)drawRect.right())); + drawRect.setTop (std::min(y, (int)drawRect.top())); + drawRect.setLeft (std::min(x, (int)drawRect.left())); + drawRect.setBottom(std::max(y, (int)drawRect.bottom())); + drawRect.setRight (std::max(x, (int)drawRect.right())); } } } @@ -362,5 +362,5 @@ int ThingType::getExactSize(int layer, int xPattern, int yPattern, int zPattern, getTexture(animationPhase); // we must calculate it anyway. int frameIndex = getTextureIndex(layer, xPattern, yPattern, zPattern); Size size = m_texturesFramesOriginRects[animationPhase][frameIndex].size() - m_texturesFramesOffsets[animationPhase][frameIndex].toSize(); - return std::max(size.width(), size.height()); + return std::max(size.width(), size.height()); } diff --git a/src/client/tile.cpp b/src/client/tile.cpp index 72e6860f..6d76f43d 100644 --- a/src/client/tile.cpp +++ b/src/client/tile.cpp @@ -101,8 +101,8 @@ void Tile::draw(const Point& dest, float scaleFactor, int drawFlags, LightView * thing->draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, lightView); if(thing->isLyingCorpse()) { - redrawPreviousTopW = std::max(thing->getWidth(), redrawPreviousTopW); - redrawPreviousTopH = std::max(thing->getHeight(), redrawPreviousTopH); + redrawPreviousTopW = std::max(thing->getWidth(), redrawPreviousTopW); + redrawPreviousTopH = std::max(thing->getHeight(), redrawPreviousTopH); } m_drawElevation += thing->getElevation(); diff --git a/src/client/uiitem.cpp b/src/client/uiitem.cpp index 50af3fa0..79a05b4f 100644 --- a/src/client/uiitem.cpp +++ b/src/client/uiitem.cpp @@ -48,11 +48,11 @@ void UIItem::drawSelf(Fw::DrawPane drawPane) Rect drawRect = getPaddingRect(); Point dest = drawRect.bottomRight() + Point(1,1); - int exactSize = std::max(32, m_item->getExactSize()); + int exactSize = std::max(32, m_item->getExactSize()); if(exactSize == 0) return; - float scaleFactor = std::min(drawRect.width() / (float)exactSize, drawRect.height() / (float)exactSize); + float scaleFactor = std::min(drawRect.width() / (float)exactSize, drawRect.height() / (float)exactSize); dest += (m_item->getDisplacement() - Point(32,32)) * scaleFactor; g_painter->setColor(m_color); diff --git a/src/client/uimap.cpp b/src/client/uimap.cpp index 90594726..a961e4af 100644 --- a/src/client/uimap.cpp +++ b/src/client/uimap.cpp @@ -77,7 +77,7 @@ void UIMap::movePixels(int x, int y) bool UIMap::setZoom(int zoom) { - m_zoom = std::min(std::max(zoom, m_maxZoomIn), m_maxZoomOut); + m_zoom = std::min(std::max(zoom, m_maxZoomIn), m_maxZoomOut); updateVisibleDimension(); return false; } diff --git a/src/client/uiprogressrect.cpp b/src/client/uiprogressrect.cpp index 7f20d812..1187f1ca 100644 --- a/src/client/uiprogressrect.cpp +++ b/src/client/uiprogressrect.cpp @@ -44,35 +44,35 @@ void UIProgressRect::drawSelf(Fw::DrawPane drawPane) // 0% - 12.5% (12.5) // triangle from top center, to top right (var x) if(m_percent < 12.5) { - Point var = Point(std::max(m_percent - 0.0, 0.0) * (drawRect.right() - drawRect.horizontalCenter()) / 12.5, 0); + Point var = Point(std::max(m_percent - 0.0, 0.0) * (drawRect.right() - drawRect.horizontalCenter()) / 12.5, 0); g_painter->drawFilledTriangle(drawRect.center(), drawRect.topRight() + Point(1,0), drawRect.topCenter() + var); } // 12.5% - 37.5% (25) // triangle from top right to bottom right (var y) if(m_percent < 37.5) { - Point var = Point(0, std::max(m_percent - 12.5, 0.0) * (drawRect.bottom() - drawRect.top()) / 25.0); + Point var = Point(0, std::max(m_percent - 12.5, 0.0) * (drawRect.bottom() - drawRect.top()) / 25.0); g_painter->drawFilledTriangle(drawRect.center(), drawRect.bottomRight() + Point(1,1), drawRect.topRight() + var + Point(1,0)); } // 37.5% - 62.5% (25) // triangle from bottom right to bottom left (var x) if(m_percent < 62.5) { - Point var = Point(std::max(m_percent - 37.5, 0.0) * (drawRect.right() - drawRect.left()) / 25.0, 0); + Point var = Point(std::max(m_percent - 37.5, 0.0) * (drawRect.right() - drawRect.left()) / 25.0, 0); g_painter->drawFilledTriangle(drawRect.center(), drawRect.bottomLeft() + Point(0,1), drawRect.bottomRight() - var + Point(1,1)); } // 62.5% - 87.5% (25) // triangle from bottom left to top left if(m_percent < 87.5) { - Point var = Point(0, std::max(m_percent - 62.5, 0.0) * (drawRect.bottom() - drawRect.top()) / 25.0); + Point var = Point(0, std::max(m_percent - 62.5, 0.0) * (drawRect.bottom() - drawRect.top()) / 25.0); g_painter->drawFilledTriangle(drawRect.center(), drawRect.topLeft(), drawRect.bottomLeft() - var + Point(0,1)); } // 87.5% - 100% (12.5) // triangle from top left to top center if(m_percent < 100) { - Point var = Point(std::max(m_percent - 87.5, 0.0) * (drawRect.horizontalCenter() - drawRect.left()) / 12.5, 0); + Point var = Point(std::max(m_percent - 87.5, 0.0) * (drawRect.horizontalCenter() - drawRect.left()) / 12.5, 0); g_painter->drawFilledTriangle(drawRect.center(), drawRect.topCenter(), drawRect.topLeft() + var); } @@ -84,7 +84,7 @@ void UIProgressRect::drawSelf(Fw::DrawPane drawPane) void UIProgressRect::setPercent(float percent) { - m_percent = std::max(std::min((double)percent, 100.0), 0.0); + m_percent = std::max(std::min((double)percent, 100.0), 0.0); } void UIProgressRect::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode) diff --git a/src/framework/core/adaptativeframecounter.cpp b/src/framework/core/adaptativeframecounter.cpp index aa227250..ca1f40c6 100644 --- a/src/framework/core/adaptativeframecounter.cpp +++ b/src/framework/core/adaptativeframecounter.cpp @@ -89,7 +89,7 @@ bool AdaptativeFrameCounter::update() void AdaptativeFrameCounter::setMaxFps(int maxFps) { - maxFps = std::max(std::min(maxFps, 1000), 0); + maxFps = std::max(std::min(maxFps, 1000), 0); if(maxFps != 0) { m_bestFrameDelay = 1000000 / maxFps; diff --git a/src/framework/graphics/bitmapfont.cpp b/src/framework/graphics/bitmapfont.cpp index a75ce6ed..43b9d6eb 100644 --- a/src/framework/graphics/bitmapfont.cpp +++ b/src/framework/graphics/bitmapfont.cpp @@ -209,7 +209,7 @@ const std::vector& BitmapFont::calculateGlyphsPositions(const std::string lineWidths[lines] += m_glyphsSize[glyph].width() ; if((i+1 != textLength && text[i+1] != '\n')) // only add space if letter is not the last or before a \n. lineWidths[lines] += m_glyphSpacing.width(); - maxLineWidth = std::max(maxLineWidth, lineWidths[lines]); + maxLineWidth = std::max(maxLineWidth, lineWidths[lines]); } } } diff --git a/src/framework/graphics/framebuffer.cpp b/src/framework/graphics/framebuffer.cpp index aced6ba8..f2fb53ac 100644 --- a/src/framework/graphics/framebuffer.cpp +++ b/src/framework/graphics/framebuffer.cpp @@ -149,8 +149,8 @@ Size FrameBuffer::getSize() { if(m_fbo == 0) { // the buffer size is limited by the window size - return Size(std::min(m_texture->getWidth(), g_window.getWidth()), - std::min(m_texture->getHeight(), g_window.getHeight())); + return Size(std::min(m_texture->getWidth(), g_window.getWidth()), + std::min(m_texture->getHeight(), g_window.getHeight())); } return m_texture->getSize(); }