[General] Remove custom data from PlayerSpellbook packet

It has never made sense to have custom spell data in PlayerSpellbook packets, so it has been removed.
remotes/1728160796594174844/tmp_0.7.0-alpha
David Cernat 7 years ago
parent 2e0b6e4e3e
commit 8fbed1f808

@ -51,70 +51,6 @@ void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept
player->spellbookChanges.spells.push_back(spell); player->spellbookChanges.spells.push_back(spell);
} }
void SpellFunctions::AddCustomSpell(unsigned short pid, const char* spellId, const char* spellName) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
ESM::Spell spell;
spell.mName = spellName;
spell.mId = spellId;
player->spellbookChanges.spells.push_back(spell);
}
void SpellFunctions::AddCustomSpellData(unsigned short pid, const char* spellId, int type, int cost, int flags) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
int index = -1;
for(int i = 0; i < player->spellbookChanges.spells.size(); i++)
{
if( strcmp(player->spellbookChanges.spells.at(index).mId.c_str(), spellId) == 0)
{
index = i;
}
}
if(index == -1)
return;
player->spellbookChanges.spells.at(index).mData.mType = type;
player->spellbookChanges.spells.at(index).mData.mCost = cost;
player->spellbookChanges.spells.at(index).mData.mFlags = flags;
}
void SpellFunctions::AddCustomSpellEffect(unsigned short pid, const char* spellId, short effectId, signed char mSkill, signed char mAttribute, int mRange, int mArea, int mDuration, int mMagnMin, int mMagnMax) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
int index = -1;
for(int i = 0; i < player->spellbookChanges.spells.size(); i++)
{
if( strcmp(player->spellbookChanges.spells.at(index).mId.c_str(), spellId) == 0)
{
index = i;
}
}
if(index == -1)
return;
ESM::ENAMstruct effect;
effect.mEffectID = effectId;
effect.mSkill = mSkill;
effect.mAttribute = mAttribute;
effect.mRange = mRange;
effect.mArea = mArea;
effect.mDuration = mDuration;
effect.mMagnMin = mMagnMin;
effect.mMagnMax = mMagnMax;
player->spellbookChanges.spells.at(index).mEffects.mList.push_back(effect);
}
const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int index) noexcept const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int index) noexcept
{ {
Player *player; Player *player;
@ -126,149 +62,6 @@ const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int index) n
return player->spellbookChanges.spells.at(index).mId.c_str(); return player->spellbookChanges.spells.at(index).mId.c_str();
} }
const char *SpellFunctions::GetSpellName(unsigned short pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, "");
if (index >= player->spellbookChanges.count)
return "invalid";
return player->spellbookChanges.spells.at(index).mName.c_str();
}
int SpellFunctions::GetSpellType(unsigned short pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mData.mType;
}
int SpellFunctions::GetSpellCost(unsigned short pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mData.mCost;
}
int SpellFunctions::GetSpellFlags(unsigned short pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mData.mFlags;
}
unsigned int SpellFunctions::GetSpellEffectCount(unsigned short pid, unsigned int index) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mEffects.mList.size();
}
short SpellFunctions::GetSpellEffectId(unsigned short pid, unsigned int index, unsigned int j) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mEffects.mList.at(j).mEffectID;
}
signed char SpellFunctions::GetSpellEffectSkill(unsigned short pid, unsigned int index, unsigned int j) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mEffects.mList.at(j).mSkill;
}
signed char SpellFunctions::GetSpellEffectAttribute(unsigned short pid, unsigned int index, unsigned int j) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mEffects.mList.at(j).mAttribute;
}
int SpellFunctions::GetSpellEffectRange(unsigned short pid, unsigned int index, unsigned int j) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mEffects.mList.at(j).mRange;
}
int SpellFunctions::GetSpellEffectArea(unsigned short pid, unsigned int index, unsigned int j) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mEffects.mList.at(j).mArea;
}
int SpellFunctions::GetSpellEffectDuration(unsigned short pid, unsigned int index, unsigned int j) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mEffects.mList.at(j).mDuration;
}
int SpellFunctions::GetSpellEffectMagnMin(unsigned short pid, unsigned int index, unsigned int j) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mEffects.mList.at(j).mMagnMin;
}
int SpellFunctions::GetSpellEffectMagnMax(unsigned short pid, unsigned int index, unsigned int j) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
if (index >= player->spellbookChanges.count)
return 0;
return player->spellbookChanges.spells.at(index).mEffects.mList.at(j).mMagnMax;
}
void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
{ {
Player *player; Player *player;

@ -9,24 +9,8 @@
\ \
{"SetSpellbookChangesAction", SpellFunctions::SetSpellbookChangesAction},\ {"SetSpellbookChangesAction", SpellFunctions::SetSpellbookChangesAction},\
{"AddSpell", SpellFunctions::AddSpell},\ {"AddSpell", SpellFunctions::AddSpell},\
{"AddCustomSpell", SpellFunctions::AddCustomSpell},\
{"AddCustomSpellData", SpellFunctions::AddCustomSpellData},\
{"AddCustomSpellEffect", SpellFunctions::AddCustomSpellEffect},\
\ \
{"GetSpellId", SpellFunctions::GetSpellId},\ {"GetSpellId", SpellFunctions::GetSpellId},\
{"GetSpellName", SpellFunctions::GetSpellName},\
{"GetSpellType", SpellFunctions::GetSpellType},\
{"GetSpellCost", SpellFunctions::GetSpellCost},\
{"GetSpellFlags", SpellFunctions::GetSpellFlags},\
{"GetSpellEffectCount", SpellFunctions::GetSpellEffectCount},\
{"GetSpellEffectId", SpellFunctions::GetSpellEffectId},\
{"GetSpellEffectSkill", SpellFunctions::GetSpellEffectSkill},\
{"GetSpellEffectAttribute", SpellFunctions::GetSpellEffectAttribute},\
{"GetSpellEffectRange", SpellFunctions::GetSpellEffectRange},\
{"GetSpellEffectArea", SpellFunctions::GetSpellEffectArea},\
{"GetSpellEffectDuration", SpellFunctions::GetSpellEffectDuration},\
{"GetSpellEffectMagnMin", SpellFunctions::GetSpellEffectMagnMin},\
{"GetSpellEffectMagnMax", SpellFunctions::GetSpellEffectMagnMax},\
\ \
{"SendSpellbookChanges", SpellFunctions::SendSpellbookChanges} {"SendSpellbookChanges", SpellFunctions::SendSpellbookChanges}
@ -78,45 +62,6 @@ public:
*/ */
static void AddSpell(unsigned short pid, const char* spellId) noexcept; static void AddSpell(unsigned short pid, const char* spellId) noexcept;
/**
* \brief Add a new custom spell to the spellbook changes for a player.
*
* \param pid The player ID whose spellbook changes should be used.
* \param spellId The spellId of the spell.
* \param spellName The name of the spell.
* \return void
*/
static void AddCustomSpell(unsigned short pid, const char* spellId, const char* spellName) noexcept;
/**
* \brief Add custom spell data to the spellbook changes for a player.
*
* \param pid The player ID whose spellbook changes should be used.
* \param spellId The spellId of the spell.
* \param type The type of the spell.
* \param cost The cost of the spell.
* \param flags The flags of the spell.
* \return void
*/
static void AddCustomSpellData(unsigned short pid, const char* spellId, int type, int cost, int flags) noexcept;
/**
* \brief Add custom spell effect to the spellbook changes for a player.
*
* \param pid The player ID whose spellbook changes should be used.
* \param spellId The spellId of the spell.
* \param effectId The effectId of the spell effect.
* \param mSkill The skill affected by the spell effect.
* \param mAttribute The attribute affected by the spell effect.
* \param mRange The range of the spell effect.
* \param mArea The area of the spell effect.
* \param mDuration The duration of the spell effect.
* \param mMagnMin The minimum magnitude of the spell effect.
* \param mMagnMax The maximum magnitude of the spell effect.
* \return void
*/
static void AddCustomSpellEffect(unsigned short pid, const char* spellId, short effectId, signed char mSkill, signed char mAttribute, int mRange, int mArea, int mDuration, int mMagnMin, int mMagnMax) noexcept;
/** /**
* \brief Get the spellId at a certain index in a player's latest spellbook changes. * \brief Get the spellId at a certain index in a player's latest spellbook changes.
* *
@ -126,131 +71,6 @@ public:
*/ */
static const char *GetSpellId(unsigned short pid, unsigned int index) noexcept; static const char *GetSpellId(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the name of the spell at a certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \return The spell name.
*/
static const char *GetSpellName(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the type of the spell at a certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \return The spell type.
*/
static int GetSpellType(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the cost of the spell at a certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \return The spell cost.
*/
static int GetSpellCost(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the flags of the spell at a certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \return The spell flags.
*/
static int GetSpellFlags(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the number of effects on the spell at a certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \return The spell effect count.
*/
static unsigned int GetSpellEffectCount(unsigned short pid, unsigned int index) noexcept;
/**
* \brief Get the effectId of the effect at a certain index in the spell at another certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \param j The index of the effect.
* \return The effectId.
*/
static short GetSpellEffectId(unsigned short pid, unsigned int index, unsigned int j) noexcept;
/**
* \brief Get the affected skill of the effect at a certain index in the spell at another certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \param j The index of the effect.
* \return The affected skill.
*/
static signed char GetSpellEffectSkill(unsigned short pid, unsigned int index, unsigned int j) noexcept;
/**
* \brief Get the affected attribute of the effect at a certain index in the spell at another certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \param j The index of the effect.
* \return The affected attribute.
*/
static signed char GetSpellEffectAttribute(unsigned short pid, unsigned int index, unsigned int j) noexcept;
/**
* \brief Get the range of the effect at a certain index in the spell at another certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \param j The index of the effect.
* \return The range.
*/
static int GetSpellEffectRange(unsigned short pid, unsigned int index, unsigned int j) noexcept;
/**
* \brief Get the area of the effect at a certain index in the spell at another certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \param j The index of the effect.
* \return The area.
*/
static int GetSpellEffectArea(unsigned short pid, unsigned int index, unsigned int j) noexcept;
/**
* \brief Get the duration of the effect at a certain index in the spell at another certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \param j The index of the effect.
* \return The duration.
*/
static int GetSpellEffectDuration(unsigned short pid, unsigned int index, unsigned int j) noexcept;
/**
* \brief Get the minimum magnitude of the effect at a certain index in the spell at another certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \param j The index of the effect.
* \return The minimum magnitude.
*/
static int GetSpellEffectMagnMin(unsigned short pid, unsigned int index, unsigned int j) noexcept;
/**
* \brief Get the maximum magnitude of the effect at a certain index in the spell at another certain index in a player's latest spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param index The index of the spell.
* \param j The index of the effect.
* \return The maximum magnitude.
*/
static int GetSpellEffectMagnMax(unsigned short pid, unsigned int index, unsigned int j) noexcept;
/** /**
* \brief Send a PlayerSpellbook packet with a player's recorded spellbook changes. * \brief Send a PlayerSpellbook packet with a player's recorded spellbook changes.
* *

@ -434,7 +434,6 @@ namespace MWGui
Include a messagebox notifying players that custom spells are not synced yet Include a messagebox notifying players that custom spells are not synced yet
*/ */
MWBase::Environment::get().getWindowManager()->messageBox("Custom spells are not synchronized in multiplayer yet and their effects cannot be seen by other players in most cases."); MWBase::Environment::get().getWindowManager()->messageBox("Custom spells are not synchronized in multiplayer yet and their effects cannot be seen by other players in most cases.");
mwmp::Main::get().getLocalPlayer()->sendSpellAddition(*spell);
/* /*
End of tes3mp addition End of tes3mp addition
*/ */

@ -1428,32 +1428,6 @@ void LocalPlayer::sendSpellRemoval(std::string id)
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send(); getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send();
} }
void LocalPlayer::sendSpellAddition(const ESM::Spell &spell)
{
/*
spellbookChanges.spells.clear();
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(const ESM::Spell &spell)
{
/*
spellbookChanges.spells.clear();
spellbookChanges.spells.push_back(spell);
spellbookChanges.action = SpellbookChanges::REMOVE;
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_SPELLBOOK)->Send();
*/
}
void LocalPlayer::sendQuickKey(unsigned short slot, int type, const std::string& itemId) void LocalPlayer::sendQuickKey(unsigned short slot, int type, const std::string& itemId)
{ {
quickKeyChanges.quickKeys.clear(); quickKeyChanges.quickKeys.clear();

@ -74,9 +74,7 @@ namespace mwmp
void sendSpellbook(); void sendSpellbook();
void sendCellStates(); void sendCellStates();
void sendSpellAddition(std::string id); void sendSpellAddition(std::string id);
void sendSpellAddition(const ESM::Spell& spell);
void sendSpellRemoval(std::string id); void sendSpellRemoval(std::string id);
void sendSpellRemoval(const ESM::Spell& spell);
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);

@ -31,40 +31,6 @@ void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send)
RW(spell.mId, send, true); RW(spell.mId, send, true);
if(spell.mId.find("$dynamic") != string::npos)
{
RW(spell.mName, send, true);
RW(spell.mData.mType, send, true);
RW(spell.mData.mCost, send, true);
RW(spell.mData.mFlags, send, true);
uint32_t effectCount = 0;
if (send)
effectCount = spell.mEffects.mList.size();
RW(effectCount, send, true);
for (uint32_t j = 0; j < effectCount; j++)
{
ESM::ENAMstruct effect;
if (send)
effect = spell.mEffects.mList.at(j);
RW(effect.mEffectID, send, true);
RW(effect.mSkill, send, true);
RW(effect.mAttribute, send, true);
RW(effect.mRange, send, true);
RW(effect.mArea, send, true);
RW(effect.mDuration, send, true);
RW(effect.mMagnMin, send, true);
RW(effect.mMagnMax, send, true);
if(!send)
spell.mEffects.mList.push_back(effect);
}
}
if (!send) if (!send)
player->spellbookChanges.spells.push_back(spell); player->spellbookChanges.spells.push_back(spell);
} }

Loading…
Cancel
Save