replay bug fixes, script bug fix
This commit is contained in:
parent
1d8b3a216c
commit
152d8c2f40
@ -56,8 +56,8 @@ CReference *&CReplay::pEmptyReferences = *(CReference**)0x8F256C;
|
|||||||
CStoredDetailedAnimationState *&CReplay::pPedAnims = *(CStoredDetailedAnimationState**)0x8F6260;
|
CStoredDetailedAnimationState *&CReplay::pPedAnims = *(CStoredDetailedAnimationState**)0x8F6260;
|
||||||
uint8 *&CReplay::pPickups = *(uint8**)0x8F1A48;
|
uint8 *&CReplay::pPickups = *(uint8**)0x8F1A48;
|
||||||
uint8 *&CReplay::pReferences = *(uint8**)0x880FAC;
|
uint8 *&CReplay::pReferences = *(uint8**)0x880FAC;
|
||||||
uint8(&CReplay::BufferStatus)[8] = *(uint8(*)[8])*(uintptr*)0x8804D8;
|
uint8(&CReplay::BufferStatus)[NUM_REPLAYBUFFERS] = *(uint8(*)[NUM_REPLAYBUFFERS])*(uintptr*)0x8804D8;
|
||||||
uint8(&CReplay::Buffers)[8][100000] = *(uint8(*)[8][100000])*(uintptr*)0x779958;
|
uint8(&CReplay::Buffers)[NUM_REPLAYBUFFERS][REPLAYBUFFERSIZE] = *(uint8(*)[NUM_REPLAYBUFFERS][REPLAYBUFFERSIZE])*(uintptr*)0x779958;
|
||||||
bool &CReplay::bPlayingBackFromFile = *(bool*)0x95CD58;
|
bool &CReplay::bPlayingBackFromFile = *(bool*)0x95CD58;
|
||||||
bool &CReplay::bReplayEnabled = *(bool*)0x617CAC;
|
bool &CReplay::bReplayEnabled = *(bool*)0x617CAC;
|
||||||
uint32 &CReplay::SlowMotion = *(uint32*)0x9414D4;
|
uint32 &CReplay::SlowMotion = *(uint32*)0x9414D4;
|
||||||
@ -201,7 +201,7 @@ void CReplay::Init(void)
|
|||||||
Record.m_nOffset = 0;
|
Record.m_nOffset = 0;
|
||||||
Record.m_pBase = nil;
|
Record.m_pBase = nil;
|
||||||
Record.m_bSlot = 0;
|
Record.m_bSlot = 0;
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < NUM_REPLAYBUFFERS; i++)
|
||||||
BufferStatus[i] = REPLAYBUFFER_UNUSED;
|
BufferStatus[i] = REPLAYBUFFER_UNUSED;
|
||||||
Record.m_bSlot = 0;
|
Record.m_bSlot = 0;
|
||||||
Record.m_pBase = Buffers[0];
|
Record.m_pBase = Buffers[0];
|
||||||
@ -250,6 +250,10 @@ void CReplay::Update(void)
|
|||||||
SaveReplayToHD();
|
SaveReplayToHD();
|
||||||
if (CPad::GetPad(0)->GetFJustDown(2))
|
if (CPad::GetPad(0)->GetFJustDown(2))
|
||||||
PlayReplayFromHD();
|
PlayReplayFromHD();
|
||||||
|
#ifdef USE_BETA_REPLAY_MODE
|
||||||
|
if (CPad::GetPad(0)->GetFJustDown(3))
|
||||||
|
TriggerPlaybackLastCoupleOfSeconds(5000, REPLAYCAMMODE_TOPDOWN, 0.0f, 0.0f, 0.0f, 4);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,6 +262,41 @@ WRAPPER void CReplay::RecordThisFrame(void) { EAXJMP(0x5932B0); }
|
|||||||
#else
|
#else
|
||||||
void CReplay::RecordThisFrame(void)
|
void CReplay::RecordThisFrame(void)
|
||||||
{
|
{
|
||||||
|
#ifdef FIX_REPLAY_BUGS
|
||||||
|
uint32 memory_required = sizeof(tGeneralPacket) + sizeof(tClockPacket) + sizeof(tWeatherPacket) + sizeof(tTimerPacket);
|
||||||
|
CVehiclePool* vehiclesT = CPools::GetVehiclePool();
|
||||||
|
for (int i = 0; i < vehiclesT->GetSize(); i++) {
|
||||||
|
CVehicle* v = vehiclesT->GetSlot(i);
|
||||||
|
if (v && v->m_rwObject && v->GetModelIndex() != MI_AIRTRAIN && v->GetModelIndex() != MI_TRAIN)
|
||||||
|
memory_required += sizeof(tVehicleUpdatePacket);
|
||||||
|
}
|
||||||
|
CPedPool* pedsT = CPools::GetPedPool();
|
||||||
|
for (int i = 0; i < pedsT->GetSize(); i++) {
|
||||||
|
CPed* p = pedsT->GetSlot(i);
|
||||||
|
if (!p || !p->m_rwObject)
|
||||||
|
continue;
|
||||||
|
if (!p->bHasAlreadyBeenRecorded) {
|
||||||
|
memory_required += sizeof(tPedHeaderPacket);
|
||||||
|
}
|
||||||
|
memory_required += sizeof(tPedUpdatePacket);
|
||||||
|
}
|
||||||
|
for (uint8 i = 0; i < 16; i++) {
|
||||||
|
if (!CBulletTraces::aTraces[i].m_bInUse)
|
||||||
|
continue;
|
||||||
|
memory_required += sizeof(tBulletTracePacket);
|
||||||
|
}
|
||||||
|
memory_required += sizeof(tEndOfFramePacket);
|
||||||
|
if (Record.m_nOffset + memory_required > REPLAYBUFFERSIZE) {
|
||||||
|
Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END;
|
||||||
|
BufferStatus[Record.m_bSlot] = REPLAYBUFFER_PLAYBACK;
|
||||||
|
Record.m_bSlot = (Record.m_bSlot + 1) % NUM_REPLAYBUFFERS;
|
||||||
|
BufferStatus[Record.m_bSlot] = REPLAYBUFFER_RECORD;
|
||||||
|
Record.m_pBase = Buffers[Record.m_bSlot];
|
||||||
|
Record.m_nOffset = 0;
|
||||||
|
*Record.m_pBase = REPLAYPACKET_END;
|
||||||
|
MarkEverythingAsNew();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
tGeneralPacket* general = (tGeneralPacket*)&Record.m_pBase[Record.m_nOffset];
|
tGeneralPacket* general = (tGeneralPacket*)&Record.m_pBase[Record.m_nOffset];
|
||||||
general->type = REPLAYPACKET_GENERAL;
|
general->type = REPLAYPACKET_GENERAL;
|
||||||
general->camera_pos.CopyOnlyMatrix(&TheCamera.GetMatrix());
|
general->camera_pos.CopyOnlyMatrix(&TheCamera.GetMatrix());
|
||||||
@ -316,21 +355,22 @@ void CReplay::RecordThisFrame(void)
|
|||||||
tEndOfFramePacket* eof = (tEndOfFramePacket*)&Record.m_pBase[Record.m_nOffset];
|
tEndOfFramePacket* eof = (tEndOfFramePacket*)&Record.m_pBase[Record.m_nOffset];
|
||||||
eof->type = REPLAYPACKET_ENDOFFRAME;
|
eof->type = REPLAYPACKET_ENDOFFRAME;
|
||||||
Record.m_nOffset += sizeof(*eof);
|
Record.m_nOffset += sizeof(*eof);
|
||||||
if (Record.m_nOffset <= 97000){
|
Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END;
|
||||||
|
#ifndef FIX_REPLAY_BUGS
|
||||||
|
if (Record.m_nOffset <= REPLAYBUFFERSIZE - 3000){
|
||||||
/* Unsafe assumption which can cause buffer overflow
|
/* Unsafe assumption which can cause buffer overflow
|
||||||
* if size of next frame exceeds 3000 bytes.
|
* if size of next frame exceeds 3000 bytes.
|
||||||
* Most notably it causes various timecyc errors. */
|
* Most notably it causes various timecyc errors. */
|
||||||
Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Record.m_pBase[Record.m_nOffset] = REPLAYPACKET_END;
|
|
||||||
BufferStatus[Record.m_bSlot] = REPLAYBUFFER_PLAYBACK;
|
BufferStatus[Record.m_bSlot] = REPLAYBUFFER_PLAYBACK;
|
||||||
Record.m_bSlot = (Record.m_bSlot + 1) % 8;
|
Record.m_bSlot = (Record.m_bSlot + 1) % NUM_REPLAYBUFFERS;
|
||||||
BufferStatus[Record.m_bSlot] = REPLAYBUFFER_RECORD;
|
BufferStatus[Record.m_bSlot] = REPLAYBUFFER_RECORD;
|
||||||
Record.m_pBase = Buffers[Record.m_bSlot];
|
Record.m_pBase = Buffers[Record.m_bSlot];
|
||||||
Record.m_nOffset = 0;
|
Record.m_nOffset = 0;
|
||||||
*Record.m_pBase = REPLAYPACKET_END;
|
*Record.m_pBase = REPLAYPACKET_END;
|
||||||
MarkEverythingAsNew();
|
MarkEverythingAsNew();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -366,8 +406,8 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
|
|||||||
CAnimBlendAssociation* main = RpAnimBlendClumpGetMainAssociation((RpClump*)ped->m_rwObject, &second, &blend_amount);
|
CAnimBlendAssociation* main = RpAnimBlendClumpGetMainAssociation((RpClump*)ped->m_rwObject, &second, &blend_amount);
|
||||||
if (main){
|
if (main){
|
||||||
state->animId = main->animId;
|
state->animId = main->animId;
|
||||||
state->time = 255.0f / 4.0f * max(0.0f, min(4.0f, main->currentTime));
|
state->time = 255.0f / 4.0f * clamp(main->currentTime, 0.0f, 4.0f);
|
||||||
state->speed = 255.0f / 3.0f * max(0.0f, min(3.0f, main->speed));
|
state->speed = 255.0f / 3.0f * clamp(main->speed, 0.0f, 3.0f);
|
||||||
}else{
|
}else{
|
||||||
state->animId = 3;
|
state->animId = 3;
|
||||||
state->time = 0;
|
state->time = 0;
|
||||||
@ -375,9 +415,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
|
|||||||
}
|
}
|
||||||
if (second) {
|
if (second) {
|
||||||
state->secAnimId = second->animId;
|
state->secAnimId = second->animId;
|
||||||
state->secTime = 255.0f / 4.0f * max(0.0f, min(4.0f, second->currentTime));
|
state->secTime = 255.0f / 4.0f * clamp(second->currentTime, 0.0f, 4.0f);
|
||||||
state->secSpeed = 255.0f / 3.0f * max(0.0f, min(3.0f, second->speed));
|
state->secSpeed = 255.0f / 3.0f * clamp(second->speed, 0.0f, 3.0f);
|
||||||
state->blendAmount = 255.0f / 2.0f * max(0.0f, min(2.0f, blend_amount));
|
state->blendAmount = 255.0f / 2.0f * clamp(blend_amount, 0.0f, 2.0f);
|
||||||
}else{
|
}else{
|
||||||
state->secAnimId = 0;
|
state->secAnimId = 0;
|
||||||
state->secTime = 0;
|
state->secTime = 0;
|
||||||
@ -387,9 +427,9 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
|
|||||||
CAnimBlendAssociation* partial = RpAnimBlendClumpGetMainPartialAssociation((RpClump*)ped->m_rwObject);
|
CAnimBlendAssociation* partial = RpAnimBlendClumpGetMainPartialAssociation((RpClump*)ped->m_rwObject);
|
||||||
if (partial) {
|
if (partial) {
|
||||||
state->partAnimId = partial->animId;
|
state->partAnimId = partial->animId;
|
||||||
state->partAnimTime = 255.0f / 4.0f * max(0.0f, min(4.0f, partial->currentTime));
|
state->partAnimTime = 255.0f / 4.0f * clamp(partial->currentTime, 0.0f, 4.0f);
|
||||||
state->partAnimSpeed = 255.0f / 3.0f * max(0.0f, min(3.0f, partial->speed));
|
state->partAnimSpeed = 255.0f / 3.0f * clamp(partial->speed, 0.0f, 3.0f);
|
||||||
state->partBlendAmount = 255.0f / 2.0f * max(0.0f, min(2.0f, partial->blendAmount));
|
state->partBlendAmount = 255.0f / 2.0f * clamp(partial->blendAmount, 0.0f, 2.0f);
|
||||||
}else{
|
}else{
|
||||||
state->partAnimId = 0;
|
state->partAnimId = 0;
|
||||||
state->partAnimTime = 0;
|
state->partAnimTime = 0;
|
||||||
@ -404,13 +444,16 @@ WRAPPER void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimat
|
|||||||
#else
|
#else
|
||||||
void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state)
|
void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++){
|
for (int i = 0; i < NUM_MAIN_ANIMS_IN_REPLAY; i++){
|
||||||
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainAssociation_N((RpClump*)ped->m_rwObject, i);
|
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainAssociation_N((RpClump*)ped->m_rwObject, i);
|
||||||
if (assoc){
|
if (assoc){
|
||||||
state->aAnimId[i] = assoc->animId;
|
state->aAnimId[i] = assoc->animId;
|
||||||
state->aCurTime[i] = 255.0f / 4.0f * max(0.0f, min(4.0f, assoc->currentTime));
|
state->aCurTime[i] = 255.0f / 4.0f * clamp(assoc->currentTime, 0.0f, 4.0f);
|
||||||
state->aSpeed[i] = 255.0f / 3.0f * max(0.0f, min(3.0f, assoc->speed));
|
state->aSpeed[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f);
|
||||||
state->aBlendAmount[i] = 255.0f / 2.0f * max(0.0f, min(2.0f, assoc->blendAmount));
|
state->aBlendAmount[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f);
|
||||||
|
#ifdef FIX_REPLAY_BUGS
|
||||||
|
state->aBlendDelta[i] = 127.0f / 32.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
|
||||||
|
#endif
|
||||||
state->aFlags[i] = assoc->flags;
|
state->aFlags[i] = 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);
|
||||||
@ -427,13 +470,16 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
|
|||||||
state->aFlags[i] = 0;
|
state->aFlags[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < NUM_PARTIAL_ANIMS_IN_REPLAY; i++) {
|
||||||
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainPartialAssociation_N((RpClump*)ped->m_rwObject, i);
|
CAnimBlendAssociation* assoc = RpAnimBlendClumpGetMainPartialAssociation_N((RpClump*)ped->m_rwObject, i);
|
||||||
if (assoc) {
|
if (assoc) {
|
||||||
state->aAnimId2[i] = assoc->animId;
|
state->aAnimId2[i] = assoc->animId;
|
||||||
state->aCurTime2[i] = 255.0f / 4.0f * max(0.0f, min(4.0f, assoc->currentTime));
|
state->aCurTime2[i] = 255.0f / 4.0f * clamp(assoc->currentTime, 0.0f, 4.0f);
|
||||||
state->aSpeed2[i] = 255.0f / 3.0f * max(0.0f, min(3.0f, assoc->speed));
|
state->aSpeed2[i] = 255.0f / 3.0f * clamp(assoc->speed, 0.0f, 3.0f);
|
||||||
state->aBlendAmount2[i] = 255.0f / 2.0f * max(0.0f, min(2.0f, assoc->blendAmount));
|
state->aBlendAmount2[i] = 255.0f / 2.0f * clamp(assoc->blendAmount, 0.0f, 2.0f);
|
||||||
|
#ifdef FIX_REPLAY_BUGS
|
||||||
|
state->aBlendDelta2[i] = 127.0f / 16.0f * clamp(assoc->blendDelta, -16.0f, 16.0f);
|
||||||
|
#endif
|
||||||
state->aFlags2[i] = assoc->flags;
|
state->aFlags2[i] = 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);
|
||||||
@ -460,7 +506,7 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB
|
|||||||
{
|
{
|
||||||
tPedUpdatePacket *pp = (tPedUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
|
tPedUpdatePacket *pp = (tPedUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
|
||||||
if (!ped){
|
if (!ped){
|
||||||
debug("Replay:Ped wasn't there\n");
|
printf("Replay:Ped wasn't there\n");
|
||||||
buffer->m_nOffset += sizeof(tPedUpdatePacket);
|
buffer->m_nOffset += sizeof(tPedUpdatePacket);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -541,17 +587,33 @@ WRAPPER void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAni
|
|||||||
#else
|
#else
|
||||||
void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state)
|
void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++){
|
#ifdef FIX_REPLAY_BUGS
|
||||||
|
CAnimBlendAssociation* assoc;
|
||||||
|
for (int i = 0; ((assoc = RpAnimBlendClumpGetMainAssociation_N(ped->GetClump(), i))); i++)
|
||||||
|
assoc->SetBlend(0.0f, -1.0f);
|
||||||
|
for (int i = 0; ((assoc = RpAnimBlendClumpGetMainPartialAssociation_N(ped->GetClump(), i))); i++)
|
||||||
|
assoc->SetBlend(0.0f, -1.0f);
|
||||||
|
#endif
|
||||||
|
for (int i = 0; i < NUM_MAIN_ANIMS_IN_REPLAY; i++) {
|
||||||
if (state->aAnimId[i] == NUM_ANIMS)
|
if (state->aAnimId[i] == NUM_ANIMS)
|
||||||
continue;
|
continue;
|
||||||
|
#ifdef FIX_REPLAY_BUGS
|
||||||
|
CAnimBlendAssociation* anim = CAnimManager::AddAnimation(ped->GetClump(),
|
||||||
|
state->aAnimId[i] > 3 ? ASSOCGRP_STD : ped->m_animGroup,
|
||||||
|
(AnimationId)state->aAnimId[i]);
|
||||||
|
#else
|
||||||
CAnimBlendAssociation* anim = CAnimManager::BlendAnimation(
|
CAnimBlendAssociation* anim = CAnimManager::BlendAnimation(
|
||||||
(RpClump*)ped->m_rwObject,
|
(RpClump*)ped->m_rwObject,
|
||||||
state->aAnimId[i] > 3 ? ASSOCGRP_STD : ped->m_animGroup,
|
state->aAnimId[i] > 3 ? ASSOCGRP_STD : ped->m_animGroup,
|
||||||
(AnimationId)state->aAnimId[i], 100.0f);
|
(AnimationId)state->aAnimId[i], 100.0f);
|
||||||
|
#endif
|
||||||
anim->SetCurrentTime(state->aCurTime[i] * 4.0f / 255.0f);
|
anim->SetCurrentTime(state->aCurTime[i] * 4.0f / 255.0f);
|
||||||
anim->speed = state->aSpeed[i] * 3.0f / 255.0f;
|
anim->speed = state->aSpeed[i] * 3.0f / 255.0f;
|
||||||
/* Lack of commented out calculation causes megajump */
|
#ifdef FIX_REPLAY_BUGS
|
||||||
anim->SetBlend(state->aBlendAmount[i] /* * 2.0f / 255.0f */, 1.0f);
|
anim->SetBlend(state->aBlendAmount[i] * 2.0f / 255.0f, state->aBlendDelta[i] * 16.0f / 127.0f);
|
||||||
|
#else
|
||||||
|
anim->SetBlend(state->aBlendAmount[i], 1.0f);
|
||||||
|
#endif
|
||||||
anim->flags = state->aFlags[i];
|
anim->flags = state->aFlags[i];
|
||||||
uint8 callback = state->aFunctionCallbackID[i];
|
uint8 callback = state->aFunctionCallbackID[i];
|
||||||
if (!callback)
|
if (!callback)
|
||||||
@ -561,17 +623,26 @@ void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationSt
|
|||||||
else
|
else
|
||||||
anim->SetDeleteCallback(FindCBFunction(callback & 0x7F), ped);
|
anim->SetDeleteCallback(FindCBFunction(callback & 0x7F), ped);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < NUM_PARTIAL_ANIMS_IN_REPLAY; i++) {
|
||||||
if (state->aAnimId2[i] == NUM_ANIMS)
|
if (state->aAnimId2[i] == NUM_ANIMS)
|
||||||
continue;
|
continue;
|
||||||
|
#ifdef FIX_REPLAY_BUGS
|
||||||
|
CAnimBlendAssociation* anim = CAnimManager::AddAnimation(ped->GetClump(),
|
||||||
|
state->aAnimId2[i] > 3 ? ASSOCGRP_STD : ped->m_animGroup,
|
||||||
|
(AnimationId)state->aAnimId2[i]);
|
||||||
|
#else
|
||||||
CAnimBlendAssociation* anim = CAnimManager::BlendAnimation(
|
CAnimBlendAssociation* anim = CAnimManager::BlendAnimation(
|
||||||
(RpClump*)ped->m_rwObject,
|
(RpClump*)ped->m_rwObject,
|
||||||
state->aAnimId2[i] > 3 ? ASSOCGRP_STD : ped->m_animGroup,
|
state->aAnimId2[i] > 3 ? ASSOCGRP_STD : ped->m_animGroup,
|
||||||
(AnimationId)state->aAnimId2[i], 100.0f);
|
(AnimationId)state->aAnimId2[i], 100.0f);
|
||||||
|
#endif
|
||||||
anim->SetCurrentTime(state->aCurTime2[i] * 4.0f / 255.0f);
|
anim->SetCurrentTime(state->aCurTime2[i] * 4.0f / 255.0f);
|
||||||
anim->speed = state->aSpeed2[i] * 3.0f / 255.0f;
|
anim->speed = state->aSpeed2[i] * 3.0f / 255.0f;
|
||||||
/* Lack of commented out calculation causes megajump */
|
#ifdef FIX_REPLAY_BUGS
|
||||||
anim->SetBlend(state->aBlendAmount2[i] /* * 2.0f / 255.0f */, 1.0f);
|
anim->SetBlend(state->aBlendAmount2[i] * 2.0f / 255.0f, state->aBlendDelta2[i] * 16.0f / 127.0f);
|
||||||
|
#else
|
||||||
|
anim->SetBlend(state->aBlendAmount2[i], 1.0f);
|
||||||
|
#endif
|
||||||
anim->flags = state->aFlags2[i];
|
anim->flags = state->aFlags2[i];
|
||||||
uint8 callback = state->aFunctionCallbackID2[i];
|
uint8 callback = state->aFunctionCallbackID2[i];
|
||||||
if (!callback)
|
if (!callback)
|
||||||
@ -589,23 +660,23 @@ WRAPPER void CReplay::PlaybackThisFrame(void) { EAXJMP(0x5946B0); }
|
|||||||
#else
|
#else
|
||||||
void CReplay::PlaybackThisFrame(void)
|
void CReplay::PlaybackThisFrame(void)
|
||||||
{
|
{
|
||||||
static int SlowMotionCounter = 0;
|
static int FrameSloMo = 0;
|
||||||
CAddressInReplayBuffer buf = Playback;
|
CAddressInReplayBuffer buf = Playback;
|
||||||
if (PlayBackThisFrameInterpolation(&buf, 1.0f, nil)){
|
if (PlayBackThisFrameInterpolation(&buf, 1.0f, nil)){
|
||||||
DMAudio.SetEffectsFadeVol(127);
|
DMAudio.SetEffectsFadeVol(127);
|
||||||
DMAudio.SetMusicFadeVol(127);
|
DMAudio.SetMusicFadeVol(127);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (SlowMotionCounter){
|
if (FrameSloMo){
|
||||||
CAddressInReplayBuffer buf_sm = buf;
|
CAddressInReplayBuffer buf_sm = buf;
|
||||||
if (PlayBackThisFrameInterpolation(&buf_sm, SlowMotionCounter * 1.0f / SlowMotion, nil)){
|
if (PlayBackThisFrameInterpolation(&buf_sm, FrameSloMo * 1.0f / SlowMotion, nil)){
|
||||||
DMAudio.SetEffectsFadeVol(127);
|
DMAudio.SetEffectsFadeVol(127);
|
||||||
DMAudio.SetMusicFadeVol(127);
|
DMAudio.SetMusicFadeVol(127);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SlowMotionCounter = (SlowMotionCounter + 1) % SlowMotion;
|
FrameSloMo = (FrameSloMo + 1) % SlowMotion;
|
||||||
if (SlowMotionCounter == 0)
|
if (FrameSloMo == 0)
|
||||||
Playback = buf;
|
Playback = buf;
|
||||||
ProcessLookAroundCam();
|
ProcessLookAroundCam();
|
||||||
DMAudio.SetEffectsFadeVol(0);
|
DMAudio.SetEffectsFadeVol(0);
|
||||||
@ -613,6 +684,29 @@ void CReplay::PlaybackThisFrame(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// next two functions are only found in mobile version
|
||||||
|
// most likely they were optimized out for being unused
|
||||||
|
|
||||||
|
void CReplay::TriggerPlaybackLastCoupleOfSeconds(uint32 start, uint8 cam_mode, float cam_x, float cam_y, float cam_z, uint32 slomo)
|
||||||
|
{
|
||||||
|
if (Mode != MODE_RECORD)
|
||||||
|
return;
|
||||||
|
TriggerPlayback(cam_mode, cam_x, cam_y, cam_z, true);
|
||||||
|
SlowMotion = slomo;
|
||||||
|
bAllowLookAroundCam = false;
|
||||||
|
if (!FastForwardToTime(CTimer::GetTimeInMilliseconds() - start))
|
||||||
|
Mode = MODE_RECORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CReplay::FastForwardToTime(uint32 start)
|
||||||
|
{
|
||||||
|
uint32 timer = 0;
|
||||||
|
while (start > timer)
|
||||||
|
if (PlayBackThisFrameInterpolation(&Playback, 1.0f, &timer))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
WRAPPER void CReplay::StoreCarUpdate(CVehicle *vehicle, int id) { EAXJMP(0x5947F0); }
|
WRAPPER void CReplay::StoreCarUpdate(CVehicle *vehicle, int id) { EAXJMP(0x5947F0); }
|
||||||
#else
|
#else
|
||||||
@ -660,7 +754,7 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
|
|||||||
{
|
{
|
||||||
tVehicleUpdatePacket* vp = (tVehicleUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
|
tVehicleUpdatePacket* vp = (tVehicleUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
|
||||||
if (!vehicle){
|
if (!vehicle){
|
||||||
debug("Replay:Car wasn't there");
|
printf("Replay:Car wasn't there");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CMatrix vehicle_matrix;
|
CMatrix vehicle_matrix;
|
||||||
@ -686,34 +780,34 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
|
|||||||
car->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f;
|
car->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f;
|
||||||
car->m_aWheelRotation[i] = vp->wheel_rotation[i] * PI / 128.0f;
|
car->m_aWheelRotation[i] = vp->wheel_rotation[i] * PI / 128.0f;
|
||||||
}
|
}
|
||||||
car->Doors[2].m_fAngle = car->Doors[2].m_fPrevAngle = vp->door_angles[0] * PI / 127.0f;
|
car->Doors[DOOR_FRONT_LEFT].m_fAngle = car->Doors[DOOR_FRONT_LEFT].m_fPrevAngle = vp->door_angles[0] * PI / 127.0f;
|
||||||
car->Doors[3].m_fAngle = car->Doors[3].m_fPrevAngle = vp->door_angles[1] * PI / 127.0f;
|
car->Doors[DOOR_FRONT_RIGHT].m_fAngle = car->Doors[DOOR_FRONT_RIGHT].m_fPrevAngle = vp->door_angles[1] * PI / 127.0f;
|
||||||
if (vp->door_angles[0])
|
if (vp->door_angles[0])
|
||||||
car->Damage.SetDoorStatus(2, 2);
|
car->Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_SWINGING);
|
||||||
if (vp->door_angles[1])
|
if (vp->door_angles[1])
|
||||||
car->Damage.SetDoorStatus(3, 2);
|
car->Damage.SetDoorStatus(DOOR_FRONT_RIGHT, DOOR_STATUS_SWINGING);
|
||||||
if (vp->door_status & 1 && car->Damage.GetDoorStatus(DOOR_BONNET) != 3){
|
if (vp->door_status & 1 && car->Damage.GetDoorStatus(DOOR_BONNET) != 3){
|
||||||
car->Damage.SetDoorStatus(DOOR_BONNET, 3);
|
car->Damage.SetDoorStatus(DOOR_BONNET, DOOR_STATUS_MISSING);
|
||||||
car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true);
|
car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true);
|
||||||
}
|
}
|
||||||
if (vp->door_status & 2 && car->Damage.GetDoorStatus(DOOR_BOOT) != 3) {
|
if (vp->door_status & 2 && car->Damage.GetDoorStatus(DOOR_BOOT) != 3) {
|
||||||
car->Damage.SetDoorStatus(DOOR_BOOT, 3);
|
car->Damage.SetDoorStatus(DOOR_BOOT, DOOR_STATUS_MISSING);
|
||||||
car->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true);
|
car->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true);
|
||||||
}
|
}
|
||||||
if (vp->door_status & 4 && car->Damage.GetDoorStatus(DOOR_FRONT_LEFT) != 3) {
|
if (vp->door_status & 4 && car->Damage.GetDoorStatus(DOOR_FRONT_LEFT) != 3) {
|
||||||
car->Damage.SetDoorStatus(DOOR_FRONT_LEFT, 3);
|
car->Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_MISSING);
|
||||||
car->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT, true);
|
car->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT, true);
|
||||||
}
|
}
|
||||||
if (vp->door_status & 8 && car->Damage.GetDoorStatus(DOOR_FRONT_RIGHT) != 3) {
|
if (vp->door_status & 8 && car->Damage.GetDoorStatus(DOOR_FRONT_RIGHT) != 3) {
|
||||||
car->Damage.SetDoorStatus(DOOR_FRONT_RIGHT, 3);
|
car->Damage.SetDoorStatus(DOOR_FRONT_RIGHT, DOOR_STATUS_MISSING);
|
||||||
car->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT, true);
|
car->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT, true);
|
||||||
}
|
}
|
||||||
if (vp->door_status & 0x10 && car->Damage.GetDoorStatus(DOOR_REAR_LEFT) != 3) {
|
if (vp->door_status & 0x10 && car->Damage.GetDoorStatus(DOOR_REAR_LEFT) != 3) {
|
||||||
car->Damage.SetDoorStatus(DOOR_REAR_LEFT, 3);
|
car->Damage.SetDoorStatus(DOOR_REAR_LEFT, DOOR_STATUS_MISSING);
|
||||||
car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true);
|
car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true);
|
||||||
}
|
}
|
||||||
if (vp->door_status & 0x20 && car->Damage.GetDoorStatus(DOOR_REAR_RIGHT) != 3) {
|
if (vp->door_status & 0x20 && car->Damage.GetDoorStatus(DOOR_REAR_RIGHT) != 3) {
|
||||||
car->Damage.SetDoorStatus(DOOR_REAR_RIGHT, 3);
|
car->Damage.SetDoorStatus(DOOR_REAR_RIGHT, DOOR_STATUS_MISSING);
|
||||||
car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true);
|
car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true);
|
||||||
}
|
}
|
||||||
vehicle->bEngineOn = true;
|
vehicle->bEngineOn = true;
|
||||||
@ -738,7 +832,9 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
|
|||||||
* Obviously fact of picking them up is a bug on its own,
|
* Obviously fact of picking them up is a bug on its own,
|
||||||
* but it doesn't cancel this one.
|
* but it doesn't cancel this one.
|
||||||
*/
|
*/
|
||||||
|
#ifndef FIX_REPLAY_BUGS
|
||||||
FindPlayerPed()->m_pWanted = &PlayerWanted;
|
FindPlayerPed()->m_pWanted = &PlayerWanted;
|
||||||
|
#endif
|
||||||
|
|
||||||
CBulletTraces::Init();
|
CBulletTraces::Init();
|
||||||
float split = 1.0f - interpolation;
|
float split = 1.0f - interpolation;
|
||||||
@ -758,7 +854,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
|
|||||||
FinishPlayback();
|
FinishPlayback();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
buffer->m_bSlot = (slot + 1) % 8;
|
buffer->m_bSlot = (slot + 1) % NUM_REPLAYBUFFERS;
|
||||||
buffer->m_nOffset = 0;
|
buffer->m_nOffset = 0;
|
||||||
buffer->m_pBase = Buffers[buffer->m_bSlot];
|
buffer->m_pBase = Buffers[buffer->m_bSlot];
|
||||||
ped_min_index = 0;
|
ped_min_index = 0;
|
||||||
@ -880,6 +976,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
|
|||||||
case REPLAYPACKET_ENDOFFRAME:
|
case REPLAYPACKET_ENDOFFRAME:
|
||||||
{
|
{
|
||||||
/* Not supposed to be here. */
|
/* Not supposed to be here. */
|
||||||
|
assert(false);
|
||||||
buffer->m_nOffset++;
|
buffer->m_nOffset++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -961,7 +1058,7 @@ void CReplay::EmptyReplayBuffer(void)
|
|||||||
if (Mode == MODE_PLAYBACK)
|
if (Mode == MODE_PLAYBACK)
|
||||||
return;
|
return;
|
||||||
Record.m_nOffset = 0;
|
Record.m_nOffset = 0;
|
||||||
for (int i = 0; i < 8; i++){
|
for (int i = 0; i < NUM_REPLAYBUFFERS; i++){
|
||||||
BufferStatus[i] = REPLAYBUFFER_UNUSED;
|
BufferStatus[i] = REPLAYBUFFER_UNUSED;
|
||||||
}
|
}
|
||||||
Record.m_bSlot = 0;
|
Record.m_bSlot = 0;
|
||||||
@ -1040,11 +1137,11 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca
|
|||||||
DMAudio.SetEffectsFadeVol(0);
|
DMAudio.SetEffectsFadeVol(0);
|
||||||
DMAudio.SetMusicFadeVol(0);
|
DMAudio.SetMusicFadeVol(0);
|
||||||
int current;
|
int current;
|
||||||
for (current = 0; current < 8; current++)
|
for (current = 0; current < NUM_REPLAYBUFFERS; current++)
|
||||||
if (BufferStatus[current] == REPLAYBUFFER_RECORD)
|
if (BufferStatus[current] == REPLAYBUFFER_RECORD)
|
||||||
break;
|
break;
|
||||||
int first;
|
int first;
|
||||||
for (first = (current + 1) % 8; ; first = (first + 1) % 8)
|
for (first = (current + 1) % NUM_REPLAYBUFFERS; ; first = (first + 1) % NUM_REPLAYBUFFERS)
|
||||||
if (BufferStatus[first] == REPLAYBUFFER_RECORD || BufferStatus[first] == REPLAYBUFFER_PLAYBACK)
|
if (BufferStatus[first] == REPLAYBUFFER_RECORD || BufferStatus[first] == REPLAYBUFFER_PLAYBACK)
|
||||||
break;
|
break;
|
||||||
Playback.m_bSlot = first;
|
Playback.m_bSlot = first;
|
||||||
@ -1153,7 +1250,11 @@ void CReplay::RestoreStuffFromMem(void)
|
|||||||
memcpy(CRadar::ms_RadarTrace, pRadarBlips, sizeof(CBlip) * NUMRADARBLIPS);
|
memcpy(CRadar::ms_RadarTrace, pRadarBlips, sizeof(CBlip) * NUMRADARBLIPS);
|
||||||
delete[] pRadarBlips;
|
delete[] pRadarBlips;
|
||||||
pRadarBlips = nil;
|
pRadarBlips = nil;
|
||||||
FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted); /* Nice memory leak */
|
#ifdef FIX_REPLAY_BUGS
|
||||||
|
// NB: can only be used with fixed bug at the start of PlayBackThisFrameInterpolation
|
||||||
|
delete FindPlayerPed()->m_pWanted;
|
||||||
|
#endif
|
||||||
|
FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted);
|
||||||
CWorld::Players[0] = PlayerInfo;
|
CWorld::Players[0] = PlayerInfo;
|
||||||
int i = CPools::GetPedPool()->GetSize();
|
int i = CPools::GetPedPool()->GetSize();
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
@ -1366,25 +1467,25 @@ void CReplay::SaveReplayToHD(void)
|
|||||||
{
|
{
|
||||||
CFileMgr::SetDirMyDocuments();
|
CFileMgr::SetDirMyDocuments();
|
||||||
int fw = CFileMgr::OpenFileForWriting("replay.rep");
|
int fw = CFileMgr::OpenFileForWriting("replay.rep");
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_REPLAY_BUGS
|
||||||
if (fw == 0) {
|
if (fw == 0) {
|
||||||
#else
|
#else
|
||||||
if (fw < 0){ // BUG?
|
if (fw < 0){ // BUG?
|
||||||
#endif
|
#endif
|
||||||
debug("Couldn't open replay.rep for writing");
|
printf("Couldn't open replay.rep for writing");
|
||||||
CFileMgr::SetDir("");
|
CFileMgr::SetDir("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CFileMgr::Write(fw, "gta3_7f", sizeof("gta3_7f"));
|
CFileMgr::Write(fw, "gta3_7f", sizeof("gta3_7f"));
|
||||||
int current;
|
int current;
|
||||||
for (current = 0; current < 8; current++)
|
for (current = 0; current < NUM_REPLAYBUFFERS; current++)
|
||||||
if (BufferStatus[current] == REPLAYBUFFER_RECORD)
|
if (BufferStatus[current] == REPLAYBUFFER_RECORD)
|
||||||
break;
|
break;
|
||||||
int first;
|
int first;
|
||||||
for (first = (current + 1) % 8; ; first = (first + 1) % 8)
|
for (first = (current + 1) % NUM_REPLAYBUFFERS; ; first = (first + 1) % NUM_REPLAYBUFFERS)
|
||||||
if (BufferStatus[first] == REPLAYBUFFER_RECORD || BufferStatus[first] == REPLAYBUFFER_PLAYBACK)
|
if (BufferStatus[first] == REPLAYBUFFER_RECORD || BufferStatus[first] == REPLAYBUFFER_PLAYBACK)
|
||||||
break;
|
break;
|
||||||
for(int i = first;; i = (i + 1) % 8 ){
|
for(int i = first;; i = (i + 1) % NUM_REPLAYBUFFERS){
|
||||||
CFileMgr::Write(fw, (char*)Buffers[first], sizeof(Buffers[first]));
|
CFileMgr::Write(fw, (char*)Buffers[first], sizeof(Buffers[first]));
|
||||||
if (BufferStatus[i] == REPLAYBUFFER_RECORD)
|
if (BufferStatus[i] == REPLAYBUFFER_RECORD)
|
||||||
break;
|
break;
|
||||||
@ -1402,14 +1503,16 @@ void PlayReplayFromHD(void)
|
|||||||
CFileMgr::SetDirMyDocuments();
|
CFileMgr::SetDirMyDocuments();
|
||||||
int fr = CFileMgr::OpenFile("replay.rep", "rb");
|
int fr = CFileMgr::OpenFile("replay.rep", "rb");
|
||||||
if (fr == 0) {
|
if (fr == 0) {
|
||||||
debug("Couldn't open replay.rep for reading");
|
printf("Couldn't open replay.rep for reading");
|
||||||
/* Forgot to SetDir? */
|
#ifdef FIX_REPLAY_BUGS
|
||||||
|
CFileMgr::SetDir("");
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CFileMgr::Read(fr, gString, 8);
|
CFileMgr::Read(fr, gString, 8);
|
||||||
if (strncmp(gString, "gta3_7f", sizeof("gta3_7f"))){
|
if (strncmp(gString, "gta3_7f", sizeof("gta3_7f"))){
|
||||||
CFileMgr::CloseFile(fr);
|
CFileMgr::CloseFile(fr);
|
||||||
debug("Wrong file type for replay");
|
printf("Wrong file type for replay");
|
||||||
CFileMgr::SetDir("");
|
CFileMgr::SetDir("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1417,7 +1520,7 @@ void PlayReplayFromHD(void)
|
|||||||
for (slot = 0; CFileMgr::Read(fr, (char*)CReplay::Buffers[slot], sizeof(CReplay::Buffers[slot])); slot++)
|
for (slot = 0; CFileMgr::Read(fr, (char*)CReplay::Buffers[slot], sizeof(CReplay::Buffers[slot])); slot++)
|
||||||
CReplay::BufferStatus[slot] = CReplay::REPLAYBUFFER_PLAYBACK;
|
CReplay::BufferStatus[slot] = CReplay::REPLAYBUFFER_PLAYBACK;
|
||||||
CReplay::BufferStatus[slot - 1] = CReplay::REPLAYBUFFER_RECORD;
|
CReplay::BufferStatus[slot - 1] = CReplay::REPLAYBUFFER_RECORD;
|
||||||
while (slot < 8)
|
while (slot < CReplay::NUM_REPLAYBUFFERS)
|
||||||
CReplay::BufferStatus[slot++] = CReplay::REPLAYBUFFER_UNUSED;
|
CReplay::BufferStatus[slot++] = CReplay::REPLAYBUFFER_UNUSED;
|
||||||
CFileMgr::CloseFile(fr);
|
CFileMgr::CloseFile(fr);
|
||||||
CFileMgr::SetDir("");
|
CFileMgr::SetDir("");
|
||||||
@ -1433,7 +1536,7 @@ WRAPPER void CReplay::StreamAllNecessaryCarsAndPeds(void) { EAXJMP(0x597560); }
|
|||||||
#else
|
#else
|
||||||
void CReplay::StreamAllNecessaryCarsAndPeds(void)
|
void CReplay::StreamAllNecessaryCarsAndPeds(void)
|
||||||
{
|
{
|
||||||
for (int slot = 0; slot < 8; slot++) {
|
for (int slot = 0; slot < NUM_REPLAYBUFFERS; slot++) {
|
||||||
if (BufferStatus[slot] == REPLAYBUFFER_UNUSED)
|
if (BufferStatus[slot] == REPLAYBUFFER_UNUSED)
|
||||||
continue;
|
continue;
|
||||||
for (int offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
|
for (int offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
|
||||||
@ -1459,7 +1562,7 @@ WRAPPER void CReplay::FindFirstFocusCoordinate(CVector *coord) { EAXJMP(0x5975E0
|
|||||||
void CReplay::FindFirstFocusCoordinate(CVector *coord)
|
void CReplay::FindFirstFocusCoordinate(CVector *coord)
|
||||||
{
|
{
|
||||||
*coord = CVector(0.0f, 0.0f, 0.0f);
|
*coord = CVector(0.0f, 0.0f, 0.0f);
|
||||||
for (int slot = 0; slot < 8; slot++) {
|
for (int slot = 0; slot < NUM_REPLAYBUFFERS; slot++) {
|
||||||
if (BufferStatus[slot] == REPLAYBUFFER_UNUSED)
|
if (BufferStatus[slot] == REPLAYBUFFER_UNUSED)
|
||||||
continue;
|
continue;
|
||||||
for (int offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
|
for (int offset = 0; Buffers[slot][offset] != REPLAYPACKET_END; offset += FindSizeOfPacket(Buffers[slot][offset])) {
|
||||||
@ -1561,7 +1664,7 @@ size_t CReplay::FindSizeOfPacket(uint8 type)
|
|||||||
case REPLAYPACKET_ENDOFFRAME: return 4;
|
case REPLAYPACKET_ENDOFFRAME: return 4;
|
||||||
case REPLAYPACKET_TIMER: return sizeof(tTimerPacket);
|
case REPLAYPACKET_TIMER: return sizeof(tTimerPacket);
|
||||||
case REPLAYPACKET_BULLET_TRACES:return sizeof(tBulletTracePacket);
|
case REPLAYPACKET_BULLET_TRACES:return sizeof(tBulletTracePacket);
|
||||||
default: break;
|
default: assert(false); break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1572,11 +1675,11 @@ WRAPPER void CReplay::Display(void) { EAXJMP(0x595EE0); }
|
|||||||
#else
|
#else
|
||||||
void CReplay::Display()
|
void CReplay::Display()
|
||||||
{
|
{
|
||||||
static int counter = 0;
|
static int TimeCount = 0;
|
||||||
if (Mode == MODE_RECORD)
|
if (Mode == MODE_RECORD)
|
||||||
return;
|
return;
|
||||||
counter = (counter + 1) % 65536;
|
TimeCount = (TimeCount + 1) % UINT16_MAX;
|
||||||
if ((counter & 0x20) == 0)
|
if ((TimeCount & 0x20) == 0)
|
||||||
return;
|
return;
|
||||||
CFont::SetPropOn();
|
CFont::SetPropOn();
|
||||||
CFont::SetBackgroundOff();
|
CFont::SetBackgroundOff();
|
||||||
|
@ -10,6 +10,12 @@
|
|||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
#ifndef DONT_FIX_REPLAY_BUGS
|
||||||
|
#define FIX_REPLAY_BUGS
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
struct CAddressInReplayBuffer
|
struct CAddressInReplayBuffer
|
||||||
{
|
{
|
||||||
uint32 m_nOffset;
|
uint32 m_nOffset;
|
||||||
@ -32,20 +38,31 @@ struct CStoredAnimationState
|
|||||||
uint8 partBlendAmount;
|
uint8 partBlendAmount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
NUM_MAIN_ANIMS_IN_REPLAY = 3,
|
||||||
|
NUM_PARTIAL_ANIMS_IN_REPLAY = 6
|
||||||
|
};
|
||||||
|
|
||||||
struct CStoredDetailedAnimationState
|
struct CStoredDetailedAnimationState
|
||||||
{
|
{
|
||||||
uint8 aAnimId[3];
|
uint8 aAnimId[NUM_MAIN_ANIMS_IN_REPLAY];
|
||||||
uint8 aCurTime[3];
|
uint8 aCurTime[NUM_MAIN_ANIMS_IN_REPLAY];
|
||||||
uint8 aSpeed[3];
|
uint8 aSpeed[NUM_MAIN_ANIMS_IN_REPLAY];
|
||||||
uint8 aBlendAmount[3];
|
uint8 aBlendAmount[NUM_MAIN_ANIMS_IN_REPLAY];
|
||||||
uint8 aFunctionCallbackID[3];
|
#ifdef FIX_REPLAY_BUGS
|
||||||
uint16 aFlags[3];
|
int8 aBlendDelta[NUM_MAIN_ANIMS_IN_REPLAY];
|
||||||
uint8 aAnimId2[6];
|
#endif
|
||||||
uint8 aCurTime2[6];
|
uint8 aFunctionCallbackID[NUM_MAIN_ANIMS_IN_REPLAY];
|
||||||
uint8 aSpeed2[6];
|
uint16 aFlags[NUM_MAIN_ANIMS_IN_REPLAY];
|
||||||
uint8 aBlendAmount2[6];
|
uint8 aAnimId2[NUM_PARTIAL_ANIMS_IN_REPLAY];
|
||||||
uint8 aFunctionCallbackID2[6];
|
uint8 aCurTime2[NUM_PARTIAL_ANIMS_IN_REPLAY];
|
||||||
uint16 aFlags2[6];
|
uint8 aSpeed2[NUM_PARTIAL_ANIMS_IN_REPLAY];
|
||||||
|
uint8 aBlendAmount2[NUM_PARTIAL_ANIMS_IN_REPLAY];
|
||||||
|
#ifdef FIX_REPLAY_BUGS
|
||||||
|
int8 aBlendDelta2[NUM_PARTIAL_ANIMS_IN_REPLAY];
|
||||||
|
#endif
|
||||||
|
uint8 aFunctionCallbackID2[NUM_PARTIAL_ANIMS_IN_REPLAY];
|
||||||
|
uint16 aFlags2[NUM_PARTIAL_ANIMS_IN_REPLAY];
|
||||||
};
|
};
|
||||||
|
|
||||||
void PlayReplayFromHD(void);
|
void PlayReplayFromHD(void);
|
||||||
@ -82,6 +99,11 @@ class CReplay
|
|||||||
REPLAYBUFFER_RECORD = 2
|
REPLAYBUFFER_RECORD = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
NUM_REPLAYBUFFERS = 8,
|
||||||
|
REPLAYBUFFERSIZE = 100000
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct tGeneralPacket
|
struct tGeneralPacket
|
||||||
{
|
{
|
||||||
@ -209,8 +231,8 @@ private:
|
|||||||
static CStoredDetailedAnimationState *&pPedAnims;
|
static CStoredDetailedAnimationState *&pPedAnims;
|
||||||
static uint8 *&pPickups;
|
static uint8 *&pPickups;
|
||||||
static uint8 *&pReferences;
|
static uint8 *&pReferences;
|
||||||
static uint8 (&BufferStatus)[8];
|
static uint8 (&BufferStatus)[NUM_REPLAYBUFFERS];
|
||||||
static uint8 (&Buffers)[8][100000];
|
static uint8 (&Buffers)[NUM_REPLAYBUFFERS][REPLAYBUFFERSIZE];
|
||||||
static bool &bPlayingBackFromFile;
|
static bool &bPlayingBackFromFile;
|
||||||
static bool &bReplayEnabled;
|
static bool &bReplayEnabled;
|
||||||
static uint32 &SlowMotion;
|
static uint32 &SlowMotion;
|
||||||
@ -274,6 +296,8 @@ private:
|
|||||||
static void RetrievePedAnimation(CPed *ped, CStoredAnimationState *state);
|
static void RetrievePedAnimation(CPed *ped, CStoredAnimationState *state);
|
||||||
static void RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state);
|
static void RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state);
|
||||||
static void PlaybackThisFrame(void);
|
static void PlaybackThisFrame(void);
|
||||||
|
static void TriggerPlaybackLastCoupleOfSeconds(uint32, uint8, float, float, float, uint32);
|
||||||
|
static bool FastForwardToTime(uint32);
|
||||||
static void StoreCarUpdate(CVehicle *vehicle, int id);
|
static void StoreCarUpdate(CVehicle *vehicle, int id);
|
||||||
static void ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer);
|
static void ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer);
|
||||||
static bool PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer);
|
static bool PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer);
|
||||||
|
@ -8106,6 +8106,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
|
|||||||
if (model != -1)
|
if (model != -1)
|
||||||
break;
|
break;
|
||||||
model = CStreaming::ms_vehiclesLoaded[index];
|
model = CStreaming::ms_vehiclesLoaded[index];
|
||||||
|
if (model == -1)
|
||||||
|
continue;
|
||||||
// desperatly want to believe this was inlined :|
|
// desperatly want to believe this was inlined :|
|
||||||
CBaseModelInfo* pInfo = CModelInfo::GetModelInfo(model);
|
CBaseModelInfo* pInfo = CModelInfo::GetModelInfo(model);
|
||||||
assert(pInfo->m_type == MITYPE_VEHICLE);
|
assert(pInfo->m_type == MITYPE_VEHICLE);
|
||||||
|
@ -168,6 +168,10 @@ enum Config {
|
|||||||
#define USE_MEASUREMENTS_IN_METERS // makes game use meters instead of feet in script
|
#define USE_MEASUREMENTS_IN_METERS // makes game use meters instead of feet in script
|
||||||
#define USE_PRECISE_MEASUREMENT_CONVERTION // makes game convert feet to meeters more precisely
|
#define USE_PRECISE_MEASUREMENT_CONVERTION // makes game convert feet to meeters more precisely
|
||||||
|
|
||||||
|
// Replay
|
||||||
|
//#define DONT_FIX_REPLAY_BUGS // keeps various bugs in CReplay, some of which are fairly cool!
|
||||||
|
//#define USE_BETA_REPLAY_MODE // adds another replay mode, a few seconds slomo (caution: buggy!)
|
||||||
|
|
||||||
// Vehicles
|
// Vehicles
|
||||||
#define EXPLODING_AIRTRAIN // can blow up jumbo jet with rocket launcher
|
#define EXPLODING_AIRTRAIN // can blow up jumbo jet with rocket launcher
|
||||||
//#define REMOVE_TREADABLE_PATHFIND
|
//#define REMOVE_TREADABLE_PATHFIND
|
||||||
|
Loading…
Reference in New Issue
Block a user