Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 3 additions & 12 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 @@ -2524,21 +2524,12 @@
}
}

int maxBase = player._pMaxManaBase;

if (maxBase < 0) {
// Fix bugged state; do not turn this into a "negative penalty" mana boost.
if (player._pMaxManaBase < 0)
player._pMaxManaBase = 0;
maxBase = 0;
}

const int penalty = maxBase / 10; // 10% of max base mana (>= 0)

player._pMaxManaBase -= penalty; // will remain >= 0
player._pManaBase -= penalty; // may go negative, allowed
player._pMaxMana -= penalty; // may go negative, allowed
player._pMana -= penalty; // may go negative, allowed
const int penalty = player._pMaxManaBase / 10;

ModifyPlrManaCapacity(player, -penalty, true);
RedrawEverything();
InitDiabloMsg(message);
}
Expand Down
19 changes: 19 additions & 0 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3372,6 +3372,25 @@ void ModifyPlrVit(Player &player, int l)
}
}

void ModifyPlrManaCapacity(Player &player, int delta, bool shiftCurrent)
{
constexpr int MinManaBase = 0;

const int newMaxBase = std::max(MinManaBase, player._pMaxManaBase + delta);
const int applied = newMaxBase - player._pMaxManaBase;

player._pMaxManaBase = newMaxBase;
player._pMaxMana += applied;

if (shiftCurrent) {
player._pManaBase += applied;
player._pMana += applied;
} else {
player._pManaBase = std::min(player._pManaBase, player._pMaxManaBase);
player._pMana = std::min(player._pMana, player._pMaxMana);
}
}

void SetPlayerHitPoints(Player &player, int val)
{
player._pHitPoints = val;
Expand Down
1 change: 1 addition & 0 deletions Source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ void ModifyPlrStr(Player &player, int l);
void ModifyPlrMag(Player &player, int l);
void ModifyPlrDex(Player &player, int l);
void ModifyPlrVit(Player &player, int l);
void ModifyPlrManaCapacity(Player &player, int delta, bool shiftCurrent);
void SetPlayerHitPoints(Player &player, int val);
void SetPlrStr(Player &player, int v);
void SetPlrMag(Player &player, int v);
Expand Down
Loading