forked from mirror/openmw-tes3mp
Merge with tes3mp-packetexpansion by fixing conflicts
# Conflicts: # apps/openmw-mp/Networking.cpp # apps/openmw/mwmp/Networking.cpp # components/CMakeLists.txt # components/openmw-mp/NetworkMessages.hpp # components/openmw-mp/PacketsController.cpp
This commit is contained in:
commit
c639337842
81 changed files with 1558 additions and 943 deletions
|
@ -26,9 +26,12 @@ Networking::Networking(RakNet::RakPeerInterface *peer)
|
|||
this->peer = peer;
|
||||
players = Players::GetPlayers();
|
||||
|
||||
controller = new PacketsController(peer);
|
||||
playerController = new PlayerPacketController(peer);
|
||||
worldController = new WorldPacketController(peer);
|
||||
|
||||
controller->SetStream(0, &bsOut); // set send stream
|
||||
// Set send stream
|
||||
playerController->SetStream(0, &bsOut);
|
||||
worldController->SetStream(0, &bsOut);
|
||||
|
||||
running = true;
|
||||
exitCode = 0;
|
||||
|
@ -41,39 +44,18 @@ Networking::~Networking()
|
|||
Script::Call<Script::CallbackIdentity("OnServerExit")>(false);
|
||||
|
||||
sThis = 0;
|
||||
delete controller;
|
||||
delete playerController;
|
||||
LOG_QUIT();
|
||||
}
|
||||
|
||||
void Networking::Update(RakNet::Packet *packet)
|
||||
void Networking::ProcessPlayerPacket(RakNet::Packet *packet)
|
||||
{
|
||||
|
||||
Player *player = Players::GetPlayer(packet->guid);
|
||||
|
||||
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
|
||||
|
||||
{
|
||||
RakNet::RakNetGUID ignoredGUID;
|
||||
bsIn.Read(ignoredGUID);
|
||||
(void)ignoredGUID;
|
||||
}
|
||||
|
||||
controller->SetStream(&bsIn, 0);
|
||||
|
||||
if (player == 0)
|
||||
{
|
||||
controller->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
|
||||
Players::NewPlayer(packet->guid);
|
||||
player = Players::GetPlayer(packet->guid);
|
||||
controller->GetPacket(ID_USER_MYID)->Send(Players::GetPlayer(packet->guid), false);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerPacket *myPacket = controller->GetPacket(packet->data[0]);
|
||||
PlayerPacket *myPacket = playerController->GetPacket(packet->data[0]);
|
||||
|
||||
if (packet->data[0] == ID_HANDSHAKE)
|
||||
{
|
||||
DEBUG_PRINTF("ID_HANDSHAKE\n");
|
||||
string passw = "SuperPassword";
|
||||
|
||||
myPacket->Read(player);
|
||||
|
@ -118,7 +100,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
|
||||
if (!result)
|
||||
{
|
||||
controller->GetPacket(ID_USER_DISCONNECTED)->Send(Players::GetPlayer(packet->guid), false);
|
||||
playerController->GetPacket(ID_USER_DISCONNECTED)->Send(Players::GetPlayer(packet->guid), false);
|
||||
Players::DeletePlayer(packet->guid);
|
||||
return;
|
||||
}
|
||||
|
@ -126,7 +108,7 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
else if (packet->data[0] == ID_GAME_BASE_INFO)
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_BASE_INFO about %s",
|
||||
player->Npc()->mName.c_str());
|
||||
player->Npc()->mName.c_str());
|
||||
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
|
@ -145,264 +127,355 @@ void Networking::Update(RakNet::Packet *packet)
|
|||
{
|
||||
/*case ID_GAME_BASE_INFO:
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_BASE_INFO about %s",
|
||||
player->Npc()->mName.c_str());
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_BASE_INFO about %s",
|
||||
player->Npc()->mName.c_str());
|
||||
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
|
||||
break;
|
||||
break;
|
||||
}*/
|
||||
case ID_GAME_POS:
|
||||
case ID_GAME_POS:
|
||||
{
|
||||
//DEBUG_PRINTF("ID_GAME_POS \n");
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
//DEBUG_PRINTF("ID_GAME_POS \n");
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true); //send to other clients
|
||||
}
|
||||
|
||||
break;
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true); //send to other clients
|
||||
}
|
||||
case ID_GAME_CELL:
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_GAME_CELL:
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_CELL from %s",
|
||||
player->Npc()->mName.c_str());
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_CELL from %s",
|
||||
myPacket->Read(player);
|
||||
|
||||
LOG_APPEND(Log::LOG_INFO, "- Moved to %s",
|
||||
player->GetCell()->getDescription().c_str());
|
||||
|
||||
myPacket->Send(player, true); //send to other clients
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeCell")>(player->GetID());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_APPEND(Log::LOG_INFO, "- Ignored because %s is dead",
|
||||
player->Npc()->mName.c_str());
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
|
||||
LOG_APPEND(Log::LOG_INFO, "- Moved to %s",
|
||||
player->GetCell()->getDescription().c_str());
|
||||
|
||||
myPacket->Send(player, true); //send to other clients
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeCell")>(player->GetID());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_APPEND(Log::LOG_INFO, "- Ignored because %s is dead",
|
||||
player->Npc()->mName.c_str());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_GAME_ATTRIBUTE:
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_GAME_ATTRIBUTE:
|
||||
{
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeAttributes")>(player->GetID());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_GAME_SKILL:
|
||||
{
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeSkills")>(player->GetID());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_GAME_LEVEL:
|
||||
{
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeLevel")>(player->GetID());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_GAME_EQUIPMENT:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_EQUIPMENT\n");
|
||||
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeEquipment")>(player->GetID());
|
||||
|
||||
break;
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeAttributes")>(player->GetID());
|
||||
}
|
||||
|
||||
case ID_GAME_ATTACK:
|
||||
break;
|
||||
}
|
||||
case ID_GAME_SKILL:
|
||||
{
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_ATTACK\n");
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeSkills")>(player->GetID());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_GAME_LEVEL:
|
||||
{
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeLevel")>(player->GetID());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ID_GAME_EQUIPMENT:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_EQUIPMENT\n");
|
||||
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerChangeEquipment")>(player->GetID());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_GAME_ATTACK:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_ATTACK\n");
|
||||
|
||||
if (!player->CreatureStats()->mDead)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
|
||||
Player *target = Players::GetPlayer(player->GetAttack()->target);
|
||||
|
||||
if (target == nullptr)
|
||||
target = player;
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Player: %s attaked %s state: %d", player->Npc()->mName.c_str(),
|
||||
target->Npc()->mName.c_str(), player->GetAttack()->pressed == 1);
|
||||
if (player->GetAttack()->pressed == 0)
|
||||
{
|
||||
myPacket->Read(player);
|
||||
|
||||
Player *target = Players::GetPlayer(player->GetAttack()->target);
|
||||
|
||||
if (target == nullptr)
|
||||
target = player;
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Player: %s attaked %s state: %d", player->Npc()->mName.c_str(),
|
||||
target->Npc()->mName.c_str(), player->GetAttack()->pressed == 1);
|
||||
if (player->GetAttack()->pressed == 0)
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "success: %d", player->GetAttack()->success == 1);
|
||||
if (player->GetAttack()->success == 1)
|
||||
{
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "success: %d", player->GetAttack()->success == 1);
|
||||
if (player->GetAttack()->success == 1)
|
||||
{
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "damage: %d", player->GetAttack()->damage == 1);
|
||||
player->setLastAttackerID(target->GetID());
|
||||
}
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "damage: %d", player->GetAttack()->damage == 1);
|
||||
player->setLastAttackerID(target->GetID());
|
||||
}
|
||||
|
||||
myPacket->Send(player, true);
|
||||
controller->GetPacket(ID_GAME_DYNAMICSTATS)->RequestData(player->GetAttack()->target);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_GAME_DYNAMICSTATS:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_DYNAMICSTATS\n");
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
break;
|
||||
playerController->GetPacket(ID_GAME_DYNAMICSTATS)->RequestData(player->GetAttack()->target);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_GAME_DIE:
|
||||
case ID_GAME_DYNAMICSTATS:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_DYNAMICSTATS\n");
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_GAME_DIE:
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_DIE from %s",
|
||||
player->Npc()->mName.c_str());
|
||||
|
||||
Player *killer = Players::GetPlayer(player->getLastAttackerID());
|
||||
|
||||
short reason = 0; // unknown;
|
||||
|
||||
if (!killer)
|
||||
killer = player;
|
||||
else if (killer->GetID() == player->GetID())
|
||||
reason = 2; //suicide
|
||||
else
|
||||
reason = 1; //killed
|
||||
|
||||
player->resetLastAttacker();
|
||||
|
||||
player->CreatureStats()->mDead = true;
|
||||
myPacket->Send(player, true);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerDeath")>(player->GetID(), reason, killer->GetID());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_GAME_RESURRECT:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_RESURRECT\n");
|
||||
//packetResurrect.Read(player);
|
||||
player->CreatureStats()->mDead = false;
|
||||
myPacket->Send(player, true);
|
||||
playerController->GetPacket(ID_GAME_POS)->RequestData(player->guid);
|
||||
playerController->GetPacket(ID_GAME_CELL)->RequestData(player->guid);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerResurrect")>(player->GetID());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_GAME_DRAWSTATE:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_DRAWSTATE\n");
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_CHAT_MESSAGE:
|
||||
{
|
||||
DEBUG_PRINTF("ID_CHAT_MESSAGE\n");
|
||||
myPacket->Read(player);
|
||||
Script::CallBackReturn<Script::CallbackIdentity("OnPlayerSendMessage")> result = true;
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerSendMessage")>(result, player->GetID(), player->ChatMessage()->c_str());
|
||||
|
||||
if (result)
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_DIE from %s",
|
||||
player->Npc()->mName.c_str());
|
||||
|
||||
Player *killer = Players::GetPlayer(player->getLastAttackerID());
|
||||
|
||||
short reason = 0; // unknown;
|
||||
|
||||
if (!killer)
|
||||
killer = player;
|
||||
else if (killer->GetID() == player->GetID())
|
||||
reason = 2; //suicide
|
||||
else
|
||||
reason = 1; //killed
|
||||
|
||||
player->resetLastAttacker();
|
||||
|
||||
player->CreatureStats()->mDead = true;
|
||||
*player->ChatMessage() = player->Npc()->mName + " (" + std::to_string(player->GetID()) + "): "
|
||||
+ *player->ChatMessage() + "\n";
|
||||
myPacket->Send(player, false);
|
||||
myPacket->Send(player, true);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerDeath")>(player->GetID(), reason, killer->GetID());
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ID_GAME_CHARGEN:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_CHARGEN\n");
|
||||
myPacket->Read(player);
|
||||
|
||||
case ID_GAME_RESURRECT:
|
||||
if (player->CharGenStage()->current == player->CharGenStage()->end && player->CharGenStage()->current != 0)
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_RESURRECT\n");
|
||||
//packetResurrect.Read(player);
|
||||
player->CreatureStats()->mDead = false;
|
||||
myPacket->Send(player, true);
|
||||
controller->GetPacket(ID_GAME_POS)->RequestData(player->guid);
|
||||
controller->GetPacket(ID_GAME_CELL)->RequestData(player->guid);
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerResurrect")>(player->GetID());
|
||||
|
||||
break;
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerEndCharGen")>(player->GetID());
|
||||
cout << "RACE: " << player->Npc()->mRace << endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_GAME_DRAWSTATE:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_DRAWSTATE\n");
|
||||
myPacket->Read(player);
|
||||
myPacket->Send(player, true);
|
||||
break;
|
||||
}
|
||||
case ID_GUI_MESSAGEBOX:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GUI_MESSAGEBOX\n");
|
||||
myPacket->Read(player);
|
||||
|
||||
case ID_CHAT_MESSAGE:
|
||||
{
|
||||
DEBUG_PRINTF("ID_CHAT_MESSAGE\n");
|
||||
myPacket->Read(player);
|
||||
Script::CallBackReturn<Script::CallbackIdentity("OnPlayerSendMessage")> result = true;
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerSendMessage")>(result, player->GetID(), player->ChatMessage()->c_str());
|
||||
Script::Call<Script::CallbackIdentity("OnGUIAction")>(player->GetID(), (int)player->guiMessageBox.id,
|
||||
player->guiMessageBox.data.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
*player->ChatMessage() = player->Npc()->mName + " (" + std::to_string(player->GetID()) + "): "
|
||||
+ *player->ChatMessage() + "\n";
|
||||
myPacket->Send(player, false);
|
||||
myPacket->Send(player, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ID_GAME_CHARGEN:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_CHARGEN\n");
|
||||
myPacket->Read(player);
|
||||
case ID_GAME_CHARCLASS:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_CHARCLASS\n");
|
||||
myPacket->Read(player);
|
||||
break;
|
||||
}
|
||||
|
||||
if (player->CharGenStage()->current == player->CharGenStage()->end && player->CharGenStage()->current != 0)
|
||||
{
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerEndCharGen")>(player->GetID());
|
||||
cout << "RACE: " << player->Npc()->mRace << endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ID_GAME_INVENTORY:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_INVENTORY\n");
|
||||
myPacket->Read(player);
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_GUI_MESSAGEBOX:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GUI_MESSAGEBOX\n");
|
||||
myPacket->Read(player);
|
||||
default:
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled PlayerPacket with identifier %i has arrived",
|
||||
packet->data[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Script::Call<Script::CallbackIdentity("OnGUIAction")>(player->GetID(), (int)player->guiMessageBox.id,
|
||||
player->guiMessageBox.data.c_str());
|
||||
break;
|
||||
}
|
||||
void Networking::ProcessWorldPacket(RakNet::Packet *packet)
|
||||
{
|
||||
Player *player = Players::GetPlayer(packet->guid);
|
||||
|
||||
case ID_GAME_CHARCLASS:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_CHARCLASS\n");
|
||||
myPacket->Read(player);
|
||||
break;
|
||||
}
|
||||
case ID_GAME_INVENTORY:
|
||||
{
|
||||
DEBUG_PRINTF("ID_GAME_INVENTORY\n");
|
||||
myPacket->Read(player);
|
||||
break;
|
||||
}
|
||||
if (!player->isHandshaked() || player->LoadedState() != Player::POSTLOADED)
|
||||
return;
|
||||
|
||||
default:
|
||||
printf("Message with identifier %i has arrived.\n", packet->data[0]);
|
||||
break;
|
||||
WorldPacket *myPacket = worldController->GetPacket(packet->data[0]);
|
||||
WorldEvent *event = new WorldEvent(player->guid);
|
||||
event->cellRef.blank();
|
||||
|
||||
switch (packet->data[0])
|
||||
{
|
||||
|
||||
case ID_WORLD_OBJECT_PLACE:
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_WORLD_OBJECT_PLACE from %s",
|
||||
player->Npc()->mName.c_str());
|
||||
|
||||
myPacket->Read(event);
|
||||
myPacket->Send(event, true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_WORLD_OBJECT_DELETE:
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_WORLD_OBJECT_DELETE from %s",
|
||||
player->Npc()->mName.c_str());
|
||||
|
||||
myPacket->Read(event);
|
||||
|
||||
LOG_APPEND(Log::LOG_WARN, "- cellRef: %s, %i\n- cell: %s",
|
||||
event->cellRef.mRefID.c_str(),
|
||||
event->cellRef.mRefNum.mIndex,
|
||||
event->cell.getDescription().c_str());
|
||||
|
||||
myPacket->Send(event, true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled WorldPacket with identifier %i has arrived",
|
||||
packet->data[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Networking::Update(RakNet::Packet *packet)
|
||||
{
|
||||
Player *player = Players::GetPlayer(packet->guid);
|
||||
|
||||
RakNet::BitStream bsIn(&packet->data[1], packet->length, false);
|
||||
|
||||
{
|
||||
RakNet::RakNetGUID ignoredGUID;
|
||||
bsIn.Read(ignoredGUID);
|
||||
(void)ignoredGUID;
|
||||
}
|
||||
|
||||
if (player == 0)
|
||||
{
|
||||
playerController->SetStream(&bsIn, 0);
|
||||
|
||||
playerController->GetPacket(ID_HANDSHAKE)->RequestData(packet->guid);
|
||||
Players::NewPlayer(packet->guid);
|
||||
player = Players::GetPlayer(packet->guid);
|
||||
playerController->GetPacket(ID_USER_MYID)->Send(Players::GetPlayer(packet->guid), false);
|
||||
return;
|
||||
}
|
||||
else if (playerController->ContainsPacket(packet->data[0]))
|
||||
{
|
||||
playerController->SetStream(&bsIn, 0);
|
||||
ProcessPlayerPacket(packet);
|
||||
}
|
||||
else if (worldController->ContainsPacket(packet->data[0]))
|
||||
{
|
||||
worldController->SetStream(&bsIn, 0);
|
||||
ProcessWorldPacket(packet);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Unhandled Raknet packet with identifier %i has arrived",
|
||||
packet->data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void Networking::NewPlayer(RakNet::RakNetGUID guid)
|
||||
{
|
||||
controller->GetPacket(ID_GAME_BASE_INFO)->RequestData(guid);
|
||||
controller->GetPacket(ID_GAME_DYNAMICSTATS)->RequestData(guid);
|
||||
controller->GetPacket(ID_GAME_POS)->RequestData(guid);
|
||||
controller->GetPacket(ID_GAME_CELL)->RequestData(guid);
|
||||
controller->GetPacket(ID_GAME_EQUIPMENT)->RequestData(guid);
|
||||
playerController->GetPacket(ID_GAME_BASE_INFO)->RequestData(guid);
|
||||
playerController->GetPacket(ID_GAME_DYNAMICSTATS)->RequestData(guid);
|
||||
playerController->GetPacket(ID_GAME_POS)->RequestData(guid);
|
||||
playerController->GetPacket(ID_GAME_CELL)->RequestData(guid);
|
||||
playerController->GetPacket(ID_GAME_EQUIPMENT)->RequestData(guid);
|
||||
|
||||
for (TPlayers::iterator pl = players->begin(); pl != players->end(); pl++) //sending other players to new player
|
||||
{
|
||||
if (pl->first == guid) continue;
|
||||
|
||||
controller->GetPacket(ID_GAME_BASE_INFO)->Send(pl->second, guid);
|
||||
controller->GetPacket(ID_GAME_DYNAMICSTATS)->Send(pl->second, guid);
|
||||
controller->GetPacket(ID_GAME_ATTRIBUTE)->Send(pl->second, guid);
|
||||
controller->GetPacket(ID_GAME_SKILL)->Send(pl->second, guid);
|
||||
controller->GetPacket(ID_GAME_POS)->Send(pl->second, guid);
|
||||
controller->GetPacket(ID_GAME_CELL)->Send(pl->second, guid);
|
||||
controller->GetPacket(ID_GAME_EQUIPMENT)->Send(pl->second, guid);
|
||||
playerController->GetPacket(ID_GAME_BASE_INFO)->Send(pl->second, guid);
|
||||
playerController->GetPacket(ID_GAME_DYNAMICSTATS)->Send(pl->second, guid);
|
||||
playerController->GetPacket(ID_GAME_ATTRIBUTE)->Send(pl->second, guid);
|
||||
playerController->GetPacket(ID_GAME_SKILL)->Send(pl->second, guid);
|
||||
playerController->GetPacket(ID_GAME_POS)->Send(pl->second, guid);
|
||||
playerController->GetPacket(ID_GAME_CELL)->Send(pl->second, guid);
|
||||
playerController->GetPacket(ID_GAME_EQUIPMENT)->Send(pl->second, guid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -415,13 +488,18 @@ void Networking::DisconnectPlayer(RakNet::RakNetGUID guid)
|
|||
if (!player)
|
||||
return;
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerDisconnect")>(player->GetID());
|
||||
controller->GetPacket(ID_USER_DISCONNECTED)->Send(player, true);
|
||||
playerController->GetPacket(ID_USER_DISCONNECTED)->Send(player, true);
|
||||
Players::DeletePlayer(guid);
|
||||
}
|
||||
|
||||
PacketsController *Networking::GetController() const
|
||||
PlayerPacketController *Networking::GetPlayerController() const
|
||||
{
|
||||
return controller;
|
||||
return playerController;
|
||||
}
|
||||
|
||||
WorldPacketController *Networking::GetWorldController() const
|
||||
{
|
||||
return worldController;
|
||||
}
|
||||
|
||||
const Networking &Networking::Get()
|
||||
|
@ -454,31 +532,37 @@ int Networking::MainLoop()
|
|||
switch (packet->data[0])
|
||||
{
|
||||
case ID_REMOTE_DISCONNECTION_NOTIFICATION:
|
||||
printf("Another client has disconnected.\n");
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has disconnected",
|
||||
packet->systemAddress.ToString());
|
||||
break;
|
||||
case ID_REMOTE_CONNECTION_LOST:
|
||||
printf("Another client has lost connection.\n");
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has lost connection",
|
||||
packet->systemAddress.ToString());
|
||||
break;
|
||||
case ID_REMOTE_NEW_INCOMING_CONNECTION:
|
||||
printf("Another client has connected.\n");
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has connected",
|
||||
packet->systemAddress.ToString());
|
||||
break;
|
||||
case ID_CONNECTION_REQUEST_ACCEPTED: // client to server
|
||||
{
|
||||
printf("Our connection request has been accepted.\n");
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "Our connection request has been accepted");
|
||||
break;
|
||||
}
|
||||
case ID_NEW_INCOMING_CONNECTION:
|
||||
printf("A connection is incoming.\n");
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "A connection is incoming from %s",
|
||||
packet->systemAddress.ToString());
|
||||
break;
|
||||
case ID_NO_FREE_INCOMING_CONNECTIONS:
|
||||
printf("The server is full.\n");
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "%s", "The server is full");
|
||||
break;
|
||||
case ID_DISCONNECTION_NOTIFICATION:
|
||||
printf("A client has disconnected.\n");
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has disconnected",
|
||||
packet->systemAddress.ToString());
|
||||
DisconnectPlayer(packet->guid);
|
||||
break;
|
||||
case ID_CONNECTION_LOST:
|
||||
printf("A client has lost connection.\n");
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Client at %s has lost connection",
|
||||
packet->systemAddress.ToString());
|
||||
DisconnectPlayer(packet->guid);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
#ifndef OPENMW_NETWORKING_HPP
|
||||
#define OPENMW_NETWORKING_HPP
|
||||
|
||||
#include <components/openmw-mp/PacketsController.hpp>
|
||||
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
||||
#include <components/openmw-mp/Controllers/WorldPacketController.hpp>
|
||||
#include "Player.hpp"
|
||||
|
||||
namespace mwmp
|
||||
|
@ -19,7 +20,11 @@ namespace mwmp
|
|||
void NewPlayer(RakNet::RakNetGUID guid);
|
||||
void DisconnectPlayer(RakNet::RakNetGUID guid);
|
||||
void KickPlayer(RakNet::RakNetGUID guid);
|
||||
|
||||
void ProcessPlayerPacket(RakNet::Packet *packet);
|
||||
void ProcessWorldPacket(RakNet::Packet *packet);
|
||||
void Update(RakNet::Packet *packet);
|
||||
|
||||
unsigned short NumberOfConnections() const;
|
||||
unsigned int MaxConnections() const;
|
||||
|
||||
|
@ -27,7 +32,9 @@ namespace mwmp
|
|||
|
||||
void StopServer(int code);
|
||||
|
||||
PacketsController *GetController() const;
|
||||
PlayerPacketController *GetPlayerController() const;
|
||||
WorldPacketController *GetWorldController() const;
|
||||
|
||||
static const Networking &Get();
|
||||
static Networking *GetPtr();
|
||||
|
||||
|
@ -37,7 +44,8 @@ namespace mwmp
|
|||
RakNet::BitStream bsOut;
|
||||
TPlayers *players;
|
||||
|
||||
PacketsController *controller;
|
||||
PlayerPacketController *playerController;
|
||||
WorldPacketController *worldController;
|
||||
|
||||
bool running;
|
||||
int exitCode;
|
||||
|
|
|
@ -15,7 +15,7 @@ void CharClassFunctions::SendClass(unsigned short pid) noexcept
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CHARCLASS)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CHARCLASS)->Send(player, false);
|
||||
}
|
||||
|
||||
void CharClassFunctions::SetDefaultClass(unsigned short pid, const char *id) noexcept
|
||||
|
|
|
@ -15,9 +15,9 @@ void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool
|
|||
|
||||
DEBUG_PRINTF("System: %s", message);
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, false);
|
||||
if (broadcast)
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, true);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_CHAT_MESSAGE)->Send(player, true);
|
||||
}
|
||||
|
||||
void ScriptFunctions::CleanChat(unsigned short pid)
|
||||
|
|
|
@ -18,7 +18,7 @@ void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) no
|
|||
player->guiMessageBox.label = label;
|
||||
player->guiMessageBox.type = Player::GUIMessageBox::MessageBox;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
|
||||
}
|
||||
|
||||
void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept
|
||||
|
@ -31,7 +31,7 @@ void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *labe
|
|||
player->guiMessageBox.buttons = buttons;
|
||||
player->guiMessageBox.type = Player::GUIMessageBox::CustomMessageBox;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
|
||||
}
|
||||
|
||||
void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label) noexcept
|
||||
|
@ -43,7 +43,7 @@ void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label) no
|
|||
player->guiMessageBox.label = label;
|
||||
player->guiMessageBox.type = Player::GUIMessageBox::InputDialog;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(player, false);
|
||||
}
|
||||
|
||||
void GUIFunctions::SetMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state) noexcept
|
||||
|
|
|
@ -114,8 +114,8 @@ void ItemFunctions::SendEquipment(unsigned short pid) noexcept
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, false);
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, true);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_EQUIPMENT)->Send(player, true);
|
||||
}
|
||||
|
||||
void ItemFunctions::SendInventory(unsigned short pid) noexcept
|
||||
|
|
|
@ -454,14 +454,14 @@ void StatsFunctions::SetCharGenStage(unsigned short pid, int start, int end) noe
|
|||
player->CharGenStage()->current = start;
|
||||
player->CharGenStage()->end = end;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CHARGEN)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CHARGEN)->Send(player, false);
|
||||
}
|
||||
|
||||
void StatsFunctions::Resurrect(unsigned short pid)
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_RESURRECT)->RequestData(player->guid);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_RESURRECT)->RequestData(player->guid);
|
||||
}
|
||||
|
||||
void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
|
||||
|
@ -469,16 +469,16 @@ void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_BASE_INFO)->Send(player, false);
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_BASE_INFO)->Send(player, true);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_BASE_INFO)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_BASE_INFO)->Send(player, true);
|
||||
}
|
||||
|
||||
void StatsFunctions::SendDynamicStats(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(player, false);
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(player, true);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(player, true);
|
||||
}
|
||||
|
||||
void StatsFunctions::SendAttributes(unsigned short pid) noexcept
|
||||
|
@ -486,8 +486,8 @@ void StatsFunctions::SendAttributes(unsigned short pid) noexcept
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_ATTRIBUTE)->Send(player, false);
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_ATTRIBUTE)->Send(player, true);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_ATTRIBUTE)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_ATTRIBUTE)->Send(player, true);
|
||||
}
|
||||
|
||||
void StatsFunctions::SendSkills(unsigned short pid) noexcept
|
||||
|
@ -495,8 +495,8 @@ void StatsFunctions::SendSkills(unsigned short pid) noexcept
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_SKILL)->Send(player, false);
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_SKILL)->Send(player, true);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_SKILL)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_SKILL)->Send(player, true);
|
||||
}
|
||||
|
||||
void StatsFunctions::SendLevel(unsigned short pid) noexcept
|
||||
|
@ -504,6 +504,6 @@ void StatsFunctions::SendLevel(unsigned short pid) noexcept
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_LEVEL)->Send(player, false);
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_LEVEL)->Send(player, true);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_LEVEL)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_LEVEL)->Send(player, true);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ void TranslocationFunctions::SetPos(unsigned short pid, double x, double y, doub
|
|||
player->Position()->pos[1] = y;
|
||||
player->Position()->pos[2] = z;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_POS)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_POS)->Send(player, false);
|
||||
}
|
||||
|
||||
void TranslocationFunctions::SetCell(unsigned short pid, const char *name) noexcept
|
||||
|
@ -80,7 +80,7 @@ void TranslocationFunctions::SetCell(unsigned short pid, const char *name) noexc
|
|||
|
||||
player->GetCell()->mName = name;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CELL)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CELL)->Send(player, false);
|
||||
}
|
||||
|
||||
const char* TranslocationFunctions::GetCell(unsigned short pid) noexcept
|
||||
|
@ -108,24 +108,24 @@ void TranslocationFunctions::SetExterior(unsigned short pid, int x, int y) noexc
|
|||
player->GetCell()->mData.mFlags &= ~ESM::Cell::Interior;
|
||||
}
|
||||
|
||||
player->GetCell()->mCellId.mIndex.mX = x;
|
||||
player->GetCell()->mCellId.mIndex.mY = y;
|
||||
player->GetCell()->mData.mX = x;
|
||||
player->GetCell()->mData.mY = y;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_CELL)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_CELL)->Send(player, false);
|
||||
}
|
||||
|
||||
int TranslocationFunctions::GetExteriorX(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,0);
|
||||
return player->GetCell()->mCellId.mIndex.mX;
|
||||
return player->GetCell()->mData.mX;
|
||||
}
|
||||
|
||||
int TranslocationFunctions::GetExteriorY(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,0);
|
||||
return player->GetCell()->mCellId.mIndex.mY;
|
||||
return player->GetCell()->mData.mY;
|
||||
}
|
||||
|
||||
bool TranslocationFunctions::IsInExterior(unsigned short pid) noexcept
|
||||
|
@ -183,5 +183,5 @@ void TranslocationFunctions::SetAngle(unsigned short pid, double x, double y, do
|
|||
player->Position()->rot[1] = y;
|
||||
player->Position()->rot[2] = z;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_POS)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_POS)->Send(player, false);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept
|
|||
player->month = -1;
|
||||
player->day = -1;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_TIME)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_TIME)->Send(player, false);
|
||||
}
|
||||
|
||||
void WorldFunctions::SetMonth(unsigned short pid, int month) noexcept
|
||||
|
@ -29,7 +29,7 @@ void WorldFunctions::SetMonth(unsigned short pid, int month) noexcept
|
|||
player->month = month;
|
||||
player->day = -1;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_TIME)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_TIME)->Send(player, false);
|
||||
|
||||
}
|
||||
|
||||
|
@ -42,5 +42,5 @@ void WorldFunctions::SetDay(unsigned short pid, int day) noexcept
|
|||
player->month = -1;
|
||||
player->day = day;
|
||||
|
||||
mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_TIME)->Send(player, false);
|
||||
mwmp::Networking::Get().GetPlayerController()->GetPacket(ID_GAME_TIME)->Send(player, false);
|
||||
}
|
||||
|
|
|
@ -551,7 +551,7 @@ namespace MWClass
|
|||
|
||||
void Npc::hit(const MWWorld::Ptr& ptr, float attackStrength, int type) const
|
||||
{
|
||||
if(mwmp::Main::get().getNetworking()->isDedicatedPlayer(ptr))
|
||||
if (mwmp::Main::get().getNetworking()->isDedicatedPlayer(ptr))
|
||||
return;
|
||||
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
|
@ -594,16 +594,16 @@ namespace MWClass
|
|||
|
||||
float hitchance = MWMechanics::getHitChance(ptr, victim, ptr.getClass().getSkill(ptr, weapskill));
|
||||
|
||||
if(ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
{
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->success = true;
|
||||
if(mwmp::Main::get().getNetworking()->isDedicatedPlayer(victim))
|
||||
if (mwmp::Main::get().getNetworking()->isDedicatedPlayer(victim))
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->target =mwmp::Players::GetPlayer(victim)->guid;
|
||||
}
|
||||
|
||||
if(Misc::Rng::roll0to99() >= hitchance)
|
||||
{
|
||||
if(ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
{
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->success = false;
|
||||
mwmp::Main::get().getLocalPlayer()->sendAttack(0);
|
||||
|
@ -843,7 +843,7 @@ namespace MWClass
|
|||
}
|
||||
|
||||
|
||||
if(attacker == MWMechanics::getPlayer() && mwmp::Main::get().getNetworking()->isDedicatedPlayer(ptr))
|
||||
if (attacker == MWMechanics::getPlayer() && mwmp::Main::get().getNetworking()->isDedicatedPlayer(ptr))
|
||||
{
|
||||
mwmp::Attack *_atk = mwmp::Main::get().getLocalPlayer()->GetAttack();
|
||||
_atk->damage = damage;
|
||||
|
@ -853,7 +853,7 @@ namespace MWClass
|
|||
mwmp::Main::get().getLocalPlayer()->sendAttack(0); // todo: make this sensitive to different weapon types
|
||||
}
|
||||
|
||||
if(ptr == MWMechanics::getPlayer())
|
||||
if (ptr == MWMechanics::getPlayer())
|
||||
{
|
||||
mwmp::Main::get().getLocalPlayer()->updateDynamicStats(true);
|
||||
mwmp::Main::get().getLocalPlayer()->updatePosition(true); // fix position after getting damage;
|
||||
|
@ -863,7 +863,7 @@ namespace MWClass
|
|||
boost::shared_ptr<MWWorld::Action> Npc::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
if(actor == MWMechanics::getPlayer() && mwmp::Main::get().getNetworking()->isDedicatedPlayer(ptr))
|
||||
if (actor == MWMechanics::getPlayer() && mwmp::Main::get().getNetworking()->isDedicatedPlayer(ptr))
|
||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::FailedAction("Not implemented."));
|
||||
// player got activated by another NPC
|
||||
if(ptr == MWMechanics::getPlayer())
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include "hud.hpp"
|
||||
|
||||
#include <components/openmw-mp/Base/WorldEvent.hpp>
|
||||
#include "../mwmp/Main.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
|
||||
#include <MyGUI_RenderManager.h>
|
||||
#include <MyGUI_ProgressBar.h>
|
||||
#include <MyGUI_Button.h>
|
||||
|
@ -51,6 +55,18 @@ namespace MWGui
|
|||
if (setNewOwner)
|
||||
dropped.getCellRef().setOwner("");
|
||||
|
||||
// Added by tes3mp
|
||||
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
|
||||
event->cell = *dropped.getCell()->getCell();
|
||||
event->cellRef.mRefID = dropped.getCellRef().getRefId();
|
||||
event->cellRef.mRefNum = dropped.getCellRef().getRefNum();
|
||||
event->cellRef.mPos = dropped.getCellRef().getPosition();
|
||||
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_WORLD_OBJECT_PLACE)->Send(event);
|
||||
|
||||
printf("Sending ID_WORLD_OBJECT_PLACE about %s\n%i\n",
|
||||
event->cellRef.mRefID.c_str(),
|
||||
event->cellRef.mRefNum.mIndex);
|
||||
|
||||
return dropped;
|
||||
}
|
||||
|
||||
|
|
|
@ -1039,7 +1039,7 @@ namespace MWMechanics
|
|||
mwmp::Main::get().getLocalPlayer()->prepareAttack(2, state);
|
||||
}
|
||||
|
||||
if(mwmp::Main::get().getNetworking()->isDedicatedPlayer(iter->first))
|
||||
if (mwmp::Main::get().getNetworking()->isDedicatedPlayer(iter->first))
|
||||
iter->second->getCharacterController()->setAttackingOrSpell(mwmp::Main::get().getNetworking()->Attack(iter->first));
|
||||
|
||||
|
||||
|
|
|
@ -117,13 +117,13 @@ namespace MWMechanics
|
|||
|
||||
|
||||
bool isDedicated = mwmp::Main::get().getNetworking()->isDedicatedPlayer(blocker);
|
||||
if(attacker == MWMechanics::getPlayer())
|
||||
if (attacker == MWMechanics::getPlayer())
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->block = false;
|
||||
|
||||
if((!isDedicated && Misc::Rng::roll0to99() < x) ||
|
||||
if ((!isDedicated && Misc::Rng::roll0to99() < x) ||
|
||||
(isDedicated && mwmp::Players::GetPlayer(blocker)->GetAttack()->block == 1))
|
||||
{
|
||||
if(attacker == MWMechanics::getPlayer())
|
||||
if (attacker == MWMechanics::getPlayer())
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->block = true;
|
||||
|
||||
// Reduce shield durability by incoming damage
|
||||
|
@ -180,7 +180,7 @@ namespace MWMechanics
|
|||
void projectileHit(const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim, MWWorld::Ptr weapon, const MWWorld::Ptr &projectile,
|
||||
const osg::Vec3f& hitPosition, float attackStrength)
|
||||
{
|
||||
if(mwmp::Main::get().getNetworking()->isDedicatedPlayer(attacker))
|
||||
if (mwmp::Main::get().getNetworking()->isDedicatedPlayer(attacker))
|
||||
return;
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
const MWWorld::Store<ESM::GameSetting> &gmst = world->getStore().get<ESM::GameSetting>();
|
||||
|
@ -202,7 +202,7 @@ namespace MWMechanics
|
|||
int skillValue = attacker.getClass().getSkill(attacker,
|
||||
weapon.getClass().getEquipmentSkill(weapon));
|
||||
|
||||
if(attacker == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
if (attacker == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->success = true;
|
||||
|
||||
if (Misc::Rng::roll0to99() >= getHitChance(attacker, victim, skillValue))
|
||||
|
|
|
@ -799,13 +799,13 @@ namespace MWMechanics
|
|||
|
||||
bool isDedicated = mwmp::Main::get().getNetworking()->isDedicatedPlayer(mCaster);
|
||||
|
||||
if(mCaster == getPlayer())
|
||||
if (mCaster == getPlayer())
|
||||
{
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->success = true;
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->pressed = true;
|
||||
}
|
||||
|
||||
if(isDedicated)
|
||||
if (isDedicated)
|
||||
{
|
||||
mwmp::Players::GetPlayer(mCaster)->GetAttack()->pressed = false;
|
||||
}
|
||||
|
@ -821,7 +821,7 @@ namespace MWMechanics
|
|||
fail = true;
|
||||
}
|
||||
|
||||
if(mCaster == getPlayer())
|
||||
if (mCaster == getPlayer())
|
||||
{
|
||||
mwmp::Main::get().getLocalPlayer()->sendAttack(1);
|
||||
mwmp::Main::get().getLocalPlayer()->GetAttack()->pressed = false;
|
||||
|
|
|
@ -439,7 +439,7 @@ void DedicatedPlayer::updateCell()
|
|||
MWWorld::CellStore *cellStore;
|
||||
|
||||
if (cell.isExterior() == 1)
|
||||
cellStore = world->getExterior(cell.mCellId.mIndex.mX, cell.mCellId.mIndex.mY);
|
||||
cellStore = world->getExterior(cell.mData.mX, cell.mData.mY);
|
||||
else if (!cell.mName.empty())
|
||||
cellStore = world->getInterior(cell.mName);
|
||||
// Go no further if cell data is invalid
|
||||
|
|
|
@ -130,7 +130,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,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;
|
||||
|
@ -168,7 +168,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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -90,7 +90,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)
|
||||
{
|
||||
|
@ -99,11 +99,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);*/
|
||||
|
||||
}
|
||||
|
@ -128,7 +128,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;
|
||||
|
@ -163,7 +163,7 @@ void LocalPlayer::updateDynamicStats(bool forceUpdate)
|
|||
|
||||
timer = 0;
|
||||
|
||||
GetNetworking()->GetPacket(ID_GAME_DYNAMICSTATS)->Send(this);
|
||||
GetNetworking()->GetPlayerPacket(ID_GAME_DYNAMICSTATS)->Send(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ void LocalPlayer::updateAttributes(bool forceUpdate)
|
|||
|
||||
if (isUpdating || forceUpdate)
|
||||
{
|
||||
GetNetworking()->GetPacket(ID_GAME_ATTRIBUTE)->Send(this);
|
||||
GetNetworking()->GetPlayerPacket(ID_GAME_ATTRIBUTE)->Send(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,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
|
||||
|
@ -273,7 +273,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))
|
||||
{
|
||||
|
@ -285,7 +285,7 @@ void LocalPlayer::updatePosition(bool forceUpdate)
|
|||
{
|
||||
sentJumpEnd = true;
|
||||
(*Position()) = ptrPos;
|
||||
GetNetworking()->GetPacket(ID_GAME_POS)->Send(this);
|
||||
GetNetworking()->GetPlayerPacket(ID_GAME_POS)->Send(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,11 +309,11 @@ void LocalPlayer::updateCell(bool forceUpdate)
|
|||
}
|
||||
else if (ptrCell->isExterior())
|
||||
{
|
||||
if (ptrCell->mCellId.mIndex.mX != GetCell()->mCellId.mIndex.mX)
|
||||
if (ptrCell->mData.mX != GetCell()->mData.mX)
|
||||
{
|
||||
shouldUpdate = true;
|
||||
}
|
||||
else if (ptrCell->mCellId.mIndex.mY != GetCell()->mCellId.mIndex.mY)
|
||||
else if (ptrCell->mData.mY != GetCell()->mData.mY)
|
||||
{
|
||||
shouldUpdate = true;
|
||||
}
|
||||
|
@ -334,7 +334,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
|
||||
|
@ -398,7 +398,7 @@ void LocalPlayer::updateEquipped(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);
|
||||
equipChanged = false;
|
||||
}
|
||||
|
@ -508,7 +508,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)
|
||||
|
@ -539,7 +539,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;
|
||||
}
|
||||
|
@ -606,7 +606,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,8 +695,8 @@ void LocalPlayer::setCell()
|
|||
|
||||
world->getPlayer().setTeleported(true);
|
||||
|
||||
int x = GetCell()->mCellId.mIndex.mX;
|
||||
int y = GetCell()->mCellId.mIndex.mY;
|
||||
int x = GetCell()->mData.mX;
|
||||
int y = GetCell()->mData.mY;
|
||||
|
||||
if (GetCell()->isExterior())
|
||||
{
|
||||
|
@ -783,7 +783,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)
|
||||
|
@ -801,7 +801,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);
|
||||
}
|
||||
|
||||
|
@ -832,6 +832,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);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,16 +10,17 @@
|
|||
#include <string>
|
||||
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include <components/openmw-mp/Packets/PacketPosition.hpp>
|
||||
#include <components/openmw-mp/Packets/PacketBaseInfo.hpp>
|
||||
#include <components/openmw-mp/Packets/PacketEquipment.hpp>
|
||||
#include <components/openmw-mp/Packets/PacketAttack.hpp>
|
||||
#include <components/openmw-mp/Packets/PacketDynamicStats.hpp>
|
||||
#include <components/openmw-mp/Packets/PacketResurrect.hpp>
|
||||
#include <components/openmw-mp/Packets/PacketDie.hpp>
|
||||
#include <components/openmw-mp/Packets/PacketCell.hpp>
|
||||
#include <components/openmw-mp/Packets/PacketDrawState.hpp>
|
||||
#include <components/openmw-mp/PacketsController.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PacketPosition.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PacketBaseInfo.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PacketEquipment.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PacketAttack.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PacketDynamicStats.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PacketResurrect.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PacketDie.hpp>
|
||||
#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);
|
||||
|
@ -45,14 +48,19 @@ namespace mwmp
|
|||
|
||||
bool isConnected();
|
||||
|
||||
WorldEvent *createWorldEvent();
|
||||
|
||||
private:
|
||||
bool connected;
|
||||
RakNet::RakPeerInterface *peer;
|
||||
RakNet::SystemAddress serverAddr;
|
||||
RakNet::BitStream bsOut;
|
||||
|
||||
PacketsController controller;
|
||||
PlayerPacketController playerController;
|
||||
WorldPacketController worldController;
|
||||
|
||||
void ProcessPlayerPacket(RakNet::Packet *packet);
|
||||
void ProcessWorldPacket(RakNet::Packet *packet);
|
||||
void ReceiveMessage(RakNet::Packet *packet);
|
||||
LocalPlayer *getLocalPlayer();
|
||||
};
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <components/openmw-mp/Base/WorldEvent.hpp>
|
||||
#include "../mwmp/Main.hpp"
|
||||
|
||||
#include <components/compiler/extensions.hpp>
|
||||
#include <components/compiler/opcodes.hpp>
|
||||
#include <components/compiler/locals.hpp>
|
||||
|
@ -668,7 +671,16 @@ namespace MWScript
|
|||
runtime.pop();
|
||||
|
||||
if (parameter == 1)
|
||||
{
|
||||
// Added by tes3mp
|
||||
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
|
||||
event->cell = *ptr.getCell()->getCell();
|
||||
event->cellRef.mRefID = ptr.getCellRef().getRefId();
|
||||
event->cellRef.mRefNum = ptr.getCellRef().getRefNum();
|
||||
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_WORLD_OBJECT_DELETE)->Send(event);
|
||||
|
||||
MWBase::Environment::get().getWorld()->deleteObject(ptr);
|
||||
}
|
||||
else if (parameter == 0)
|
||||
MWBase::Environment::get().getWorld()->undeleteObject(ptr);
|
||||
else
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include "actiontake.hpp"
|
||||
|
||||
#include <components/openmw-mp/Base/WorldEvent.hpp>
|
||||
#include "../mwmp/Main.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
@ -17,6 +21,19 @@ namespace MWWorld
|
|||
MWBase::Environment::get().getMechanicsManager()->itemTaken(
|
||||
actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
|
||||
actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
|
||||
|
||||
// Added by tes3mp
|
||||
mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent();
|
||||
event->cell = *getTarget().getCell()->getCell();
|
||||
event->cellRef.mRefID = getTarget().getCellRef().getRefId();
|
||||
event->cellRef.mRefNum = getTarget().getCellRef().getRefNum();
|
||||
mwmp::Main::get().getNetworking()->GetWorldPacket(ID_WORLD_OBJECT_DELETE)->Send(event);
|
||||
|
||||
printf("Sending ID_WORLD_OBJECT_DELETE about\n- cellRef: %s, %i\n- cell: %s",
|
||||
event->cellRef.mRefID.c_str(),
|
||||
event->cellRef.mRefNum.mIndex,
|
||||
event->cell.getDescription().c_str());
|
||||
|
||||
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,6 +168,30 @@ namespace
|
|||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Added by tes3mp
|
||||
template <typename PtrType>
|
||||
struct SearchByRefNumCustomVisitor
|
||||
{
|
||||
PtrType mFound;
|
||||
ESM::RefNum mRefNumToFind;
|
||||
|
||||
SearchByRefNumCustomVisitor(const ESM::RefNum& toFind)
|
||||
: mFound(NULL)
|
||||
, mRefNumToFind(toFind)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(const PtrType& ptr)
|
||||
{
|
||||
if (ptr.getCellRef().getRefNum() == mRefNumToFind)
|
||||
{
|
||||
mFound = ptr;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
|
@ -433,6 +457,14 @@ namespace MWWorld
|
|||
return Ptr();
|
||||
}
|
||||
|
||||
// Added by tes3mp
|
||||
Ptr CellStore::searchByRefNum (ESM::RefNum refNum)
|
||||
{
|
||||
SearchByRefNumCustomVisitor<MWWorld::Ptr> searchVisitor(refNum);
|
||||
forEach(searchVisitor);
|
||||
return searchVisitor.mFound;
|
||||
}
|
||||
|
||||
float CellStore::getWaterLevel() const
|
||||
{
|
||||
if (isExterior())
|
||||
|
|
|
@ -228,6 +228,9 @@ namespace MWWorld
|
|||
Ptr searchViaActorId (int id);
|
||||
///< Will return an empty Ptr if cell is not loaded.
|
||||
|
||||
Ptr searchByRefNum (ESM::RefNum refNum);
|
||||
///< Added by tes3mp
|
||||
|
||||
float getWaterLevel() const;
|
||||
|
||||
void setWaterLevel (float level);
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace MWWorld
|
|||
*/
|
||||
MWWorld::CellRef mRef;
|
||||
|
||||
/* Added by TES3MP to prevent dedicated players' references from automatically
|
||||
/* Added by tes3mp to prevent dedicated players' references from automatically
|
||||
* and unpredictably moving across exterior cell boundaries on clients
|
||||
*/
|
||||
bool canChangeCell;
|
||||
|
|
|
@ -147,11 +147,17 @@ add_component_dir (version
|
|||
|
||||
add_component_dir (openmw-mp
|
||||
Log
|
||||
PacketsController
|
||||
Packets/PlayerPacket Packets/PacketBaseInfo Packets/PacketPosition Packets/PacketEquipment Packets/PacketAttack
|
||||
Packets/PacketDynamicStats Packets/PacketCell Packets/PacketDrawState Packets/PacketChatMessage
|
||||
Packets/PacketCharGen Packets/PacketAttribute Packets/PacketSkill Packets/PacketLevel Packets/PacketHandshake
|
||||
Packets/PacketGUIBoxes Packets/PacketClass Packets/PacketTime Packets/PacketInventory)
|
||||
Controllers/PlayerPacketController Controllers/WorldPacketController
|
||||
Packets/BasePacket Packets/Player/PlayerPacket Packets/World/WorldPacket
|
||||
|
||||
Packets/Player/PacketBaseInfo Packets/Player/PacketPosition Packets/Player/PacketEquipment
|
||||
Packets/Player/PacketAttack Packets/Player/PacketDynamicStats Packets/Player/PacketCell
|
||||
Packets/Player/PacketDrawState Packets/Player/PacketChatMessage Packets/Player/PacketCharGen
|
||||
Packets/Player/PacketAttribute Packets/Player/PacketSkill Packets/Player/PacketLevel
|
||||
Packets/Player/PacketHandshake Packets/Player/PacketGUIBoxes Packets/Player/PacketClass
|
||||
Packets/Player/PacketTime Packets/PacketInventory
|
||||
|
||||
Packets/World/PacketObjectDelete Packets/World/PacketObjectPlace)
|
||||
|
||||
add_component_dir (fallback
|
||||
fallback validate
|
||||
|
|
31
components/openmw-mp/Base/WorldEvent.hpp
Normal file
31
components/openmw-mp/Base/WorldEvent.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef OPENMW_WORLDEVENT_HPP
|
||||
#define OPENMW_WORLDEVENT_HPP
|
||||
|
||||
#include <components/esm/loadcell.hpp>
|
||||
#include <components/esm/cellref.hpp>
|
||||
#include <RakNetTypes.h>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class WorldEvent
|
||||
{
|
||||
public:
|
||||
|
||||
WorldEvent(RakNet::RakNetGUID guid) : guid(guid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
WorldEvent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RakNet::RakNetGUID guid;
|
||||
|
||||
ESM::Cell cell;
|
||||
ESM::CellRef cellRef;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_WORLDEVENT_HPP
|
87
components/openmw-mp/Controllers/PlayerPacketController.cpp
Normal file
87
components/openmw-mp/Controllers/PlayerPacketController.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
#include "../Packets/Player/PacketClass.hpp"
|
||||
#include "../Packets/Player/PacketPosition.hpp"
|
||||
#include "../Packets/Player/PacketBaseInfo.hpp"
|
||||
#include "../Packets/Player/PacketEquipment.hpp"
|
||||
#include "../Packets/Player/PacketAttack.hpp"
|
||||
#include "../Packets/Player/PacketDynamicStats.hpp"
|
||||
#include "../Packets/Player/PacketResurrect.hpp"
|
||||
#include "../Packets/Player/PacketDie.hpp"
|
||||
#include "../Packets/Player/PacketCell.hpp"
|
||||
#include "../Packets/Player/PacketSendMyID.hpp"
|
||||
#include "../Packets/Player/PacketDisconnect.hpp"
|
||||
#include "../Packets/Player/PacketDrawState.hpp"
|
||||
#include "../Packets/Player/PacketChatMessage.hpp"
|
||||
#include "../Packets/Player/PacketCharGen.hpp"
|
||||
#include "../Packets/Player/PacketAttribute.hpp"
|
||||
#include "../Packets/Player/PacketSkill.hpp"
|
||||
#include "../Packets/Player/PacketLevel.hpp"
|
||||
#include "../Packets/Player/PacketHandshake.hpp"
|
||||
#include "../Packets/Player/PacketGUIBoxes.hpp"
|
||||
#include "../Packets/Player/PacketTime.hpp"
|
||||
#include "../Packets/Player/PacketLoaded.hpp"
|
||||
#include "../Packets/Player/PacketInventory.hpp"
|
||||
|
||||
#include "PlayerPacketController.hpp"
|
||||
|
||||
template <typename T>
|
||||
inline void AddPacket(mwmp::PlayerPacketController::packets_t *packets, RakNet::RakPeerInterface *peer)
|
||||
{
|
||||
T *packet = new T(peer);
|
||||
typedef mwmp::PlayerPacketController::packets_t::value_type value_t;
|
||||
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet)));
|
||||
}
|
||||
|
||||
mwmp::PlayerPacketController::PlayerPacketController(RakNet::RakPeerInterface *peer)
|
||||
{
|
||||
AddPacket<PacketPosition>(&packets, peer);
|
||||
AddPacket<PacketCell>(&packets, peer);
|
||||
AddPacket<PacketBaseInfo>(&packets, peer);
|
||||
AddPacket<PacketEquipment>(&packets, peer);
|
||||
|
||||
AddPacket<PacketAttack>(&packets, peer);
|
||||
AddPacket<PacketDynamicStats>(&packets, peer);
|
||||
AddPacket<PacketResurrect>(&packets, peer);
|
||||
|
||||
AddPacket<PacketDie>(&packets, peer);
|
||||
AddPacket<PacketDrawState>(&packets, peer);
|
||||
AddPacket<PacketSendMyID>(&packets, peer);
|
||||
AddPacket<PacketDisconnect>(&packets, peer);
|
||||
|
||||
AddPacket<PacketChatMessage>(&packets, peer);
|
||||
AddPacket<PacketCharGen>(&packets, peer);
|
||||
AddPacket<PacketAttribute>(&packets, peer);
|
||||
AddPacket<PacketSkill>(&packets, peer);
|
||||
AddPacket<PacketLevel>(&packets, peer);
|
||||
|
||||
AddPacket<PacketHandshake>(&packets, peer);
|
||||
AddPacket<PacketGUIBoxes>(&packets, peer);
|
||||
AddPacket<PacketClass>(&packets, peer);
|
||||
AddPacket<PacketTime>(&packets, peer);
|
||||
AddPacket<PacketLoaded>(&packets, peer);
|
||||
AddPacket<PacketInventory>(&packets, peer);
|
||||
}
|
||||
|
||||
|
||||
mwmp::PlayerPacket *mwmp::PlayerPacketController::GetPacket(RakNet::MessageID id)
|
||||
{
|
||||
return packets[(unsigned char)id].get();
|
||||
}
|
||||
|
||||
void mwmp::PlayerPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||||
{
|
||||
BOOST_FOREACH( packets_t::value_type &packet, packets )
|
||||
packet.second->SetStreams(inStream, outStream);
|
||||
}
|
||||
|
||||
bool mwmp::PlayerPacketController::ContainsPacket(RakNet::MessageID id)
|
||||
{
|
||||
BOOST_FOREACH(packets_t::value_type &packet, packets) {
|
||||
if (packet.first == id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -1,29 +1,27 @@
|
|||
//
|
||||
// Created by koncord on 15.01.16.
|
||||
//
|
||||
|
||||
#ifndef OPENMW_PACKETSCONTROLLER_HPP
|
||||
#define OPENMW_PACKETSCONTROLLER_HPP
|
||||
#ifndef OPENMW_PLAYERPACKETCONTROLLER_HPP
|
||||
#define OPENMW_PLAYERPACKETCONTROLLER_HPP
|
||||
|
||||
|
||||
#include <RakPeerInterface.h>
|
||||
#include "Packets/PlayerPacket.hpp"
|
||||
#include "../Packets/Player/PlayerPacket.hpp"
|
||||
#include <map>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class PacketsController
|
||||
class PlayerPacketController
|
||||
{
|
||||
public:
|
||||
PacketsController(RakNet::RakPeerInterface *peer);
|
||||
PlayerPacketController(RakNet::RakPeerInterface *peer);
|
||||
PlayerPacket *GetPacket(RakNet::MessageID id);
|
||||
void SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream);
|
||||
|
||||
bool ContainsPacket(RakNet::MessageID id);
|
||||
|
||||
typedef std::map<unsigned char, boost::shared_ptr<PlayerPacket> > packets_t;
|
||||
private:
|
||||
packets_t packets;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PACKETSCONTROLLER_HPP
|
||||
#endif //OPENMW_PLAYERPACKETCONTROLLER_HPP
|
43
components/openmw-mp/Controllers/WorldPacketController.cpp
Normal file
43
components/openmw-mp/Controllers/WorldPacketController.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
#include "../Packets/World/PacketObjectPlace.hpp"
|
||||
#include "../Packets/World/PacketObjectDelete.hpp"
|
||||
|
||||
#include "WorldPacketController.hpp"
|
||||
|
||||
template <typename T>
|
||||
inline void AddPacket(mwmp::WorldPacketController::packets_t *packets, RakNet::RakPeerInterface *peer)
|
||||
{
|
||||
T *packet = new T(peer);
|
||||
typedef mwmp::WorldPacketController::packets_t::value_type value_t;
|
||||
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet)));
|
||||
}
|
||||
|
||||
mwmp::WorldPacketController::WorldPacketController(RakNet::RakPeerInterface *peer)
|
||||
{
|
||||
AddPacket<PacketObjectPlace>(&packets, peer);
|
||||
AddPacket<PacketObjectDelete>(&packets, peer);
|
||||
}
|
||||
|
||||
|
||||
mwmp::WorldPacket *mwmp::WorldPacketController::GetPacket(RakNet::MessageID id)
|
||||
{
|
||||
return packets[(unsigned char)id].get();
|
||||
}
|
||||
|
||||
void mwmp::WorldPacketController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||||
{
|
||||
BOOST_FOREACH( packets_t::value_type &packet, packets )
|
||||
packet.second->SetStreams(inStream, outStream);
|
||||
}
|
||||
|
||||
bool mwmp::WorldPacketController::ContainsPacket(RakNet::MessageID id)
|
||||
{
|
||||
BOOST_FOREACH(packets_t::value_type &packet, packets) {
|
||||
if (packet.first == id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
27
components/openmw-mp/Controllers/WorldPacketController.hpp
Normal file
27
components/openmw-mp/Controllers/WorldPacketController.hpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef OPENMW_WORLDPACKETCONTROLLER_HPP
|
||||
#define OPENMW_WORLDPACKETCONTROLLER_HPP
|
||||
|
||||
|
||||
#include <RakPeerInterface.h>
|
||||
#include "../Packets/World/WorldPacket.hpp"
|
||||
#include <map>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class WorldPacketController
|
||||
{
|
||||
public:
|
||||
WorldPacketController(RakNet::RakPeerInterface *peer);
|
||||
WorldPacket *GetPacket(RakNet::MessageID id);
|
||||
void SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream);
|
||||
|
||||
bool ContainsPacket(RakNet::MessageID id);
|
||||
|
||||
typedef std::map<unsigned char, boost::shared_ptr<WorldPacket> > packets_t;
|
||||
private:
|
||||
packets_t packets;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_WORLDPACKETCONTROLLER_HPP
|
|
@ -31,7 +31,10 @@ enum GameMessages
|
|||
ID_LOADED,
|
||||
ID_GUI_MESSAGEBOX,
|
||||
ID_GAME_TIME,
|
||||
ID_GAME_INVENTORY
|
||||
ID_GAME_INVENTORY,
|
||||
|
||||
ID_WORLD_OBJECT_PLACE,
|
||||
ID_WORLD_OBJECT_DELETE
|
||||
};
|
||||
|
||||
|
||||
|
|
37
components/openmw-mp/Packets/BasePacket.cpp
Normal file
37
components/openmw-mp/Packets/BasePacket.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include <PacketPriority.h>
|
||||
#include <RakPeer.h>
|
||||
#include "BasePacket.hpp"
|
||||
|
||||
using namespace mwmp;
|
||||
|
||||
BasePacket::BasePacket(RakNet::RakPeerInterface *peer)
|
||||
{
|
||||
packetID = 0;
|
||||
priority = HIGH_PRIORITY;
|
||||
reliability = RELIABLE_ORDERED;
|
||||
this->peer = peer;
|
||||
}
|
||||
|
||||
BasePacket::~BasePacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BasePacket::SetReadStream(RakNet::BitStream *bitStream)
|
||||
{
|
||||
bsRead = bitStream;
|
||||
}
|
||||
|
||||
void BasePacket::SetSendStream(RakNet::BitStream *bitStream)
|
||||
{
|
||||
bsSend = bitStream;
|
||||
}
|
||||
|
||||
void BasePacket::SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||||
{
|
||||
if (inStream != 0)
|
||||
bsRead = inStream;
|
||||
if (outStream != 0)
|
||||
bsSend = outStream;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef OPENMW_PLAYERPACKET_HPP
|
||||
#define OPENMW_PLAYERPACKET_HPP
|
||||
#ifndef OPENMW_BASEPACKET_HPP
|
||||
#define OPENMW_BASEPACKET_HPP
|
||||
|
||||
#include <string>
|
||||
#include <RakNetTypes.h>
|
||||
|
@ -10,20 +10,12 @@
|
|||
|
||||
namespace mwmp
|
||||
{
|
||||
class PlayerPacket
|
||||
class BasePacket
|
||||
{
|
||||
public:
|
||||
PlayerPacket(RakNet::RakPeerInterface *peer);
|
||||
BasePacket(RakNet::RakPeerInterface *peer);
|
||||
|
||||
~PlayerPacket();
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);
|
||||
|
||||
virtual void Send(BasePlayer *player, bool toOtherPlayers = true);
|
||||
virtual void Send(BasePlayer *player, RakNet::AddressOrGUID destination);
|
||||
virtual void Read(BasePlayer *player);
|
||||
|
||||
virtual void RequestData(RakNet::RakNetGUID player);
|
||||
~BasePacket();
|
||||
|
||||
void SetReadStream(RakNet::BitStream *bitStream);
|
||||
void SetSendStream(RakNet::BitStream *bitStream);
|
||||
|
@ -90,16 +82,12 @@ namespace mwmp
|
|||
}
|
||||
|
||||
protected:
|
||||
BasePlayer *player;
|
||||
unsigned char packetID;
|
||||
PacketReliability reliability;
|
||||
PacketPriority priority;
|
||||
|
||||
private:
|
||||
RakNet::BitStream *bsRead, *bsSend, *bs;
|
||||
RakNet::RakPeerInterface *peer;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PLAYERPACKET_HPP
|
||||
#endif //OPENMW_BASEPACKET_HPP
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_PACKETATTACK_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef OPENMW_PACKETATTRIBUTE_HPP
|
||||
#define OPENMW_PACKETATTRIBUTE_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef OPENMW_PACKETBASEINFO_HPP
|
||||
#define OPENMW_PACKETBASEINFO_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -18,9 +18,7 @@ void mwmp::PacketCell::Packet(RakNet::BitStream *bs, mwmp::BasePlayer *player, b
|
|||
PlayerPacket::Packet(bs, player, send);
|
||||
|
||||
RW(player->GetCell()->mData.mFlags, send);
|
||||
|
||||
RW(player->GetCell()->mCellId.mIndex.mX, send);
|
||||
RW(player->GetCell()->mCellId.mIndex.mY, send);
|
||||
|
||||
RW(player->GetCell()->mData.mX, send);
|
||||
RW(player->GetCell()->mData.mY, send);
|
||||
RW(player->GetCell()->mName, send);
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_PACKETCELL_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_PACKETCHARGEN_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef OPENMW_PACKETCHATMESSAGE_HPP
|
||||
#define OPENMW_PACKETCHATMESSAGE_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_PACKETCLASS_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_PACKETDIE_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
|
||||
namespace mwmp
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef OPENMW_PACKETDISCONNECT_HPP
|
||||
#define OPENMW_PACKETDISCONNECT_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
|
||||
namespace mwmp
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_PACKETDRAWSTATE_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_PACKAGEDYNAMICSTATS_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef OPENMW_PACKETEQUIPMENT_HPP
|
||||
#define OPENMW_PACKETEQUIPMENT_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_PACKETGUIBOXES_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef OPENMW_PACKETHANDSHAKE_HPP
|
||||
#define OPENMW_PACKETHANDSHAKE_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef OPENMW_PACKETLEVEL_HPP
|
||||
#define OPENMW_PACKETLEVEL_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef OPENMW_PACKETLOADED_HPP
|
||||
#define OPENMW_PACKETLOADED_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef OPENMW_PACKETPOSITION_HPP
|
||||
#define OPENMW_PACKETPOSITION_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_PACKETRESURRECT_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
|
||||
namespace mwmp
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef OPENMW_PACKETSENDMYID_HPP
|
||||
#define OPENMW_PACKETSENDMYID_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
|
||||
namespace mwmp
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_PACKETSKILL_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -6,7 +6,7 @@
|
|||
#define OPENMW_TIMEPACKET_HPP
|
||||
|
||||
|
||||
#include <components/openmw-mp/Packets/PlayerPacket.hpp>
|
||||
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
|
@ -17,7 +17,7 @@ void PlayerPacket::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
|
|||
}
|
||||
}
|
||||
|
||||
PlayerPacket::PlayerPacket(RakNet::RakPeerInterface *peer)
|
||||
PlayerPacket::PlayerPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
||||
{
|
||||
packetID = 0;
|
||||
priority = HIGH_PRIORITY;
|
||||
|
@ -49,28 +49,10 @@ void PlayerPacket::Read(BasePlayer *player)
|
|||
Packet(bsRead, player, false);
|
||||
}
|
||||
|
||||
void PlayerPacket::SetReadStream(RakNet::BitStream *bitStream)
|
||||
{
|
||||
bsRead = bitStream;
|
||||
}
|
||||
|
||||
void PlayerPacket::SetSendStream(RakNet::BitStream *bitStream)
|
||||
{
|
||||
bsSend = bitStream;
|
||||
}
|
||||
|
||||
void PlayerPacket::RequestData(RakNet::RakNetGUID player)
|
||||
void PlayerPacket::RequestData(RakNet::RakNetGUID guid)
|
||||
{
|
||||
bsSend->ResetWritePointer();
|
||||
bsSend->Write(packetID);
|
||||
bsSend->Write(player);
|
||||
peer->Send(bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, player, false);
|
||||
bsSend->Write(guid);
|
||||
peer->Send(bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false);
|
||||
}
|
||||
|
||||
void PlayerPacket::SetStreams(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||||
{
|
||||
if (inStream != 0)
|
||||
bsRead = inStream;
|
||||
if (outStream != 0)
|
||||
bsSend = outStream;
|
||||
}
|
46
components/openmw-mp/Packets/Player/PlayerPacket.hpp
Normal file
46
components/openmw-mp/Packets/Player/PlayerPacket.hpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#ifndef OPENMW_PLAYERPACKET_HPP
|
||||
#define OPENMW_PLAYERPACKET_HPP
|
||||
|
||||
#include <string>
|
||||
#include <RakNetTypes.h>
|
||||
#include <BitStream.h>
|
||||
#include <PacketPriority.h>
|
||||
#include <components/openmw-mp/Base/BasePlayer.hpp>
|
||||
|
||||
#include <components/openmw-mp/Packets/BasePacket.hpp>
|
||||
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class PlayerPacket : public BasePacket
|
||||
{
|
||||
public:
|
||||
PlayerPacket(RakNet::RakPeerInterface *peer);
|
||||
|
||||
~PlayerPacket();
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);
|
||||
|
||||
virtual void Send(BasePlayer *player, bool toOtherPlayers = true);
|
||||
virtual void Send(BasePlayer *player, RakNet::AddressOrGUID destination);
|
||||
virtual void Read(BasePlayer *player);
|
||||
|
||||
virtual void RequestData(RakNet::RakNetGUID guid);
|
||||
|
||||
static size_t headerSize()
|
||||
{
|
||||
return (size_t)(1 + RakNet::RakNetGUID::size()); // packetID + RakNetGUID (uint64_t)
|
||||
}
|
||||
|
||||
unsigned char GetPacketID()
|
||||
{
|
||||
return packetID;
|
||||
}
|
||||
|
||||
protected:
|
||||
BasePlayer *player;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PLAYERPACKET_HPP
|
22
components/openmw-mp/Packets/World/PacketObjectDelete.cpp
Normal file
22
components/openmw-mp/Packets/World/PacketObjectDelete.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include "PacketObjectDelete.hpp"
|
||||
|
||||
using namespace mwmp;
|
||||
|
||||
PacketObjectDelete::PacketObjectDelete(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||
{
|
||||
packetID = ID_WORLD_OBJECT_DELETE;
|
||||
}
|
||||
|
||||
void PacketObjectDelete::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send)
|
||||
{
|
||||
WorldPacket::Packet(bs, event, send);
|
||||
|
||||
RW(event->cellRef.mRefID, send);
|
||||
RW(event->cellRef.mRefNum.mIndex, send);
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
RW(event->cell.mName, send);
|
||||
}
|
17
components/openmw-mp/Packets/World/PacketObjectDelete.hpp
Normal file
17
components/openmw-mp/Packets/World/PacketObjectDelete.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef OPENMW_PACKETOBJECTDELETE_HPP
|
||||
#define OPENMW_PACKETOBJECTDELETE_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/World/WorldPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class PacketObjectDelete : public WorldPacket
|
||||
{
|
||||
public:
|
||||
PacketObjectDelete(RakNet::RakPeerInterface *peer);
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PACKETOBJECTDELETE_HPP
|
23
components/openmw-mp/Packets/World/PacketObjectPlace.cpp
Normal file
23
components/openmw-mp/Packets/World/PacketObjectPlace.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include "PacketObjectPlace.hpp"
|
||||
|
||||
using namespace mwmp;
|
||||
|
||||
PacketObjectPlace::PacketObjectPlace(RakNet::RakPeerInterface *peer) : WorldPacket(peer)
|
||||
{
|
||||
packetID = ID_WORLD_OBJECT_PLACE;
|
||||
}
|
||||
|
||||
void PacketObjectPlace::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send)
|
||||
{
|
||||
WorldPacket::Packet(bs, event, send);
|
||||
|
||||
RW(event->cellRef.mRefID, send);
|
||||
RW(event->cellRef.mRefNum.mIndex, send);
|
||||
RW(event->cellRef.mPos, send);
|
||||
|
||||
RW(event->cell.mData.mFlags, send);
|
||||
RW(event->cell.mData.mX, send);
|
||||
RW(event->cell.mData.mY, send);
|
||||
RW(event->cell.mName, send);
|
||||
}
|
17
components/openmw-mp/Packets/World/PacketObjectPlace.hpp
Normal file
17
components/openmw-mp/Packets/World/PacketObjectPlace.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef OPENMW_PACKETOBJECTPLACE_HPP
|
||||
#define OPENMW_PACKETOBJECTPLACE_HPP
|
||||
|
||||
#include <components/openmw-mp/Packets/World/WorldPacket.hpp>
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class PacketObjectPlace : public WorldPacket
|
||||
{
|
||||
public:
|
||||
PacketObjectPlace(RakNet::RakPeerInterface *peer);
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_PACKETOBJECTPLACE_HPP
|
58
components/openmw-mp/Packets/World/WorldPacket.cpp
Normal file
58
components/openmw-mp/Packets/World/WorldPacket.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include <PacketPriority.h>
|
||||
#include <RakPeer.h>
|
||||
#include "WorldPacket.hpp"
|
||||
|
||||
using namespace mwmp;
|
||||
|
||||
void WorldPacket::Packet(RakNet::BitStream *bs, WorldEvent *event, bool send)
|
||||
{
|
||||
this->event = event;
|
||||
this->bs = bs;
|
||||
|
||||
if (send)
|
||||
{
|
||||
bs->Write(packetID);
|
||||
bs->Write(event->guid);
|
||||
}
|
||||
}
|
||||
|
||||
WorldPacket::WorldPacket(RakNet::RakPeerInterface *peer) : BasePacket(peer)
|
||||
{
|
||||
packetID = 0;
|
||||
priority = HIGH_PRIORITY;
|
||||
reliability = RELIABLE_ORDERED;
|
||||
this->peer = peer;
|
||||
}
|
||||
|
||||
WorldPacket::~WorldPacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WorldPacket::Send(WorldEvent *event, RakNet::AddressOrGUID destination)
|
||||
{
|
||||
bsSend->ResetWritePointer();
|
||||
Packet(bsSend, event, true);
|
||||
peer->Send(bsSend, priority, reliability, 0, destination, false);
|
||||
}
|
||||
|
||||
void WorldPacket::Send(WorldEvent *event, bool toOther)
|
||||
{
|
||||
bsSend->ResetWritePointer();
|
||||
Packet(bsSend, event, true);
|
||||
peer->Send(bsSend, priority, reliability, 0, event->guid, toOther);
|
||||
}
|
||||
|
||||
void WorldPacket::Read(WorldEvent *event)
|
||||
{
|
||||
Packet(bsRead, event, false);
|
||||
}
|
||||
|
||||
void WorldPacket::RequestData(RakNet::RakNetGUID guid)
|
||||
{
|
||||
bsSend->ResetWritePointer();
|
||||
bsSend->Write(packetID);
|
||||
bsSend->Write(guid);
|
||||
peer->Send(bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false);
|
||||
}
|
46
components/openmw-mp/Packets/World/WorldPacket.hpp
Normal file
46
components/openmw-mp/Packets/World/WorldPacket.hpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#ifndef OPENMW_WORLDPACKET_HPP
|
||||
#define OPENMW_WORLDPACKET_HPP
|
||||
|
||||
#include <string>
|
||||
#include <RakNetTypes.h>
|
||||
#include <BitStream.h>
|
||||
#include <PacketPriority.h>
|
||||
#include <components/openmw-mp/Base/WorldEvent.hpp>
|
||||
|
||||
#include <components/openmw-mp/Packets/BasePacket.hpp>
|
||||
|
||||
|
||||
namespace mwmp
|
||||
{
|
||||
class WorldPacket : public BasePacket
|
||||
{
|
||||
public:
|
||||
WorldPacket(RakNet::RakPeerInterface *peer);
|
||||
|
||||
~WorldPacket();
|
||||
|
||||
virtual void Packet(RakNet::BitStream *bs, WorldEvent *event, bool send);
|
||||
|
||||
virtual void Send(WorldEvent *event, bool toOtherPlayers = true);
|
||||
virtual void Send(WorldEvent *event, RakNet::AddressOrGUID destination);
|
||||
virtual void Read(WorldEvent *event);
|
||||
|
||||
virtual void RequestData(RakNet::RakNetGUID guid);
|
||||
|
||||
static size_t headerSize()
|
||||
{
|
||||
return (size_t)(1 + RakNet::RakNetGUID::size()); // packetID + RakNetGUID (uint64_t)
|
||||
}
|
||||
|
||||
unsigned char GetPacketID()
|
||||
{
|
||||
return packetID;
|
||||
}
|
||||
|
||||
protected:
|
||||
WorldEvent *event;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif //OPENMW_WORLDPACKET_HPP
|
|
@ -1,82 +0,0 @@
|
|||
//
|
||||
// Created by koncord on 15.01.16.
|
||||
//
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
#include "Packets/PacketClass.hpp"
|
||||
#include "Packets/PacketPosition.hpp"
|
||||
#include "Packets/PacketBaseInfo.hpp"
|
||||
#include "components/openmw-mp/Packets/PacketEquipment.hpp"
|
||||
#include "Packets/PacketAttack.hpp"
|
||||
#include "Packets/PacketDynamicStats.hpp"
|
||||
#include "Packets/PacketResurrect.hpp"
|
||||
#include "Packets/PacketDie.hpp"
|
||||
#include "Packets/PacketCell.hpp"
|
||||
#include "Packets/PacketSendMyID.hpp"
|
||||
#include "Packets/PacketDisconnect.hpp"
|
||||
#include "Packets/PacketDrawState.hpp"
|
||||
#include "Packets/PacketChatMessage.hpp"
|
||||
#include "Packets/PacketCharGen.hpp"
|
||||
#include "Packets/PacketAttribute.hpp"
|
||||
#include "Packets/PacketSkill.hpp"
|
||||
#include "Packets/PacketLevel.hpp"
|
||||
#include "Packets/PacketHandshake.hpp"
|
||||
#include "Packets/PacketGUIBoxes.hpp"
|
||||
#include "Packets/PacketTime.hpp"
|
||||
#include "Packets/PacketLoaded.hpp"
|
||||
#include "Packets/PacketInventory.hpp"
|
||||
|
||||
#include "PacketsController.hpp"
|
||||
|
||||
template <typename T>
|
||||
inline void AddPacket(mwmp::PacketsController::packets_t *packets, RakNet::RakPeerInterface *peer)
|
||||
{
|
||||
T *packet = new T(peer);
|
||||
typedef mwmp::PacketsController::packets_t::value_type value_t;
|
||||
packets->insert(value_t(packet->GetPacketID(), value_t::second_type(packet)));
|
||||
}
|
||||
|
||||
mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer)
|
||||
{
|
||||
AddPacket<PacketPosition>(&packets, peer);
|
||||
AddPacket<PacketCell>(&packets, peer);
|
||||
AddPacket<PacketBaseInfo>(&packets, peer);
|
||||
AddPacket<PacketEquipment>(&packets, peer);
|
||||
|
||||
AddPacket<PacketAttack>(&packets, peer);
|
||||
AddPacket<PacketDynamicStats>(&packets, peer);
|
||||
AddPacket<PacketResurrect>(&packets, peer);
|
||||
|
||||
AddPacket<PacketDie>(&packets, peer);
|
||||
AddPacket<PacketDrawState>(&packets, peer);
|
||||
AddPacket<PacketSendMyID>(&packets, peer);
|
||||
AddPacket<PacketDisconnect>(&packets, peer);
|
||||
|
||||
AddPacket<PacketChatMessage>(&packets, peer);
|
||||
AddPacket<PacketCharGen>(&packets, peer);
|
||||
AddPacket<PacketAttribute>(&packets, peer);
|
||||
AddPacket<PacketSkill>(&packets, peer);
|
||||
AddPacket<PacketLevel>(&packets, peer);
|
||||
|
||||
AddPacket<PacketHandshake>(&packets, peer);
|
||||
AddPacket<PacketGUIBoxes>(&packets, peer);
|
||||
AddPacket<PacketClass>(&packets, peer);
|
||||
AddPacket<PacketTime>(&packets, peer);
|
||||
AddPacket<PacketLoaded>(&packets, peer);
|
||||
AddPacket<PacketInventory>(&packets, peer);
|
||||
}
|
||||
|
||||
|
||||
mwmp::PlayerPacket *mwmp::PacketsController::GetPacket(RakNet::MessageID id)
|
||||
{
|
||||
return packets[(unsigned char)id].get();
|
||||
}
|
||||
|
||||
void mwmp::PacketsController::SetStream(RakNet::BitStream *inStream, RakNet::BitStream *outStream)
|
||||
{
|
||||
BOOST_FOREACH( packets_t::value_type &packet, packets )
|
||||
packet.second->SetStreams(inStream, outStream);
|
||||
}
|
Loading…
Reference in a new issue