Loading...   


void EntityList::MobProcess()
{
#ifdef IDLE_WHEN_EMPTY
	if (numclients < 1)
		return;
#endif
	auto it = mob_list.begin();
	while (it != mob_list.end()) {
		if (!it->second) {
			++it;
			continue;
		}
		if (!it->second->Process()) {
			Mob *mob = it->second;
			uint16 tempid = it->first;
			++it; // we don't erase here because the destructor will
			if (mob->IsNPC()) {
				entity_list.RemoveNPC(mob->CastToNPC()->GetID());
			} else if (mob->IsMerc()) {
				entity_list.RemoveMerc(mob->CastToMerc()->GetID());
#ifdef BOTS
			} else if (mob->IsBot()) {
				entity_list.RemoveBot(mob->CastToBot()->GetID());
#endif
			} else {
#ifdef _WINDOWS
				struct in_addr in;
				in.s_addr = mob->CastToClient()->GetIP();
				std::cout << "Dropping client: Process=false, ip=" << inet_ntoa(in) << ", port=" << mob->CastToClient()->GetPort() << std::endl;
#endif
				zone->StartShutdownTimer();
				Group *g = GetGroupByMob(mob);
				if (g) {
					LogFile->write(EQEMuLog::Error, "About to delete a client still in a group.");
					g->DelMember(mob);
				}
				Raid *r = entity_list.GetRaidByClient(mob->CastToClient());
				if (r) {
					LogFile->write(EQEMuLog::Error, "About to delete a client still in a raid.");
					r->MemberZoned(mob->CastToClient());
				}
				entity_list.RemoveClient(mob->GetID());
			}
			entity_list.RemoveMob(tempid);
		} else {
			++it;
		}
	}
}

Raw Paste Data