int CInstanceHandler::registerBcnm(uint16 id, CCharEntity* PChar) { if(!hasFreeInstance()) { return -1; } CInstance* PInstance = instanceutils::loadInstance(this,id); if(PInstance==NULL) { return -1; } for(int i=0; i<m_MaxInstances; i++) { if(m_Instances[i]==NULL) { PInstance->setInstanceNumber(i+1); break; } } switch(PInstance->getMaxParticipants()) { case 1: if(PInstance->addPlayerToBcnm(PChar)) { ShowDebug("InstanceHandler ::1 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->GetName(),id,PInstance->getInstanceNumber()); } break; case 3: if(PChar->PParty == NULL) { //just add the initiator if(PInstance->addPlayerToBcnm(PChar)) { ShowDebug("InstanceHandler ::3 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->GetName(),id,PInstance->getInstanceNumber()); } } else { int numRegistered = 0; for(int j=0; j<PChar->PParty->members.size(); j++) { if(PInstance->addPlayerToBcnm((CCharEntity*)PChar->PParty->members.at(j))) { ShowDebug("InstanceHandler ::3 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->PParty->members.at(j)->GetName(),id,PInstance->getInstanceNumber()); numRegistered++; } if(numRegistered>=3) { break; } } } break; case 6: if(PChar->PParty == NULL) { //just add the initiator if(PInstance->addPlayerToBcnm(PChar)) { ShowDebug("InstanceHandler ::6 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->GetName(),id,PInstance->getInstanceNumber()); } } else { for(int j=0; j<PChar->PParty->members.size(); j++) { if(PInstance->addPlayerToBcnm((CCharEntity*)PChar->PParty->members.at(j))) { ShowDebug("InstanceHandler ::6 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->PParty->members.at(j)->GetName(),id,PInstance->getInstanceNumber()); } } } break; case 12: ShowDebug("BCNMs for 12 people are not implemented yet.\n"); break; case 18: if(PChar->PParty == NULL) { //1 player entering 18 man bcnm if(PInstance->addPlayerToBcnm(PChar)) { ShowDebug("InstanceHandler ::18 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->GetName(),id,PInstance->getInstanceNumber()); } } else { //alliance entering 18 man bcnm if(PChar->PParty->m_PAlliance != NULL) { for(uint8 a = 0; a < PChar->PParty->m_PAlliance->partyList.size(); ++a) { for(uint8 j=0; j<PChar->PParty->m_PAlliance->partyList.at(a)->members.size(); j++) { if(PInstance->addPlayerToBcnm((CCharEntity*)PChar->PParty->m_PAlliance->partyList.at(a)->members.at(j))) { ShowDebug("InstanceHandler ::18 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->PParty->m_PAlliance->partyList.at(a)->members.at(j)->GetName(),id,PInstance->getInstanceNumber()); } } } } else { //single party entering 18 man bcnm for(uint8 j=0; j<PChar->PParty->members.size(); j++) { if(PInstance->addPlayerToBcnm((CCharEntity*)PChar->PParty->members.at(j))) { ShowDebug("InstanceHandler ::18 Added %s to the valid players list for BCNM %i Instance %i \n", PChar->PParty->members.at(j)->GetName(),id,PInstance->getInstanceNumber()); } } } } break; default: ShowDebug("Unknown max participants value %i \n",PInstance->getMaxParticipants()); } if(!PInstance->isReserved()) { //no player met the criteria for entering, so revoke the previous permission. ShowDebug("No player has met the requirements for entering the BCNM.\n"); delete PInstance; return -1; } m_Instances[PInstance->getInstanceNumber()-1] = PInstance; PInstance->init(); luautils::OnBcnmRegister(PChar,PInstance); return PInstance->getInstanceNumber(); }