Browse Source

🐛 Fix loading chosen hero

pull/1652/head
Anders Jenbo 5 years ago
parent
commit
8fa0612433
  1. 2
      Source/mainmenu.cpp
  2. 3
      Source/multi.cpp
  3. 12
      Source/pfile.cpp
  4. 2
      Source/pfile.h

2
Source/mainmenu.cpp

@ -103,6 +103,8 @@ bool mainmenu_select_hero_dialog(GameData *gameData)
return false; return false;
} }
pfile_read_player_from_save(gszHero, myplr);
return true; return true;
} }

3
Source/multi.cpp

@ -10,6 +10,7 @@
#include "DiabloUI/diabloui.h" #include "DiabloUI/diabloui.h"
#include "diablo.h" #include "diablo.h"
#include "dthread.h" #include "dthread.h"
#include "mainmenu.h"
#include "nthread.h" #include "nthread.h"
#include "options.h" #include "options.h"
#include "pfile.h" #include "pfile.h"
@ -827,7 +828,7 @@ bool multi_init_multi(GameData *gameData)
myplr = playerId; myplr = playerId;
gbIsMultiplayer = true; gbIsMultiplayer = true;
pfile_read_player_from_save(); pfile_read_player_from_save(gszHero, myplr);
return true; return true;
} }

12
Source/pfile.cpp

@ -385,13 +385,13 @@ bool pfile_delete_save(_uiheroinfo *hero_info)
return true; return true;
} }
void pfile_read_player_from_save() void pfile_read_player_from_save(char name[16], int playerId)
{ {
HANDLE archive; HANDLE archive;
DWORD save_num; DWORD save_num;
PkPlayerStruct pkplr; PkPlayerStruct pkplr;
save_num = pfile_get_save_num_from_name(gszHero); save_num = pfile_get_save_num_from_name(name);
archive = pfile_open_save_archive(save_num); archive = pfile_open_save_archive(save_num);
if (archive == nullptr) if (archive == nullptr)
app_fatal("Unable to open archive"); app_fatal("Unable to open archive");
@ -404,11 +404,11 @@ void pfile_read_player_from_save()
pfile_SFileCloseArchive(&archive); pfile_SFileCloseArchive(&archive);
UnPackPlayer(&pkplr, myplr, false); UnPackPlayer(&pkplr, playerId, false);
LoadHeroItems(&plr[myplr]); LoadHeroItems(&plr[playerId]);
RemoveEmptyInventory(myplr); RemoveEmptyInventory(playerId);
CalcPlrInv(myplr, false); CalcPlrInv(playerId, false);
} }
bool LevelFileExists() bool LevelFileExists()

2
Source/pfile.h

@ -35,7 +35,7 @@ void pfile_ui_set_class_stats(unsigned int player_class_nr, _uidefaultstats *cla
bool pfile_ui_save_create(_uiheroinfo *heroinfo); bool pfile_ui_save_create(_uiheroinfo *heroinfo);
bool pfile_get_file_name(uint8_t lvl, char *dst); bool pfile_get_file_name(uint8_t lvl, char *dst);
bool pfile_delete_save(_uiheroinfo *hero_info); bool pfile_delete_save(_uiheroinfo *hero_info);
void pfile_read_player_from_save(); void pfile_read_player_from_save(char name[16], int playerId);
bool LevelFileExists(); bool LevelFileExists();
void GetTempLevelNames(char *szTemp); void GetTempLevelNames(char *szTemp);
void GetPermLevelNames(char *szPerm); void GetPermLevelNames(char *szPerm);

Loading…
Cancel
Save