forked from mirror/openmw-tes3mp
Send spellbook in LocalPlayer CharGen & change UPDATE action name to SET
This commit is contained in:
parent
0f7748d9d2
commit
83277a1512
7 changed files with 39 additions and 25 deletions
|
@ -75,7 +75,7 @@ void ItemFunctions::ClearInventory(unsigned short pid) noexcept
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
player->packetItemsBuffer.items.clear();
|
player->packetItemsBuffer.items.clear();
|
||||||
player->packetItemsBuffer.action = PacketItems::UPDATE;
|
player->packetItemsBuffer.action = PacketItems::SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* itemId)
|
bool ItemFunctions::HasItemEquipped(unsigned short pid, const char* itemId)
|
||||||
|
|
|
@ -44,7 +44,7 @@ void SpellFunctions::ClearSpellbook(unsigned short pid) noexcept
|
||||||
GET_PLAYER(pid, player, );
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
player->packetSpellsBuffer.spells.clear();
|
player->packetSpellsBuffer.spells.clear();
|
||||||
player->packetSpellsBuffer.action = PacketSpells::UPDATE;
|
player->packetSpellsBuffer.action = PacketSpells::SET;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int i) noexcept
|
const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int i) noexcept
|
||||||
|
|
|
@ -27,9 +27,6 @@
|
||||||
#include "actorutil.hpp"
|
#include "actorutil.hpp"
|
||||||
#include "combat.hpp"
|
#include "combat.hpp"
|
||||||
|
|
||||||
#include "../mwmp/Main.hpp"
|
|
||||||
#include "../mwmp/LocalPlayer.hpp"
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -216,15 +213,8 @@ namespace MWMechanics
|
||||||
std::vector<std::string> selectedSpells = autoCalcPlayerSpells(skills, attributes, race);
|
std::vector<std::string> selectedSpells = autoCalcPlayerSpells(skills, attributes, race);
|
||||||
|
|
||||||
for (std::vector<std::string>::iterator it = selectedSpells.begin(); it != selectedSpells.end(); ++it)
|
for (std::vector<std::string>::iterator it = selectedSpells.begin(); it != selectedSpells.end(); ++it)
|
||||||
{
|
|
||||||
creatureStats.getSpells().add(*it);
|
creatureStats.getSpells().add(*it);
|
||||||
|
|
||||||
// Added by tes3mp
|
|
||||||
//
|
|
||||||
// LocalPlayer has gained a spell, so send a packet with it
|
|
||||||
mwmp::Main::get().getLocalPlayer()->sendSpellAddition(*it);
|
|
||||||
}
|
|
||||||
|
|
||||||
// forced update and current value adjustments
|
// forced update and current value adjustments
|
||||||
mActors.updateActor (ptr, 0);
|
mActors.updateActor (ptr, 0);
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,7 @@ bool LocalPlayer::charGenThread()
|
||||||
updateSkills(true);
|
updateSkills(true);
|
||||||
updateLevel(true);
|
updateLevel(true);
|
||||||
sendClass();
|
sendClass();
|
||||||
|
sendSpellbook();
|
||||||
getNetworking()->getPlayerPacket(ID_GAME_CHARGEN)->Send(this);
|
getNetworking()->getPlayerPacket(ID_GAME_CHARGEN)->Send(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,7 +621,7 @@ void LocalPlayer::updateDrawStateAndFlags(bool forceUpdate)
|
||||||
|
|
||||||
void LocalPlayer::addItems()
|
void LocalPlayer::addItems()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < packetItems.count; i++)
|
for (unsigned int i = 0; i < packetItems.count; i++)
|
||||||
|
@ -634,7 +635,7 @@ void LocalPlayer::addItems()
|
||||||
|
|
||||||
void LocalPlayer::addSpells()
|
void LocalPlayer::addSpells()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
||||||
|
|
||||||
for (vector<ESM::Spell>::const_iterator spell = packetSpells.spells.begin(); spell != packetSpells.spells.end(); spell++)
|
for (vector<ESM::Spell>::const_iterator spell = packetSpells.spells.begin(); spell != packetSpells.spells.end(); spell++)
|
||||||
|
@ -644,7 +645,7 @@ void LocalPlayer::addSpells()
|
||||||
|
|
||||||
void LocalPlayer::removeItems()
|
void LocalPlayer::removeItems()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < packetItems.count; i++)
|
for (unsigned int i = 0; i < packetItems.count; i++)
|
||||||
|
@ -656,7 +657,7 @@ void LocalPlayer::removeItems()
|
||||||
|
|
||||||
void LocalPlayer::removeSpells()
|
void LocalPlayer::removeSpells()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
||||||
|
|
||||||
for (vector<ESM::Spell>::const_iterator spell = packetSpells.spells.begin(); spell != packetSpells.spells.end(); spell++)
|
for (vector<ESM::Spell>::const_iterator spell = packetSpells.spells.begin(); spell != packetSpells.spells.end(); spell++)
|
||||||
|
@ -855,7 +856,7 @@ void LocalPlayer::setEquipment()
|
||||||
|
|
||||||
void LocalPlayer::setInventory()
|
void LocalPlayer::setInventory()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
MWWorld::ContainerStore &ptrStore = ptrPlayer.getClass().getContainerStore(ptrPlayer);
|
||||||
|
|
||||||
// Clear items in inventory
|
// Clear items in inventory
|
||||||
|
@ -873,7 +874,7 @@ void LocalPlayer::setInventory()
|
||||||
|
|
||||||
void LocalPlayer::setSpellbook()
|
void LocalPlayer::setSpellbook()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptrPlayer = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
||||||
|
|
||||||
// Clear spells in spellbook, while ignoring abilities, powers, etc.
|
// Clear spells in spellbook, while ignoring abilities, powers, etc.
|
||||||
|
@ -931,10 +932,32 @@ void LocalPlayer::sendInventory()
|
||||||
}
|
}
|
||||||
|
|
||||||
packetItems.count = (unsigned int) packetItems.items.size();
|
packetItems.count = (unsigned int) packetItems.items.size();
|
||||||
packetItems.action = PacketItems::UPDATE;
|
packetItems.action = PacketItems::SET;
|
||||||
Main::get().getNetworking()->getPlayerPacket(ID_GAME_INVENTORY)->Send(this);
|
Main::get().getNetworking()->getPlayerPacket(ID_GAME_INVENTORY)->Send(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalPlayer::sendSpellbook()
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||||
|
MWMechanics::Spells &ptrSpells = ptrPlayer.getClass().getCreatureStats(ptrPlayer).getSpells();
|
||||||
|
|
||||||
|
packetSpells.spells.clear();
|
||||||
|
|
||||||
|
// Send spells in spellbook, while ignoring abilities, powers, etc.
|
||||||
|
for (MWMechanics::Spells::TIterator iter = ptrSpells.begin(); iter != ptrSpells.end(); ++iter)
|
||||||
|
{
|
||||||
|
const ESM::Spell *spell = iter->first;
|
||||||
|
|
||||||
|
if (spell->mData.mType == ESM::Spell::ST_Spell)
|
||||||
|
{
|
||||||
|
packetSpells.spells.push_back(*spell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
packetSpells.action = PacketSpells::SET;
|
||||||
|
Main::get().getNetworking()->getPlayerPacket(ID_GAME_SPELLBOOK)->Send(this);
|
||||||
|
}
|
||||||
|
|
||||||
void LocalPlayer::sendSpellAddition(std::string id)
|
void LocalPlayer::sendSpellAddition(std::string id)
|
||||||
{
|
{
|
||||||
if (id.find("$dynamic") != string::npos) // skip custom spells
|
if (id.find("$dynamic") != string::npos) // skip custom spells
|
||||||
|
|
|
@ -55,6 +55,7 @@ namespace mwmp
|
||||||
|
|
||||||
void sendClass();
|
void sendClass();
|
||||||
void sendInventory();
|
void sendInventory();
|
||||||
|
void sendSpellbook();
|
||||||
void sendSpellAddition(std::string id);
|
void sendSpellAddition(std::string id);
|
||||||
void sendSpellAddition(const ESM::Spell &spell);
|
void sendSpellAddition(const ESM::Spell &spell);
|
||||||
void sendSpellRemoval(std::string id);
|
void sendSpellRemoval(std::string id);
|
||||||
|
|
|
@ -309,7 +309,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
{
|
{
|
||||||
getLocalPlayer()->removeItems();
|
getLocalPlayer()->removeItems();
|
||||||
}
|
}
|
||||||
else // PacketItems::UPDATE
|
else // PacketItems::SET
|
||||||
{
|
{
|
||||||
getLocalPlayer()->setInventory();
|
getLocalPlayer()->setInventory();
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
{
|
{
|
||||||
getLocalPlayer()->removeSpells();
|
getLocalPlayer()->removeSpells();
|
||||||
}
|
}
|
||||||
else // PacketSpells::UPDATE
|
else // PacketSpells::SET
|
||||||
{
|
{
|
||||||
getLocalPlayer()->setSpellbook();
|
getLocalPlayer()->setSpellbook();
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,11 @@ namespace mwmp
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
enum ACTION_TYPE
|
enum ACTION_TYPE
|
||||||
{
|
{
|
||||||
UPDATE = 0,
|
SET = 0,
|
||||||
ADD,
|
ADD,
|
||||||
REMOVE
|
REMOVE
|
||||||
};
|
};
|
||||||
int action; //0 - Full update, 1 - Add item, 2 - Remove item
|
int action; //0 - Clear and set in entirety, 1 - Add item, 2 - Remove item
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PacketSpells
|
struct PacketSpells
|
||||||
|
@ -65,11 +65,11 @@ namespace mwmp
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
enum ACTION_TYPE
|
enum ACTION_TYPE
|
||||||
{
|
{
|
||||||
UPDATE = 0,
|
SET = 0,
|
||||||
ADD,
|
ADD,
|
||||||
REMOVE
|
REMOVE
|
||||||
};
|
};
|
||||||
int action; //0 - Full update, 1 - Add spell, 2 - Remove spell
|
int action; //0 - Clear and set in entirety, 1 - Add spell, 2 - Remove spell
|
||||||
};
|
};
|
||||||
|
|
||||||
class BasePlayer
|
class BasePlayer
|
||||||
|
|
Loading…
Reference in a new issue