Skip to content

Commit

Permalink
LoadGameLevel bin exact (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
galaxyhaxz authored and AJenbo committed Nov 8, 2018
1 parent 86f0014 commit a11b924
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 109 deletions.
220 changes: 113 additions & 107 deletions Source/diablo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1713,90 +1713,94 @@ void __fastcall CreateLevel(int lvldir)

void __fastcall LoadGameLevel(BOOL firstflag, int lvldir)
{
int v2; // ebp
bool visited; // edx
int i; // ecx
int j; // eax
int i, j;
BOOL visited;

v2 = 0;
if (setseed)
if(setseed)
glSeedTbl[currlevel] = setseed;

music_stop();
SetCursor(CURSOR_HAND);
SetRndSeed(glSeedTbl[currlevel]);
IncProgress();
MakeLightTable();
LoadLvlGFX();
IncProgress();
if (firstflag) {

if(firstflag) {
InitInv();
InitItemGFX();
InitQuestText();

if (gbMaxPlayers) {
for (i = 0; i < gbMaxPlayers; i++)
InitPlrGFXMem(i);
}
for(i = 0; i < gbMaxPlayers; i++)
InitPlrGFXMem(i);

InitStores();
InitAutomapOnce();
InitHelp();
}

SetRndSeed(glSeedTbl[currlevel]);
if (leveltype == DTYPE_TOWN)

if(leveltype == DTYPE_TOWN)
SetupTownStores();

IncProgress();
InitAutomap();
if (leveltype != DTYPE_TOWN && lvldir != 4) {

if(leveltype != DTYPE_TOWN && lvldir != 4) {
InitLighting();
InitVision();
}

InitLevelMonsters();
IncProgress();
if (!setlevel) {

if(!setlevel) {
CreateLevel(lvldir);
IncProgress();
FillSolidBlockTbls();
SetRndSeed(glSeedTbl[currlevel]);
if (leveltype != DTYPE_TOWN) {

if(leveltype != DTYPE_TOWN) {
GetLevelMTypes();
InitThemes();
LoadAllGFX();
} else {
InitMissileGFX();
}

IncProgress();
if (lvldir == 3)

if(lvldir == 3)
GetReturnLvlPos();
if (lvldir == 5)
if(lvldir == 5)
GetPortalLvlPos();

IncProgress();

for (i = 0; i < MAX_PLRS; i++) {
if (plr[i].plractive) {
if (currlevel == plr[i].plrlevel) {
InitPlayerGFX(v2);
if (lvldir != 4)
InitPlayer(v2, firstflag);
}
for(i = 0; i < MAX_PLRS; i++) {
if(plr[i].plractive && currlevel == plr[i].plrlevel) {
InitPlayerGFX(i);
if(lvldir != 4)
InitPlayer(i, firstflag);
}
++v2;
}

PlayDungMsgs();
InitMultiView();
IncProgress();

visited = 0;
if (gbMaxPlayers > 0) {
for (i = 0; i < gbMaxPlayers; i++) {
if (plr[i].plractive)
visited = visited || plr[i]._pLvlVisited[currlevel];
}
visited = FALSE;
for(i = 0; i < gbMaxPlayers; i++) {
if(plr[i].plractive)
visited = visited || plr[i]._pLvlVisited[currlevel];
}

SetRndSeed(glSeedTbl[currlevel]);
if (leveltype != DTYPE_TOWN) {
if (firstflag || lvldir == 4 || !plr[myplr]._pLvlVisited[currlevel] || gbMaxPlayers != 1) {

if(leveltype != DTYPE_TOWN) {
if(firstflag || lvldir == 4 || !plr[myplr]._pLvlVisited[currlevel] || gbMaxPlayers != 1) {
HoldThemeRooms();
glMid1Seed[currlevel] = GetRndSeed();
InitMonsters();
Expand All @@ -1808,113 +1812,115 @@ void __fastcall LoadGameLevel(BOOL firstflag, int lvldir)
InitMissiles();
InitDead();
glEndSeed[currlevel] = GetRndSeed();
if (gbMaxPlayers != 1)

if(gbMaxPlayers != 1)
DeltaLoadLevel();

IncProgress();
SavePreLighting();
goto LABEL_55;
} else {
InitMonsters();
InitMissiles();
InitDead();
IncProgress();
LoadLevel();
IncProgress();
}
} else {
for(i = 0; i < MAXDUNX; i++) {
for(j = 0; j < MAXDUNY; j++)
dFlags[i][j] |= DFLAG_LIT;
}
InitMonsters();

InitTowners();
InitItems();
InitMissiles();
InitDead();
IncProgress();
LoadLevel();
LABEL_54:

if(!firstflag && lvldir != 4 && plr[myplr]._pLvlVisited[currlevel] && gbMaxPlayers == 1)
LoadLevel();
if(gbMaxPlayers != 1)
DeltaLoadLevel();

IncProgress();
LABEL_55:
if (gbMaxPlayers == 1)
ResyncQuests();
else
ResyncMPQuests();
goto LABEL_72;
}
if(gbMaxPlayers == 1)
ResyncQuests();
else
ResyncMPQuests();
} else {
/// ASSERT: assert(! pSpeedCels);
pSpeedCels = DiabloAllocPtr(0x100000);
LoadSetMap();
IncProgress();
GetLevelMTypes();
InitMonsters();
InitMissileGFX();
InitDead();
FillSolidBlockTbls();
IncProgress();

if(lvldir == 5)
GetPortalLvlPos();

for (i = 0; i < MAXDUNX; i++) {
for (j = 0; j < MAXDUNY; j++)
dFlags[i][j] |= DFLAG_LIT;
for(i = 0; i < MAX_PLRS; i++) {
if(plr[i].plractive && currlevel == plr[i].plrlevel) {
InitPlayerGFX(i);
if(lvldir != 4)
InitPlayer(i, firstflag);
}
}

InitTowners();
InitItems();
InitMissiles();
InitMultiView();
IncProgress();
if (!firstflag && lvldir != 4 && plr[myplr]._pLvlVisited[currlevel]) {
if (gbMaxPlayers != 1)
goto LABEL_53;

if(firstflag || lvldir == 4 || !plr[myplr]._pSLvlVisited[setlvlnum]) {
InitItems();
SavePreLighting();
} else {
LoadLevel();
}
if (gbMaxPlayers == 1)
goto LABEL_54;
LABEL_53:
DeltaLoadLevel();
goto LABEL_54;
}
pSpeedCels = DiabloAllocPtr(0x100000);
LoadSetMap();
IncProgress();
GetLevelMTypes();
InitMonsters();
InitMissileGFX();
InitDead();
FillSolidBlockTbls();
IncProgress();
if (lvldir == 5)
GetPortalLvlPos();

for (i = 0; i < MAX_PLRS; i++) {
if (plr[i].plractive) {
if (currlevel == plr[i].plrlevel) {
InitPlayerGFX(v2);
if (lvldir != 4)
InitPlayer(v2, firstflag);
}
}
++v2;
}

InitMultiView();
IncProgress();
if (firstflag || lvldir == 4 || !plr[myplr]._pSLvlVisited[setlvlnum]) {
InitItems();
SavePreLighting();
} else {
LoadLevel();
InitMissiles();
IncProgress();
}
InitMissiles();
IncProgress();
LABEL_72:

SyncPortals();

for (i = 0; i < MAX_PLRS; i++) {
if (plr[i].plractive && plr[i].plrlevel == currlevel && (!plr[i]._pLvlChanging || i == myplr)) {
if (plr[i]._pHitPoints <= 0)
for(i = 0; i < MAX_PLRS; i++) {
if(plr[i].plractive && plr[i].plrlevel == currlevel && (!plr[i]._pLvlChanging || i == myplr)) {
if(plr[i]._pHitPoints > 0) {
if(gbMaxPlayers == 1)
dPlayer[plr[i].WorldX][plr[i].WorldY] = i + 1;
else
SyncInitPlrPos(i);
} else {
dFlags[plr[i].WorldX][plr[i].WorldY] |= DFLAG_DEAD_PLAYER;
else if (gbMaxPlayers == 1)
dPlayer[plr[i].WorldX][plr[i].WorldY] = i + 1;
else
SyncInitPlrPos(i);
}
}
}

if (leveltype != DTYPE_TOWN)
if(leveltype != DTYPE_TOWN)
SetDungeonMicros();

InitLightMax();
IncProgress();
IncProgress();
if (firstflag) {

if(firstflag) {
InitControlPan();
IncProgress();
}
if (leveltype != DTYPE_TOWN) {
if(leveltype != DTYPE_TOWN) {
ProcessLightList();
ProcessVisionList();
}

music_start(leveltype);
//do
// _LOBYTE(v19) = IncProgress();
while (!IncProgress())
;
if (setlevel && setlvlnum == SL_SKELKING && quests[QTYPE_KING]._qactive == 2)

while(!IncProgress());

if(setlevel && setlvlnum == SL_SKELKING && quests[QTYPE_KING]._qactive == 2)
PlaySFX(USFX_SKING1);
}
// 525738: using guessed type int setseed;
Expand Down
2 changes: 1 addition & 1 deletion Source/interfac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void __cdecl interface_msg_pump()
}
}

bool __cdecl IncProgress()
BOOL __cdecl IncProgress()
{
interface_msg_pump();
sgdwProgress += 15;
Expand Down
2 changes: 1 addition & 1 deletion Source/interfac.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern int progress_id; // idb

void __cdecl interfac_cpp_init();
void __cdecl interface_msg_pump();
bool __cdecl IncProgress();
BOOL __cdecl IncProgress();
void __cdecl DrawCutscene();
void __fastcall DrawProgress(int screen_x, int screen_y, int progress_id);
void __fastcall ShowProgress(int uMsg);
Expand Down

0 comments on commit a11b924

Please sign in to comment.