Browse Source

Item: Optimize to save 16 bytes (312->288)

pull/5390/head
Gleb Mazovetskiy 3 years ago
parent
commit
ac26f3a23b
  1. 2
      Source/itemdat.h
  2. 16
      Source/items.h
  3. 2
      Source/pack.cpp
  4. 2
      Source/pack.h

2
Source/itemdat.h

@ -355,7 +355,7 @@ enum class ItemSpecialEffect : uint32_t {
};
use_enum_as_flags(ItemSpecialEffect);
enum class ItemSpecialEffectHf : uint32_t {
enum class ItemSpecialEffectHf : uint8_t {
// clang-format off
None = 0,
Devastation = 1 << 0,

16
Source/items.h

@ -179,9 +179,9 @@ struct Item {
/** Randomly generated identifier */
int32_t _iSeed = 0;
uint16_t _iCreateInfo = 0;
enum ItemType _itype = ItemType::None;
Point position = { 0, 0 };
ItemType _itype = ItemType::None;
bool _iAnimFlag = false;
Point position = { 0, 0 };
/*
* @brief Contains Information for current Animation
*/
@ -193,8 +193,8 @@ struct Item {
item_quality _iMagical = ITEM_QUALITY_NORMAL;
char _iName[64] = {};
char _iIName[64] = {};
enum item_equip_type _iLoc = ILOC_NONE;
enum item_class _iClass = ICLASS_NONE;
item_equip_type _iLoc = ILOC_NONE;
item_class _iClass = ICLASS_NONE;
uint8_t _iCurs = 0;
int _ivalue = 0;
int _iIvalue = 0;
@ -202,8 +202,9 @@ struct Item {
uint8_t _iMaxDam = 0;
int16_t _iAC = 0;
ItemSpecialEffect _iFlags = ItemSpecialEffect::None;
enum item_misc_id _iMiscId = IMISC_NONE;
enum spell_id _iSpell = SPL_NULL;
item_misc_id _iMiscId = IMISC_NONE;
spell_id _iSpell = SPL_NULL;
_item_indexes IDidx = IDI_NONE;
int _iCharges = 0;
int _iMaxCharges = 0;
int _iDurability = 0;
@ -242,9 +243,8 @@ struct Item {
uint8_t _iMinMag = 0;
int8_t _iMinDex = 0;
bool _iStatFlag = false;
_item_indexes IDidx = IDI_NONE;
uint32_t dwBuff = 0;
ItemSpecialEffectHf _iDamAcFlags = ItemSpecialEffectHf::None;
uint32_t dwBuff = 0;
/**
* @brief Clears this item and returns the old value

2
Source/pack.cpp

@ -132,7 +132,7 @@ void PackPlayer(PlayerPack *pPack, const Player &player, bool manashield, bool n
pPack->wReflections = SDL_SwapLE16(player.wReflections);
pPack->pDifficulty = SDL_SwapLE32(player.pDifficulty);
pPack->pDamAcFlags = static_cast<ItemSpecialEffectHf>(SDL_SwapLE32(static_cast<uint32_t>(player.pDamAcFlags)));
pPack->pDamAcFlags = SDL_SwapLE32(static_cast<uint32_t>(player.pDamAcFlags));
pPack->pDiabloKillLevel = SDL_SwapLE32(player.pDiabloKillLevel);
pPack->bIsHellfire = gbIsHellfire ? 1 : 0;

2
Source/pack.h

@ -74,7 +74,7 @@ struct PlayerPack {
int16_t wReserved8; // For future use
uint32_t pDiabloKillLevel;
uint32_t pDifficulty;
ItemSpecialEffectHf pDamAcFlags;
uint32_t pDamAcFlags; // `ItemSpecialEffectHf` is 1 byte but this is 4 bytes.
/**@brief Only used in multiplayer sync (SendPlayerInfo/recv_plrinfo). Never used in save games (single- or multiplayer). */
uint8_t friendlyMode;
/**@brief Only used in multiplayer sync (SendPlayerInfo/recv_plrinfo). Never used in save games (single- or multiplayer). */

Loading…
Cancel
Save