[Client] Combine methods for sending spell packets into a single one

pull/471/head
David Cernat 6 years ago
parent 140e0ed52c
commit 45b011452e

@ -172,7 +172,7 @@ namespace MWGui
Send an ID_PLAYER_SPELLBOOK packet every time a player buys a spell
*/
mwmp::Main::get().getLocalPlayer()->sendSpellAddition(mSpellsWidgetMap.find(_sender)->second);
mwmp::Main::get().getLocalPlayer()->sendSpellChange(mSpellsWidgetMap.find(_sender)->second, mwmp::SpellbookChanges::ADD);
/*
End of tes3mp addition
*/

@ -229,7 +229,7 @@ namespace MWGui
Send an ID_PLAYER_SPELLBOOK packet every time a player deletes one of their spells
*/
mwmp::Main::get().getLocalPlayer()->sendSpellRemoval(mSpellToDelete);
mwmp::Main::get().getLocalPlayer()->sendSpellChange(mSpellToDelete, mwmp::SpellbookChanges::REMOVE);
/*
End of tes3mp addition
*/

@ -1425,9 +1425,10 @@ void LocalPlayer::sendCellStates()
getNetworking()->getPlayerPacket(ID_PLAYER_CELL_STATE)->Send();
}
void LocalPlayer::sendSpellAddition(std::string id)
void LocalPlayer::sendSpellChange(std::string id, unsigned int action)
{
if (id.find("$dynamic") != string::npos) // skip custom spells
// Skip any bugged spells that somehow have clientside-only dynamic IDs
if (id.find("$dynamic") != string::npos)
return;
spellbookChanges.spells.clear();
@ -1436,23 +1437,7 @@ void LocalPlayer::sendSpellAddition(std::string id)
spell.mId = id;
spellbookChanges.spells.push_back(spell);
spellbookChanges.action = SpellbookChanges::ADD;
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send();
}
void LocalPlayer::sendSpellRemoval(std::string id)
{
if (id.find("$dynamic") != string::npos) // skip custom spells
return;
spellbookChanges.spells.clear();
ESM::Spell spell;
spell.mId = id;
spellbookChanges.spells.push_back(spell);
spellbookChanges.action = SpellbookChanges::REMOVE;
spellbookChanges.action = action;
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send();
}

@ -73,8 +73,7 @@ namespace mwmp
void sendInventory();
void sendSpellbook();
void sendCellStates();
void sendSpellAddition(std::string id);
void sendSpellRemoval(std::string id);
void sendSpellChange(std::string id, unsigned int action);
void sendQuickKey(unsigned short slot, int type, const std::string& itemId = "");
void sendJournalEntry(const std::string& quest, int index, const MWWorld::Ptr& actor);
void sendJournalIndex(const std::string& quest, int index);

@ -479,7 +479,7 @@ namespace MWScript
through a script
*/
if (ptr == MWMechanics::getPlayer())
mwmp::Main::get().getLocalPlayer()->sendSpellAddition(id);
mwmp::Main::get().getLocalPlayer()->sendSpellChange(id, mwmp::SpellbookChanges::ADD);
/*
End of tes3mp addition
*/
@ -515,7 +515,7 @@ namespace MWScript
through a script
*/
if (ptr == MWMechanics::getPlayer())
mwmp::Main::get().getLocalPlayer()->sendSpellRemoval(id);
mwmp::Main::get().getLocalPlayer()->sendSpellChange(id, mwmp::SpellbookChanges::REMOVE);
/*
End of tes3mp addition
*/

Loading…
Cancel
Save