本文整理汇总了C++中STRINGLIST::size方法的典型用法代码示例。如果您正苦于以下问题:C++ STRINGLIST::size方法的具体用法?C++ STRINGLIST::size怎么用?C++ STRINGLIST::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STRINGLIST
的用法示例。
在下文中一共展示了STRINGLIST::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitCommand
bool ExtendedQuestAction :: InitCommand(const STRINGLIST &tokenList)
{
if(tokenList.size() < 1)
return false;
const QuestScriptCommandDef *cmd = GetCommandDef(tokenList[0]);
if(cmd == 0)
{
g_Logs.data->warn("Quest command not recognized [%v]", tokenList[0].c_str());
return false;
}
size_t tokenCount = tokenList.size();
if(tokenCount != cmd->numParams + 1) //First token is command itself
{
g_Logs.data->warn("Expected [%v] arguments for command [%v]", cmd->numParams, cmd->name);
return false;
}
opCode = cmd->opCode;
for(int i = 0; i < cmd->numParams; i++)
{
bool valid = false;
int result = 0;
valid = ResolveOperand(tokenList[1 + i], cmd->paramType[i], result);
if(valid == false)
return false;
param[i] = result;
}
return true;
/*
int opCode = GetCondition(tokenList[0]);
size_t tokenCount = tokenList.size();
int p1 = 0;
int p2 = 0;
int p3 = 0;
switch(opCode)
{
case CONDITION_HASSTAT:
if(ExpectTokens(tokenCount, 4) == false) return false;
p1 = GetStatIDByName(tokenList[1]);
p2 = GetComparator(tokenList[2]);
p3 = Util::GetFloat(tokenList[3]);
if(p1 == -1 || p2 == COMP_NONE)
return false;
break;
case CONDITION_HASITEM:
if(ExpectTokens(tokenCount, 3) == false) return false;
p1 = Util::GetInteger(tokenList[1]);
p2 = Util::GetInteger(tokenList[2]);
break;
}
commandType = opCode;
param1 = p1;
param2 = p2;
param3 = p3;
return true;
*/
}
示例2: d
const char * Platform::Filename(const char *path)
{
STRINGLIST v;
const std::string p = path;
const std::string d(1, PLATFORM_FOLDERVALID);
Util::Split(p, d.c_str(), v);
if(v.size() == 0)
return "";
else
return v[v.size() - 1].c_str();
}
示例3: if
const char * Platform::Extension(const char *path)
{
STRINGLIST v;
const std::string p = Filename(path);
const std::string d(1, PLATFORM_FOLDERVALID);
Util::Split(p, ".", v);
if(v.size() == 0)
return "";
else if(v.size() == 1)
return v[0].c_str();
else
return v[v.size() - 1].c_str();
}
示例4: AddLine
void QuestActionContainer :: AddLine(const char *statement)
{
STRINGLIST commands;
Util::Split(statement, ";", commands);
for(size_t i = 0; i < commands.size(); i++)
AddCommand(commands[i]);
}
示例5: 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());
}
示例6: AssignFloatArrayFromStringSplit
//Break a comma-delimited string into tokens, then loading the converted values into a raw array of floats.
void AssignFloatArrayFromStringSplit(float *arrayDest, size_t arraySize, const std::string &strData)
{
STRINGLIST strArray;
Split(strData, ",", strArray);
for(size_t i = 0; i < strArray.size(); i++)
{
if(i >= arraySize)
return;
arrayDest[i] = static_cast<float>(atof(strArray[i].c_str()));
}
}
示例7:
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;
}
示例8: LoadDFNCategory
void CServerDefinitions::LoadDFNCategory( DEFINITIONCATEGORIES toLoad )
{
CleanPriorityMap();
defaultPriority = 0;
UI08 wasPriod = 2;
BuildPriorityMap( toLoad, wasPriod );
cDirectoryListing fileList( toLoad, defExt );
fileList.Flatten( true );
STRINGLIST *shortListing = fileList.FlattenedShortList();
STRINGLIST *longListing = fileList.FlattenedList();
std::vector< PrioScan > mSort;
for( size_t i = 0; i < shortListing->size(); ++i )
{
mSort.push_back( PrioScan( (*longListing)[i].c_str(), GetPriority( (*shortListing)[i].c_str() ) ) );
}
if( !mSort.empty() )
{
std::sort( mSort.begin(), mSort.end() );
Console.Print( "Section %20s : %6i", dirnames[toLoad].c_str(), 0 );
size_t iTotal = 0;
Console.TurnYellow();
std::vector< PrioScan >::const_iterator mIter;
for( mIter = mSort.begin(); mIter != mSort.end(); ++mIter )
{
Console.Print( "\b\b\b\b\b\b" );
ScriptListings[toLoad].push_back( new Script( (*mIter).filename, toLoad, false ) );
iTotal += ScriptListings[toLoad].back()->NumEntries();
Console.Print( "%6i", iTotal );
}
Console.Print( "\b\b\b\b\b\b%6i", CountOfEntries( toLoad ) );
Console.TurnNormal();
Console.Print( " entries" );
switch( wasPriod )
{
case 0: Console.PrintSpecial( CGREEN, "prioritized" ); break; // prioritized
case 1:
Console.PrintSpecial( CGREEN, "done" );
break; // file exist, no section
default:
case 2:
Console.PrintSpecial( CBLUE, "done" );
break; // no file
};
}
}
示例9: BuildPriorityMap
void CServerDefinitions::BuildPriorityMap( DEFINITIONCATEGORIES category, UI08& wasPrioritized )
{
cDirectoryListing priorityFile( category, "priority.nfo", false );
STRINGLIST *longList = priorityFile.List();
if( longList->size() > 0 )
{
std::string filename = (*longList)[0];
// Do we have any priority informat?
if( FileExists( filename ) ) // the file exists, so perhaps we do
{
Script *prio = new Script( filename, category, false ); // generate a script for it
if( prio != NULL ) // successfully made a script
{
UString tag;
UString data;
ScriptSection *prioInfo = prio->FindEntry( "PRIORITY" ); // find the priority entry
if( prioInfo != NULL )
{
for( tag = prioInfo->First(); !prioInfo->AtEnd(); tag = prioInfo->Next() ) // keep grabbing priority info
{
data = prioInfo->GrabData();
if( tag.upper() == "DEFAULTPRIORITY" )
defaultPriority = data.toShort();
else
{
std::string filenametemp = tag.lower();
priorityMap[filenametemp] = data.toShort();
}
}
wasPrioritized = 0;
}
else
wasPrioritized = 1;
delete prio; // remove script
prio = NULL;
}
else
wasPrioritized = 2;
return;
}
}
#if defined( UOX_DEBUG_MODE )
// Console.Warning( "Failed to open priority.nfo for reading in %s DFN", dirnames[category].c_str() );
#endif
wasPrioritized = 2;
}
示例10: AddCommand
void QuestActionContainer :: AddCommand(const std::string &command)
{
STRINGLIST tokens;
//Util::Split(command, " ", tokens);
Util::TokenizeByWhitespace(command, tokens);
if(tokens.size() == 0)
{
g_Logs.data->warn("No tokens in command.");
return;
}
ExtendedQuestAction inst;
if(inst.InitCommand(tokens) == true)
{
//Debug disassembly
//g_Log.AddMessageFormat("%s = [%d]=%d,%d,%d", command.c_str(), inst.opCode, inst.param[0], inst.param[1], inst.param[2]);
mInstList.push_back(inst);
}
}
示例11: PrepExt_QueryResponseStringList
int PrepExt_QueryResponseStringList(char *buffer, int queryIndex, const STRINGLIST &strData)
{
int wpos = 0;
wpos += PutByte(&buffer[wpos], 1); //_handleQueryResultMsg
wpos += PutShort(&buffer[wpos], 0); //Placeholder for message size
wpos += PutInteger(&buffer[wpos], queryIndex); //Query response index
wpos += PutShort(&buffer[wpos], 1); //Row count
int count = strData.size();
if(count > 255)
{
g_Logs.server->warn("PrepExt_QueryResponseStringList too many strings: %v", count);
count = 255;
}
wpos += PutByte(&buffer[wpos], count); //String count
for(int a = 0; a < count; a++)
wpos += PutStringUTF(&buffer[wpos], strData[a].c_str()); //String data
PutShort(&buffer[1], wpos - 3); //Message size
return wpos;
}
示例12: Flatten
void cDirectoryListing::Flatten( bool isParent )
{
ClearFlatten();
std::string temp;
STRINGLIST_ITERATOR sIter;
for( sIter = filenameList.begin(); sIter != filenameList.end(); ++sIter )
{
flattenedFull.push_back( (*sIter) );
if( isParent )
temp = "";
else
{
temp = shortCurrentDir;
temp += "/";
}
temp += (*sIter);
flattenedShort.push_back( temp );
}
DIRLIST_ITERATOR dIter;
for( dIter = subdirectories.begin(); dIter != subdirectories.end(); ++dIter )
{
(*dIter).Flatten( false );
STRINGLIST *shortFlat = (*dIter).FlattenedShortList();
STRINGLIST *longFlat = (*dIter).FlattenedList();
for( size_t k = 0; k < longFlat->size(); ++k )
{
flattenedFull.push_back( (*longFlat)[k] );
if( isParent )
temp = "";
else
{
temp = shortCurrentDir;
temp += "/";
}
temp += (*shortFlat)[k];
flattenedShort.push_back( temp );
}
(*dIter).ClearFlatten();
}
}
示例13: 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);
}
//.........这里部分代码省略.........
示例14: handleQuery
int CreditShopEditHandler::handleQuery(SimulatorThread *sim,
CharacterServerData *pld, SimulatorQuery *query,
CreatureInstance *creatureInstance) {
if (query->args.size() < 1)
return PrepExt_QueryResponseError(sim->SendBuf, query->ID,
"Invalid query.");
if (!sim->CheckPermissionSimple(Perm_Account, Permission_Sage))
return PrepExt_QueryResponseError(sim->SendBuf, query->ID,
"Permission denied.");
if (strcmp(query->GetString(0), "DELETE") == 0 && query->args.size() > 1) {
int id = query->GetInteger(1);
CS::CreditShopItem *item = g_CreditShopManager.GetItem(id);
if (item == NULL)
return PrepExt_QueryResponseError(sim->SendBuf, query->ID,
"Invalid item.");
else {
// TODO remove
if (g_CreditShopManager.RemoveItem(id)) {
g_Logs.event->info("[CS] Removed credit shop item %v",
item->mId);
return PrepExt_QueryResponseString(sim->SendBuf, query->ID,
"OK");
}
return PrepExt_QueryResponseError(sim->SendBuf, query->ID,
"Failed to remove.");
}
} else if (query->args.size() > 22) {
CS::CreditShopItem * csItem;
bool isNew = strcmp(query->GetString(0), "NEW") == 0;
if (isNew) {
csItem = new CS::CreditShopItem();
csItem->mId = g_CreditShopManager.nextMarketItemID++;
csItem->mCreatedDate = g_ServerTime / 1000;
SessionVarsChangeData.AddChange();
Util::SafeFormat(sim->Aux3, sizeof(sim->Aux3),
"Created market csItem %d", csItem->mId);
g_Logs.cs->info("%v (%v) created %v (%v)", pld->accPtr->Name, pld->charPtr->cdef.css.display_name,
csItem->mId, csItem->mItemId);
} else {
csItem = g_CreditShopManager.GetItem(query->GetInteger(0));
if (csItem == NULL)
return PrepExt_QueryResponseError(sim->SendBuf, query->ID,
"Invalid item.");
Util::SafeFormat(sim->Aux3, sizeof(sim->Aux3),
"Save market csItem %d", csItem->mId);
g_Logs.cs->info("%v (%v) updated %v (%v)", pld->accPtr->Name, pld->charPtr->cdef.css.display_name,
csItem->mId, csItem->mItemId);
}
int currency = query->GetInteger(16);
unsigned long priceCopper = 0;
unsigned long priceCredits = 0;
STRINGLIST priceElements;
Util::Split(query->GetString(14), "+", priceElements);
if (currency == Currency::COPPER) {
priceCopper = atoi(priceElements[0].c_str());
} else if (currency == Currency::CREDITS) {
priceCredits = atoi(priceElements[0].c_str());
} else if (currency == Currency::COPPER_CREDITS) {
if (priceElements.size() != 2) {
return PrepExt_QueryResponseError(sim->SendBuf, query->ID,
"COPPER+CREDITS require two costs, <copperCost>+<creditCost>.");
}
priceCopper = atoi(priceElements[0].c_str());
priceCredits = atoi(priceElements[1].c_str());
}
csItem->mTitle = query->GetString(2);
csItem->mDescription = query->GetString(4);
csItem->mCategory = Category::GetIDByName(query->GetString(6));
csItem->mStatus = Status::GetIDByName(query->GetString(8));
Util::ParseDate(query->GetString(10), csItem->mStartDate);
Util::ParseDate(query->GetString(12), csItem->mEndDate);
csItem->mPriceCopper = priceCopper;
csItem->mPriceCredits = priceCredits;
csItem->mPriceCurrency = currency;
csItem->mQuantityLimit = query->GetInteger(18);
csItem->mQuantitySold = query->GetInteger(20);
csItem->ParseItemProto(query->GetString(22));
// Check the item
ItemDef * item = g_ItemManager.GetSafePointerByID(csItem->mItemId);
if (item == NULL) {
if (isNew)
delete csItem;
return PrepExt_QueryResponseError(sim->SendBuf, query->ID,
"No such item!");
}
if (csItem->mTitle.compare(item->mDisplayName) == 0)
csItem->mTitle = "";
g_CreditShopManager.SaveItem(csItem);
g_CreditShopManager.cs.Enter(
"SimulatorThread :: handle_query_item_market_edit");
g_CreditShopManager.mItems[csItem->mId] = csItem;
g_CreditShopManager.cs.Leave();
//.........这里部分代码省略.........
示例15: LoadConfig
bool LoadConfig(std::string filename) {
bool oauthSet = false;
//Loads the configuration options from the target file. These are core options
//required for the server to operate.
FileReader lfr;
if (lfr.OpenText(filename.c_str()) != Err_OK) {
return false;
}
static char Delimiter[] = { '=', 13, 10 };
lfr.Delimiter = Delimiter;
lfr.CommentStyle = Comment_Semi;
while (lfr.FileOpen() == true) {
int r = lfr.ReadLine();
if (r > 0) {
lfr.SingleBreak("=");
char *NameBlock = lfr.BlockToString(0);
if (strcmp(NameBlock, "ProtocolVersion") == 0) {
g_ProtocolVersion = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "AuthMode") == 0) {
g_AuthMode = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "AuthKey") == 0) {
strncpy(g_AuthKey, lfr.BlockToString(1), sizeof(g_AuthKey) - 1);
} else if (strcmp(NameBlock, "RouterPort") == 0) {
g_RouterPort = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "SimulatorAddress") == 0) {
strncpy(g_SimulatorAddress, lfr.BlockToString(1),
sizeof(g_SimulatorAddress) - 1);
} else if (strcmp(NameBlock, "BindAddress") == 0) {
strncpy(g_BindAddress, lfr.BlockToString(1),
sizeof(g_BindAddress) - 1);
} else if (strcmp(NameBlock, "SimulatorPort") == 0) {
g_SimulatorPort = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "ThreadSleep") == 0) {
g_ThreadSleep = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "ErrorSleep") == 0) {
g_ErrorSleep = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "MainSleep") == 0) {
g_MainSleep = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "DefX") == 0) {
g_Config.DefX = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "DefY") == 0) {
g_Config.DefY = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "DefZ") == 0) {
g_Config.DefZ = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "DefZone") == 0) {
g_Config.DefZone = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "DefRotation") == 0) {
g_Config.DefRotation = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "HTTPBaseFolder") == 0) {
g_Config.HTTPBaseFolder = lfr.BlockToString(1);
} else if (strcmp(NameBlock, "HTTPCARFolder") == 0) {
g_Config.HTTPCARFolder = lfr.BlockToString(1);
} else if (strcmp(NameBlock, "HTTPListenPort") == 0) {
g_HTTPListenPort = lfr.BlockToInt(1);
}
#ifndef NO_SSL
else if(strcmp(NameBlock, "HTTPSListenPort") == 0)
{
g_HTTPSListenPort = lfr.BlockToInt(1);
}
else if(strcmp(NameBlock, "SSLCertificate") == 0)
{
AppendString(g_SSLCertificate, lfr.BlockToStringC(1, 0));
}
#endif
else if (strcmp(NameBlock, "RebroadcastDelay") == 0) {
g_RebroadcastDelay = lfr.BlockToULongC(1);
} else if (strcmp(NameBlock, "SceneryAutosaveTime") == 0) {
g_SceneryAutosaveTime = lfr.BlockToULongC(1);
} else if (strcmp(NameBlock, "ForceUpdateTime") == 0) {
g_ForceUpdateTime = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "ItemBindingTypeOverride") == 0) {
g_ItemBindingTypeOverride = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "ItemArmorTypeOverride") == 0) {
g_ItemArmorTypeOverride = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "ItemWeaponTypeOverride") == 0) {
g_ItemWeaponTypeOverride = lfr.BlockToInt(1);
} else if (strcmp(NameBlock, "MOTD_Name") == 0) {
g_MOTD_Name = lfr.BlockToStringC(1, 0);
} else if (strcmp(NameBlock, "MOTD_Channel") == 0) {
g_MOTD_Channel = lfr.BlockToStringC(1, 0);
} else if (strcmp(NameBlock, "RemoteAuthenticationPassword") == 0) {
g_Config.RemoteAuthenticationPassword = lfr.BlockToStringC(1,
0);
} else if (strcmp(NameBlock, "ProperSceneryList") == 0) {
g_Config.ProperSceneryList = lfr.BlockToIntC(1);
} else if (strcmp(NameBlock, "BuybackLimit") == 0) {
g_Config.BuybackLimit = lfr.BlockToIntC(1);
} else if (strcmp(NameBlock, "Upgrade") == 0)
g_Config.Upgrade = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "HeartbeatIntervalMS") == 0)
g_Config.HeartbeatIntervalMS = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "HeartbeatAbortCount") == 0)
g_Config.HeartbeatAbortCount = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "WarpMovementBlockTime") == 0)
g_Config.WarpMovementBlockTime = lfr.BlockToIntC(1);
else if (strcmp(NameBlock, "IdleCheckVerification") == 0)
//.........这里部分代码省略.........