You could try something like the following, using ROM's built-in is_exact_name 
boolean... it would probably cut down a lot on memory allocation as well...
 
Change that char *word[1000] to a simple char *word... i assume at the end of 
the round you're cycling through a loop of 1000 and freeing all those strings, 
but you could simply make it 1 string and each time a guess is made, do 
something like this:
 
strcat(word," ");
strcat(word,argument);
 
and then when another guess is made you can say:
 
if ( is_exact_name(argument,word) )
 
which should just check the newly entered word against the whole list of words 
held by word, just like when a player walks up to a "standard merc guard 
cityguard midgaard" (or whatever the name is) and types "look guard"... you'll 
want to use is_exact_name instead of is_name because if someone guesses a word 
that's part of another word that's been guessed, like if some wise guy guesses 
horsee when the letters are orshe, the code simply sees that the first and last 
letter are correct and logs it, and then someone guesses horse, which is_name 
would return as having been tried already because it uses str_prefix instead of 
str_cmp, which reminds me, you may want to do a strlen check also before 
logging previous word attempts... hope this helps....
 
wavewave
Richard Lindsey.
 
p.s. you may also want to change the char *first and char *last to simply char 
first and char last, since they only hold 1 letter apiece... and you can do the 
same thing to char *name[1000] that you do to char *word and make it a list of 
names inside of one char * variable, but in order to correlate who said which 
word, you can loop through them with something like one_argument until you find 
the word you're looking for, and where the current pointer is in name, or you 
could loop through it looking for strstr(word," ") and strstr(name," ") until 
you find the right word, and then look at the current pointer to name... you'd 
want to initialize another char * variable to both of those first, however, to 
hold the pointer to the beginnings of the strings, or else make it a separate 
function like find_match("blah",word,name) so that the word and name pointers 
are still in the original locations when it returns from find_match...
 
struct     wordtwist_data
{
     int totalguesses; //how many guesses people have made so far(total for
everyone)
     int turns_left; //how many turns are left before the round is over
     char *first; //letter that correct phrases begin with
     char *last; //letter that correct phrases end with
     char dict[MAX_STRING_LENGTH]; //the word list file
     char *word[1000]; //these are the words guessed(i think this is where
my problem is)
     char *name[1000]; //these are who guessed which words
     bool newround; //newround? yes or no?
};

Reply via email to