[General] Change regular enums to enum class

pull/367/head
Koncord 7 years ago
parent 8f5d31cb03
commit c4949ac5d9

@ -140,7 +140,7 @@ void CellController::update(Player *player)
{
for (auto cell : player->cellStateChanges.cellStates)
{
if (cell.type == mwmp::CellState::LOAD)
if (cell.type == mwmp::CellState::Type::Load)
{
Cell *c = addCell(cell.cell);
c->addPlayer(player);

@ -6,6 +6,8 @@
#include "CellState.hpp"
#include <utility>
void CellState::Init(LuaState &lua)
{
lua.getState()->new_usertype<CellState>("CellState",
@ -14,12 +16,12 @@ void CellState::Init(LuaState &lua)
);
}
CellState::CellState(mwmp::CellState state) : state(state)
CellState::CellState(mwmp::CellState state) : state(std::move(state))
{
}
int CellState::getStateType() const
mwmp::CellState::Type CellState::getStateType() const
{
return state.type;
}

@ -16,7 +16,7 @@ public:
explicit CellState(mwmp::CellState state);
public:
int getStateType() const;
mwmp::CellState::Type getStateType() const;
std::string getDescription() const;
private:

@ -40,12 +40,12 @@ void Factions::processUpdate()
clear();
}
int Factions::getFactionChangesAction() const
mwmp::FactionChanges::Type Factions::getFactionChangesAction() const
{
return player->factionChanges.action;
}
void Factions::setFactionChangesAction(int action)
void Factions::setFactionChangesAction(mwmp::FactionChanges::Type action)
{
player->factionChanges.action = action;
setChanged();

@ -43,8 +43,8 @@ public:
~Factions();
int getFactionChangesAction() const;
void setFactionChangesAction(int action);
mwmp::FactionChanges::Type getFactionChangesAction() const;
void setFactionChangesAction(mwmp::FactionChanges::Type action);
void addFaction(Faction faction);
Faction getFaction(int id) const;

@ -39,7 +39,7 @@ void GUI::messageBox(int id, const char *label)
{
player->guiMessageBox.id = id;
player->guiMessageBox.label = label;
player->guiMessageBox.type = Player::GUIMessageBox::MessageBox;
player->guiMessageBox.type = Player::GUIMessageBox::Type::MessageBox;
setChanged();
}
@ -49,7 +49,7 @@ void GUI::customMessageBox(int id, const char *label, const char *buttons)
player->guiMessageBox.id = id;
player->guiMessageBox.label = label;
player->guiMessageBox.buttons = buttons;
player->guiMessageBox.type = Player::GUIMessageBox::CustomMessageBox;
player->guiMessageBox.type = Player::GUIMessageBox::Type::CustomMessageBox;
setChanged();
}
@ -58,7 +58,7 @@ void GUI::inputDialog(int id, const char *label)
{
player->guiMessageBox.id = id;
player->guiMessageBox.label = label;
player->guiMessageBox.type = Player::GUIMessageBox::InputDialog;
player->guiMessageBox.type = Player::GUIMessageBox::Type::InputDialog;
setChanged();
}
@ -68,7 +68,7 @@ void GUI::passwordDialog(int id, const char *label, const char *note)
player->guiMessageBox.id = id;
player->guiMessageBox.label = label;
player->guiMessageBox.note = note;
player->guiMessageBox.type = Player::GUIMessageBox::PasswordDialog;
player->guiMessageBox.type = Player::GUIMessageBox::Type::PasswordDialog;
setChanged();
}
@ -78,7 +78,7 @@ void GUI::listBox(int id, const char *label, const char *items)
player->guiMessageBox.id = id;
player->guiMessageBox.label = label;
player->guiMessageBox.data = items;
player->guiMessageBox.type = Player::GUIMessageBox::ListBox;
player->guiMessageBox.type = Player::GUIMessageBox::Type::ListBox;
setChanged();
}

@ -33,7 +33,7 @@ void Inventory::Init(LuaState &lua)
);
}
Inventory::Inventory(NetActor *actor) : netActor(actor), equipmentChanged(false), inventoryChanged(0)
Inventory::Inventory(NetActor *actor) : netActor(actor), equipmentChanged(false), inventoryChanged(mwmp::InventoryChanges::Type::None)
{
printf("Inventory::Inventory()\n");
}
@ -89,7 +89,7 @@ void Inventory::update()
void Inventory::InitializeInventoryChanges()
{
netActor->getNetCreature()->inventoryChanges.items.clear();
netActor->getNetCreature()->inventoryChanges.action = mwmp::InventoryChanges::SET;
netActor->getNetCreature()->inventoryChanges.action = mwmp::InventoryChanges::Type::Set;
}
int Inventory::getChangesSize() const
@ -121,9 +121,9 @@ void Inventory::unequipItem( unsigned short slot)
void Inventory::addItem(const std::string &refId, unsigned int count, int charge, int enchantmentCharge)
{
if (inventoryChanged == mwmp::InventoryChanges::REMOVE)
if (inventoryChanged == mwmp::InventoryChanges::Type::Remove)
return;
if (inventoryChanged == 0)
if (inventoryChanged == mwmp::InventoryChanges::Type::None)
InitializeInventoryChanges();
mwmp::Item item;
@ -133,17 +133,17 @@ void Inventory::addItem(const std::string &refId, unsigned int count, int charge
item.enchantmentCharge = enchantmentCharge;
netActor->getNetCreature()->inventoryChanges.items.push_back(item);
netActor->getNetCreature()->inventoryChanges.action = mwmp::InventoryChanges::ADD;
if (inventoryChanged == 0 && netActor->isPlayer())
netActor->getNetCreature()->inventoryChanges.action = mwmp::InventoryChanges::Type::Add;
if (inventoryChanged == mwmp::InventoryChanges::Type::None && netActor->isPlayer())
netActor->toPlayer()->addToUpdateQueue();
inventoryChanged = netActor->getNetCreature()->inventoryChanges.action;
}
void Inventory::removeItem(const std::string &refId, unsigned short count)
{
if (inventoryChanged == mwmp::InventoryChanges::ADD)
if (inventoryChanged == mwmp::InventoryChanges::Type::Add)
return;
if (inventoryChanged == 0)
if (inventoryChanged == mwmp::InventoryChanges::Type::None)
InitializeInventoryChanges();
mwmp::Item item;
@ -151,8 +151,8 @@ void Inventory::removeItem(const std::string &refId, unsigned short count)
item.count = count;
netActor->getNetCreature()->inventoryChanges.items.push_back(item);
netActor->getNetCreature()->inventoryChanges.action = mwmp::InventoryChanges::REMOVE;
if (inventoryChanged == 0 && netActor->isPlayer())
netActor->getNetCreature()->inventoryChanges.action = mwmp::InventoryChanges::Type::Remove;
if (inventoryChanged == mwmp::InventoryChanges::Type::None && netActor->isPlayer())
netActor->toPlayer()->addToUpdateQueue();
inventoryChanged = netActor->getNetCreature()->inventoryChanges.action;
}
@ -191,10 +191,10 @@ bool Inventory::isEquipmentChanged()
void Inventory::resetInventoryFlag()
{
inventoryChanged = 0;
inventoryChanged = mwmp::InventoryChanges::Type::None;
}
int Inventory::inventoryChangeType()
mwmp::InventoryChanges::Type Inventory::inventoryChangeType()
{
return inventoryChanged;
}

@ -16,7 +16,7 @@ public:
static void Init(LuaState &lua);
bool isEquipmentChanged();
void resetEquipmentFlag();
int inventoryChangeType();
mwmp::InventoryChanges::Type inventoryChangeType();
void resetInventoryFlag();
public:
explicit Inventory(NetActor *netActor);
@ -57,7 +57,7 @@ private:
// not controlled pointer
NetActor *netActor;
bool equipmentChanged;
int inventoryChanged;
mwmp::InventoryChanges::Type inventoryChanged;
};

@ -350,7 +350,7 @@ void ObjectController::sendObjects(shared_ptr<Player> player, shared_ptr<vector<
for (auto &e : events)
{
e.action = mwmp::BaseEvent::SET;
e.action = mwmp::BaseEvent::Action::Set;
e.guid = player->guid;
e.cell = cell;
}
@ -514,7 +514,7 @@ void ObjectController::sendContainers(shared_ptr<Player> player, shared_ptr<vect
mwmp::BaseEvent event;
event.cell = cell;
event.action = mwmp::BaseEvent::SET;
event.action = mwmp::BaseEvent::Action::Set;
event.guid = player->guid;
for (auto &object : *objects)
@ -535,7 +535,7 @@ void ObjectController::sendContainers(shared_ptr<Player> player, shared_ptr<vect
void ObjectController::requestContainers(shared_ptr<Player> player)
{
mwmp::BaseEvent event;
event.action = mwmp::BaseEvent::REQUEST;
event.action = mwmp::BaseEvent::Action::Request;
event.guid = player->guid;
event.cell = player->cell;

@ -218,7 +218,7 @@ void Player::update()
inventory.resetEquipmentFlag();
}
if (inventory.inventoryChangeType() != 0)
if (inventory.inventoryChangeType() != mwmp::InventoryChanges::Type::None)
{
auto packet = plPCtrl->GetPacket(ID_PLAYER_INVENTORY);
packet->setPlayer(this);

@ -50,12 +50,12 @@ void JournalItem::setIndex(int index)
item.index = index;
}
int JournalItem::getType() const
mwmp::JournalItem::Type JournalItem::getType() const
{
return item.type;
}
void JournalItem::setType(int type)
void JournalItem::setType(mwmp::JournalItem::Type type)
{
item.type = type;
}

@ -25,8 +25,8 @@ public:
int getIndex() const;
void setIndex(int index);
int getType() const;
void setType(int type);
mwmp::JournalItem::Type getType() const;
void setType(mwmp::JournalItem::Type type);
std::string getActorRefId() const;
void setActorRefId(const std::string &refid);

@ -18,12 +18,12 @@ namespace mwmp
void Do(WorldPacket &packet, const std::shared_ptr<Player> &player, BaseEvent &event) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player->npc.mName.c_str());
LOG_APPEND(Log::LOG_INFO, "- action: %i", event.action);
LOG_APPEND(Log::LOG_INFO, "- action: %i", (int) event.action);
// Until we have a timestamp-based system, send packets pertaining to more
// than one container (i.e. replies to server requests for container contents)
// only to players who have the container's cell loaded
if (event.action == BaseEvent::SET && event.worldObjects.size() > 1)
if (event.action == BaseEvent::Action::Set && event.worldObjects.size() > 1)
{
Cell *serverCell = CellController::get().getCell(event.cell);

@ -114,7 +114,7 @@ namespace MWGui
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
worldEvent->reset();
worldEvent->cell = *mPtr.getCell()->getCell();
worldEvent->action = mwmp::BaseEvent::REMOVE;
worldEvent->action = mwmp::BaseEvent::Action::Remove;
mwmp::WorldObject worldObject;
worldObject.refId = mPtr.getCellRef().getRefId();
@ -160,7 +160,7 @@ namespace MWGui
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
worldEvent->reset();
worldEvent->cell = *mPtr.getCell()->getCell();
worldEvent->action = mwmp::BaseEvent::ADD;
worldEvent->action = mwmp::BaseEvent::Action::Add;
mwmp::WorldObject worldObject;
worldObject.refId = mPtr.getCellRef().getRefId();
@ -330,7 +330,7 @@ namespace MWGui
mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent();
worldEvent->reset();
worldEvent->cell = *mPtr.getCell()->getCell();
worldEvent->action = mwmp::BaseEvent::SET;
worldEvent->action = mwmp::BaseEvent::Action::Set;
mwmp::WorldObject worldObject;
worldObject.refId = mPtr.getCellRef().getRefId();

@ -1330,7 +1330,7 @@ namespace MWMechanics
if (localAttack->pressed != state)
{
MechanicsHelper::resetAttack(localAttack);
localAttack->type = mwmp::Attack::MELEE;
localAttack->type = mwmp::Attack::Type::Melee;
localAttack->pressed = state;
localAttack->shouldSend = true;
}

@ -222,7 +222,7 @@ namespace MWMechanics
if (localAttack && localAttack->pressed != storage.mAttack)
{
MechanicsHelper::resetAttack(localAttack);
localAttack->type = mwmp::Attack::MELEE;
localAttack->type = mwmp::Attack::Type::Melee;
localAttack->pressed = storage.mAttack;
localAttack->shouldSend = true;
}
@ -291,10 +291,10 @@ namespace MWMechanics
*/
mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(actor);
if (localAttack && localAttack->pressed != false)
if (localAttack && localAttack->pressed)
{
MechanicsHelper::resetAttack(localAttack);
localAttack->type = mwmp::Attack::MELEE;
localAttack->type = mwmp::Attack::Type::Melee;
localAttack->pressed = false;
localAttack->shouldSend = true;
}
@ -644,10 +644,10 @@ namespace MWMechanics
*/
mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(actor);
if (localAttack && localAttack->pressed != true)
if (localAttack && !localAttack->pressed)
{
MechanicsHelper::resetAttack(localAttack);
localAttack->type = mwmp::Attack::MELEE;
localAttack->type = mwmp::Attack::Type::Melee;
localAttack->pressed = true;
localAttack->shouldSend = true;
}

@ -1098,7 +1098,7 @@ bool CharacterController::updateCreatureState()
if (localAttack)
{
MechanicsHelper::resetAttack(localAttack);
localAttack->type = mwmp::Attack::MAGIC;
localAttack->type = mwmp::Attack::Type::Magic;
localAttack->pressed = true;
localAttack->shouldSend = true;
}
@ -1379,7 +1379,7 @@ bool CharacterController::updateWeaponState()
if (localAttack)
{
MechanicsHelper::resetAttack(localAttack);
localAttack->type = mwmp::Attack::MAGIC;
localAttack->type = mwmp::Attack::Type::Magic;
localAttack->pressed = true;
localAttack->shouldSend = true;
}

@ -255,12 +255,12 @@ void Cell::readAttack(ActorList& actorList)
// Set the correct drawState here if we've somehow we've missed a previous
// AnimFlags packet
if (actor->attack.type == mwmp::Attack::MELEE && actor->drawState != 1)
if (actor->attack.type == mwmp::Attack::Type::Melee && actor->drawState != 1)
{
actor->drawState = 1;
actor->setAnimFlags();
}
else if (actor->attack.type == mwmp::Attack::MAGIC && actor->drawState != 2)
else if (actor->attack.type == mwmp::Attack::Type::Magic && actor->drawState != 2)
{
actor->drawState = 2;
actor->setAnimFlags();

@ -177,7 +177,7 @@ void mwmp::GUIController::showInputBox(const BasePlayer::GUIMessageBox &guiMessa
mInputBox = 0;
mInputBox = new TextInputDialog();
mInputBox->setEditPassword(guiMessageBox.type == BasePlayer::GUIMessageBox::PasswordDialog);
mInputBox->setEditPassword(guiMessageBox.type == BasePlayer::GUIMessageBox::Type::PasswordDialog);
mInputBox->setTextLabel(guiMessageBox.label);
mInputBox->setTextNote(guiMessageBox.note);

@ -31,7 +31,7 @@ LocalActor::LocalActor()
wasForceMoveJumping = false;
wasFlying = false;
attack.type = Attack::MELEE;
attack.type = Attack::Type::Melee;
attack.shouldSend = false;
attack.instant = false;
@ -237,7 +237,7 @@ void LocalActor::updateAttack()
{
if (attack.shouldSend)
{
if (attack.type == Attack::MAGIC)
if (attack.type == Attack::Type::Magic)
{
MWMechanics::CreatureStats &attackerStats = ptr.getClass().getCreatureStats(ptr);
attack.spellId = attackerStats.getSpells().getSelectedSpell();

@ -538,7 +538,7 @@ void LocalPlayer::updateAttack()
{
if (attack.shouldSend)
{
if (attack.type == Attack::MAGIC)
if (attack.type == Attack::Type::Magic)
{
attack.spellId = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
@ -690,7 +690,7 @@ void LocalPlayer::addJournalItems()
{
MWWorld::Ptr ptrFound;
if (journalItem.type == JournalItem::ENTRY)
if (journalItem.type == JournalItem::Type::Entry)
{
ptrFound = MWBase::Environment::get().getWorld()->searchPtr(journalItem.actorRefId, false);
@ -700,7 +700,7 @@ void LocalPlayer::addJournalItems()
try
{
if (journalItem.type == JournalItem::ENTRY)
if (journalItem.type == JournalItem::Type::Entry)
MWBase::Environment::get().getJournal()->addEntry(journalItem.quest, journalItem.index, ptrFound);
else
MWBase::Environment::get().getJournal()->setJournalIndex(journalItem.quest, journalItem.index);
@ -1080,7 +1080,7 @@ void LocalPlayer::setFactions()
if (!ptrNpcStats.isInFaction(faction.factionId))
ptrNpcStats.joinFaction(faction.factionId);
if (factionChanges.action == mwmp::FactionChanges::RANK)
if (factionChanges.action == mwmp::FactionChanges::Type::Rank)
{
// While the faction rank is different in the packet than in the NpcStats,
// adjust the NpcStats accordingly
@ -1092,7 +1092,7 @@ void LocalPlayer::setFactions()
ptrNpcStats.lowerRank(faction.factionId);
}
}
else if (factionChanges.action == mwmp::FactionChanges::EXPULSION)
else if (factionChanges.action == mwmp::FactionChanges::Type::Expulsion)
{
// If the expelled state is different in the packet than in the NpcStats,
// adjust the NpcStats accordingly
@ -1105,7 +1105,7 @@ void LocalPlayer::setFactions()
}
}
else if (factionChanges.action == mwmp::FactionChanges::REPUTATION)
else if (factionChanges.action == mwmp::FactionChanges::Type::Reputation)
ptrNpcStats.setFactionReputation(faction.factionId, faction.reputation);
}
}
@ -1183,7 +1183,7 @@ void LocalPlayer::sendInventory()
inventoryChanges.items.push_back(item);
}
inventoryChanges.action = InventoryChanges::SET;
inventoryChanges.action = InventoryChanges::Type::Set;
getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_INVENTORY)->Send();
}
@ -1202,7 +1202,7 @@ void LocalPlayer::sendSpellbook()
spellbookChanges.spells.push_back(*spell.first);
}
spellbookChanges.action = SpellbookChanges::SET;
spellbookChanges.action = SpellbookChanges::Type::Set;
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send();
}
@ -1225,7 +1225,7 @@ void LocalPlayer::sendSpellAddition(std::string id)
spell.mId = id;
spellbookChanges.spells.push_back(spell);
spellbookChanges.action = SpellbookChanges::ADD;
spellbookChanges.action = SpellbookChanges::Type::Add;
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send();
}
@ -1241,7 +1241,7 @@ void LocalPlayer::sendSpellRemoval(std::string id)
spell.mId = id;
spellbookChanges.spells.push_back(spell);
spellbookChanges.action = SpellbookChanges::REMOVE;
spellbookChanges.action = SpellbookChanges::Type::Remove;
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send();
}
@ -1295,7 +1295,7 @@ void LocalPlayer::sendJournalEntry(const std::string& quest, int index, const MW
journalChanges.journalItems.clear();
mwmp::JournalItem journalItem;
journalItem.type = JournalItem::ENTRY;
journalItem.type = JournalItem::Type::Entry;
journalItem.quest = quest;
journalItem.index = index;
journalItem.actorRefId = actor.getCellRef().getRefId();
@ -1311,7 +1311,7 @@ void LocalPlayer::sendJournalIndex(const std::string& quest, int index)
journalChanges.journalItems.clear();
mwmp::JournalItem journalItem;
journalItem.type = JournalItem::INDEX;
journalItem.type = JournalItem::Type::Index;
journalItem.quest = quest;
journalItem.index = index;
@ -1324,7 +1324,7 @@ void LocalPlayer::sendJournalIndex(const std::string& quest, int index)
void LocalPlayer::sendFactionRank(const std::string& factionId, int rank)
{
factionChanges.factions.clear();
factionChanges.action = FactionChanges::RANK;
factionChanges.action = FactionChanges::Type::Rank;
mwmp::Faction faction;
faction.factionId = factionId;
@ -1339,7 +1339,7 @@ void LocalPlayer::sendFactionRank(const std::string& factionId, int rank)
void LocalPlayer::sendFactionExpulsionState(const std::string& factionId, bool isExpelled)
{
factionChanges.factions.clear();
factionChanges.action = FactionChanges::EXPULSION;
factionChanges.action = FactionChanges::Type::Expulsion;
mwmp::Faction faction;
faction.factionId = factionId;
@ -1354,7 +1354,7 @@ void LocalPlayer::sendFactionExpulsionState(const std::string& factionId, bool i
void LocalPlayer::sendFactionReputation(const std::string& factionId, int reputation)
{
factionChanges.factions.clear();
factionChanges.action = FactionChanges::REPUTATION;
factionChanges.action = FactionChanges::Type::Reputation;
mwmp::Faction faction;
faction.factionId = factionId;
@ -1439,7 +1439,7 @@ void LocalPlayer::clearCurrentContainer()
currentContainer.mpNum = 0;
}
void LocalPlayer::storeCellState(const ESM::Cell& cell, int stateType)
void LocalPlayer::storeCellState(const ESM::Cell& cell, mwmp::CellState::Type stateType)
{
std::vector<CellState>::iterator iter;

@ -89,7 +89,7 @@ namespace mwmp
void clearCurrentContainer();
void storeCurrentContainer(const MWWorld::Ptr& container);
void storeCellState(const ESM::Cell& cell, int stateType);
void storeCellState(const ESM::Cell& cell, mwmp::CellState::Type stateType);
void playAnimation();
void playSpeech();

@ -167,7 +167,7 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
}
// Get the weapon used (if hand-to-hand, weapon = inv.end())
if (attack.type == attack.MELEE)
if (attack.type == Attack::Type::Melee)
{
MWWorld::Ptr weapon;
@ -201,7 +201,7 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
attack.success);
}
}
else if (attack.type == attack.MAGIC)
else if (attack.type == Attack::Type::Magic)
{
if (attack.instant)
{

@ -69,13 +69,13 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
MWWorld::ContainerStore& containerStore = ptrFound.getClass().getContainerStore(ptrFound);
// If we are setting the entire contents, clear the current ones
if (action == BaseEvent::SET)
if (action == BaseEvent::Action::Set)
containerStore.clear();
MWWorld::Ptr ownerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
for (const auto &containerItem : worldObject.containerItems)
{
if (action == BaseEvent::ADD || action == BaseEvent::SET)
if (action == BaseEvent::Action::Add || action == BaseEvent::Action::Set)
{
// Create a ManualRef to be able to set item charge
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), containerItem.refId, 1);
@ -92,7 +92,7 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
containerStore.add(newPtr, containerItem.count, ownerPtr, true);
}
else if (action == BaseEvent::REMOVE)
else if (action == BaseEvent::Action::Remove)
{
// We have to find the right item ourselves because ContainerStore has no method
// accounting for charge
@ -122,8 +122,8 @@ void WorldEvent::editContainers(MWWorld::CellStore* cellStore)
// Was this a SET or ADD action on an actor's container, and are we the authority
// over the actor? If so, autoequip the actor
if ((action == BaseEvent::ADD || action == BaseEvent::SET) && ptrFound.getClass().isActor() &&
mwmp::Main::get().getCellController()->isLocalActor(ptrFound))
if ((action == BaseEvent::Action::Add || action == BaseEvent::Action::Set) && ptrFound.getClass().isActor()
&& mwmp::Main::get().getCellController()->isLocalActor(ptrFound))
{
MWWorld::InventoryStore& invStore = ptrFound.getClass().getInventoryStore(ptrFound);
invStore.autoEquip(ptrFound);
@ -941,7 +941,7 @@ void WorldEvent::sendContainers(MWWorld::CellStore* cellStore)
{
reset();
cell = *cellStore->getCell();
action = BaseEvent::SET;
action = BaseEvent::Action::Set;
MWWorld::CellRefList<ESM::Container> *containerList = cellStore->getContainers();

@ -22,22 +22,22 @@ namespace mwmp
{
if (isLocal())
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_GUI_MESSAGEBOX, Type %d, MSG %s", player->guiMessageBox.type,
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_GUI_MESSAGEBOX, Type %d, MSG %s", (int) player->guiMessageBox.type,
player->guiMessageBox.label.c_str());
switch(player->guiMessageBox.type)
{
case BasePlayer::GUIMessageBox::MessageBox:
case BasePlayer::GUIMessageBox::Type::MessageBox:
Main::get().getGUIController()->showMessageBox(player->guiMessageBox);
break;
case BasePlayer::GUIMessageBox::CustomMessageBox:
case BasePlayer::GUIMessageBox::Type::CustomMessageBox:
Main::get().getGUIController()->showCustomMessageBox(player->guiMessageBox);
break;
case BasePlayer::GUIMessageBox::InputDialog:
case BasePlayer::GUIMessageBox::PasswordDialog:
case BasePlayer::GUIMessageBox::Type::InputDialog:
case BasePlayer::GUIMessageBox::Type::PasswordDialog:
Main::get().getGUIController()->showInputBox(player->guiMessageBox);
break;
case BasePlayer::GUIMessageBox::ListBox:
case BasePlayer::GUIMessageBox::Type::ListBox:
Main::get().getGUIController()->showDialogList(player->guiMessageBox);
break;
}

@ -28,11 +28,10 @@ namespace mwmp
else
{
LocalPlayer &localPlayer = static_cast<LocalPlayer&>(*player);
int inventoryAction = localPlayer.inventoryChanges.action;
if (inventoryAction == InventoryChanges::ADD)
if (localPlayer.inventoryChanges.action == InventoryChanges::Type::Add)
localPlayer.addItems();
else if (inventoryAction == InventoryChanges::REMOVE)
else if (localPlayer.inventoryChanges.action == InventoryChanges::Type::Remove)
localPlayer.removeItems();
else // InventoryChanges::SET
localPlayer.setInventory();

@ -29,12 +29,11 @@ namespace mwmp
else
{
LocalPlayer &localPlayer = static_cast<LocalPlayer&>(*player);
int spellbookAction = localPlayer.spellbookChanges.action;
if (spellbookAction == SpellbookChanges::ADD)
if (localPlayer.spellbookChanges.action == SpellbookChanges::Type::Add)
localPlayer.addSpells();
else if (spellbookAction == SpellbookChanges::REMOVE)
else if (localPlayer.spellbookChanges.action == SpellbookChanges::Type::Remove)
localPlayer.removeSpells();
else // SpellbookChanges::SET
localPlayer.setSpellbook();

@ -17,10 +17,10 @@ namespace mwmp
{
BaseObjectProcessor::Do(packet, event);
LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", event.action);
LOG_APPEND(Log::LOG_VERBOSE, "- action: %i", (int)event.action);
// If we've received a request for information, comply with it
if (event.action == mwmp::BaseEvent::REQUEST)
if (event.action == mwmp::BaseEvent::Action::Request)
event.sendContainers(ptrCellStore);
// Otherwise, edit containers based on the information received
else

@ -266,7 +266,7 @@ namespace MWWorld
Store a cell unload for the LocalPlayer
*/
mwmp::Main::get().getLocalPlayer()->storeCellState(*(*iter)->getCell(), mwmp::CellState::UNLOAD);
mwmp::Main::get().getLocalPlayer()->storeCellState(*(*iter)->getCell(), mwmp::CellState::Type::Unload);
/*
End of tes3mp addition
*/
@ -347,7 +347,7 @@ namespace MWWorld
Store a cell load for the LocalPlayer
*/
mwmp::Main::get().getLocalPlayer()->storeCellState(*cell->getCell(), mwmp::CellState::LOAD);
mwmp::Main::get().getLocalPlayer()->storeCellState(*cell->getCell(), mwmp::CellState::Type::Load);
/*
End of tes3mp addition
*/

@ -76,12 +76,12 @@ namespace mwmp
}
enum WORLD_ACTION
enum class Action : uint8_t
{
SET = 0,
ADD = 1,
REMOVE = 2,
REQUEST = 3
Set = 0,
Add,
Remove,
Request
};
RakNet::RakNetGUID guid;
@ -91,7 +91,7 @@ namespace mwmp
ESM::Cell cell;
std::string consoleCommand;
unsigned char action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item, 3 - Request items
Action action;
bool isValid;
};

@ -46,15 +46,15 @@ namespace mwmp
{
std::string quest;
int index;
enum JOURNAL_ITEM_TYPE
enum class Type
{
ENTRY = 0,
INDEX = 1
Entry = 0,
Index = 1
};
std::string actorRefId;
int type; // 0 - An entire entry, 1 - An index
Type type;
};
struct Faction
@ -101,13 +101,13 @@ namespace mwmp
{
ESM::Cell cell;
enum CELL_STATE_ACTION
enum class Type: uint8_t
{
LOAD = 0,
UNLOAD = 1
Load = 0,
Unload
};
int type; // 0 - Cell load, 1 - Cell unload
Type type;
};
struct JournalChanges
@ -119,14 +119,14 @@ namespace mwmp
{
std::vector<Faction> factions;
enum FACTION_ACTION
enum class Type: uint8_t
{
RANK = 0,
EXPULSION = 1,
REPUTATION = 2
Rank = 0,
Expulsion,
Reputation
};
int action; // 0 - Rank, 1 - Expulsion state, 2 - Both
Type action;
};
struct TopicChanges
@ -153,13 +153,14 @@ namespace mwmp
{
std::vector<ESM::Spell> spells;
enum ACTION_TYPE
enum class Type: int8_t
{
SET = 0,
ADD,
REMOVE
None = -1,
Set = 0,
Add,
Remove
};
int action; // 0 - Clear and set in entirety, 1 - Add spell, 2 - Remove spell
Type action;
};
struct QuickKeyChanges
@ -191,9 +192,7 @@ namespace mwmp
struct GUIMessageBox
{
int id;
int type;
enum GUI_TYPE
enum class Type: uint8_t
{
MessageBox = 0,
CustomMessageBox,
@ -201,6 +200,10 @@ namespace mwmp
PasswordDialog,
ListBox
};
int id;
Type type;
std::string label;
std::string note;
std::string buttons;
@ -237,8 +240,8 @@ namespace mwmp
BasePlayer(RakNet::RakNetGUID guid) : guid(guid)
{
inventoryChanges.action = 0;
spellbookChanges.action = 0;
inventoryChanges.action = InventoryChanges::Type::None;
spellbookChanges.action = SpellbookChanges::Type::None;
useCreatureName = false;
isWerewolf = false;
}

@ -23,13 +23,14 @@ namespace mwmp
struct InventoryChanges
{
std::vector<Item> items;
enum ACTION_TYPE
enum class Type: int8_t
{
SET = 0,
ADD,
REMOVE
None = -1,
Set = 0,
Add,
Remove
};
int action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item
Type action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item
};
struct Target
@ -47,14 +48,15 @@ namespace mwmp
Target target;
char type; // 0 - melee, 1 - magic, 2 - throwable
enum TYPE
enum class Type: uint8_t
{
MELEE = 0,
MAGIC,
THROWABLE
Melee = 0,
Magic,
Throwable
};
Type type;
std::string spellId; // id of spell (e.g. "fireball")
float damage;

@ -15,30 +15,37 @@ void mwmp::PacketPreInit::Packet(RakNet::BitStream *bs, bool send)
{
BasePacket::Packet(bs, send);
size_t size = checksums->size();
uint16_t size = checksums->size();
RW(size, send);
for (size_t i = 0; i < size; i++)
if(!send)
{
PluginPair ppair;
if (send)
ppair = (*checksums)[i];
if(size > 256)
return;
checksums->clear();
checksums->resize(size);
}
for (auto &&ppair : *checksums)
{
RW(ppair.first, send);
size_t hashSize = ppair.second.size();
uint8_t hashSize = ppair.second.size();
RW(hashSize, send);
for (size_t j = 0; j < hashSize; j++)
if(!send)
{
if(hashSize > 16)
return;
ppair.second.resize(hashSize);
}
for (auto &&hash :ppair.second)
{
unsigned hash;
if (send)
hash = ppair.second[j];
RW(hash, send);
if (!send)
ppair.second.push_back(hash);
}
if (!send)
checksums->push_back(ppair);
}
}

@ -23,9 +23,9 @@ void PacketGUIBoxes::Packet(RakNet::BitStream *bs, bool send)
RW(player->guiMessageBox.data, send);
if (player->guiMessageBox.type == BasePlayer::GUIMessageBox::CustomMessageBox)
if (player->guiMessageBox.type == BasePlayer::GUIMessageBox::Type::CustomMessageBox)
RW(player->guiMessageBox.buttons, send);
else if (player->guiMessageBox.type == BasePlayer::GUIMessageBox::PasswordDialog)
else if (player->guiMessageBox.type == BasePlayer::GUIMessageBox::Type::PasswordDialog)
RW(player->guiMessageBox.note, send);
}

@ -32,13 +32,13 @@ void PacketPlayerFaction::Packet(RakNet::BitStream *bs, bool send)
{
RW(faction.factionId, send, true);
if (player->factionChanges.action == FactionChanges::RANK)
if (player->factionChanges.action == FactionChanges::Type::Rank)
RW(faction.rank, send);
if (player->factionChanges.action == FactionChanges::EXPULSION)
if (player->factionChanges.action == FactionChanges::Type::Expulsion)
RW(faction.isExpelled, send);
if (player->factionChanges.action == FactionChanges::REPUTATION)
if (player->factionChanges.action == FactionChanges::Type::Reputation)
RW(faction.reputation, send);
}
}

@ -32,7 +32,7 @@ void PacketPlayerJournal::Packet(RakNet::BitStream *bs, bool send)
RW(journalItem.quest, send, true);
RW(journalItem.index, send);
if (journalItem.type == JournalItem::ENTRY)
if (journalItem.type == JournalItem::Type::Entry)
RW(journalItem.actorRefId, send, true);
}
}

Loading…
Cancel
Save