mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 10:53:44 +00:00
The client works out on its own when its racer goes the wrong way and shows a 6 second countdown, but it only moves the car when the server sends RacingSetPlayerResetInfo, which DLU never did for this. The server now follows the reset planes the way the client's LWORacingControlComponent does (1.10.64): each path waypoint is a plane facing along its rotation; the racer starts between planes 0 and 1, moves forward when in front of the upcoming plane and back when behind the last one (CheckUpcomingResetPlane @ 0x00c7edf0, CheckLastResetPlane @ 0x00c7f1a0, CrossResetPlaneBackward @ 0x00cba380). Driving back through a second plane in a row starts the client's countdown (UpdateWrongWayCount @ 0x00be5c10, 6 seconds); going forward through a plane ends it. When it runs out, the racer gets the same reset as an unsmashed reset: reset info for their furthest point and RacingResetPlayerToLastReset. Resets sent for smashes keep the planes in step as well. Fixes issue 764. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
1.8 KiB
C++
49 lines
1.8 KiB
C++
#include "GameMessages.h"
|
|
#include "RacingControlComponent.h"
|
|
#include "ZoneFile.h"
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace {
|
|
// A straight track along +Z with planes every 10 units, all facing along the track
|
|
std::vector<PathWaypoint> StraightTrack() {
|
|
std::vector<PathWaypoint> waypoints(5);
|
|
for (size_t i = 0; i < waypoints.size(); i++) waypoints[i].position = NiPoint3(0.0f, 0.0f, 10.0f * static_cast<float>(i));
|
|
return waypoints;
|
|
}
|
|
}
|
|
|
|
TEST(RacingWrongWayTests, DrivingForwardMovesThePlanes) {
|
|
const auto track = StraightTrack();
|
|
RacingPlayerInfo player{};
|
|
RacingControlComponent::StepResetPlanes(player, track, NiPoint3(0.0f, 0.0f, 5.0f));
|
|
EXPECT_EQ(player.lastPlane, 0u);
|
|
EXPECT_EQ(player.upcomingPlane, 1u);
|
|
RacingControlComponent::StepResetPlanes(player, track, NiPoint3(0.0f, 0.0f, 25.0f));
|
|
EXPECT_EQ(player.lastPlane, 2u);
|
|
EXPECT_EQ(player.upcomingPlane, 3u);
|
|
EXPECT_EQ(player.wrongWayCount, 0u);
|
|
EXPECT_LT(player.wrongWayTime, 0.0f);
|
|
}
|
|
|
|
TEST(RacingWrongWayTests, TheSecondPlaneBackStartsTheCountdown) {
|
|
const auto track = StraightTrack();
|
|
RacingPlayerInfo player{};
|
|
player.lastPlane = 3;
|
|
player.upcomingPlane = 4;
|
|
RacingControlComponent::StepResetPlanes(player, track, NiPoint3(0.0f, 0.0f, 25.0f));
|
|
EXPECT_EQ(player.wrongWayCount, 1u);
|
|
EXPECT_LT(player.wrongWayTime, 0.0f);
|
|
RacingControlComponent::StepResetPlanes(player, track, NiPoint3(0.0f, 0.0f, 15.0f));
|
|
EXPECT_EQ(player.wrongWayCount, 2u);
|
|
EXPECT_EQ(player.lastPlane, 1u);
|
|
EXPECT_EQ(player.upcomingPlane, 2u);
|
|
EXPECT_FLOAT_EQ(player.wrongWayTime, 6.0f);
|
|
|
|
// Turning around and going through a plane again ends it
|
|
RacingControlComponent::StepResetPlanes(player, track, NiPoint3(0.0f, 0.0f, 21.0f));
|
|
EXPECT_EQ(player.wrongWayCount, 0u);
|
|
EXPECT_LT(player.wrongWayTime, 0.0f);
|
|
EXPECT_EQ(player.lastPlane, 2u);
|
|
}
|