From 8fbed1f8080a700bc5e265da715b2709ea4c6974 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 24 Jul 2018 20:58:55 +0300 Subject: [PATCH] [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. --- apps/openmw-mp/Script/Functions/Spells.cpp | 207 ------------------ apps/openmw-mp/Script/Functions/Spells.hpp | 180 --------------- apps/openmw/mwgui/spellcreationdialog.cpp | 1 - apps/openmw/mwmp/LocalPlayer.cpp | 26 --- apps/openmw/mwmp/LocalPlayer.hpp | 2 - .../Packets/Player/PacketPlayerSpellbook.cpp | 34 --- 6 files changed, 450 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Spells.cpp b/apps/openmw-mp/Script/Functions/Spells.cpp index d3d7f57e7..08269cc14 100644 --- a/apps/openmw-mp/Script/Functions/Spells.cpp +++ b/apps/openmw-mp/Script/Functions/Spells.cpp @@ -51,70 +51,6 @@ void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept 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 { 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(); } -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 { Player *player; diff --git a/apps/openmw-mp/Script/Functions/Spells.hpp b/apps/openmw-mp/Script/Functions/Spells.hpp index a8dd84746..29aa66c10 100644 --- a/apps/openmw-mp/Script/Functions/Spells.hpp +++ b/apps/openmw-mp/Script/Functions/Spells.hpp @@ -9,24 +9,8 @@ \ {"SetSpellbookChangesAction", SpellFunctions::SetSpellbookChangesAction},\ {"AddSpell", SpellFunctions::AddSpell},\ - {"AddCustomSpell", SpellFunctions::AddCustomSpell},\ - {"AddCustomSpellData", SpellFunctions::AddCustomSpellData},\ - {"AddCustomSpellEffect", SpellFunctions::AddCustomSpellEffect},\ \ {"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} @@ -78,45 +62,6 @@ public: */ 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. * @@ -126,131 +71,6 @@ public: */ 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. * diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 14fc6f09e..348e5da92 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -434,7 +434,6 @@ namespace MWGui 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."); - mwmp::Main::get().getLocalPlayer()->sendSpellAddition(*spell); /* End of tes3mp addition */ diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index c2cb4fef9..28e746222 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -1428,32 +1428,6 @@ void LocalPlayer::sendSpellRemoval(std::string id) 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) { quickKeyChanges.quickKeys.clear(); diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 8c079b180..39937fb6b 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -74,9 +74,7 @@ namespace mwmp void sendSpellbook(); void sendCellStates(); void sendSpellAddition(std::string id); - void sendSpellAddition(const ESM::Spell& spell); void sendSpellRemoval(std::string id); - void sendSpellRemoval(const ESM::Spell& spell); 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); diff --git a/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp b/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp index be0034ee3..9f3224a04 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerSpellbook.cpp @@ -31,40 +31,6 @@ void PacketPlayerSpellbook::Packet(RakNet::BitStream *bs, bool send) 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) player->spellbookChanges.spells.push_back(spell); }