[Client] Add player processors

pull/199/head
Koncord 8 years ago
parent a6111b6599
commit f09dc2b65b

@ -0,0 +1,30 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORCHATMESSAGE_HPP
#define OPENMW_PROCESSORCHATMESSAGE_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
#include "apps/openmw/mwmp/Main.hpp"
#include "apps/openmw/mwmp/GUIController.hpp"
namespace mwmp
{
class ProcessorChatMessage : public PlayerProcessor
{
public:
ProcessorChatMessage()
{
BPP_INIT(ID_CHAT_MESSAGE)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
Main::get().getGUIController()->printChatMessage(player->chatMessage);
}
};
}
#endif //OPENMW_PROCESSORCHATMESSAGE_HPP

@ -0,0 +1,44 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORGUIMESSAGEBOX_HPP
#define OPENMW_PROCESSORGUIMESSAGEBOX_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorGUIMessageBox : public PlayerProcessor
{
public:
ProcessorGUIMessageBox()
{
BPP_INIT(ID_GUI_MESSAGEBOX)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_GUI_MESSAGEBOX, Type %d, MSG %s", player->guiMessageBox.type,
player->guiMessageBox.label.c_str());
int messageBoxType = player->guiMessageBox.type;
if (messageBoxType == BasePlayer::GUIMessageBox::MessageBox)
Main::get().getGUIController()->showMessageBox(player->guiMessageBox);
else if (messageBoxType == BasePlayer::GUIMessageBox::CustomMessageBox)
Main::get().getGUIController()->showCustomMessageBox(player->guiMessageBox);
else if (messageBoxType == BasePlayer::GUIMessageBox::InputDialog)
Main::get().getGUIController()->showInputBox(player->guiMessageBox);
else if (messageBoxType == BasePlayer::GUIMessageBox::ListBox)
Main::get().getGUIController()->showDialogList(player->guiMessageBox);
}
}
};
}
#endif //OPENMW_PROCESSORGUIMESSAGEBOX_HPP

@ -0,0 +1,30 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORGAMECONSOLE_HPP
#define OPENMW_PROCESSORGAMECONSOLE_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorGameConsole : public PlayerProcessor
{
public:
ProcessorGameConsole()
{
BPP_INIT(ID_GAME_CONSOLE)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
}
};
}
#endif //OPENMW_PROCESSORGAMECONSOLE_HPP

@ -0,0 +1,39 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORGAMETIME_HPP
#define OPENMW_PROCESSORGAMETIME_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorGameTime : public PlayerProcessor
{
public:
ProcessorGameTime()
{
BPP_INIT(ID_PLAYER_CHARCLASS)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
MWBase::World *world = MWBase::Environment::get().getWorld();
if (player->hour != -1)
world->setHour(player->hour);
else if (player->day != -1)
world->setDay(player->day);
else if (player->month != -1)
world->setMonth(player->month);
}
}
};
}
#endif //OPENMW_PROCESSORGAMETIME_HPP

@ -0,0 +1,28 @@
//
// Created by koncord on 04.04.17.
//
#ifndef OPENMW_PROCESSORHANDSHAKE_HPP
#define OPENMW_PROCESSORHANDSHAKE_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorHandshake : public PlayerProcessor
{
public:
ProcessorHandshake()
{
BPP_INIT(ID_HANDSHAKE)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
packet.setPlayer(getLocalPlayer()); // player is 0 because myGuid will be setted after ProcessUserMyID
packet.Send(serverAddr);
}
};
}
#endif //OPENMW_PROCESSORHANDSHAKE_HPP

@ -0,0 +1,88 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERATTACK_HPP
#define OPENMW_PROCESSORPLAYERATTACK_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
#include "apps/openmw/mwbase/world.hpp"
#include "apps/openmw/mwworld/containerstore.hpp"
#include "apps/openmw/mwworld/inventorystore.hpp"
#include "apps/openmw/mwmechanics/combat.hpp"
#include "apps/openmw/mwbase/environment.hpp"
namespace mwmp
{
class ProcessorPlayerAttack : public PlayerProcessor
{
public:
ProcessorPlayerAttack()
{
BPP_INIT(ID_PLAYER_ATTACK)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
DedicatedPlayer &dedicatedPlayer = static_cast<DedicatedPlayer&>(*player);
//cout << "Player: " << dedicatedPlayer.Npc()->mName << " pressed: " << (dedicatedPlayer.getAttack()->pressed == 1) << endl;
if (dedicatedPlayer.attack.pressed == 0)
{
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Attack success: %s", dedicatedPlayer.attack.success ? "true" : "false");
if (dedicatedPlayer.attack.success == 1)
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Damage: %f",dedicatedPlayer.attack.damage);
}
MWMechanics::CreatureStats &stats = dedicatedPlayer.getPtr().getClass().getNpcStats(dedicatedPlayer.getPtr());
stats.getSpells().setSelectedSpell(dedicatedPlayer.attack.refid);
MWWorld::Ptr victim;
if (dedicatedPlayer.attack.target == getLocalPlayer()->guid)
victim = MWBase::Environment::get().getWorld()->getPlayerPtr();
else if (Players::getPlayer(dedicatedPlayer.attack.target) != 0)
victim = Players::getPlayer(dedicatedPlayer.attack.target)->getPtr();
MWWorld::Ptr attacker;
attacker = dedicatedPlayer.getPtr();
// Get the weapon used (if hand-to-hand, weapon = inv.end())
if (dedicatedPlayer.drawState == 1)
{
MWWorld::InventoryStore &inv = attacker.getClass().getInventoryStore(attacker);
MWWorld::ContainerStoreIterator weaponslot = inv.getSlot(
MWWorld::InventoryStore::Slot_CarriedRight);
MWWorld::Ptr weapon = ((weaponslot != inv.end()) ? *weaponslot : MWWorld::Ptr());
if (!weapon.isEmpty() && weapon.getTypeName() != typeid(ESM::Weapon).name())
weapon = MWWorld::Ptr();
if (victim.mRef != 0)
{
bool healthdmg;
if (!weapon.isEmpty())
healthdmg = true;
else
{
MWMechanics::CreatureStats &otherstats = victim.getClass().getCreatureStats(victim);
healthdmg = otherstats.isParalyzed() || otherstats.getKnockedDown();
}
if (!weapon.isEmpty())
MWMechanics::blockMeleeAttack(attacker, victim, weapon, dedicatedPlayer.attack.damage, 1);
dedicatedPlayer.getPtr().getClass().onHit(victim, dedicatedPlayer.attack.damage, healthdmg, weapon, attacker, osg::Vec3f(),
dedicatedPlayer.attack.success);
}
}
else
{
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "SpellId: %s", dedicatedPlayer.attack.refid.c_str());
LOG_APPEND(Log::LOG_VERBOSE, " - success: %d", dedicatedPlayer.attack.success);
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERATTACK_HPP

@ -0,0 +1,49 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERATTRIBUTE_HPP
#define OPENMW_PROCESSORPLAYERATTRIBUTE_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
#include "apps/openmw/mwmechanics/npcstats.hpp"
#include "apps/openmw/mwclass/npc.hpp"
namespace mwmp
{
class ProcessorPlayerAttribute : public PlayerProcessor
{
public:
ProcessorPlayerAttribute()
{
BPP_INIT(ID_PLAYER_ATTRIBUTE)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if(isRequest())
static_cast<LocalPlayer *>(player)->updateAttributes(true);
else
static_cast<LocalPlayer *>(player)->setAttributes();
}
else
{
MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer *>(player)->getPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
MWMechanics::AttributeValue attributeValue;
for (int i = 0; i < 8; ++i)
{
attributeValue.readState(player->creatureStats.mAttributes[i]);
ptrCreatureStats->setAttribute(i, attributeValue);
}
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERATTRIBUTE_HPP

@ -0,0 +1,58 @@
//
// Created by koncord on 04.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERBASEINFO_HPP
#define OPENMW_PROCESSORPLAYERBASEINFO_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerBaseInfo : public PlayerProcessor
{
public:
ProcessorPlayerBaseInfo()
{
BPP_INIT(ID_PLAYER_BASEINFO)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_BASEINFO from server");
if(isLocal())
{
LOG_APPEND(Log::LOG_INFO, "- Packet was about my id");
if(isRequest())
{
LOG_APPEND(Log::LOG_INFO, "- Requesting info");
packet.Send(serverAddr);
}
else
{
LOG_APPEND(Log::LOG_INFO, "- Updating LocalPlayer");
static_cast<LocalPlayer*>(player)->updateChar();
}
}
else
{
LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player == 0 ? "new player" : player->npc.mName.c_str());
if (player == 0)
{
LOG_APPEND(Log::LOG_INFO, "- Exchanging data with new player");
player = Players::newPlayer(guid);
packet.setPlayer(player);
packet.Read();
}
Players::createPlayer(guid);
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERBASEINFO_HPP

@ -0,0 +1,37 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERCELLCHANGE_HPP
#define OPENMW_PROCESSORPLAYERCELLCHANGE_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerCellChange : public PlayerProcessor
{
public:
ProcessorPlayerCellChange()
{
BPP_INIT(ID_PLAYER_CELL_CHANGE)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if (isRequest())
static_cast<LocalPlayer *>(player)->updateCell(true);
else
static_cast<LocalPlayer *>(player)->setCell();
}
else
static_cast<DedicatedPlayer*>(player)->updateCell();
}
};
}
#endif //OPENMW_PROCESSORPLAYERCELLCHANGE_HPP

@ -0,0 +1,31 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERCELLSTATE_HPP
#define OPENMW_PROCESSORPLAYERCELLSTATE_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerCellState : public PlayerProcessor
{
public:
ProcessorPlayerCellState()
{
BPP_INIT(ID_PLAYER_CELL_STATE)
avoidReading = true;
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal() && isRequest())
static_cast<LocalPlayer *>(player)->sendCellStates();
}
};
}
#endif //OPENMW_PROCESSORPLAYERCELLSTATE_HPP

@ -0,0 +1,35 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERCHARCLASS_HPP
#define OPENMW_PROCESSORPLAYERCHARCLASS_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerCharClass : public PlayerProcessor
{
public:
ProcessorPlayerCharClass()
{
BPP_INIT(ID_PLAYER_CHARCLASS)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if(isRequest())
static_cast<LocalPlayer *>(player)->sendClass();
else
static_cast<LocalPlayer *>(player)->setClass();
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERCHARCLASS_HPP

@ -0,0 +1,29 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERCHARGEN_HPP
#define OPENMW_PROCESSORPLAYERCHARGEN_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerCharGen : public PlayerProcessor
{
public:
ProcessorPlayerCharGen()
{
BPP_INIT(ID_PLAYER_CHARGEN)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
}
};
}
#endif //OPENMW_PROCESSORPLAYERCHARGEN_HPP

@ -0,0 +1,53 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERDEATH_HPP
#define OPENMW_PROCESSORPLAYERDEATH_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerDeath : public PlayerProcessor
{
public:
ProcessorPlayerDeath()
{
BPP_INIT(ID_PLAYER_DEATH)
avoidReading = true;
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_DEATH from server");
if (isLocal())
{
LOG_APPEND(Log::LOG_INFO, "- Packet was about me");
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::DynamicStat<float> health = playerPtr.getClass().getCreatureStats(playerPtr).getHealth();
health.setCurrent(0);
playerPtr.getClass().getCreatureStats(playerPtr).setHealth(health);
packet.setPlayer(player);
packet.Send(serverAddr);
}
else
{
LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str());
MWMechanics::DynamicStat<float> health;
player->creatureStats.mDead = true;
health.readState(player->creatureStats.mDynamic[0]);
health.setCurrent(0);
health.writeState(player->creatureStats.mDynamic[0]);
MWWorld::Ptr ptr = static_cast<DedicatedPlayer*>(player)->getPtr();
ptr.getClass().getCreatureStats(ptr).setHealth(health);
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERDEATH_HPP

@ -0,0 +1,35 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERDRAWSTATE_HPP
#define OPENMW_PROCESSORPLAYERDRAWSTATE_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerDrawState : public PlayerProcessor
{
public:
ProcessorPlayerDrawState()
{
BPP_INIT(ID_PLAYER_DRAWSTATE)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if(isRequest())
static_cast<LocalPlayer *>(player)->updateDrawStateAndFlags(true);
}
else
static_cast<DedicatedPlayer *>(player)->updateDrawState();
}
};
}
#endif //OPENMW_PROCESSORPLAYERDRAWSTATE_HPP

@ -0,0 +1,47 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERDYNAMICSTATS_HPP
#define OPENMW_PROCESSORPLAYERDYNAMICSTATS_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerDynamicStats : public PlayerProcessor
{
public:
ProcessorPlayerDynamicStats()
{
BPP_INIT(ID_PLAYER_DYNAMICSTATS)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if (isRequest())
static_cast<LocalPlayer *>(player)->updateDynamicStats(true);
else
static_cast<LocalPlayer *>(player)->setDynamicStats();
}
else
{
MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer*>(player)->getPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
MWMechanics::DynamicStat<float> value;
for (int i = 0; i < 3; ++i)
{
value.readState(player->creatureStats.mDynamic[i]);
ptrCreatureStats->setDynamic(i, value);
}
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERDYNAMICSTATS_HPP

@ -0,0 +1,36 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYEREQUIPMENT_HPP
#define OPENMW_PROCESSORPLAYEREQUIPMENT_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerEquipment : public PlayerProcessor
{
public:
ProcessorPlayerEquipment()
{
BPP_INIT(ID_PLAYER_EQUIPMENT)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if (isRequest())
static_cast<LocalPlayer*>(player)->updateEquipment(true);
else
static_cast<LocalPlayer*>(player)->setEquipment();
}
else
static_cast<DedicatedPlayer*>(player)->updateEquipment();
}
};
}
#endif //OPENMW_PROCESSORPLAYEREQUIPMENT_HPP

@ -0,0 +1,43 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERUPDATEINVENTORY_HPP
#define OPENMW_PROCESSORPLAYERUPDATEINVENTORY_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerInventory : public PlayerProcessor
{
public:
ProcessorPlayerInventory()
{
BPP_INIT(ID_PLAYER_INVENTORY)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (!isLocal()) return;
if (isRequest())
static_cast<LocalPlayer*>(player)->updateInventory(true);
else
{
LocalPlayer &localPlayer = static_cast<LocalPlayer&>(*player);
int inventoryAction = localPlayer.inventoryChanges.action;
if (inventoryAction == InventoryChanges::ADD)
localPlayer.addItems();
else if (inventoryAction == InventoryChanges::REMOVE)
localPlayer.removeItems();
else // InventoryChanges::SET
localPlayer.setInventory();
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERUPDATEINVENTORY_HPP

@ -0,0 +1,36 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERJOURNAL_HPP
#define OPENMW_PROCESSORPLAYERJOURNAL_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerJournal : public PlayerProcessor
{
public:
ProcessorPlayerJournal()
{
BPP_INIT(ID_PLAYER_JOURNAL)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (!isLocal()) return;
if (isRequest())
{
// Entire journal cannot currently be requested from players
}
else
static_cast<LocalPlayer*>(player)->addJournalItems();
}
};
}
#endif //OPENMW_PROCESSORPLAYERJOURNAL_HPP

@ -0,0 +1,42 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERLEVEL_HPP
#define OPENMW_PROCESSORPLAYERLEVEL_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerLevel : public PlayerProcessor
{
public:
ProcessorPlayerLevel()
{
BPP_INIT(ID_PLAYER_LEVEL)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if(isRequest())
static_cast<LocalPlayer *>(player)->updateLevel(true);
else
static_cast<LocalPlayer *>(player)->setLevel();
}
else
{
MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer *>(player)->getPtr();
MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer);
ptrCreatureStats->setLevel(player->creatureStats.mLevel);
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERLEVEL_HPP

@ -0,0 +1,41 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERPOS_HPP
#define OPENMW_PROCESSORPLAYERPOS_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerPos : public PlayerProcessor
{
public:
ProcessorPlayerPos()
{
BPP_INIT(ID_PLAYER_POS)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if (!isRequest())
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "ID_PLAYER_POS changed by server");
static_cast<LocalPlayer*>(player)->setPosition();
}
else
static_cast<LocalPlayer*>(player)->updatePosition(true);
}
else // dedicated player
static_cast<DedicatedPlayer*>(player)->updateMarker();
}
};
}
#endif //OPENMW_PROCESSORPLAYERPOS_HPP

@ -0,0 +1,67 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERRESURRECT_HPP
#define OPENMW_PROCESSORPLAYERRESURRECT_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
#include "apps/openmw/mwmp/Main.hpp"
#include "apps/openmw/mwmp/Networking.hpp"
namespace mwmp
{
class ProcessorPlayerResurrect : public PlayerProcessor
{
public:
ProcessorPlayerResurrect()
{
BPP_INIT(ID_PLAYER_RESURRECT)
avoidReading = true;
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_RESURRECT from server");
if (isLocal())
{
LOG_APPEND(Log::LOG_INFO, "- Packet was about me");
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
playerPtr.getClass().getCreatureStats(playerPtr).resurrect();
// If this player had a weapon or spell readied when dying, they will
// still have it readied but be unable to use it unless we clear it here
playerPtr.getClass().getNpcStats(playerPtr).setDrawState(MWMechanics::DrawState_Nothing);
packet.setPlayer(player);
packet.Send(serverAddr);
static_cast<LocalPlayer*>(player)->updateDynamicStats(true);
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_DYNAMICSTATS)->setPlayer(player);
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_DYNAMICSTATS)->Send(serverAddr);
}
else
{
LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str());
player->creatureStats.mDead = false;
if (player->creatureStats.mDynamic[0].mMod < 1)
player->creatureStats.mDynamic[0].mMod = 1;
player->creatureStats.mDynamic[0].mCurrent = player->creatureStats.mDynamic[0].mMod;
MWWorld::Ptr ptr = static_cast<DedicatedPlayer*>(player)->getPtr();
ptr.getClass().getCreatureStats(ptr).resurrect();
MWMechanics::DynamicStat<float> health;
health.readState(player->creatureStats.mDynamic[0]);
ptr.getClass().getCreatureStats(ptr).setHealth(health);
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERRESURRECT_HPP

@ -0,0 +1,47 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERSKILL_HPP
#define OPENMW_PROCESSORPLAYERSKILL_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerSkill : public PlayerProcessor
{
public:
ProcessorPlayerSkill()
{
BPP_INIT(ID_PLAYER_SKILL)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
{
if(isRequest())
static_cast<LocalPlayer *>(player)->updateSkills(true);
else
static_cast<LocalPlayer *>(player)->setSkills();
}
else
{
MWWorld::Ptr ptrPlayer = static_cast<DedicatedPlayer *>(player)->getPtr();
MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer);
MWMechanics::SkillValue skillValue;
for (int i = 0; i < 27; ++i)
{
skillValue.readState(player->npcStats.mSkills[i]);
ptrNpcStats->setSkill(i, skillValue);
}
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERSKILL_HPP

@ -0,0 +1,44 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERSPELLBOOK_HPP
#define OPENMW_PROCESSORPLAYERSPELLBOOK_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorPlayerSpellbook : public PlayerProcessor
{
public:
ProcessorPlayerSpellbook()
{
BPP_INIT(ID_PLAYER_SPELLBOOK)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (!isLocal()) return;
if (isRequest())
static_cast<LocalPlayer*>(player)->sendSpellbook();
else
{
LocalPlayer &localPlayer = static_cast<LocalPlayer&>(*player);
int spellbookAction = localPlayer.spellbookChanges.action;
if (spellbookAction == SpellbookChanges::ADD)
localPlayer.addSpells();
else if (spellbookAction == SpellbookChanges::REMOVE)
localPlayer.removeSpells();
else // SpellbookChanges::SET
localPlayer.setSpellbook();
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERSPELLBOOK_HPP

@ -0,0 +1,33 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORUSERDISCONNECTED_HPP
#define OPENMW_PROCESSORUSERDISCONNECTED_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
#include "apps/openmw/mwstate/statemanagerimp.hpp"
namespace mwmp
{
class ProcessorUserDisconnected : public PlayerProcessor
{
public:
ProcessorUserDisconnected()
{
BPP_INIT(ID_USER_DISCONNECTED)
avoidReading = true;
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
if (isLocal())
MWBase::Environment::get().getStateManager()->requestQuit();
else
Players::disconnectPlayer(guid);
}
};
}
#endif //OPENMW_PROCESSORUSERDISCONNECTED_HPP

@ -0,0 +1,31 @@
//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORUSERMYID_HPP
#define OPENMW_PROCESSORUSERMYID_HPP
#include "apps/openmw/mwmp/PlayerProcessor.hpp"
namespace mwmp
{
class ProcessorUserMyID : public PlayerProcessor
{
public:
ProcessorUserMyID()
{
BPP_INIT(ID_USER_MYID)
avoidReading = true;
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_USER_MYID from server");
myGuid = guid;
getLocalPlayer()->guid = guid;
}
};
}
#endif //OPENMW_PROCESSORUSERMYID_HPP
Loading…
Cancel
Save