no message
This commit is contained in:
@@ -152,6 +152,89 @@ int main() {
|
||||
"chk_time past cap: released immediately (staleness valve)");
|
||||
}
|
||||
|
||||
// --- 7) motion-driven remote walk (reference MovementProcess) --------------
|
||||
// Speed comes from the WALK/RUN root motion * movSpd/100, not dwDuration;
|
||||
// heading follows Src->Dst while walking and takes bRot on arrival.
|
||||
{
|
||||
EntityStore es;
|
||||
es.set_now(0);
|
||||
es.mut_spawn(70, 101, 2, "Wolf", 0, 0, 0, 0, 100 /*moving_speed*/, 0);
|
||||
es.set_motion_speed(70, 87.5f, 425.0f);
|
||||
es.tick();
|
||||
// server says 100 ms (it prices NPC walks at RUN speed); ignored here.
|
||||
es.mut_move(70, 45.0f, FUNC_WAIT, 1000.0f, 0.0f, 100, 0, 0);
|
||||
CHECK(es.get(70)->moving && std::abs(es.get(70)->angle - 90.0f) < 1e-3f,
|
||||
"motion walk: faces Src->Dst, not bRot");
|
||||
uint32_t now = 0;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
now += 100;
|
||||
es.set_now(now);
|
||||
es.tick();
|
||||
}
|
||||
CHECK(es.get(70)->moving && std::abs(es.get(70)->x - 425.0f) < 1.0f,
|
||||
"motion walk: run mode advances at RUN motion speed, ignores dwDuration");
|
||||
es.mut_walk_mode(70, WALKMODE_WALK);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
now += 100;
|
||||
es.set_now(now);
|
||||
es.tick();
|
||||
}
|
||||
CHECK(std::abs(es.get(70)->x - 512.5f) < 1.0f, "motion walk: walk mode uses WALK motion speed");
|
||||
es.mut_change_speed(70, 200); // movSpd 200 doubles the step
|
||||
now += 1000;
|
||||
es.set_now(now);
|
||||
es.tick(); // capped at MOVE_MAX_TICK_MS
|
||||
CHECK(std::abs(es.get(70)->x - (512.5f + 175.0f * 0.25f)) < 1.0f,
|
||||
"motion walk: movSpd scales speed; tick step capped");
|
||||
for (int i = 0; i < 100 && es.get(70)->moving; ++i) {
|
||||
now += 100;
|
||||
es.set_now(now);
|
||||
es.tick();
|
||||
}
|
||||
CHECK(!es.get(70)->moving && es.get(70)->func == FUNC_WAIT, "motion walk: stops on arrival");
|
||||
CHECK(es.get(70)->x == 1000.0f && es.get(70)->y == 0.0f, "motion walk: snaps to Dst");
|
||||
CHECK(std::abs(es.get(70)->angle - 45.0f) < 1e-3f, "motion walk: bRot applied on arrival");
|
||||
}
|
||||
|
||||
// --- 8) FUNC_MOVE walks past Dst, overshoot guard turns back and stops ------
|
||||
{
|
||||
EntityStore es;
|
||||
es.set_now(0);
|
||||
es.mut_spawn(80, 0, 0, "Pc", 0, 0, 0, 0, 100, 0);
|
||||
es.set_motion_speed(80, 0.0f, 1000.0f);
|
||||
es.tick();
|
||||
es.mut_move(80, 90.0f, FUNC_MOVE, 100.0f, 0.0f, 100, 0, 0);
|
||||
uint32_t now = 0;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
now += 50;
|
||||
es.set_now(now);
|
||||
es.tick();
|
||||
}
|
||||
CHECK(es.get(80)->moving && es.get(80)->x > 100.0f, "FUNC_MOVE: keeps walking past Dst");
|
||||
bool turned = false;
|
||||
for (int i = 0; i < 40 && es.get(80)->moving; ++i) {
|
||||
now += 50;
|
||||
es.set_now(now);
|
||||
es.tick();
|
||||
turned = turned || std::abs(es.get(80)->angle - 270.0f) < 1e-3f;
|
||||
}
|
||||
CHECK(turned, "FUNC_MOVE overshoot: turns back toward Dst");
|
||||
CHECK(!es.get(80)->moving && es.get(80)->x == 100.0f && es.get(80)->func == FUNC_WAIT,
|
||||
"FUNC_MOVE overshoot: returns to Dst and stops");
|
||||
}
|
||||
|
||||
// --- 9) unknown motion speed keeps the dwDuration lerp, heading Src->Dst -----
|
||||
{
|
||||
EntityStore es;
|
||||
es.set_now(0);
|
||||
spawn(es, 90, 0, 0);
|
||||
es.mut_move(90, 0.0f, FUNC_WAIT, 0.0f, -500.0f, 1000, 0, 0);
|
||||
CHECK(std::abs(es.get(90)->angle - 180.0f) < 1e-3f, "duration walk: faces Src->Dst");
|
||||
es.set_now(500);
|
||||
es.tick();
|
||||
CHECK(std::abs(es.get(90)->y + 250.0f) < 1e-3f, "duration walk: lerps over dwDuration");
|
||||
}
|
||||
|
||||
if (g_fail == 0) {
|
||||
std::printf("PASS: net_state_queue_test (§3.2 TCP state queue / thresholds / gates)\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user