本文整理汇总了C++中PlayerList::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerList::reserve方法的具体用法?C++ PlayerList::reserve怎么用?C++ PlayerList::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerList
的用法示例。
在下文中一共展示了PlayerList::reserve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeLeader
void GroupObject::changeLeader(Player* player)
{
mMasterLooter = player->getCharId();
// we create a new list containing the new hierarchy
PlayerList tempList;
tempList.reserve(20);
tempList.push_back(player); // new leader
tempList.push_back(getLeader()); // old leader
// iterate trough old list
PlayerList::iterator listIt = mMembers.begin() + 1; // starting at position 1 ( 0 is the old leader)
while(listIt != mMembers.end())
{
// if not the new leader (its in position of new list 1 already)
if((*listIt) != player)
{
tempList.push_back((*listIt)); // add to the new list
}
++listIt;
}
// do i need this ? =0
mMembers.empty();
// assign the new list
mMembers = tempList;
// recalculate member indexes
resetIndexes();
// send the delta to everyone
broadcastDeltaResetAll();
// send the sys message to everyone
gChatMessageLib->sendGroupSystemMessage(getLeader()->getName(), BString("new_leader"), NULL, this, true);
}