mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
[Client] Combine methods for sending spell packets into a single one
This commit is contained in:
parent
140e0ed52c
commit
45b011452e
5 changed files with 9 additions and 25 deletions
|
@ -172,7 +172,7 @@ namespace MWGui
|
||||||
|
|
||||||
Send an ID_PLAYER_SPELLBOOK packet every time a player buys a spell
|
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
|
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
|
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
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1425,9 +1425,10 @@ void LocalPlayer::sendCellStates()
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_CELL_STATE)->Send();
|
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;
|
return;
|
||||||
|
|
||||||
spellbookChanges.spells.clear();
|
spellbookChanges.spells.clear();
|
||||||
|
@ -1436,23 +1437,7 @@ void LocalPlayer::sendSpellAddition(std::string id)
|
||||||
spell.mId = id;
|
spell.mId = id;
|
||||||
spellbookChanges.spells.push_back(spell);
|
spellbookChanges.spells.push_back(spell);
|
||||||
|
|
||||||
spellbookChanges.action = SpellbookChanges::ADD;
|
spellbookChanges.action = action;
|
||||||
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;
|
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this);
|
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this);
|
||||||
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send();
|
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send();
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,8 +73,7 @@ namespace mwmp
|
||||||
void sendInventory();
|
void sendInventory();
|
||||||
void sendSpellbook();
|
void sendSpellbook();
|
||||||
void sendCellStates();
|
void sendCellStates();
|
||||||
void sendSpellAddition(std::string id);
|
void sendSpellChange(std::string id, unsigned int action);
|
||||||
void sendSpellRemoval(std::string id);
|
|
||||||
void sendQuickKey(unsigned short slot, int type, const std::string& itemId = "");
|
void sendQuickKey(unsigned short slot, int 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);
|
||||||
|
|
|
@ -479,7 +479,7 @@ namespace MWScript
|
||||||
through a script
|
through a script
|
||||||
*/
|
*/
|
||||||
if (ptr == MWMechanics::getPlayer())
|
if (ptr == MWMechanics::getPlayer())
|
||||||
mwmp::Main::get().getLocalPlayer()->sendSpellAddition(id);
|
mwmp::Main::get().getLocalPlayer()->sendSpellChange(id, mwmp::SpellbookChanges::ADD);
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
@ -515,7 +515,7 @@ namespace MWScript
|
||||||
through a script
|
through a script
|
||||||
*/
|
*/
|
||||||
if (ptr == MWMechanics::getPlayer())
|
if (ptr == MWMechanics::getPlayer())
|
||||||
mwmp::Main::get().getLocalPlayer()->sendSpellRemoval(id);
|
mwmp::Main::get().getLocalPlayer()->sendSpellChange(id, mwmp::SpellbookChanges::REMOVE);
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue