mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-04 19:19:40 +00:00
[Client] Avoid PlayerSpellbook packet spam in some mods
This commit is contained in:
parent
d9bc1abf48
commit
1baf82db32
1 changed files with 36 additions and 24 deletions
|
@ -470,18 +470,24 @@ namespace MWScript
|
||||||
// make sure a spell with this ID actually exists.
|
// make sure a spell with this ID actually exists.
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (id);
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (id);
|
||||||
|
|
||||||
ptr.getClass().getCreatureStats (ptr).getSpells().add (id);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Start of tes3mp addition
|
Start of tes3mp change (major)
|
||||||
|
|
||||||
Send an ID_PLAYER_SPELLBOOK packet every time a player gains a spell
|
Only add the spell if the target doesn't already have it
|
||||||
through a script
|
|
||||||
|
Send an ID_PLAYER_SPELLBOOK packet every time a player gains a spell here
|
||||||
*/
|
*/
|
||||||
if (ptr == MWMechanics::getPlayer())
|
MWMechanics::Spells &spells = ptr.getClass().getCreatureStats(ptr).getSpells();
|
||||||
mwmp::Main::get().getLocalPlayer()->sendSpellChange(id, mwmp::SpellbookChanges::ADD);
|
|
||||||
|
if (!spells.hasSpell(id))
|
||||||
|
{
|
||||||
|
spells.add(id);
|
||||||
|
|
||||||
|
if (mwmp::Main::get().getLocalPlayer()->isLoggedIn() && ptr == MWMechanics::getPlayer())
|
||||||
|
mwmp::Main::get().getLocalPlayer()->sendSpellChange(id, mwmp::SpellbookChanges::ADD);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp change (major)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -498,26 +504,32 @@ namespace MWScript
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
ptr.getClass().getCreatureStats (ptr).getSpells().remove (id);
|
|
||||||
|
|
||||||
MWBase::WindowManager *wm = MWBase::Environment::get().getWindowManager();
|
|
||||||
|
|
||||||
if (ptr == MWMechanics::getPlayer() &&
|
|
||||||
id == wm->getSelectedSpell())
|
|
||||||
{
|
|
||||||
wm->unsetSelectedSpell();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Start of tes3mp addition
|
Start of tes3mp change (major)
|
||||||
|
|
||||||
Send an ID_PLAYER_SPELLBOOK packet every time a player loses a spell
|
Only remove the spell if the target has it
|
||||||
through a script
|
|
||||||
|
Send an ID_PLAYER_SPELLBOOK packet every time a player loses a spell here
|
||||||
*/
|
*/
|
||||||
if (ptr == MWMechanics::getPlayer())
|
MWMechanics::Spells &spells = ptr.getClass().getCreatureStats(ptr).getSpells();
|
||||||
mwmp::Main::get().getLocalPlayer()->sendSpellChange(id, mwmp::SpellbookChanges::REMOVE);
|
|
||||||
|
if (spells.hasSpell(id))
|
||||||
|
{
|
||||||
|
ptr.getClass().getCreatureStats(ptr).getSpells().remove(id);
|
||||||
|
|
||||||
|
if (ptr == MWMechanics::getPlayer())
|
||||||
|
{
|
||||||
|
MWBase::WindowManager *wm = MWBase::Environment::get().getWindowManager();
|
||||||
|
|
||||||
|
if (id == wm->getSelectedSpell())
|
||||||
|
wm->unsetSelectedSpell();
|
||||||
|
|
||||||
|
if (mwmp::Main::get().getLocalPlayer()->isLoggedIn())
|
||||||
|
mwmp::Main::get().getLocalPlayer()->sendSpellChange(id, mwmp::SpellbookChanges::REMOVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp change (major)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue