* Draws the whole map, part by part. */
| 162 | * Draws the whole map, part by part. |
| 163 | */ |
| 164 | void Map::draw() |
| 165 | { |
| 166 | if (!_redraw) |
| 167 | { |
| 168 | return; |
| 169 | } |
| 170 | Surface::draw(); |
| 171 | Tile *t; |
| 172 | |
| 173 | _projectileInFOV = _save->getDebugMode(); |
| 174 | if (_projectile) |
| 175 | { |
| 176 | t = _save->getTile(Position(_projectile->getPosition(0).x/16, _projectile->getPosition(0).y/16, _projectile->getPosition(0).z/24)); |
| 177 | if (_save->getSide() == FACTION_PLAYER || (t && t->getVisible())) |
| 178 | { |
| 179 | _projectileInFOV = true; |
| 180 | } |
| 181 | } |
| 182 | _explosionInFOV = _save->getDebugMode(); |
| 183 | if (!_explosions.empty()) |
| 184 | { |
| 185 | for (std::list<Explosion*>::iterator i = _explosions.begin(); i != _explosions.end(); ++i) |
| 186 | { |
| 187 | t = _save->getTile(Position((*i)->getPosition().x/16, (*i)->getPosition().y/16, (*i)->getPosition().z/24)); |
| 188 | if (t && ((*i)->isBig() || t->getVisible())) |
| 189 | { |
| 190 | _explosionInFOV = true; |
| 191 | break; |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | if ((_save->getSelectedUnit() && _save->getSelectedUnit()->getVisible()) || _unitDying || _save->getSelectedUnit() == 0 || _save->getDebugMode() || _projectileInFOV || _explosionInFOV) |
| 197 | { |
| 198 | drawTerrain(this); |
| 199 | } |
| 200 | else |
| 201 | { |
| 202 | _message->blit(this); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Replaces a certain amount of colors in the surface's palette. |
no test coverage detected