From 516684aaab2d54d97e92785e182d3f7c67d652ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Sun, 7 Jul 2013 08:27:27 +0000 Subject: [PATCH] Visual 2012 compile fixes. Unfortunately no C99 math nor uniform initialization till VS 2013. --- Global.h | 5 +++++ client/battle/CBattleInterface.cpp | 2 +- client/battle/CCreatureAnimation.cpp | 14 +++++++------- client/gui/SDL_Extensions.cpp | 6 ++++++ client/gui/SDL_Extensions.h | 1 + 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Global.h b/Global.h index 997441345..032dcae82 100644 --- a/Global.h +++ b/Global.h @@ -112,6 +112,9 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size."); #include #include +#include + + #ifdef ANDROID #include #endif @@ -584,6 +587,8 @@ namespace vstd else return nullptr; } + + using boost::math::round; } using vstd::operator-=; using vstd::make_unique; diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index 47443e1bb..d043b872e 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -2065,7 +2065,7 @@ void CBattleInterface::setAnimSpeed(int set) int CBattleInterface::getAnimSpeed() const { - return round(settings["battle"]["animationSpeed"].Float() * 100); + return vstd::round(settings["battle"]["animationSpeed"].Float() * 100); } void CBattleInterface::setActiveStack(const CStack * stack) diff --git a/client/battle/CCreatureAnimation.cpp b/client/battle/CCreatureAnimation.cpp index 8754fa200..814c9d5d6 100644 --- a/client/battle/CCreatureAnimation.cpp +++ b/client/battle/CCreatureAnimation.cpp @@ -137,8 +137,8 @@ CCreatureAnimation::CCreatureAnimation(std::string name, TSpeedController contro speed(0.1), currentFrame(0), elapsedTime(0), - type(CCreatureAnim::HOLDING), - border({0, 0, 0, 0}), + type(CCreatureAnim::HOLDING), + border(CSDL_Ext::makeColor(0, 0, 0, 0)), speedController(controller), once(false) { @@ -242,19 +242,19 @@ void CCreatureAnimation::playOnce( CCreatureAnim::EAnimType type ) inline int getBorderStrength(float time) { - float borderStrength = fabs(round(time) - time) * 2; // generate value in range 0-1 + float borderStrength = fabs(vstd::round(time) - time) * 2; // generate value in range 0-1 return borderStrength * 155 + 100; // scale to 0-255 } static SDL_Color genShadow(ui8 alpha) { - return {0, 0, 0, alpha}; + return CSDL_Ext::makeColor(0, 0, 0, alpha); } static SDL_Color genBorderColor(ui8 alpha, const SDL_Color & base) { - return {base.r, base.g, base.b, ui8(base.unused * alpha / 256)}; + return CSDL_Ext::makeColor(base.r, base.g, base.b, ui8(base.unused * alpha / 256)); } static ui8 mixChannels(ui8 c1, ui8 c2, ui8 a1, ui8 a2) @@ -264,12 +264,12 @@ static ui8 mixChannels(ui8 c1, ui8 c2, ui8 a1, ui8 a2) static SDL_Color addColors(const SDL_Color & base, const SDL_Color & over) { - return { + return CSDL_Ext::makeColor( mixChannels(over.r, base.r, over.unused, base.unused), mixChannels(over.g, base.g, over.unused, base.unused), mixChannels(over.b, base.b, over.unused, base.unused), ui8(over.unused + base.unused * (255 - over.unused) / 256) - }; + ); } std::array CCreatureAnimation::genSpecialPalette() diff --git a/client/gui/SDL_Extensions.cpp b/client/gui/SDL_Extensions.cpp index b10f6dc60..7ed2b9f56 100644 --- a/client/gui/SDL_Extensions.cpp +++ b/client/gui/SDL_Extensions.cpp @@ -977,6 +977,12 @@ void CSDL_Ext::fillTexture(SDL_Surface *dst, SDL_Surface * src) } } +SDL_Color CSDL_Ext::makeColor(ui8 r, ui8 g, ui8 b, ui8 a) +{ + SDL_Color ret = {r, g, b, a}; + return ret; +} + template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<2>(int, int); template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<3>(int, int); template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<4>(int, int); diff --git a/client/gui/SDL_Extensions.h b/client/gui/SDL_Extensions.h index 93244d3a9..77817d44c 100644 --- a/client/gui/SDL_Extensions.h +++ b/client/gui/SDL_Extensions.h @@ -170,6 +170,7 @@ namespace CSDL_Ext int blit8bppAlphaTo24bppT(const SDL_Surface * src, const SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect); //blits 8 bpp surface with alpha channel to 24 bpp surface int blit8bppAlphaTo24bpp(const SDL_Surface * src, const SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect); //blits 8 bpp surface with alpha channel to 24 bpp surface Uint32 colorToUint32(const SDL_Color * color); //little endian only + SDL_Color makeColor(ui8 r, ui8 g, ui8 b, ui8 a); void update(SDL_Surface * what = screen); //updates whole surface (default - main screen) void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const int3 &color);