Merge pull request #1266 from Nick007J/miami

Mission replay
This commit is contained in:
Nikolay 2021-08-07 18:47:28 +03:00 committed by GitHub
commit e947081622
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 2061 additions and 1755 deletions

View file

@ -102,6 +102,15 @@ CGameLogic::Update()
CVector vecRestartPos;
float fRestartFloat;
#ifdef MISSION_REPLAY
// what a place to check!
if (gbTryingPorn4Again) {
CRunningScript* pScript = CTheScripts::pActiveScripts;
if (pScript && !CGeneral::faststricmp(pScript->m_abScriptName, "porno4"))
gbTryingPorn4Again = false;
}
#endif
if (CCutsceneMgr::IsCutsceneProcessing()) return;
UpdateShortCut();

File diff suppressed because it is too large Load diff

View file

@ -47,6 +47,10 @@ void FlushLog();
#define KEY_LENGTH_IN_SCRIPT (8)
#ifdef USE_DEBUG_SCRIPT_LOADER
extern const char* scriptfile;
#endif
//#define GTA_SCRIPT_COLLECTIVE
struct intro_script_rectangle
@ -372,6 +376,13 @@ public:
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
int CollectParameterForDebug(char* buf, bool& var);
void GetStoredParameterForDebug(char* buf);
void LogOnStartProcessing();
void LogBeforeProcessingCommand(int32 command);
void LogAfterProcessingCommand(int32 command);
static char commandInfo[];
static uint32 storedIp;
#endif
float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
@ -575,13 +586,24 @@ public:
static void SetObjectiveForAllPedsInCollective(int, eObjective);
#endif
#ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT
static bool MissionSupportsMissionReplay(int index)
{
return index >= 3 && index <= 35 || index >= 51 && index <= 65 || index >= 67 && index <= 74 || index >= 83 && index <= 87;
}
#endif
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
static void LogAfterScriptInitializing();
static void LogBeforeScriptProcessing();
static void LogAfterScriptProcessing();
#endif
};
#ifdef USE_DEBUG_SCRIPT_LOADER
extern int scriptToLoad;
#endif
#ifdef MISSION_REPLAY
static_assert(false, "Mission replay is not supported");
extern int AllowMissionReplay;
extern uint32 WaitForMissionActivate;
extern uint32 WaitForSave;
@ -592,6 +614,11 @@ extern bool gbTryingPorn4Again;
extern int IsInAmmunation;
extern int MissionSkipLevel;
#ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT
extern bool UsingMobileScript;
extern bool AlreadySavedGame;
#endif
uint32 AddExtraDeathDelay();
void RetryMission(int, int);
#endif

View file

@ -149,7 +149,12 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
}
case COMMAND_ADD_EXPLOSION:
CollectParameters(&m_nIp, 4);
CExplosion::AddExplosion(nil, nil, (eExplosionType)ScriptParams[3], *(CVector*)&ScriptParams[0], 0, true);
#ifdef SIMPLER_MISSIONS
if (!CGeneral::faststricmp(m_abScriptName, "hait2"))
CExplosion::AddExplosion(nil, nil, (eExplosionType)ScriptParams[3], *(CVector*)&ScriptParams[0], 0, true, 11.25f);
else
#endif
CExplosion::AddExplosion(nil, nil, (eExplosionType)ScriptParams[3], *(CVector*)&ScriptParams[0], 0, true);
return 0;
case COMMAND_IS_CAR_UPRIGHT:

View file

@ -1379,8 +1379,10 @@ void CRunningScript::DoDeatharrestCheck()
if (!pPlayer->IsRestartingAfterDeath() && !pPlayer->IsRestartingAfterArrest())
return;
#ifdef MISSION_REPLAY
if (AllowMissionReplay != 0)
if (AllowMissionReplay != 7 && AllowMissionReplay != 0)
return;
if (AllowMissionReplay == 7)
AllowMissionReplay = 0;
if (CanAllowMissionReplay())
AllowMissionReplay = 1;
#endif

View file

@ -125,10 +125,6 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
case COMMAND_MAKE_PLAYER_SAFE_FOR_CUTSCENE:
{
CollectParameters(&m_nIp, 1);
#ifdef MISSION_REPLAY
AllowMissionReplay = 0;
SaveGameForPause(3);
#endif
CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
CPad::GetPad(ScriptParams[0])->SetDisablePlayerControls(PLAYERCONTROL_CUTSCENE);
pPlayerInfo->MakePlayerSafe(true);
@ -372,14 +368,28 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
return 0;
case COMMAND_LOAD_AND_LAUNCH_MISSION_INTERNAL:
{
#ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT
uint32 oldIp = m_nIp;
#endif
CollectParameters(&m_nIp, 1);
if (CTheScripts::NumberOfExclusiveMissionScripts > 0 && ScriptParams[0] <= UINT16_MAX - 2)
return 0;
#ifdef MISSION_REPLAY
missionRetryScriptIndex = ScriptParams[0];
if (missionRetryScriptIndex == 19)
CStats::LastMissionPassedName[0] = '\0';
#ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT
if (!UsingMobileScript && CTheScripts::MissionSupportsMissionReplay(missionRetryScriptIndex)){
if (!AlreadySavedGame) {
m_nIp = oldIp - 2;
SaveGameForPause(4);
AlreadySavedGame = true;
return 0;
}
else {
AlreadySavedGame = false;
}
}
#endif
#endif
CTimer::Suspend();
int offset = CTheScripts::MultiScriptArray[ScriptParams[0]];
@ -1075,6 +1085,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
}
case COMMAND_FAIL_CURRENT_MISSION:
CTheScripts::FailCurrentMission = 2;
#ifdef MISSION_REPLAY
MissionSkipLevel = 0;
#endif
return 0;
case COMMAND_GET_CLOSEST_OBJECT_OF_TYPE:
{

View file

@ -576,6 +576,9 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
return 0;
case COMMAND_DO_SAVE_GAME:
CollectParameters(&m_nIp, 1);
#ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT
UsingMobileScript = true;
#endif
#ifdef MISSION_REPLAY
SaveGameForPause(ScriptParams[0]);
#endif

1763
src/control/ScriptDebug.cpp Normal file

File diff suppressed because it is too large Load diff

View file

@ -572,7 +572,11 @@ CMenuManager::Initialise(void)
m_fMapCenterX = MENU_X_LEFT_ALIGNED(320.0f);
m_fMapCenterY = MENU_Y(225.0f);
CPad::StopPadsShaking();
#ifdef MISSION_REPLAY
if (!m_OnlySaveMenu && m_nCurrScreen != MENUPAGE_MISSION_RETRY)
#else
if (!m_OnlySaveMenu)
#endif
m_nCurrScreen = MENUPAGE_NONE;
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_STARTING, 0);
@ -4769,6 +4773,18 @@ CMenuManager::ProcessUserInput(uint8 goDown, uint8 goUp, uint8 optionSelected, u
OutputDebugString("STARTED PLAYING FRONTEND AUDIO TRACK");
}
break;
#ifdef MISSION_REPLAY
case MENUACTION_REJECT_RETRY:
doingMissionRetry = false;
AllowMissionReplay = 0;
RequestFrontEndShutDown();
break;
case MENUACTION_UNK114:
doingMissionRetry = false;
RequestFrontEndShutDown();
RetryMission(2, 0);
return;
#endif
case MENUACTION_SAVEGAME:
{
int saveSlot = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_SaveSlot;
@ -5413,6 +5429,19 @@ CMenuManager::ProcessFileActions()
{
switch (m_nCurrScreen) {
case MENUPAGE_LOADING_IN_PROGRESS:
#ifdef MISSION_REPLAY
if (MissionSkipLevel) {
if (gGameState != GS_PLAYING_GAME)
DoSettingsBeforeStartingAGame();
RequestFrontEndShutDown();
break;
}
if (doingMissionRetry) {
RetryMission(2, 0);
m_nCurrSaveSlot = SLOT_COUNT;
doingMissionRetry = false;
}
#endif
if (CheckSlotDataValid(m_nCurrSaveSlot)) {
#ifdef USE_DEBUG_SCRIPT_LOADER
scriptToLoad = 0;

View file

@ -221,8 +221,11 @@ enum eMenuScreen
#ifdef DETECT_JOYSTICK_MENU
MENUPAGE_DETECT_JOYSTICK,
#endif
#endif
#ifdef MISSION_REPLAY
MENUPAGE_MISSION_RETRY,
#endif
MENUPAGE_OUTRO, // Originally 34, but CFO needs last screen to be empty to count number of menu pages
MENUPAGES
};
@ -292,6 +295,10 @@ enum eMenuAction
MENUACTION_CTRLVIBRATION,
MENUACTION_CTRLCONFIG,
#endif
#ifdef MISSION_REPLAY
MENUACTION_REJECT_RETRY,
MENUACTION_UNK114
#endif
};
enum eCheckHover

View file

@ -329,6 +329,16 @@ CMenuScreen aScreens[] = {
},
#endif
#ifdef MISSION_REPLAY
// MENUPAGE_MISSION_RETRY = 57 on mobile
{ "M_FAIL", MENUPAGE_DISABLED, 0,
MENUACTION_LABEL, "FESZ_RM", SAVESLOT_NONE, MENUPAGE_NONE, 0, 0, 0,
MENUACTION_CHANGEMENU, "FEM_YES", SAVESLOT_NONE, MENUPAGE_LOADING_IN_PROGRESS, 320, 200, MENUALIGN_CENTER,
MENUACTION_REJECT_RETRY, "FEM_NO", SAVESLOT_NONE, MENUPAGE_NONE, 320, 225, MENUALIGN_CENTER,
},
#endif
// MENUPAGE_OUTRO - Originally 34
{ "", 0, 0, },
};

View file

@ -784,6 +784,17 @@ CMenuScreenCustom aScreens[] = {
},
#endif
#ifdef MISSION_REPLAY
// MENUPAGE_MISSION_RETRY = 57 on mobile
{ "M_FAIL", MENUPAGE_DISABLED, nil, nil,
MENUACTION_LABEL, "FESZ_RM", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, 0, 0, 0,
MENUACTION_CHANGEMENU, "FEM_YES", { nil, SAVESLOT_NONE, MENUPAGE_LOADING_IN_PROGRESS }, 320, 200, MENUALIGN_CENTER,
MENUACTION_REJECT_RETRY, "FEM_NO", { nil, SAVESLOT_NONE, MENUPAGE_NONE }, 320, 225, MENUALIGN_CENTER,
},
#endif
// MENUPAGE_OUTRO = 34
{ "", 0, nil, nil, },
};

View file

@ -269,7 +269,7 @@ INITSAVEBUF
if (pVehicle->IsBoat() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving))
++nNumBoats;
if (pVehicle->IsBike() && (pVehicle->VehicleCreatedBy == MISSION_VEHICLE || bForceSaving))
++nNumBoats;
++nNumBikes;
#else
if (!pVehicle->pDriver && !bHasPassenger) {
if (pVehicle->IsCar() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE)
@ -277,7 +277,7 @@ INITSAVEBUF
if (pVehicle->IsBoat() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE)
++nNumBoats;
if (pVehicle->IsBike() && pVehicle->VehicleCreatedBy == MISSION_VEHICLE)
++nNumBoats;
++nNumBikes;
#endif
}
}

View file

@ -182,6 +182,9 @@ enum Config {
# define PC_MENU
# define PC_WATER
#elif defined GTA_XBOX
#elif defined GTA_MOBILE
# define MISSION_REPLAY
# define SIMPLER_MISSIONS
#endif
// This is enabled for all released games.
@ -376,14 +379,15 @@ enum Config {
#define USE_PRECISE_MEASUREMENT_CONVERTION // makes game convert feet to meeters more precisely
#define SUPPORT_JAPANESE_SCRIPT
//#define SUPPORT_XBOX_SCRIPT
//#define SUPPORT_MOBILE_SCRIPT
#define SUPPORT_MOBILE_SCRIPT
#if (defined SUPPORT_XBOX_SCRIPT && defined SUPPORT_MOBILE_SCRIPT)
static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually exclusive");
#endif
#ifdef PC_MENU
//#define MISSION_REPLAY // mobile feature
#define MISSION_REPLAY // mobile feature
//#define SIMPLER_MISSIONS // apply simplifications from mobile
#define USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT
#endif
//#define SIMPLIER_MISSIONS // apply simplifications from mobile
#define USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
#define SCRIPT_LOG_FILE_LEVEL 0 // 0 == no log, 1 == overwrite every frame, 2 == full log
@ -400,6 +404,10 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually
#undef USE_BASIC_SCRIPT_DEBUG_OUTPUT
#endif
#ifndef MISSION_REPLAY
#undef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT
#endif
// 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!)

View file

@ -1176,13 +1176,20 @@ void DisplaySaveResult(int unk, char* name)
bool SaveGameForPause(int type)
{
if (AllowMissionReplay != 0 || type != 3 && WaitForSave > CTimer::GetTimeInMilliseconds())
if (AllowMissionReplay != 0 && AllowMissionReplay != 7) {
debug("SaveGameForPause failed during AllowMissionReplay %d", AllowMissionReplay);
return false;
}
if (type != 3 && WaitForSave > CTimer::GetTimeInMilliseconds()) {
debug("SaveGameForPause failed WaitForSave");
return false;
}
WaitForSave = 0;
if (gGameState != GS_PLAYING_GAME || CTheScripts::IsPlayerOnAMission() || CStats::LastMissionPassedName[0] == '\0') {
if (gGameState != GS_PLAYING_GAME || (CTheScripts::bAlreadyRunningAMissionScript && type != 5)) {
DisplaySaveResult(3, CStats::LastMissionPassedName);
return false;
}
debug("SaveGameForPause ******************************** %s doSave %d", CStats::LastMissionPassedName, !CTheScripts::bAlreadyRunningAMissionScript);
IsQuickSave = type;
MissionStartTime = 0;
int res = PcSaveHelper.SaveSlot(PAUSE_SAVE_SLOT);

View file

@ -102,7 +102,11 @@ CExplosion::GetExplosionPosition(uint8 id)
}
bool
#ifdef SIMPLER_MISSIONS
CExplosion::AddExplosion(CEntity* explodingEntity, CEntity* culprit, eExplosionType type, const CVector& pos, uint32 lifetime, bool makeSound, float radius)
#else
CExplosion::AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32 lifetime, bool makeSound)
#endif
{
CVector pPosn;
CVector posGround;
@ -150,7 +154,11 @@ CExplosion::AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionT
switch (type)
{
case EXPLOSION_GRENADE:
#ifdef SIMPLER_MISSIONS
explosion.m_fRadius = (radius == -1.0f ? 9.0f : radius);
#else
explosion.m_fRadius = 9.0f;
#endif
explosion.m_fPower = 300.0f;
explosion.m_fStopTime = lifetime + CTimer::GetTimeInMilliseconds() + 750;
explosion.m_fPropagationRate = 0.5f;

View file

@ -37,7 +37,11 @@ class CExplosion
float m_fPower;
float m_fZshift;
public:
static bool AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32 lifetime, bool makeSound = true); //done(new parametr in android ver is fix for one mission)
#ifdef SIMPLER_MISSIONS
static bool AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32 lifetime, bool makeSound = true, float radius = -1.0f);
#else
static bool AddExplosion(CEntity* explodingEntity, CEntity* culprit, eExplosionType type, const CVector& pos, uint32 lifetime, bool makeSound = true);
#endif
static void ClearAllExplosions(); //done
static bool DoesExplosionMakeSound(uint8 id); //done
static int8 GetExplosionActiveCounter(uint8 id); //done