Rename client Networking's GetPacket method into GetPlayerPacket

pull/78/head
David Cernat 8 years ago
parent e27d1857ef
commit f218613231

@ -129,7 +129,7 @@ namespace mwmp
*localPlayer->ChatMessage() = str;
RakNet::BitStream bs;
networking->GetPacket(ID_CHAT_MESSAGE)->Packet(&bs, localPlayer, true);
networking->GetPlayerPacket(ID_CHAT_MESSAGE)->Packet(&bs, localPlayer, true);
networking->SendData(&bs);
}

@ -109,7 +109,7 @@ void mwmp::GUIController::OnInputBoxDone(MWGui::WindowBase *parWindow)
printf("GUIController::OnInputBoxDone: %s.\n",mInputBox->getTextInput().c_str());
Main::get().getLocalPlayer()->guiMessageBox.data = mInputBox->getTextInput();
Main::get().getNetworking()->GetPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer());
Main::get().getNetworking()->GetPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer());
MWBase::Environment::get().getWindowManager()->removeDialog(mInputBox);
mInputBox = 0;
@ -155,7 +155,7 @@ void mwmp::GUIController::update(float dt)
printf("Pressed: %d\n", pressedButton);
calledMessageBox = false;
Main::get().getLocalPlayer()->guiMessageBox.data = MyGUI::utility::toString(pressedButton);
Main::get().getNetworking()->GetPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer());
Main::get().getNetworking()->GetPlayerPacket(ID_GUI_MESSAGEBOX)->Send(Main::get().getLocalPlayer());
}
}

@ -89,7 +89,7 @@ bool LocalPlayer::charGenThread() // todo: need fix
(*BirthSign()) = world->getPlayer().getBirthSign();
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Sending ID_GAME_BASE_INFO to server with my CharGen info");
GetNetworking()->GetPacket(ID_GAME_BASE_INFO)->Send(this);
GetNetworking()->GetPlayerPacket(ID_GAME_BASE_INFO)->Send(this);
if (CharGenStage()->end != 1)
{
@ -98,11 +98,11 @@ bool LocalPlayer::charGenThread() // todo: need fix
updateSkills(true);
updateLevel(true);
sendClass();
GetNetworking()->GetPacket(ID_GAME_CHARGEN)->Send(this);
GetNetworking()->GetPlayerPacket(ID_GAME_CHARGEN)->Send(this);
}
CharGenStage()->end = 0;
/*RakNet::BitStream bs;
GetNetworking()->GetPacket(ID_GAME_BASE_INFO)->Packet(&bs, this, true);
GetNetworking()->GetPlayerPacket(ID_GAME_BASE_INFO)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs);*/
}
@ -127,7 +127,7 @@ bool LocalPlayer::charGenThread() // todo: need fix
windowManager->pushGuiMode(MWGui::GM_Review);
break;
}
GetNetworking()->GetPacket(ID_GAME_CHARGEN)->Send(this);
GetNetworking()->GetPlayerPacket(ID_GAME_CHARGEN)->Send(this);
CharGenStage()->current++;
return false;
@ -162,7 +162,7 @@ void LocalPlayer::updateDynamicStats(bool forceUpdate)
timer = 0;
GetNetworking()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(this);
GetNetworking()->GetPlayerPacket(ID_GAME_DYNAMICSTATS)->Send(this);
}
}
}
@ -184,7 +184,7 @@ void LocalPlayer::updateAttributes(bool forceUpdate)
if (isUpdating || forceUpdate)
{
GetNetworking()->GetPacket(ID_GAME_ATTRIBUTE)->Send(this);
GetNetworking()->GetPlayerPacket(ID_GAME_ATTRIBUTE)->Send(this);
}
}
@ -220,7 +220,7 @@ void LocalPlayer::updateSkills(bool forceUpdate)
if (isUpdating || forceUpdate)
{
NpcStats()->mLevelProgress = ptrNpcStats.getLevelProgress();
GetNetworking()->GetPacket(ID_GAME_SKILL)->Send(this);
GetNetworking()->GetPlayerPacket(ID_GAME_SKILL)->Send(this);
}
}
@ -232,7 +232,7 @@ void LocalPlayer::updateLevel(bool forceUpdate)
if (ptrNpcStats.getLevel() != CreatureStats()->mLevel || forceUpdate)
{
CreatureStats()->mLevel = ptrNpcStats.getLevel();
GetNetworking()->GetPacket(ID_GAME_LEVEL)->Send(this);
GetNetworking()->GetPlayerPacket(ID_GAME_LEVEL)->Send(this);
// Also update skills to refresh level progress and attribute bonuses
// for next level up
@ -272,7 +272,7 @@ void LocalPlayer::updatePosition(bool forceUpdate)
Dir()->pos[1] = move.mPosition[1];
Dir()->pos[2] = move.mPosition[2];
GetNetworking()->GetPacket(ID_GAME_POS)->Send(this);
GetNetworking()->GetPlayerPacket(ID_GAME_POS)->Send(this);
}
else if (isJumping && world->isOnGround(player))
{
@ -284,7 +284,7 @@ void LocalPlayer::updatePosition(bool forceUpdate)
{
sentJumpEnd = true;
(*Position()) = ptrPos;
GetNetworking()->GetPacket(ID_GAME_POS)->Send(this);
GetNetworking()->GetPlayerPacket(ID_GAME_POS)->Send(this);
}
}
@ -333,7 +333,7 @@ void LocalPlayer::updateCell(bool forceUpdate)
updatePosition(true);
RakNet::BitStream bs;
GetNetworking()->GetPacket((RakNet::MessageID) ID_GAME_CELL)->Packet(&bs, this, true);
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_CELL)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs);
// Also update skill progress
@ -396,7 +396,7 @@ void LocalPlayer::updateInventory(bool forceUpdate)
{
RakNet::BitStream bs;
bs.ResetWritePointer();
GetNetworking()->GetPacket((RakNet::MessageID) ID_GAME_EQUIPMENT)->Packet(&bs, this, true);
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_EQUIPMENT)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs);
invChanged = false;
}
@ -426,7 +426,7 @@ void LocalPlayer::updateAttackState(bool forceUpdate)
GetAttack()->refid = spell;
/*RakNet::BitStream bs;
GetNetworking()->GetPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true);
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs);*/
}
else if (state == MWMechanics::DrawState_Weapon)
@ -457,7 +457,7 @@ void LocalPlayer::updateDeadState(bool forceUpdate)
{
CreatureStats()->mDead = true;
RakNet::BitStream bs;
GetNetworking()->GetPacket((RakNet::MessageID)ID_GAME_DIE)->Packet(&bs, this, true);
GetNetworking()->GetPlayerPacket((RakNet::MessageID)ID_GAME_DIE)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs);
isDead = true;
}
@ -524,7 +524,7 @@ void LocalPlayer::updateDrawStateAndFlags(bool forceUpdate)
mwmp::Main::get().getLocalPlayer()->updatePosition(true); // fix position after jump;
RakNet::BitStream bs;
GetNetworking()->GetPacket((RakNet::MessageID) ID_GAME_DRAWSTATE)->Packet(&bs, this, true);
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_DRAWSTATE)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs);
//timer = 0;
}
@ -695,7 +695,7 @@ void LocalPlayer::sendClass()
else
charClass.mId = cls->mId;
GetNetworking()->GetPacket(ID_GAME_CHARCLASS)->Send(this);
GetNetworking()->GetPlayerPacket(ID_GAME_CHARCLASS)->Send(this);
}
void LocalPlayer::sendAttack(char type)
@ -713,7 +713,7 @@ void LocalPlayer::sendAttack(char type)
GetAttack()->type = type;
GetAttack()->pressed = false;
RakNet::BitStream bs;
GetNetworking()->GetPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true);
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs);
}
@ -744,6 +744,6 @@ void LocalPlayer::prepareAttack(char type, bool state)
GetAttack()->attacker = guid;
RakNet::BitStream bs;
GetNetworking()->GetPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true);
GetNetworking()->GetPlayerPacket((RakNet::MessageID) ID_GAME_ATTACK)->Packet(&bs, this, true);
GetNetworking()->SendData(&bs);
}

@ -189,8 +189,8 @@ void Main::UpdateWorld(float dt) const
init = false;
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Sending ID_GAME_BASE_INFO to server");
mNetworking->GetPacket(ID_GAME_BASE_INFO)->Send(getLocalPlayer());
mNetworking->GetPacket(ID_LOADED)->Send(getLocalPlayer());
mNetworking->GetPlayerPacket(ID_GAME_BASE_INFO)->Send(getLocalPlayer());
mNetworking->GetPlayerPacket(ID_LOADED)->Send(getLocalPlayer());
mLocalPlayer->updateDynamicStats(true);
get().getGUIController()->setChatVisible(true);
}

@ -24,7 +24,7 @@
using namespace std;
using namespace mwmp;
Networking::Networking(): peer(RakNet::RakPeerInterface::GetInstance()), controller(peer)
Networking::Networking(): peer(RakNet::RakPeerInterface::GetInstance()), playerController(peer), worldController(peer)
{
RakNet::SocketDescriptor sd;
@ -32,7 +32,9 @@ Networking::Networking(): peer(RakNet::RakPeerInterface::GetInstance()), control
RakNet::StartupResult b = peer->Startup(1,&sd, 1);
RakAssert(b==RAKNET_STARTED);
controller.SetStream(0, &bsOut);
playerController.SetStream(0, &bsOut);
worldController.SetStream(0, &bsOut);
connected = 0;
}
@ -178,7 +180,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
if (id != myid)
pl = Players::GetPlayer(id);
PlayerPacket *myPacket = controller.GetPacket(packet->data[0]);
PlayerPacket *myPacket = playerController.GetPacket(packet->data[0]);
switch (packet->data[0])
{
@ -409,7 +411,7 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
myPacket->Send(getLocalPlayer(), serverAddr);
getLocalPlayer()->updateDynamicStats(true);
controller.GetPacket(ID_GAME_DYNAMICSTATS)->Send(getLocalPlayer(), serverAddr);
playerController.GetPacket(ID_GAME_DYNAMICSTATS)->Send(getLocalPlayer(), serverAddr);
}
else if (pl != 0)
{
@ -618,9 +620,14 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
}
}
PlayerPacket *Networking::GetPacket(RakNet::MessageID id)
PlayerPacket *Networking::GetPlayerPacket(RakNet::MessageID id)
{
return playerController.GetPacket(id);
}
WorldPacket *Networking::GetWorldPacket(RakNet::MessageID id)
{
return controller.GetPacket(id);
return worldController.GetPacket(id);
}
LocalPlayer *Networking::getLocalPlayer()

@ -20,6 +20,7 @@
#include <components/openmw-mp/Packets/Player/PacketCell.hpp>
#include <components/openmw-mp/Packets/Player/PacketDrawState.hpp>
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
#include <components/openmw-mp/Controllers/WorldPacketController.hpp>
namespace mwmp
{
@ -33,7 +34,9 @@ namespace mwmp
void Connect(const std::string& ip, unsigned short port);
void Update();
void SendData(RakNet::BitStream *bitStream);
PlayerPacket *GetPacket(RakNet::MessageID id);
PlayerPacket *GetPlayerPacket(RakNet::MessageID id);
WorldPacket *GetWorldPacket(RakNet::MessageID id);
bool isDedicatedPlayer(const MWWorld::Ptr &ptr);
bool Attack(const MWWorld::Ptr &ptr);
@ -51,7 +54,8 @@ namespace mwmp
RakNet::SystemAddress serverAddr;
RakNet::BitStream bsOut;
PlayerPacketController controller;
PlayerPacketController playerController;
WorldPacketController worldController;
void ReceiveMessage(RakNet::Packet *packet);
LocalPlayer *getLocalPlayer();

Loading…
Cancel
Save