|
@@ -43,7 +43,7 @@ static const StringID _endgame_perf_titl
|
|
|
|
|
|
StringID EndGameGetPerformanceTitleFromValue(uint value)
|
|
|
{
|
|
|
value = minu(value / 64, lengthof(_endgame_perf_titles) - 1);
|
|
|
value = std::min<uint>(value / 64, lengthof(_endgame_perf_titles) - 1);
|
|
|
|
|
|
return _endgame_perf_titles[value];
|
|
|
}
|
|
@@ -132,7 +132,7 @@ void SaveToHighScore()
|
|
|
for (i = 0; i < SP_SAVED_HIGHSCORE_END; i++) {
|
|
|
for (hs = _highscore_table[i]; hs != endof(_highscore_table[i]); hs++) {
|
|
|
/* First character is a command character, so strlen will fail on that */
|
|
|
byte length = min(sizeof(hs->company), StrEmpty(hs->company) ? 0 : (int)strlen(&hs->company[1]) + 1);
|
|
|
byte length = std::min(sizeof(hs->company), StrEmpty(hs->company) ? 0 : strlen(&hs->company[1]) + 1);
|
|
|
|
|
|
if (fwrite(&length, sizeof(length), 1, fp) != 1 || // write away string length
|
|
|
fwrite(hs->company, length, 1, fp) > 1 || // Yes... could be 0 bytes too
|
|
@@ -163,7 +163,7 @@ void LoadFromHighScore()
|
|
|
for (hs = _highscore_table[i]; hs != endof(_highscore_table[i]); hs++) {
|
|
|
byte length;
|
|
|
if (fread(&length, sizeof(length), 1, fp) != 1 ||
|
|
|
fread(hs->company, min<int>(lengthof(hs->company), length), 1, fp) > 1 || // Yes... could be 0 bytes too
|
|
|
fread(hs->company, std::min<int>(lengthof(hs->company), length), 1, fp) > 1 || // Yes... could be 0 bytes too
|
|
|
fread(&hs->score, sizeof(hs->score), 1, fp) != 1 ||
|
|
|
fseek(fp, 2, SEEK_CUR) == -1) { // XXX - placeholder for hs->title, not saved anymore; compatibility
|
|
|
DEBUG(misc, 1, "Highscore corrupted");
|