本文整理汇总了C++中STRINGLIST::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ STRINGLIST::push_back方法的具体用法?C++ STRINGLIST::push_back怎么用?C++ STRINGLIST::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STRINGLIST
的用法示例。
在下文中一共展示了STRINGLIST::push_back方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::vector<std::string> InfoManager::GetLoadingAnnouncments() {
STRINGLIST l = g_ClusterManager.GetList(LISTPREFIX_LOADING_ANNOUNCMENTS);
STRINGLIST s;
if(l.size() == 0) {
s.push_back(StringUtil::Format(ReplaceBrandingPatterns("Welcome to ${GameName} - ${Edition}. You can set your own <b>Loading Announcements</b> by creating and adding multiple elements to the list <b>'%s'</b> in the Redis database."), LISTPREFIX_LOADING_ANNOUNCMENTS.c_str()));
}
else {
for(auto it = l.begin(); it != l.end(); ++it) {
s.push_back(ReplaceBrandingPatterns(*it));
}
}
return s;
}
示例2: GetCategory
void IGFManager :: GetCategory(int id, MULTISTRING &output)
{
IGFCategory *category = GetPagedCategoryPtr(id);
if(category == NULL)
return;
STRINGLIST header;
header.push_back(ConvertInteger(id));
header.push_back(category->mTitle);
output.push_back(header);
EnumCategoryList(id, output);
EnumThreadList(id, output);
}
示例3: PlaySound
void AINutPlayer::PlaySound(const char *name) {
STRINGLIST sub;
Util::Split(name, "|", sub);
while (sub.size() < 2) {
sub.push_back("");
}
attachedCreature->SendPlaySound(sub[0].c_str(), sub[1].c_str());
}
示例4: EnumCategoryList
void IGFManager :: EnumCategoryList(int parentID, MULTISTRING &output)
{
STRINGLIST entry;
CATEGORYPAGE::iterator it;
IGFCategoryPage::CATEGORYENTRY::iterator eit;
for(it = mCategoryPages.begin(); it != mCategoryPages.end(); ++it)
{
for(eit = it->second.mEntries.begin(); eit != it->second.mEntries.end(); ++eit)
{
if(eit->second.mParentCategory == parentID)
{
entry.push_back(ConvertInteger(TYPE_CATEGORY));
entry.push_back(ConvertInteger(eit->second.mID));
entry.push_back(ConvertInteger(eit->second.mLocked));
entry.push_back(ConvertInteger(0)); //Stickied. Categories don't have this.
entry.push_back(eit->second.mTitle);
entry.push_back(ConvertInteger(eit->second.mThreadList.size()));
entry.push_back(ConvertInteger(GetTimeOffset(eit->second.mLastUpdateTime)));
output.push_back(entry);
entry.clear();
}
}
}
}
示例5: TokenizeByWhitespace
// Tokenize a string using whitespace as separators, but including string quotations.
void TokenizeByWhitespace(const std::string &input, STRINGLIST &output)
{
std::string str = input;
output.clear();
size_t len = str.size();
int first = -1;
int last = -1;
bool quote = false;
bool terminate = false;
for(size_t i = 0; i < len; i++)
{
switch(input[i])
{
case '"':
terminate = true; //Treat opening quote as a block start
quote = !quote;
break;
case ' ':
case '\t':
case '\n':
case '\r':
if(quote == false)
terminate = true;
break;
default:
if(first == -1)
first = i;
last = i;
}
if(terminate == true)
{
if(first >= 0 && last >= 0)
{
std::string t = str.substr(first, last - first + 1);
output.push_back(str.substr(first, last - first + 1));
first = -1;
last = -1;
}
terminate = false;
}
}
if(first != -1 && first < (int)len)
output.push_back(str.substr(first, len - first + 1));
}
示例6: OpenCategory
void IGFManager :: OpenCategory(int type, int id, MULTISTRING &output)
{
//Expand an object. If it's a category, enumerate a list of subcategories.
if(type == TYPE_CATEGORY)
{
IGFCategory *category = GetPagedCategoryPtr(id);
if(category != NULL)
{
STRINGLIST header;
header.push_back(ConvertInteger(id));
header.push_back(category->mTitle);
output.push_back(header);
int searchID = category->mID;
EnumCategoryList(searchID, output);
EnumThreadList(searchID, output);
}
}
}
示例7: EnumThreadList
void IGFManager :: EnumThreadList(int parentID, MULTISTRING &output)
{
IGFCategory* category = GetPagedCategoryPtr(parentID);
if(category == NULL)
return;
//Pregenerate a list of threads
std::vector<IGFThread*> results;
for(size_t i = 0; i < category->mThreadList.size(); i++)
{
IGFThread* thread = GetPagedThreadPtr(category->mThreadList[i]);
if(thread != NULL)
results.push_back(thread);
}
if(category->mFlags.hasFlag(IGFFlags::FLAG_SORTALPHABETICAL))
std::sort(results.begin(), results.end(), ThreadSortAlphabetical);
STRINGLIST entry;
for(size_t i = 0; i < results.size(); i++)
{
IGFThread* thread = results[i];
entry.push_back(ConvertInteger(TYPE_THREAD));
entry.push_back(ConvertInteger(thread->mID));
entry.push_back(ConvertInteger(thread->mLocked));
entry.push_back(ConvertInteger(thread->mStickied));
entry.push_back(thread->mTitle);
entry.push_back(ConvertInteger(thread->mPostList.size()));
entry.push_back(ConvertInteger(GetTimeOffset(thread->mLastUpdateTime)));
output.push_back(entry);
entry.clear();
}
}
示例8: ExecuteSingleCommand
int QuestActionContainer :: ExecuteSingleCommand(SimulatorThread *caller, ExtendedQuestAction &e)
{
CreatureInstance *cInst = caller->creatureInst;
switch(e.opCode)
{
case COMMAND_NONE: return 0;
case CONDITION_HEROISM:
{
int value = cInst->css.heroism;
if(Compare(value, e.param[0], e.param[1]) == true)
return 0;
caller->SendInfoMessage("You don't meet the heroism requirement.", INFOMSG_ERROR);
return -1;
}
break;
case CONDITION_HAS_ITEM:
{
int itemID = e.param[0];
int itemCount = e.param[1];
int count = caller->pld.charPtr->inventory.GetItemCount(INV_CONTAINER, itemID);
if(count >= itemCount)
return 0;
caller->SendInfoMessage("You don't have the required items in your backpack inventory.", INFOMSG_ERROR);
return -1;
}
break;
case CONDITION_HAS_QUEST:
{
int questID = e.param[0];
if(caller->pld.charPtr->questJournal.activeQuests.HasQuestID(questID) > -1)
return 0;
return -1;
}
break;
case CONDITION_BELOW_LEVEL:
{
int maxLevel = e.param[0];
if(caller->pld.charPtr->cdef.css.level < maxLevel)
return 0;
caller->SendInfoMessage("You are too high a level to accept this quest.", INFOMSG_ERROR);
return -1;
}
break;
case CONDITION_TRANSFORMED:
{
int creatureDefID = e.param[0];
if(cInst->IsTransformed() && cInst->transformCreatureId == creatureDefID)
return 0;
CreatureDefinition *def = CreatureDef.GetPointerByCDef(creatureDefID);
char buffer[128];
Util::SafeFormat(buffer, sizeof(buffer), "You must be transformed into %s to continue with this quest.", def->css.display_name);
caller->SendInfoMessage(buffer, INFOMSG_INFO);
return -1;
}
case CONDITION_UNTRANSFORMED:
{
if(!cInst->IsTransformed())
return 0;
CreatureDefinition *def = CreatureDef.GetPointerByCDef(cInst->transformCreatureId);
char buffer[128];
Util::SafeFormat(buffer, sizeof(buffer), "You cannot be transformed into %s to continue with this quest.", def->css.display_name);
caller->SendInfoMessage(buffer, INFOMSG_INFO);
return -1;
}
break;
case ACTION_CHANGE_HEROISM:
cInst->css.heroism += e.param[0];
cInst->OnHeroismChange();
break;
case ACTION_REMOVE_ITEM:
{
int itemID = e.param[0];
int itemCount = e.param[1];
char buffer[2048];
int len = caller->pld.charPtr->inventory.RemoveItemsAndUpdate(INV_CONTAINER, itemID, itemCount, buffer);
if(len > 0)
caller->AttemptSend(buffer, len);
}
break;
case ACTION_SEND_TEXT:
caller->SendInfoMessage(e.paramStr.c_str(), INFOMSG_INFO);
break;
case ACTION_PLAY_SOUND:
{
STRINGLIST sub;
Util::Split(e.paramStr, "|", sub);
while(sub.size() < 2)
{
sub.push_back("");
}
caller->SendPlaySound(sub[0].c_str(), sub[1].c_str());
}
break;
case ACTION_BROADCAST:
{
char buffer[128];
Util::SafeFormat(buffer, sizeof(buffer), e.paramStr.c_str(), cInst->css.display_name);
g_SimulatorManager.BroadcastMessage(buffer);
}
//.........这里部分代码省略.........
示例9: OpenThread
void IGFManager :: OpenThread(int threadID, int startPost, int requestedCount, MULTISTRING &output)
{
IGFThread *thread = GetPagedThreadPtr(threadID);
if(thread == NULL)
return;
startPost = Util::ClipInt(startPost, 0, thread->mPostList.size() - 1);
STRINGLIST row;
//We retrieve the time offset since the first session since the client uses
//4 byte integers which theoretically may not be large enough to hold the time data.
unsigned long timeOffset = g_PlatformTime.getAbsoluteMinutes();
//Prepare the header
row.push_back(ConvertInteger(threadID)); //[0]
row.push_back(thread->mTitle); //[1]
row.push_back(ConvertInteger(startPost)); //[2]
row.push_back(ConvertInteger(thread->mPostList.size())); //[3]
row.push_back(ConvertInteger(timeOffset - thread->mLastUpdateTime)); //[4]
output.push_back(row);
row.clear();
//Append the post data.
int count = 0;
for(size_t i = startPost; i < thread->mPostList.size(); i++)
{
IGFPost *post = GetPagedPostPtr(thread->mPostList[i]);
if(post == NULL)
{
g_Logs.data->error("OpenThread: unable to find post: %v", thread->mPostList[i]);
continue;
}
row.push_back(ConvertInteger(post->mID)); //[0]
row.push_back(post->mCreatorName.c_str()); //[1]
row.push_back(post->mCreationTime.c_str()); //[2]
row.push_back(ConvertInteger(timeOffset - post->mPostedTime)); //[3]
row.push_back(post->mBodyText.c_str()); //[4]
row.push_back(ConvertInteger(post->mEditCount)); //[5]
row.push_back(ConvertInteger(timeOffset - post->mLastUpdateTime)); //[6]
output.push_back(row);
row.clear();
if(++count >= requestedCount)
break;
}
}
示例10: RunImplementationCommands
//.........这里部分代码省略.........
int result = (attachedCreature->AIIsTargetFriend() == true) ? 1 : 0;
SetVar(in->param1, result);
}
break;
case OP_SETSPEED:
attachedCreature->Speed = in->param1;
break;
case OP_GETTARGETCDEF:
{
int targCDef = 0;
if(attachedCreature->CurrentTarget.targ != NULL)
targCDef = attachedCreature->CurrentTarget.targ->CreatureDefID;
SetVar(in->param1, targCDef);
}
break;
case OP_GETPROPERTY:
{
const char *propName = GetStringTableEntry(in->param1);
SetVar(in->param2, static_cast<int>(attachedCreature->AIGetProperty(propName, false)));
}
break;
case OP_GETTARGETPROPERTY:
{
const char *propName = GetStringTableEntry(in->param1);
SetVar(in->param2, static_cast<int>(attachedCreature->AIGetProperty(propName, true)));
}
break;
case OP_DISPELTARGETPROPERTY:
{
const char *propName = GetStringTableEntry(in->param1);
int sign = in->param2;
attachedCreature->AIDispelTargetProperty(propName, sign);
}
break;
case OP_RANDOMIZE:
SetVar(in->param2, randint(1, in->param1));
break;
case OP_FINDCDEF:
{
int creatureID = 0;
CreatureInstance *targ = attachedCreature->actInst->GetNPCInstanceByCDefID(in->param1);
if(targ != NULL)
creatureID = targ->CreatureID;
SetVar(in->param2, creatureID);
}
break;
case OP_PLAYSOUND:
{
STRINGLIST sub;
Util::Split(GetStringTableEntry(in->param1), "|", sub);
while(sub.size() < 2)
{
sub.push_back("");
}
attachedCreature->SendPlaySound(sub[0].c_str(), sub[1].c_str());
}
break;
case OP_GETBUFFTIER:
SetVar(in->param2, attachedCreature->AIGetBuffTier(in->param1, false));
break;
case OP_GETTARGETBUFFTIER:
SetVar(in->param2, attachedCreature->AIGetBuffTier(in->param1, true));
break;
case OP_TARGETINRANGE:
SetVar(in->param2, (attachedCreature->InRange_Target((float)in->param1) == true) ? 1 : 0);
break;
case OP_GETTARGETRANGE:
SetVar(in->param1, attachedCreature->AIGetTargetRange());
break;
case OP_SETGTAE:
attachedCreature->AISetGTAE();
break;
case OP_GETSPEED:
{
int result = 0;
int creatureID = GetVarValue(in->param1);
CreatureInstance *targ = ResolveCreatureInstance(creatureID);
if(targ != NULL)
{
result = targ->Speed;
}
SetVar(in->param2, result);
}
break;
case OP_CIDISBUSY:
{
int result = 0;
CreatureInstance *targ = ResolveCreatureInstance(GetVarValue(in->param1));
if(targ != NULL)
{
result = (targ->AICheckIfAbilityBusy() == true) ? 1 : 0;
}
SetVar(in->param2, result);
}
break;
default:
g_Logs.script->error("Unidentified op type: %v", in->opCode);
break;
}
}
示例11: handleQuery
int TradeEssenceHandler::handleQuery(SimulatorThread *sim,
CharacterServerData *pld, SimulatorQuery *query,
CreatureInstance *creatureInstance) {
/* Query: trade.essence
Sent when an item is purchased from a chest using tokens or
essences, instead of gold.
Args : [0] = Creature Instance ID
[1] = Item proto of the player's selection.
*/
// [0] = Creature Instance ID
// [1] = Item Proto that was selected ex: "item143548:0:0:0"
if (query->argCount < 2)
return 0;
int CID = atoi(query->args[0].c_str());
int CDef = sim->ResolveCreatureDef(CID);
//Since the Essence Shop scanning functions modify the string while searching
//for tokens, copy it to a buffer here.
Util::SafeCopy(sim->Aux1, query->args[1].c_str(), sizeof(sim->Aux1));
EssenceShopItem *iptr = NULL;
EssenceShop *esptr =
creatureInstance->actInst->essenceShopList.GetEssenceShopPtr(CDef, sim->Aux1,
&iptr);
if (esptr == NULL || iptr == NULL) {
g_Logs.simulator->error(
"[%d] Failed to process EssenceShop item [%s] for CreatureDef [%d]",
sim->InternalID, sim->Aux1, CDef);
return PrepExt_QueryResponseError(sim->SendBuf, query->ID,
"Failed to determine item selection.");
}
InventoryManager &inv = pld->charPtr->inventory;
int currentItemCount = inv.GetItemCount(INV_CONTAINER, esptr->EssenceID);
if (currentItemCount < iptr->EssenceCost) {
g_Logs.simulator->warn("[%v] Essence requirement for item %v: %v / %v",
sim->InternalID, esptr->EssenceID, currentItemCount,
iptr->EssenceCost);
return PrepExt_QueryResponseString(sim->SendBuf, query->ID,
"You do not have enough essences.");
}
InventorySlot *newItem = pld->charPtr->inventory.AddItem_Ex(INV_CONTAINER,
iptr->ItemID, 1);
if (newItem == NULL) {
pld->charPtr->pendingChanges++;
int err = pld->charPtr->inventory.LastError;
if (err == InventoryManager::ERROR_ITEM)
return PrepExt_QueryResponseString(sim->SendBuf, query->ID,
"Server error: item does not exist.");
else if (err == InventoryManager::ERROR_SPACE)
return PrepExt_QueryResponseString(sim->SendBuf, query->ID,
"You do not have any free inventory space.");
else if (err == InventoryManager::ERROR_LIMIT)
return PrepExt_QueryResponseString(sim->SendBuf, query->ID,
"You already the maximum amount of these items.");
else
return PrepExt_QueryResponseString(sim->SendBuf, query->ID,
"Server error: undefined error.");
}
sim->ActivateActionAbilities(newItem);
STRINGLIST result;
result.push_back("OK");
sprintf(sim->Aux3, "%d", iptr->EssenceCost);
result.push_back(sim->Aux3);
int wpos = PrepExt_QueryResponseStringList(sim->SendBuf, query->ID, result);
wpos += AddItemUpdate(&sim->SendBuf[wpos], sim->Aux3, newItem);
wpos += inv.RemoveItemsAndUpdate(INV_CONTAINER, esptr->EssenceID,
iptr->EssenceCost, &sim->SendBuf[wpos]);
pld->charPtr->pendingChanges++;
return wpos;
}
示例12: SendPageRequest
void SceneryManager::SendPageRequest(const SceneryPageRequest& request, std::list<PacketManager::PACKET_PAIR>& outgoingPackets)
{
TimeObject to("SceneryManager::SendPageRequest");
STRINGLIST queryRows;
Packet data;
int wpos = 0;
char idBuf[32];
GetThread("SceneryManager::HandlePageRequests[page]");
SceneryPage *page = GetOrCreatePage(request.zone, request.x, request.y);
if(page == NULL)
{
g_Log.AddMessageFormat("[ERROR] SendPageRequest retrieved NULL page");
wpos = PrepExt_QueryResponseNull(prepBuf, request.queryID);
data.Assign(prepBuf, wpos);
outgoingPackets.push_back(PacketManager::PACKET_PAIR(request.socket, data));
ReleaseThread();
return;
}
SceneryPage::SCENERY_IT it;
for(it = page->mSceneryList.begin(); it != page->mSceneryList.end(); ++it)
{
//Build the list of scenery ID strings to form the response to the scenery.list query.
//No need to save row data unless the query is required.
if(request.skipQuery == false)
{
sprintf(idBuf, "%d", it->second.ID);
queryRows.push_back(idBuf);
}
wpos += PrepExt_UpdateScenery(&prepBuf[wpos], &it->second);
if(wpos > Global::MAX_SEND_CHUNK_SIZE)
{
data.Assign(prepBuf, wpos);
outgoingPackets.push_back(PacketManager::PACKET_PAIR(request.socket, data));
wpos = 0;
}
}
if(wpos > 0)
{
data.Assign(prepBuf, wpos);
outgoingPackets.push_back(PacketManager::PACKET_PAIR(request.socket, data));
}
//Done accessing the scenery data itself, no need to hold the thread any longer.
//All the remaining stuff is using a resident list of query IDs to form into a response
//packet.
ReleaseThread();
//Now build the query response if the client has requested it.
if(request.skipQuery == true)
return;
//Reset the packet buffer and data.
wpos = 0;
data.Clear();
//Get the size of the response
int sizeReq = 6; //Query ID (4 bytes) + row count (2 bytes)
for(size_t s = 0; s < queryRows.size(); s++)
{
sizeReq++; //1 string per row
sizeReq += PutStringReq(queryRows[s].c_str());
}
wpos += PutByte(&prepBuf[wpos], 1); //_handleQueryResultMsg
wpos += PutShort(&prepBuf[wpos], sizeReq); //Message size
wpos += PutInteger(&prepBuf[wpos], request.queryID);
wpos += PutShort(&prepBuf[wpos], queryRows.size());
for(size_t s = 0; s < queryRows.size(); s++)
{
wpos += PutByte(&prepBuf[wpos], 1);
wpos += PutStringUTF(&prepBuf[wpos], queryRows[s].c_str());
if(wpos > Global::MAX_SEND_CHUNK_SIZE)
{
data.Append(prepBuf, wpos);
wpos = 0;
}
}
if(wpos > 0)
data.Append(prepBuf, wpos);
outgoingPackets.push_back(PacketManager::PACKET_PAIR(request.socket, data));
}