[General] Add & implement PlayerShapeshift packet for werewolf states

This commit is contained in:
David Cernat 2017-07-15 09:02:19 +03:00
parent f17aa2a323
commit 43a3daf0aa
18 changed files with 195 additions and 58 deletions

View file

@ -131,9 +131,10 @@ set(PROCESSORS_PLAYER
processors/player/ProcessorPlayerJournal.hpp processors/player/ProcessorPlayerKillCount.hpp processors/player/ProcessorPlayerJournal.hpp processors/player/ProcessorPlayerKillCount.hpp
processors/player/ProcessorPlayerLevel.hpp processors/player/ProcessorPlayerMap.hpp processors/player/ProcessorPlayerLevel.hpp processors/player/ProcessorPlayerMap.hpp
processors/player/ProcessorPlayerPosition.hpp processors/player/ProcessorPlayerRest.hpp processors/player/ProcessorPlayerPosition.hpp processors/player/ProcessorPlayerRest.hpp
processors/player/ProcessorPlayerResurrect.hpp processors/player/ProcessorPlayerSkill.hpp processors/player/ProcessorPlayerResurrect.hpp processors/player/ProcessorPlayerShapeshift.hpp
processors/player/ProcessorPlayerSpeech.hpp processors/player/ProcessorPlayerSpellbook.hpp processors/player/ProcessorPlayerSkill.hpp processors/player/ProcessorPlayerSpeech.hpp
processors/player/ProcessorPlayerStatsDynamic.hpp processors/player/ProcessorPlayerTopic.hpp processors/player/ProcessorPlayerSpellbook.hpp processors/player/ProcessorPlayerStatsDynamic.hpp
processors/player/ProcessorPlayerTopic.hpp
) )
source_group(tes3mp-server\\processors\\player FILES ${PROCESSORS_PLAYER}) source_group(tes3mp-server\\processors\\player FILES ${PROCESSORS_PLAYER})

View file

@ -145,6 +145,7 @@ public:
{"OnPlayerInventory", Function<void, unsigned short>()}, {"OnPlayerInventory", Function<void, unsigned short>()},
{"OnPlayerJournal", Function<void, unsigned short>()}, {"OnPlayerJournal", Function<void, unsigned short>()},
{"OnPlayerFaction", Function<void, unsigned short>()}, {"OnPlayerFaction", Function<void, unsigned short>()},
{"OnPlayerShapeshift", Function<void, unsigned short>()},
{"OnPlayerSpellbook", Function<void, unsigned short>()}, {"OnPlayerSpellbook", Function<void, unsigned short>()},
{"OnPlayerTopic", Function<void, unsigned short>()}, {"OnPlayerTopic", Function<void, unsigned short>()},
{"OnPlayerDisposition", Function<void, unsigned short>()}, {"OnPlayerDisposition", Function<void, unsigned short>()},

View file

@ -33,6 +33,7 @@
#include "player/ProcessorPlayerPosition.hpp" #include "player/ProcessorPlayerPosition.hpp"
#include "player/ProcessorPlayerRest.hpp" #include "player/ProcessorPlayerRest.hpp"
#include "player/ProcessorPlayerResurrect.hpp" #include "player/ProcessorPlayerResurrect.hpp"
#include "player/ProcessorPlayerShapeshift.hpp"
#include "player/ProcessorPlayerSkill.hpp" #include "player/ProcessorPlayerSkill.hpp"
#include "player/ProcessorPlayerSpeech.hpp" #include "player/ProcessorPlayerSpeech.hpp"
#include "player/ProcessorPlayerSpellbook.hpp" #include "player/ProcessorPlayerSpellbook.hpp"
@ -101,6 +102,7 @@ void ProcessorInitializer()
PlayerProcessor::AddProcessor(new ProcessorPlayerPosition()); PlayerProcessor::AddProcessor(new ProcessorPlayerPosition());
PlayerProcessor::AddProcessor(new ProcessorPlayerRest()); PlayerProcessor::AddProcessor(new ProcessorPlayerRest());
PlayerProcessor::AddProcessor(new ProcessorPlayerResurrect()); PlayerProcessor::AddProcessor(new ProcessorPlayerResurrect());
PlayerProcessor::AddProcessor(new ProcessorPlayerShapeshift());
PlayerProcessor::AddProcessor(new ProcessorPlayerSkill()); PlayerProcessor::AddProcessor(new ProcessorPlayerSkill());
PlayerProcessor::AddProcessor(new ProcessorPlayerSpeech()); PlayerProcessor::AddProcessor(new ProcessorPlayerSpeech());
PlayerProcessor::AddProcessor(new ProcessorPlayerSpellbook()); PlayerProcessor::AddProcessor(new ProcessorPlayerSpellbook());

View file

@ -0,0 +1,27 @@
#ifndef OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP
#define OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP
#include "../PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerShapeshift : public PlayerProcessor
{
public:
ProcessorPlayerShapeshift()
{
BPP_INIT(ID_PLAYER_SHAPESHIFT)
}
void Do(PlayerPacket &packet, Player &player) override
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str());
packet.Send(true);
Script::Call<Script::CallbackIdentity("OnPlayerShapeshift")>(player.getId());
}
};
}
#endif //OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP

View file

@ -117,8 +117,8 @@ add_openmw_dir (mwmp/processors/player ProcessorChatMessage ProcessorGUIMessageB
ProcessorPlayerBook ProcessorPlayerBounty ProcessorPlayerCellChange ProcessorPlayerCellState ProcessorPlayerCharClass ProcessorPlayerBook ProcessorPlayerBounty ProcessorPlayerCellChange ProcessorPlayerCellState ProcessorPlayerCharClass
ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDisposition ProcessorPlayerEquipment ProcessorPlayerFaction ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDisposition ProcessorPlayerEquipment ProcessorPlayerFaction
ProcessorPlayerInventory ProcessorPlayerJail ProcessorPlayerJournal ProcessorPlayerKillCount ProcessorPlayerLevel ProcessorPlayerInventory ProcessorPlayerJail ProcessorPlayerJournal ProcessorPlayerKillCount ProcessorPlayerLevel
ProcessorPlayerMap ProcessorPlayerPosition ProcessorPlayerResurrect ProcessorPlayerSkill ProcessorPlayerSpeech ProcessorPlayerMap ProcessorPlayerPosition ProcessorPlayerResurrect ProcessorPlayerShapeshift ProcessorPlayerSkill
ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic ProcessorPlayerTopic ProcessorPlayerSpeech ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic ProcessorPlayerTopic
) )
add_openmw_dir (mwmp/processors/world BaseObjectProcessor ProcessorConsoleCommand ProcessorContainer ProcessorDoorState add_openmw_dir (mwmp/processors/world BaseObjectProcessor ProcessorConsoleCommand ProcessorContainer ProcessorDoorState

View file

@ -237,6 +237,11 @@ void DedicatedPlayer::setCell()
Main::get().getCellController()->getCell(cell)->updateLocal(true); Main::get().getCellController()->getCell(cell)->updateLocal(true);
} }
void DedicatedPlayer::setShapeshift()
{
MWBase::Environment::get().getMechanicsManager()->setWerewolf(ptr, isWerewolf);
}
void DedicatedPlayer::updateMarker() void DedicatedPlayer::updateMarker()
{ {
if (!markerEnabled) if (!markerEnabled)

View file

@ -37,6 +37,7 @@ namespace mwmp
void setAnimFlags(); void setAnimFlags();
void setEquipment(); void setEquipment();
void setCell(); void setCell();
void setShapeshift();
void updateMarker(); void updateMarker();
void removeMarker(); void removeMarker();

View file

@ -149,8 +149,8 @@ bool LocalPlayer::charGenThread()
else if (charGenStage.end != 0) else if (charGenStage.end != 0)
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
npc = *player.get<ESM::NPC>()->mBase; npc = *ptrPlayer.get<ESM::NPC>()->mBase;
birthsign = world->getPlayer().getBirthSign(); birthsign = world->getPlayer().getBirthSign();
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_BASEINFO to server with my CharGen info"); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_BASEINFO to server with my CharGen info");
@ -187,9 +187,9 @@ bool LocalPlayer::hasFinishedCharGen()
void LocalPlayer::updateStatsDynamic(bool forceUpdate) void LocalPlayer::updateStatsDynamic(bool forceUpdate)
{ {
MWWorld::Ptr player = getPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
MWMechanics::DynamicStat<float> health(ptrCreatureStats->getHealth()); MWMechanics::DynamicStat<float> health(ptrCreatureStats->getHealth());
MWMechanics::DynamicStat<float> magicka(ptrCreatureStats->getMagicka()); MWMechanics::DynamicStat<float> magicka(ptrCreatureStats->getMagicka());
MWMechanics::DynamicStat<float> fatigue(ptrCreatureStats->getFatigue()); MWMechanics::DynamicStat<float> fatigue(ptrCreatureStats->getFatigue());
@ -223,8 +223,8 @@ void LocalPlayer::updateStatsDynamic(bool forceUpdate)
void LocalPlayer::updateAttributes(bool forceUpdate) void LocalPlayer::updateAttributes(bool forceUpdate)
{ {
MWWorld::Ptr player = getPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player); const MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
bool attributesChanged = false; bool attributesChanged = false;
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
@ -245,8 +245,8 @@ void LocalPlayer::updateAttributes(bool forceUpdate)
void LocalPlayer::updateSkills(bool forceUpdate) void LocalPlayer::updateSkills(bool forceUpdate)
{ {
MWWorld::Ptr player = getPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player); const MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
// Track whether skills have changed their values, but not whether // Track whether skills have changed their values, but not whether
// progress towards skill increases has changed (to not spam server // progress towards skill increases has changed (to not spam server
@ -282,8 +282,8 @@ void LocalPlayer::updateSkills(bool forceUpdate)
void LocalPlayer::updateLevel(bool forceUpdate) void LocalPlayer::updateLevel(bool forceUpdate)
{ {
MWWorld::Ptr player = getPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
const MWMechanics::CreatureStats &ptrCreatureStats = player.getClass().getCreatureStats(player); const MWMechanics::CreatureStats &ptrCreatureStats = ptrPlayer.getClass().getCreatureStats(ptrPlayer);
if (ptrCreatureStats.getLevel() != creatureStats.mLevel || forceUpdate) if (ptrCreatureStats.getLevel() != creatureStats.mLevel || forceUpdate)
{ {
@ -299,8 +299,8 @@ void LocalPlayer::updateLevel(bool forceUpdate)
void LocalPlayer::updateBounty(bool forceUpdate) void LocalPlayer::updateBounty(bool forceUpdate)
{ {
MWWorld::Ptr player = getPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
const MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player); const MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
if (ptrNpcStats.getBounty() != npcStats.mBounty || forceUpdate) if (ptrNpcStats.getBounty() != npcStats.mBounty || forceUpdate)
{ {
@ -313,14 +313,14 @@ void LocalPlayer::updateBounty(bool forceUpdate)
void LocalPlayer::updatePosition(bool forceUpdate) void LocalPlayer::updatePosition(bool forceUpdate)
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
static bool posWasChanged = false; static bool posWasChanged = false;
static bool isJumping = false; static bool isJumping = false;
static bool sentJumpEnd = true; static bool sentJumpEnd = true;
static float oldRot[2] = {0}; static float oldRot[2] = {0};
position = player.getRefData().getPosition(); position = ptrPlayer.getRefData().getPosition();
bool posIsChanging = (direction.pos[0] != 0 || direction.pos[1] != 0 || bool posIsChanging = (direction.pos[0] != 0 || direction.pos[1] != 0 ||
position.rot[0] != oldRot[0] || position.rot[2] != oldRot[1]); position.rot[0] != oldRot[0] || position.rot[2] != oldRot[1]);
@ -332,13 +332,13 @@ void LocalPlayer::updatePosition(bool forceUpdate)
posWasChanged = posIsChanging; posWasChanged = posIsChanging;
if (!isJumping && !world->isOnGround(player) && !world->isFlying(player)) if (!isJumping && !world->isOnGround(ptrPlayer) && !world->isFlying(ptrPlayer))
isJumping = true; isJumping = true;
getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->Send(); getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->Send();
} }
else if (isJumping && world->isOnGround(player)) else if (isJumping && world->isOnGround(ptrPlayer))
{ {
isJumping = false; isJumping = false;
sentJumpEnd = false; sentJumpEnd = false;
@ -347,7 +347,7 @@ void LocalPlayer::updatePosition(bool forceUpdate)
else if (!sentJumpEnd) else if (!sentJumpEnd)
{ {
sentJumpEnd = true; sentJumpEnd = true;
position = player.getRefData().getPosition(); position = ptrPlayer.getRefData().getPosition();
getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->setPlayer(this); getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->Send(); getNetworking()->getPlayerPacket(ID_PLAYER_POSITION)->Send();
} }
@ -402,14 +402,14 @@ void LocalPlayer::updateChar()
void LocalPlayer::updateEquipment(bool forceUpdate) void LocalPlayer::updateEquipment(bool forceUpdate)
{ {
MWWorld::Ptr player = getPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
static bool equipmentChanged = false; static bool equipmentChanged = false;
if (forceUpdate) if (forceUpdate)
equipmentChanged = true; equipmentChanged = true;
MWWorld::InventoryStore &invStore = player.getClass().getInventoryStore(player); MWWorld::InventoryStore &invStore = ptrPlayer.getClass().getInventoryStore(ptrPlayer);
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++) for (int slot = 0; slot < MWWorld::InventoryStore::Slots; slot++)
{ {
auto &item = equipedItems[slot]; auto &item = equipedItems[slot];
@ -425,8 +425,8 @@ void LocalPlayer::updateEquipment(bool forceUpdate)
if (slot == MWWorld::InventoryStore::Slot_CarriedRight) if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
{ {
MWMechanics::WeaponType weaptype; MWMechanics::WeaponType weaptype;
MWMechanics::getActiveWeapon(player.getClass().getCreatureStats(player), MWMechanics::getActiveWeapon(ptrPlayer.getClass().getCreatureStats(ptrPlayer),
player.getClass().getInventoryStore(player), &weaptype); ptrPlayer.getClass().getInventoryStore(ptrPlayer), &weaptype);
if (weaptype != MWMechanics::WeapType_Thrown) if (weaptype != MWMechanics::WeapType_Thrown)
item.count = 1; item.count = 1;
} }
@ -536,9 +536,9 @@ void LocalPlayer::updateAttack()
void LocalPlayer::updateDeadState(bool forceUpdate) void LocalPlayer::updateDeadState(bool forceUpdate)
{ {
MWWorld::Ptr player = getPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
MWMechanics::NpcStats *ptrNpcStats = &player.getClass().getNpcStats(player); MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer);
static bool isDead = false; static bool isDead = false;
if (ptrNpcStats->isDead() && !isDead) if (ptrNpcStats->isDead() && !isDead)
@ -561,9 +561,9 @@ void LocalPlayer::updateDeadState(bool forceUpdate)
void LocalPlayer::updateAnimFlags(bool forceUpdate) void LocalPlayer::updateAnimFlags(bool forceUpdate)
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
MWMechanics::NpcStats ptrNpcStats = player.getClass().getNpcStats(player); MWMechanics::NpcStats ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
using namespace MWMechanics; using namespace MWMechanics;
static bool wasRunning = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Run); static bool wasRunning = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Run);
@ -576,16 +576,16 @@ void LocalPlayer::updateAnimFlags(bool forceUpdate)
bool isForceJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceJump); bool isForceJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceJump);
bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump); bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
isFlying = world->isFlying(player); isFlying = world->isFlying(ptrPlayer);
bool isJumping = !world->isOnGround(player) && !isFlying; bool isJumping = !world->isOnGround(ptrPlayer) && !isFlying;
// We need to send a new packet at the end of jumping and flying too, // We need to send a new packet at the end of jumping and flying too,
// so keep track of what we were doing last frame // so keep track of what we were doing last frame
static bool wasJumping = false; static bool wasJumping = false;
static bool wasFlying = false; static bool wasFlying = false;
MWMechanics::DrawState_ currentDrawState = player.getClass().getNpcStats(player).getDrawState(); MWMechanics::DrawState_ currentDrawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState();
static MWMechanics::DrawState_ lastDrawState = player.getClass().getNpcStats(player).getDrawState(); static MWMechanics::DrawState_ lastDrawState = ptrPlayer.getClass().getNpcStats(ptrPlayer).getDrawState();
if (wasRunning != isRunning || if (wasRunning != isRunning ||
wasSneaking != isSneaking || wasForceJumping != isForceJumping || wasSneaking != isSneaking || wasForceJumping != isForceJumping ||
@ -649,7 +649,7 @@ void LocalPlayer::addSpells()
for (const auto &spell : spellbookChanges.spells) for (const auto &spell : spellbookChanges.spells)
ptrSpells.add(spell.mId); ptrSpells.add(spell.mId);
} }
void LocalPlayer::addJournalItems() void LocalPlayer::addJournalItems()
@ -714,9 +714,9 @@ void LocalPlayer::removeSpells()
void LocalPlayer::setDynamicStats() void LocalPlayer::setDynamicStats()
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
MWMechanics::DynamicStat<float> dynamicStat; MWMechanics::DynamicStat<float> dynamicStat;
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
@ -731,9 +731,9 @@ void LocalPlayer::setDynamicStats()
void LocalPlayer::setAttributes() void LocalPlayer::setAttributes()
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
MWMechanics::AttributeValue attributeValue; MWMechanics::AttributeValue attributeValue;
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
@ -746,9 +746,9 @@ void LocalPlayer::setAttributes()
void LocalPlayer::setSkills() void LocalPlayer::setSkills()
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
MWMechanics::NpcStats *ptrNpcStats = &player.getClass().getNpcStats(player); MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer);
MWMechanics::SkillValue skillValue; MWMechanics::SkillValue skillValue;
for (int i = 0; i < 27; ++i) for (int i = 0; i < 27; ++i)
@ -766,25 +766,25 @@ void LocalPlayer::setSkills()
void LocalPlayer::setLevel() void LocalPlayer::setLevel()
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &player.getClass().getCreatureStats(player); MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
ptrCreatureStats->setLevel(creatureStats.mLevel); ptrCreatureStats->setLevel(creatureStats.mLevel);
} }
void LocalPlayer::setBounty() void LocalPlayer::setBounty()
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
MWMechanics::NpcStats *ptrNpcStats = &player.getClass().getNpcStats(player); MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer);
ptrNpcStats->setBounty(npcStats.mBounty); ptrNpcStats->setBounty(npcStats.mBounty);
} }
void LocalPlayer::setPosition() void LocalPlayer::setPosition()
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
// If we're ignoring this position packet because of an invalid cell change, // If we're ignoring this position packet because of an invalid cell change,
// don't make the next one get ignored as well // don't make the next one get ignored as well
@ -793,8 +793,8 @@ void LocalPlayer::setPosition()
else else
{ {
world->getPlayer().setTeleported(true); world->getPlayer().setTeleported(true);
world->moveObject(player, position.pos[0], position.pos[1], position.pos[2]); world->moveObject(ptrPlayer, position.pos[0], position.pos[1], position.pos[2]);
world->rotateObject(player, position.rot[0], position.rot[1], position.rot[2]); world->rotateObject(ptrPlayer, position.rot[0], position.rot[1], position.rot[2]);
} }
updatePosition(true); updatePosition(true);
@ -806,7 +806,7 @@ void LocalPlayer::setPosition()
void LocalPlayer::setCell() void LocalPlayer::setCell()
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr();
ESM::Position pos; ESM::Position pos;
// To avoid crashes, close any container menus this player may be in // To avoid crashes, close any container menus this player may be in
@ -829,12 +829,12 @@ void LocalPlayer::setCell()
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
world->changeToExteriorCell(pos, true); world->changeToExteriorCell(pos, true);
world->fixPosition(player); world->fixPosition(ptrPlayer);
} }
else if (world->findExteriorPosition(cell.mName, pos)) else if (world->findExteriorPosition(cell.mName, pos))
{ {
world->changeToExteriorCell(pos, true); world->changeToExteriorCell(pos, true);
world->fixPosition(player); world->fixPosition(ptrPlayer);
} }
else else
{ {
@ -950,8 +950,8 @@ void LocalPlayer::setSpellbook()
void LocalPlayer::setFactions() void LocalPlayer::setFactions()
{ {
MWWorld::Ptr player = getPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player); MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
for (const auto &faction : factionChanges.factions) for (const auto &faction : factionChanges.factions)
{ {
@ -997,8 +997,8 @@ void LocalPlayer::setKills()
void LocalPlayer::setBooks() void LocalPlayer::setBooks()
{ {
MWWorld::Ptr player = getPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player); MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
for (const auto &book : bookChanges.books) for (const auto &book : bookChanges.books)
ptrNpcStats.flagAsUsed(book.bookId); ptrNpcStats.flagAsUsed(book.bookId);
@ -1006,8 +1006,8 @@ void LocalPlayer::setBooks()
void LocalPlayer::setMapExplored() void LocalPlayer::setMapExplored()
{ {
MWWorld::Ptr player = getPlayerPtr(); MWWorld::Ptr ptrPlayer = getPlayerPtr();
MWMechanics::NpcStats &ptrNpcStats = player.getClass().getNpcStats(player); MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
for (const auto &cellExplored : mapChanges.cellsExplored) for (const auto &cellExplored : mapChanges.cellsExplored)
{ {
@ -1018,6 +1018,12 @@ void LocalPlayer::setMapExplored()
} }
} }
void LocalPlayer::setShapeshift()
{
MWWorld::Ptr ptrPlayer = getPlayerPtr();
MWBase::Environment::get().getMechanicsManager()->setWerewolf(ptrPlayer, isWerewolf);
}
void LocalPlayer::sendClass() void LocalPlayer::sendClass()
{ {
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
@ -1259,6 +1265,16 @@ void LocalPlayer::sendBook(const std::string& bookId)
getNetworking()->getPlayerPacket(ID_PLAYER_BOOK)->Send(); getNetworking()->getPlayerPacket(ID_PLAYER_BOOK)->Send();
} }
void LocalPlayer::sendShapeshift(bool werewolfState)
{
isWerewolf = werewolfState;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_SHAPESHIFT with isWerewolf of %s", isWerewolf ? "true" : "false");
getNetworking()->getPlayerPacket(ID_PLAYER_SHAPESHIFT)->setPlayer(this);
getNetworking()->getPlayerPacket(ID_PLAYER_SHAPESHIFT)->Send();
}
void LocalPlayer::clearCellStates() void LocalPlayer::clearCellStates()
{ {
cellStateChanges.cellStates.clear(); cellStateChanges.cellStates.clear();

View file

@ -62,6 +62,7 @@ namespace mwmp
void setKills(); void setKills();
void setBooks(); void setBooks();
void setMapExplored(); void setMapExplored();
void setShapeshift();
void sendClass(); void sendClass();
void sendInventory(); void sendInventory();
@ -79,6 +80,7 @@ namespace mwmp
void sendTopic(const std::string& topic); void sendTopic(const std::string& topic);
void sendKill(const std::string& refId, int number); void sendKill(const std::string& refId, int number);
void sendBook(const std::string& bookId); void sendBook(const std::string& bookId);
void sendShapeshift(bool isWerewolf);
void clearCellStates(); void clearCellStates();
void clearCurrentContainer(); void clearCurrentContainer();

View file

@ -38,6 +38,7 @@
#include "player/ProcessorPlayerRegionAuthority.hpp" #include "player/ProcessorPlayerRegionAuthority.hpp"
#include "player/ProcessorPlayerRest.hpp" #include "player/ProcessorPlayerRest.hpp"
#include "player/ProcessorPlayerResurrect.hpp" #include "player/ProcessorPlayerResurrect.hpp"
#include "player/ProcessorPlayerShapeshift.hpp"
#include "player/ProcessorPlayerSkill.hpp" #include "player/ProcessorPlayerSkill.hpp"
#include "player/ProcessorPlayerSpeech.hpp" #include "player/ProcessorPlayerSpeech.hpp"
#include "player/ProcessorPlayerSpellbook.hpp" #include "player/ProcessorPlayerSpellbook.hpp"
@ -115,6 +116,7 @@ void ProcessorInitializer()
PlayerProcessor::AddProcessor(new ProcessorPlayerRegionAuthority()); PlayerProcessor::AddProcessor(new ProcessorPlayerRegionAuthority());
PlayerProcessor::AddProcessor(new ProcessorPlayerRest()); PlayerProcessor::AddProcessor(new ProcessorPlayerRest());
PlayerProcessor::AddProcessor(new ProcessorPlayerResurrect()); PlayerProcessor::AddProcessor(new ProcessorPlayerResurrect());
PlayerProcessor::AddProcessor(new ProcessorPlayerShapeshift());
PlayerProcessor::AddProcessor(new ProcessorPlayerSkill()); PlayerProcessor::AddProcessor(new ProcessorPlayerSkill());
PlayerProcessor::AddProcessor(new ProcessorPlayerSpeech()); PlayerProcessor::AddProcessor(new ProcessorPlayerSpeech());
PlayerProcessor::AddProcessor(new ProcessorPlayerSpellbook()); PlayerProcessor::AddProcessor(new ProcessorPlayerSpellbook());

View file

@ -0,0 +1,30 @@
#ifndef OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP
#define OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP
#include "../PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerShapeshift : public PlayerProcessor
{
public:
ProcessorPlayerShapeshift()
{
BPP_INIT(ID_PLAYER_SHAPESHIFT)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
static_cast<LocalPlayer *>(player)->setShapeshift();
}
else if (player != 0)
{
static_cast<DedicatedPlayer *>(player)->setShapeshift();
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERSHAPESHIFT_HPP

View file

@ -1224,6 +1224,17 @@ namespace MWScript
{ {
MWWorld::Ptr ptr = R()(runtime); MWWorld::Ptr ptr = R()(runtime);
MWBase::Environment::get().getMechanicsManager()->setWerewolf(ptr, set); MWBase::Environment::get().getMechanicsManager()->setWerewolf(ptr, set);
/*
Start of tes3mp addition
When the player's werewolf state changes, send an ID_PLAYER_SHAPESHIFT packet
*/
if (ptr == MWMechanics::getPlayer())
mwmp::Main::get().getLocalPlayer()->sendShapeshift(set);
/*
End of tes3mp addition
*/
} }
}; };

View file

@ -182,7 +182,8 @@ add_component_dir (openmw-mp/Packets/Player
PacketPlayerCellState PacketPlayerClass PacketPlayerDeath PacketPlayerEquipment PacketPlayerFaction PacketPlayerCellState PacketPlayerClass PacketPlayerDeath PacketPlayerEquipment PacketPlayerFaction
PacketPlayerInventory PacketPlayerJail PacketPlayerJournal PacketPlayerKillCount PacketPlayerLevel PacketPlayerInventory PacketPlayerJail PacketPlayerJournal PacketPlayerKillCount PacketPlayerLevel
PacketPlayerMap PacketPlayerPosition PacketPlayerRegionAuthority PacketPlayerRest PacketPlayerResurrect PacketPlayerMap PacketPlayerPosition PacketPlayerRegionAuthority PacketPlayerRest PacketPlayerResurrect
PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic PacketPlayerTopic PacketPlayerShapeshift PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic
PacketPlayerTopic
) )
add_component_dir (openmw-mp/Packets/World add_component_dir (openmw-mp/Packets/World

View file

@ -246,6 +246,8 @@ namespace mwmp
std::string chatMessage; std::string chatMessage;
CGStage charGenStage; CGStage charGenStage;
std::string passw; std::string passw;
bool isWerewolf;
std::string creatureModel; std::string creatureModel;
bool useCreatureName; bool useCreatureName;

View file

@ -31,6 +31,7 @@
#include "../Packets/Player/PacketPlayerRegionAuthority.hpp" #include "../Packets/Player/PacketPlayerRegionAuthority.hpp"
#include "../Packets/Player/PacketPlayerRest.hpp" #include "../Packets/Player/PacketPlayerRest.hpp"
#include "../Packets/Player/PacketPlayerResurrect.hpp" #include "../Packets/Player/PacketPlayerResurrect.hpp"
#include "../Packets/Player/PacketPlayerShapeshift.hpp"
#include "../Packets/Player/PacketPlayerSkill.hpp" #include "../Packets/Player/PacketPlayerSkill.hpp"
#include "../Packets/Player/PacketPlayerSpeech.hpp" #include "../Packets/Player/PacketPlayerSpeech.hpp"
#include "../Packets/Player/PacketPlayerSpellbook.hpp" #include "../Packets/Player/PacketPlayerSpellbook.hpp"
@ -83,6 +84,7 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p
AddPacket<PacketPlayerRegionAuthority>(&packets, peer); AddPacket<PacketPlayerRegionAuthority>(&packets, peer);
AddPacket<PacketPlayerRest>(&packets, peer); AddPacket<PacketPlayerRest>(&packets, peer);
AddPacket<PacketPlayerResurrect>(&packets, peer); AddPacket<PacketPlayerResurrect>(&packets, peer);
AddPacket<PacketPlayerShapeshift>(&packets, peer);
AddPacket<PacketPlayerSkill>(&packets, peer); AddPacket<PacketPlayerSkill>(&packets, peer);
AddPacket<PacketPlayerSpeech>(&packets, peer); AddPacket<PacketPlayerSpeech>(&packets, peer);
AddPacket<PacketPlayerSpellbook>(&packets, peer); AddPacket<PacketPlayerSpellbook>(&packets, peer);

View file

@ -47,6 +47,7 @@ enum GameMessages
ID_PLAYER_REGION_AUTHORITY, ID_PLAYER_REGION_AUTHORITY,
ID_PLAYER_RESURRECT, ID_PLAYER_RESURRECT,
ID_PLAYER_REST, ID_PLAYER_REST,
ID_PLAYER_SHAPESHIFT,
ID_PLAYER_SKILL, ID_PLAYER_SKILL,
ID_PLAYER_SPEECH, ID_PLAYER_SPEECH,
ID_PLAYER_SPELLBOOK, ID_PLAYER_SPELLBOOK,

View file

@ -0,0 +1,16 @@
#include "PacketPlayerShapeshift.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
using namespace mwmp;
PacketPlayerShapeshift::PacketPlayerShapeshift(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_SHAPESHIFT;
}
void PacketPlayerShapeshift::Packet(RakNet::BitStream *bs, bool send)
{
PlayerPacket::Packet(bs, send);
RW(player->isWerewolf, send);
}

View file

@ -0,0 +1,17 @@
#ifndef OPENMW_PACKETPLAYERSHAPESHIFT_HPP
#define OPENMW_PACKETPLAYERSHAPESHIFT_HPP
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
namespace mwmp
{
class PacketPlayerShapeshift : public PlayerPacket
{
public:
PacketPlayerShapeshift(RakNet::RakPeerInterface *peer);
virtual void Packet(RakNet::BitStream *bs, bool send);
};
}
#endif //OPENMW_PACKETPLAYERSHAPESHIFT_HPP