From 0711e6af4dc0f3f1be540e6aeb5ef4dc20af5080 Mon Sep 17 00:00:00 2001 From: obligaron Date: Sat, 12 Nov 2022 12:53:48 +0100 Subject: [PATCH] Sync SpawnQuestItem (multiplayer quest items) --- Source/items.cpp | 20 +++++++++++++++----- Source/items.h | 2 +- Source/objects.cpp | 12 ++++++------ Source/quests.cpp | 4 ++-- Source/towners.cpp | 2 +- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index 7ca1fcb0a..63d355803 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -468,7 +468,7 @@ void SpawnNote() } Point position = GetRandomAvailableItemPosition(); - SpawnQuestItem(id, position, 0, 1); + SpawnQuestItem(id, position, 0, 1, false); } void CalcSelfItems(Player &player) @@ -1619,6 +1619,9 @@ void SpawnRock() item._iSelFlag = 2; item._iPostDraw = true; item.AnimInfo.currentFrame = 10; + item._iCreateInfo |= CF_PREGEN; + + DeltaAddItem(ii); } void ItemDoppel() @@ -2345,11 +2348,11 @@ void InitItems() if (Quests[Q_ROCK].IsAvailable()) SpawnRock(); if (Quests[Q_ANVIL].IsAvailable()) - SpawnQuestItem(IDI_ANVIL, SetPiece.position.megaToWorld() + Displacement { 11, 11 }, 0, 1); + SpawnQuestItem(IDI_ANVIL, SetPiece.position.megaToWorld() + Displacement { 11, 11 }, 0, 1, false); if (sgGameInitInfo.bCowQuest != 0 && currlevel == 20) - SpawnQuestItem(IDI_BROWNSUIT, { 25, 25 }, 3, 1); + SpawnQuestItem(IDI_BROWNSUIT, { 25, 25 }, 3, 1, false); if (sgGameInitInfo.bCowQuest != 0 && currlevel == 19) - SpawnQuestItem(IDI_GREYSUIT, { 25, 25 }, 3, 1); + SpawnQuestItem(IDI_GREYSUIT, { 25, 25 }, 3, 1, false); if (currlevel > 0 && currlevel < 16) AddInitItems(); if (currlevel >= 21 && currlevel <= 23) @@ -3261,7 +3264,7 @@ void CornerstoneLoad(Point position) CornerStone.item = item; } -void SpawnQuestItem(_item_indexes itemid, Point position, int randarea, int selflag) +void SpawnQuestItem(_item_indexes itemid, Point position, int randarea, int selflag, bool sendmsg) { if (randarea > 0) { int tries = 0; @@ -3306,6 +3309,13 @@ void SpawnQuestItem(_item_indexes itemid, Point position, int randarea, int self item.AnimInfo.currentFrame = item.AnimInfo.numberOfFrames - 1; item._iAnimFlag = false; } + + if (sendmsg) + NetSendCmdPItem(true, CMD_SPAWNITEM, item.position, item); + else { + DeltaAddItem(ii); + item._iCreateInfo |= CF_PREGEN; + } } void SpawnRewardItem(_item_indexes itemid, Point position, bool sendmsg) diff --git a/Source/items.h b/Source/items.h index 8bc178ac5..56ab8f276 100644 --- a/Source/items.h +++ b/Source/items.h @@ -506,7 +506,7 @@ void RecreateItem(const Player &player, Item &item, _item_indexes idx, uint16_t void RecreateEar(Item &item, uint16_t ic, int iseed, uint8_t bCursval, string_view heroName); void CornerstoneSave(); void CornerstoneLoad(Point position); -void SpawnQuestItem(_item_indexes itemid, Point position, int randarea, int selflag); +void SpawnQuestItem(_item_indexes itemid, Point position, int randarea, int selflag, bool sendmsg); void SpawnRewardItem(_item_indexes itemid, Point position, bool sendmsg); void SpawnMapOfDoom(Point position, bool sendmsg); void SpawnRuneBomb(Point position, bool sendmsg); diff --git a/Source/objects.cpp b/Source/objects.cpp index 093a2fd71..01e7c4176 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1992,7 +1992,7 @@ void OperateBookLever(Object &questBook, bool sendmsg) Quests[Q_BLOOD]._qactive = QUEST_ACTIVE; Quests[Q_BLOOD]._qlog = true; Quests[Q_BLOOD]._qvar1 = 1; - SpawnQuestItem(IDI_BLDSTONE, SetPiece.position.megaToWorld() + Displacement { 9, 17 }, 0, 1); + SpawnQuestItem(IDI_BLDSTONE, SetPiece.position.megaToWorld() + Displacement { 9, 17 }, 0, 1, true); } if (questBook._otype == OBJ_STEELTOME && Quests[Q_WARLORD]._qvar1 == 0) { Quests[Q_WARLORD]._qactive = QUEST_ACTIVE; @@ -2136,7 +2136,7 @@ void OperateMushroomPatch(const Player &player, Object &mushroomPatch) PlaySfxLoc(IS_CHEST, mushroomPatch.position); Point pos = GetSuperItemLoc(mushroomPatch.position); - SpawnQuestItem(IDI_MUSHROOM, pos, 0, 0); + SpawnQuestItem(IDI_MUSHROOM, pos, 0, 0, true); Quests[Q_MUSHROOM]._qvar1 = QS_MUSHSPAWNED; } @@ -2162,7 +2162,7 @@ void OperateInnSignChest(const Player &player, Object &questContainer) PlaySfxLoc(IS_CHEST, questContainer.position); Point pos = GetSuperItemLoc(questContainer.position); - SpawnQuestItem(IDI_BANNER, pos, 0, 0); + SpawnQuestItem(IDI_BANNER, pos, 0, 0, true); } void OperateSlainHero(const Player &player, Object &corpse) @@ -2252,12 +2252,12 @@ void OperatePedestal(Player &player, Object &pedestal) if (pedestal._oVar6 == 1) { PlaySfxLoc(LS_PUDDLE, pedestal.position); ObjChangeMap(SetPiece.position.x, SetPiece.position.y + 3, SetPiece.position.x + 2, SetPiece.position.y + 7); - SpawnQuestItem(IDI_BLDSTONE, SetPiece.position.megaToWorld() + Displacement { 3, 10 }, 0, 1); + SpawnQuestItem(IDI_BLDSTONE, SetPiece.position.megaToWorld() + Displacement { 3, 10 }, 0, 1, true); } if (pedestal._oVar6 == 2) { PlaySfxLoc(LS_PUDDLE, pedestal.position); ObjChangeMap(SetPiece.position.x + 6, SetPiece.position.y + 3, SetPiece.position.x + SetPiece.size.width, SetPiece.position.y + 7); - SpawnQuestItem(IDI_BLDSTONE, SetPiece.position.megaToWorld() + Displacement { 15, 10 }, 0, 1); + SpawnQuestItem(IDI_BLDSTONE, SetPiece.position.megaToWorld() + Displacement { 15, 10 }, 0, 1, true); } if (pedestal._oVar6 == 3) { PlaySfxLoc(LS_BLODSTAR, pedestal.position); @@ -3404,7 +3404,7 @@ void OperateLazStand(Object &stand) stand._oAnimFrame++; stand._oSelFlag = 0; Point pos = GetSuperItemLoc(stand.position); - SpawnQuestItem(IDI_LAZSTAFF, pos, 0, 0); + SpawnQuestItem(IDI_LAZSTAFF, pos, 0, 0, true); NetSendCmdLoc(MyPlayerId, false, CMD_OPERATEOBJ, stand.position); } diff --git a/Source/quests.cpp b/Source/quests.cpp index c6707f07e..e07aa4a0c 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -642,7 +642,7 @@ void ResyncQuests() } if (currlevel == Quests[Q_MUSHROOM]._qlevel) { if (Quests[Q_MUSHROOM]._qactive == QUEST_INIT && Quests[Q_MUSHROOM]._qvar1 == QS_INIT) { - SpawnQuestItem(IDI_FUNGALTM, { 0, 0 }, 5, 1); + SpawnQuestItem(IDI_FUNGALTM, { 0, 0 }, 5, 1, false); Quests[Q_MUSHROOM]._qvar1 = QS_TOMESPAWNED; } else { if (Quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) { @@ -657,7 +657,7 @@ void ResyncQuests() } if (currlevel == Quests[Q_VEIL]._qlevel + 1 && Quests[Q_VEIL]._qactive == QUEST_ACTIVE && Quests[Q_VEIL]._qvar1 == 0) { Quests[Q_VEIL]._qvar1 = 1; - SpawnQuestItem(IDI_GLDNELIX, { 0, 0 }, 5, 1); + SpawnQuestItem(IDI_GLDNELIX, { 0, 0 }, 5, 1, false); } if (setlevel && setlvlnum == SL_VILEBETRAYER) { if (Quests[Q_BETRAYER]._qvar1 >= 4) diff --git a/Source/towners.cpp b/Source/towners.cpp index 8306d5a87..4ad47a3ac 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -497,7 +497,7 @@ void TalkToHealer(Player &player, Towner &healer) } if (Quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) { if (Quests[Q_MUSHROOM]._qvar1 >= QS_MUSHGIVEN && Quests[Q_MUSHROOM]._qvar1 < QS_BRAINGIVEN && RemoveInventoryItemById(player, IDI_BRAIN)) { - SpawnQuestItem(IDI_SPECELIX, healer.position + Displacement { 0, 1 }, 0, 0); + SpawnQuestItem(IDI_SPECELIX, healer.position + Displacement { 0, 1 }, 0, 0, true); InitQTextMsg(TEXT_MUSH4); Quests[Q_MUSHROOM]._qvar1 = QS_BRAINGIVEN; QuestDialogTable[TOWN_HEALER][Q_MUSHROOM] = TEXT_NONE;