当前位置: 首页>>代码示例>>C++>>正文


C++ CStringList::add方法代码示例

本文整理汇总了C++中CStringList::add方法的典型用法代码示例。如果您正苦于以下问题:C++ CStringList::add方法的具体用法?C++ CStringList::add怎么用?C++ CStringList::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CStringList的用法示例。


在下文中一共展示了CStringList::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: saveWeapons

void saveWeapons(char* pFile)
{
	CStringList weaponData;
	for(int i = 0; i < weaponList.count(); i++)
	{
		CString code;
		char modTime[30];
		int index;

		CWeapon* weapon = (CWeapon*)weaponList[i];
		index = weaponData.add("NEWWEAPON ");
		sprintf(modTime, "%li", (long int)weapon->modTime);

		// Save name.
		weaponData[index] << weapon->name << ",";

		// If the NPC doesn't have an image, write a hyphen.
		if ( weapon->image.length() == 0 ) weaponData[index] << "-" << ",";
		else weaponData[index] << weapon->image << ",";

		// Write the modification time.
		weaponData[index] << modTime;

		code = weapon->code;
		char* line = strtok(code.text(), "\xa7");
		while(line != NULL)
		{
			weaponData.add(line);
			line = strtok(NULL, "\xa7");
		}
		weaponData.add("ENDWEAPON\r\n");
	}
	weaponData.save(pFile);
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:34,代码来源:main.cpp

示例2: saveNpcs

void CLevel::saveNpcs()
{
	return;

	CStringList npcData;
	//printf("SAVING NPCS\n");
	for(int i = 0; i < npcs.count(); i++)
	{
		CNpc* npc = (CNpc*)npcs[i];
		if(npc == NULL)
			continue;
		npcData.add(CString() << "REPLACENPC " << toString(i));
		CPacket props;
		for(int ii = 0; ii < npcpropcount; ii++)
		{
			if(ii != ACTIONSCRIPT)
				props << (char) ii << npc->getProperty(ii);
		}
		npcData.add(props);
		npcData.add("REPLACENPCEND\r\n");
	}
	CString fName;
	fName << "npcprops" << fSep << fileName << ".code";
	npcData.save(fName.text());
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:25,代码来源:CLevel.cpp

示例3: getSubFiles

	void getSubFiles(char* pDir, CStringList& pOut, CString* search)
	{
		SceUID dir;
		if ((dir = sceIoDopen(pDir)) <= 0)
			return;

		SceIoDirent ent;
		SceIoStat statx;

		while (sceIoDread(dir, &ent) > 0)
		{
			CString fullName = CString() << pDir << ent.d_name;
			sceIoGetstat(fullName.text(), &statx);
			if (!(statx.st_mode & S_IFDIR))
			{
				if (search != 0)
				{
					CString s( *search );
					CString m( ent.d_name );
					s.replaceAll( "%", "*" );
					s << ".txt";
					if (m.match( s.text()) == false) continue;
				}
				pOut.add( ent.d_name );
			}
		}

		sceIoDclose(dir);
	}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:29,代码来源:main.cpp

示例4: getSubDirs

void getSubDirs()
{
	// If foldersconfig.txt is turned off, use the old style.
	if ( noFoldersConfig )
	{
		subDirs.clear();
		getSubDirs_os( dataDir.text() );
		if ( shareFolder.length() > 1 )
			getSubDirs_os( shareFolder.text() );
	}
	else
	{
		subDirs.clear();
		subDirs.add(dataDir);
		for (int i = 0; i < folderConfig.count(); i++)
		{
			if (folderConfig[i][0] == '#')
				continue;

			CBuffer fmask, fname;

			// Get rid of all \t and replace with ' '.
			// Also, trim.
			folderConfig[i].replaceAll( "\t", " " );

			// Read past the identifier.
			folderConfig[i].setRead(folderConfig[i].find(' '));

			// Read the mask
			CBuffer temp = folderConfig[i].readString( "" );
			temp.trim();

			// If it starts with ./, use . instead of world/ as the search dir.
			if ( temp.find( "./" ) == 0 )
				fmask = CBuffer() << programDir << temp;
			else
				fmask = CBuffer() << dataDir << temp;

			// Pull off the file mask and only save the directory.
			fname = CBuffer() << fmask.readChars(fmask.findl(fSep[0])) << fSep;
			if (subDirs.find(fname) == -1)
				subDirs.add(fname);
		}
	}
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:45,代码来源:main.cpp

示例5: getSubDirs_os

void getSubDirs_os(char *pDir)
{
	DIR *dir;
	struct stat statx;
	struct dirent *ent;
	if ((dir = opendir(pDir)) == NULL)
		return;
	subDirs.add(pDir);
	while ((ent = readdir(dir)) != NULL)
	{
		if (ent->d_name[0] != '.')
		{
			CString directory = CString() << pDir << ent->d_name << fSep;
			stat(directory.text(), &statx);
			if (statx.st_mode & S_IFDIR)
				getSubDirs_os(directory.text());
		}
	}
	closedir(dir);
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:20,代码来源:main.cpp

示例6: apply

/* Never was great formulating =P */
bool CWordFilter::apply(CPlayer *pPlayer, CBuffer &pBuffer, int pCheck)
{
	bool logsave = false, rctell = false;
	CBuffer start;
	CStringList found;
	int pos = 0, wc = 0;

	for (int i = 0; i < WordList.count(); i++)
	{
		WordMatch *word = (WordMatch *)WordList[i];
		if (!word->check[pCheck])
			continue;

		for (int j = 0; j < pBuffer.length(); j++)
		{
			for (int k = 0; k < word->match.length(); k++)
			{
				char c1 = pBuffer[j + k];
				char c2 = word->match[k];
				if (c2 != '?' && (isUpper(c2) && c2 != c1) || (isLower(c2) && toLower(c2) != toLower(c1)))
				{
					if (wc >= word->precision)
					{
						found.add(start);

						for (int l = 0; l < (int)sizeof(word->action); l++)
						{
							if (!word->action[l])
								continue;

							switch (l)
							{
								case FILTERA_LOG:
									if (logsave)
										break;

									logsave = true;
									if (pPlayer != NULL)
										errorOut("wordfilter.txt", CBuffer() << pPlayer->accountName << " has used rude words while chatting: " << start);
								break;

								case FILTERA_REPLACE:
									pos = pBuffer.find(' ', j);
									pos = (pos == -1 ? start.length() : pos-j+1);
									for (int m = 0; m < pos; m++)
										pBuffer.replace(j + m, '*');
								break;

								case FILTERA_TELLRC:
									if (rctell)
										break;

									rctell = true;
									if (pPlayer != NULL)
										sendRCPacket(CPacket() << (char)DRCLOG << pPlayer->accountName << " has used rude words while chatting: " << start);
								break;

								case FILTERA_WARN:
									pBuffer = (word->warnmessage.length() > 0 ? word->warnmessage : warnmessage);
								break;

								case FILTERA_JAIL: // kinda useless...?
								break;

								case FILTERA_BAN:
									if (pPlayer != NULL)
									{
										CBuffer pLog = CBuffer() << "\n" << getTimeStr(0) << "\n" << pPlayer->accountName << " has used rude words while chatting: " << start;
										pPlayer->setBan(pLog, true);
									}
								break;
							}
						}
					}

					start.clear();
					wc = 0;
					break;
				}

				start.writeChar(c1);
				wc++;
			}
		}
	}

	return (found.count() > 0);
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:89,代码来源:CWordFilter.cpp


注:本文中的CStringList::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。