diff --git a/CIO/CFile.cpp b/CIO/CFile.cpp index b145be7..e3d9d54 100644 --- a/CIO/CFile.cpp +++ b/CIO/CFile.cpp @@ -782,7 +782,7 @@ bool CFile::save_wld(void* data) { char zero = 0; // to fill bytes char temp = 0; // to fill bytes - bobMAP* myMap = (bobMAP*)data; + auto* myMap = (bobMAP*)data; char map_version[11] = "WORLD_V1.0"; char map_data_header[16]; diff --git a/CMap.cpp b/CMap.cpp index f7cd269..0d8014c 100644 --- a/CMap.cpp +++ b/CMap.cpp @@ -215,7 +215,7 @@ void CMap::destructMap() bobMAP* CMap::generateMap(int width, int height, MapType type, TriangleTerrainType texture, int border, int border_texture) { - bobMAP* myMap = new bobMAP(); + auto* myMap = new bobMAP(); strcpy(myMap->name, "Ohne Namen"); myMap->width = width; diff --git a/CSurface.cpp b/CSurface.cpp index b2bb38a..45a837f 100644 --- a/CSurface.cpp +++ b/CSurface.cpp @@ -1261,7 +1261,7 @@ vector CSurface::get_nodeVector(const vector& v1, const vector& v2, const vector vector CSurface::get_normVector(const vector& v) { vector normal; - float length = static_cast(sqrt(pow(v.x, 2) + pow(v.y, 2) + pow(v.z, 2))); + auto length = static_cast(sqrt(pow(v.x, 2) + pow(v.y, 2) + pow(v.z, 2))); // in case vector length equals 0 (should not happen) if(std::abs(length) < 1e-20f) { diff --git a/SGE/sge_blib.cpp b/SGE/sge_blib.cpp index 93260d0..ff6c2be 100644 --- a/SGE/sge_blib.cpp +++ b/SGE/sge_blib.cpp @@ -2093,9 +2093,9 @@ void sge_FilledTrigon(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 */ /* Starting coords for the three lines */ - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); + auto xc = Sint32(x2 << 16); /* Lines step values */ Sint32 m1 = 0; @@ -2180,9 +2180,9 @@ void sge_FilledTrigonAlpha(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, S SWAP(x1, x2, y); } - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); + auto xc = Sint32(x2 << 16); Sint32 m1 = 0; Sint32 m2 = Sint32((x3 - x1) << 16) / Sint32(y3 - y1); @@ -2299,22 +2299,22 @@ void sge_FadedTrigon(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 */ /* Starting coords for the three lines */ - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); + auto xc = Sint32(x2 << 16); /* Starting colors (rgb) for the three lines */ - Sint32 r1 = Sint32(col1.r << 16); + auto r1 = Sint32(col1.r << 16); Sint32 r2 = r1; - Sint32 r3 = Sint32(col2.r << 16); + auto r3 = Sint32(col2.r << 16); - Sint32 g1 = Sint32(col1.g << 16); + auto g1 = Sint32(col1.g << 16); Sint32 g2 = g1; - Sint32 g3 = Sint32(col2.g << 16); + auto g3 = Sint32(col2.g << 16); - Sint32 b1 = Sint32(col1.b << 16); + auto b1 = Sint32(col1.b << 16); Sint32 b2 = b1; - Sint32 b3 = Sint32(col2.b << 16); + auto b3 = Sint32(col2.b << 16); /* Lines step values */ Sint32 m1 = 0; @@ -2451,9 +2451,9 @@ void sge_TexturedTrigon(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint */ /* Starting coords for the three lines */ - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); + auto xc = Sint32(x2 << 16); /* Lines step values */ Sint32 m1 = 0; @@ -2461,13 +2461,13 @@ void sge_TexturedTrigon(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint Sint32 m3 = 0; /* Starting texture coords for the three lines */ - Sint32 srcx1 = Sint32(sx1 << 16); + auto srcx1 = Sint32(sx1 << 16); Sint32 srcx2 = srcx1; - Sint32 srcx3 = Sint32(sx2 << 16); + auto srcx3 = Sint32(sx2 << 16); - Sint32 srcy1 = Sint32(sy1 << 16); + auto srcy1 = Sint32(sy1 << 16); Sint32 srcy2 = srcy1; - Sint32 srcy3 = Sint32(sy2 << 16); + auto srcy3 = Sint32(sy2 << 16); /* Texture coords stepping value */ Sint32 xstep1 = 0; @@ -2600,9 +2600,9 @@ void sge_FadedTexturedTrigon(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, */ /* Starting coords for the three lines */ - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); + auto xc = Sint32(x2 << 16); /* Starting colors (rgb) for the three lines */ Sint32 i1 = i_orig1; @@ -2620,13 +2620,13 @@ void sge_FadedTexturedTrigon(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint32 istep3 = 0; /* Starting texture coords for the three lines */ - Sint32 srcx1 = Sint32(sx1 << 16); + auto srcx1 = Sint32(sx1 << 16); Sint32 srcx2 = srcx1; - Sint32 srcx3 = Sint32(sx2 << 16); + auto srcx3 = Sint32(sx2 << 16); - Sint32 srcy1 = Sint32(sy1 << 16); + auto srcy1 = Sint32(sy1 << 16); Sint32 srcy2 = srcy1; - Sint32 srcy3 = Sint32(sy2 << 16); + auto srcy3 = Sint32(sy2 << 16); /* Texture coords stepping value */ Sint32 xstep1 = 0; @@ -2780,9 +2780,9 @@ void sge_PreCalcFadedTexturedTrigon(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sin */ /* Starting coords for the three lines */ - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); + auto xc = Sint32(x2 << 16); /* Starting colors (rgb) for the three lines */ Uint16 i1 = i_orig1; @@ -2800,13 +2800,13 @@ void sge_PreCalcFadedTexturedTrigon(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sin Sint16 istep3 = 0; /* Starting texture coords for the three lines */ - Sint32 srcx1 = Sint32(sx1 << 16); + auto srcx1 = Sint32(sx1 << 16); Sint32 srcx2 = srcx1; - Sint32 srcx3 = Sint32(sx2 << 16); + auto srcx3 = Sint32(sx2 << 16); - Sint32 srcy1 = Sint32(sy1 << 16); + auto srcy1 = Sint32(sy1 << 16); Sint32 srcy2 = srcy1; - Sint32 srcy3 = Sint32(sy2 << 16); + auto srcy3 = Sint32(sy2 << 16); /* Texture coords stepping value */ Sint32 xstep1 = 0; @@ -2966,9 +2966,9 @@ void sge_FadedTexturedTrigonColorKeys(SDL_Surface* dest, Sint16 x1, Sint16 y1, S */ /* Starting coords for the three lines */ - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); + auto xc = Sint32(x2 << 16); /* Starting colors (rgb) for the three lines */ Sint32 i1 = i_orig1; @@ -2986,13 +2986,13 @@ void sge_FadedTexturedTrigonColorKeys(SDL_Surface* dest, Sint16 x1, Sint16 y1, S Sint32 istep3 = 0; /* Starting texture coords for the three lines */ - Sint32 srcx1 = Sint32(sx1 << 16); + auto srcx1 = Sint32(sx1 << 16); Sint32 srcx2 = srcx1; - Sint32 srcx3 = Sint32(sx2 << 16); + auto srcx3 = Sint32(sx2 << 16); - Sint32 srcy1 = Sint32(sy1 << 16); + auto srcy1 = Sint32(sy1 << 16); Sint32 srcy2 = srcy1; - Sint32 srcy3 = Sint32(sy2 << 16); + auto srcy3 = Sint32(sy2 << 16); /* Texture coords stepping value */ Sint32 xstep1 = 0; @@ -3148,9 +3148,9 @@ void sge_PreCalcFadedTexturedTrigonColorKeys(SDL_Surface* dest, Sint16 x1, Sint1 */ /* Starting coords for the three lines */ - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); + auto xc = Sint32(x2 << 16); /* Starting colors (rgb) for the three lines */ Uint16 i1 = i_orig1; @@ -3168,13 +3168,13 @@ void sge_PreCalcFadedTexturedTrigonColorKeys(SDL_Surface* dest, Sint16 x1, Sint1 Sint16 istep3 = 0; /* Starting texture coords for the three lines */ - Sint32 srcx1 = Sint32(sx1 << 16); + auto srcx1 = Sint32(sx1 << 16); Sint32 srcx2 = srcx1; - Sint32 srcx3 = Sint32(sx2 << 16); + auto srcx3 = Sint32(sx2 << 16); - Sint32 srcy1 = Sint32(sy1 << 16); + auto srcy1 = Sint32(sy1 << 16); Sint32 srcy2 = srcy1; - Sint32 srcy3 = Sint32(sy2 << 16); + auto srcy3 = Sint32(sy2 << 16); /* Texture coords stepping value */ Sint32 xstep1 = 0; @@ -3340,25 +3340,25 @@ void sge_TexturedRect(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 * We do this exactly like sge_TexturedTrigon(), but here we must trace four lines. */ - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); - Sint32 xd = Sint32(x3 << 16); + auto xc = Sint32(x2 << 16); + auto xd = Sint32(x3 << 16); Sint32 m1 = 0; Sint32 m2 = Sint32((x3 - x1) << 16) / Sint32(y3 - y1); Sint32 m3 = Sint32((x4 - x2) << 16) / Sint32(y4 - y2); Sint32 m4 = 0; - Sint32 srcx1 = Sint32(sx1 << 16); + auto srcx1 = Sint32(sx1 << 16); Sint32 srcx2 = srcx1; - Sint32 srcx3 = Sint32(sx2 << 16); - Sint32 srcx4 = Sint32(sx3 << 16); + auto srcx3 = Sint32(sx2 << 16); + auto srcx4 = Sint32(sx3 << 16); - Sint32 srcy1 = Sint32(sy1 << 16); + auto srcy1 = Sint32(sy1 << 16); Sint32 srcy2 = srcy1; - Sint32 srcy3 = Sint32(sy2 << 16); - Sint32 srcy4 = Sint32(sy3 << 16); + auto srcy3 = Sint32(sy2 << 16); + auto srcy4 = Sint32(sy3 << 16); Sint32 xstep1 = 0; Sint32 xstep2 = Sint32((sx3 - sx1) << 16) / Sint32(y3 - y1); @@ -3522,10 +3522,10 @@ void sge_FadedTexturedRect(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, S * We do this exactly like sge_TexturedTrigon(), but here we must trace four lines. */ - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); - Sint32 xd = Sint32(x3 << 16); + auto xc = Sint32(x2 << 16); + auto xd = Sint32(x3 << 16); /* Starting colors (rgb) for the three lines */ Sint32 i1 = i_orig1; @@ -3544,15 +3544,15 @@ void sge_FadedTexturedRect(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint16 x2, S Sint32 istep3 = 0; Sint32 istep4 = (i_orig4 - i2) / Sint32(y4 - y2); - Sint32 srcx1 = Sint32(sx1 << 16); + auto srcx1 = Sint32(sx1 << 16); Sint32 srcx2 = srcx1; - Sint32 srcx3 = Sint32(sx2 << 16); - Sint32 srcx4 = Sint32(sx3 << 16); + auto srcx3 = Sint32(sx2 << 16); + auto srcx4 = Sint32(sx3 << 16); - Sint32 srcy1 = Sint32(sy1 << 16); + auto srcy1 = Sint32(sy1 << 16); Sint32 srcy2 = srcy1; - Sint32 srcy3 = Sint32(sy2 << 16); - Sint32 srcy4 = Sint32(sy3 << 16); + auto srcy3 = Sint32(sy2 << 16); + auto srcy4 = Sint32(sy3 << 16); Sint32 xstep1 = 0; Sint32 xstep2 = Sint32((sx3 - sx1) << 16) / Sint32(y3 - y1); @@ -3724,10 +3724,10 @@ void sge_PreCalcFadedTexturedRect(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint1 * We do this exactly like sge_TexturedTrigon(), but here we must trace four lines. */ - Sint32 xa = Sint32(x1 << 16); + auto xa = Sint32(x1 << 16); Sint32 xb = xa; - Sint32 xc = Sint32(x2 << 16); - Sint32 xd = Sint32(x3 << 16); + auto xc = Sint32(x2 << 16); + auto xd = Sint32(x3 << 16); /* Starting colors (rgb) for the three lines */ Uint16 i1 = i_orig1; @@ -3746,15 +3746,15 @@ void sge_PreCalcFadedTexturedRect(SDL_Surface* dest, Sint16 x1, Sint16 y1, Sint1 Sint16 istep3 = 0; Sint16 istep4 = (i_orig4 - i2) / (y4 - y2); - Sint32 srcx1 = Sint32(sx1 << 16); + auto srcx1 = Sint32(sx1 << 16); Sint32 srcx2 = srcx1; - Sint32 srcx3 = Sint32(sx2 << 16); - Sint32 srcx4 = Sint32(sx3 << 16); + auto srcx3 = Sint32(sx2 << 16); + auto srcx4 = Sint32(sx3 << 16); - Sint32 srcy1 = Sint32(sy1 << 16); + auto srcy1 = Sint32(sy1 << 16); Sint32 srcy2 = srcy1; - Sint32 srcy3 = Sint32(sy2 << 16); - Sint32 srcy4 = Sint32(sy3 << 16); + auto srcy3 = Sint32(sy2 << 16); + auto srcy4 = Sint32(sy3 << 16); Sint32 xstep1 = 0; Sint32 xstep2 = Sint32((sx3 - sx1) << 16) / Sint32(y3 - y1); @@ -3999,8 +3999,8 @@ int sge_FilledPolygonAlpha(SDL_Surface* dest, Uint16 n, Sint16* x, Sint16* y, Ui if(SDL_LockSurface(dest) < 0) return -2; - pline* line = new pline[n]; - pline_p* plist = new pline_p[n]; + auto* line = new pline[n]; + auto* plist = new pline_p[n]; Sint16 y1, y2, x1, x2, tmp, sy; Sint16 ymin = y[1], ymax = y[1]; @@ -4170,8 +4170,8 @@ int sge_AAFilledPolygon(SDL_Surface* dest, Uint16 n, Sint16* x, Sint16* y, Uint3 if(SDL_LockSurface(dest) < 0) return -2; - pline* line = new pline[n]; - pline_p* plist = new pline_p[n]; + auto* line = new pline[n]; + auto* plist = new pline_p[n]; Sint16 y1, y2, x1, x2, tmp, sy; Sint16 ymin = y[1], ymax = y[1]; @@ -4350,8 +4350,8 @@ int sge_FadedPolygonAlpha(SDL_Surface* dest, Uint16 n, Sint16* x, Sint16* y, Uin if(SDL_LockSurface(dest) < 0) return -2; - fpline* line = new fpline[n]; - pline_p* plist = new pline_p[n]; + auto* line = new fpline[n]; + auto* plist = new pline_p[n]; Sint16 y1, y2, x1, x2, tmp, sy; Sint16 ymin = y[1], ymax = y[1]; @@ -4551,8 +4551,8 @@ int sge_AAFadedPolygon(SDL_Surface* dest, Uint16 n, Sint16* x, Sint16* y, Uint8* if(SDL_LockSurface(dest) < 0) return -2; - fpline* line = new fpline[n]; - pline_p* plist = new pline_p[n]; + auto* line = new fpline[n]; + auto* plist = new pline_p[n]; Sint16 y1, y2, x1, x2, tmp, sy; Sint16 ymin = y[1], ymax = y[1]; diff --git a/SGE/sge_misc.cpp b/SGE/sge_misc.cpp index 6f18112..9743c96 100644 --- a/SGE/sge_misc.cpp +++ b/SGE/sge_misc.cpp @@ -70,7 +70,7 @@ Uint32 sge_DelayRes() Uint32 sge_Delay(Uint32 ticks) { Uint32 start = SDL_GetTicks(); - Sint32 time_left = (Sint32)ticks; + auto time_left = (Sint32)ticks; Uint32 tmp; if(ticks >= delay_res) diff --git a/SGE/sge_primitives.cpp b/SGE/sge_primitives.cpp index a03ed83..8cf892c 100644 --- a/SGE/sge_primitives.cpp +++ b/SGE/sge_primitives.cpp @@ -433,7 +433,7 @@ void _Line(SDL_Surface* surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uin x = y = 0; Sint16 pixx = surface->format->BytesPerPixel; - Sint16 pixy = (Sint16)surface->pitch; + auto pixy = (Sint16)surface->pitch; Uint8* pixel = (Uint8*)surface->pixels + y1 * pixy + x1 * pixx; pixx *= sdx; @@ -1803,7 +1803,7 @@ void sge_AAFilledEllipse(SDL_Surface* surface, Sint16 xc, Sint16 yc, Uint16 rx, int ds = 2 * a2; int dt = 2 * b2; - int dxt = int(a2 / sqrt(a2 + b2)); + auto dxt = int(a2 / sqrt(a2 + b2)); int t = 0; int s = -2 * a2 * ry; @@ -1982,7 +1982,7 @@ void sge_DoCircle(SDL_Surface* Surface, Sint16 x, Sint16 y, Uint16 r, Uint32 col void Callback(SDL_Surface* Surf, Sint16 X, Sint16 Y, Uint32 Color)) { Sint16 cx = 0; - Sint16 cy = (Sint16)r; + auto cy = (Sint16)r; Sint16 df = 1 - (Sint16)r; Sint16 d_e = 3; Sint16 d_se = -2 * r + 5; @@ -2088,7 +2088,7 @@ void sge_CircleAlpha(SDL_Surface* Surface, Sint16 x, Sint16 y, Uint16 r, Uint8 R void sge_FilledCircle(SDL_Surface* Surface, Sint16 x, Sint16 y, Uint16 r, Uint32 color) { Sint16 cx = 0; - Sint16 cy = (Sint16)r; + auto cy = (Sint16)r; bool draw = true; Sint16 df = 1 - (Sint16)r; Sint16 d_e = 3; @@ -2145,7 +2145,7 @@ void sge_FilledCircle(SDL_Surface* Surface, Sint16 x, Sint16 y, Uint16 r, Uint8 void sge_FilledCircleAlpha(SDL_Surface* Surface, Sint16 x, Sint16 y, Uint16 r, Uint32 color, Uint8 alpha) { Sint16 cx = 0; - Sint16 cy = (Sint16)r; + auto cy = (Sint16)r; bool draw = true; Sint16 df = 1 - (Sint16)r; Sint16 d_e = 3; @@ -2230,7 +2230,7 @@ void sge_AAFilledCircle(SDL_Surface* surface, Sint16 xc, Sint16 yc, Uint16 r, Ui /* Note: I don't think there is any great performance win in translating this to fixed-point integer math, */ \ /* most of the time is spent in the line drawing routine. */ \ /* */ \ - float x = float(x1), y = float(y1); \ + auto x = float(x1), y = float(y1); \ float xp = x, yp = y; \ float delta; \ float dx, d2x, d3x; \ diff --git a/SGE/sge_rotation.cpp b/SGE/sge_rotation.cpp index 82556f2..96f9296 100644 --- a/SGE/sge_rotation.cpp +++ b/SGE/sge_rotation.cpp @@ -51,10 +51,10 @@ static void _calcRect(SDL_Surface* src, SDL_Surface* dst, float theta, float xsc // We don't really need fixed-point here // but why not? - Sint32 const istx = Sint32((sin(theta) * xscale) * 8192.0); /* Inverse transform */ - Sint32 const ictx = Sint32((cos(theta) * xscale) * 8192.2); - Sint32 const isty = Sint32((sin(theta) * yscale) * 8192.0); - Sint32 const icty = Sint32((cos(theta) * yscale) * 8192.2); + auto const istx = Sint32((sin(theta) * xscale) * 8192.0); /* Inverse transform */ + auto const ictx = Sint32((cos(theta) * xscale) * 8192.2); + auto const isty = Sint32((sin(theta) * yscale) * 8192.0); + auto const icty = Sint32((cos(theta) * yscale) * 8192.2); // Calculate the four corner points for(int i = 0; i < 4; i++) @@ -326,14 +326,14 @@ static SDL_Rect sge_transformNorm(SDL_Surface* src, SDL_Surface* dst, float angl SDL_Rect r; r.x = r.y = r.w = r.h = 0; - float theta = float(angle * M_PI / 180.0); /* Convert to radians. */ + auto theta = float(angle * M_PI / 180.0); /* Convert to radians. */ // Here we use 18.13 fixed point integer math // Sint32 should have 31 usable bits and one for sign // 2^13 = 8192 // Check scales - Sint32 maxint = Sint32(pow(2, sizeof(Sint32) * 8 - 1 - 13)); // 2^(31-13) + auto maxint = Sint32(pow(2, sizeof(Sint32) * 8 - 1 - 13)); // 2^(31-13) if(xscale == 0 || yscale == 0) return r; @@ -349,12 +349,12 @@ static SDL_Rect sge_transformNorm(SDL_Surface* src, SDL_Surface* dst, float angl yscale = float(-8192.0 / maxint); // Fixed-point equivalents - Sint32 const stx = Sint32((sin(theta) / xscale) * 8192.0); - Sint32 const ctx = Sint32((cos(theta) / xscale) * 8192.0); - Sint32 const sty = Sint32((sin(theta) / yscale) * 8192.0); - Sint32 const cty = Sint32((cos(theta) / yscale) * 8192.0); - Sint32 const mx = Sint32(px * 8192.0); - Sint32 const my = Sint32(py * 8192.0); + auto const stx = Sint32((sin(theta) / xscale) * 8192.0); + auto const ctx = Sint32((cos(theta) / xscale) * 8192.0); + auto const sty = Sint32((sin(theta) / yscale) * 8192.0); + auto const cty = Sint32((cos(theta) / yscale) * 8192.0); + auto const mx = Sint32(px * 8192.0); + auto const my = Sint32(py * 8192.0); // Compute a bounding rectangle Sint16 xmin = 0, xmax = dst->w, ymin = 0, ymax = dst->h; @@ -433,14 +433,14 @@ static SDL_Rect sge_transformAA(SDL_Surface* src, SDL_Surface* dst, float angle, SDL_Rect r; r.x = r.y = r.w = r.h = 0; - float theta = float(angle * M_PI / 180.0); /* Convert to radians. */ + auto theta = float(angle * M_PI / 180.0); /* Convert to radians. */ // Here we use 18.13 fixed point integer math // Sint32 should have 31 usable bits and one for sign // 2^13 = 8192 // Check scales - Sint32 maxint = Sint32(pow(2, sizeof(Sint32) * 8 - 1 - 13)); // 2^(31-13) + auto maxint = Sint32(pow(2, sizeof(Sint32) * 8 - 1 - 13)); // 2^(31-13) if(xscale == 0 || yscale == 0) return r; @@ -456,12 +456,12 @@ static SDL_Rect sge_transformAA(SDL_Surface* src, SDL_Surface* dst, float angle, yscale = float(-8192.0 / maxint); // Fixed-point equivalents - Sint32 const stx = Sint32((sin(theta) / xscale) * 8192.0); - Sint32 const ctx = Sint32((cos(theta) / xscale) * 8192.0); - Sint32 const sty = Sint32((sin(theta) / yscale) * 8192.0); - Sint32 const cty = Sint32((cos(theta) / yscale) * 8192.0); - Sint32 const mx = Sint32(px * 8192.0); - Sint32 const my = Sint32(py * 8192.0); + auto const stx = Sint32((sin(theta) / xscale) * 8192.0); + auto const ctx = Sint32((cos(theta) / xscale) * 8192.0); + auto const sty = Sint32((sin(theta) / yscale) * 8192.0); + auto const cty = Sint32((cos(theta) / yscale) * 8192.0); + auto const mx = Sint32(px * 8192.0); + auto const my = Sint32(py * 8192.0); // Compute a bounding rectangle Sint16 xmin = 0, xmax = dst->w, ymin = 0, ymax = dst->h; @@ -552,7 +552,7 @@ SDL_Rect sge_transform(SDL_Surface* src, SDL_Surface* dst, float angle, float xs //================================================================================== SDL_Surface* sge_transform_surface(SDL_Surface* src, Uint32 bcol, float angle, float xscale, float yscale, Uint8 flags) { - float theta = float(angle * M_PI / 180.0); /* Convert to radians. */ + auto theta = float(angle * M_PI / 180.0); /* Convert to radians. */ // Compute a bounding rectangle Sint16 xmin = 0, xmax = 0, ymin = 0, ymax = 0; @@ -678,7 +678,7 @@ SDL_Surface* sge_rotate_scaled_surface(SDL_Surface* src, int angle, double scale SDL_Surface* dest; /* Create the destination surface*/ - int max = int(sqrt((src->h * src->h / 2 + src->w * src->w / 2) * scale + 1)); + auto max = int(sqrt((src->h * src->h / 2 + src->w * src->w / 2) * scale + 1)); dest = SDL_AllocSurface(SDL_SWSURFACE, max, max, src->format->BitsPerPixel, src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); if(!dest) diff --git a/SGE/sge_shape.cpp b/SGE/sge_shape.cpp index bb3bda9..72611f5 100644 --- a/SGE/sge_shape.cpp +++ b/SGE/sge_shape.cpp @@ -565,7 +565,7 @@ void sge_ssprite::add_frame(SDL_Surface* img) void sge_ssprite::add_frame(SDL_Surface* img, sge_cdata* cdata) { // Create a new frame - sge_frame* frame = new sge_frame; // User has to catch bad_alloc himself + auto* frame = new sge_frame; // User has to catch bad_alloc himself frame->img = img; frame->cdata = cdata; frames.push_back(frame); diff --git a/SGE/sge_surface.cpp b/SGE/sge_surface.cpp index 5e694f9..1b1fff9 100644 --- a/SGE/sge_surface.cpp +++ b/SGE/sge_surface.cpp @@ -904,7 +904,7 @@ void sge_AlphaFader(Uint8 sR, Uint8 sG, Uint8 sB, Uint8 sA, Uint8 dR, Uint8 dG, //================================================================================== void sge_SetupRainbowPalette(SDL_Surface* Surface, Uint32* ctab, int intensity, int start, int stop) { - int slice = (int)((stop - start) / 6); + auto slice = (int)((stop - start) / 6); /* Red-Yellow */ sge_Fader(Surface, 255, intensity, intensity, 255, 255, intensity, ctab, start, slice); diff --git a/SGE/sge_textpp.cpp b/SGE/sge_textpp.cpp index d056f5d..e5c76c9 100644 --- a/SGE/sge_textpp.cpp +++ b/SGE/sge_textpp.cpp @@ -33,7 +33,7 @@ using namespace std; //================================================================================== sge_TextEditor::node* sge_TextEditor::new_node(node* p, node* n, Uint16 c) { - node* tmp = new node; + auto* tmp = new node; tmp->prev = p; tmp->next = n;