55 */
66#include " pfile.h"
77
8+ #include < algorithm>
89#include < cstdint>
910#include < string>
1011#include < string_view>
@@ -65,6 +66,19 @@ namespace {
6566/* * List of character names for the character selection screen. */
6667char hero_names[MAX_CHARACTERS][PlayerNameLength];
6768
69+ #ifdef __DREAMCAST__
70+ constexpr uint32_t DreamcastMaxSaveSlots = 8 ;
71+ #endif
72+
73+ uint32_t GetPlatformSaveSlotCount ()
74+ {
75+ #ifdef __DREAMCAST__
76+ return std::min<uint32_t >(MAX_CHARACTERS, DreamcastMaxSaveSlots);
77+ #else
78+ return MAX_CHARACTERS;
79+ #endif
80+ }
81+
6882#ifdef __DREAMCAST__
6983bool IsRamSavePath (std::string_view path)
7084{
@@ -890,7 +904,7 @@ bool pfile_ui_set_hero_infos(bool (*uiAddHeroInfo)(_uiheroinfo *))
890904{
891905 memset (hero_names, 0 , sizeof (hero_names));
892906
893- for (uint32_t i = 0 ; i < MAX_CHARACTERS ; i++) {
907+ for (uint32_t i = 0 ; i < GetPlatformSaveSlotCount () ; i++) {
894908 std::optional<SaveReader> archive = OpenSaveArchive (i);
895909 if (archive) {
896910 PlayerPack pkplr;
@@ -905,9 +919,11 @@ bool pfile_ui_set_hero_infos(bool (*uiAddHeroInfo)(_uiheroinfo *))
905919 Player &player = Players[0 ];
906920
907921 UnPackPlayer (pkplr, player);
922+ #ifndef __DREAMCAST__
908923 LoadHeroItems (player);
909924 RemoveAllInvalidItems (player);
910925 CalcPlrInv (player, false );
926+ #endif
911927
912928 Game2UiPlayer (player, &uihero, hasSaveGame);
913929 uiAddHeroInfo (&uihero);
@@ -930,7 +946,8 @@ void pfile_ui_set_class_stats(HeroClass playerClass, _uidefaultstats *classStats
930946uint32_t pfile_ui_get_first_unused_save_num ()
931947{
932948 uint32_t saveNum;
933- for (saveNum = 0 ; saveNum < MAX_CHARACTERS; saveNum++) {
949+ const uint32_t saveSlotCount = GetPlatformSaveSlotCount ();
950+ for (saveNum = 0 ; saveNum < saveSlotCount; saveNum++) {
934951 if (hero_names[saveNum][0 ] == ' \0 ' )
935952 break ;
936953 }
@@ -942,7 +959,7 @@ bool pfile_ui_save_create(_uiheroinfo *heroinfo)
942959 PlayerPack pkplr;
943960
944961 const uint32_t saveNum = heroinfo->saveNumber ;
945- if (saveNum >= MAX_CHARACTERS )
962+ if (saveNum >= GetPlatformSaveSlotCount () )
946963 return false ;
947964 heroinfo->saveNumber = saveNum;
948965
0 commit comments