- fix Havana ferry drifting & replay inconsistencies, improve Swap2Cars

This commit is contained in:
Ilya Shurumov 2021-06-26 16:18:04 +06:00 committed by InspirationByte
parent 53ebf9b421
commit 8a2abaa9db
3 changed files with 38 additions and 17 deletions

View File

@ -79,7 +79,8 @@ int VegasMonorailData[] = {
};
int HavanaFerryData[12] = {
40, 0, 0, 425555, -452, 20000, 25, 0, 0, 315750, 130740, 135960
40, 0, 64, 425555, -452, 20000, // Ferry 1
25, 0, 64, 315750, 130740, 135960 // Ferry 2
};
int RioFerryData[6] = {
@ -444,10 +445,10 @@ static int cameraEventsActive = 0;
static CameraDelay cameraDelay;
static Detonator detonator;
static int eventHaze = 0;
static int carsOnBoat = 0;
static int doneFirstHavanaCameraHack = 0;
static SVECTOR boatOffset;
static FixedEvent* fixedEvent = NULL;
int carsOnBoat = 0;
MultiCar multiCar;
@ -1090,6 +1091,10 @@ void SetUpEvents(int full)
evt->node = HavanaFerryData + 4;
evt->data = HavanaFerryData;
// [A] reset Ferry angles
evt->data[1] = RSIN(CameraCnt * 32) >> 9;
evt->data[2] = RCOS(CameraCnt * 16) + 4096 >> 7;
VisibilityLists(VIS_ADD, 0);
MakeEventTrackable(evt);
@ -2306,7 +2311,7 @@ void StepEvents(void)
while (ev)
{
carsOnBoat = onBoatLastFrame;
//carsOnBoat = onBoatLastFrame;
if (ev->flags & 2)
{
@ -2330,7 +2335,7 @@ void StepEvents(void)
// make Tanner on boat also
if (player[0].playerType == 2 && OnBoat((VECTOR*)player[0].pos, ev, &dist))
carsOnBoat |= 0x300000;
carsOnBoat |= (1 << TANNER_COLLIDER_CARID);// 0x300000;
BoatOffset(&boatOffset, ev);
@ -2345,19 +2350,16 @@ void StepEvents(void)
if (ev->flags & 0x800)
{
// [A] what the fuck this code is doing? Makes boat float harder after explosion?
int tmSqr;
ev->data[1] = rcossin_tbl[(CameraCnt & 0x7f) * 64] >> 9 & 0xfff;
ev->data[2] = rcossin_tbl[(CameraCnt & 0xff) * 32 + 1] + 4096 >> 7;
tmSqr = detonator.timer * detonator.timer;
ev->data[1] = RSIN(CameraCnt * 32) >> 9;
ev->data[2] = RCOS(CameraCnt * 16) + 4096 >> 7;
if (detonator.timer - 1U < 159) // HMM?
{
ev->data[1] -= rcossin_tbl[(detonator.timer & 0x3fU) * 128] * tmSqr >> 0x12;
ev->data[2] -= rcossin_tbl[(detonator.timer & 0x3fU) * 128] * tmSqr >> 0x10;
int tmSqr;
tmSqr = detonator.timer * detonator.timer;
ev->data[1] -= RSIN(detonator.timer * 64) * tmSqr >> 18; //rcossin_tbl[(detonator.timer & 0x3fU) * 128] * tmSqr >> 0x12;
ev->data[2] -= RSIN(detonator.timer * 64) * tmSqr >> 16; //rcossin_tbl[(detonator.timer & 0x3fU) * 128] * tmSqr >> 0x10;
}
if (foam.rotate & 0xffff7fffU) // HMMMMMM?
@ -2399,7 +2401,7 @@ void StepEvents(void)
if (i == TANNER_COLLIDER_CARID)
{
SetTannerPosition(pos);
carsOnBoat &= ~0x100000;
carsOnBoat &= ~(1 << TANNER_COLLIDER_CARID);
}
else if ((onBoatLastFrame & bit) == 0)
{
@ -2407,8 +2409,9 @@ void StepEvents(void)
vel->vz -= speed.z * 4096;
}
car_data[i].st.n.fposition[0] = car_data[i].hd.where.t[0] << 4;
car_data[i].st.n.fposition[2] = car_data[i].hd.where.t[2] << 4;
// [A] this causes drifting, StepOneCar already does better job at updating this
// car_data[i].st.n.fposition[0] = pos->vx << 4;
// car_data[i].st.n.fposition[2] = pos->vz << 4;
}
else if (vel && (onBoatLastFrame & bit))
{
@ -3432,6 +3435,11 @@ VECTOR* TriggerEvent(int i)
event->node = &HavanaFerryData[10];
event->data = &HavanaFerryData[6];
// [A] reset Ferry angles
event->data[1] = RSIN(CameraCnt * 32) >> 9;
event->data[2] = RCOS(CameraCnt * 16) + 4096 >> 7;
break;
case 2:
TriggerDoor(&havanaFixed[0], &stage[i], 1);

View File

@ -6,6 +6,8 @@ extern EventGlobal events;
extern CELL_OBJECT *EventCop;
extern int event_models_active;
extern int carsOnBoat;
extern void InitEvents(); // 0x0004BBD4
extern void SetUpEvents(int full); // 0x00046258
extern VECTOR* TriggerEvent(int i);

View File

@ -1246,6 +1246,7 @@ int Swap2Cars(int curslot, int newslot)
int pnodeNewId;
int ctrlNodeCurId;
int pnodeCurId;
int tmp;
CAR_DATA cd;
@ -1304,6 +1305,16 @@ int Swap2Cars(int curslot, int newslot)
memcpy((u_char*)&car_data[newslot], (u_char*)&car_data[curslot], sizeof(CAR_DATA));
memcpy((u_char*)&car_data[curslot], (u_char*)&cd, sizeof(CAR_DATA));
// [A] event - swap cars on boat
tmp = carsOnBoat & (1 << newslot);
carsOnBoat &= ~(1 << newslot);
if (carsOnBoat & (1 << curslot))
carsOnBoat |= (1 << newslot);
if(tmp)
carsOnBoat |= (1 << curslot);
// swap ids
car_data[newslot].id = newslot;
car_data[curslot].id = curslot;