Refactor player groups

Group structures are used now. Adds more checks in some places but simplifies things overall.
We can expand this system to entities as well now pretty trivially.
This commit is contained in:
gsemaj
2022-04-23 15:58:08 -04:00
parent 71e78afa0b
commit 3dc7124f58
5 changed files with 14 additions and 15 deletions

View File

@@ -259,16 +259,10 @@ void Combat::npcAttackPc(Mob *mob, time_t currTime) {
* single RNG roll per mission task, and every group member shares that same
* set of rolls.
*/
void Combat::genQItemRolls(Player *leader, std::map<int, int>& rolls) {
auto players = (*leader->group)[EntityKind::PLAYER];
void Combat::genQItemRolls(std::vector<Player*> players, std::map<int, int>& rolls) {
for (int i = 0; i < players.size(); i++) {
CNSocket *otherSock = players[i].sock;
if (otherSock == nullptr)
continue;
Player *member = PlayerManager::getPlayer(otherSock);
Player* member = players[i];
for (int j = 0; j < ACTIVE_MISSION_COUNT; j++)
if (member->tasks[j] != 0)
rolls[member->tasks[j]] = Rand::rand();