small code cleanup and optimization

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@2706 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 793133ce0b7d78393cdf8529063b47042500e603
Former-commit-id: 60aae87f15e8ea8de2ffd2710f5cc8150903da45
This commit is contained in:
pouillot 2010-08-28 13:48:44 +00:00
parent eb657248c1
commit b7345f1f99

View file

@ -28,8 +28,7 @@
int doMipMap(const char *tfname, int mipmap)
{
char *buf = (char *) malloc(strlen(tfname)+1);
strcpy(buf, tfname);
char *buf = strdup(tfname);
// find the filename extension.
char *s = strrchr(buf, '.');
@ -40,23 +39,21 @@ int doMipMap(const char *tfname, int mipmap)
// search for the texture parameters.
s = strrchr(buf, '_');
// no mipmap for "_n" and "shadow".
if (s) {
// check the "_n".
if (strncmp(s, "_n", 4) == 0) {
mipmap = FALSE;
}
// 1) no mipmap for "*_n".
if (s && s[1] == 'n') {
mipmap = FALSE;
}
// 1) no mipmap for "*shadow*".
if (mipmap) {
// Check the shadow.
s = strrchr((char *)tfname, '/');
if (!s) {
s = (char *) tfname;
s = (char*)tfname;
} else {
s++;
}
if (strstr(s, "shadow") != NULL) {
if (strstr(s, "shadow")) {
mipmap = FALSE;
}
}