From cf6de6c47416f0292086fff6d2823d03712163b4 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 3 Mar 2017 23:36:29 +0200 Subject: [PATCH] [Client] Update old packet-sending code in LocalPlayer and GUIChat --- apps/openmw/mwmp/GUIChat.cpp | 4 +--- apps/openmw/mwmp/LocalPlayer.cpp | 27 ++++++++------------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwmp/GUIChat.cpp b/apps/openmw/mwmp/GUIChat.cpp index 79b9a079b..a4d6be24e 100644 --- a/apps/openmw/mwmp/GUIChat.cpp +++ b/apps/openmw/mwmp/GUIChat.cpp @@ -134,9 +134,7 @@ namespace mwmp localPlayer->chatMessage = str; - RakNet::BitStream bs; - networking->getPlayerPacket(ID_CHAT_MESSAGE)->Packet(&bs, localPlayer, true); - networking->sendData(&bs); + networking->getPlayerPacket(ID_CHAT_MESSAGE)->Send(localPlayer); } void GUIChat::clean() diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 17e070f26..d00e3a0c2 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -356,9 +356,7 @@ void LocalPlayer::updateCell(bool forceUpdate) // cell change events in server scripts will have the wrong player position updatePosition(true); - RakNet::BitStream bs; - getNetworking()->getPlayerPacket(ID_PLAYER_CELL_CHANGE)->Packet(&bs, this, true); - getNetworking()->sendData(&bs); + getNetworking()->getPlayerPacket(ID_PLAYER_CELL_CHANGE)->Send(this); // Also force an update to skills (to send all progress to skill increases) updateSkills(true); @@ -422,10 +420,7 @@ void LocalPlayer::updateEquipment(bool forceUpdate) if (equipChanged) { - RakNet::BitStream bs; - bs.ResetWritePointer(); - getNetworking()->getPlayerPacket(ID_PLAYER_EQUIPMENT)->Packet(&bs, this, true); - getNetworking()->sendData(&bs); + getNetworking()->getPlayerPacket(ID_PLAYER_EQUIPMENT)->Send(this); equipChanged = false; } } @@ -523,10 +518,6 @@ void LocalPlayer::updateAttackState(bool forceUpdate) attack.type = Attack::MAGIC; attack.pressed = true; attack.refid = spell; - - /*RakNet::BitStream bs; - getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Packet(&bs, this, true); - getNetworking()->SendData(&bs);*/ } else if (state == MWMechanics::DrawState_Weapon) { @@ -556,8 +547,9 @@ void LocalPlayer::updateDeadState(bool forceUpdate) { creatureStats.mDead = true; RakNet::BitStream bs; - getNetworking()->getPlayerPacket((RakNet::MessageID)ID_PLAYER_DEATH)->Packet(&bs, this, true); - getNetworking()->sendData(&bs); + + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_DEATH to server about myself"); + getNetworking()->getPlayerPacket(ID_PLAYER_DEATH)->Send(this); isDead = true; } else if (ptrNpcStats->getHealth().getCurrent() > 0 && isDead) @@ -631,8 +623,7 @@ void LocalPlayer::updateDrawStateAndFlags(bool forceUpdate) mwmp::Main::get().getLocalPlayer()->updatePosition(true); // fix position after jump; RakNet::BitStream bs; - getNetworking()->getPlayerPacket(ID_PLAYER_DRAWSTATE)->Packet(&bs, this, true); - getNetworking()->sendData(&bs); + getNetworking()->getPlayerPacket(ID_PLAYER_DRAWSTATE)->Send(this); } } @@ -1106,8 +1097,7 @@ void LocalPlayer::sendAttack(Attack::TYPE type) attack.type = type; attack.pressed = false; RakNet::BitStream bs; - getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Packet(&bs, this, true); - getNetworking()->sendData(&bs); + getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Send(this); } void LocalPlayer::clearCellStates() @@ -1178,6 +1168,5 @@ void LocalPlayer::prepareAttack(Attack::TYPE type, bool state) attack.attacker = guid; RakNet::BitStream bs; - getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Packet(&bs, this, true); - getNetworking()->sendData(&bs); + getNetworking()->getPlayerPacket(ID_PLAYER_ATTACK)->Send(this); }