- tyre tracks edge cases fixed

This commit is contained in:
InspirationByte 2022-01-29 20:30:00 +03:00
parent b839691cd4
commit e33c979a9a
4 changed files with 35 additions and 24 deletions

View File

@ -1482,7 +1482,7 @@ void jump_debris(CAR_DATA* cp)
// [D] [T]
void CheckCarEffects(CAR_DATA* cp, int player_id)
{
static char last_track_state[MAX_TYRE_TRACK_PLAYERS][MAX_TYRE_TRACK_WHEELS] = { -1 };
static char last_track_state[MAX_TYRE_PLAYERS][MAX_TYRE_TRACK_WHEELS] = { -1 };
int skidsound, cnt;
char wheels_on_ground;
@ -1668,20 +1668,20 @@ void CheckCarEffects(CAR_DATA* cp, int player_id)
GetTyreTrackPositions(cp, player_id);
#define ADD_WHEEL_TYRE_TRACK(wheelNum, trackIdx) \
if (wheels_on_ground & (1 << wheelNum)) { \
AddTyreTrack(trackIdx, tracks_and_smoke, player_id, last_track_state[player_id][trackIdx] != -1); \
last_track_state[player_id][trackIdx] = 1; \
} else \
last_track_state[player_id][trackIdx] = -1;
if (wheels_on_ground & (1 << wheelNum)) { \
AddTyreTrack(trackIdx, tracks_and_smoke, player_id, last_track_state[player_id][trackIdx] != -1); \
last_track_state[player_id][trackIdx] = 1; \
} else \
last_track_state[player_id][trackIdx] = -1;
if (lay_down_tracks & 1) // rear
{
#if MAX_TYRE_TRACK_WHEELS == 4
ADD_WHEEL_TYRE_TRACK(0, 0)
ADD_WHEEL_TYRE_TRACK(2, 2)
ADD_WHEEL_TYRE_TRACK(2, 2)
#else
ADD_WHEEL_TYRE_TRACK(0, 0)
ADD_WHEEL_TYRE_TRACK(2, 1)
ADD_WHEEL_TYRE_TRACK(2, 1)
#endif
}
else
@ -1699,7 +1699,7 @@ void CheckCarEffects(CAR_DATA* cp, int player_id)
if (lay_down_tracks & 2) // front
{
ADD_WHEEL_TYRE_TRACK(1, 1)
ADD_WHEEL_TYRE_TRACK(3, 3)
ADD_WHEEL_TYRE_TRACK(3, 3)
}
else
{

View File

@ -1199,15 +1199,27 @@ void StepSim(void)
static int stupid_logic[4];
// "Car Bomb"?
if (gInGameCutsceneActive != 0 && gCurrentMissionNumber == 23 && gInGameCutsceneID == 0)
stupid_logic[0] = 2;
#if MAX_TYRE_TRACK_PLAYERS > 2
if (gInGameCutsceneActive != 0)
{
for (i = 0; i < 4; i++)
{
stupid_logic[i] = player[i + NumPlayers].playerCarId;
}
}
else
stupid_logic[0] = player[0].playerCarId;
#endif
{
// "Car Bomb"?
if (gInGameCutsceneActive != 0 && gCurrentMissionNumber == 23 && gInGameCutsceneID == 0)
stupid_logic[0] = 2;
else
stupid_logic[0] = player[0].playerCarId;
stupid_logic[1] = player[1].playerCarId;
stupid_logic[2] = gThePlayerCar;
stupid_logic[3] = player[0].targetCarId; // [A]
stupid_logic[1] = player[1].playerCarId;
stupid_logic[2] = gThePlayerCar;
stupid_logic[3] = player[0].targetCarId; // [A]
}
for (i = 0; i < 3; i++)
{

View File

@ -32,20 +32,20 @@ int gShadowTextureNum;
UV shadowuv;
POLYFT4 shadowpoly;
VECTOR tyre_new_positions[MAX_TYRE_TRACK_PLAYERS][MAX_TYRE_TRACK_WHEELS];
VECTOR tyre_save_positions[MAX_TYRE_TRACK_PLAYERS][MAX_TYRE_TRACK_WHEELS];
VECTOR tyre_new_positions[MAX_TYRE_PLAYERS][MAX_TYRE_TRACK_WHEELS];
VECTOR tyre_save_positions[MAX_TYRE_PLAYERS][MAX_TYRE_TRACK_WHEELS];
int smoke_count[MAX_TYRE_PLAYERS][MAX_TYRE_TRACK_WHEELS];
int tyre_track_offset[MAX_TYRE_TRACK_PLAYERS][MAX_TYRE_TRACK_WHEELS];
int num_tyre_tracks[MAX_TYRE_TRACK_PLAYERS][MAX_TYRE_TRACK_WHEELS];
TYRE_TRACK track_buffer[MAX_TYRE_TRACK_PLAYERS][MAX_TYRE_TRACK_WHEELS][64];
int smoke_count[MAX_TYRE_TRACK_PLAYERS][MAX_TYRE_TRACK_WHEELS];
// [D] [T]
void InitTyreTracks(void)
{
int i;
for (i = 0; i < 4; i++)
for (i = 0; i < MAX_TYRE_TRACK_PLAYERS; i++)
{
ClearMem((char*)num_tyre_tracks[i], sizeof(num_tyre_tracks[0]));
ClearMem((char*)tyre_track_offset[i], sizeof(tyre_track_offset[0]));
@ -56,7 +56,7 @@ void InitTyreTracks(void)
void ResetTyreTracks(CAR_DATA* cp, int player_id)
{
// [A] reset tyre tracks
if (player_id >= 0 && player_id < 2 && cp->controlType != CONTROL_TYPE_NONE)
if (player_id >= 0 && player_id < MAX_TYRE_TRACK_PLAYERS && cp->controlType != CONTROL_TYPE_NONE)
{
GetTyreTrackPositions(cp, player_id);
SetTyreTrackOldPositions(player_id);
@ -293,9 +293,7 @@ void DrawTyreTracks(void)
tt_p = track_buffer[player_id][wheel_loop] + index;
index++;
if (index == 64)
index = 0;
index &= 63;
if (tt_p->type == 2)
continue;

View File

@ -37,6 +37,7 @@
#endif
// Tyre track visuals
#define MAX_TYRE_PLAYERS 4
#ifndef PSX
#define MAX_TYRE_TRACK_WHEELS 4
#define MAX_TYRE_TRACK_PLAYERS 4