MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SortSaveGameList

Function SortSaveGameList

src/fios_gui.cpp:302–321  ·  view source on GitHub ↗

* Sort the collected list save games prior to displaying it in the save/load gui. * @param[in,out] file_list List of save game files found in the directory. */

Source from the content-addressed store, hash-verified

300 * @param[in,out] file_list List of save game files found in the directory.
301 */
302static void SortSaveGameList(FileList &file_list)
303{
304 size_t sort_start = 0;
305 size_t sort_end = 0;
306
307 /* Directories are always above the files (FIOS_TYPE_DIR)
308 * Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
309 * Only sort savegames/scenarios, not directories
310 */
311 for (const auto &item : file_list) {
312 switch (item.type.detailed) {
313 case DFT_FIOS_DIR: sort_start++; break;
314 case DFT_FIOS_PARENT: sort_start++; break;
315 case DFT_FIOS_DRIVE: sort_end++; break;
316 default: break;
317 }
318 }
319
320 std::sort(file_list.begin() + sort_start, file_list.end() - sort_end);
321}
322
323struct SaveLoadWindow : public Window {
324private:

Callers 1

OnPaintMethod · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected