lfnetwork.com mark read register faq members calendar

Thread: Reading files
Thread Tools Display Modes
Post a new thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Prev Previous Post   Next Post Next
Old 07-27-2006, 11:30 AM   #1
Dom_152
Rookie
 
Dom_152's Avatar
 
Join Date: Jan 2006
Location: England
Posts: 150
Reading files

Help me with reading files! At the moment my Mod is only reading the first word in the file (This is for a word filter) but there are 2 others below it. The filedump shows that all 3 have been read and tehre is a \n character separating them. How can I get my mod to read all of the words? I want it to read the first word, check if that word is in the sentence if it is star it out... then move onto the next word in the list. Here is my current code:
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, 1024, file);
			trap_FS_FCloseFile(file);

			CmdAll(va("print \"Filedump: %s\n\"", fileDump));

			if(len) //only check for bad words if the file has something in it
			{				
				while(i < len+1) //We just keep going through the file
				{
					
					while(y < 25) //25 = max Word length
					{
  						if(fileDump[y * (i+1)] == "\n") //If the character is a space then it will NOT be copied
						{
							y++; //STOP! If there is a space that's the end of the word
						}
						else
						{
							word[y] = fileDump[y * (i+1)]; 
							y++;
						}										

					}
				

					//OK By this point we should have a word so lets check if it's in the file
					//So we check to see if the bad word is ANYWHERE in the sentence
					value = stristr(p, word);				
					
					if(value != NULL)
					{
						start = p - value;

						if(start < 0)
						{
							start = -start;
						}							
						
						while(x < strlen(word))
						{
							p[start + x] = '*';

							x++;
						}	
					}

					//i++;
					CmdAll(va("print \"I = %i\n\"", i));
					i += 25; //Increase I by 25 as this is the size of a word
				}
			}
		
				
				BG_TempFree(25);
				BG_TempFree(len+1);		
		}	
	}


-----------------------------------------------------
MultiPlayer Xtra
Jedi Academy MP Mod
(Released! Source Code and all!)

Jedi Academy - Xtra
Coming Soon...

-----------------------------------------------------
Dom_152 is offline   you may: quote & reply,
Post a new thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > Reading files

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:28 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.