| 193 | } |
| 194 | |
| 195 | static void testJump(bool success, int x, int y, int dir, int face, |
| 196 | int dx, int dy, int freq, int speed, bool facing_locked) { |
| 197 | |
| 198 | const MockGame mg(MockMap::ePassBlock20x15); |
| 199 | auto& ch = *mg.GetEvent(1); |
| 200 | |
| 201 | ch.SetX(x); |
| 202 | ch.SetY(y); |
| 203 | ch.SetDirection(dir); |
| 204 | ch.SetFacing(face); |
| 205 | ch.SetMoveSpeed(speed); |
| 206 | ch.SetMoveFrequency(freq); |
| 207 | const auto maxstop = ch.GetMaxStopCount(); |
| 208 | if (facing_locked) { |
| 209 | ch.SetFacingLocked(true); |
| 210 | } |
| 211 | |
| 212 | CAPTURE(success); |
| 213 | CAPTURE(speed); |
| 214 | CAPTURE(freq); |
| 215 | |
| 216 | const auto tx = x + dx; |
| 217 | const auto ty = y + dy; |
| 218 | |
| 219 | // Expected direction after the jump finishes. |
| 220 | auto tdir = Down; |
| 221 | if (std::abs(dy) >= std::abs(dx)) { |
| 222 | tdir = dy >= 0 ? Down : Up; |
| 223 | } else { |
| 224 | tdir = dx >= 0 ? Right : Left; |
| 225 | } |
| 226 | auto tface = facing_locked ? face : tdir; |
| 227 | |
| 228 | // Jump in place always succeeds |
| 229 | if (x == tx && y == ty) { |
| 230 | success = true; |
| 231 | } |
| 232 | |
| 233 | INFO("BEFORE JUMP"); |
| 234 | |
| 235 | REQUIRE_EQ(ch.Jump(tx, ty), success); |
| 236 | |
| 237 | if (!success) { |
| 238 | INFO("FAIL JUMP"); |
| 239 | testChar(ch, tx, ty, tdir, tface, 0, false, 0, 0, freq, speed, 0, maxstop); |
| 240 | return; |
| 241 | } |
| 242 | |
| 243 | testChar(ch, tx, ty, tdir, tface, 256, true, x, y, freq, speed, 0, maxstop); |
| 244 | |
| 245 | // FIXME: Verify all speeds |
| 246 | static const int jump_speed[] = {8, 12, 16, 24, 32, 64}; |
| 247 | const auto dt = jump_speed[speed - 1]; |
| 248 | |
| 249 | INFO("ANIMATE JUMP"); |
| 250 | |
| 251 | for(int i = 256 - dt; i > 0; i -= dt) { |
| 252 | ForceUpdate(ch); |
no test coverage detected