Browse Source

baa

dyn-players-param2
Anders Jenbo 4 years ago
parent
commit
73fbadbbcb
  1. 28
      Source/multi.cpp
  2. 68
      Source/player.cpp
  3. 10
      Source/spells.cpp
  4. 2
      Source/sync.cpp
  5. 36
      test/inv_test.cpp
  6. 33
      test/pack_test.cpp
  7. 2
      test/path_test.cpp
  8. 8
      test/player_test.cpp

28
Source/multi.cpp

@ -196,11 +196,11 @@ void MonsterSeeds()
Monsters[i]._mAISeed = seed + i;
}
void HandleTurnUpperBit(int pnum)
void HandleTurnUpperBit(size_t pnum)
{
int i;
size_t i;
for (i = 0; i < MAX_PLRS; i++) {
for (i = 0; i < Players.size(); i++) {
if ((player_state[i] & PS_CONNECTED) != 0 && i != pnum)
break;
}
@ -225,7 +225,7 @@ void ParseTurn(int pnum, uint32_t turn)
}
}
void PlayerLeftMsg(int pnum, bool left)
void PlayerLeftMsg(size_t pnum, bool left)
{
if (pnum == MyPlayerId) {
return;
@ -263,7 +263,7 @@ void PlayerLeftMsg(int pnum, bool left)
void ClearPlayerLeftState()
{
for (int i = 0; i < MAX_PLRS; i++) {
for (size_t i = 0; i < Players.size(); i++) {
if (sgbPlayerLeftGameTbl[i]) {
if (gbBufferMsgs == 1)
msg_send_drop_pkt(i, sgdwPlayerLeftReasonTbl[i]);
@ -278,7 +278,7 @@ void ClearPlayerLeftState()
void CheckDropPlayer()
{
for (int i = 0; i < MAX_PLRS; i++) {
for (size_t i = 0; i < Players.size(); i++) {
if ((player_state[i] & PS_ACTIVE) == 0 && (player_state[i] & PS_CONNECTED) != 0) {
SNetDropPlayer(i, LEAVE_DROP);
}
@ -308,7 +308,7 @@ void BeginTimeout()
CheckDropPlayer();
}
void HandleAllPackets(int pnum, const byte *data, size_t size)
void HandleAllPackets(size_t pnum, const byte *data, size_t size)
{
for (unsigned offset = 0; offset < size;) {
int messageSize = ParseCmd(pnum, reinterpret_cast<const TCmd *>(&data[offset]));
@ -515,7 +515,7 @@ void multi_send_msg_packet(uint32_t pmask, const byte *data, size_t size)
pkt.hdr.wLen = static_cast<uint16_t>(len);
memcpy(pkt.body, data, size);
size_t playerID = 0;
for (size_t v = 1; playerID < MAX_PLRS; playerID++, v <<= 1) {
for (size_t v = 1; playerID < Players.size(); playerID++, v <<= 1) {
if ((v & pmask) != 0) {
if (!SNetSendMessage(playerID, &pkt.hdr, len) && SErrGetLastError() != STORM_ERROR_INVALID_PLAYER) {
nthread_terminate_game("SNetSendMessage");
@ -527,10 +527,10 @@ void multi_send_msg_packet(uint32_t pmask, const byte *data, size_t size)
void multi_msg_countdown()
{
for (int i = 0; i < MAX_PLRS; i++) {
for (size_t i = 0; i < Players.size(); i++) {
if ((player_state[i] & PS_TURN_ARRIVED) != 0) {
if (gdwMsgLenTbl[i] == sizeof(int32_t))
ParseTurn(i, *(int32_t *)glpMsgTbl[i]);
if (gdwMsgLenTbl[i] == sizeof(uint32_t))
ParseTurn(i, *(uint32_t *)glpMsgTbl[i]);
}
}
}
@ -590,7 +590,7 @@ void multi_process_network_packets()
ClearPlayerLeftState();
ProcessTmsgs();
int dwID = -1;
size_t dwID = std::numeric_limits<size_t>::max();
TPktHdr *pkt;
uint32_t dwMsgSize = 0;
while (SNetReceiveMessage(&dwID, (void **)&pkt, &dwMsgSize)) {
@ -658,7 +658,7 @@ void multi_process_network_packets()
CheckPlayerInfoTimeouts();
}
void multi_send_zero_packet(int pnum, _cmd_id bCmd, const byte *data, size_t size)
void multi_send_zero_packet(size_t pnum, _cmd_id bCmd, const byte *data, size_t size)
{
assert(pnum != MyPlayerId);
assert(data != nullptr);
@ -779,7 +779,7 @@ bool NetInit(bool bSinglePlayer)
return true;
}
void recv_plrinfo(int pnum, const TCmdPlrInfoHdr &header, bool recv)
void recv_plrinfo(size_t pnum, const TCmdPlrInfoHdr &header, bool recv)
{
static PlayerPack PackedPlayerBuffer[MAX_PLRS];

68
Source/player.cpp

@ -166,7 +166,7 @@ struct DirectionSettings {
DisplacementOf<int8_t> map;
ScrollDirection scrollDir;
PLR_MODE walkMode;
void (*walkModeHandler)(int, const DirectionSettings &);
void (*walkModeHandler)(size_t, const DirectionSettings &);
};
/** Specifies the frame of each animation for which an action is triggered, for each player class. */
@ -218,14 +218,14 @@ void PmChangeLightOff(Player &player)
ChangeLightOffset(player._plid, { x, y });
}
void WalkUpwards(int pnum, const DirectionSettings &walkParams)
void WalkUpwards(size_t pnum, const DirectionSettings &walkParams)
{
Player &player = Players[pnum];
dPlayer[player.position.future.x][player.position.future.y] = -(pnum + 1);
player.position.temp = WorldTilePosition { static_cast<WorldTileCoord>(walkParams.tileAdd.deltaX), static_cast<WorldTileCoord>(walkParams.tileAdd.deltaY) };
}
void WalkDownwards(int pnum, const DirectionSettings & /*walkParams*/)
void WalkDownwards(size_t pnum, const DirectionSettings & /*walkParams*/)
{
Player &player = Players[pnum];
dPlayer[player.position.tile.x][player.position.tile.y] = -(pnum + 1);
@ -237,7 +237,7 @@ void WalkDownwards(int pnum, const DirectionSettings & /*walkParams*/)
PmChangeLightOff(player);
}
void WalkSides(int pnum, const DirectionSettings &walkParams)
void WalkSides(size_t pnum, const DirectionSettings &walkParams)
{
Player &player = Players[pnum];
@ -314,7 +314,7 @@ bool PlrDirOK(const Player &player, Direction dir)
return true;
}
void HandleWalkMode(int pnum, Displacement vel, Direction dir)
void HandleWalkMode(size_t pnum, Displacement vel, Direction dir)
{
Player &player = Players[pnum];
const auto &dirModeParams = WalkSettings[static_cast<size_t>(dir)];
@ -354,7 +354,7 @@ void StartWalkAnimation(Player &player, Direction dir, bool pmWillBeCalled)
/**
* @brief Start moving a player to a new tile
*/
void StartWalk(int pnum, Displacement vel, Direction dir, bool pmWillBeCalled)
void StartWalk(size_t pnum, Displacement vel, Direction dir, bool pmWillBeCalled)
{
Player &player = Players[pnum];
@ -389,7 +389,7 @@ void ClearStateVariables(Player &player)
player.position.offset2 = { 0, 0 };
}
void StartWalkStand(int pnum)
void StartWalkStand(size_t pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("StartWalkStand: illegal player {}", pnum));
@ -433,7 +433,7 @@ void ChangeOffset(Player &player)
PmChangeLightOff(player);
}
void StartAttack(int pnum, Direction d)
void StartAttack(size_t pnum, Direction d)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("StartAttack: illegal player {}", pnum));
@ -465,7 +465,7 @@ void StartAttack(int pnum, Direction d)
SetPlayerOld(player);
}
void StartRangeAttack(int pnum, Direction d, WorldTileCoord cx, WorldTileCoord cy)
void StartRangeAttack(size_t pnum, Direction d, WorldTileCoord cx, WorldTileCoord cy)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("StartRangeAttack: illegal player {}", pnum));
@ -507,7 +507,7 @@ player_graphic GetPlayerGraphicForSpell(spell_id spellId)
}
}
void StartSpell(int pnum, Direction d, WorldTileCoord cx, WorldTileCoord cy)
void StartSpell(size_t pnum, Direction d, WorldTileCoord cx, WorldTileCoord cy)
{
if ((DWORD)pnum >= MAX_PLRS)
app_fatal(fmt::format("StartSpell: illegal player {}", pnum));
@ -531,7 +531,7 @@ void StartSpell(int pnum, Direction d, WorldTileCoord cx, WorldTileCoord cy)
SetPlayerOld(player);
player.position.temp = WorldTilePosition { cx, cy };
player.spellLevel = GetSpellLevel(pnum, player._pSpell);
player.spellLevel = GetSpellLevel(player, player._pSpell);
}
void RespawnDeadItem(Item &&itm, Point target)
@ -610,7 +610,7 @@ void DropHalfPlayersGold(Player &player)
player._pGold /= 2;
}
void InitLevelChange(int pnum)
void InitLevelChange(size_t pnum)
{
Player &player = Players[pnum];
Player &myPlayer = *MyPlayer;
@ -649,7 +649,7 @@ void InitLevelChange(int pnum)
/**
* @brief Continue movement towards new tile
*/
bool DoWalk(int pnum, int variant)
bool DoWalk(size_t pnum, int variant)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("PM_DoWalk: illegal player {}", pnum));
@ -800,7 +800,7 @@ bool DamageWeapon(Player &player, int durrnd)
return false;
}
bool PlrHitMonst(int pnum, int m, bool adjacentDamage = false)
bool PlrHitMonst(size_t pnum, size_t m, bool adjacentDamage = false)
{
int hper = 0;
@ -1065,7 +1065,7 @@ bool PlrHitObj(int pnum, Object &targetObject)
return false;
}
bool DoAttack(int pnum)
bool DoAttack(size_t pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("PM_DoAttack: illegal player {}", pnum));
@ -1174,7 +1174,7 @@ bool DoAttack(int pnum)
return false;
}
bool DoRangeAttack(int pnum)
bool DoRangeAttack(size_t pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("PM_DoRangeAttack: illegal player {}", pnum));
@ -1274,7 +1274,7 @@ void DamageParryItem(Player &player)
}
}
bool DoBlock(int pnum)
bool DoBlock(size_t pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("PM_DoBlock: illegal player {}", pnum));
@ -1335,7 +1335,7 @@ void DamageArmor(Player &player)
CalcPlrInv(player, true);
}
bool DoSpell(int pnum)
bool DoSpell(size_t pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("PM_DoSpell: illegal player {}", pnum));
@ -1366,7 +1366,7 @@ bool DoSpell(int pnum)
return false;
}
bool DoGotHit(int pnum)
bool DoGotHit(size_t pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("PM_DoGotHit: illegal player {}", pnum));
@ -1414,7 +1414,7 @@ bool IsPlayerAdjacentToObject(Player &player, Object &object)
return x <= 1 && y <= 1;
}
void CheckNewPath(int pnum, bool pmWillBeCalled)
void CheckNewPath(size_t pnum, bool pmWillBeCalled)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("CheckNewPath: illegal player {}", pnum));
@ -2853,7 +2853,7 @@ void FixPlayerLocation(Player &player, Direction bDir)
ChangeVisionXY(player._pvid, player.position.tile);
}
void StartStand(int pnum, Direction dir)
void StartStand(size_t pnum, Direction dir)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("StartStand: illegal player {}", pnum));
@ -2873,7 +2873,7 @@ void StartStand(int pnum, Direction dir)
SetPlayerOld(player);
}
void StartPlrBlock(int pnum, Direction dir)
void StartPlrBlock(size_t pnum, Direction dir)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("StartPlrBlock: illegal player {}", pnum));
@ -2899,7 +2899,7 @@ void StartPlrBlock(int pnum, Direction dir)
SetPlayerOld(player);
}
void FixPlrWalkTags(int pnum)
void FixPlrWalkTags(size_t pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("FixPlrWalkTags: illegal player {}", pnum));
@ -2919,7 +2919,7 @@ void FixPlrWalkTags(int pnum)
}
}
void RemovePlrFromMap(int pnum)
void RemovePlrFromMap(size_t pnum)
{
int pp = pnum + 1;
int pn = -(pnum + 1);
@ -2931,7 +2931,7 @@ void RemovePlrFromMap(int pnum)
}
}
void StartPlrHit(int pnum, int dam, bool forcehit)
void StartPlrHit(size_t pnum, int dam, bool forcehit)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("StartPlrHit: illegal player {}", pnum));
@ -2983,7 +2983,7 @@ void StartPlrHit(int pnum, int dam, bool forcehit)
__attribute__((no_sanitize("shift-base")))
#endif
void
StartPlayerKill(int pnum, int earflag)
StartPlayerKill(size_t pnum, int earflag)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("StartPlayerKill: illegal player {}", pnum));
@ -3103,7 +3103,7 @@ void StripTopGold(Player &player)
player._pGold = CalculateGold(player);
}
void ApplyPlrDamage(int pnum, int dam, int minHP /*= 0*/, int frac /*= 0*/, int earflag /*= 0*/)
void ApplyPlrDamage(size_t pnum, int dam, int minHP /*= 0*/, int frac /*= 0*/, int earflag /*= 0*/)
{
Player &player = Players[pnum];
@ -3150,7 +3150,7 @@ void ApplyPlrDamage(int pnum, int dam, int minHP /*= 0*/, int frac /*= 0*/, int
}
}
void SyncPlrKill(int pnum, int earflag)
void SyncPlrKill(size_t pnum, int earflag)
{
Player &player = Players[pnum];
@ -3163,7 +3163,7 @@ void SyncPlrKill(int pnum, int earflag)
StartPlayerKill(pnum, earflag);
}
void RemovePlrMissiles(int pnum)
void RemovePlrMissiles(size_t pnum)
{
if (leveltype != DTYPE_TOWN && pnum == MyPlayerId) {
auto &golem = Monsters[MyPlayerId];
@ -3189,7 +3189,7 @@ void RemovePlrMissiles(int pnum)
__attribute__((no_sanitize("shift-base")))
#endif
void
StartNewLvl(int pnum, interface_mode fom, int lvl)
StartNewLvl(size_t pnum, interface_mode fom, int lvl)
{
InitLevelChange(pnum);
@ -3255,7 +3255,7 @@ void RestartTownLvl(int pnum)
}
}
void StartWarpLvl(int pnum, int pidx)
void StartWarpLvl(size_t pnum, uint16_t pidx)
{
Player &player = Players[pnum];
@ -3592,7 +3592,7 @@ void SyncPlrAnim(Player &player)
ScrollViewPort(player, WalkSettings[static_cast<size_t>(player._pdir)].scrollDir);
}
void SyncInitPlrPos(int pnum)
void SyncInitPlrPos(size_t pnum)
{
Player &player = Players[pnum];
@ -3627,7 +3627,7 @@ void SyncInitPlrPos(int pnum)
}
}
void SyncInitPlr(int pnum)
void SyncInitPlr(size_t pnum)
{
if ((DWORD)pnum >= MAX_PLRS) {
app_fatal(fmt::format("SyncInitPlr: illegal player {}", pnum));
@ -3851,7 +3851,7 @@ void PlayDungMsgs()
}
#ifdef BUILD_TESTING
bool TestPlayerDoGotHit(int pnum)
bool TestPlayerDoGotHit(size_t pnum)
{
return DoGotHit(pnum);
}

10
Source/spells.cpp

@ -64,7 +64,7 @@ void ClearReadiedSpell(Player &player)
}
}
void PlacePlayer(int pnum)
void PlacePlayer(size_t pnum)
{
Player &player = Players[pnum];
@ -166,7 +166,7 @@ int GetManaAmount(Player &player, spell_id sn)
return ma;
}
void UseMana(int id, spell_id sn)
void UseMana(size_t id, spell_id sn)
{
int ma; // mana cost
@ -220,11 +220,11 @@ SpellCheckResult CheckSpell(int id, spell_id sn, spell_type st, bool manaonly)
return SpellCheckResult::Success;
}
if (GetSpellLevel(id, sn) <= 0) {
Player &player = Players[id];
if (GetSpellLevel(player, sn) <= 0) {
return SpellCheckResult::Fail_Level0;
}
Player &player = Players[id];
if (player._pMana < GetManaAmount(player, sn)) {
return SpellCheckResult::Fail_NoMana;
}
@ -254,7 +254,7 @@ void CastSpell(int id, spell_id spl, int sx, int sy, int dx, int dy, int spllvl)
}
}
void DoResurrect(int pnum, uint16_t rid)
void DoResurrect(size_t pnum, size_t rid)
{
if ((DWORD)pnum >= MAX_PLRS || rid >= MAX_PLRS) {
return;

2
Source/sync.cpp

@ -286,7 +286,7 @@ uint32_t sync_all_monsters(byte *pbBuf, uint32_t dwMaxLen)
return dwMaxLen;
}
uint32_t OnSyncData(const TCmd *pCmd, int pnum)
uint32_t OnSyncData(const TCmd *pCmd, size_t pnum)
{
const auto &header = *reinterpret_cast<const TSyncHeader *>(pCmd);

36
test/inv_test.cpp

@ -4,7 +4,17 @@
#include "inv.h"
#include "player.h"
using namespace devilution;
namespace devilution {
namespace {
class InvTest : public ::testing::Test {
public:
void SetUp() override
{
Players.resize(1);
MyPlayer = &Players[0];
}
};
/* Set up a given item as a spell scroll, allowing for its usage. */
void set_up_scroll(Item &item, spell_id spell)
@ -28,7 +38,7 @@ void clear_inventory()
}
// Test that the scroll is used in the inventory in correct conditions
TEST(Inv, UseScroll_from_inventory)
TEST_F(InvTest, UseScroll_from_inventory)
{
set_up_scroll(MyPlayer->InvList[2], SPL_FIREBOLT);
MyPlayer->_pNumInv = 5;
@ -36,14 +46,14 @@ TEST(Inv, UseScroll_from_inventory)
}
// Test that the scroll is used in the belt in correct conditions
TEST(Inv, UseScroll_from_belt)
TEST_F(InvTest, UseScroll_from_belt)
{
set_up_scroll(MyPlayer->SpdList[2], SPL_FIREBOLT);
EXPECT_TRUE(UseScroll(MyPlayer->_pRSpell));
}
// Test that the scroll is not used in the inventory for each invalid condition
TEST(Inv, UseScroll_from_inventory_invalid_conditions)
TEST_F(InvTest, UseScroll_from_inventory_invalid_conditions)
{
// Empty the belt to prevent using a scroll from the belt
for (int i = 0; i < MAXBELTITEMS; i++) {
@ -72,7 +82,7 @@ TEST(Inv, UseScroll_from_inventory_invalid_conditions)
}
// Test that the scroll is not used in the belt for each invalid condition
TEST(Inv, UseScroll_from_belt_invalid_conditions)
TEST_F(InvTest, UseScroll_from_belt_invalid_conditions)
{
// Disable the inventory to prevent using a scroll from the inventory
MyPlayer->_pNumInv = 0;
@ -99,7 +109,7 @@ TEST(Inv, UseScroll_from_belt_invalid_conditions)
}
// Test gold calculation
TEST(Inv, CalculateGold)
TEST_F(InvTest, CalculateGold)
{
MyPlayer->_pNumInv = 10;
// Set up 4 slots of gold in the inventory
@ -117,7 +127,7 @@ TEST(Inv, CalculateGold)
}
// Test automatic gold placing
TEST(Inv, GoldAutoPlace)
TEST_F(InvTest, GoldAutoPlace)
{
// Empty the inventory
clear_inventory();
@ -139,7 +149,7 @@ TEST(Inv, GoldAutoPlace)
}
// Test removing an item from inventory with no other items.
TEST(Inv, RemoveInvItem)
TEST_F(InvTest, RemoveInvItem)
{
clear_inventory();
// Put a two-slot misc item into the inventory:
@ -156,7 +166,7 @@ TEST(Inv, RemoveInvItem)
}
// Test removing an item from inventory with other items in it.
TEST(Inv, RemoveInvItem_other_item)
TEST_F(InvTest, RemoveInvItem_other_item)
{
clear_inventory();
// Put a two-slot misc item and a ring into the inventory:
@ -178,7 +188,7 @@ TEST(Inv, RemoveInvItem_other_item)
}
// Test removing an item from the belt
TEST(Inv, RemoveSpdBarItem)
TEST_F(InvTest, RemoveSpdBarItem)
{
// Clear the belt
for (int i = 0; i < MAXBELTITEMS; i++) {
@ -192,7 +202,7 @@ TEST(Inv, RemoveSpdBarItem)
}
// Test removing a scroll from the inventory
TEST(Inv, RemoveCurrentSpellScroll_inventory)
TEST_F(InvTest, RemoveCurrentSpellScroll_inventory)
{
clear_inventory();
@ -209,7 +219,7 @@ TEST(Inv, RemoveCurrentSpellScroll_inventory)
}
// Test removing a scroll from the belt
TEST(Inv, RemoveCurrentSpellScroll_belt)
TEST_F(InvTest, RemoveCurrentSpellScroll_belt)
{
// Clear the belt
for (int i = 0; i < MAXBELTITEMS; i++) {
@ -225,7 +235,7 @@ TEST(Inv, RemoveCurrentSpellScroll_belt)
EXPECT_TRUE(MyPlayer->SpdList[3].isEmpty());
}
TEST(Inv, ItemSize)
TEST_F(InvTest, ItemSize)
{
Item testItem {};

33
test/pack_test.cpp

@ -332,7 +332,16 @@ const TestItemStruct DiabloItems[] = {
// clang-format on
};
TEST(PackTest, UnPackItem_diablo)
class PackTest : public ::testing::Test {
public:
void SetUp() override
{
Players.resize(1);
MyPlayer = &Players[0];
}
};
TEST_F(PackTest, UnPackItem_diablo)
{
Item id;
ItemPack is;
@ -353,7 +362,7 @@ TEST(PackTest, UnPackItem_diablo)
}
}
TEST(PackTest, UnPackItem_diablo_unique_bug)
TEST_F(PackTest, UnPackItem_diablo_unique_bug)
{
ItemPack pkItemBug = { 6, 911, 14, 5, 60, 60, 0, 0, 0, 0 }; // Veil of Steel - with morph bug
ItemPack pkItem = { 6, 655, 14, 5, 60, 60, 0, 0, 0, 0 }; // Veil of Steel - fixed
@ -403,7 +412,7 @@ const TestItemStruct SpawnItems[] = {
// clang-format on
};
TEST(PackTest, UnPackItem_spawn)
TEST_F(PackTest, UnPackItem_spawn)
{
Item id;
ItemPack is;
@ -447,7 +456,7 @@ const TestItemStruct DiabloMPItems[] = {
// clang-format on
};
TEST(PackTest, UnPackItem_diablo_multiplayer)
TEST_F(PackTest, UnPackItem_diablo_multiplayer)
{
Item id;
ItemPack is;
@ -660,7 +669,7 @@ const TestItemStruct HellfireItems[] = {
// clang-format on
};
TEST(PackTest, UnPackItem_hellfire)
TEST_F(PackTest, UnPackItem_hellfire)
{
Item id;
ItemPack is;
@ -682,7 +691,7 @@ TEST(PackTest, UnPackItem_hellfire)
}
}
TEST(PackTest, UnPackItem_diablo_strip_hellfire_items)
TEST_F(PackTest, UnPackItem_diablo_strip_hellfire_items)
{
ItemPack is = { 1478792102, 259, 92, 0, 0, 0, 0, 0, 0, 0 }; // Scroll of Search
Item id;
@ -696,7 +705,7 @@ TEST(PackTest, UnPackItem_diablo_strip_hellfire_items)
ASSERT_EQ(id._itype, ItemType::None);
}
TEST(PackTest, UnPackItem_empty)
TEST_F(PackTest, UnPackItem_empty)
{
ItemPack is = { 0, 0, 0xFFFF, 0, 0, 0, 0, 0, 0, 0 };
Item id;
@ -706,7 +715,7 @@ TEST(PackTest, UnPackItem_empty)
ASSERT_EQ(id._itype, ItemType::None);
}
TEST(PackTest, PackItem_empty)
TEST_F(PackTest, PackItem_empty)
{
ItemPack is;
Item id = {};
@ -737,25 +746,25 @@ static void compareGold(const ItemPack &is, int iCurs)
ComparePackedItems(is, is2);
}
TEST(PackTest, UnPackItem_gold_small)
TEST_F(PackTest, UnPackItem_gold_small)
{
ItemPack is = { 0, 0, IDI_GOLD, 0, 0, 0, 0, 0, 1000, 0 };
compareGold(is, ICURS_GOLD_SMALL);
}
TEST(PackTest, UnPackItem_gold_medium)
TEST_F(PackTest, UnPackItem_gold_medium)
{
ItemPack is = { 0, 0, IDI_GOLD, 0, 0, 0, 0, 0, 1001, 0 };
compareGold(is, ICURS_GOLD_MEDIUM);
}
TEST(PackTest, UnPackItem_gold_large)
TEST_F(PackTest, UnPackItem_gold_large)
{
ItemPack is = { 0, 0, IDI_GOLD, 0, 0, 0, 0, 0, 2500, 0 };
compareGold(is, ICURS_GOLD_LARGE);
}
TEST(PackTest, UnPackItem_ear)
TEST_F(PackTest, UnPackItem_ear)
{
ItemPack is = { 1633955154, 17509, 23, 111, 103, 117, 101, 68, 19843, 0 };
Item id;

2
test/path_test.cpp

@ -110,7 +110,7 @@ void CheckPath(Point startPosition, Point destinationPosition, std::vector<int8_
// Die early if the wrong path length is returned as we don't want to read oob in expectedSteps
ASSERT_LE(pathLength, expectedSteps.size()) << "Path is longer than expected.";
for (auto i = 0; i < pathLength; i++) {
for (int i = 0; i < pathLength; i++) {
EXPECT_EQ(pathSteps[i], expectedSteps[i]) << "Path step " << i << " differs from expectation for a path from "
<< startPosition << " to " << destinationPosition; // this shouldn't be a requirement but...

8
test/player_test.cpp

@ -5,10 +5,10 @@
using namespace devilution;
namespace devilution {
extern bool TestPlayerDoGotHit(int pnum);
extern bool TestPlayerDoGotHit(size_t pnum);
}
int RunBlockTest(int frames, ItemSpecialEffect flags)
size_t RunBlockTest(int frames, ItemSpecialEffect flags)
{
int pnum = 0;
Player &player = Players[pnum];
@ -17,7 +17,7 @@ int RunBlockTest(int frames, ItemSpecialEffect flags)
player._pIFlags = flags;
StartPlrHit(pnum, 5, false);
int i = 1;
size_t i = 1;
for (; i < 100; i++) {
TestPlayerDoGotHit(pnum);
if (player._pmode != PM_GOTHIT)
@ -42,7 +42,7 @@ constexpr int Rogue = 7;
constexpr int Sorcerer = 8;
struct BlockTestCase {
int expectedRecoveryFrame;
size_t expectedRecoveryFrame;
int maxRecoveryFrame;
ItemSpecialEffect itemFlags;
};

Loading…
Cancel
Save