Skip to content

Commit

Permalink
Removed the separate tour stop counter
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Oct 16, 2024
1 parent 8e3d1ed commit c2d8ef3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/common/GameValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ void CGameValues::init()
matchtype = MatchType::SingleGame;
tourindex = 0;
tourstopcurrent = 0;
tourstoptotal = 0;
worldindex = 0;
teamcollision = TeamCollisionStyle::Off;
screencrunch = true;
Expand Down
1 change: 0 additions & 1 deletion src/common/GameValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ class CGameValues : public CGameConfig

short tourindex;
short tourstopcurrent;
short tourstoptotal;
std::vector<TourStop*> tourstops;

short worldindex;
Expand Down
7 changes: 3 additions & 4 deletions src/common/WorldTourStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,12 @@ TourStop ParseTourStopLine(char* buffer, const Version& version, bool fIsWorld)
strncpy(ts.szName, pszTemp, 127);
ts.szName[127] = 0;
} else {
sprintf(ts.szName, "Tour Stop %d", game_values.tourstoptotal + 1);
sprintf(ts.szName, "Tour Stop %d", game_values.tourstops.size() + 1);
}
} else {
ts.iPoints = 1;
ts.iBonusType = 0;
sprintf(ts.szName, "Tour Stop %d", game_values.tourstoptotal + 1);
sprintf(ts.szName, "Tour Stop %d", game_values.tourstops.size() + 1);
}

if (version >= Version {1, 8, 0, 0}) {
Expand All @@ -640,7 +640,7 @@ TourStop ParseTourStopLine(char* buffer, const Version& version, bool fIsWorld)
strncpy(ts.szName, pszTemp, 127);
ts.szName[127] = 0;
} else {
sprintf(ts.szName, "Bonus House %d", game_values.tourstoptotal + 1);
sprintf(ts.szName, "Bonus House %d", game_values.tourstops.size() + 1);
}

pszTemp = strtok(NULL, ",\n");
Expand Down Expand Up @@ -789,7 +789,6 @@ std::string WriteTourStopLine(const TourStop& ts, bool fIsWorld)
void ResetTourStops()
{
game_values.tourstopcurrent = 0;
game_values.tourstoptotal = 0;

// added to prevent 'vector iterators incompatible' exception
if (!game_values.tourstops.empty())
Expand Down
2 changes: 1 addition & 1 deletion src/smw/GSGameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ void UpdateScoreBoard()
}
}

if (++game_values.tourstopcurrent >= game_values.tourstoptotal) {
if (++game_values.tourstopcurrent >= game_values.tourstops.size()) {
//Calculate Tour Winner by counting up 1st, 2nd, 3rd, and 4th place wins

short iWinningTeam = -2; //Set winning team to -2 to signify a tie between teams
Expand Down
14 changes: 6 additions & 8 deletions src/smw/GSMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void MenuState::onEnterState()
} else if (game_values.matchtype == MatchType::Tour) {
mTournamentScoreboardMenu->miTournamentScoreboard->RefreshTourScores();

if (game_values.tourstopcurrent < game_values.tourstoptotal)
if (game_values.tourstopcurrent < game_values.tourstops.size())
mTourStopMenu->miTourStop->Refresh(game_values.tourstopcurrent);
} else if (game_values.matchtype == MatchType::Tournament) {
mTournamentScoreboardMenu->miTournamentScoreboard->StopSwirl();
Expand Down Expand Up @@ -709,7 +709,7 @@ void MenuState::update()
iDisplayErrorTimer = 120;
fErrorReadingTourFile = true;
} else {
mTournamentScoreboardMenu->miTournamentScoreboard->CreateScoreboard(score_cnt, game_values.tourstoptotal, &rm->spr_tour_markers);
mTournamentScoreboardMenu->miTournamentScoreboard->CreateScoreboard(score_cnt, game_values.tourstops.size(), &rm->spr_tour_markers);
}
} else if (game_values.matchtype == MatchType::Tournament) {
printf(" Match type: Tournament\n");
Expand Down Expand Up @@ -1481,7 +1481,7 @@ bool MenuState::ReadTourFile()
char buffer[256];
bool fReadVersion = false;
Version version;
while (fgets(buffer, 256, fp) && game_values.tourstoptotal < 10) {
while (fgets(buffer, 256, fp) && game_values.tourstops.size() < 10) {
if (strchr(ignorable_leads, buffer[0]))
continue;

Expand Down Expand Up @@ -1509,22 +1509,20 @@ bool MenuState::ReadTourFile()

TourStop* ts = new TourStop();
*ts = ParseTourStopLine(buffer, version, false);

game_values.tourstops.push_back(ts);
game_values.tourstoptotal++;
}

if (game_values.tourstoptotal != 0) {
if (game_values.tourstops.size() != 0) {
mTourStopMenu->miTourStop->Refresh(game_values.tourstopcurrent);

//For old tours, turn on the bonus wheel at the end
if (version.major == 1 && version.minor == 7 && version.patch == 0 && version.build <= 1)
game_values.tourstops[game_values.tourstoptotal - 1]->iBonusType = 1;
game_values.tourstops[game_values.tourstops.size() - 1]->iBonusType = 1;
}

fclose(fp);

return game_values.tourstoptotal != 0;
return game_values.tourstops.size() != 0;
}

void MenuState::StartGame()
Expand Down
2 changes: 1 addition & 1 deletion src/smw/ui/MI_TournamentScoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ void MI_TournamentScoreboard::RefreshTourScores()
miIconImages[iTeam][iGame]->setVisible(true);
}

for (short iGame = game_values.tourstopcurrent; iGame < game_values.tourstoptotal; iGame++) {
for (size_t iGame = game_values.tourstopcurrent; iGame < game_values.tourstops.size(); iGame++) {
miIconImages[iTeam][iGame]->setVisible(false);
}

Expand Down
7 changes: 3 additions & 4 deletions src/smw/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,10 @@ WorldMap::WorldMap(const std::string& path, short tilesize)
delete[] buffer;

game_values.tourstops.push_back(ts);
game_values.tourstoptotal++;

if (++iCurrentStage >= iNumStages) {
//Scan stage IDs and make sure we have a stage for each one
short iMaxStage = game_values.tourstoptotal + 5;
short iMaxStage = game_values.tourstops.size() + 5;
for (short iRow = 0; iRow < iHeight; iRow++) {
for (short iCol = 0; iCol < iWidth; iCol++) {
short iType = tiles[iCol][iRow].iType;
Expand Down Expand Up @@ -877,9 +876,9 @@ bool WorldMap::Save(const std::string& szPath) const
fprintf(file, "#Stage Type 0,Map,Mode,Goal,Points,Bonus List(Max 10),Name,End World, then mode settings (see sample tour file for details)\n");
fprintf(file, "#Stage Type 1,Bonus House Name,Sequential/Random Order,Display Text,Powerup List(Max 5)\n");

fprintf(file, "%d\n", game_values.tourstoptotal);
fprintf(file, "%d\n", game_values.tourstops.size());

for (short iStage = 0; iStage < game_values.tourstoptotal; iStage++) {
for (short iStage = 0; iStage < game_values.tourstops.size(); iStage++) {
std::string line = WriteTourStopLine(*game_values.tourstops[iStage], true);
fprintf(file, "%s", line.c_str());
}
Expand Down
6 changes: 2 additions & 4 deletions src/worldeditor/worldeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3828,18 +3828,17 @@ void NewStage(short * iEditStage)
ts->iBonusType = 0;
ts->iNumBonuses = 0;

sprintf(ts->szName, "Tour Stop %d", game_values.tourstoptotal + 1);
sprintf(ts->szName, "Tour Stop %d", game_values.tourstops.size() + 1);

ts->fEndStage = false;

//Copy in default values first
memcpy(&ts->gmsSettings, &game_values.gamemodemenusettings, sizeof(GameModeSettings));

game_values.tourstops.push_back(ts);
game_values.tourstoptotal++;
g_worldmap.iNumStages++;

*iEditStage = game_values.tourstoptotal - 1;
*iEditStage = game_values.tourstops.size() - 1;
EditStage(*iEditStage);
}

Expand Down Expand Up @@ -4198,7 +4197,6 @@ int editor_stage()
delete (*itr);

game_values.tourstops.erase(itr);
game_values.tourstoptotal--;
g_worldmap.iNumStages--;

break;
Expand Down

0 comments on commit c2d8ef3

Please sign in to comment.