Thread: Reading files
View Single Post
Old 08-10-2006, 03:22 PM   #12
dumbledore
Rookie
 
Join Date: Nov 2005
Posts: 85
u could try this, didn't get a chance to test it extensively :S
Code:
	if(mpx_wordFilter.integer == 1)
	{
		len = trap_FS_FOpenFile("wordlist.txt", &file, FS_READ);//Open the bad word list

		if(file)	
		{			
			
			fileDump = BG_TempAlloc(len+1); //Allocate memory for the file dump
			word = BG_TempAlloc(25); //Allocate memory for the bad word
			
			trap_FS_Read(fileDump, len, file);
			trap_FS_FCloseFile(file);
			
			if(len) //only check for bad words if the file has something in it
			{	
				while(fileDump[i])
				{
					if(fileDump[i] == '\n') //If the character is a space then it will NOT be copied
					{
						word[y] = 0;
						i++;
						//STOP! If there is a space that's the end of the word
						while( value = stristr(p, word) )
						{
							start = value - p;
							x = 0;
							while(x < y)
							{
								p[start + x] = '*';
	
								x++;
							}
						}
						y = 0;
					}
					else
					{
						word[y++] = fileDump[i++]; 
					}										

				}
			}
			BG_TempFree(25);
			BG_TempFree(len+1);
		}	
	}
of course the real solution would be to rewrite it using com_parse, but if it's that simple you probably don't need to
dumbledore is offline   you may: quote & reply,