General Cleanup of vehicles

This commit is contained in:
MegaMech
2024-11-16 16:40:39 -07:00
parent be9f49a0be
commit d29f5c7a64
6 changed files with 47 additions and 49 deletions
+5
View File
@@ -46,6 +46,11 @@ static size_t busses;
static size_t tankerTrucks;
static size_t cars;
static size_t boats;
/**
* Note that you can only remove the tender if there are no carriages
* @arg waypoint initial waypoint to spawn at.
*/
void World::AddTrain(ATrain::TenderStatus tender, size_t numCarriages, f32 speed, uint32_t waypoint) {
Vehicles.push_back(std::make_unique<ATrain>(trains, tender, numCarriages, speed, waypoint));
trains++;
+7 -12
View File
@@ -12,7 +12,6 @@
#include "engine/vehicles/Utils.h"
#include "engine/vehicles/Vehicle.h"
#include "engine/vehicles/Train.h"
extern "C" {
#include "main.h"
@@ -202,31 +201,27 @@ void KalimariDesert::MinimapFinishlinePosition() {
void KalimariDesert::SpawnVehicles() {
generate_train_waypoints();
s32 numTrains = 2;
s32 numCars = 5;
ATrain::TenderStatus tender = ATrain::TenderStatus::HAS_TENDER;
s32 centerWaypoint = 160;
// Spawn two trains
for (size_t i = 0; i < numTrains; ++i) {
uint32_t waypoint = CalculateWaypointDistribution(i, numTrains, gVehicle2DWaypointLength, centerWaypoint);
for (size_t i = 0; i < _numTrains; ++i) {
uint32_t waypoint = CalculateWaypointDistribution(i, _numTrains, gVehicle2DWaypointLength, centerWaypoint);
if (CVarGetInteger("gMultiplayerNoFeatureCuts", 0) == false) {
// Multiplayer modes have no tender and no carriages
if (gActiveScreenMode != SCREEN_MODE_1P) {
tender = ATrain::TenderStatus::NO_TENDER;
numCars = 0;
_tender = ATrain::TenderStatus::NO_TENDER;
_numCarriages = 0;
}
// 2 player versus mode has a tender and a carriage
if ((gModeSelection == VERSUS) && (gPlayerCountSelection1 == 2)) {
tender = ATrain::TenderStatus::HAS_TENDER;
numCars = 1;
_tender = ATrain::TenderStatus::HAS_TENDER;
_numCarriages = 1;
}
}
gWorldInstance.AddTrain(tender, numCars, 2.5f, waypoint);
gWorldInstance.AddTrain(_tender, _numCarriages, 2.5f, waypoint);
}
if (gModeSelection == VERSUS) {
+6
View File
@@ -2,6 +2,7 @@
#include <libultraship.h>
#include "Course.h"
#include "engine/vehicles/Train.h"
extern "C" {
#include "assets/kalimari_desert_vertices.h"
@@ -38,4 +39,9 @@ public:
virtual void SpawnVehicles() override;
virtual void Collision() override;
virtual void Destroy() override;
private:
size_t _numTrains = 2;
size_t _numCarriages = 5;
ATrain::TenderStatus _tender = ATrain::TenderStatus::HAS_TENDER;
};
+23 -37
View File
@@ -218,52 +218,38 @@ void ToadsTurnpike::RenderCredits() {
void ToadsTurnpike::Collision() {}
void ToadsTurnpike::SpawnVehicles() {
uint32_t waypoint;
f32 a = ((gCCSelection * 90.0) / 216.0f) + 4.583333333333333;
f32 b = ((gCCSelection * 90.0) / 216.0f) + 2.9166666666666665;
a /= 2; // Normally vehicle logic is only ran every 2 frames. This slows the vehicles down to match.
b /= 2;
uint32_t waypoint;
// Other game modes spawn seven of each vehicle
if (gModeSelection == TIME_TRIALS) {
for (size_t i = 0; i < NUM_TIME_TRIAL_BOX_TRUCKS; i++) {
waypoint = CalculateWaypointDistribution(i, NUM_TIME_TRIAL_BOX_TRUCKS, gWaypointCountByPathIndex[0], 0);
gWorldInstance.AddTruck(a, b, &D_80164550[0][0], waypoint);
}
_numTrucks = 8;
_numBuses = 8;
_numTankerTrucks = 8;
_numCars = 8;
}
for (size_t i = 0; i < _numTrucks; i++) {
waypoint = CalculateWaypointDistribution(i, _numTrucks, gWaypointCountByPathIndex[0], 0);
gWorldInstance.AddTruck(a, b, &D_80164550[0][0], waypoint);
}
for (size_t i = 0; i < NUM_TIME_TRIAL_SCHOOL_BUSES; i++) {
waypoint = CalculateWaypointDistribution(i, NUM_TIME_TRIAL_SCHOOL_BUSES, gWaypointCountByPathIndex[0], 75);
gWorldInstance.AddBus(a, b, &D_80164550[0][0], waypoint);
}
for (size_t i = 0; i < _numBuses; i++) {
waypoint = CalculateWaypointDistribution(i, _numBuses, gWaypointCountByPathIndex[0], 75);
gWorldInstance.AddBus(a, b,&D_80164550[0][0], waypoint);
}
for (size_t i = 0; i < NUM_TIME_TRIAL_TANKER_TRUCKS; i++) {
waypoint = CalculateWaypointDistribution(i, NUM_TIME_TRIAL_TANKER_TRUCKS, gWaypointCountByPathIndex[0], 50);
gWorldInstance.AddTankerTruck(a, b, &D_80164550[0][0], waypoint);
}
for (size_t i = 0; i < _numTankerTrucks; i++) {
waypoint = CalculateWaypointDistribution(i, _numTankerTrucks, gWaypointCountByPathIndex[0], 50);
gWorldInstance.AddTankerTruck(a, b, &D_80164550[0][0], waypoint);
}
for (size_t i = 0; i < NUM_TIME_TRIAL_CARS; i++) {
waypoint = CalculateWaypointDistribution(i, NUM_TIME_TRIAL_CARS, gWaypointCountByPathIndex[0], 25);
gWorldInstance.AddCar(a, b, &D_80164550[0][0], waypoint);
}
} else { // All other modes
for (size_t i = 0; i < NUM_RACE_BOX_TRUCKS; i++) {
uint32_t waypoint = CalculateWaypointDistribution(i, NUM_RACE_BOX_TRUCKS, gWaypointCountByPathIndex[0], 0);
gWorldInstance.AddTruck(a, b, &D_80164550[0][0], waypoint);
}
for (size_t i = 0; i < NUM_RACE_SCHOOL_BUSES; i++) {
waypoint = CalculateWaypointDistribution(i, NUM_RACE_SCHOOL_BUSES, gWaypointCountByPathIndex[0], 75);
gWorldInstance.AddBus(a, b,&D_80164550[0][0], waypoint);
}
for (size_t i = 0; i < NUM_RACE_TANKER_TRUCKS; i++) {
waypoint = CalculateWaypointDistribution(i, NUM_RACE_TANKER_TRUCKS, gWaypointCountByPathIndex[0], 50);
gWorldInstance.AddTankerTruck(a, b, &D_80164550[0][0], waypoint);
}
for (size_t i = 0; i < NUM_RACE_CARS; i++) {
waypoint = CalculateWaypointDistribution(i, NUM_RACE_CARS, gWaypointCountByPathIndex[0], 25);
gWorldInstance.AddCar(a, b, &D_80164550[0][0], waypoint);
}
for (size_t i = 0; i < _numCars; i++) {
waypoint = CalculateWaypointDistribution(i, _numCars, gWaypointCountByPathIndex[0], 25);
gWorldInstance.AddCar(a, b, &D_80164550[0][0], waypoint);
}
if (gModeSelection == VERSUS) {
+5
View File
@@ -39,4 +39,9 @@ public:
virtual void Collision() override;
virtual void SpawnVehicles() override;
virtual void Destroy() override;
private:
size_t _numTrucks = 7;
size_t _numBuses = 7;
size_t _numTankerTrucks = 7;
size_t _numCars = 7;
};
+1
View File
@@ -416,6 +416,7 @@ void func_802A487C(Vtx* arg0, UNUSED struct UnkStruct_800DC5EC* arg1, UNUSED s32
}
void func_802A4A0C(Vtx* vtx, struct UnkStruct_800DC5EC* arg1, UNUSED s32 arg2, UNUSED s32 arg3, UNUSED f32* arg4) {
//! @todo Confirm if this crash still happens and fix if so
s32 id = arg1 - D_8015F480;
arg1->camera = &cameras[id]; // bad fix of bowser castle crash where camera get an invalid value
Camera* camera = arg1->camera;