void DigitalBrain::SetLead (int flag) { if (flag == TRUE){ isWing = FALSE; SetLeader (self); } else { isWing = self->GetCampaignObject()->GetComponentIndex(self); SetLeader (self->GetCampaignObject()->GetComponentLead()); } }
void Raid::SetRaidLeader(const char *wasLead, const char *name) { std::string query = StringFormat("UPDATE raid_members SET israidleader = 0 WHERE name = '%s'", wasLead); auto results = database.QueryDatabase(query); if (!results.Success()) LogFile->write(EQEMuLog::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str()); query = StringFormat("UPDATE raid_members SET israidleader = 1 WHERE name = '%s'", name); results = database.QueryDatabase(query); if (!results.Success()) LogFile->write(EQEMuLog::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str()); strn0cpy(leadername, name, 64); Client *c = entity_list.GetClientByName(name); if(c) SetLeader(c); LearnMembers(); VerifyRaid(); SendMakeLeaderPacket(name); ServerPacket *pack = new ServerPacket(ServerOP_RaidLeader, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, name, 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); }
void Guild::DelMember(ObjectGuid guid, bool isDisbanding) { uint32 lowguid = guid.GetCounter(); // guild master can be deleted when loading guild and guid doesn't exist in characters table // or when he is removed from guild by gm command if (m_LeaderGuid == guid && !isDisbanding) { MemberSlot* oldLeader = NULL; MemberSlot* best = NULL; ObjectGuid newLeaderGUID; for (Guild::MemberList::iterator i = members.begin(); i != members.end(); ++i) { if (i->first == lowguid) { oldLeader = &(i->second); continue; } if (!best || best->RankId > i->second.RankId) { best = &(i->second); newLeaderGUID = ObjectGuid(HIGHGUID_PLAYER, i->first); } } if (!best) { Disband(); return; } SetLeader(newLeaderGUID); // If player not online data in data field will be loaded from guild tabs no need to update it !! if (Player *newLeader = sObjectMgr.GetPlayer(newLeaderGUID)) newLeader->SetRank(GR_GUILDMASTER); // when leader non-exist (at guild load with deleted leader only) not send broadcasts if (oldLeader) { BroadcastEvent(GE_LEADER_CHANGED, oldLeader->Name.c_str(), best->Name.c_str()); BroadcastEvent(GE_LEFT, guid, oldLeader->Name.c_str()); } } members.erase(lowguid); Player *player = sObjectMgr.GetPlayer(guid); // If player not online data in data field will be loaded from guild tabs no need to update it !! if (player) { player->SetInGuild(0); player->SetRank(0); } CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", lowguid); if (!isDisbanding) UpdateAccountsNumber(); }
// Make sure our leader hasn't gone away without telling us. void DigitalBrain::CheckLead(void) { SimBaseClass *pobj; SimBaseClass* newLead = NULL; BOOL done = FALSE; int i = 0; if ( flightLead && flightLead->VuState() == VU_MEM_ACTIVE && !flightLead->IsDead() ){ return; } { VuListIterator cit(self->GetCampaignObject()->GetComponents()); pobj = (SimBaseClass*)cit.GetFirst(); while(!done){ if( pobj && pobj->VuState() == VU_MEM_ACTIVE && !pobj->IsDead() ){ done = TRUE; newLead = pobj; } else if(i > 3){ done = TRUE; newLead = self; } ++i; pobj = (SimBaseClass*)cit.GetNext(); } } SetLeader (newLead); }
void Group::ChangeLeader(Mob* newleader) { // this changes the current group leader, notifies other members, and updates leadship AA // if the new leader is invalid, do nothing if (!newleader) return; Mob* oldleader = GetLeader(); EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct)); GroupJoin_Struct* gu = (GroupJoin_Struct*) outapp->pBuffer; gu->action = groupActMakeLeader; strcpy(gu->membername, newleader->GetName()); strcpy(gu->yourname, oldleader->GetName()); SetLeader(newleader); database.SetGroupLeaderName(GetID(), newleader->GetName()); for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++) { if (members[i] && members[i]->IsClient()) { members[i]->CastToClient()->QueuePacket(outapp); } } safe_delete(outapp); }
bool Group::AddMember(Player* pPlayer) { if(!IsFull()) { SubGroup* subgroup = FindFreeSubGroup(); if(subgroup == NULL) { // weird shit.. sLog.outDebug("GROUP: Tried to add member %s but FindFreeSubGroup returned NULL!", pPlayer->GetName()); return false; } subgroup->AddPlayer(pPlayer); pPlayer->SetGroup(this); if(m_MemberCount == 1) { // We're the only member? Set us to the leader. SetLeader(pPlayer); } UpdateAllOutOfRangePlayersFor(pPlayer); Update(); // Send group update return true; } else { return false; } }
void CBotSquad::ChangeLeader ( void ) { if ( m_theSquad.IsEmpty() ) { SetLeader(NULL); } else { m_pLeader = m_theSquad.Pop(); if ( m_theSquad.IsEmpty() ) SetLeader(NULL); else { Init(); // new squad init } } }
void PlayerbotMgr::OnBotLogin(Player * const bot) { PlayerbotAI* ai = bot->GetPlayerbotAI(); if (!ai) { PlayerbotAI* ai = new PlayerbotAI(this, bot); if (ai) bot->SetPlayerbotAI(ai); } ai = bot->GetPlayerbotAI(); SetLeader(NULL); }
//================================================================================ // Constructor //================================================================================ CSquad::CSquad() { // Predeterminado SetName( "WithoutName" ); SetMemberLimit( 0 ); SetTacticalMode( 99 ); SetStrategie( ENDURE_UNTIL_DEATH ); SetSkill( 99 ); SetFollowLeader( false ); SetLeader( NULL ); m_nController = NULL; // Nos agregamos a la lista TheSquads->AddSquad( this ); }
/* ================== CheckTeamVote ================== */ void CheckTeamVote( int team ) { int cs_offset; if( team == ClientBase::TEAM_RED ) cs_offset = 0; else if( team == ClientBase::TEAM_BLUE ) cs_offset = 1; else return; if( !theLevel.teamVoteTime_[cs_offset] ) return; if( theLevel.time_ - theLevel.teamVoteTime_[cs_offset] >= VOTE_TIME ) { SV_GameSendServerCommand( -1, "print \"Team vote failed.\n\"" ); } else { if( theLevel.teamVoteYes_[cs_offset] > theLevel.numteamVotingClients_[cs_offset]/2 ) { // execute the command, then remove the vote SV_GameSendServerCommand( -1, "print \"Team vote passed.\n\"" ); // if( !Q_strncmp( "leader", theLevel.teamVoteString_[cs_offset], 6) ) { //set the team leader SetLeader(team, atoi(theLevel.teamVoteString_[cs_offset] + 7)); } else Cbuf_ExecuteText( EXEC_APPEND, va("%s\n", theLevel.teamVoteString_[cs_offset] ) ); } else if( theLevel.teamVoteNo_[cs_offset] >= theLevel.numteamVotingClients_[cs_offset]/2 ) { // same behavior as a timeout SV_GameSendServerCommand( -1, "print \"Team vote failed.\n\"" ); } else { // still waiting for a majority return; } } theLevel.teamVoteTime_[cs_offset] = 0; SV_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, "" ); }
CParty::CParty(CBattleEntity* PEntity) { DSP_DEBUG_BREAK_IF(PEntity == NULL); DSP_DEBUG_BREAK_IF(PEntity->PParty != NULL); m_PartyID = PEntity->id; m_PartyType = PEntity->objtype == TYPE_PC ? PARTY_PCS : PARTY_MOBS; m_PLeader = NULL; m_PAlliance = NULL; m_PSyncTarget = NULL; m_PQuaterMaster = NULL; AddMember(PEntity); SetLeader(PEntity); }
void CParty::AssignPartyRole(int8* MemberName, uint8 role) { DSP_DEBUG_BREAK_IF (m_PartyType != PARTY_PCS); switch(role) { case 0: SetLeader(MemberName); break; case 4: SetQuarterMaster(MemberName); break; case 5: SetQuarterMaster(NULL); break; case 6: SetSyncTarget(MemberName, 238); break; case 7: SetSyncTarget(NULL, 553); break; } uint8 data[4]; WBUFL(data, 0) = m_PartyID; message::send(MSG_PT_RELOAD, data, sizeof data, NULL); return; }
void CTeam::AddPlayer(int playerNum) { // note: does it matter if this team was already dead? // (besides needing to restore its original unit-limit) if (isDead) { teamHandler->UpdateTeamUnitLimitsPreSpawn(teamNum); } if (!HasLeader()) { SetLeader(playerNum); } playerHandler->Player(playerNum)->JoinTeam(teamNum); playerHandler->Player(playerNum)->SetControlledTeams(); isDead = false; }
void Group::MemberZoned(Mob* removemob) { uint32 i; if (removemob == nullptr) return; if(removemob == GetLeader()) SetLeader(nullptr); for (i = 0; i < MAX_GROUP_MEMBERS; i++) { if (members[i] == removemob) { members[i] = nullptr; //should NOT clear the name, it is used for world communication. break; } } }
void CParty::AssignPartyRole(int8* MemberName, uint8 role) { DSP_DEBUG_BREAK_IF(m_PartyType != PARTY_PCS); switch (role) { case 0: SetLeader((const char*)MemberName); break; case 4: SetQuarterMaster((const char*)MemberName); break; case 5: SetQuarterMaster(nullptr); break; case 6: SetSyncTarget(MemberName, 238); break; case 7: SetSyncTarget(nullptr, 553); break; } uint8 data[4] {}; ref<uint32>(data, 0) = m_PartyID; message::send(MSG_PT_RELOAD, data, sizeof data, nullptr); return; }
CParty::CParty(CBattleEntity* PEntity, Sql_t* sql) { DSP_DEBUG_BREAK_IF(PEntity == NULL); DSP_DEBUG_BREAK_IF(PEntity->PParty != NULL); m_PartyID = PEntity->id; m_PartyType = PEntity->objtype == TYPE_PC ? PARTY_PCS : PARTY_MOBS; m_PartyNumber = 0; m_PLeader = NULL; m_PAlliance = NULL; m_PSyncTarget = NULL; m_PQuaterMaster = NULL; AddMember(PEntity, sql); SetLeader((int8*)PEntity->name.c_str()); }
CParty::CParty(CBattleEntity* PEntity) { DSP_DEBUG_BREAK_IF(PEntity == nullptr); DSP_DEBUG_BREAK_IF(PEntity->PParty != nullptr); m_PartyID = PEntity->id; m_PartyType = PEntity->objtype == TYPE_PC ? PARTY_PCS : PARTY_MOBS; m_PartyNumber = 0; m_PLeader = nullptr; m_PAlliance = nullptr; m_PSyncTarget = nullptr; m_PQuaterMaster = nullptr; m_EffectsChanged = false; AddMember(PEntity); SetLeader((char*)PEntity->name.c_str()); }
//creating a new group Group::Group(Mob* leader) : GroupIDConsumer() { memset(members, 0, sizeof(members)); members[0] = leader; leader->SetGrouped(true); SetLeader(leader); uint32 i; for(i=0;i<MAX_GROUP_MEMBERS;i++) { memset(membername[i],0,64); MemberRoles[i] = 0; } strcpy(membername[0],leader->GetName()); if(leader->IsClient()) strcpy(leader->CastToClient()->GetPP().groupMembers[0],leader->GetName()); }
void CParty::RemovePartyLeader(CBattleEntity* PEntity) { DSP_DEBUG_BREAK_IF(members.empty()); int ret = Sql_Query(SqlHandle, "SELECT charname FROM accounts_sessions JOIN chars ON accounts_sessions.charid = chars.charid \ JOIN accounts_parties ON accounts_parties.charid = chars.charid WHERE partyid = %u AND NOT partyflag & %d \ ORDER BY timestamp ASC LIMIT 1;", m_PartyID, PARTY_LEADER); if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0 && Sql_NextRow(SqlHandle) == SQL_SUCCESS) { SetLeader(Sql_GetData(SqlHandle, 0)); } if (m_PLeader == PEntity) { DisbandParty(); } else { RemoveMember(PEntity); } }
void Raid::SetRaidLeader(const char *wasLead, const char *name) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; if (!database.RunQuery(query,MakeAnyLenString(&query, "UPDATE raid_members SET israidleader=0 WHERE name='%s'", wasLead),errbuf,&result)){ printf("Set Raid Leader error: %s\n", errbuf); } else mysql_free_result(result); safe_delete_array(query); query = 0; if (!database.RunQuery(query,MakeAnyLenString(&query, "UPDATE raid_members SET israidleader=1 WHERE name='%s'", name),errbuf,&result)){ printf("Set Raid Leader error: %s\n", errbuf); } else mysql_free_result(result); safe_delete_array(query); strn0cpy(leadername, name, 64); Client *c = entity_list.GetClientByName(name); if(c) SetLeader(c); LearnMembers(); VerifyRaid(); SendMakeLeaderPacket(name); ServerPacket *pack = new ServerPacket(ServerOP_RaidLeader, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, name, 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); }
BOOL KNpcTeam::AddMember(KNpc *pNewMember, int nIndex) { BOOL bRetCode = FALSE; KGLOG_PROCESS_ERROR(pNewMember); KGLOG_PROCESS_ERROR(nIndex >= 0); KGLOG_PROCESS_ERROR(m_pMember[nIndex] == NULL); m_pMember[nIndex] = pNewMember; m_nMemberCount++; if (m_nMemberCount == 1) { bRetCode = SetLeader(nIndex); KGLOG_PROCESS_ERROR(bRetCode); } bRetCode = TRUE; Exit0: return bRetCode; }
//creating a new group Group::Group(Mob* leader) : GroupIDConsumer() { memset(members, 0, sizeof(members)); members[0] = leader; leader->SetGrouped(true); SetLeader(leader); SetOldLeaderName(leader->GetName()); Log.Out(Logs::Detail, Logs::Group, "Group:Group() Setting OldLeader to: %s and Leader to: %s", GetOldLeaderName(), leader->GetName()); uint32 i; for(i=0;i<MAX_GROUP_MEMBERS;i++) { memset(membername[i],0,64); MemberRoles[i] = 0; } strcpy(membername[0],leader->GetName()); if(leader->IsClient()) strcpy(leader->CastToClient()->GetPP().groupMembers[0],leader->GetName()); }
bool Guild::CheckGuildStructure() { // Repair the structure of guild // If the guildmaster doesn't exist or isn't the member of guild // attempt to promote another member int32 GM_rights = GetRank(m_LeaderGuid); if (GM_rights == -1) { if (DelMember(m_LeaderGuid)) return false; // guild will disbanded and deleted in caller } else if (GM_rights != GR_GUILDMASTER) SetLeader(m_LeaderGuid); // Allow only 1 guildmaster, set other to officer for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) if (itr->second.RankId == GR_GUILDMASTER && m_LeaderGuid != itr->second.guid) itr->second.ChangeRank(GR_OFFICER); return true; }
void DigitalBrain::Sleep(void) { SetLeader (NULL); ClearTarget(); // NOTE: This is only legal if the platorms target list is already cleared. // Currently, SimVehicle::Sleep call SimMover::Sleep which clears the list, // then it calls theBrain::Sleep. As long as this doesn't change this will // not cause a leak. if (groundTargetPtr){ #ifdef DEBUG if (groundTargetPtr->prev || groundTargetPtr->next){ MonoPrint ("Ground target still in list at sleep\n"); } #endif groundTargetPtr->prev = NULL; groundTargetPtr->next = NULL; } SetGroundTarget( NULL ); }
/* ================== CheckTeamVote ================== */ void CheckTeamVote( int team ) { int cs_offset; if ( team == TEAM_RED ) cs_offset = 0; else if ( team == TEAM_BLUE ) cs_offset = 1; else return; if ( !level.teamVoteTime[cs_offset] ) { return; } if ( level.time - level.teamVoteTime[cs_offset] >= VOTE_TIME ) { trap_SendServerCommand( -1, "print \"Team vote failed.\n\"" ); } else { if ( level.teamVoteYes[cs_offset] > level.numteamVotingClients[cs_offset]/2 ) { // execute the command, then remove the vote trap_SendServerCommand( -1, "print \"Team vote passed.\n\"" ); // if ( !Q_strncmp( "leader", level.teamVoteString[cs_offset], 6) ) { //set the team leader SetLeader(team, atoi(level.teamVoteString[cs_offset] + 7)); } else { trap_SendConsoleCommand( EXEC_APPEND, va("%s\n", level.teamVoteString[cs_offset] ) ); } } else if ( level.teamVoteNo[cs_offset] >= level.numteamVotingClients[cs_offset]/2 ) { // same behavior as a timeout trap_SendServerCommand( -1, "print \"Team vote failed.\n\"" ); } else { // still waiting for a majority return; } } level.teamVoteTime[cs_offset] = 0; trap_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, "" ); }
void Group::RemovePlayer(Player* pPlayer) { WorldPacket data; SubGroup *sg = GetSubGroup(pPlayer->GetSubGroup()); ASSERT(sg); // something wrong here if that isn't right sg->RemovePlayer(pPlayer); pPlayer->SetGroup(NULL); if(pPlayer->GetSession() != NULL) { SendNullUpdate(pPlayer); //pPlayer->RemoveAllAreaAuras(); data.SetOpcode(SMSG_GROUP_DESTROYED); pPlayer->GetSession()->SendPacket(&data); data.Initialize(SMSG_PARTY_COMMAND_RESULT); data << uint32(2) << uint8(0) << uint32(0); // you leave the group pPlayer->GetSession()->SendPacket(&data); } if(m_MemberCount < 2) { Disband(); return; } Player *newPlayer = FindFirstPlayer(); if(m_Looter == pPlayer) m_Looter = newPlayer; if(m_Leader == pPlayer) SetLeader(newPlayer); else Update(); }
void Group::ChangeLeader(Mob* newleader) { // this changes the current group leader, notifies other members, and updates leadship AA // if the new leader is invalid, do nothing if (!newleader) return; EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct)); GroupJoin_Struct* gu = (GroupJoin_Struct*) outapp->pBuffer; gu->action = groupActMakeLeader; strcpy(gu->membername, newleader->GetName()); strcpy(gu->yourname, GetOldLeaderName()); SetLeader(newleader); database.SetGroupLeaderName(GetID(), newleader->GetName()); for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++) { if (members[i] && members[i]->IsClient()) { members[i]->CastToClient()->QueuePacket(outapp); Log.Out(Logs::Detail, Logs::Group, "ChangeLeader(): Local leader update packet sent to: %s .", members[i]->GetName()); } } safe_delete(outapp); Log.Out(Logs::Detail, Logs::Group, "ChangeLeader(): Old Leader is: %s New leader is: %s", GetOldLeaderName(), newleader->GetName()); ServerPacket* pack = new ServerPacket(ServerOP_ChangeGroupLeader, sizeof(ServerGroupLeader_Struct)); ServerGroupLeader_Struct* fgu = (ServerGroupLeader_Struct*)pack->pBuffer; fgu->zoneid = zone->GetZoneID(); fgu->gid = GetID(); strcpy(fgu->leader_name, newleader->GetName()); strcpy(fgu->oldleader_name, GetOldLeaderName()); worldserver.SendPacket(pack); //safe_delete(pack); SetOldLeaderName(newleader->GetName()); }
void CParty::RemovePartyLeader(CBattleEntity* PEntity) { DSP_DEBUG_BREAK_IF(members.empty()); DSP_DEBUG_BREAK_IF(m_PLeader != PEntity); DSP_DEBUG_BREAK_IF(PEntity->objtype != TYPE_PC); if (members.size() == 1) { DisbandParty(); } else { for (uint32 i = 0; i < members.size(); ++i) { if (PEntity != members.at(i)) { SetLeader(members.at(i)); break; } } RemoveMember(PEntity); } }
void CParty::AssignPartyRole(int8* MemberName, uint8 role) { DSP_DEBUG_BREAK_IF (m_PartyType != PARTY_PCS); for (uint32 i = 0; i < members.size(); ++i) { CCharEntity* PChar = (CCharEntity*)members.at(i); if (strcmp(MemberName, PChar->GetName()) == 0) { switch(role) { case 0: SetLeader(PChar); break; case 4: SetQuaterMaster(PChar); break; case 5: SetQuaterMaster(NULL); break; case 6: SetSyncTarget(PChar); break; } ReloadParty(); return; } } ShowError(CL_RED"The character with name <%s> isn't found in party\n" CL_RESET, MemberName); }
void Raid::VerifyRaid() { for(int x = 0; x < MAX_RAID_MEMBERS; x++) { if(strlen(members[x].membername) == 0){ members[x].member = nullptr; } else{ Client *c = entity_list.GetClientByName(members[x].membername); if(c){ members[x].member = c; } else{ members[x].member = nullptr; } } if(members[x].IsRaidLeader){ if(strlen(members[x].membername) > 0){ SetLeader(members[x].member); strn0cpy(leadername, members[x].membername, 64); } } } }