1
0
Fork 0

Fix ad020759: Update town data loader for FileHandle change. (#12942)

A non-conflicting merge conflict...
pull/12943/head
Peter Nelson 2024-09-16 17:52:24 +01:00 committed by GitHub
parent 74910d3d14
commit 4be3361aa3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -380,16 +380,16 @@ void LoadTownData()
{ {
/* Load the JSON file as a string initially. We'll parse it soon. */ /* Load the JSON file as a string initially. We'll parse it soon. */
size_t filesize; size_t filesize;
FILE *f = FioFOpenFile(_file_to_saveload.name, "rb", HEIGHTMAP_DIR, &filesize); auto f = FioFOpenFile(_file_to_saveload.name, "rb", HEIGHTMAP_DIR, &filesize);
if (f == nullptr) { if (!f.has_value()) {
ShowErrorMessage(STR_TOWN_DATA_ERROR_LOAD_FAILED, STR_TOWN_DATA_ERROR_JSON_FORMATTED_INCORRECTLY, WL_ERROR); ShowErrorMessage(STR_TOWN_DATA_ERROR_LOAD_FAILED, STR_TOWN_DATA_ERROR_JSON_FORMATTED_INCORRECTLY, WL_ERROR);
return; return;
} }
std::string text(filesize, '\0'); std::string text(filesize, '\0');
size_t len = fread(text.data(), filesize, 1, f); size_t len = fread(text.data(), filesize, 1, *f);
FioFCloseFile(f); f.reset();
if (len != 1) { if (len != 1) {
ShowErrorMessage(STR_TOWN_DATA_ERROR_LOAD_FAILED, STR_TOWN_DATA_ERROR_JSON_FORMATTED_INCORRECTLY, WL_ERROR); ShowErrorMessage(STR_TOWN_DATA_ERROR_LOAD_FAILED, STR_TOWN_DATA_ERROR_JSON_FORMATTED_INCORRECTLY, WL_ERROR);
return; return;