Skip to content

Commit 847541a

Browse files
committed
sgGameInitInfo multiplayer handling part 2
1 parent 67bd213 commit 847541a

4 files changed

Lines changed: 19 additions & 20 deletions

File tree

Source/DiabloUI/multi/selgame.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,9 @@ void selgame_Password_Select(size_t /*value*/)
666666
m_game_data->bRunInTown = *GetOptions().Gameplay.runInTown ? 1 : 0;
667667
m_game_data->bTheoQuest = *GetOptions().Gameplay.theoQuest ? 1 : 0;
668668
m_game_data->bCowQuest = *GetOptions().Gameplay.cowQuest ? 1 : 0;
669+
m_game_data->bSharedExperience = *GetOptions().Gameplay.sharedXP ? 1 : 0;
670+
m_game_data->bRemoveCripplingEffects = *GetOptions().Gameplay.removeCripplingEffects ? 1 : 0;
671+
m_game_data->bDisableSearch = *GetOptions().Gameplay.disableSearch ? 1 : 0;
669672

670673
GameData gameInitInfo = *m_game_data;
671674
gameInitInfo.swapLE();

Source/items.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ _item_indexes RndUItem(Monster *monster)
14031403
return false;
14041404
if (IsAnyOf(item.itype, ItemType::Gold, ItemType::Misc))
14051405
return false;
1406-
if (sgGameInitInfo.bDisableSearch && item.iSpell == SpellID::Search)
1406+
if (sgGameInitInfo.bDisableSearch == 1 && item.iSpell == SpellID::Search)
14071407
return false;
14081408
return true;
14091409
});
@@ -1416,7 +1416,7 @@ _item_indexes RndAllItems()
14161416

14171417
int itemMaxLevel = ItemsGetCurrlevel() * 2;
14181418
return GetItemIndexForDroppableItem(false, [&itemMaxLevel](const ItemData &item) {
1419-
if (sgGameInitInfo.bDisableSearch && item.iSpell == SpellID::Search)
1419+
if (sgGameInitInfo.bDisableSearch == 1 && item.iSpell == SpellID::Search)
14201420
return false;
14211421
if (itemMaxLevel < item.iMinMLvl)
14221422
return false;
@@ -1434,7 +1434,7 @@ _item_indexes RndTypeItems(ItemType itemType, int imid, int lvl)
14341434
return false;
14351435
if (imid != -1 && item.iMiscId != imid)
14361436
return false;
1437-
if (sgGameInitInfo.bDisableSearch && item.iSpell == SpellID::Search)
1437+
if (sgGameInitInfo.bDisableSearch == 1 && item.iSpell == SpellID::Search)
14381438
return false;
14391439
return true;
14401440
});
@@ -1533,7 +1533,7 @@ void SetupBaseItem(Point position, _item_indexes idx, bool onlygood, bool sendms
15331533
item = {};
15341534
item.position = originalPos;
15351535
SetupAllItems(*MyPlayer, item, idx, AdvanceRndSeed(), 2 * curlv, 1, onlygood, delta, false);
1536-
} while (item._iSpell == SpellID::Search && sgGameInitInfo.bDisableSearch);
1536+
} while (item._iSpell == SpellID::Search && sgGameInitInfo.bDisableSearch == 1);
15371537
TryRandomUniqueItem(item, idx, 2 * curlv, 1, onlygood, delta);
15381538
SetupItem(item);
15391539

@@ -2017,7 +2017,7 @@ void SpawnOnePremium(Item &premiumItem, int plvl, const Player &player)
20172017
&& premiumItem._iMinMag <= magic
20182018
&& premiumItem._iMinDex <= dexterity
20192019
&& premiumItem._iIvalue >= itemValue
2020-
&& (!sgGameInitInfo.bDisableSearch || premiumItem._iSpell != SpellID::Search)) {
2020+
&& (sgGameInitInfo.bDisableSearch != 1 || premiumItem._iSpell != SpellID::Search)) {
20212021
break;
20222022
}
20232023
}
@@ -2199,7 +2199,7 @@ void CreateMagicItem(Point position, int lvl, ItemType itemType, int imid, int i
21992199
SetupAllItems(*MyPlayer, item, idx, AdvanceRndSeed(), 2 * lvl, 1, true, delta);
22002200
TryRandomUniqueItem(item, idx, 2 * lvl, 1, true, delta);
22012201
SetupItem(item);
2202-
if (item._iCurs == icurs && (!sgGameInitInfo.bDisableSearch || item._iSpell != SpellID::Search))
2202+
if (item._iCurs == icurs && (sgGameInitInfo.bDisableSearch != 1 || item._iSpell != SpellID::Search))
22032203
break;
22042204

22052205
idx = RndTypeItems(itemType, imid, lvl);
@@ -3262,7 +3262,7 @@ _item_indexes RndItemForMonsterLevel(int8_t monsterLevel)
32623262
return IDI_GOLD;
32633263

32643264
return GetItemIndexForDroppableItem(true, [&monsterLevel](const ItemData &item) {
3265-
if (sgGameInitInfo.bDisableSearch && item.iSpell == SpellID::Search)
3265+
if (sgGameInitInfo.bDisableSearch == 1 && item.iSpell == SpellID::Search)
32663266
return false;
32673267
return item.iMinMLvl <= monsterLevel;
32683268
});
@@ -3479,7 +3479,7 @@ void SpawnItem(Monster &monster, Point position, bool sendmsg, bool spawn /*= fa
34793479
item = {};
34803480
item.position = originalPos;
34813481
SetupAllItems(*MyPlayer, item, idx, AdvanceRndSeed(), mLevel, uper, onlygood, false, false);
3482-
} while (item._iSpell == SpellID::Search && sgGameInitInfo.bDisableSearch);
3482+
} while (item._iSpell == SpellID::Search && sgGameInitInfo.bDisableSearch == 1);
34833483
TryRandomUniqueItem(item, idx, mLevel, uper, onlygood, false);
34843484
SetupItem(item);
34853485

@@ -3491,11 +3491,7 @@ void SpawnItem(Monster &monster, Point position, bool sendmsg, bool spawn /*= fa
34913491

34923492
void CreateRndItem(Point position, bool onlygood, bool sendmsg, bool delta)
34933493
{
3494-
_item_indexes idx;
3495-
3496-
do {
3497-
idx = onlygood ? RndUItem(nullptr) : RndAllItems();
3498-
} while (sgGameInitInfo.bDisableSearch && AllItemsList[idx].iSpell == SpellID::Search);
3494+
_item_indexes idx = onlygood ? RndUItem(nullptr) : RndAllItems();
34993495

35003496
SetupBaseItem(position, idx, onlygood, sendmsg, delta);
35013497
}
@@ -4504,7 +4500,7 @@ void SpawnWitch(int lvl)
45044500
SetRndSeed(item._iSeed);
45054501
DiscardRandomValues(1);
45064502
GetItemAttrs(item, bookType, lvl);
4507-
} while (item._iSpell == SpellID::Search && sgGameInitInfo.bDisableSearch);
4503+
} while (item._iSpell == SpellID::Search && sgGameInitInfo.bDisableSearch == 1);
45084504
item._iCreateInfo = lvl | CF_WITCH;
45094505
item._iIdentified = true;
45104506
bookCount++;
@@ -4532,7 +4528,7 @@ void SpawnWitch(int lvl)
45324528
if (maxlvl != -1)
45334529
GetItemBonus(*MyPlayer, item, maxlvl / 2, maxlvl, true, true);
45344530
} while (item._iIvalue > maxValue
4535-
|| (item._iSpell == SpellID::Search && sgGameInitInfo.bDisableSearch));
4531+
|| (item._iSpell == SpellID::Search && sgGameInitInfo.bDisableSearch == 1));
45364532

45374533
item._iCreateInfo = lvl | CF_WITCH;
45384534
item._iIdentified = true;
@@ -4649,7 +4645,7 @@ void SpawnBoy(int lvl)
46494645
|| BoyItem._iMinMag > magic
46504646
|| BoyItem._iMinDex > dexterity
46514647
|| BoyItem._iIvalue < ivalue
4652-
|| (BoyItem._iSpell == SpellID::Search && sgGameInitInfo.bDisableSearch))
4648+
|| (BoyItem._iSpell == SpellID::Search && sgGameInitInfo.bDisableSearch == 1))
46534649
&& count < 250));
46544650
BoyItem._iCreateInfo = lvl | CF_BOY;
46554651
BoyItem._iIdentified = true;

Source/monster.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ void MonsterAttackPlayer(Monster &monster, Player &player, int hit, int minDam,
11541154
}
11551155
if (monster.type().type == MT_YZOMBIE
11561156
&& &player == MyPlayer
1157-
&& !sgGameInitInfo.bRemoveCripplingEffects) {
1157+
&& sgGameInitInfo.bRemoveCripplingEffects != 1) {
11581158
if (player._pMaxHP > 64) {
11591159
if (player._pMaxHPBase > 64) {
11601160
player._pMaxHP -= 64;
@@ -4794,7 +4794,7 @@ bool Monster::isPossibleToHit() const
47944794
void Monster::tag(const Player &tagger)
47954795
{
47964796
whoHit |= 1 << tagger.getId();
4797-
if (sgGameInitInfo.bSharedExperience) {
4797+
if (sgGameInitInfo.bSharedExperience == 1) {
47984798
for (const auto &player : Players) {
47994799
if (player.plractive && player.plrlevel == tagger.plrlevel) {
48004800
whoHit |= 1 << player.getId();

Source/objects.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,7 +3198,7 @@ int FindValidShrine()
31983198
continue;
31993199

32003200
if (IsAnyOf(rv, ShrineFascinating, ShrineOrnate, ShrineSacred, ShrineMurphys, ShrineTainted)
3201-
&& sgGameInitInfo.bRemoveCripplingEffects)
3201+
&& sgGameInitInfo.bRemoveCripplingEffects == 1)
32023202
continue;
32033203

32043204
return rv;
@@ -3632,7 +3632,7 @@ bool Object::IsDisabled() const
36323632
return false;
36333633
}
36343634

3635-
if (sgGameInitInfo.bRemoveCripplingEffects) {
3635+
if (sgGameInitInfo.bRemoveCripplingEffects == 1) {
36363636
return false;
36373637
}
36383638
if (IsAnyOf(_otype, _object_id::OBJ_GOATSHRINE, _object_id::OBJ_CAULDRON)) {

0 commit comments

Comments
 (0)