Skip to content
Merged
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
7 changes: 4 additions & 3 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifdef USE_SDL3
#include <SDL3/SDL_timer.h>
#else
#include <SDL.h>

Check warning on line 25 in Source/items.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/items.cpp:25:1 [misc-include-cleaner]

included header SDL.h is not used directly
#endif

#include <fmt/core.h>
Expand Down Expand Up @@ -97,7 +97,7 @@
Item Items[MAXITEMS + 1];
uint8_t ActiveItems[MAXITEMS];
uint8_t ActiveItemCount;
int8_t dItem[MAXDUNX][MAXDUNY];

Check warning on line 100 in Source/items.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/items.cpp:100:23 [readability-math-missing-parentheses]

'*' has higher precedence than '+'; add parentheses to explicitly specify the order of operations

Check warning on line 100 in Source/items.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/items.cpp:100:14 [readability-math-missing-parentheses]

'*' has higher precedence than '+'; add parentheses to explicitly specify the order of operations
bool ShowUniqueItemInfoBox;
CornerStoneStruct CornerStone;
bool UniqueItemFlags[128];
Expand Down Expand Up @@ -461,7 +461,7 @@
const Point position = GetRandomAvailableItemPosition();
item.position = position;

dItem[position.x][position.y] = ii + 1;

Check warning on line 464 in Source/items.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/items.cpp:464:35 [bugprone-narrowing-conversions]

narrowing conversion from 'int' to signed type 'int8_t' (aka 'signed char') is implementation-defined

item._iSeed = AdvanceRndSeed();
SetRndSeed(item._iSeed);
Expand Down Expand Up @@ -529,7 +529,7 @@
bool isValid = IsItemValid(player, equipment);

if (currstr < equipment._iMinStr
|| currmag < equipment._iMinMag

Check warning on line 532 in Source/items.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/items.cpp:532:11 [modernize-use-integer-sign-comparison]

comparison between 'signed' and 'unsigned' integers
|| currdex < equipment._iMinDex)
isValid = false;

Expand Down Expand Up @@ -698,22 +698,22 @@
}
}

int SaveItemPower(const Player &player, Item &item, ItemPower &power)

Check warning on line 701 in Source/items.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/items.cpp:701:5 [readability-function-cognitive-complexity]

function 'SaveItemPower' has cognitive complexity of 26 (threshold 25)
{
int r = RndPL(power.param1, power.param2);

switch (power.type) {
case IPL_TOHIT:
item._iPLToHit += static_cast<int16_t>(r);

Check warning on line 707 in Source/items.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/items.cpp:707:21 [bugprone-narrowing-conversions]

narrowing conversion from 'int' to signed type 'int16_t' (aka 'short') is implementation-defined
break;
case IPL_TOHIT_CURSE:
item._iPLToHit -= static_cast<int16_t>(r);

Check warning on line 710 in Source/items.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/items.cpp:710:21 [bugprone-narrowing-conversions]

narrowing conversion from 'int' to signed type 'int16_t' (aka 'short') is implementation-defined
break;
case IPL_DAMP:
item._iPLDam += static_cast<int16_t>(r);

Check warning on line 713 in Source/items.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/items.cpp:713:19 [bugprone-narrowing-conversions]

narrowing conversion from 'int' to signed type 'int16_t' (aka 'short') is implementation-defined
break;
case IPL_DAMP_CURSE:
item._iPLDam -= static_cast<int16_t>(r);

Check warning on line 716 in Source/items.cpp

View workflow job for this annotation

GitHub Actions / tidy-check

Source/items.cpp:716:19 [bugprone-narrowing-conversions]

narrowing conversion from 'int' to signed type 'int16_t' (aka 'short') is implementation-defined
break;
case IPL_DOPPELGANGER:
item._iDamAcFlags |= ItemSpecialEffectHf::Doppelganger;
Expand Down Expand Up @@ -2536,13 +2536,14 @@
}

void CalcPlrLightRadius(Player &player, int lrad)

{
lrad = std::clamp(lrad, 2, 15);

if (player._pLightRad != lrad) {
ChangeLightRadius(player.lightId, lrad);
ChangeVisionRadius(player.getId(), lrad);
if (player.isOnActiveLevel()) {
ChangeLightRadius(player.lightId, lrad);
ChangeVisionRadius(player.getId(), lrad);
}
player._pLightRad = lrad;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2492,6 +2492,8 @@ void InitPlayer(Player &player, bool firstTime)
player.wReflections = 0;
}

player.lightId = NO_LIGHT;

if (player.isOnActiveLevel()) {

SetPlrAnims(player);
Expand Down Expand Up @@ -2523,8 +2525,6 @@ void InitPlayer(Player &player, bool firstTime)
if (&player == MyPlayer) {
player.lightId = AddLight(player.position.tile, player._pLightRad);
ChangeLightXY(player.lightId, player.position.tile); // fix for a bug where old light is still visible at the entrance after reentering level
} else {
player.lightId = NO_LIGHT;
}
ActivateVision(player.position.tile, player._pLightRad, player.getId());
}
Expand Down
Loading