force use of template version of std::min/max

This commit is contained in:
Ahmed Samy 2013-11-14 00:02:47 +02:00
parent 1711d8bdaf
commit 25d3019d1a
17 changed files with 48 additions and 48 deletions

View File

@ -70,13 +70,13 @@ void Creature::draw(const Point& dest, float scaleFactor, bool animate, LightVie
if(m_showTimedSquare && animate) { if(m_showTimedSquare && animate) {
g_painter->setColor(m_timedSquareColor); 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>((int)(2*scaleFactor), 1));
g_painter->setColor(Color::white); g_painter->setColor(Color::white);
} }
if(m_showStaticSquare && animate) { if(m_showStaticSquare && animate) {
g_painter->setColor(m_staticSquareColor); 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>((int)(2*scaleFactor), 1));
g_painter->setColor(Color::white); 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, // when creature is an effect we cant render the first and last animation phase,
// instead we should loop in the phases between // instead we should loop in the phases between
if(m_outfit.getCategory() == ThingCategoryEffect) { if(m_outfit.getCategory() == ThingCategoryEffect) {
animationPhases = std::max(1, animationPhases-2); animationPhases = std::max<int>(1, animationPhases-2);
animateTicks = Otc::INVISIBLE_TICKS_PER_FRAME; animateTicks = Otc::INVISIBLE_TICKS_PER_FRAME;
} }
@ -372,7 +372,7 @@ void Creature::updateJump()
int nextT, i = 1; int nextT, i = 1;
do { 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<int>(b*b + 4*a*(roundHeight+diff*i), 0.0)) * diff) / (2*a));
++i; ++i;
if(nextT < halfJumpDuration) if(nextT < halfJumpDuration)
@ -556,7 +556,7 @@ void Creature::updateWalk()
int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f); int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
// needed for paralyze effect // needed for paralyze effect
m_walkedPixels = std::max(m_walkedPixels, totalPixelsWalked); m_walkedPixels = std::max<int>(m_walkedPixels, totalPixelsWalked);
// update walk animation and offsets // update walk animation and offsets
updateWalkAnimation(totalPixelsWalked); updateWalkAnimation(totalPixelsWalked);
@ -820,7 +820,7 @@ int Creature::getStepDuration(bool ignoreDiagonal, Otc::Direction dir)
if(g_game.getFeature(Otc::GameNewSpeedLaw) && hasSpeedFormula()) { if(g_game.getFeature(Otc::GameNewSpeedLaw) && hasSpeedFormula()) {
int formulatedSpeed = 1; int formulatedSpeed = 1;
if(speed > -m_speedFormula[Otc::SpeedFormulaB]) { if(speed > -m_speedFormula[Otc::SpeedFormulaB]) {
formulatedSpeed = std::max(1, (int)floor((m_speedFormula[Otc::SpeedFormulaA] * log((speed / 2) formulatedSpeed = std::max<int>(1, (int)floor((m_speedFormula[Otc::SpeedFormulaA] * log((speed / 2)
+ m_speedFormula[Otc::SpeedFormulaB]) + m_speedFormula[Otc::SpeedFormulaC]) + 0.5)); + m_speedFormula[Otc::SpeedFormulaB]) + m_speedFormula[Otc::SpeedFormulaC]) + 0.5));
} }
interval = std::floor(interval / (double)formulatedSpeed); interval = std::floor(interval / (double)formulatedSpeed);
@ -835,7 +835,7 @@ int Creature::getStepDuration(bool ignoreDiagonal, Otc::Direction dir)
if(g_game.getProtocolVersion() <= 810) if(g_game.getProtocolVersion() <= 810)
factor = 2; factor = 2;
interval = std::max(interval, g_game.getServerBeat()); interval = std::max<int>(interval, g_game.getServerBeat());
if(!ignoreDiagonal && (m_lastStepDirection == Otc::NorthWest || m_lastStepDirection == Otc::NorthEast || if(!ignoreDiagonal && (m_lastStepDirection == Otc::NorthWest || m_lastStepDirection == Otc::NorthEast ||
m_lastStepDirection == Otc::SouthWest || m_lastStepDirection == Otc::SouthEast)) m_lastStepDirection == Otc::SouthWest || m_lastStepDirection == Otc::SouthEast))
@ -887,7 +887,7 @@ int Creature::getExactSize(int layer, int xPattern, int yPattern, int zPattern,
continue; continue;
for(layer = 0; layer < getLayers(); ++layer) for(layer = 0; layer < getLayers(); ++layer)
exactSize = std::max(exactSize, Thing::getExactSize(layer, xPattern, yPattern, zPattern, animationPhase)); exactSize = std::max<int>(exactSize, Thing::getExactSize(layer, xPattern, yPattern, zPattern, animationPhase));
} }
return exactSize; return exactSize;

View File

@ -31,7 +31,7 @@ void Effect::draw(const Point& dest, float scaleFactor, bool animate, LightView
int animationPhase = 0; int animationPhase = 0;
if(animate) if(animate)
animationPhase = std::min((int)(m_animationTimer.ticksElapsed() / m_phaseDuration), getAnimationPhases() - 1); animationPhase = std::min<int>((int)(m_animationTimer.ticksElapsed() / m_phaseDuration), getAnimationPhases() - 1);
rawGetThingType()->draw(dest, scaleFactor, 0, 0, 0, 0, animationPhase, lightView); rawGetThingType()->draw(dest, scaleFactor, 0, 0, 0, 0, animationPhase, lightView);
} }

View File

@ -287,7 +287,7 @@ public:
bool isFollowing() { return !!m_followingCreature; } bool isFollowing() { return !!m_followingCreature; }
bool isConnectionOk() { return m_protocolGame && m_protocolGame->getElapsedTicksSinceLastRead() < 5000; } 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<int>(m_ping, m_pingTimer.elapsed_millis()) : -1; }
ContainerPtr getContainer(int index) { return m_containers[index]; } ContainerPtr getContainer(int index) { return m_containers[index]; }
std::map<int, ContainerPtr> getContainers() { return m_containers; } std::map<int, ContainerPtr> getContainers() { return m_containers; }
std::map<int, Vip> getVips() { return m_vips; } std::map<int, Vip> getVips() { return m_vips; }

View File

@ -50,7 +50,7 @@ TexturePtr LightView::generateLightBubble(float centerFactor)
for(int x = 0; x < bubbleDiameter; x++) { for(int x = 0; x < bubbleDiameter; x++) {
for(int y = 0; y < bubbleDiameter; y++) { for(int y = 0; y < bubbleDiameter; y++) {
float radius = std::sqrt((bubbleRadius - x)*(bubbleRadius - x) + (bubbleRadius - y)*(bubbleRadius - 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<float>(std::min<float>((bubbleRadius-radius)/(float)(bubbleRadius-centerRadius), 1.0f), 0.0f);
// light intensity varies inversely with the square of the distance // light intensity varies inversely with the square of the distance
intensity = intensity * intensity; intensity = intensity * intensity;

View File

@ -58,7 +58,7 @@ LocalPlayer::LocalPlayer()
void LocalPlayer::lockWalk(int millis) void LocalPlayer::lockWalk(int millis)
{ {
m_walkLockExpiration = std::max(m_walkLockExpiration, (ticks_t) g_clock.millis() + millis); m_walkLockExpiration = std::max<int>(m_walkLockExpiration, (ticks_t) g_clock.millis() + millis);
} }
bool LocalPlayer::canWalk(Otc::Direction direction) bool LocalPlayer::canWalk(Otc::Direction direction)
@ -263,7 +263,7 @@ void LocalPlayer::updateWalk()
{ {
int stepDuration = getStepDuration(); int stepDuration = getStepDuration();
float walkTicksPerPixel = getStepDuration(true) / 32.0f; float walkTicksPerPixel = getStepDuration(true) / 32.0f;
int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f); int totalPixelsWalked = std::min<int>(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
// update walk animation and offsets // update walk animation and offsets
updateWalkAnimation(totalPixelsWalked); updateWalkAnimation(totalPixelsWalked);

View File

@ -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; int y = 12 - 48 * t / (float)Otc::ANIMATED_TEXT_DURATION;
offset += Point(0, y); offset += Point(0, y);
} }
offset.y = std::min(offset.y, 12); offset.y = std::min<int>(offset.y, 12);
animatedText->setOffset(offset); animatedText->setOffset(offset);
} }
m_animatedTexts.push_back(animatedText); m_animatedTexts.push_back(animatedText);
@ -615,7 +615,7 @@ int Map::getFirstAwareFloor()
int Map::getLastAwareFloor() int Map::getLastAwareFloor()
{ {
if(m_centralPosition.z > Otc::SEA_FLOOR) 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<int>(m_centralPosition.z+Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::MAX_Z);
else else
return Otc::SEA_FLOOR; return Otc::SEA_FLOOR;
} }

View File

@ -159,7 +159,7 @@ void MapView::draw(const Rect& rect)
} }
if(m_shaderSwitchDone && m_shader && m_fadeInTime > 0) if(m_shaderSwitchDone && m_shader && m_fadeInTime > 0)
fadeOpacity = std::min(m_fadeTimer.timeElapsed() / m_fadeInTime, 1.0f); fadeOpacity = std::min<float>(m_fadeTimer.timeElapsed() / m_fadeInTime, 1.0f);
Rect srcRect = calcFramebufferSource(rect.size()); Rect srcRect = calcFramebufferSource(rect.size());
Point drawOffset = srcRect.topLeft(); 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 // loop through / diagonals beginning at top left and going to top right
for(int diagonal = 0; diagonal < numDiagonals && !stop; ++diagonal) { for(int diagonal = 0; diagonal < numDiagonals && !stop; ++diagonal) {
// loop current diagonal tiles // loop current diagonal tiles
int advance = std::max(diagonal - m_drawDimension.height(), 0); int advance = std::max<int>(diagonal - m_drawDimension.height(), 0);
for(int iy = diagonal - advance, ix = advance; iy >= 0 && ix < m_drawDimension.width() && !stop; --iy, ++ix) { 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 // only start really looking tiles in the desired start
if(m_updateTilesPos < start) { if(m_updateTilesPos < start) {
@ -364,10 +364,10 @@ void MapView::updateVisibleTilesCache(int start)
}; };
for(int i=0;i<4;++i) { for(int i=0;i<4;++i) {
int sx = std::max(lines[i].left(), area.left()); int sx = std::max<int>(lines[i].left(), area.left());
int ex = std::min(lines[i].right(), area.right()); int ex = std::min<int>(lines[i].right(), area.right());
int sy = std::max(lines[i].top(), area.top()); int sy = std::max<int>(lines[i].top(), area.top());
int ey = std::min(lines[i].bottom(), area.bottom()); int ey = std::min<int>(lines[i].bottom(), area.bottom());
for(int qx=sx;qx<=ex;++qx) for(int qx=sx;qx<=ex;++qx)
for(int qy=sy;qy<=ey;++qy) for(int qy=sy;qy<=ey;++qy)
m_spiral[count++] = Point(qx, qy); m_spiral[count++] = Point(qx, qy);
@ -608,7 +608,7 @@ int MapView::calcFirstVisibleFloor()
// limits to underground floors while under sea level // limits to underground floors while under sea level
if(cameraPosition.z > Otc::SEA_FLOOR) if(cameraPosition.z > Otc::SEA_FLOOR)
firstFloor = std::max(cameraPosition.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::UNDERGROUND_FLOOR); firstFloor = std::max<int>(cameraPosition.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::UNDERGROUND_FLOOR);
// loop in 3x3 tiles around the camera // loop in 3x3 tiles around the camera
for(int ix = -1; ix <= 1 && firstFloor < cameraPosition.z; ++ix) { 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 // 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<int>(std::max<int>(z, 0), (int)Otc::MAX_Z);
return z; return z;
} }
@ -666,10 +666,10 @@ int MapView::calcLastVisibleFloor()
} }
if(m_lockedFirstVisibleFloor != -1) if(m_lockedFirstVisibleFloor != -1)
z = std::max(m_lockedFirstVisibleFloor, z); z = std::max<int>(m_lockedFirstVisibleFloor, z);
// just ensure the that the floor is in the valid range // 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<int>(std::max<int>(z, 0), (int)Otc::MAX_Z);
return z; return z;
} }

View File

@ -200,7 +200,7 @@ void Minimap::updateTile(const Position& pos, const TilePtr& tile)
minimapTile.flags |= MinimapTileNotWalkable; minimapTile.flags |= MinimapTileNotWalkable;
if(!tile->isPathable()) if(!tile->isPathable())
minimapTile.flags |= MinimapTileNotPathable; minimapTile.flags |= MinimapTileNotPathable;
minimapTile.speed = std::min((int)std::ceil(tile->getGroundSpeed() / 10.0f), 255); minimapTile.speed = std::min<int>((int)std::ceil(tile->getGroundSpeed() / 10.0f), 255);
} }
if(minimapTile != MinimapTile()) { if(minimapTile != MinimapTile()) {

View File

@ -1701,7 +1701,7 @@ void ProtocolGame::setMapDescription(const InputMessagePtr& msg, int x, int y, i
if(z > Otc::SEA_FLOOR) { if(z > Otc::SEA_FLOOR) {
startz = z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE; startz = z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE;
endz = std::min(z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::MAX_Z); endz = std::min<int>(z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::MAX_Z);
zstep = 1; zstep = 1;
} }
else { else {

View File

@ -129,7 +129,7 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS
uint8 width = fin->getU8(); uint8 width = fin->getU8();
uint8 height = fin->getU8(); uint8 height = fin->getU8();
m_size = Size(width, height); 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>((int)fin->getU8(), std::max<int>(width * 32, height * 32)) : 32;
m_layers = fin->getU8(); m_layers = fin->getU8();
m_numPatternX = fin->getU8(); m_numPatternX = fin->getU8();
m_numPatternY = 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) { for(int y = framePos.y; y < framePos.y + m_size.height() * Otc::TILE_PIXELS; ++y) {
uint8 *p = fullImage->getPixel(x,y); uint8 *p = fullImage->getPixel(x,y);
if(p[3] != 0x00) { if(p[3] != 0x00) {
drawRect.setTop (std::min(y, (int)drawRect.top())); drawRect.setTop (std::min<int>(y, (int)drawRect.top()));
drawRect.setLeft (std::min(x, (int)drawRect.left())); drawRect.setLeft (std::min<int>(x, (int)drawRect.left()));
drawRect.setBottom(std::max(y, (int)drawRect.bottom())); drawRect.setBottom(std::max<int>(y, (int)drawRect.bottom()));
drawRect.setRight (std::max(x, (int)drawRect.right())); drawRect.setRight (std::max<int>(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. getTexture(animationPhase); // we must calculate it anyway.
int frameIndex = getTextureIndex(layer, xPattern, yPattern, zPattern); int frameIndex = getTextureIndex(layer, xPattern, yPattern, zPattern);
Size size = m_texturesFramesOriginRects[animationPhase][frameIndex].size() - m_texturesFramesOffsets[animationPhase][frameIndex].toSize(); Size size = m_texturesFramesOriginRects[animationPhase][frameIndex].size() - m_texturesFramesOffsets[animationPhase][frameIndex].toSize();
return std::max(size.width(), size.height()); return std::max<int>(size.width(), size.height());
} }

View File

@ -101,8 +101,8 @@ void Tile::draw(const Point& dest, float scaleFactor, int drawFlags, LightView *
thing->draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, lightView); thing->draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, lightView);
if(thing->isLyingCorpse()) { if(thing->isLyingCorpse()) {
redrawPreviousTopW = std::max(thing->getWidth(), redrawPreviousTopW); redrawPreviousTopW = std::max<int>(thing->getWidth(), redrawPreviousTopW);
redrawPreviousTopH = std::max(thing->getHeight(), redrawPreviousTopH); redrawPreviousTopH = std::max<int>(thing->getHeight(), redrawPreviousTopH);
} }
m_drawElevation += thing->getElevation(); m_drawElevation += thing->getElevation();

View File

@ -48,11 +48,11 @@ void UIItem::drawSelf(Fw::DrawPane drawPane)
Rect drawRect = getPaddingRect(); Rect drawRect = getPaddingRect();
Point dest = drawRect.bottomRight() + Point(1,1); Point dest = drawRect.bottomRight() + Point(1,1);
int exactSize = std::max(32, m_item->getExactSize()); int exactSize = std::max<int>(32, m_item->getExactSize());
if(exactSize == 0) if(exactSize == 0)
return; return;
float scaleFactor = std::min(drawRect.width() / (float)exactSize, drawRect.height() / (float)exactSize); float scaleFactor = std::min<float>(drawRect.width() / (float)exactSize, drawRect.height() / (float)exactSize);
dest += (m_item->getDisplacement() - Point(32,32)) * scaleFactor; dest += (m_item->getDisplacement() - Point(32,32)) * scaleFactor;
g_painter->setColor(m_color); g_painter->setColor(m_color);

View File

@ -77,7 +77,7 @@ void UIMap::movePixels(int x, int y)
bool UIMap::setZoom(int zoom) bool UIMap::setZoom(int zoom)
{ {
m_zoom = std::min(std::max(zoom, m_maxZoomIn), m_maxZoomOut); m_zoom = std::min<int>(std::max<int>(zoom, m_maxZoomIn), m_maxZoomOut);
updateVisibleDimension(); updateVisibleDimension();
return false; return false;
} }

View File

@ -44,35 +44,35 @@ void UIProgressRect::drawSelf(Fw::DrawPane drawPane)
// 0% - 12.5% (12.5) // 0% - 12.5% (12.5)
// triangle from top center, to top right (var x) // triangle from top center, to top right (var x)
if(m_percent < 12.5) { 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<int>(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); g_painter->drawFilledTriangle(drawRect.center(), drawRect.topRight() + Point(1,0), drawRect.topCenter() + var);
} }
// 12.5% - 37.5% (25) // 12.5% - 37.5% (25)
// triangle from top right to bottom right (var y) // triangle from top right to bottom right (var y)
if(m_percent < 37.5) { 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<int>(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)); g_painter->drawFilledTriangle(drawRect.center(), drawRect.bottomRight() + Point(1,1), drawRect.topRight() + var + Point(1,0));
} }
// 37.5% - 62.5% (25) // 37.5% - 62.5% (25)
// triangle from bottom right to bottom left (var x) // triangle from bottom right to bottom left (var x)
if(m_percent < 62.5) { 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<int>(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)); g_painter->drawFilledTriangle(drawRect.center(), drawRect.bottomLeft() + Point(0,1), drawRect.bottomRight() - var + Point(1,1));
} }
// 62.5% - 87.5% (25) // 62.5% - 87.5% (25)
// triangle from bottom left to top left // triangle from bottom left to top left
if(m_percent < 87.5) { 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<int>(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)); g_painter->drawFilledTriangle(drawRect.center(), drawRect.topLeft(), drawRect.bottomLeft() - var + Point(0,1));
} }
// 87.5% - 100% (12.5) // 87.5% - 100% (12.5)
// triangle from top left to top center // triangle from top left to top center
if(m_percent < 100) { 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<int>(m_percent - 87.5, 0.0) * (drawRect.horizontalCenter() - drawRect.left()) / 12.5, 0);
g_painter->drawFilledTriangle(drawRect.center(), drawRect.topCenter(), drawRect.topLeft() + var); 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) void UIProgressRect::setPercent(float percent)
{ {
m_percent = std::max(std::min((double)percent, 100.0), 0.0); m_percent = std::max<float>(std::min<float>((double)percent, 100.0), 0.0);
} }
void UIProgressRect::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode) void UIProgressRect::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)

View File

@ -89,7 +89,7 @@ bool AdaptativeFrameCounter::update()
void AdaptativeFrameCounter::setMaxFps(int maxFps) void AdaptativeFrameCounter::setMaxFps(int maxFps)
{ {
maxFps = std::max(std::min(maxFps, 1000), 0); maxFps = std::max<int>(std::min<int>(maxFps, 1000), 0);
if(maxFps != 0) { if(maxFps != 0) {
m_bestFrameDelay = 1000000 / maxFps; m_bestFrameDelay = 1000000 / maxFps;

View File

@ -209,7 +209,7 @@ const std::vector<Point>& BitmapFont::calculateGlyphsPositions(const std::string
lineWidths[lines] += m_glyphsSize[glyph].width() ; 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. 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(); lineWidths[lines] += m_glyphSpacing.width();
maxLineWidth = std::max(maxLineWidth, lineWidths[lines]); maxLineWidth = std::max<int>(maxLineWidth, lineWidths[lines]);
} }
} }
} }

View File

@ -149,8 +149,8 @@ Size FrameBuffer::getSize()
{ {
if(m_fbo == 0) { if(m_fbo == 0) {
// the buffer size is limited by the window size // the buffer size is limited by the window size
return Size(std::min(m_texture->getWidth(), g_window.getWidth()), return Size(std::min<int>(m_texture->getWidth(), g_window.getWidth()),
std::min(m_texture->getHeight(), g_window.getHeight())); std::min<int>(m_texture->getHeight(), g_window.getHeight()));
} }
return m_texture->getSize(); return m_texture->getSize();
} }