forked from mirror/openmw-tes3mp
[Server] Improve Player::sendToLoaded()
This commit is contained in:
parent
f35d35741e
commit
dd352f0a91
11 changed files with 24 additions and 21 deletions
|
@ -295,22 +295,25 @@ void Player::forEachLoaded(std::function<void(Player *pl, Player *other)> func)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::sendToLoaded(mwmp::PlayerPacket *myPacket)
|
void Player::sendToLoaded(mwmp::PlayerPacket &myPacket)
|
||||||
{
|
{
|
||||||
std::list <Player*> plList;
|
static std::set<Player*> plList;
|
||||||
|
static CellController::TContainer *addrCells = nullptr;
|
||||||
|
|
||||||
|
if (addrCells != &cells)
|
||||||
|
{
|
||||||
|
addrCells = &cells;
|
||||||
|
plList.clear();
|
||||||
for (auto &cell : cells)
|
for (auto &cell : cells)
|
||||||
for (auto &pl : *cell)
|
for (auto &pl : *cell)
|
||||||
plList.push_back(pl);
|
plList.insert(pl);
|
||||||
|
}
|
||||||
|
|
||||||
plList.sort();
|
for (auto &pl : plList)
|
||||||
plList.unique();
|
|
||||||
|
|
||||||
for (auto pl : plList)
|
|
||||||
{
|
{
|
||||||
if (pl == this) continue;
|
if (pl == this) continue;
|
||||||
myPacket->setPlayer(this);
|
myPacket.setPlayer(this);
|
||||||
myPacket->Send(pl->guid);
|
myPacket.Send(pl->guid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
virtual ~Player();
|
virtual ~Player();
|
||||||
|
|
||||||
CellController::TContainer *getCells();
|
CellController::TContainer *getCells();
|
||||||
void sendToLoaded(mwmp::PlayerPacket *myPacket);
|
void sendToLoaded(mwmp::PlayerPacket &myPacket);
|
||||||
|
|
||||||
void forEachLoaded(std::function<void(Player *pl, Player *other)> func);
|
void forEachLoaded(std::function<void(Player *pl, Player *other)> func);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF(strPacketID.c_str());
|
DEBUG_PRINTF(strPacketID.c_str());
|
||||||
|
|
||||||
player->sendToLoaded(&packet);
|
player->sendToLoaded(packet);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF(strPacketID.c_str());
|
DEBUG_PRINTF(strPacketID.c_str());
|
||||||
|
|
||||||
player->sendToLoaded(&packet);
|
player->sendToLoaded(packet);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace mwmp
|
||||||
|
|
||||||
if (!player->creatureStats.mDead)
|
if (!player->creatureStats.mDead)
|
||||||
{
|
{
|
||||||
player->sendToLoaded(&packet);
|
player->sendToLoaded(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
//myPacket->Send(player, true);
|
//myPacket->Send(player, true);
|
||||||
|
|
||||||
player->sendToLoaded(&packet);
|
player->sendToLoaded(packet);
|
||||||
|
|
||||||
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_ATTRIBUTE>(player);
|
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_ATTRIBUTE>(player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF(strPacketID.c_str());
|
DEBUG_PRINTF(strPacketID.c_str());
|
||||||
|
|
||||||
player->sendToLoaded(&packet);
|
player->sendToLoaded(packet);
|
||||||
|
|
||||||
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_EQUIPMENT>(player);
|
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_EQUIPMENT>(player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace mwmp
|
||||||
//DEBUG_PRINTF(strPacketID);
|
//DEBUG_PRINTF(strPacketID);
|
||||||
if (!player->creatureStats.mDead)
|
if (!player->creatureStats.mDead)
|
||||||
{
|
{
|
||||||
player->sendToLoaded(&packet);
|
player->sendToLoaded(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace mwmp
|
||||||
if (!player->creatureStats.mDead)
|
if (!player->creatureStats.mDead)
|
||||||
{
|
{
|
||||||
//myPacket->Send(player, true);
|
//myPacket->Send(player, true);
|
||||||
player->sendToLoaded(&packet);
|
player->sendToLoaded(packet);
|
||||||
|
|
||||||
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_SKILL>(player);
|
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_SKILL>(player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF(strPacketID.c_str());
|
DEBUG_PRINTF(strPacketID.c_str());
|
||||||
|
|
||||||
player->sendToLoaded(&packet);
|
player->sendToLoaded(packet);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
DEBUG_PRINTF(strPacketID.c_str());
|
DEBUG_PRINTF(strPacketID.c_str());
|
||||||
|
|
||||||
player->sendToLoaded(&packet);
|
player->sendToLoaded(packet);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue