[General] Rename PlayerTeam into PlayerAlly

Considering that you can be allies with someone without being allied to their allies, changing the name makes the system more intuitive.
This commit is contained in:
David Cernat 2019-12-05 19:15:11 +02:00
parent a383b7b612
commit 980edac942
16 changed files with 110 additions and 113 deletions

View File

@ -11,12 +11,12 @@ using namespace std;
static std::string tempCellDescription; static std::string tempCellDescription;
void MechanicsFunctions::ClearTeamMembersForPlayer(unsigned short pid) noexcept void MechanicsFunctions::ClearAlliedPlayersForPlayer(unsigned short pid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
player->teamMembers.clear(); player->alliedPlayers.clear();
} }
unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned short pid) noexcept unsigned char MechanicsFunctions::GetMiscellaneousChangeType(unsigned short pid) noexcept
@ -189,15 +189,15 @@ void MechanicsFunctions::SetSelectedSpellId(unsigned short pid, const char *spel
player->selectedSpellId = spellId; player->selectedSpellId = spellId;
} }
void MechanicsFunctions::AddTeamMemberForPlayer(unsigned short pid, unsigned short teamMemberPid) noexcept void MechanicsFunctions::AddAlliedPlayerForPlayer(unsigned short pid, unsigned short alliedPlayerPid) noexcept
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
Player *teamMember; Player *alliedPlayer;
GET_PLAYER(teamMemberPid, teamMember, ); GET_PLAYER(alliedPlayerPid, alliedPlayer, );
player->teamMembers.push_back(teamMember->guid); player->alliedPlayers.push_back(alliedPlayer->guid);
} }
void MechanicsFunctions::SendMarkLocation(unsigned short pid) void MechanicsFunctions::SendMarkLocation(unsigned short pid)
@ -226,12 +226,12 @@ void MechanicsFunctions::SendSelectedSpell(unsigned short pid)
packet->Send(false); packet->Send(false);
} }
void MechanicsFunctions::SendTeam(unsigned short pid, bool sendToOtherPlayers) void MechanicsFunctions::SendAlliedPlayers(unsigned short pid, bool sendToOtherPlayers)
{ {
Player *player; Player *player;
GET_PLAYER(pid, player, ); GET_PLAYER(pid, player, );
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TEAM); mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ALLY);
packet->setPlayer(player); packet->setPlayer(player);
packet->Send(false); packet->Send(false);

View File

@ -4,7 +4,7 @@
#include "../Types.hpp" #include "../Types.hpp"
#define MECHANICSAPI \ #define MECHANICSAPI \
{"ClearTeamMembersForPlayer", MechanicsFunctions::ClearTeamMembersForPlayer},\ {"ClearAlliedPlayersForPlayer", MechanicsFunctions::ClearAlliedPlayersForPlayer},\
\ \
{"GetMiscellaneousChangeType", MechanicsFunctions::GetMiscellaneousChangeType},\ {"GetMiscellaneousChangeType", MechanicsFunctions::GetMiscellaneousChangeType},\
\ \
@ -31,11 +31,11 @@
{"SetMarkRot", MechanicsFunctions::SetMarkRot},\ {"SetMarkRot", MechanicsFunctions::SetMarkRot},\
{"SetSelectedSpellId", MechanicsFunctions::SetSelectedSpellId},\ {"SetSelectedSpellId", MechanicsFunctions::SetSelectedSpellId},\
\ \
{"AddTeamMemberForPlayer", MechanicsFunctions::AddTeamMemberForPlayer},\ {"AddAlliedPlayerForPlayer", MechanicsFunctions::AddAlliedPlayerForPlayer},\
\ \
{"SendMarkLocation", MechanicsFunctions::SendMarkLocation},\ {"SendMarkLocation", MechanicsFunctions::SendMarkLocation},\
{"SendSelectedSpell", MechanicsFunctions::SendSelectedSpell},\ {"SendSelectedSpell", MechanicsFunctions::SendSelectedSpell},\
{"SendTeam", MechanicsFunctions::SendTeam},\ {"SendAlliedPlayers", MechanicsFunctions::SendAlliedPlayers},\
\ \
{"Jail", MechanicsFunctions::Jail},\ {"Jail", MechanicsFunctions::Jail},\
{"Resurrect", MechanicsFunctions::Resurrect},\ {"Resurrect", MechanicsFunctions::Resurrect},\
@ -48,13 +48,12 @@ class MechanicsFunctions
public: public:
/** /**
* \brief Clear the list of players who will be regarded as being on this player's * \brief Clear the list of players who will be regarded as being player's allies.
* team.
* *
* \param pid The player ID. * \param pid The player ID.
* \return void * \return void
*/ */
static void ClearTeamMembersForPlayer(unsigned short pid) noexcept; static void ClearAlliedPlayersForPlayer(unsigned short pid) noexcept;
/** /**
* \brief Get the type of a PlayerMiscellaneous packet. * \brief Get the type of a PlayerMiscellaneous packet.
@ -240,13 +239,13 @@ public:
static void SetSelectedSpellId(unsigned short pid, const char *spellId) noexcept; static void SetSelectedSpellId(unsigned short pid, const char *spellId) noexcept;
/** /**
* \brief Add a team member to a player's list of team members. * \brief Add an ally to a player's list of allied players.
* *
* \param pid The player ID. * \param pid The player ID.
* \param teamMemberPid The team member's player ID. * \param alliedPlayerPid The ally's player ID.
* \return void * \return void
*/ */
static void AddTeamMemberForPlayer(unsigned short pid, unsigned short teamMemberPid) noexcept; static void AddAlliedPlayerForPlayer(unsigned short pid, unsigned short alliedPlayerPid) noexcept;
/** /**
* \brief Send a PlayerMiscellaneous packet with a Mark location to a player. * \brief Send a PlayerMiscellaneous packet with a Mark location to a player.
@ -265,14 +264,14 @@ public:
static void SendSelectedSpell(unsigned short pid); static void SendSelectedSpell(unsigned short pid);
/** /**
* \brief Send a PlayerTeam packet with a list of team member IDs to a player. * \brief Send a PlayerAlly packet with a list of team member IDs to a player.
* *
* \param pid The player ID. * \param pid The player ID.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the * \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default). * player attached to the packet (false by default).
* \return void * \return void
*/ */
static void SendTeam(unsigned short pid, bool sendToOtherPlayers); static void SendAlliedPlayers(unsigned short pid, bool sendToOtherPlayers);
/** /**
* \brief Send a PlayerJail packet about a player. * \brief Send a PlayerJail packet about a player.

View File

@ -115,14 +115,14 @@ add_openmw_dir (mwmp/processors/actor ProcessorActorAI ProcessorActorAnimFlags P
) )
add_openmw_dir (mwmp/processors/player ProcessorChatMessage ProcessorGUIMessageBox ProcessorUserDisconnected add_openmw_dir (mwmp/processors/player ProcessorChatMessage ProcessorGUIMessageBox ProcessorUserDisconnected
ProcessorUserMyID ProcessorGameSettings ProcessorPlayerAnimFlags ProcessorPlayerAnimPlay ProcessorPlayerAttack ProcessorUserMyID ProcessorGameSettings ProcessorPlayerAlly ProcessorPlayerAnimFlags ProcessorPlayerAnimPlay
ProcessorPlayerAttribute ProcessorPlayerBaseInfo ProcessorPlayerBehavior ProcessorPlayerBook ProcessorPlayerBounty ProcessorPlayerAttack ProcessorPlayerAttribute ProcessorPlayerBaseInfo ProcessorPlayerBehavior ProcessorPlayerBook
ProcessorPlayerCast ProcessorPlayerCellChange ProcessorPlayerCellState ProcessorPlayerCharClass ProcessorPlayerCharGen ProcessorPlayerBounty ProcessorPlayerCast ProcessorPlayerCellChange ProcessorPlayerCellState ProcessorPlayerCharClass
ProcessorPlayerDeath ProcessorPlayerDisposition ProcessorPlayerEquipment ProcessorPlayerFaction ProcessorPlayerInput ProcessorPlayerCharGen ProcessorPlayerDeath ProcessorPlayerDisposition ProcessorPlayerEquipment ProcessorPlayerFaction
ProcessorPlayerInventory ProcessorPlayerItemUse ProcessorPlayerJail ProcessorPlayerJournal ProcessorPlayerLevel ProcessorPlayerInput ProcessorPlayerInventory ProcessorPlayerItemUse ProcessorPlayerJail ProcessorPlayerJournal
ProcessorPlayerMiscellaneous ProcessorPlayerMomentum ProcessorPlayerPosition ProcessorPlayerQuickKeys ProcessorPlayerReputation ProcessorPlayerLevel ProcessorPlayerMiscellaneous ProcessorPlayerMomentum ProcessorPlayerPosition ProcessorPlayerQuickKeys
ProcessorPlayerResurrect ProcessorPlayerShapeshift ProcessorPlayerSkill ProcessorPlayerSpeech ProcessorPlayerSpellbook ProcessorPlayerReputation ProcessorPlayerResurrect ProcessorPlayerShapeshift ProcessorPlayerSkill ProcessorPlayerSpeech
ProcessorPlayerStatsDynamic ProcessorPlayerTopic ProcessorPlayerTeam ProcessorPlayerSpellbook ProcessorPlayerStatsDynamic ProcessorPlayerTopic
) )
add_openmw_dir (mwmp/processors/object BaseObjectProcessor add_openmw_dir (mwmp/processors/object BaseObjectProcessor

View File

@ -2363,15 +2363,15 @@ namespace MWMechanics
/* /*
Start of tes3mp addition Start of tes3mp addition
If we're checking the LocalPlayer and the iteratedActor is a DedicatedPlayer belonging to this one's teamMembers, If we're checking the LocalPlayer and the iteratedActor is a DedicatedPlayer belonging to this one's alliedPlayers,
include the iteratedActor in the actors siding with the player include the iteratedActor in the actors siding with the player
Alternatively, if we're checking a DedicatedPlayer and the iteratedActor is a LocalPlayer or DedicatedPlayer Alternatively, if we're checking a DedicatedPlayer and the iteratedActor is a LocalPlayer or DedicatedPlayer
belonging to their team members, include the iteratedActor in the actors siding with them belonging to their alliedPlayers, include the iteratedActor in the actors siding with them
*/ */
if (actor == getPlayer() && mwmp::PlayerList::isDedicatedPlayer(iteratedActor)) if (actor == getPlayer() && mwmp::PlayerList::isDedicatedPlayer(iteratedActor))
{ {
if (Utils::vectorContains(mwmp::Main::get().getLocalPlayer()->teamMembers, mwmp::PlayerList::getPlayer(iteratedActor)->guid)) if (Utils::vectorContains(mwmp::Main::get().getLocalPlayer()->alliedPlayers, mwmp::PlayerList::getPlayer(iteratedActor)->guid))
{ {
list.push_back(iteratedActor); list.push_back(iteratedActor);
} }
@ -2379,12 +2379,12 @@ namespace MWMechanics
else if (mwmp::PlayerList::isDedicatedPlayer(actor)) else if (mwmp::PlayerList::isDedicatedPlayer(actor))
{ {
if (iteratedActor == getPlayer() && if (iteratedActor == getPlayer() &&
Utils::vectorContains(mwmp::PlayerList::getPlayer(actor)->teamMembers, mwmp::Main::get().getLocalPlayer()->guid)) Utils::vectorContains(mwmp::PlayerList::getPlayer(actor)->alliedPlayers, mwmp::Main::get().getLocalPlayer()->guid))
{ {
list.push_back(iteratedActor); list.push_back(iteratedActor);
} }
else if (mwmp::PlayerList::isDedicatedPlayer(iteratedActor) && else if (mwmp::PlayerList::isDedicatedPlayer(iteratedActor) &&
Utils::vectorContains(mwmp::PlayerList::getPlayer(actor)->teamMembers, mwmp::PlayerList::getPlayer(iteratedActor)->guid)) Utils::vectorContains(mwmp::PlayerList::getPlayer(actor)->alliedPlayers, mwmp::PlayerList::getPlayer(iteratedActor)->guid))
{ {
list.push_back(iteratedActor); list.push_back(iteratedActor);
} }

View File

@ -290,9 +290,9 @@ bool MechanicsHelper::isTeamMember(const MWWorld::Ptr& playerChecked, const MWWo
playerCheckedGuid = PlayerList::getPlayer(playerChecked)->guid; playerCheckedGuid = PlayerList::getPlayer(playerChecked)->guid;
if (playerWithTeamIsLocal) if (playerWithTeamIsLocal)
isTeamMember = Utils::vectorContains(mwmp::Main::get().getLocalPlayer()->teamMembers, playerCheckedGuid); isTeamMember = Utils::vectorContains(mwmp::Main::get().getLocalPlayer()->alliedPlayers, playerCheckedGuid);
else else
isTeamMember = Utils::vectorContains(PlayerList::getPlayer(playerWithTeam)->teamMembers, playerCheckedGuid); isTeamMember = Utils::vectorContains(PlayerList::getPlayer(playerWithTeam)->alliedPlayers, playerCheckedGuid);
} }
} }

View File

@ -8,6 +8,7 @@
#include "player/ProcessorGUIMessageBox.hpp" #include "player/ProcessorGUIMessageBox.hpp"
#include "player/ProcessorUserDisconnected.hpp" #include "player/ProcessorUserDisconnected.hpp"
#include "player/ProcessorGameSettings.hpp" #include "player/ProcessorGameSettings.hpp"
#include "player/ProcessorPlayerAlly.hpp"
#include "player/ProcessorPlayerAnimFlags.hpp" #include "player/ProcessorPlayerAnimFlags.hpp"
#include "player/ProcessorPlayerAnimPlay.hpp" #include "player/ProcessorPlayerAnimPlay.hpp"
#include "player/ProcessorPlayerAttack.hpp" #include "player/ProcessorPlayerAttack.hpp"
@ -43,7 +44,6 @@
#include "player/ProcessorPlayerSpeech.hpp" #include "player/ProcessorPlayerSpeech.hpp"
#include "player/ProcessorPlayerSpellbook.hpp" #include "player/ProcessorPlayerSpellbook.hpp"
#include "player/ProcessorPlayerStatsDynamic.hpp" #include "player/ProcessorPlayerStatsDynamic.hpp"
#include "player/ProcessorPlayerTeam.hpp"
#include "player/ProcessorPlayerTopic.hpp" #include "player/ProcessorPlayerTopic.hpp"
#include "ObjectProcessor.hpp" #include "ObjectProcessor.hpp"
@ -112,6 +112,7 @@ void ProcessorInitializer()
PlayerProcessor::AddProcessor(new ProcessorGUIMessageBox()); PlayerProcessor::AddProcessor(new ProcessorGUIMessageBox());
PlayerProcessor::AddProcessor(new ProcessorUserDisconnected()); PlayerProcessor::AddProcessor(new ProcessorUserDisconnected());
PlayerProcessor::AddProcessor(new ProcessorGameSettings()); PlayerProcessor::AddProcessor(new ProcessorGameSettings());
PlayerProcessor::AddProcessor(new ProcessorPlayerAlly());
PlayerProcessor::AddProcessor(new ProcessorPlayerAnimFlags()); PlayerProcessor::AddProcessor(new ProcessorPlayerAnimFlags());
PlayerProcessor::AddProcessor(new ProcessorPlayerAnimPlay()); PlayerProcessor::AddProcessor(new ProcessorPlayerAnimPlay());
PlayerProcessor::AddProcessor(new ProcessorPlayerAttack()); PlayerProcessor::AddProcessor(new ProcessorPlayerAttack());
@ -147,7 +148,6 @@ void ProcessorInitializer()
PlayerProcessor::AddProcessor(new ProcessorPlayerSpeech()); PlayerProcessor::AddProcessor(new ProcessorPlayerSpeech());
PlayerProcessor::AddProcessor(new ProcessorPlayerSpellbook()); PlayerProcessor::AddProcessor(new ProcessorPlayerSpellbook());
PlayerProcessor::AddProcessor(new ProcessorPlayerStatsDynamic()); PlayerProcessor::AddProcessor(new ProcessorPlayerStatsDynamic());
PlayerProcessor::AddProcessor(new ProcessorPlayerTeam());
PlayerProcessor::AddProcessor(new ProcessorPlayerTopic()); PlayerProcessor::AddProcessor(new ProcessorPlayerTopic());
ObjectProcessor::AddProcessor(new ProcessorConsoleCommand()); ObjectProcessor::AddProcessor(new ProcessorConsoleCommand());

View File

@ -1,5 +1,5 @@
#ifndef OPENMW_PROCESSORPLAYERTEAM_HPP #ifndef OPENMW_PROCESSORPLAYERALLY_HPP
#define OPENMW_PROCESSORPLAYERTEAM_HPP #define OPENMW_PROCESSORPLAYERALLY_HPP
#include "../PlayerProcessor.hpp" #include "../PlayerProcessor.hpp"
#include "apps/openmw/mwmp/Main.hpp" #include "apps/openmw/mwmp/Main.hpp"
@ -7,12 +7,12 @@
namespace mwmp namespace mwmp
{ {
class ProcessorPlayerTeam final: public PlayerProcessor class ProcessorPlayerAlly final: public PlayerProcessor
{ {
public: public:
ProcessorPlayerTeam() ProcessorPlayerAlly()
{ {
BPP_INIT(ID_PLAYER_TEAM) BPP_INIT(ID_PLAYER_ALLY)
} }
virtual void Do(PlayerPacket &packet, BasePlayer *player) virtual void Do(PlayerPacket &packet, BasePlayer *player)
@ -21,15 +21,15 @@ namespace mwmp
if (isLocal()) if (isLocal())
{ {
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_TEAM about LocalPlayer %s from server", localPlayer->npc.mName.c_str()); LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_ALLY about LocalPlayer %s from server", localPlayer->npc.mName.c_str());
for (std::vector<RakNet::RakNetGUID>::iterator iter = localPlayer->teamMembers.begin(); iter != localPlayer->teamMembers.end(); ) for (std::vector<RakNet::RakNetGUID>::iterator iter = localPlayer->alliedPlayers.begin(); iter != localPlayer->alliedPlayers.end(); )
{ {
DedicatedPlayer *dedicatedPlayer = PlayerList::getPlayer(*iter); DedicatedPlayer *dedicatedPlayer = PlayerList::getPlayer(*iter);
if (dedicatedPlayer) if (dedicatedPlayer)
{ {
LOG_APPEND(TimedLog::LOG_INFO, "- Adding DedicatedPlayer %s to our team members", dedicatedPlayer->npc.mName.c_str()); LOG_APPEND(TimedLog::LOG_INFO, "- Adding DedicatedPlayer %s to our allied players", dedicatedPlayer->npc.mName.c_str());
} }
++iter; ++iter;
@ -37,13 +37,13 @@ namespace mwmp
} }
else if (player != 0) else if (player != 0)
{ {
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_TEAM about DedicatedPlayer %s from server", player->npc.mName.c_str()); LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_ALLY about DedicatedPlayer %s from server", player->npc.mName.c_str());
for (std::vector<RakNet::RakNetGUID>::iterator iter = player->teamMembers.begin(); iter != player->teamMembers.end(); ) for (std::vector<RakNet::RakNetGUID>::iterator iter = player->alliedPlayers.begin(); iter != player->alliedPlayers.end(); )
{ {
if (*iter == localPlayer->guid) if (*iter == localPlayer->guid)
{ {
LOG_APPEND(TimedLog::LOG_INFO, "- Adding LocalPlayer %s to their team members", localPlayer->npc.mName.c_str()); LOG_APPEND(TimedLog::LOG_INFO, "- Adding LocalPlayer %s to their allied players", localPlayer->npc.mName.c_str());
} }
else else
{ {
@ -51,7 +51,7 @@ namespace mwmp
if (otherDedicatedPlayer) if (otherDedicatedPlayer)
{ {
LOG_APPEND(TimedLog::LOG_INFO, "- Adding DedicatedPlayer %s to their team members", otherDedicatedPlayer->npc.mName.c_str()); LOG_APPEND(TimedLog::LOG_INFO, "- Adding DedicatedPlayer %s to their allied players", otherDedicatedPlayer->npc.mName.c_str());
} }
} }
@ -62,4 +62,4 @@ namespace mwmp
}; };
} }
#endif //OPENMW_PROCESSORPLAYERTEAM_HPP #endif //OPENMW_PROCESSORPLAYERALLY_HPP

View File

@ -26,13 +26,13 @@ namespace mwmp
{ {
mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer(); mwmp::LocalPlayer *localPlayer = mwmp::Main::get().getLocalPlayer();
for (std::vector<RakNet::RakNetGUID>::iterator iter = localPlayer->teamMembers.begin(); iter != localPlayer->teamMembers.end(); ) for (std::vector<RakNet::RakNetGUID>::iterator iter = localPlayer->alliedPlayers.begin(); iter != localPlayer->alliedPlayers.end(); )
{ {
if (*iter == guid) if (*iter == guid)
{ {
DedicatedPlayer *dedicatedPlayer = PlayerList::getPlayer(guid); DedicatedPlayer *dedicatedPlayer = PlayerList::getPlayer(guid);
LOG_APPEND(TimedLog::LOG_INFO, "- Deleting %s from our team members", dedicatedPlayer->npc.mName.c_str()); LOG_APPEND(TimedLog::LOG_INFO, "- Deleting %s from our allied players", dedicatedPlayer->npc.mName.c_str());
iter = localPlayer->teamMembers.erase(iter); iter = localPlayer->alliedPlayers.erase(iter);
} }
else else
++iter; ++iter;

View File

@ -189,16 +189,14 @@ add_component_dir (openmw-mp/Packets/Player
PacketChatMessage PacketGUIBoxes PacketGameSettings PacketChatMessage PacketGUIBoxes PacketGameSettings
PacketPlayerBaseInfo PacketPlayerCharGen PacketPlayerActiveSkills PacketPlayerAnimFlags PacketPlayerAnimPlay PacketPlayerBaseInfo PacketPlayerCharGen PacketPlayerActiveSkills PacketPlayerAlly PacketPlayerAnimFlags
PacketPlayerAttack PacketPlayerAttribute PacketPlayerBehavior PacketPlayerBook PacketPlayerBounty PacketPlayerAnimPlay PacketPlayerAttack PacketPlayerAttribute PacketPlayerBehavior PacketPlayerBook
PacketPlayerCast PacketPlayerCellChange PacketPlayerCellState PacketPlayerClass PacketPlayerDeath PacketPlayerBounty PacketPlayerCast PacketPlayerCellChange PacketPlayerCellState PacketPlayerClass
PacketPlayerEquipment PacketPlayerFaction PacketPlayerInput PacketPlayerInventory PacketPlayerItemUse PacketPlayerDeath PacketPlayerEquipment PacketPlayerFaction PacketPlayerInput PacketPlayerInventory
PacketPlayerJail PacketPlayerJournal PacketPlayerLevel PacketPlayerMiscellaneous PacketPlayerMomentum PacketPlayerItemUse PacketPlayerJail PacketPlayerJournal PacketPlayerLevel PacketPlayerMiscellaneous
PacketPlayerPosition PacketPlayerQuickKeys PacketPlayerReputation PacketPlayerRest PacketPlayerResurrect PacketPlayerMomentum PacketPlayerPosition PacketPlayerQuickKeys PacketPlayerReputation PacketPlayerRest
PacketPlayerShapeshift PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook PacketPlayerStatsDynamic PacketPlayerResurrect PacketPlayerShapeshift PacketPlayerSkill PacketPlayerSpeech PacketPlayerSpellbook
PacketPlayerTopic PacketPlayerStatsDynamic PacketPlayerTopic
PacketPlayerTeam
) )
add_component_dir (openmw-mp/Packets/Object add_component_dir (openmw-mp/Packets/Object

View File

@ -216,7 +216,7 @@ namespace mwmp
std::vector<CellState> cellStateChanges; std::vector<CellState> cellStateChanges;
ESM::ActiveSpells activeSpells; ESM::ActiveSpells activeSpells;
std::vector<RakNet::RakNetGUID> teamMembers; std::vector<RakNet::RakNetGUID> alliedPlayers;
CurrentContainer currentContainer; CurrentContainer currentContainer;
int difficulty = 0; int difficulty = 0;

View File

@ -5,6 +5,7 @@
#include "../Packets/Player/PacketLoaded.hpp" #include "../Packets/Player/PacketLoaded.hpp"
#include "../Packets/Player/PacketGameSettings.hpp" #include "../Packets/Player/PacketGameSettings.hpp"
#include "../Packets/Player/PacketPlayerActiveSkills.hpp" #include "../Packets/Player/PacketPlayerActiveSkills.hpp"
#include "../Packets/Player/PacketPlayerAlly.hpp"
#include "../Packets/Player/PacketPlayerAnimFlags.hpp" #include "../Packets/Player/PacketPlayerAnimFlags.hpp"
#include "../Packets/Player/PacketPlayerAnimPlay.hpp" #include "../Packets/Player/PacketPlayerAnimPlay.hpp"
#include "../Packets/Player/PacketPlayerAttack.hpp" #include "../Packets/Player/PacketPlayerAttack.hpp"
@ -25,7 +26,6 @@
#include "../Packets/Player/PacketPlayerItemUse.hpp" #include "../Packets/Player/PacketPlayerItemUse.hpp"
#include "../Packets/Player/PacketPlayerJail.hpp" #include "../Packets/Player/PacketPlayerJail.hpp"
#include "../Packets/Player/PacketPlayerJournal.hpp" #include "../Packets/Player/PacketPlayerJournal.hpp"
#include "../Packets/Player/PacketPlayerTeam.hpp"
#include "../Packets/Player/PacketPlayerLevel.hpp" #include "../Packets/Player/PacketPlayerLevel.hpp"
#include "../Packets/Player/PacketPlayerMiscellaneous.hpp" #include "../Packets/Player/PacketPlayerMiscellaneous.hpp"
#include "../Packets/Player/PacketPlayerMomentum.hpp" #include "../Packets/Player/PacketPlayerMomentum.hpp"
@ -60,6 +60,7 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p
AddPacket<PacketGameSettings>(&packets, peer); AddPacket<PacketGameSettings>(&packets, peer);
AddPacket<PacketPlayerActiveSkills>(&packets, peer); AddPacket<PacketPlayerActiveSkills>(&packets, peer);
AddPacket<PacketPlayerAlly>(&packets, peer);
AddPacket<PacketPlayerAnimFlags>(&packets, peer); AddPacket<PacketPlayerAnimFlags>(&packets, peer);
AddPacket<PacketPlayerAnimPlay>(&packets, peer); AddPacket<PacketPlayerAnimPlay>(&packets, peer);
AddPacket<PacketPlayerAttack>(&packets, peer); AddPacket<PacketPlayerAttack>(&packets, peer);
@ -81,7 +82,6 @@ mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *p
AddPacket<PacketPlayerItemUse>(&packets, peer); AddPacket<PacketPlayerItemUse>(&packets, peer);
AddPacket<PacketPlayerJail>(&packets, peer); AddPacket<PacketPlayerJail>(&packets, peer);
AddPacket<PacketPlayerJournal>(&packets, peer); AddPacket<PacketPlayerJournal>(&packets, peer);
AddPacket<PacketPlayerTeam>(&packets, peer);
AddPacket<PacketPlayerLevel>(&packets, peer); AddPacket<PacketPlayerLevel>(&packets, peer);
AddPacket<PacketPlayerMiscellaneous>(&packets, peer); AddPacket<PacketPlayerMiscellaneous>(&packets, peer);
AddPacket<PacketPlayerMomentum>(&packets, peer); AddPacket<PacketPlayerMomentum>(&packets, peer);

View File

@ -109,7 +109,7 @@ enum GameMessages
ID_PLAYER_ITEM_USE, ID_PLAYER_ITEM_USE,
ID_PLAYER_CAST, ID_PLAYER_CAST,
ID_PLAYER_TEAM, ID_PLAYER_ALLY,
ID_WORLD_DESTINATION_OVERRIDE, ID_WORLD_DESTINATION_OVERRIDE,
ID_PLACEHOLDER ID_PLACEHOLDER
}; };

View File

@ -0,0 +1,30 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerAlly.hpp"
mwmp::PacketPlayerAlly::PacketPlayerAlly(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_ALLY;
}
void mwmp::PacketPlayerAlly::Packet(RakNet::BitStream *newBitstream, bool send)
{
PlayerPacket::Packet(newBitstream, send);
uint32_t count;
if (send)
count = static_cast<uint32_t>(player->alliedPlayers.size());
RW(count, send);
if (!send)
{
player->alliedPlayers.clear();
player->alliedPlayers.resize(count);
}
for (auto &&teamPlayerGuid : player->alliedPlayers)
{
RW(teamPlayerGuid, send, true);
}
}

View File

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

View File

@ -1,30 +0,0 @@
#include <components/openmw-mp/NetworkMessages.hpp>
#include "PacketPlayerTeam.hpp"
mwmp::PacketPlayerTeam::PacketPlayerTeam(RakNet::RakPeerInterface *peer) : PlayerPacket(peer)
{
packetID = ID_PLAYER_TEAM;
}
void mwmp::PacketPlayerTeam::Packet(RakNet::BitStream *newBitstream, bool send)
{
PlayerPacket::Packet(newBitstream, send);
uint32_t count;
if (send)
count = static_cast<uint32_t>(player->teamMembers.size());
RW(count, send);
if (!send)
{
player->teamMembers.clear();
player->teamMembers.resize(count);
}
for (auto &&teamPlayerGuid : player->teamMembers)
{
RW(teamPlayerGuid, send, true);
}
}

View File

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