1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +02:00

Visual 2012 compile fixes.

Unfortunately no C99 math nor uniform initialization till VS 2013.
This commit is contained in:
Michał W. Urbańczyk
2013-07-07 08:27:27 +00:00
parent 146a5e5ef8
commit 516684aaab
5 changed files with 20 additions and 8 deletions

View File

@ -112,6 +112,9 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/variant.hpp> #include <boost/variant.hpp>
#include <boost/math/special_functions/round.hpp>
#ifdef ANDROID #ifdef ANDROID
#include <android/log.h> #include <android/log.h>
#endif #endif
@ -584,6 +587,8 @@ namespace vstd
else else
return nullptr; return nullptr;
} }
using boost::math::round;
} }
using vstd::operator-=; using vstd::operator-=;
using vstd::make_unique; using vstd::make_unique;

View File

@ -2065,7 +2065,7 @@ void CBattleInterface::setAnimSpeed(int set)
int CBattleInterface::getAnimSpeed() const 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) void CBattleInterface::setActiveStack(const CStack * stack)

View File

@ -138,7 +138,7 @@ CCreatureAnimation::CCreatureAnimation(std::string name, TSpeedController contro
currentFrame(0), currentFrame(0),
elapsedTime(0), elapsedTime(0),
type(CCreatureAnim::HOLDING), type(CCreatureAnim::HOLDING),
border({0, 0, 0, 0}), border(CSDL_Ext::makeColor(0, 0, 0, 0)),
speedController(controller), speedController(controller),
once(false) once(false)
{ {
@ -242,19 +242,19 @@ void CCreatureAnimation::playOnce( CCreatureAnim::EAnimType type )
inline int getBorderStrength(float time) 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 return borderStrength * 155 + 100; // scale to 0-255
} }
static SDL_Color genShadow(ui8 alpha) 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) 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) 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) 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.r, base.r, over.unused, base.unused),
mixChannels(over.g, base.g, over.unused, base.unused), mixChannels(over.g, base.g, over.unused, base.unused),
mixChannels(over.b, base.b, over.unused, base.unused), mixChannels(over.b, base.b, over.unused, base.unused),
ui8(over.unused + base.unused * (255 - over.unused) / 256) ui8(over.unused + base.unused * (255 - over.unused) / 256)
}; );
} }
std::array<SDL_Color, 8> CCreatureAnimation::genSpecialPalette() std::array<SDL_Color, 8> CCreatureAnimation::genSpecialPalette()

View File

@ -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<2>(int, int);
template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<3>(int, int); template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<3>(int, int);
template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<4>(int, int); template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<4>(int, int);

View File

@ -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 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 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 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 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); void drawBorder(SDL_Surface * sur, int x, int y, int w, int h, const int3 &color);