0x00479413
| 124 | |
| 125 | // 0x00479413 |
| 126 | bool updateLevelCrossingAnimation(const Animation& anim) |
| 127 | { |
| 128 | auto tile = TileManager::get(anim.pos); |
| 129 | bool shouldInvalidate = false; |
| 130 | bool hasAnimation = false; |
| 131 | |
| 132 | // It's possible to have multiple level crossing elements on the same tile/baseZ |
| 133 | // this happens if you have tram tracks on road on track. |
| 134 | for (auto& el : tile) |
| 135 | { |
| 136 | auto* elRoad = el.as<RoadElement>(); |
| 137 | if (elRoad == nullptr) |
| 138 | { |
| 139 | continue; |
| 140 | } |
| 141 | if (elRoad->baseZ() != anim.baseZ) |
| 142 | { |
| 143 | continue; |
| 144 | } |
| 145 | if (!elRoad->hasLevelCrossing()) |
| 146 | { |
| 147 | continue; |
| 148 | } |
| 149 | |
| 150 | const auto* levelCrossingObj = ObjectManager::get<LevelCrossingObject>(elRoad->levelCrossingObjectId()); |
| 151 | |
| 152 | if (ScenarioManager::getScenarioTicks() & levelCrossingObj->var_0A) |
| 153 | { |
| 154 | hasAnimation = true; |
| 155 | } |
| 156 | else |
| 157 | { |
| 158 | shouldInvalidate = true; |
| 159 | auto newFrame = elRoad->unk6l(); |
| 160 | if (elRoad->hasUnk7_10()) |
| 161 | { |
| 162 | if (newFrame != 15) |
| 163 | { |
| 164 | newFrame++; |
| 165 | if (newFrame > levelCrossingObj->closedFrames) |
| 166 | { |
| 167 | newFrame = 15; |
| 168 | } |
| 169 | } |
| 170 | hasAnimation = true; |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | if (newFrame != 0) |
| 175 | { |
| 176 | newFrame--; |
| 177 | if (newFrame == 14) |
| 178 | { |
| 179 | newFrame = levelCrossingObj->closedFrames; |
| 180 | } |
| 181 | hasAnimation = true; |
| 182 | } |
| 183 | // Doesn't set hasAnimation = true on else branch! |
no test coverage detected