Exemple #1
0
 void unlock(vm_pagenum_t pagenum)
 {
   VM_page *found = searchhash(pagenum);
   QASSERT(found != NULL);
   if ( found->locked > 0 )
   {
     found->locked--;
     if ( !found->locked )
       locks++;
   }
 }
Exemple #2
0
 bool lock(vm_pagenum_t pagenum)
 {
   if ( locks > 0 )
   {
     VM_page *found = searchhash(pagenum);
     QASSERT(found != NULL);
     if ( !found->locked )
       locks--;
     found->locked++;
     return true;
   }
   return false;
 }
Exemple #3
0
int scoreWord(Tile word[15])
{
    char tempword[17];
    int tempscore, wordmult=1, index,i=0;
    tempscore = 0;
	for(i = 0;i<15;i++)
	{
		if(word[i].letter==' ') break;
		tempword[i]=word[i].letter;
	}

    tempword[i]=0;

	struct word wordstruct;
	for(i = 0;i<17;i++)
	{
		wordstruct.tempw[i] = tempword[i];
	}

    if(!searchhash(wordstruct))
    {
        return -1;
    }
    else
    {
		for(int i = 0;i<15;i++)
		{
			if(word[i].letter==' ') break;
			index = word[i].letter - 'A';  // find zero-based index for alpha tile score.
		
			      // new tiles get letter and/or word multiplier, if any
			if(word[i].scored==false)
			{
				tempscore += LetterScore[index] * getLetterMul(word[i].type);
				wordmult *= getWordMul(word[i].type);  //Saving the new multiplier into a temporary variable.
			}
			else 
				tempscore += LetterScore[index];
		}
    }    
	// calculate final word score
    return (tempscore * wordmult);
}