Browse Source

Enable loading hellfire games form main menu

pull/970/head
Anders Jenbo 5 years ago
parent
commit
a2a3729491
  1. 35
      Source/diablo.cpp
  2. 4
      Source/init.cpp
  3. 1
      Source/init.h
  4. 41
      Source/inv.cpp
  5. 1
      Source/inv.h
  6. 11
      Source/pfile.cpp
  7. 48
      SourceX/storm/storm.cpp

35
Source/diablo.cpp

@ -49,6 +49,7 @@ int setseed;
int debugmonsttypes; int debugmonsttypes;
int PauseMode; int PauseMode;
bool forceSpawn; bool forceSpawn;
bool forceDiablo;
BOOLEAN UseTheoQuest; BOOLEAN UseTheoQuest;
BOOLEAN UseCowFarmer; BOOLEAN UseCowFarmer;
BOOLEAN UseNestArt; BOOLEAN UseNestArt;
@ -118,6 +119,8 @@ static void print_help_and_exit()
printf(" %-20s %-30s\n", "-x", "Run in windowed mode"); printf(" %-20s %-30s\n", "-x", "Run in windowed mode");
printf(" %-20s %-30s\n", "--spawn", "Force spawn mode even if diabdat.mpq is found"); printf(" %-20s %-30s\n", "--spawn", "Force spawn mode even if diabdat.mpq is found");
#ifdef HELLFIRE #ifdef HELLFIRE
printf("\nHellfire options:\n");
printf(" %-20s %-30s\n", "--diablo", "Force diablo mode even if hellfire.mpq is found");
printf(" %-20s %-30s\n", "--theoquest", "Enable the Theo quest"); printf(" %-20s %-30s\n", "--theoquest", "Enable the Theo quest");
printf(" %-20s %-30s\n", "--cowquest", "Enable the Cow quest"); printf(" %-20s %-30s\n", "--cowquest", "Enable the Cow quest");
printf(" %-20s %-30s\n", "--nestart", "Use alternate nest palette"); printf(" %-20s %-30s\n", "--nestart", "Use alternate nest palette");
@ -168,6 +171,8 @@ static void diablo_parse_flags(int argc, char **argv)
} else if (strcasecmp("--spawn", argv[i]) == 0) { } else if (strcasecmp("--spawn", argv[i]) == 0) {
forceSpawn = TRUE; forceSpawn = TRUE;
#ifdef HELLFIRE #ifdef HELLFIRE
} else if (strcasecmp("--diablo", argv[i]) == 0) {
forceDiablo = TRUE;
} else if (strcasecmp("--theoquest", argv[i]) == 0) { } else if (strcasecmp("--theoquest", argv[i]) == 0) {
UseTheoQuest = TRUE; UseTheoQuest = TRUE;
} else if (strcasecmp("--cowquest", argv[i]) == 0) { } else if (strcasecmp("--cowquest", argv[i]) == 0) {
@ -384,9 +389,7 @@ BOOL StartGame(BOOL bNewGame, BOOL bSinglePlayer)
do { do {
fExitProgram = FALSE; fExitProgram = FALSE;
#ifndef HELLFIRE
gbLoadGame = FALSE; gbLoadGame = FALSE;
#endif
if (!NetInit(bSinglePlayer, &fExitProgram)) { if (!NetInit(bSinglePlayer, &fExitProgram)) {
gbRunGameResult = !fExitProgram; gbRunGameResult = !fExitProgram;
@ -400,25 +403,15 @@ BOOL StartGame(BOOL bNewGame, BOOL bSinglePlayer)
InitQuests(); InitQuests();
InitPortals(); InitPortals();
InitDungMsgs(myplr); InitDungMsgs(myplr);
#ifndef HELLFIRE
} }
if (!gbValidSaveFile || !gbLoadGame) { if (!gbValidSaveFile || !gbLoadGame) {
#else
if (!gbValidSaveFile && gbLoadGame)
inv_diablo_to_hellfire(myplr);
#endif
uMsg = WM_DIABNEWGAME; uMsg = WM_DIABNEWGAME;
} else { } else {
uMsg = WM_DIABLOADGAME; uMsg = WM_DIABLOADGAME;
} }
run_game_loop(uMsg); run_game_loop(uMsg);
NetClose(); NetClose();
#ifndef HELLFIRE
pfile_create_player_description(0, 0); pfile_create_player_description(0, 0);
#else
if (gbMaxPlayers == 1)
break;
#endif
} while (gbRunGameResult); } while (gbRunGameResult);
SNetDestroy(); SNetDestroy();
@ -451,6 +444,8 @@ static void diablo_init()
if (forceSpawn) if (forceSpawn)
gbIsSpawn = true; gbIsSpawn = true;
if (forceDiablo)
gbIsHellfire = false;
UiInitialize(); UiInitialize();
UiSetSpawned(gbIsSpawn); UiSetSpawned(gbIsSpawn);
@ -475,17 +470,13 @@ static void diablo_splash()
play_movie("gendata\\logo.smk", TRUE); play_movie("gendata\\logo.smk", TRUE);
#ifndef HELLFIRE if (gbIsHellfire && getIniBool("Hellfire", "Intro", true)) {
if (!gbIsSpawn)
#endif
if (getIniBool(APP_NAME, "Intro", true)) {
#ifndef HELLFIRE
play_movie("gendata\\diablo1.smk", TRUE);
#else
play_movie("gendata\\Hellfire.smk", TRUE); play_movie("gendata\\Hellfire.smk", TRUE);
#endif setIniValue("Hellfire", "Intro", "0");
setIniValue(APP_NAME, "Intro", "0"); } else if (!gbIsSpawn && getIniBool("Diablo", "Intro", true)) {
} play_movie("gendata\\diablo1.smk", TRUE);
setIniValue("Diablo", "Intro", "0");
}
UiTitleDialog(); UiTitleDialog();
} }

4
Source/init.cpp

@ -27,6 +27,8 @@ HANDLE diabdat_mpq;
HANDLE patch_rt_mpq; HANDLE patch_rt_mpq;
/** Indicate if we only have access to demo data */ /** Indicate if we only have access to demo data */
bool gbIsSpawn; bool gbIsSpawn;
/** Indicate if we have loaded the Hellfire expansion data */
bool gbIsHellfire;
HANDLE hfmonk_mpq; HANDLE hfmonk_mpq;
HANDLE hfbard_mpq; HANDLE hfbard_mpq;
HANDLE hfbarb_mpq; HANDLE hfbarb_mpq;
@ -145,6 +147,8 @@ void init_archives()
#ifdef HELLFIRE #ifdef HELLFIRE
hellfire_mpq = init_test_access("hellfire.mpq", "DiabloInstall", 8000, FS_PC); hellfire_mpq = init_test_access("hellfire.mpq", "DiabloInstall", 8000, FS_PC);
if (hellfire_mpq != NULL)
gbIsHellfire = true;
hfmonk_mpq = init_test_access("hfmonk.mpq", "DiabloInstall", 8100, FS_PC); hfmonk_mpq = init_test_access("hfmonk.mpq", "DiabloInstall", 8100, FS_PC);
hfbard_mpq = init_test_access("hfbard.mpq", "DiabloInstall", 8110, FS_PC); hfbard_mpq = init_test_access("hfbard.mpq", "DiabloInstall", 8110, FS_PC);
hfbarb_mpq = init_test_access("hfbarb.mpq", "DiabloInstall", 8120, FS_PC); hfbarb_mpq = init_test_access("hfbarb.mpq", "DiabloInstall", 8120, FS_PC);

1
Source/init.h

@ -18,6 +18,7 @@ extern HANDLE hellfire_mpq;
extern WNDPROC CurrentProc; extern WNDPROC CurrentProc;
extern HANDLE diabdat_mpq; extern HANDLE diabdat_mpq;
extern bool gbIsSpawn; extern bool gbIsSpawn;
extern bool gbIsHellfire;
extern HANDLE patch_rt_mpq; extern HANDLE patch_rt_mpq;
extern HANDLE hfmonk_mpq; extern HANDLE hfmonk_mpq;
extern HANDLE hfbard_mpq; extern HANDLE hfbard_mpq;

41
Source/inv.cpp

@ -1698,47 +1698,6 @@ void RemoveInvItem(int pnum, int iv)
CalcPlrScrolls(pnum); CalcPlrScrolls(pnum);
} }
/**
* @brief This destroyes all items except gold
*/
BOOL inv_diablo_to_hellfire(int pnum)
{
ItemStruct tmp;
ItemStruct *item;
int i, old_item_cnt, new_item_index;
if (plr[pnum]._pgfxnum != 0) {
plr[pnum]._pgfxnum = 0;
plr[pnum]._pGFXLoad = 0;
SetPlrAnims(pnum);
}
for (i = 0, item = plr[pnum].InvBody; i < NUM_INVLOC; i++, item++) {
item->_itype = ITYPE_NONE;
}
old_item_cnt = plr[pnum]._pNumInv;
memset(plr[pnum].InvGrid, 0, sizeof(plr[pnum].InvGrid));
plr[pnum]._pNumInv = 0;
for (i = 0; i < old_item_cnt; i++) {
item = &plr[pnum].InvList[i];
if (item->_itype == ITYPE_GOLD) {
new_item_index = plr[pnum]._pNumInv;
// BUGFIX: new_item_index may be greater or equal to NUM_INV_GRID_ELEM
tmp = *item;
item->_itype = ITYPE_NONE;
plr[pnum].InvList[new_item_index] = tmp;
plr[pnum]._pNumInv++;
plr[pnum].InvGrid[i] = plr[pnum]._pNumInv;
} else {
item->_itype = ITYPE_NONE;
}
};
for (i = 0, item = plr[pnum].SpdList; i < MAXBELTITEMS; i++, item++) {
item->_itype = ITYPE_NONE;
}
CalcPlrItemVals(pnum, FALSE);
return FALSE;
}
void RemoveSpdBarItem(int pnum, int iv) void RemoveSpdBarItem(int pnum, int iv)
{ {
plr[pnum].SpdList[iv]._itype = ITYPE_NONE; plr[pnum].SpdList[iv]._itype = ITYPE_NONE;

1
Source/inv.h

@ -27,7 +27,6 @@ int SwapItem(ItemStruct *a, ItemStruct *b);
void CheckInvSwap(int pnum, BYTE bLoc, int idx, WORD wCI, int seed, BOOL bId); void CheckInvSwap(int pnum, BYTE bLoc, int idx, WORD wCI, int seed, BOOL bId);
void inv_update_rem_item(int pnum, BYTE iv); void inv_update_rem_item(int pnum, BYTE iv);
void RemoveInvItem(int pnum, int iv); void RemoveInvItem(int pnum, int iv);
BOOL inv_diablo_to_hellfire(int pnum);
void RemoveSpdBarItem(int pnum, int iv); void RemoveSpdBarItem(int pnum, int iv);
void CheckInvItem(); void CheckInvItem();
void CheckInvScrn(); void CheckInvScrn();

11
Source/pfile.cpp

@ -23,11 +23,9 @@ namespace {
std::string GetSavePath(DWORD save_num) std::string GetSavePath(DWORD save_num)
{ {
std::string path = GetPrefPath(); std::string path = GetPrefPath();
#ifdef HELLFIRE
const char *ext = ".hsv";
#else
const char *ext = ".sv"; const char *ext = ".sv";
#endif if (gbIsHellfire)
ext = ".hsv";
if (gbIsSpawn) { if (gbIsSpawn) {
if (gbMaxPlayers <= 1) { if (gbMaxPlayers <= 1) {
@ -39,12 +37,7 @@ std::string GetSavePath(DWORD save_num)
if (gbMaxPlayers <= 1) { if (gbMaxPlayers <= 1) {
path.append("single_"); path.append("single_");
} else { } else {
#ifdef HELLFIRE
path.append("hrinfo_");
ext = ".drv";
#else
path.append("multi_"); path.append("multi_");
#endif
} }
} }

48
SourceX/storm/storm.cpp

@ -152,29 +152,31 @@ BOOL SFileOpenFile(const char *filename, HANDLE *phFile)
result = SFileOpenFileEx((HANDLE)0, path.c_str(), 0xFFFFFFFF, phFile); result = SFileOpenFileEx((HANDLE)0, path.c_str(), 0xFFFFFFFF, phFile);
} }
if (!result) { if (gbIsHellfire) {
result = SFileOpenFileEx((HANDLE)hfopt2_mpq, filename, 0, phFile); if (!result) {
} result = SFileOpenFileEx((HANDLE)hfopt2_mpq, filename, 0, phFile);
if (!result) { }
result = SFileOpenFileEx((HANDLE)hfopt1_mpq, filename, 0, phFile); if (!result) {
} result = SFileOpenFileEx((HANDLE)hfopt1_mpq, filename, 0, phFile);
if (!result) { }
result = SFileOpenFileEx((HANDLE)hfvoice_mpq, filename, 0, phFile); if (!result) {
} result = SFileOpenFileEx((HANDLE)hfvoice_mpq, filename, 0, phFile);
if (!result) { }
result = SFileOpenFileEx((HANDLE)hfmusic_mpq, filename, 0, phFile); if (!result) {
} result = SFileOpenFileEx((HANDLE)hfmusic_mpq, filename, 0, phFile);
if (!result) { }
result = SFileOpenFileEx((HANDLE)hfbarb_mpq, filename, 0, phFile); if (!result) {
} result = SFileOpenFileEx((HANDLE)hfbarb_mpq, filename, 0, phFile);
if (!result) { }
result = SFileOpenFileEx((HANDLE)hfbard_mpq, filename, 0, phFile); if (!result) {
} result = SFileOpenFileEx((HANDLE)hfbard_mpq, filename, 0, phFile);
if (!result) { }
result = SFileOpenFileEx((HANDLE)hfmonk_mpq, filename, 0, phFile); if (!result) {
} result = SFileOpenFileEx((HANDLE)hfmonk_mpq, filename, 0, phFile);
if (!result) { }
result = SFileOpenFileEx((HANDLE)hellfire_mpq, filename, 0, phFile); if (!result) {
result = SFileOpenFileEx((HANDLE)hellfire_mpq, filename, 0, phFile);
}
} }
if (!result && patch_rt_mpq) { if (!result && patch_rt_mpq) {
result = SFileOpenFileEx((HANDLE)patch_rt_mpq, filename, 0, phFile); result = SFileOpenFileEx((HANDLE)patch_rt_mpq, filename, 0, phFile);

Loading…
Cancel
Save