예제 #1
0
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);
}
예제 #2
0
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());
}
예제 #3
0
	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);
	}
예제 #4
0
	void getSubFiles(char* pDir, CStringList& pOut, CString* search)
	{
		DIR *dir;
		struct stat statx;
		struct dirent *ent;
		if ((dir = opendir(pDir)) == NULL)
			return;
		while ((ent = readdir(dir)) != NULL)
		{
			CString fullName = CString() << pDir << ent->d_name;
			stat(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 );
			}
		}
		closedir(dir);
	}
예제 #5
0
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);
		}
	}
}
예제 #6
0
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);
}
예제 #7
0
	void getSubFiles(char* pDir, CStringList& pOut, CString* search)
	{
		// Assemble the search wildcards.
		CString searchdir( pDir );
		if ( search == 0 ) searchdir << "*";
		else
		{
			searchdir << search->replaceAll( "%", "*" );
			searchdir << ".txt";
		}

		WIN32_FIND_DATA filedata;
		HANDLE hFind = FindFirstFile(searchdir.text(), &filedata);
		if(hFind!=NULL)
		{
			do
			{
				if(!(filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
					pOut.add(filedata.cFileName);
			} while (FindNextFile(hFind, &filedata));
		}
		FindClose(hFind);
	}
예제 #8
0
void getSubDirs_os(char *pDir)
{
	CString searchdir = CString() << pDir << "*";
	WIN32_FIND_DATA filedata;
	HANDLE hFind = FindFirstFile(searchdir.text(), &filedata);
	subDirs.add(pDir);

	if(hFind!=NULL)
	{
		do
		{
			if(filedata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				if(filedata.cFileName[0] != '.')
				{
					CString directory = CString() << pDir << filedata.cFileName << fSep;
					getSubDirs_os(directory.text());
				}
			}
		} while (FindNextFile(hFind, &filedata));
	}
	FindClose(hFind);
}
예제 #9
0
/* 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);
}