summaryrefslogtreecommitdiff
path: root/src/engine/TrainCrossing.cpp
diff options
context:
space:
mode:
authorcoco875 <59367621+coco875@users.noreply.github.com>2025-06-19 22:26:04 +0000
committerGitHub <noreply@github.com>2025-06-19 16:26:04 -0600
commit5d7cf20c83bf49e6b27f07684535727506526012 (patch)
treed5a02b39520ff255f4b1ffc557be5026d481427c /src/engine/TrainCrossing.cpp
parent602141fb11e2614583caa23b250ca115ce451c99 (diff)
pr Code 80005fd0 (#181)
* fix error * a lot of change * basic rename of local variable * continue rename and improve Enhancements * re-apply change * revert the remove of dma_texture and fix mtxf_multiplication * more documentation port * some fix * more fix * fix arround * Update torch * fix spelling --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
Diffstat (limited to 'src/engine/TrainCrossing.cpp')
-rw-r--r--src/engine/TrainCrossing.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/engine/TrainCrossing.cpp b/src/engine/TrainCrossing.cpp
index 8dce6984b..21eefc8d2 100644
--- a/src/engine/TrainCrossing.cpp
+++ b/src/engine/TrainCrossing.cpp
@@ -29,9 +29,9 @@ void TrainCrossing::CrossingTrigger() {
s32 i;
OnTriggered = 0;
-
for (const auto& actor : gWorldInstance.Actors) {
- if (auto train = dynamic_cast<ATrain*>(actor)) {;
+ if (auto train = dynamic_cast<ATrain*>(actor)) {
+ ;
f32 radius = DynamicRadius(train->Locomotive.position, train->Locomotive.velocity, Position);
if (Distance(train->Locomotive.position, Position) < radius) {
@@ -53,7 +53,7 @@ void TrainCrossing::AICrossingBehaviour(s32 playerId) {
if ((!(D_801631E0[playerId] != 0)) ||
(set_vehicle_render_distance_flags(gPlayers[playerId].pos, TRAIN_CROSSING_AI_DISTANCE, 0))) {
if ((OnTriggered == 1) && ((Timer) > FRAMES_SINCE_CROSSING_ACTIVATED)) {
- if ((sSomeNearestWaypoint > WaypointMin) && (sSomeNearestWaypoint < WaypointMax)) {
+ if ((sSomeNearestPathPoint > WaypointMin) && (sSomeNearestPathPoint < WaypointMax)) {
bStopAICrossing[playerId] = 1;
}
}
@@ -61,9 +61,9 @@ void TrainCrossing::AICrossingBehaviour(s32 playerId) {
}
f32 TrainCrossing::Distance(Vec3f a, Vec3f b) {
- float dx = b[0] - a[0]; // Difference in x-coordinates
- float dy = b[1] - a[1]; // Difference in y-coordinates
- float dz = b[2] - a[2]; // Difference in z-coordinates
+ float dx = b[0] - a[0]; // Difference in x-coordinates
+ float dy = b[1] - a[1]; // Difference in y-coordinates
+ float dz = b[2] - a[2]; // Difference in z-coordinates
return sqrt(dx * dx + dy * dy + dz * dz); // Return the distance
}
@@ -75,8 +75,7 @@ f32 TrainCrossing::DynamicRadius(Vec3f trainPos, Vec3f trainVelocity, Vec3f cros
trainToCrossing[2] = crossingPos[2] - trainPos[2];
// Dot product to check if the train is approaching or moving away from the crossing
- f32 dotProduct = trainToCrossing[0] * trainVelocity[0] +
- trainToCrossing[1] * trainVelocity[1] +
+ f32 dotProduct = trainToCrossing[0] * trainVelocity[0] + trainToCrossing[1] * trainVelocity[1] +
trainToCrossing[2] * trainVelocity[2];
if (dotProduct > 0) {