[Server] Improve Player::sendToLoaded()

sol2-server-rewrite
Koncord 7 years ago
parent f35d35741e
commit dd352f0a91

@ -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;
for (auto &cell : cells)
for (auto &pl : *cell)
plList.push_back(pl);
static std::set<Player*> plList;
static CellController::TContainer *addrCells = nullptr;
plList.sort();
plList.unique();
if (addrCells != &cells)
{
addrCells = &cells;
plList.clear();
for (auto &cell : cells)
for (auto &pl : *cell)
plList.insert(pl);
}
for (auto pl : plList)
for (auto &pl : plList)
{
if (pl == this) continue;
myPacket->setPlayer(this);
myPacket->Send(pl->guid);
myPacket.setPlayer(this);
myPacket.Send(pl->guid);
}
}

@ -66,7 +66,7 @@ public:
virtual ~Player();
CellController::TContainer *getCells();
void sendToLoaded(mwmp::PlayerPacket *myPacket);
void sendToLoaded(mwmp::PlayerPacket &myPacket);
void forEachLoaded(std::function<void(Player *pl, Player *other)> func);

@ -21,7 +21,7 @@ namespace mwmp
{
DEBUG_PRINTF(strPacketID.c_str());
player->sendToLoaded(&packet);
player->sendToLoaded(packet);
}
};
}

@ -17,7 +17,7 @@ namespace mwmp
{
DEBUG_PRINTF(strPacketID.c_str());
player->sendToLoaded(&packet);
player->sendToLoaded(packet);
}
};
}

@ -25,7 +25,7 @@ namespace mwmp
if (!player->creatureStats.mDead)
{
player->sendToLoaded(&packet);
player->sendToLoaded(packet);
}
}
};

@ -23,7 +23,7 @@ namespace mwmp
{
//myPacket->Send(player, true);
player->sendToLoaded(&packet);
player->sendToLoaded(packet);
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_ATTRIBUTE>(player);
}

@ -21,7 +21,7 @@ namespace mwmp
{
DEBUG_PRINTF(strPacketID.c_str());
player->sendToLoaded(&packet);
player->sendToLoaded(packet);
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_EQUIPMENT>(player);
}

@ -22,7 +22,7 @@ namespace mwmp
//DEBUG_PRINTF(strPacketID);
if (!player->creatureStats.mDead)
{
player->sendToLoaded(&packet);
player->sendToLoaded(packet);
}
}
};

@ -22,7 +22,7 @@ namespace mwmp
if (!player->creatureStats.mDead)
{
//myPacket->Send(player, true);
player->sendToLoaded(&packet);
player->sendToLoaded(packet);
Networking::get().getState().getEventCtrl().Call<CoreEvent::ON_PLAYER_SKILL>(player);
}

@ -17,7 +17,7 @@ namespace mwmp
{
DEBUG_PRINTF(strPacketID.c_str());
player->sendToLoaded(&packet);
player->sendToLoaded(packet);
}
};
}

@ -21,7 +21,7 @@ namespace mwmp
{
DEBUG_PRINTF(strPacketID.c_str());
player->sendToLoaded(&packet);
player->sendToLoaded(packet);
}
};
}

Loading…
Cancel
Save