diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 722ea8c1c..265d688d6 100644 --- a/Source/diablo.cpp +++ b/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; diff --git a/Source/msg.cpp b/Source/msg.cpp index 04b356931..0f4b04c90 100644 --- a/Source/msg.cpp +++ b/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) diff --git a/Source/msg.h b/Source/msg.h index 1d3652d82..1b60646d3 100644 --- a/Source/msg.h +++ b/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(); diff --git a/Source/portal.cpp b/Source/portal.cpp index e961984f5..9e47e6d60 100644 --- a/Source/portal.cpp +++ b/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; } } diff --git a/Source/quests.cpp b/Source/quests.cpp index a33de49a5..e1dff965a 100644 --- a/Source/quests.cpp +++ b/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++; } }