Skip to content

Commit

Permalink
fix skipselect loading prev savegame
Browse files Browse the repository at this point in the history
  • Loading branch information
White Dragon committed Feb 16, 2018
1 parent ec6fd10 commit c3aec09
Showing 1 changed file with 46 additions and 21 deletions.
67 changes: 46 additions & 21 deletions engine/openbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -34032,13 +34032,14 @@ int selectplayer(int *players, char *filename, int useSavedGame)
char argbuf[MAX_ARG_LEN + 1] = "";
s_set_entry *set = levelsets + current_set;
s_savelevel *save = savelevel + current_set;
int load_count = 0, saved_select_screen = 0;
int load_count = 0, saved_select_screen = 0;
int is_first_select = 1;

savelevelinfo();

selectScreen = 1;
kill_all();
if(allowselect_args[0] != 'a') reset_playable_list(1); // 'a' is the first char of allowselect, if there's 'a' then there is allowselect
if(!skipselect[0][0] && !set->noselect) reset_playable_list(1); // or (allowselect_args[0] != 'a') 'a' is the first char of allowselect, if there's 'a' then there is allowselect
memset(player, 0, sizeof(*player) * 4);

if(useSavedGame && save)
Expand All @@ -34056,6 +34057,15 @@ int selectplayer(int *players, char *filename, int useSavedGame)
for(i = 0; i < set->maxplayers; i++)
{
player[i].hasplayed = players[i];
}

for(i = 0; i < set->maxplayers; i++)
{
if (savelevel[current_set].pLives[i] > 0)
{
is_first_select = 0;
break;
}
}

if(filename && filename[0])
Expand Down Expand Up @@ -34123,8 +34133,12 @@ int selectplayer(int *players, char *filename, int useSavedGame)
}
}
else // without select.txt
{
defaultselect = 1;
{
if(is_first_select || (!skipselect[0][0] && !set->noselect)) // no select is skipselect without names
{
defaultselect = 1; // normal select or skipselect/noselect? 1 == normal select
}

if(!noshare)
{
credits = CONTINUES;
Expand All @@ -34138,30 +34152,40 @@ int selectplayer(int *players, char *filename, int useSavedGame)
}

if(skipselect[0][0] || set->noselect)
{
{
for(i = 0; i < set->maxplayers; i++)
{
if(!players[i])
{
continue;
}
strncpy(player[i].name, skipselect[i], MAX_NAME_LEN);
if(!creditscheat)
{
if(noshare)
{
--player[i].credits;
}
else
strncpy(player[i].name, skipselect[i], MAX_NAME_LEN);

if(defaultselect)
{
player[i].lives = PLAYER_LIVES;
if(!creditscheat)
{
--credits;
}
if(noshare)
{
--player[i].credits;
}
else
{
--credits;
}
}
}
/*if lives <= 0 then it means you start a new game and so.. take all lives a*/
if (player[i].lives <= 0) player[i].lives = PLAYER_LIVES;
else player[i].lives = savelevel[current_set].pLives[i]; /*used for skipselect*/
else
{
player[i].lives = savelevel[current_set].pLives[i];
player[i].score = savelevel[current_set].pScores[i];
if(noshare) player[i].credits = savelevel[current_set].pCredits[i];
else credits = savelevel[current_set].credits;
}
}
selectScreen = 0;
selectScreen = 0;

return 1;
}

Expand Down Expand Up @@ -34226,8 +34250,9 @@ int selectplayer(int *players, char *filename, int useSavedGame)
else
{
player[i].lives = savelevel[current_set].pLives[i];
player[i].credits = savelevel[current_set].pCredits[i];
player[i].score = savelevel[current_set].pScores[i];
player[i].score = savelevel[current_set].pScores[i];
if(noshare) player[i].credits = savelevel[current_set].pCredits[i];
else credits = savelevel[current_set].credits;
}
}
}
Expand Down

0 comments on commit c3aec09

Please sign in to comment.