Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions Source/objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "inv_iterators.hpp"
#include "levels/crypt.h"
#include "levels/drlg_l4.h"
#include "levels/setmaps.h"

Check warning on line 34 in Source/objects.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/objects.cpp:34:1 [misc-include-cleaner]

included header setmaps.h is not used directly
#include "levels/themes.h"
#include "levels/tile_properties.hpp"
#include "lighting.h"
Expand All @@ -42,8 +42,8 @@
#include "options.h"
#include "qol/stash.h"
#include "stores.h"
#include "towners.h"

Check warning on line 45 in Source/objects.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/objects.cpp:45:1 [misc-include-cleaner]

included header towners.h is not used directly
#include "track.h"

Check warning on line 46 in Source/objects.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/objects.cpp:46:1 [misc-include-cleaner]

included header track.h is not used directly
#include "utils/algorithm/container.hpp"
#include "utils/endian_swap.hpp"
#include "utils/is_of.hpp"
Expand All @@ -53,7 +53,7 @@

namespace devilution {

Object Objects[MAXOBJECTS];

Check warning on line 56 in Source/objects.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/objects.cpp:56:16 [misc-include-cleaner]

no header providing "MAXOBJECTS" is directly included
int AvailableObjects[MAXOBJECTS];
int ActiveObjects[MAXOBJECTS];
int ActiveObjectCount;
Expand Down Expand Up @@ -100,17 +100,17 @@
NumberOfShrineTypes
};

enum {

Check warning on line 103 in Source/objects.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/objects.cpp:103:1 [performance-enum-size]

enum '(unnamed enum at /home/runner/work/DevilutionX/DevilutionX/Source/objects.cpp:103:1)' uses a larger base type ('unsigned int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size
// clang-format off
DOOR_CLOSED = 0,

Check warning on line 105 in Source/objects.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/objects.cpp:105:2 [readability-identifier-naming]

invalid case style for enum constant 'DOOR_CLOSED'
DOOR_OPEN = 1,

Check warning on line 106 in Source/objects.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/objects.cpp:106:2 [readability-identifier-naming]

invalid case style for enum constant 'DOOR_OPEN'
DOOR_BLOCKED = 2,

Check warning on line 107 in Source/objects.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/objects.cpp:107:2 [readability-identifier-naming]

invalid case style for enum constant 'DOOR_BLOCKED'
// clang-format on
};

int trapid;
int trapdir;
OptionalOwnedClxSpriteList pObjCels[40];

Check warning on line 113 in Source/objects.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/objects.cpp:113:1 [misc-include-cleaner]

no header providing "devilution::OptionalOwnedClxSpriteList" is directly included
object_graphic_id ObjFileList[40];
/** Specifies the number of active objects. */
int leverid;
Expand Down Expand Up @@ -228,7 +228,7 @@
N_(/* TRANSLATORS: Book Title */ "A Spellbook"),
};
/** Specifies the speech IDs of each dungeon type narrator book, for each player class. */
_speech_id StoryText[3][3] = {

Check warning on line 231 in Source/objects.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/objects.cpp:231:1 [misc-include-cleaner]

no header providing "devilution::_speech_id" is directly included
{ TEXT_BOOK11, TEXT_BOOK12, TEXT_BOOK13 },
{ TEXT_BOOK21, TEXT_BOOK22, TEXT_BOOK23 },
{ TEXT_BOOK31, TEXT_BOOK32, TEXT_BOOK33 }
Expand Down Expand Up @@ -2247,6 +2247,11 @@
}
}

int ClampU8(int v)
{
return std::clamp(v, 0, 255);
}

void OperateShrineMysterious(DiabloGenerator &rng, Player &player)
{
if (&player != MyPlayer)
Expand Down Expand Up @@ -2331,32 +2336,31 @@
if (&player != MyPlayer)
return;

// Increment armor class by 2 and decrements max damage by 1.
for (Item &item : PlayerItemsRange(player)) {
switch (item._itype) {
case ItemType::Sword:
case ItemType::Axe:
case ItemType::Bow:
case ItemType::Mace:
case ItemType::Staff:
item._iMaxDam--;
if (item._iMaxDam < item._iMinDam)
item._iMaxDam = item._iMinDam;
break;
case ItemType::Staff: {
const int minDam = static_cast<int>(item._iMinDam);
const int maxDam = static_cast<int>(item._iMaxDam);
const int newMax = std::max(maxDam - 1, minDam);
item._iMaxDam = static_cast<uint8_t>(ClampU8(newMax));
} break;
case ItemType::Shield:
case ItemType::Helm:
case ItemType::LightArmor:
case ItemType::MediumArmor:
case ItemType::HeavyArmor:
item._iAC += 2;
item._iAC = ClampU8(item._iAC + 2);
break;
default:
break;
}
}

CalcPlrInv(player, true);

InitDiabloMsg(EMSG_SHRINE_GLOOMY);
}

Expand Down
Loading