Browse Source

Fix order of operations during game initialization

pull/3951/head
staphen 4 years ago committed by Anders Jenbo
parent
commit
5b21e0188f
  1. 1
      Source/diablo.cpp
  2. 47
      Source/msg.cpp
  3. 3
      Source/msg.h
  4. 5
      Source/portal.cpp
  5. 4
      Source/quests.cpp

1
Source/diablo.cpp

@ -1649,6 +1649,7 @@ bool StartGame(bool bNewGame, bool bSinglePlayer)
InitQuests();
InitPortals();
InitDungMsgs(Players[MyPlayerId]);
DeltaSyncJunk();
}
giNumberOfLevels = gbIsHellfire ? 25 : 17;
interface_mode uMsg = WM_DIABNEWGAME;

47
Source/msg.cpp

@ -272,28 +272,17 @@ void DeltaImportJunk(const byte *src)
if (*src == byte { 0xFF }) {
memset(&sgJunk.portal[i], 0xFF, sizeof(DPortal));
src++;
SetPortalStats(i, false, 0, 0, 0, DTYPE_TOWN);
} else {
memcpy(&sgJunk.portal[i], src, sizeof(DPortal));
src += sizeof(DPortal);
SetPortalStats(
i,
true,
sgJunk.portal[i].x,
sgJunk.portal[i].y,
sgJunk.portal[i].level,
(dungeon_type)sgJunk.portal[i].ltype);
}
}
int q = 0;
for (auto &quest : Quests) {
if (!QuestsData[quest._qidx].isSinglePlayerOnly) {
for (int qidx = 0; qidx < MAXQUESTS; qidx++) {
if (!QuestsData[qidx].isSinglePlayerOnly) {
memcpy(&sgJunk.quests[q], src, sizeof(MultiQuests));
src += sizeof(MultiQuests);
quest._qlog = sgJunk.quests[q].qlog != 0;
quest._qactive = sgJunk.quests[q].qstate;
quest._qvar1 = sgJunk.quests[q].qvar1;
q++;
}
}
@ -2083,14 +2072,34 @@ void delta_sync_monster(const TSyncMonster &monsterSync, uint8_t level)
monster.mWhoHit = monsterSync.mWhoHit;
}
bool delta_portal_inited(int i)
void DeltaSyncJunk()
{
return sgJunk.portal[i].x == 0xFF;
}
for (int i = 0; i < MAXPORTAL; i++) {
if (sgJunk.portal[i].x == 0xFF) {
SetPortalStats(i, false, 0, 0, 0, DTYPE_TOWN);
} else {
SetPortalStats(
i,
true,
sgJunk.portal[i].x,
sgJunk.portal[i].y,
sgJunk.portal[i].level,
(dungeon_type)sgJunk.portal[i].ltype);
}
}
bool delta_quest_inited(int i)
{
return sgJunk.quests[i].qstate != QUEST_INVALID;
int q = 0;
for (auto &quest : Quests) {
if (QuestsData[quest._qidx].isSinglePlayerOnly) {
continue;
}
if (sgJunk.quests[q].qstate != Q_INVALID) {
quest._qlog = sgJunk.quests[q].qlog != 0;
quest._qactive = sgJunk.quests[q].qstate;
quest._qvar1 = sgJunk.quests[q].qvar1;
}
q++;
}
}
void DeltaAddItem(int ii)

3
Source/msg.h

@ -437,12 +437,11 @@ void msg_send_drop_pkt(int pnum, int reason);
bool msg_wait_resync();
void run_delta_info();
void DeltaExportData(int pnum);
void DeltaSyncJunk();
void delta_init();
void delta_kill_monster(int mi, Point position, BYTE bLevel);
void delta_monster_hp(int mi, int hp, BYTE bLevel);
void delta_sync_monster(const TSyncMonster &monsterSync, uint8_t level);
bool delta_portal_inited(int i);
bool delta_quest_inited(int i);
void DeltaAddItem(int ii);
void DeltaSaveLevel();
void DeltaLoadLevel();

5
Source/portal.cpp

@ -33,9 +33,8 @@ Point WarpDrop[MAXPORTAL] = {
void InitPortals()
{
for (int i = 0; i < MAXPORTAL; i++) {
if (delta_portal_inited(i))
Portals[i].open = false;
for (auto &portal : Portals) {
portal.open = false;
}
}

4
Source/quests.cpp

@ -310,9 +310,7 @@ void InitQuests()
quest._qactive = QUEST_INIT;
} else if (!questData.isSinglePlayerOnly) {
quest._qlevel = questData._qdmultlvl;
if (!delta_quest_inited(initiatedQuests)) {
quest._qactive = QUEST_INIT;
}
quest._qactive = QUEST_INIT;
initiatedQuests++;
}
}

Loading…
Cancel
Save