forked from mirror/openmw-tes3mp
[Server] Add doForNearest function
This commit is contained in:
parent
b760015071
commit
033472d939
3 changed files with 27 additions and 0 deletions
|
@ -170,6 +170,17 @@ void Networking::processPlayerPacket(RakNet::Packet *packet)
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Moved to %s",
|
LOG_APPEND(Log::LOG_INFO, "- Moved to %s",
|
||||||
player->cell.getDescription().c_str());
|
player->cell.getDescription().c_str());
|
||||||
|
|
||||||
|
player->doForNearest([this](Player *pl, Player *other){
|
||||||
|
const RakNet::RakNetGUID &guid = pl->guid;
|
||||||
|
playerController->GetPacket(ID_PLAYER_DYNAMICSTATS)->Send(other, guid);
|
||||||
|
playerController->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(other, guid);
|
||||||
|
playerController->GetPacket(ID_PLAYER_SKILL)->Send(other, guid);
|
||||||
|
//playerController->GetPacket(ID_PLAYER_POS)->Send(pl, guid);
|
||||||
|
playerController->GetPacket(ID_PLAYER_EQUIPMENT)->Send(other, guid);
|
||||||
|
playerController->GetPacket(ID_PLAYER_ATTACK)->Send(other, guid);
|
||||||
|
playerController->GetPacket(ID_PLAYER_DRAWSTATE)->Send(other, guid);
|
||||||
|
});
|
||||||
|
|
||||||
myPacket->Send(player, true); //send to other clients
|
myPacket->Send(player, true); //send to other clients
|
||||||
Script::Call<Script::CallbackIdentity("OnPlayerCellChange")>(player->getId());
|
Script::Call<Script::CallbackIdentity("OnPlayerCellChange")>(player->getId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,3 +154,17 @@ void Player::sendToNearest(mwmp::PlayerPacket *myPacket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::doForNearest(std::function<void (Player *pl, Player *other)> func)
|
||||||
|
{
|
||||||
|
for(auto cell : getCells())
|
||||||
|
{
|
||||||
|
for(auto pl : *cell)
|
||||||
|
{
|
||||||
|
if(pl == this)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
func(this, pl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -73,6 +73,8 @@ public:
|
||||||
CellController::TContainer getCells();
|
CellController::TContainer getCells();
|
||||||
void sendToNearest(mwmp::PlayerPacket *myPacket);
|
void sendToNearest(mwmp::PlayerPacket *myPacket);
|
||||||
|
|
||||||
|
void doForNearest(std::function<void (Player *pl, Player *other)> func);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
mwmp::InventoryChanges inventoryChangesBuffer;
|
mwmp::InventoryChanges inventoryChangesBuffer;
|
||||||
mwmp::SpellbookChanges spellbookChangesBuffer;
|
mwmp::SpellbookChanges spellbookChangesBuffer;
|
||||||
|
|
Loading…
Reference in a new issue