| 1211 | } |
| 1212 | |
| 1213 | void Game_Character::UpdateFacing() { |
| 1214 | // RPG_RT only does the IsSpinning() check for Game_Event. We did it for all types here |
| 1215 | // in order to avoid a virtual call and because normally with RPG_RT, spinning |
| 1216 | // player or vehicle is impossible. |
| 1217 | if (IsFacingLocked() || IsSpinning()) { |
| 1218 | return; |
| 1219 | } |
| 1220 | const auto dir = GetDirection(); |
| 1221 | const auto facing = GetFacing(); |
| 1222 | if (dir >= 4) /* is diagonal */ { |
| 1223 | // [UR, DR, DL, UL] -> [U, D, D, U] |
| 1224 | const auto f1 = ((dir + (dir >= 6)) % 2) * 2; |
| 1225 | // [UR, DR, DL, UL] -> [R, R, L, L] |
| 1226 | const auto f2 = (dir / 2) - (dir < 6); |
| 1227 | if (facing != f1 && facing != f2) { |
| 1228 | // Reverse the direction. |
| 1229 | SetFacing((facing + 2) % 4); |
| 1230 | } |
| 1231 | } else { |
| 1232 | SetFacing(dir); |
| 1233 | } |
| 1234 | } |
no outgoing calls
no test coverage detected