[General] Change enum QuickKey::QUICKKEY_TYPE to enum class

sol2-server-rewrite
Koncord 7 years ago
parent 2019128d92
commit 5777759aae

@ -189,7 +189,7 @@ QuickKey QuickKeys::getQuickKey(int id) const
return QuickKey(player->quickKeyChanges.quickKeys.at(id)); return QuickKey(player->quickKeyChanges.quickKeys.at(id));
} }
void QuickKeys::setQuickKey(int id, QuickKey quickKey) void QuickKeys::setQuickKey(int id, const QuickKey &quickKey)
{ {
player->quickKeyChanges.quickKeys.at(id) = quickKey.quickKey; player->quickKeyChanges.quickKeys.at(id) = quickKey.quickKey;
changed = true; changed = true;
@ -230,12 +230,12 @@ void QuickKey::setSlot(unsigned short slot)
quickKey.slot = slot; quickKey.slot = slot;
} }
int QuickKey::getType() const mwmp::QuickKey::Type QuickKey::getType() const
{ {
return quickKey.type; return quickKey.type;
} }
void QuickKey::setType(int type) void QuickKey::setType(mwmp::QuickKey::Type type)
{ {
quickKey.type = type; quickKey.type = type;
} }

@ -76,14 +76,13 @@ public:
void update(); void update();
void addQuickKey(QuickKey quickKey); void addQuickKey(const QuickKey &quickKey);
QuickKey getQuickKey(int id) const; QuickKey getQuickKey(int id) const;
void setQuickKey(int id, QuickKey quickKey); void setQuickKey(int id, const QuickKey &quickKey);
size_t size() const; size_t size() const;
void clear(); void clear();
private: private:
mwmp::QuickKey tempQuickKey;
Player *player; Player *player;
bool changed; bool changed;
}; };

@ -128,7 +128,7 @@ namespace MWGui
*/ */
if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen() && !mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys) if (mwmp::Main::get().getLocalPlayer()->hasFinishedCharGen() && !mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys)
{ {
mwmp::Main::get().getLocalPlayer()->sendQuickKey(index, Type_Unassigned); mwmp::Main::get().getLocalPlayer()->sendQuickKey(index, mwmp::QuickKey::Type::Unassigned);
} }
/* /*
End of tes3mp addition End of tes3mp addition
@ -235,7 +235,7 @@ namespace MWGui
Send a PLAYER_QUICKKEYS packet whenever a key is assigned to an item Send a PLAYER_QUICKKEYS packet whenever a key is assigned to an item
*/ */
if (!mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys) if (!mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys)
mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelectedIndex, Type_Item, item.getCellRef().getRefId()); mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelectedIndex, mwmp::QuickKey::Type::Item, item.getCellRef().getRefId());
/* /*
End of tes3mp addition End of tes3mp addition
*/ */
@ -270,7 +270,7 @@ namespace MWGui
Send a PLAYER_QUICKKEYS packet whenever a key is assigned to an item's magic Send a PLAYER_QUICKKEYS packet whenever a key is assigned to an item's magic
*/ */
if (!mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys) if (!mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys)
mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelectedIndex, Type_MagicItem, item.getCellRef().getRefId()); mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelectedIndex, mwmp::QuickKey::Type::MagicItem, item.getCellRef().getRefId());
/* /*
End of tes3mp addition End of tes3mp addition
*/ */
@ -315,7 +315,7 @@ namespace MWGui
Send a PLAYER_QUICKKEYS packet whenever a key is assigned to a spell Send a PLAYER_QUICKKEYS packet whenever a key is assigned to a spell
*/ */
if (!mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys) if (!mwmp::Main::get().getLocalPlayer()->isReceivingQuickKeys)
mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelectedIndex, Type_Magic, spellId); mwmp::Main::get().getLocalPlayer()->sendQuickKey(mSelectedIndex, mwmp::QuickKey::Type::Magic, spellId);
/* /*
End of tes3mp addition End of tes3mp addition
*/ */

@ -1032,9 +1032,9 @@ void LocalPlayer::setQuickKeys()
for (const auto &quickKey : quickKeyChanges.quickKeys) for (const auto &quickKey : quickKeyChanges.quickKeys)
{ {
LOG_APPEND(Log::LOG_INFO, "- slot: %i, type: %i, itemId: %s", quickKey.slot, quickKey.type, quickKey.itemId.c_str()); LOG_APPEND(Log::LOG_INFO, "- slot: %i, type: %i, itemId: %s", quickKey.slot, (int)quickKey.type, quickKey.itemId.c_str());
if (quickKey.type == QuickKey::ITEM || quickKey.type == QuickKey::ITEM_MAGIC) if (quickKey.type == QuickKey::Type::Item || quickKey.type == QuickKey::Type::MagicItem)
{ {
MWWorld::InventoryStore &ptrInventory = ptrPlayer.getClass().getInventoryStore(ptrPlayer); MWWorld::InventoryStore &ptrInventory = ptrPlayer.getClass().getInventoryStore(ptrPlayer);
@ -1043,18 +1043,16 @@ void LocalPlayer::setQuickKeys()
}); });
if (it != ptrInventory.end()) if (it != ptrInventory.end())
MWBase::Environment::get().getWindowManager()->setQuickKey(quickKey.slot, quickKey.type, (*it)); MWBase::Environment::get().getWindowManager()->setQuickKey(quickKey.slot, (int) quickKey.type, *it);
} }
else if (quickKey.type == QuickKey::MAGIC) else if (quickKey.type == QuickKey::Type::Magic)
{ {
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells(); MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
bool hasSpell = false; bool hasSpell = false;
MWMechanics::Spells::TIterator iter = ptrSpells.begin(); for (const auto &ptrSpell : ptrSpells)
for (; iter != ptrSpells.end(); iter++)
{ {
const ESM::Spell *spell = iter->first; if (Misc::StringUtils::ciEqual(ptrSpell.first->mId, quickKey.itemId))
if (Misc::StringUtils::ciEqual(spell->mId, quickKey.itemId))
{ {
hasSpell = true; hasSpell = true;
break; break;
@ -1062,10 +1060,10 @@ void LocalPlayer::setQuickKeys()
} }
if (hasSpell) if (hasSpell)
MWBase::Environment::get().getWindowManager()->setQuickKey(quickKey.slot, quickKey.type, 0, quickKey.itemId); MWBase::Environment::get().getWindowManager()->setQuickKey(quickKey.slot, (int) quickKey.type, 0, quickKey.itemId);
} }
else else
MWBase::Environment::get().getWindowManager()->setQuickKey(quickKey.slot, quickKey.type, 0); MWBase::Environment::get().getWindowManager()->setQuickKey(quickKey.slot, (int) quickKey.type, 0);
} }
isReceivingQuickKeys = false; isReceivingQuickKeys = false;
@ -1274,17 +1272,17 @@ void LocalPlayer::sendSpellRemoval(const ESM::Spell &spell)
*/ */
} }
void LocalPlayer::sendQuickKey(unsigned short slot, int type, const std::string& itemId) void LocalPlayer::sendQuickKey(int slot, QuickKey::Type type, const std::string& itemId)
{ {
quickKeyChanges.quickKeys.clear(); quickKeyChanges.quickKeys.clear();
mwmp::QuickKey quickKey; mwmp::QuickKey quickKey;
quickKey.slot = slot; quickKey.slot = static_cast<unsigned short>(slot);
quickKey.type = type; quickKey.type = type;
quickKey.itemId = itemId; quickKey.itemId = itemId;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_QUICKKEYS", itemId.c_str()); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_QUICKKEYS", itemId.c_str());
LOG_APPEND(Log::LOG_INFO, "- slot: %i, type: %i, itemId: %s", quickKey.slot, quickKey.type, quickKey.itemId.c_str()); LOG_APPEND(Log::LOG_INFO, "- slot: %i, type: %i, itemId: %s", quickKey.slot, (int) quickKey.type, quickKey.itemId.c_str());
quickKeyChanges.quickKeys.push_back(quickKey); quickKeyChanges.quickKeys.push_back(quickKey);

@ -74,7 +74,7 @@ namespace mwmp
void sendSpellAddition(const ESM::Spell &spell); void sendSpellAddition(const ESM::Spell &spell);
void sendSpellRemoval(std::string id); void sendSpellRemoval(std::string id);
void sendSpellRemoval(const ESM::Spell &spell); void sendSpellRemoval(const ESM::Spell &spell);
void sendQuickKey(unsigned short slot, int type, const std::string& itemId = ""); void sendQuickKey(int slot, QuickKey::Type type, const std::string& itemId = "");
void sendJournalEntry(const std::string& quest, int index, const MWWorld::Ptr& actor); void sendJournalEntry(const std::string& quest, int index, const MWWorld::Ptr& actor);
void sendJournalIndex(const std::string& quest, int index); void sendJournalIndex(const std::string& quest, int index);
void sendFactionRank(const std::string& factionId, int rank); void sendFactionRank(const std::string& factionId, int rank);

@ -85,16 +85,16 @@ namespace mwmp
{ {
std::string itemId; std::string itemId;
enum QUICKKEY_TYPE enum class Type : uint8_t
{ {
ITEM = 0, Item = 0,
MAGIC = 1, Magic,
ITEM_MAGIC = 2, MagicItem,
UNASSIGNED = 3 Unassigned
}; };
unsigned short slot; unsigned short slot;
int type; Type type;
}; };
struct CellState struct CellState

@ -25,7 +25,7 @@ void PacketPlayerQuickKeys::Packet(RakNet::BitStream *bs, bool send)
RW(quickKey.type, send); RW(quickKey.type, send);
RW(quickKey.slot, send); RW(quickKey.slot, send);
if (quickKey.type != QuickKey::UNASSIGNED) if (quickKey.type != QuickKey::Type::Unassigned)
RW(quickKey.itemId, send); RW(quickKey.itemId, send);
} }
} }

Loading…
Cancel
Save