Пример #1
0
/**
 * Find length of a string from the symbol table. To be
 * used only with print symbol table function.
 * @param  name
 * @param  list
 * @param  flag
 * @return
 */
int findLength(char* name, STList list, int flag)
{
	STList readList = list;
	if(list->stringTable->stringName != NULL)
	{
		stringSizes strings = readList->stringTable;
		while(strings->stringName != NULL)
		{
			if(strcmp(strings->stringName,name))
				strings = strings->nextEntry;
			else
				return strings->length;
			if(strings->stringName == NULL)
			{
				int length = 0;
				if(readList->parentList != NULL)
				{
					readList = readList->parentList;
					length = findLength(name,readList,1);
				}
				if(length == 0 && flag)
				{
					if(readList->sisterList != NULL)
					{
						length = findLength(name,readList->sisterList,1);
					}
				}
				return length;
			}
		}
	}
	return 0;
}
 void findLength(TreeNode* node, TreeNode* parent, int pre, int& maxLen) {
     if (!node) return;
     int cur = 1 + (parent && parent->val + 1 == node->val ? pre : 0); // 运算符优先级啊少女w 教会了我们白板不要一行写太长
     maxLen = max(cur, maxLen);
     findLength(node->left, node, cur, maxLen);
     findLength(node->right, node, cur, maxLen);
 }
 int findLength(TreeNode* node, int& maxLength) {
     if (!node) return 0;
     int leftLen = findLength(node->left, maxLength);
     int rightLen = findLength(node->right, maxLength);
     int len = max(node->left && node->val + 1 == node->left->val ? leftLen : 0,
                   node->right && node->val + 1 == node->right->val ? rightLen : 0) + 1;
     maxLength = max(len, maxLength);
     return len;
 }
Пример #4
0
int main(int argc, char *argv[]) {

  int i, bound;
  char *output;
  struct bigNum test;
  output = (char*)malloc(sizeof(char)*200);

  FILE *fin = fopen("buylow.in", "r");
  FILE *fout = fopen("buylow.out", "w");
  assert(fin); assert(fout);

  // 初始化
  for(i = 0; i < M; i++) memory[i] = -1;
  for(i = 0; i < M; i++) {
    total[i].list[0] = 0;
    total[i].length = 1;
  }

  // 读取
  fscanf(fin, "%d", &price[0]);
  bound = 0;
  for(i = 1; i <= price[0]; i++) {
    fscanf(fin, "%d", &price[i]);
    if (bound < price[i]) bound = price[i];
  }

  // 计算
  bound = findLength(bound + 1, 1);
  findSequences(bound, output);
  fprintf(fout, "%d %s\n", bound, output);

  fclose(fin);
  fclose(fout);
  return 0;
}
int main()
{
	int n;
	n = findLength(tests[0].arr);
	printf("%d", n);
	getchar();
	return 0;
}
int main(void)
{
    // Initialization.
    int currNum = 0, nextNum = 0
                               ,num = 0, lengthNum = 0, temp = 0, powed = 0, templen = 0, powed2 = 0;

    // Take our Input.
    printf("Please type in your number > ");
    scanf("%d", &num);

    // Checking if the number is greater than our Maximum range.
    if(num > MAX_RANGE) {
        printf("Sorry your number is out of range.\n");
        return OUT_OF_RANGE;
    }

    // Calculate the length of our number.
    lengthNum = findLength(num);

    // Our loop to convert number to words.
    printf("In Words: ");

    currNum = num;                      // Setting our current number to our input.
    lengthNum = findLength(currNum);    // Finding the current length.

    while(lengthNum > 0) {

        // Hundreds.
        if (lengthNum <= 3) {
            toHundreds(currNum, lengthNum);
            lengthNum = lengthNum - 3;
        }

        // Thousands
        else if (lengthNum > 3 && lengthNum <= 6)
            upHundrends(currNum, 3, "Thousand", &nextNum, &lengthNum);

        // Million.
        else if(lengthNum > 6 && lengthNum <= 9)
            upHundrends(currNum, 6, "Million", &nextNum, &lengthNum);

        // Setting the rest of the number as the current number to deal with.
        currNum = nextNum;
    }
}
Пример #7
0
int findLength(int bound, int idx) {
  int i = idx, skip, pIdx = 0, psIdx = 0;

  for(; i <= price[0]; i++) {
    // 不符合的情况跳过不用计算
    if (price[i] >= bound) continue;

    // 将选择这个数能得到最长的序列长度记录下来
    if (memory[i] == -1) {
      memory[i] = findLength(price[i], idx + 1) + 1;
    }

    // 计算:不选这个数,能得到的最长序列长度
    skip = findLength(bound, idx + 1);

    // 返回最优情况
    return max(skip, memory[i]);
  }
  return 0;
}
Пример #8
0
	void printAllWords(HashTable *hashTable, int len){
		for (int i = 0; i < base; i++)
			if (findLength(hashTable->cells[i]) == len){
				HashCell *tmp = hashTable->cells[i];
				while (tmp != nullptr){
					print(tmp->key);
					tmp = tmp->next;
				}

			}
	}
int merge_circularlists(struct node **head1, struct node **head2){
	//Returns Length of merged Sorted circular SLL and also points *head1 to final SLL .
	if (*head1 == NULL || *head2 == NULL)
		return -1;
	struct node *temp1 = *head1, *temp2 = *head2, *start = NULL, *start1 = NULL;
	if (temp1->data <= temp2->data)
	{
		start = temp1;
		temp1 = temp1->next;
	}
	else{
		start = temp2;
		temp2 = temp2->next;
	}
	start1 = start;
	while (temp1!= *head1 || temp2 != *head2)
	{
		if (temp1 == *head1 && temp2 == *head2)
			break;
		if (temp1->data <= temp2->data)
		{
			start1->next = temp1;
			start1 = start1->next;
			temp1 = temp1->next;
		}
		else{
			start1->next = temp2;
			start1 = start1->next;
			temp2 = temp2->next;
		}
	}
	if (temp1!= *head1)
	{
		while (temp1!= *head1){
			start1->next = temp1;
			start1 = start1->next;
			temp1 = temp1->next;
		}
	}
	if (temp2!= *head2)
	{
		while (temp2 != *head2){
			start1->next = temp2;
			start1 = start1->next;
			temp2 = temp2->next;
		}
	}
	start1->next = start;
	*head1 = start;
	return findLength(*head1);

}
Пример #10
0
int main () {
    int array[MAXN][MAXN];
    int N, r, c;
    int direction[4][2] = {{1,0}, {1,1}, {0,1}, {-1,1}};
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            scanf("%d", &array[i][j]);
    scanf("%d%d", &r, &c);
    for (int i = 0; i < 4; i++)
        printf("%d\n", findLength(array, N, r, c, direction[i][0], direction[i][1]));
    return 0;
}
Пример #11
0
/**
 * Print the symbol table in the specified format.
 * @param list
 */
void printSymbolTable(STList list)
{
	int a = 0;
	STList readList = list;
	while(readList != NULL)
	{
		STable entry = readList->table;
		while(entry->data != NULL)
		{
			printf("%20s%16s(%2d-%2d)%16s",entry->data->value,readList->functionName,readList->startLineNumber,readList->endLineNumber,getTokenName(entry->data->type));
			if(entry->data->type == NUM || entry->data->type == INT)
			{
				printf("%s","    ");
				printf("%15d",a);
				a = a+2;
			}
			else if(entry->data->type == RNUM || entry->data->type == REAL)
			{
				printf("%s","    ");
				printf("%15d",a);
				a= a+4;
			}
			else if(entry->data->type == STR || entry->data->type == STRING)
			{
				printf("%s","    ");
				printf("%15d",a);
				a = a + findLength(entry->data->value,readList,0);
			}
			else if(entry->data->type == MATRIX)
			{
				matrixSizes mat = findMatrix(entry->data->value,readList);
				if(mat == NULL)
				{
					printf(",0,0");
				}
				else
				{
					printf(",%d,%d",mat->rows,mat->columns);
				}
			}
			printf("\n");
			entry = entry->nextEntry;
		}
		if(readList->childList != NULL)
			printSymbolTable(readList->childList);
		if(readList->sisterList != NULL)
			readList = readList->sisterList;
		else
			readList = NULL;
	}
}
/*
 * This function converts integer in
 * between thousand and million and turns
 * them in to words.
 */
void upHundrends(int currNum, int power, char *unit, int *nextNum, int *lengthNum)
{
    // Initialization.
    int powed = 0, temp = 0, len = 0;


    powed = ceil(pow(10, power)); // Calculating the power of 10 we need.
    temp = currNum / powed;       // Getting or current number.
    len = findLength(temp);       // finding the length of the number we extracted.
    toHundreds(temp, len);        // Converting our numbers to words in hundreds.
    *lengthNum -= len;            // Removing the length of our current number from the original length.
    *nextNum = currNum % powed;   // Extracting the rest of our numbers we didn't use.
    printf("%s ", unit);          // Printing our units.
}
 int findLength(vector<int>& A, vector<int>& B) {
     if (A.size() > B.size()) {
         return findLength(B, A);
     }
     int left = 0, right = min(A.size(), B.size()) + 1;
     while (left < right) {
         const auto mid = left + (right-left) / 2;
         if (!check(mid, A, B)) {  // find the min idx such that check(idx) == false
             right = mid;
         } else {
             left = mid + 1;
         }
     }
     return left - 1;
 }
 int findLength(vector<int>& A, vector<int>& B) {
     if (A.size() < B.size()) { 
         return findLength(B, A);
     }
     int result = 0;
     vector<vector<int>> dp(2, vector<int>(B.size() + 1));
     for (int i = 0; i < A.size(); ++i) {
         for (int j = 0; j < B.size(); ++j) {
             if (A[i] == B[j]) {
                 dp[(i + 1) % 2][j + 1] = dp[i % 2][j] + 1;
                 result = max(result, dp[(i + 1) % 2][j + 1]);
             } else {
                 dp[(i + 1) % 2][j + 1] = 0;
             }
         }
     }
     return result;
 }
 int longestConsecutive(TreeNode* root) {
     int res = 0;
     findLength(root, nullptr, 0, res);
     return res;
 }
Пример #16
0
	int numberOfEmptyCell(HashTable *hashTable){
		int res = 0;
		for (int i = 0; i < base; i++)
			res += (findLength(hashTable->cells[i]) == 0);
		return res;
	}
Пример #17
0
	int numOfAddedWords(HashTable *hashTable){
		int res = 0;
		for (int i = 0; i < base; i++)
			res += findLength(hashTable->cells[i]);
		return res;
	}
main()
{
	//calling the function
	findLength();
}
Пример #19
0
	int findMaxLength(HashTable *hashTable){
		int res = -1;
		for (int i = 0; i < base; i++)
			res = max(res, findLength(hashTable->cells[i]));
		return res;
	}
Пример #20
0
	float middleLength(HashTable *hashTable){
		float res = 0;
		for (int i = 0; i < base; i++)
			res += findLength(hashTable->cells[i]) / (0.0 + base);
		return res;
	}
node *sortedToBST(node *head){
	int len=findLength(head);
	return sortedToBSTUtil(&head,len);
}
Пример #22
0
void Sprites::Draw()
{
	static int i,j,k;
	static float M[16];
	static XYZ point;
	static float distancemult;
	static int lasttype;
	static int lastspecial;
	static int whichpatchx,whichpatchz;
	static XYZ start,end,colpoint;
	static bool check;
	static bool blend;
	static float tempmult;
	static XYZ difference;
	static float lightcolor[3];
	static float viewdistsquared=viewdistance*viewdistance;
	static XYZ tempviewer;

	tempviewer=viewer+viewerfacing*6;
	check=0;

	lightcolor[0]=light.color[0]*.5+light.ambient[0];
	lightcolor[1]=light.color[1]*.5+light.ambient[1];
	lightcolor[2]=light.color[2]*.5+light.ambient[2];

	checkdelay-=multiplier*10;

	if(checkdelay<=0){
		check=1;
		checkdelay=1;
	}

	lasttype=-1;
	lastspecial=-1;
	glEnable(GL_BLEND);
	glDisable(GL_LIGHTING);
	glDisable(GL_CULL_FACE);
	glEnable(GL_TEXTURE_2D);
	blend = 1;
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
	glDepthMask(0);
	glAlphaFunc(GL_GREATER, 0.0001);
	for(i=0;i<numsprites;i++){
		if(type[i]==cloudsprite&&lasttype!=type[i]){
			glBindTexture( GL_TEXTURE_2D, cloudtexture);
			if(!blend){
				blend=1;
				glAlphaFunc(GL_GREATER, 0.0001);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			}
		}
		if(type[i]==cloudimpactsprite&&lasttype!=type[i]){
			glBindTexture( GL_TEXTURE_2D, cloudimpacttexture);
			if(!blend){
				blend=1;
				glAlphaFunc(GL_GREATER, 0.0001);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			}
		}
		if(type[i]==breathsprite&&lasttype!=type[i]){
			glBindTexture( GL_TEXTURE_2D, cloudimpacttexture);
			if(!blend){
				blend=1;
				glAlphaFunc(GL_GREATER, 0.0001);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			}
		}
		if(type[i]==smoketype&&lasttype!=type[i]){
			glBindTexture( GL_TEXTURE_2D, smoketexture);
			if(!blend){
				blend=1;
				glAlphaFunc(GL_GREATER, 0.0001);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			}
		}
		if(type[i]==bloodsprite&&lasttype!=type[i]){
			glBindTexture( GL_TEXTURE_2D, bloodtexture);
			if(!blend){
				blend=1;
				glAlphaFunc(GL_GREATER, 0.0001);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			}
		}
		if(type[i]==splintersprite&&(lasttype!=type[i]||lastspecial!=special[i])){
			if(special[i]==0)glBindTexture( GL_TEXTURE_2D, splintertexture);
			if(special[i]==1)glBindTexture( GL_TEXTURE_2D, leaftexture);
			if(special[i]==2)glBindTexture( GL_TEXTURE_2D, snowflaketexture);
			if(special[i]==3)glBindTexture( GL_TEXTURE_2D, toothtexture);
			if(!blend){
				blend=1;
				glAlphaFunc(GL_GREATER, 0.0001);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			}
		}
		if(type[i]==snowsprite&&lasttype!=type[i]){
			glBindTexture( GL_TEXTURE_2D, snowflaketexture);
			if(!blend){
				blend=1;
				glAlphaFunc(GL_GREATER, 0.0001);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			}
		}
		if(type[i]==weaponshinesprite&&lasttype!=type[i]){
			glBindTexture( GL_TEXTURE_2D, shinetexture);
			if(blend){
				blend=0;
				glAlphaFunc(GL_GREATER, 0.001);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE);
			}
		}
		if((type[i]==flamesprite||type[i]==weaponflamesprite)&&lasttype!=type[i]){
			glBindTexture( GL_TEXTURE_2D, flametexture);
			if(blend||lasttype==bloodflamesprite){
				blend=0;
				glAlphaFunc(GL_GREATER, 0.3);
				glBlendFunc(GL_SRC_ALPHA,GL_ONE);
			}
		}
		if((type[i]==bloodflamesprite)&&lasttype!=type[i]){
			glBindTexture( GL_TEXTURE_2D, bloodflametexture);
			if(blend){
				blend=0;
				glAlphaFunc(GL_GREATER, 0.3);
				glBlendFunc(GL_ONE,GL_ZERO);
				//glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
			}
		}
		if(type[i]!=snowsprite)distancemult=(viewdistsquared-(findDistancefast(&viewer,&position[i])-(viewdistsquared*fadestart))*(1/(1-fadestart)))/viewdistsquared;
		if(type[i]==snowsprite)distancemult=(144-(findDistancefast(&tempviewer,&position[i])-(144*fadestart))*(1/(1-fadestart)))/144;
		if(type[i]!=flamesprite){
			if(distancemult>=1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],opacity[i]);
			if(distancemult<1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],opacity[i]*distancemult);
		}
		if(type[i]==flamesprite){
			if(distancemult>=1)glColor4f(color[i][0],color[i][1],color[i][2],opacity[i]);
			if(distancemult<1)glColor4f(color[i][0],color[i][1],color[i][2],opacity[i]*distancemult);
		}
		lasttype=type[i];
		lastspecial=special[i];
		glMatrixMode(GL_MODELVIEW);							// Select The Modelview Matrix
		glPushMatrix();
			glTranslatef(position[i].x,position[i].y,position[i].z);
			if((type[i]==flamesprite||type[i]==weaponflamesprite||type[i]==weaponshinesprite)){
				difference=viewer-position[i];
				Normalise(&difference);
				glTranslatef(difference.x*size[i]/4, difference.y*size[i]/4, difference.z*size[i]/4);
			}
			if(type[i]==snowsprite){
				glRotatef(rotation[i]*.2,0,.3,1);
				glTranslatef(1,0,0);
			}
			glGetFloatv(GL_MODELVIEW_MATRIX,M);
			point.x=M[12];
			point.y=M[13];
			point.z=M[14];
			glLoadIdentity();
			glTranslatef(point.x, point.y, point.z);

			glRotatef(rotation[i],0,0,1);

			if((type[i]==flamesprite||type[i]==weaponflamesprite||type[i]==weaponshinesprite||type[i]==bloodflamesprite)){
				if(alivetime[i]<.14)glScalef(alivetime[i]/.14,alivetime[i]/.14,alivetime[i]/.14);
			}
			if(type[i]==smoketype||type[i]==snowsprite||type[i]==weaponshinesprite||type[i]==breathsprite){
				if(alivetime[i]<.3){
					if(distancemult>=1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],opacity[i]*alivetime[i]/.3);
					if(distancemult<1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],opacity[i]*distancemult*alivetime[i]/.3);
				}
			}
			if(type[i]==splintersprite&&special[i]>0&&special[i]!=3){
				if(alivetime[i]<.2){
					if(distancemult>=1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],alivetime[i]/.2);
					if(distancemult<1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],distancemult*alivetime[i]/.2);
				}
				else{
					if(distancemult>=1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],1);
					if(distancemult<1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],1);
				}
			}
			if(type[i]==splintersprite&&(special[i]==0||special[i]==3)){
				if(distancemult>=1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],1);
				if(distancemult<1)glColor4f(color[i][0]*lightcolor[0],color[i][1]*lightcolor[1],color[i][2]*lightcolor[2],1);
			}
			/*
			if(type[i]==snowsprite){
			glRotatef(rotation[i],0,0,1);
			glTranslatef(1,0,0);
			}*/

			glBegin(GL_TRIANGLES);
			glTexCoord2f(1.0f, 1.0f); glVertex3f( .5*size[i], .5*size[i], 0.0f);
			glTexCoord2f(0.0f, 1.0f); glVertex3f(-.5*size[i], .5*size[i], 0.0f);
			glTexCoord2f(1.0f, 0.0f); glVertex3f( .5*size[i],-.5*size[i], 0.0f);
			glTexCoord2f(0.0f, 0.0f); glVertex3f(-.5*size[i],-.5*size[i], 0.0f);
			glTexCoord2f(1.0f, 0.0f); glVertex3f( .5*size[i], -.5*size[i], 0.0f);
			glTexCoord2f(0.0f, 1.0f); glVertex3f(-.5*size[i], .5*size[i], 0.0f);
			glEnd();
		glPopMatrix();
	}
	tempmult=multiplier;
	for(i=numsprites-1;i>=0;i--){
		multiplier=tempmult;
		if(type[i]!=snowsprite)position[i]+=velocity[i]*multiplier;
		if(type[i]!=snowsprite)velocity[i]+=windvector*multiplier;
		if(type[i]==flamesprite||type[i]==smoketype)position[i]+=windvector*multiplier/2;
		if((type[i]==flamesprite||type[i]==weaponflamesprite||type[i]==weaponshinesprite||type[i]==bloodflamesprite))multiplier*=speed[i]*.7;
		alivetime[i]+=multiplier;

		if(type[i]==cloudsprite||type[i]==cloudimpactsprite){
			opacity[i]-=multiplier/2;
			size[i]+=multiplier/2;
			velocity[i].y+=gravity*multiplier*.25;
		}
		if(type[i]==breathsprite){
			opacity[i]-=multiplier/2;
			size[i]+=multiplier/2;
			if(findLength(&velocity[i])<=multiplier)velocity[i]=0;
			else{
				XYZ slowdown;
				slowdown=velocity[i]*-1;
				Normalise(&slowdown);
				slowdown*=multiplier;
				velocity[i]+=slowdown;
			}
		}
		if(type[i]==snowsprite){
			size[i]-=multiplier/120;
			rotation[i]+=multiplier*360;
			position[i].y-=multiplier;
			position[i]+=windvector*multiplier;
			if(position[i].y<tempviewer.y-6)position[i].y+=12;
			if(position[i].y>tempviewer.y+6)position[i].y-=12;
			if(position[i].z<tempviewer.z-6)position[i].z+=12;
			if(position[i].z>tempviewer.z+6)position[i].z-=12;
			if(position[i].x<tempviewer.x-6)position[i].x+=12;
			if(position[i].x>tempviewer.x+6)position[i].x-=12;
		}
		if(type[i]==bloodsprite){
			bool spritehit=0;
			rotation[i]+=multiplier*100;
			velocity[i].y+=gravity*multiplier;
			if(check){
				XYZ where,startpoint,endpoint,movepoint,footpoint;
				float rotationpoint;
				int whichtri;

				for(j=0;j<numplayers;j++){
					if(!spritehit&&player[j].dead&&alivetime[i]>.1){
						where=oldposition[i];
						where-=player[j].coords;
						if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].rotation,0);
						startpoint=where;
						where=position[i];
						where-=player[j].coords;
						if(!player[j].skeleton.free)where=DoRotation(where,0,-player[j].rotation,0);
						endpoint=where;

						movepoint=0;
						rotationpoint=0;
						whichtri=player[j].skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
						if(whichtri!=-1){
							spritehit=1;
							player[j].DoBloodBigWhere(0,160,oldposition[i]);
							DeleteSprite(i);
						}
					}
				}

				whichpatchx=position[i].x/(terrain.size/subdivision*terrain.scale*terraindetail);
				whichpatchz=position[i].z/(terrain.size/subdivision*terrain.scale*terraindetail);
				if(whichpatchx>0&&whichpatchz>0&&whichpatchx<subdivision&&whichpatchz<subdivision)
					if(terrain.patchobjectnum[whichpatchx][whichpatchz]){
						if(!spritehit)
							for(j=0;j<terrain.patchobjectnum[whichpatchx][whichpatchz];j++){
								k=terrain.patchobjects[whichpatchx][whichpatchz][j];
								start=oldposition[i];
								end=position[i];
								if(!spritehit)
									if(objects.model[k].LineCheck(&start,&end,&colpoint,&objects.position[k],&objects.rotation[k])!=-1){
										if(detail==2||(detail==1&&abs(Random()%4)==0)||(detail==0&&abs(Random()%8)==0))objects.model[k].MakeDecal(blooddecalfast,DoRotation(colpoint-objects.position[k],0,-objects.rotation[k],0),size[i]*1.6/*+abs((float)(Random()%100))/2400*/,.5,Random()%360);
										DeleteSprite(i);
										spritehit=1;
									}	
							}
					}
					if(!spritehit)
						if(position[i].y<terrain.getHeight(position[i].x,position[i].z)){
							terrain.MakeDecal(blooddecalfast,position[i],size[i]*1.6/*+abs((float)(Random()%100))/2400*/,.6,Random()%360);
							DeleteSprite(i);
						}
			}
		}
		if(type[i]==splintersprite){
			rotation[i]+=rotatespeed[i]*multiplier;
			opacity[i]-=multiplier/2;
			if(special[i]==0||special[i]==2||special[i]==3)velocity[i].y+=gravity*multiplier;
			if(special[i]==1)velocity[i].y+=gravity*multiplier*.5;
		}
		if(type[i]==flamesprite||type[i]==weaponflamesprite||type[i]==weaponshinesprite||type[i]==bloodflamesprite){
			rotation[i]+=multiplier*rotatespeed[i];
			opacity[i]-=multiplier*5/4;
			if(type[i]!=weaponshinesprite&&type[i]!=bloodflamesprite)
				if(opacity[i]<.5&&opacity[i]+multiplier*5/4>=.5&&(abs(Random()%4)==0||(initialsize[i]>2&&Random()%2==0)))MakeSprite(smoketype, position[i],velocity[i], .9,.9,.6, size[i]*1.2, .4);
			if(alivetime[i]>.14&&(type[i]==flamesprite)){
				velocity[i]=0;
				velocity[i].y=1.5;
			}
		}
		/*if(type[i]==smoketype){
		opacity[i]-=multiplier/3/initialsize[i];
		size[i]+=multiplier;
		velocity[i]=0;
		velocity[i].y=1.5;
		rotation[i]+=multiplier*rotatespeed[i]/5;
		}*/
		if(type[i]==smoketype){
			opacity[i]-=multiplier/3/initialsize[i];
			color[i][0]-=multiplier;
			color[i][1]-=multiplier;
			color[i][2]-=multiplier;
			if(color[i][0]<.6)color[i][0]=.6;
			if(color[i][1]<.6)color[i][1]=.6;
			if(color[i][2]<.6)color[i][2]=.6;
			size[i]+=multiplier;
			velocity[i]=0;
			velocity[i].y=1.5;
			rotation[i]+=multiplier*rotatespeed[i]/5;
		}
		if(opacity[i]<=0||size[i]<=0)DeleteSprite(i);
	}
	if(check)
		for(i=numsprites-1;i>=0;i--){
			oldposition[i]=position[i];
		}
		glAlphaFunc(GL_GREATER, 0.0001);
		glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
}