mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-23 09:39:16 +01:00
more bigendian fixes
This commit is contained in:
parent
21b7895b61
commit
870c560bdb
@ -67,6 +67,12 @@ void CRecordDataForGame::SaveOrRetrieveDataForThisFrame(void)
|
|||||||
uint8* pEndPtr = pController2;
|
uint8* pEndPtr = pController2;
|
||||||
if ((pDataBufferForFrame.m_nSizeOfPads[0] + pDataBufferForFrame.m_nSizeOfPads[1]) & 1)
|
if ((pDataBufferForFrame.m_nSizeOfPads[0] + pDataBufferForFrame.m_nSizeOfPads[1]) & 1)
|
||||||
pEndPtr += 2;
|
pEndPtr += 2;
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
// save as LE
|
||||||
|
pDataBufferForFrame.m_fTimeStep = FLOATSWAP32(pDataBufferForFrame.m_fTimeStep);
|
||||||
|
pDataBufferForFrame.m_nTimeInMilliseconds = BSWAP32(pDataBufferForFrame.m_nTimeInMilliseconds);
|
||||||
|
pDataBufferForFrame.m_nChecksum = BSWAP32(pDataBufferForFrame.m_nChecksum);
|
||||||
|
#endif
|
||||||
CFileMgr::Write(FId, (char*)&pDataBufferForFrame, pEndPtr - (uint8*)&pDataBufferForFrame);
|
CFileMgr::Write(FId, (char*)&pDataBufferForFrame, pEndPtr - (uint8*)&pDataBufferForFrame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -75,6 +81,11 @@ void CRecordDataForGame::SaveOrRetrieveDataForThisFrame(void)
|
|||||||
CPad::GetPad(0)->NewState.Clear();
|
CPad::GetPad(0)->NewState.Clear();
|
||||||
else {
|
else {
|
||||||
tGameBuffer* pData = (tGameBuffer*)pDataBufferPointer;
|
tGameBuffer* pData = (tGameBuffer*)pDataBufferPointer;
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
pData->m_fTimeStep = FLOATSWAP32(pData->m_fTimeStep);
|
||||||
|
pData->m_nTimeInMilliseconds = BSWAP32(pData->m_nTimeInMilliseconds);
|
||||||
|
pData->m_nChecksum = BSWAP32(pData->m_nChecksum);
|
||||||
|
#endif
|
||||||
CTimer::SetTimeInMilliseconds(pData->m_nTimeInMilliseconds);
|
CTimer::SetTimeInMilliseconds(pData->m_nTimeInMilliseconds);
|
||||||
CTimer::SetTimeStep(pData->m_fTimeStep);
|
CTimer::SetTimeStep(pData->m_fTimeStep);
|
||||||
uint8 size1 = pData->m_nSizeOfPads[0];
|
uint8 size1 = pData->m_nSizeOfPads[0];
|
||||||
@ -462,6 +473,15 @@ void CRecordDataForChase::StartChaseScene(float startTime)
|
|||||||
pBaseMemForCar[i] = new CCarStateEachFrame[CHASE_SCENE_FRAMES_IN_RECORDING];
|
pBaseMemForCar[i] = new CCarStateEachFrame[CHASE_SCENE_FRAMES_IN_RECORDING];
|
||||||
for (int j = 0; j < CHASE_SCENE_FRAMES_IN_RECORDING; j++) {
|
for (int j = 0; j < CHASE_SCENE_FRAMES_IN_RECORDING; j++) {
|
||||||
CFileMgr::Read(FId2, (char*)&pBaseMemForCar[i][j], sizeof(CCarStateEachFrame));
|
CFileMgr::Read(FId2, (char*)&pBaseMemForCar[i][j], sizeof(CCarStateEachFrame));
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
CCarStateEachFrame* state = &pBaseMemForCar[i][j];
|
||||||
|
state->velX = BSWAP16(state->velX);
|
||||||
|
state->velY = BSWAP16(state->velY);
|
||||||
|
state->velZ = BSWAP16(state->velZ);
|
||||||
|
state->pos.x = FLOATSWAP32(state->pos.x);
|
||||||
|
state->pos.y = FLOATSWAP32(state->pos.y);
|
||||||
|
state->pos.z = FLOATSWAP32(state->pos.z);
|
||||||
|
#endif
|
||||||
CFileMgr::Seek(FId2, sizeof(CCarStateEachFrame), 1);
|
CFileMgr::Seek(FId2, sizeof(CCarStateEachFrame), 1);
|
||||||
}
|
}
|
||||||
CFileMgr::CloseFile(FId2);
|
CFileMgr::CloseFile(FId2);
|
||||||
|
@ -295,6 +295,10 @@ void CReplay::RecordThisFrame(void)
|
|||||||
general->camera_pos.CopyOnlyMatrix(&TheCamera.GetMatrix());
|
general->camera_pos.CopyOnlyMatrix(&TheCamera.GetMatrix());
|
||||||
general->player_pos = FindPlayerCoors();
|
general->player_pos = FindPlayerCoors();
|
||||||
general->in_rcvehicle = CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle ? true : false;
|
general->in_rcvehicle = CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle ? true : false;
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
BSWAP_MTX(general->camera_pos.m_matrix);
|
||||||
|
BSWAP_VECTOR(general->player_pos);
|
||||||
|
#endif
|
||||||
Record.m_nOffset += sizeof(*general);
|
Record.m_nOffset += sizeof(*general);
|
||||||
tClockPacket* clock = (tClockPacket*)&Record.m_pBase[Record.m_nOffset];
|
tClockPacket* clock = (tClockPacket*)&Record.m_pBase[Record.m_nOffset];
|
||||||
clock->type = REPLAYPACKET_CLOCK;
|
clock->type = REPLAYPACKET_CLOCK;
|
||||||
@ -303,13 +307,13 @@ void CReplay::RecordThisFrame(void)
|
|||||||
Record.m_nOffset += sizeof(*clock);
|
Record.m_nOffset += sizeof(*clock);
|
||||||
tWeatherPacket* weather = (tWeatherPacket*)&Record.m_pBase[Record.m_nOffset];
|
tWeatherPacket* weather = (tWeatherPacket*)&Record.m_pBase[Record.m_nOffset];
|
||||||
weather->type = REPLAYPACKET_WEATHER;
|
weather->type = REPLAYPACKET_WEATHER;
|
||||||
weather->old_weather = CWeather::OldWeatherType;
|
weather->old_weather = BSWAP32(CWeather::OldWeatherType);
|
||||||
weather->new_weather = CWeather::NewWeatherType;
|
weather->new_weather = BSWAP32(CWeather::NewWeatherType);
|
||||||
weather->interpolation = CWeather::InterpolationValue;
|
weather->interpolation = FLOATSWAP32(CWeather::InterpolationValue);
|
||||||
Record.m_nOffset += sizeof(*weather);
|
Record.m_nOffset += sizeof(*weather);
|
||||||
tTimerPacket* timer = (tTimerPacket*)&Record.m_pBase[Record.m_nOffset];
|
tTimerPacket* timer = (tTimerPacket*)&Record.m_pBase[Record.m_nOffset];
|
||||||
timer->type = REPLAYPACKET_TIMER;
|
timer->type = REPLAYPACKET_TIMER;
|
||||||
timer->timer = CTimer::GetTimeInMilliseconds();
|
timer->timer = BSWAP32(CTimer::GetTimeInMilliseconds());
|
||||||
Record.m_nOffset += sizeof(*timer);
|
Record.m_nOffset += sizeof(*timer);
|
||||||
CVehiclePool* vehicles = CPools::GetVehiclePool();
|
CVehiclePool* vehicles = CPools::GetVehiclePool();
|
||||||
for (int i = 0; i < vehicles->GetSize(); i++){
|
for (int i = 0; i < vehicles->GetSize(); i++){
|
||||||
@ -326,7 +330,7 @@ void CReplay::RecordThisFrame(void)
|
|||||||
tPedHeaderPacket* ph = (tPedHeaderPacket*)&Record.m_pBase[Record.m_nOffset];
|
tPedHeaderPacket* ph = (tPedHeaderPacket*)&Record.m_pBase[Record.m_nOffset];
|
||||||
ph->type = REPLAYPACKET_PED_HEADER;
|
ph->type = REPLAYPACKET_PED_HEADER;
|
||||||
ph->index = i;
|
ph->index = i;
|
||||||
ph->mi = p->GetModelIndex();
|
ph->mi = BSWAP32(p->GetModelIndex());
|
||||||
ph->pedtype = p->m_nPedType;
|
ph->pedtype = p->m_nPedType;
|
||||||
Record.m_nOffset += sizeof(*ph);
|
Record.m_nOffset += sizeof(*ph);
|
||||||
p->bHasAlreadyBeenRecorded = true;
|
p->bHasAlreadyBeenRecorded = true;
|
||||||
@ -343,6 +347,10 @@ void CReplay::RecordThisFrame(void)
|
|||||||
bt->lifetime = CBulletTraces::aTraces[i].m_lifeTime;
|
bt->lifetime = CBulletTraces::aTraces[i].m_lifeTime;
|
||||||
bt->inf = CBulletTraces::aTraces[i].m_vecCurrentPos;
|
bt->inf = CBulletTraces::aTraces[i].m_vecCurrentPos;
|
||||||
bt->sup = CBulletTraces::aTraces[i].m_vecTargetPos;
|
bt->sup = CBulletTraces::aTraces[i].m_vecTargetPos;
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
BSWAP_VECTOR(bt->inf);
|
||||||
|
BSWAP_VECTOR(bt->sup);
|
||||||
|
#endif
|
||||||
Record.m_nOffset += sizeof(*bt);
|
Record.m_nOffset += sizeof(*bt);
|
||||||
}
|
}
|
||||||
tEndOfFramePacket* eof = (tEndOfFramePacket*)&Record.m_pBase[Record.m_nOffset];
|
tEndOfFramePacket* eof = (tEndOfFramePacket*)&Record.m_pBase[Record.m_nOffset];
|
||||||
@ -373,6 +381,9 @@ void CReplay::StorePedUpdate(CPed *ped, int id)
|
|||||||
pp->index = id;
|
pp->index = id;
|
||||||
pp->heading = 128.0f / PI * ped->m_fRotationCur;
|
pp->heading = 128.0f / PI * ped->m_fRotationCur;
|
||||||
pp->matrix.CompressFromFullMatrix(ped->GetMatrix());
|
pp->matrix.CompressFromFullMatrix(ped->GetMatrix());
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
BSWAP_VECTOR(pp->matrix.m_vecPos);
|
||||||
|
#endif
|
||||||
pp->assoc_group_id = ped->m_animGroup;
|
pp->assoc_group_id = ped->m_animGroup;
|
||||||
/* Would be more sane to use GetJustIndex(ped->m_pMyVehicle) in following assignment */
|
/* Would be more sane to use GetJustIndex(ped->m_pMyVehicle) in following assignment */
|
||||||
if (ped->InVehicle())
|
if (ped->InVehicle())
|
||||||
@ -435,7 +446,7 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
|
|||||||
#ifdef FIX_REPLAY_BUGS
|
#ifdef FIX_REPLAY_BUGS
|
||||||
state->aBlendDelta[i] = 127.0f / 32.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
|
state->aBlendDelta[i] = 127.0f / 32.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
|
||||||
#endif
|
#endif
|
||||||
state->aFlags[i] = assoc->flags;
|
state->aFlags[i] = BSWAP16(assoc->flags);
|
||||||
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
|
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
|
||||||
state->aFunctionCallbackID[i] = FindCBFunctionID(assoc->callback);
|
state->aFunctionCallbackID[i] = FindCBFunctionID(assoc->callback);
|
||||||
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH)
|
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH)
|
||||||
@ -461,7 +472,7 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
|
|||||||
#ifdef FIX_REPLAY_BUGS
|
#ifdef FIX_REPLAY_BUGS
|
||||||
state->aBlendDelta2[i] = 127.0f / 16.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
|
state->aBlendDelta2[i] = 127.0f / 16.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
|
||||||
#endif
|
#endif
|
||||||
state->aFlags2[i] = assoc->flags;
|
state->aFlags2[i] = BSWAP32(assoc->flags);
|
||||||
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
|
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH || assoc->callbackType == CAnimBlendAssociation::CB_DELETE) {
|
||||||
state->aFunctionCallbackID2[i] = FindCBFunctionID(assoc->callback);
|
state->aFunctionCallbackID2[i] = FindCBFunctionID(assoc->callback);
|
||||||
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH)
|
if (assoc->callbackType == CAnimBlendAssociation::CB_FINISH)
|
||||||
@ -491,6 +502,9 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB
|
|||||||
ped->m_fRotationCur = pp->heading * PI / 128.0f;
|
ped->m_fRotationCur = pp->heading * PI / 128.0f;
|
||||||
ped->m_fRotationDest = pp->heading * PI / 128.0f;
|
ped->m_fRotationDest = pp->heading * PI / 128.0f;
|
||||||
CMatrix ped_matrix;
|
CMatrix ped_matrix;
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
BSWAP_VECTOR(pp->matrix.m_vecPos);
|
||||||
|
#endif
|
||||||
pp->matrix.DecompressIntoFullMatrix(ped_matrix);
|
pp->matrix.DecompressIntoFullMatrix(ped_matrix);
|
||||||
ped->GetMatrix() = ped->GetMatrix() * CMatrix(1.0f - interpolation);
|
ped->GetMatrix() = ped->GetMatrix() * CMatrix(1.0f - interpolation);
|
||||||
ped->GetMatrix().GetPosition() *= (1.0f - interpolation);
|
ped->GetMatrix().GetPosition() *= (1.0f - interpolation);
|
||||||
@ -678,13 +692,16 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
|
|||||||
vp->type = REPLAYPACKET_VEHICLE;
|
vp->type = REPLAYPACKET_VEHICLE;
|
||||||
vp->index = id;
|
vp->index = id;
|
||||||
vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix());
|
vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix());
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
BSWAP_VECTOR(vp->matrix.m_vecPos);
|
||||||
|
#endif
|
||||||
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 = BSWAP32(vehicle->IsCar() ? ((CAutomobile*)vehicle)->Damage.m_panelStatus : 0);
|
||||||
vp->velocityX = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().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->GetMoveSpeed().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->GetMoveSpeed().z));
|
vp->velocityZ = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().z));
|
||||||
vp->mi = vehicle->GetModelIndex();
|
vp->mi = BSWAP32(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;
|
||||||
if (vehicle->GetModelIndex() == MI_RHINO)
|
if (vehicle->GetModelIndex() == MI_RHINO)
|
||||||
@ -716,6 +733,9 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CMatrix vehicle_matrix;
|
CMatrix vehicle_matrix;
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
BSWAP_VECTOR(vp->matrix.m_vecPos);
|
||||||
|
#endif
|
||||||
vp->matrix.DecompressIntoFullMatrix(vehicle_matrix);
|
vp->matrix.DecompressIntoFullMatrix(vehicle_matrix);
|
||||||
vehicle->GetMatrix() = vehicle->GetMatrix() * CMatrix(1.0f - interpolation);
|
vehicle->GetMatrix() = vehicle->GetMatrix() * CMatrix(1.0f - interpolation);
|
||||||
vehicle->GetMatrix().GetPosition() *= (1.0f - interpolation);
|
vehicle->GetMatrix().GetPosition() *= (1.0f - interpolation);
|
||||||
@ -724,7 +744,7 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
|
|||||||
vehicle->m_fHealth = 4 * vp->health;
|
vehicle->m_fHealth = 4 * vp->health;
|
||||||
vehicle->m_fGasPedal = vp->acceleration / 100.0f;
|
vehicle->m_fGasPedal = vp->acceleration / 100.0f;
|
||||||
if (vehicle->IsCar())
|
if (vehicle->IsCar())
|
||||||
ApplyPanelDamageToCar(vp->panels, (CAutomobile*)vehicle, true);
|
ApplyPanelDamageToCar(BSWAP32(vp->panels), (CAutomobile*)vehicle, true);
|
||||||
vehicle->m_vecMoveSpeed = CVector(vp->velocityX / 8000.0f, vp->velocityY / 8000.0f, vp->velocityZ / 8000.0f);
|
vehicle->m_vecMoveSpeed = CVector(vp->velocityX / 8000.0f, vp->velocityY / 8000.0f, vp->velocityZ / 8000.0f);
|
||||||
if (vehicle->GetModelIndex() == MI_RHINO) {
|
if (vehicle->GetModelIndex() == MI_RHINO) {
|
||||||
((CAutomobile*)vehicle)->m_fCarGunLR = vp->car_gun * PI / 128.0f;
|
((CAutomobile*)vehicle)->m_fCarGunLR = vp->car_gun * PI / 128.0f;
|
||||||
@ -830,7 +850,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
|
|||||||
CVehicle* v = CPools::GetVehiclePool()->GetSlot(vp->index);
|
CVehicle* v = CPools::GetVehiclePool()->GetSlot(vp->index);
|
||||||
CVehicle* new_v;
|
CVehicle* new_v;
|
||||||
if (!v) {
|
if (!v) {
|
||||||
int mi = vp->mi;
|
int mi = BSWAP16(vp->mi);
|
||||||
if (CStreaming::ms_aInfoForModel[mi].m_loadState != 1) {
|
if (CStreaming::ms_aInfoForModel[mi].m_loadState != 1) {
|
||||||
CStreaming::RequestModel(mi, 0);
|
CStreaming::RequestModel(mi, 0);
|
||||||
}
|
}
|
||||||
@ -865,11 +885,11 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
|
|||||||
{
|
{
|
||||||
tPedHeaderPacket* ph = (tPedHeaderPacket*)&ptr[offset];
|
tPedHeaderPacket* ph = (tPedHeaderPacket*)&ptr[offset];
|
||||||
if (!CPools::GetPedPool()->GetSlot(ph->index)) {
|
if (!CPools::GetPedPool()->GetSlot(ph->index)) {
|
||||||
if (CStreaming::ms_aInfoForModel[ph->mi].m_loadState != 1) {
|
if (CStreaming::ms_aInfoForModel[BSWAP16(ph->mi)].m_loadState != 1) {
|
||||||
CStreaming::RequestModel(ph->mi, 0);
|
CStreaming::RequestModel(BSWAP16(ph->mi), 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CPed* new_p = new(ph->index << 8) CCivilianPed((ePedType)ph->pedtype, ph->mi);
|
CPed* new_p = new(ph->index << 8) CCivilianPed((ePedType)ph->pedtype, BSWAP16(ph->mi));
|
||||||
new_p->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER);
|
new_p->SetStatus(STATUS_PLAYER_PLAYBACKFROMBUFFER);
|
||||||
new_p->GetMatrix().SetUnity();
|
new_p->GetMatrix().SetUnity();
|
||||||
CWorld::Add(new_p);
|
CWorld::Add(new_p);
|
||||||
@ -896,6 +916,9 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
|
|||||||
case REPLAYPACKET_GENERAL:
|
case REPLAYPACKET_GENERAL:
|
||||||
{
|
{
|
||||||
tGeneralPacket* pg = (tGeneralPacket*)&ptr[offset];
|
tGeneralPacket* pg = (tGeneralPacket*)&ptr[offset];
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
BSWAP_MTX(pg->camera_pos.m_matrix);
|
||||||
|
#endif
|
||||||
TheCamera.GetMatrix() = TheCamera.GetMatrix() * CMatrix(split);
|
TheCamera.GetMatrix() = TheCamera.GetMatrix() * CMatrix(split);
|
||||||
TheCamera.GetMatrix().GetPosition() *= split;
|
TheCamera.GetMatrix().GetPosition() *= split;
|
||||||
TheCamera.GetMatrix() += CMatrix(interpolation) * pg->camera_pos;
|
TheCamera.GetMatrix() += CMatrix(interpolation) * pg->camera_pos;
|
||||||
@ -904,9 +927,9 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
|
|||||||
pm->at = TheCamera.GetForward();
|
pm->at = TheCamera.GetForward();
|
||||||
pm->up = TheCamera.GetUp();
|
pm->up = TheCamera.GetUp();
|
||||||
pm->right = TheCamera.GetRight();
|
pm->right = TheCamera.GetRight();
|
||||||
CameraFocusX = split * CameraFocusX + interpolation * pg->player_pos.x;
|
CameraFocusX = split * CameraFocusX + interpolation * FLOATSWAP32(pg->player_pos.x);
|
||||||
CameraFocusY = split * CameraFocusY + interpolation * pg->player_pos.y;
|
CameraFocusY = split * CameraFocusY + interpolation * FLOATSWAP32(pg->player_pos.y);
|
||||||
CameraFocusZ = split * CameraFocusZ + interpolation * pg->player_pos.z;
|
CameraFocusZ = split * CameraFocusZ + interpolation * FLOATSWAP32(pg->player_pos.z);
|
||||||
bPlayerInRCBuggy = pg->in_rcvehicle;
|
bPlayerInRCBuggy = pg->in_rcvehicle;
|
||||||
buffer->m_nOffset += sizeof(tGeneralPacket);
|
buffer->m_nOffset += sizeof(tGeneralPacket);
|
||||||
break;
|
break;
|
||||||
@ -923,7 +946,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
|
|||||||
tWeatherPacket* pw = (tWeatherPacket*)&ptr[offset];
|
tWeatherPacket* pw = (tWeatherPacket*)&ptr[offset];
|
||||||
CWeather::OldWeatherType = pw->old_weather;
|
CWeather::OldWeatherType = pw->old_weather;
|
||||||
CWeather::NewWeatherType = pw->new_weather;
|
CWeather::NewWeatherType = pw->new_weather;
|
||||||
CWeather::InterpolationValue = pw->interpolation;
|
CWeather::InterpolationValue = FLOATSWAP32(pw->interpolation);
|
||||||
buffer->m_nOffset += sizeof(tWeatherPacket);
|
buffer->m_nOffset += sizeof(tWeatherPacket);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -938,14 +961,18 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
|
|||||||
{
|
{
|
||||||
tTimerPacket* pt = (tTimerPacket*)&ptr[offset];
|
tTimerPacket* pt = (tTimerPacket*)&ptr[offset];
|
||||||
if (pTimer)
|
if (pTimer)
|
||||||
*pTimer = pt->timer;
|
*pTimer = BSWAP32(pt->timer);
|
||||||
CTimer::SetTimeInMilliseconds(pt->timer);
|
CTimer::SetTimeInMilliseconds(BSWAP32(pt->timer));
|
||||||
buffer->m_nOffset += sizeof(tTimerPacket);
|
buffer->m_nOffset += sizeof(tTimerPacket);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REPLAYPACKET_BULLET_TRACES:
|
case REPLAYPACKET_BULLET_TRACES:
|
||||||
{
|
{
|
||||||
tBulletTracePacket* pb = (tBulletTracePacket*)&ptr[offset];
|
tBulletTracePacket* pb = (tBulletTracePacket*)&ptr[offset];
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
BSWAP_VECTOR(pb->inf);
|
||||||
|
BSWAP_VECTOR(pb->sup);
|
||||||
|
#endif
|
||||||
CBulletTraces::aTraces[pb->index].m_bInUse = true;
|
CBulletTraces::aTraces[pb->index].m_bInUse = true;
|
||||||
CBulletTraces::aTraces[pb->index].m_framesInUse = pb->frames;
|
CBulletTraces::aTraces[pb->index].m_framesInUse = pb->frames;
|
||||||
CBulletTraces::aTraces[pb->index].m_lifeTime = pb->lifetime;
|
CBulletTraces::aTraces[pb->index].m_lifeTime = pb->lifetime;
|
||||||
@ -1457,10 +1484,10 @@ void CReplay::StreamAllNecessaryCarsAndPeds(void)
|
|||||||
for (size_t offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
|
for (size_t offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
|
||||||
switch (Buffers[slot][offset]) {
|
switch (Buffers[slot][offset]) {
|
||||||
case REPLAYPACKET_VEHICLE:
|
case REPLAYPACKET_VEHICLE:
|
||||||
CStreaming::RequestModel(((tVehicleUpdatePacket*)&Buffers[slot][offset])->mi, 0);
|
CStreaming::RequestModel(BSWAP16(((tVehicleUpdatePacket*)&Buffers[slot][offset])->mi), 0);
|
||||||
break;
|
break;
|
||||||
case REPLAYPACKET_PED_HEADER:
|
case REPLAYPACKET_PED_HEADER:
|
||||||
CStreaming::RequestModel(((tPedHeaderPacket*)&Buffers[slot][offset])->mi, 0);
|
CStreaming::RequestModel(BSWAP16(((tPedHeaderPacket*)&Buffers[slot][offset])->mi), 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1478,7 +1505,15 @@ void CReplay::FindFirstFocusCoordinate(CVector *coord)
|
|||||||
continue;
|
continue;
|
||||||
for (size_t offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
|
for (size_t offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
|
||||||
if (Buffers[slot][offset] == REPLAYPACKET_GENERAL) {
|
if (Buffers[slot][offset] == REPLAYPACKET_GENERAL) {
|
||||||
|
#ifndef BIGENDIAN
|
||||||
*coord = ((tGeneralPacket*)&Buffers[slot][offset])->player_pos;
|
*coord = ((tGeneralPacket*)&Buffers[slot][offset])->player_pos;
|
||||||
|
#else
|
||||||
|
CVector* pos = &((tGeneralPacket*)&Buffers[slot][offset])->player_pos;
|
||||||
|
pos->x = FLOATSWAP32(pos->x);
|
||||||
|
pos->y = FLOATSWAP32(pos->y);
|
||||||
|
pos->z = FLOATSWAP32(pos->z);
|
||||||
|
*coord = *pos;
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,23 @@ inline float _floatswap32(float f)
|
|||||||
#define BSWAP32(x) __builtin_bswap32(x)
|
#define BSWAP32(x) __builtin_bswap32(x)
|
||||||
#define BSWAP16(x) __builtin_bswap16(x)
|
#define BSWAP16(x) __builtin_bswap16(x)
|
||||||
#define FLOATSWAP32(x) _floatswap32(x)
|
#define FLOATSWAP32(x) _floatswap32(x)
|
||||||
|
#define BSWAP_VECTOR(v) \
|
||||||
|
do { \
|
||||||
|
v.x = FLOATSWAP32(v.x); \
|
||||||
|
v.y = FLOATSWAP32(v.y); \
|
||||||
|
v.z = FLOATSWAP32(v.z); \
|
||||||
|
} while(0)
|
||||||
|
#define BSWAP_MTX(m) \
|
||||||
|
do { \
|
||||||
|
BSWAP_VECTOR(m.right); \
|
||||||
|
BSWAP_VECTOR(m.up); \
|
||||||
|
BSWAP_VECTOR(m.at); \
|
||||||
|
BSWAP_VECTOR(m.pos); \
|
||||||
|
BSWAP32(m.flags); \
|
||||||
|
BSWAP32(m.pad1); \
|
||||||
|
BSWAP32(m.pad2); \
|
||||||
|
BSWAP32(m.pad3); \
|
||||||
|
} while(0)
|
||||||
#else
|
#else
|
||||||
#define BSWAP32(x) (x)
|
#define BSWAP32(x) (x)
|
||||||
#define BSWAP16(x) (x)
|
#define BSWAP16(x) (x)
|
||||||
|
@ -113,7 +113,9 @@ inline CVector MultiplyInverse(const CMatrix &mat, const CVector &vec)
|
|||||||
|
|
||||||
class CCompressedMatrixNotAligned
|
class CCompressedMatrixNotAligned
|
||||||
{
|
{
|
||||||
|
#ifndef BIGENDIAN
|
||||||
CVector m_vecPos;
|
CVector m_vecPos;
|
||||||
|
#endif
|
||||||
int8 m_rightX;
|
int8 m_rightX;
|
||||||
int8 m_rightY;
|
int8 m_rightY;
|
||||||
int8 m_rightZ;
|
int8 m_rightZ;
|
||||||
@ -121,6 +123,10 @@ class CCompressedMatrixNotAligned
|
|||||||
int8 m_upY;
|
int8 m_upY;
|
||||||
int8 m_upZ;
|
int8 m_upZ;
|
||||||
public:
|
public:
|
||||||
|
#ifdef BIGENDIAN
|
||||||
|
// needs to be public for bswapping
|
||||||
|
CVector m_vecPos;
|
||||||
|
#endif
|
||||||
void CompressFromFullMatrix(CMatrix &other);
|
void CompressFromFullMatrix(CMatrix &other);
|
||||||
void DecompressIntoFullMatrix(CMatrix &other);
|
void DecompressIntoFullMatrix(CMatrix &other);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user