| 1395 | } |
| 1396 | |
| 1397 | void BattleMap::initNewMap(sp<Battle> b) |
| 1398 | { |
| 1399 | // Init visibility |
| 1400 | for (auto &o : b->participants) |
| 1401 | { |
| 1402 | b->visibleTiles[o] = std::vector<bool>(b->size.x * b->size.y * b->size.z, false); |
| 1403 | b->visibleBlocks[o] = std::vector<bool>(b->losBlocks.size(), false); |
| 1404 | b->visibleUnits[o] = {}; |
| 1405 | } |
| 1406 | |
| 1407 | // Init los block pathfinding |
| 1408 | |
| 1409 | // Vars |
| 1410 | int size = b->losBlocks.size(); |
| 1411 | auto &losBlocks = b->losBlocks; |
| 1412 | auto &linkAvailable = b->linkAvailable; |
| 1413 | |
| 1414 | // Mark all blocks for update |
| 1415 | b->linkNeedsUpdate = std::vector<bool>(size * size, false); |
| 1416 | b->blockNeedsUpdate = std::vector<bool>(size, true); |
| 1417 | |
| 1418 | // Init which blocks are adjacent (this never changes) |
| 1419 | linkAvailable = std::vector<bool>(size * size, false); |
| 1420 | for (int i = 0; i < size - 1; i++) |
| 1421 | { |
| 1422 | auto &b1 = *losBlocks[i]; |
| 1423 | for (int j = i + 1; j < size; j++) |
| 1424 | { |
| 1425 | auto &b2 = *losBlocks[j]; |
| 1426 | if (doTwoSectorsIntersect( |
| 1427 | b1.start.x, b1.start.y, b1.start.z, b1.end - b1.start + Vec3<int>{1, 1, 1}, |
| 1428 | b2.start.x, b2.start.y, b2.start.z, b2.end - b2.start + Vec3<int>{1, 1, 1})) |
| 1429 | { |
| 1430 | linkAvailable[i + j * size] = true; |
| 1431 | linkAvailable[j + i * size] = true; |
| 1432 | } |
| 1433 | } |
| 1434 | } |
| 1435 | |
| 1436 | // Init arrays for further use |
| 1437 | for (auto &type : BattleUnitTypeList) |
| 1438 | { |
| 1439 | b->blockAvailable[type] = std::vector<bool>(size, false); |
| 1440 | b->blockCenterPos[type] = std::vector<Vec3<int>>(size, Vec3<int>()); |
| 1441 | b->linkCost[type] = std::vector<int>(size * size, -1); |
| 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | void BattleMap::unloadTiles() |
| 1446 | { |
nothing calls this directly
no test coverage detected