Skip to content

Commit

Permalink
Mission Randomizer: Fix Prologue softlock at end
Browse files Browse the repository at this point in the history
* It ends with the current player model set to 0x91 (invalid and such)
  despite the player actually being Franklin. Added an additional
  check for this situation.
  • Loading branch information
Parik27 committed May 26, 2021
1 parent f04ddf1 commit d913394
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/mission/missions_Data.hh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public:

MissionRandomizer_Data (FILE *file)
{
if (!file)
return;

char line[1024] = {0};
while (fgets (line, 1024, file))
{
Expand Down
34 changes: 32 additions & 2 deletions src/mission/missions_PlayerSwitch.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,37 @@ private:

Context m_Context;

/*******************************************************/
bool
CheckCurrentPlayer (ePlayerIndex index)
{
if (*MissionRandomizer_GlobalsManager::PP_CURRENT_PED == int (index))
return true;

if (*MissionRandomizer_GlobalsManager::PP_CURRENT_PED
== int (eCharacter::_))
{
uint32_t hash = 0;
switch (index)
{
case ePlayerIndex::PLAYER_MICHAEL:
hash = "player_zero"_joaat;
break;
case ePlayerIndex::PLAYER_FRANKLIN:
hash = "player_one"_joaat;
break;
case ePlayerIndex::PLAYER_TREVOR:
hash = "player_two"_joaat;
break;
default: return false;
}

return "IS_PED_MODEL"_n("PLAYER_PED_ID"_n(), hash);
}

return false;
}

/*******************************************************/
bool
SetCurrentPlayer (ePlayerIndex index)
Expand All @@ -69,8 +100,7 @@ private:
if (!YscFunctions::SetCurrentPlayer (index, 1))
return true;

bool success
= *MissionRandomizer_GlobalsManager::PP_CURRENT_PED == int (index);
bool success = CheckCurrentPlayer (index);

if (!success)
{
Expand Down

0 comments on commit d913394

Please sign in to comment.