Merge pull request #154 from Nick007J/master

fixed replays
This commit is contained in:
aap 2019-07-20 15:30:34 +02:00 committed by GitHub
commit 33a18ef688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 35 deletions

View File

@ -625,9 +625,9 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */ vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */
vp->acceleration = vehicle->m_fGasPedal * 100.0f; vp->acceleration = vehicle->m_fGasPedal * 100.0f;
vp->panels = vehicle->IsCar() ? ((CAutomobile*)vehicle)->Damage.m_panelStatus : 0; vp->panels = vehicle->IsCar() ? ((CAutomobile*)vehicle)->Damage.m_panelStatus : 0;
vp->velocityX = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().x)); /* 8000!? */ vp->velocityX = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */
vp->velocityY = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().y)); vp->velocityY = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetMoveSpeed().y));
vp->velocityZ = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().z)); vp->velocityZ = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetMoveSpeed().z));
vp->mi = vehicle->GetModelIndex(); vp->mi = vehicle->GetModelIndex();
vp->primary_color = vehicle->m_currentColour1; vp->primary_color = vehicle->m_currentColour1;
vp->secondary_color = vehicle->m_currentColour2; vp->secondary_color = vehicle->m_currentColour2;
@ -850,10 +850,10 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
TheCamera.GetMatrix().GetPosition() *= split; TheCamera.GetMatrix().GetPosition() *= split;
TheCamera.GetMatrix() += CMatrix(interpolation) * pg->camera_pos; TheCamera.GetMatrix() += CMatrix(interpolation) * pg->camera_pos;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)); RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)TheCamera.GetMatrix().GetPosition(); pm->pos = *(RwV3d*)TheCamera.GetPosition();
pm->at = *(RwV3d*)TheCamera.GetMatrix().GetForward(); pm->at = *(RwV3d*)TheCamera.GetForward();
pm->up = *(RwV3d*)TheCamera.GetMatrix().GetUp(); pm->up = *(RwV3d*)TheCamera.GetUp();
pm->right = *(RwV3d*)TheCamera.GetMatrix().GetRight(); pm->right = *(RwV3d*)TheCamera.GetRight();
CameraFocusX = split * CameraFocusX + interpolation * pg->player_pos.x; CameraFocusX = split * CameraFocusX + interpolation * pg->player_pos.x;
CameraFocusY = split * CameraFocusY + interpolation * pg->player_pos.y; CameraFocusY = split * CameraFocusY + interpolation * pg->player_pos.y;
CameraFocusZ = split * CameraFocusZ + interpolation * pg->player_pos.z; CameraFocusZ = split * CameraFocusZ + interpolation * pg->player_pos.z;
@ -979,15 +979,15 @@ void CReplay::ProcessReplayCamera(void)
switch (CameraMode) { switch (CameraMode) {
case REPLAYCAMMODE_TOPDOWN: case REPLAYCAMMODE_TOPDOWN:
{ {
TheCamera.GetMatrix().GetPosition() = CVector(CameraFocusX, CameraFocusY, CameraFocusZ + 15.0f); TheCamera.GetPosition() = CVector(CameraFocusX, CameraFocusY, CameraFocusZ + 15.0f);
TheCamera.GetMatrix().GetForward() = CVector(0.0f, 0.0f, -1.0f); TheCamera.GetForward() = CVector(0.0f, 0.0f, -1.0f);
TheCamera.GetMatrix().GetUp() = CVector(0.0f, 1.0f, 0.0f); TheCamera.GetUp() = CVector(0.0f, 1.0f, 0.0f);
TheCamera.GetMatrix().GetRight() = CVector(1.0f, 0.0f, 0.0f); TheCamera.GetRight() = CVector(1.0f, 0.0f, 0.0f);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)); RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)&TheCamera.GetMatrix().GetPosition(); pm->pos = *(RwV3d*)&TheCamera.GetPosition();
pm->at = *(RwV3d*)&TheCamera.GetMatrix().GetForward(); pm->at = *(RwV3d*)&TheCamera.GetForward();
pm->up = *(RwV3d*)&TheCamera.GetMatrix().GetUp(); pm->up = *(RwV3d*)&TheCamera.GetUp();
pm->right = *(RwV3d*)&TheCamera.GetMatrix().GetRight(); pm->right = *(RwV3d*)&TheCamera.GetRight();
break; break;
} }
case REPLAYCAMMODE_FIXED: case REPLAYCAMMODE_FIXED:
@ -1113,7 +1113,7 @@ void CReplay::StoreStuffInMem(void)
TimeStep = CTimer::GetTimeStep(); TimeStep = CTimer::GetTimeStep();
TimeScale = CTimer::GetTimeScale(); TimeScale = CTimer::GetTimeScale();
int size = CPools::GetPedPool()->GetSize(); int size = CPools::GetPedPool()->GetSize();
pPedAnims = (CStoredDetailedAnimationState*)malloc(size * sizeof(CStoredDetailedAnimationState)); pPedAnims = new CStoredDetailedAnimationState[size];
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
CPed* ped = CPools::GetPedPool()->GetSlot(i); CPed* ped = CPools::GetPedPool()->GetSlot(i);
if (ped) if (ped)
@ -1279,7 +1279,7 @@ void CReplay::RestoreStuffFromMem(void)
continue; continue;
RetrieveDetailedPedAnimation(ped, &pPedAnims[i]); RetrieveDetailedPedAnimation(ped, &pPedAnims[i]);
} }
free(pPedAnims); delete[] pPedAnims;
pPedAnims = nil; pPedAnims = nil;
DMAudio.ChangeMusicMode(0); DMAudio.ChangeMusicMode(0);
DMAudio.SetRadioInCar(OldRadioStation); DMAudio.SetRadioInCar(OldRadioStation);
@ -1525,15 +1525,15 @@ void CReplay::ProcessLookAroundCam(void)
right.Normalise(); right.Normalise();
CVector up = CrossProduct(forward, right); CVector up = CrossProduct(forward, right);
up.Normalise(); up.Normalise();
TheCamera.GetMatrix().GetForward() = forward; TheCamera.GetForward() = forward;
TheCamera.GetMatrix().GetUp() = up; TheCamera.GetUp() = up;
TheCamera.GetMatrix().GetRight() = right; TheCamera.GetRight() = right;
TheCamera.GetMatrix().GetPosition() = camera_pt; TheCamera.GetPosition() = camera_pt;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)); RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)&TheCamera.GetMatrix().GetPosition(); pm->pos = *(RwV3d*)&TheCamera.GetPosition();
pm->at = *(RwV3d*)&TheCamera.GetMatrix().GetForward(); pm->at = *(RwV3d*)&TheCamera.GetForward();
pm->up = *(RwV3d*)&TheCamera.GetMatrix().GetUp(); pm->up = *(RwV3d*)&TheCamera.GetUp();
pm->right = *(RwV3d*)&TheCamera.GetMatrix().GetRight(); pm->right = *(RwV3d*)&TheCamera.GetRight();
TheCamera.CalculateDerivedValues(); TheCamera.CalculateDerivedValues();
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera))); RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera)); RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));

View File

@ -176,7 +176,7 @@ class CReplay
int8 velocityZ; int8 velocityZ;
union{ union{
int8 car_gun; int8 car_gun;
uint8 wheel_state; int8 wheel_state;
}; };
uint8 wheel_susp_dist[4]; uint8 wheel_susp_dist[4];
uint8 wheel_rotation[4]; uint8 wheel_rotation[4];

View File

@ -79,6 +79,7 @@ CMissionCleanup::CMissionCleanup()
void CMissionCleanup::Init() void CMissionCleanup::Init()
{ {
m_nCount = 0;
for (int i = 0; i < MAX_CLEANUP; i++){ for (int i = 0; i < MAX_CLEANUP; i++){
m_sEntities[i].type = CLEANUP_UNUSED; m_sEntities[i].type = CLEANUP_UNUSED;
m_sEntities[i].id = 0; m_sEntities[i].id = 0;
@ -102,7 +103,7 @@ void CMissionCleanup::AddEntityToList(int32 id, uint8 type)
return; return;
pNew->id = id; pNew->id = id;
pNew->type = type; pNew->type = type;
m_bCount++; m_nCount++;
} }
void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type) void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type)
@ -111,6 +112,7 @@ void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type)
if (m_sEntities[i].type == type && m_sEntities[i].id == id){ if (m_sEntities[i].type == type && m_sEntities[i].id == id){
m_sEntities[i].id = 0; m_sEntities[i].id = 0;
m_sEntities[i].type = CLEANUP_UNUSED; m_sEntities[i].type = CLEANUP_UNUSED;
m_nCount--;
} }
} }
} }
@ -603,7 +605,7 @@ void CTheScripts::Process()
if (UseTextCommands){ if (UseTextCommands){
for (int i = 0; i < MAX_NUM_INTRO_TEXT_LINES; i++) for (int i = 0; i < MAX_NUM_INTRO_TEXT_LINES; i++)
IntroTextLines[i].Reset(); IntroTextLines[i].Reset();
NumberOfIntroRectanglesThisFrame = 0; NumberOfIntroTextLinesThisFrame = 0;
for (int i = 0; i < MAX_NUM_INTRO_RECTANGLES; i++){ for (int i = 0; i < MAX_NUM_INTRO_RECTANGLES; i++){
IntroRectangles[i].m_bIsUsed = false; IntroRectangles[i].m_bIsUsed = false;
IntroRectangles[i].m_bBeforeFade = false; IntroRectangles[i].m_bBeforeFade = false;
@ -1638,27 +1640,27 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
CollectParameters(&m_nIp, 5); CollectParameters(&m_nIp, 5);
switch (ScriptParams[1]) { switch (ScriptParams[1]) {
case MI_COP: case MI_COP:
if (ScriptParams[0] = PEDTYPE_COP) if (ScriptParams[0] == PEDTYPE_COP)
ScriptParams[1] = COP_STREET; ScriptParams[1] = COP_STREET;
break; break;
case MI_SWAT: case MI_SWAT:
if (ScriptParams[0] = PEDTYPE_COP) if (ScriptParams[0] == PEDTYPE_COP)
ScriptParams[1] = COP_SWAT; ScriptParams[1] = COP_SWAT;
break; break;
case MI_FBI: case MI_FBI:
if (ScriptParams[0] = PEDTYPE_COP) if (ScriptParams[0] == PEDTYPE_COP)
ScriptParams[1] = COP_FBI; ScriptParams[1] = COP_FBI;
break; break;
case MI_ARMY: case MI_ARMY:
if (ScriptParams[0] = PEDTYPE_COP) if (ScriptParams[0] == PEDTYPE_COP)
ScriptParams[1] = COP_ARMY; ScriptParams[1] = COP_ARMY;
break; break;
case MI_MEDIC: case MI_MEDIC:
if (ScriptParams[0] = PEDTYPE_EMERGENCY) if (ScriptParams[0] == PEDTYPE_EMERGENCY)
ScriptParams[1] = PEDTYPE_EMERGENCY; ScriptParams[1] = PEDTYPE_EMERGENCY;
break; break;
case MI_FIREMAN: case MI_FIREMAN:
if (ScriptParams[0] = PEDTYPE_FIREMAN) if (ScriptParams[0] == PEDTYPE_FIREMAN)
ScriptParams[1] = PEDTYPE_FIREMAN; ScriptParams[1] = PEDTYPE_FIREMAN;
break; break;
default: default:

View File

@ -137,7 +137,7 @@ enum {
class CMissionCleanup class CMissionCleanup
{ {
CMissionCleanupEntity m_sEntities[MAX_CLEANUP]; CMissionCleanupEntity m_sEntities[MAX_CLEANUP];
uint8 m_bCount; uint8 m_nCount;
public: public:
CMissionCleanup(); CMissionCleanup();