Commit

sezero committed 74f701f

dday: rewrite strcmpwld()
As far as I can understand that stupid code, it searches the string
'check' in string 'given', like strstr(), but in a case-insensitive
way. So, unbreak it and make it to use strstr()

Comments (0)

Files changed (1)

File dday/g_misc.c Modified

View file
  • Ignore whitespace
  • Hide word diff
 
 qboolean strcmpwld (char *give, char *check)
 {
-	int i, j, givenlength, checklength;
+	char tmp[64]; /* csurface_t->name is [16] */
 
-	givenlength = strlen(give);
-	checklength = strlen(check);
+	strcpy (tmp, give);
+	Q_strlwr (tmp); // pbowens: use tolower() for editors like worldcraft
 
-	for (i = 0; i < givenlength; i++)
-	{
-		char checked[100];
-		checked[0] = 0;
-
-		for (j=i; j<checklength+i; j++)
-		{
-			// pbowens: use tolower() for editors like worldcraft
-			// SZO: WTF???
-			Com_sprintf (checked, sizeof(checked), "%s%c", &checked, tolower(give[j]));
-		}
-		if (!strcmp(check, (char *)(&checked)))
-			return true;
-	}
+	if (strstr(tmp, check))
+		return true;
 
 	return false;
 }