| 1523 | } |
| 1524 | |
| 1525 | void BattleMap::loadTilesets(GameState &state) const |
| 1526 | { |
| 1527 | if (state.battleMapTiles.size() > 0) |
| 1528 | { |
| 1529 | LogInfo("Tilesets are already loaded."); |
| 1530 | return; |
| 1531 | } |
| 1532 | |
| 1533 | // Load all tilesets used by the map |
| 1534 | for (auto &tilesetName : this->tilesets) |
| 1535 | { |
| 1536 | unsigned count = 0; |
| 1537 | auto tilesetPath = BattleMapTileset::getTilesetPath() + "/" + tilesetName; |
| 1538 | LogInfo("Loading tileset \"%s\" from \"%s\"", tilesetName, tilesetPath); |
| 1539 | BattleMapTileset tileset; |
| 1540 | if (!tileset.loadTileset(state, tilesetPath)) |
| 1541 | { |
| 1542 | LogError("Failed to load tileset \"%s\" from \"%s\"", tilesetName, tilesetPath); |
| 1543 | continue; |
| 1544 | } |
| 1545 | |
| 1546 | for (auto &tilePair : tileset.map_part_types) |
| 1547 | { |
| 1548 | auto &tileName = tilePair.first; |
| 1549 | auto &tile = tilePair.second; |
| 1550 | // Assign sounds |
| 1551 | if (tile->sfxIndex != -1) |
| 1552 | { |
| 1553 | tile->walkSounds = state.battle_common_sample_list->walkSounds.at(tile->sfxIndex); |
| 1554 | tile->objectDropSound = |
| 1555 | state.battle_common_sample_list->objectDropSounds.at(tile->sfxIndex); |
| 1556 | } |
| 1557 | // Assign map marts |
| 1558 | switch (tile->type) |
| 1559 | { |
| 1560 | case BattleMapPartType::Type::Ground: |
| 1561 | tile->rubble = rubble_feature; |
| 1562 | tile->destroyed_ground_tile = destroyed_ground_tile; |
| 1563 | break; |
| 1564 | case BattleMapPartType::Type::LeftWall: |
| 1565 | tile->rubble = rubble_left_wall; |
| 1566 | break; |
| 1567 | case BattleMapPartType::Type::RightWall: |
| 1568 | tile->rubble = rubble_right_wall; |
| 1569 | break; |
| 1570 | case BattleMapPartType::Type::Feature: |
| 1571 | tile->rubble = rubble_feature; |
| 1572 | break; |
| 1573 | } |
| 1574 | tile->damageModifier = {&state, "DAMAGEMODIFIER_TERRAIN_1_"}; |
| 1575 | // Sanity check |
| 1576 | if (state.battleMapTiles.find(tileName) != state.battleMapTiles.end()) |
| 1577 | { |
| 1578 | LogError("Duplicate tile with ID \"%s\"", tileName); |
| 1579 | continue; |
| 1580 | } |
| 1581 | state.battleMapTiles.emplace(tileName, tile); |
| 1582 | count++; |
no test coverage detected