Skip to content

Commit

Permalink
Do not let in-game menu saves mess with challenge score saving
Browse files Browse the repository at this point in the history
Lets use something that won't magically change if the in-game save menu was used, preventing score tips from being saved properly.
  • Loading branch information
KJeff01 committed Apr 25, 2024
1 parent 6ce9df1 commit af14f62
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/challenge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,30 @@ const char* currentChallengeName()
return nullptr;
}

// quite the hack, game name is stored in global sRequestResult
void updateChallenge(bool gameWon)
{
char *fStr;
std::string fullName = challengeFileName.toStdString();
int seconds = 0, newtime = (gameTime - mission.startTime) / GAME_TICKS_PER_SEC;
bool victory = false;
WzConfig scores(CHALLENGE_SCORES, WzConfig::ReadAndWrite);
ASSERT_OR_RETURN(, strlen(sRequestResult) > 0, "Empty sRequestResult");
ASSERT_OR_RETURN(, fullName.length() > 0, "Empty challengeFileName");

fStr = strrchr(sRequestResult, '/');
if (fStr != nullptr)
std::string fName;
size_t pos = fullName.find("/");
if (pos != std::string::npos)
{
fStr++; // skip slash
fName = fullName.substr(pos + 1);
}
else
{
fStr = sRequestResult;
fName = fullName; // Likely if challengeFileName no longer has the path included in it.
}
if (*fStr == '\0')
if (fName.empty())
{
debug(LOG_ERROR, "Bad path to challenge file (%s)", sRequestResult);
debug(LOG_ERROR, "Bad path to challenge file (%s)", fName.c_str());
return;
}
WzString sPath = fStr;
WzString sPath = WzString::fromUtf8(fName);
// remove .json
if (sPath.endsWith(".json"))
{
Expand Down

0 comments on commit af14f62

Please sign in to comment.