1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +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/variant.hpp>
#include <boost/math/special_functions/round.hpp>
#ifdef ANDROID
#include <android/log.h>
#endif
@ -584,6 +587,8 @@ namespace vstd
else
return nullptr;
}
using boost::math::round;
}
using vstd::operator-=;
using vstd::make_unique;

View File

@ -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)

View File

@ -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<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<3>(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 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);