| 16231 | |
| 16232 | std::map<int, std::map<std::tuple<Uint8, Uint8, Uint8, Uint8, real_t, real_t, int>, SDL_Surface*>> AOEIndicators_t::surfaceCache; |
| 16233 | void AOEIndicators_t::Indicator_t::updateIndicator() |
| 16234 | { |
| 16235 | if ( !(!gamePaused || (multiplayer && !client_disconnected[0])) ) |
| 16236 | { |
| 16237 | // paused game |
| 16238 | return; |
| 16239 | } |
| 16240 | |
| 16241 | if ( delayTicks > 0 ) |
| 16242 | { |
| 16243 | --delayTicks; |
| 16244 | return; |
| 16245 | } |
| 16246 | |
| 16247 | //auto t1 = std::chrono::high_resolution_clock::now(); |
| 16248 | |
| 16249 | const int ringSize = 1; |
| 16250 | const int gradientSize = gradient; |
| 16251 | int ring = radius - ringSize; |
| 16252 | int center = size / 2; |
| 16253 | //for ( int r = std::max(0, radius - gradientSize); r <= radius; r += 1 ) |
| 16254 | //{ |
| 16255 | // /*real_t minAngle = 0.9 * acos(1.0 - 1.0 / r); |
| 16256 | // for ( real_t i = 0; i < 360; i += minAngle ) |
| 16257 | // { |
| 16258 | // x = (size / 2) + r * std::min(0.9999, cos(i)); |
| 16259 | // y = (size / 2) + r * std::min(0.9999, sin(i)); |
| 16260 | // assert(x >= 0 && x < size); |
| 16261 | // assert(y >= 0 && y < size); |
| 16262 | |
| 16263 | // if ( r < ring ) |
| 16264 | // { |
| 16265 | // real_t alphaRatio = std::min(1.0, std::max(0.0, 1.0 + (ringSize + r - radius) / (real_t)gradientSize)); |
| 16266 | // putPixel(surfaceNew, x, y, makeColor(255, 255, 255, std::min(255.0, 255 * alphaRatio))); |
| 16267 | // } |
| 16268 | // else if ( r == ring ) |
| 16269 | // { |
| 16270 | // putPixel(surfaceNew, x, y, makeColor(255, 255, 255, 255)); |
| 16271 | // } |
| 16272 | // else |
| 16273 | // { |
| 16274 | // putPixel(surfaceNew, x, y, makeColor(212, 212, 212, 255)); |
| 16275 | // } |
| 16276 | // }*/ |
| 16277 | |
| 16278 | // /*x = r; |
| 16279 | // y = 0; |
| 16280 | // int error = 3 - 2 * radius; |
| 16281 | // while ( x >= y ) |
| 16282 | // { |
| 16283 | // putPixel(surfaceNew, center + x, center + y, makeColor(255, 255, 255, 255)); |
| 16284 | // putPixel(surfaceNew, center + x, center - y, makeColor(255, 255, 255, 255)); |
| 16285 | // putPixel(surfaceNew, center -x, center + y, makeColor(255, 255, 255, 255)); |
| 16286 | // putPixel(surfaceNew, center -x, center - y, makeColor(255, 255, 255, 255)); |
| 16287 | |
| 16288 | // putPixel(surfaceNew, center + y, center + x, makeColor(255, 255, 255, 255)); |
| 16289 | // putPixel(surfaceNew, center + y, center - x, makeColor(255, 255, 255, 255)); |
| 16290 | // putPixel(surfaceNew, center - y, center + x, makeColor(255, 255, 255, 255)); |