mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix bugs
This commit is contained in:
parent
00c47b8a04
commit
f519bc6cad
|
@ -194,7 +194,7 @@ public:
|
|||
|
||||
bool TryRecordHighscore(const utf8 * scenarioFileName, money32 companyValue, const utf8 * name) override
|
||||
{
|
||||
const scenario_index_entry * scenario = GetByFilename(scenarioFileName);
|
||||
scenario_index_entry * scenario = GetByFilename(scenarioFileName);
|
||||
if (scenario != nullptr)
|
||||
{
|
||||
// Check if record company value has been broken or the highscore is the same but no name is registered
|
||||
|
@ -205,20 +205,21 @@ public:
|
|||
if (highscore == nullptr)
|
||||
{
|
||||
highscore = InsertHighscore();
|
||||
scenario->highscore->timestamp = platform_get_datetime_now_utc();
|
||||
highscore->timestamp = platform_get_datetime_now_utc();
|
||||
scenario->highscore = highscore;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (highscore->name != nullptr)
|
||||
{
|
||||
scenario->highscore->timestamp = platform_get_datetime_now_utc();
|
||||
highscore->timestamp = platform_get_datetime_now_utc();
|
||||
}
|
||||
SafeFree(highscore->fileName);
|
||||
SafeFree(highscore->name);
|
||||
}
|
||||
scenario->highscore->fileName = String::Duplicate(Path::GetFileName(scenario->path));
|
||||
scenario->highscore->name = String::Duplicate(name);
|
||||
scenario->highscore->company_value = companyValue;
|
||||
highscore->fileName = String::Duplicate(Path::GetFileName(scenario->path));
|
||||
highscore->name = String::Duplicate(name);
|
||||
highscore->company_value = companyValue;
|
||||
SaveHighscores();
|
||||
return true;
|
||||
}
|
||||
|
@ -499,7 +500,7 @@ private:
|
|||
for (size_t i = 0; i < _highscores.size(); i++)
|
||||
{
|
||||
scenario_highscore_entry * highscore = _highscores[i];
|
||||
scenario_index_entry * scenerio = GetByPath(highscore->fileName);
|
||||
scenario_index_entry * scenerio = GetByFilename(highscore->fileName);
|
||||
if (scenerio != nullptr)
|
||||
{
|
||||
scenerio->highscore = highscore;
|
||||
|
|
|
@ -177,8 +177,13 @@ namespace String
|
|||
|
||||
utf8 * Duplicate(const utf8 * src)
|
||||
{
|
||||
size_t srcSize = SizeOf(src);
|
||||
return Memory::DuplicateArray(src, srcSize + 1);
|
||||
utf8 * result = nullptr;
|
||||
if (src != nullptr)
|
||||
{
|
||||
size_t srcSize = SizeOf(src);
|
||||
result = Memory::DuplicateArray(src, srcSize + 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
utf8 * DiscardUse(utf8 * * ptr, utf8 * replacement)
|
||||
|
|
|
@ -353,7 +353,7 @@ void scenario_success()
|
|||
*/
|
||||
void scenario_success_submit_name(const char *name)
|
||||
{
|
||||
if (scenario_repository_try_record_highscore(_scenarioFileName, gScenarioCompanyValueRecord, NULL))
|
||||
if (scenario_repository_try_record_highscore(_scenarioFileName, gScenarioCompanyValueRecord, name))
|
||||
{
|
||||
safe_strcpy(gScenarioCompletedBy, name, 32);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue