Esempio n. 1
0
void markmultiplemat()
{
	for (material *m1=materiallist;m1;m1=m1->next)
	{
		for (material *m=materiallist;m;m=m->next) m->used=true;
		for (material *m2=materiallist;m2;m2=m2->next)
		if (m1!=m2)
		{
			tTexture *t1=findtex(m1->texture);
			tTexture *t2=findtex(m2->texture);
			bool same=true;
			for (int x=0; x<256; x++)
				for (int y=0; y<256; y++)
				{
					if (t1->layers[m1->layer][x][y].a.r!=t2->layers[m2->layer][x][y].a.r ||
						t1->layers[m1->layer][x][y].a.g!=t2->layers[m2->layer][x][y].a.g ||
						t1->layers[m1->layer][x][y].a.b!=t2->layers[m2->layer][x][y].a.b ||
						t1->layers[m1->layer][x][y].a.a!=t2->layers[m2->layer][x][y].a.a) same=false;
				}
				if (same)
				{
					m2->used=false;
					m1->used=true;
					for (scene *s=scenelist;s;s=s->next)
						for (object *o=s->objects;o;o=o->next)
						{
							if (o->objdata.material1==m2->number) o->objdata.material1=m1->number;
							if (o->objdata.material2==m2->number) o->objdata.material2=m1->number;
						}
						for (event *e=eventlist;e;e=e->next)
						{
							if (e->eventtype == layer2d && e->textured && e->texture==m2->number)
							{
								e->texture=m1->number;
							}
						}
				}		
		}
		deleteunmarkedmat();
	}
}
Esempio n. 2
0
void markusedtex()
{
	for (tTexture *t=texturelist;t;t=t->next) t->used=false;
	for (material *m=materiallist;m;m=m->next)
	{
		tTexture *t=findtex(m->texture);
		t->used=true;
		//t=findtex(m->alpha);
		//t->used=true;
		//if (m->alpha!=-1)
	}
}
Esempio n. 3
0
Texture*
gettex(Array *map, const char *name) {
    if(!map || !name)
        return NULL;
    Texture *tex = findtex(map, name);
    if(tex)
        return NULL;

    printf("not found: %s, loading\n", name);
    tex = loadtexstruct(name);
    if(!tex)
        return NULL;
    arraypush(map, &tex);
    qsort(map->ptr, map->nmemb, map->size,
          (int(*)(const void*, const void*))texcmp);
    return tex;
}
Esempio n. 4
0
int parse_root(struct rootinfo *r, const char *command)
{
    r->cptr = command;
    for (;;)
    {
        int s = next_token(r);
cont_1:
        switch (s)
        {
        case E_eos:
            return true;

        case E_help:
            r->help = 1;
            return true;

        default:
            if ('-' == r->token[0])
                return false;
            goto get_img_1;

        case E_tile:
        case E_t:
            goto img_tile;
        case E_full:
        case E_f:
            goto img_full;
        case E_center:
        case E_c:
            goto img_center;

        case E_bitmap:
            s = next_token(r);
            switch (s) {
            case Etile:
            img_tile:
                r->wpstyle = WP_TILE;
                break;
            case Ecenter:
            img_center:
                r->wpstyle = WP_CENTER;
                break;
            case Estretch:
            img_full:
                r->wpstyle = WP_FULL;
                break;
            default:
                goto get_img_1;
            }
        get_img:
            s = next_token(r);
        get_img_1:
            if (E_eos == s) return false;
            if (r->bmp) return false;
            unquote(strcpy(r->wpfile, r->token));
            r->bmp = 1;
            continue;

        case E_solid:
            r->solid = 1;
            s = next_token(r);
            if (s == Einterlaced)
            {
                r->interlaced = true;
                s = next_token(r);
                if (s != E_other)
                    goto cont_1;
            }
            if (false==read_color(r->token, &r->color1)) return false;
            if (r->interlaced) r->color2 = shadecolor(r->color1, -40);
            continue;

        case E_bg:
        case E_background:
        case E_from:
            next_token(r);
            if (false==read_color(r->token, &r->color1)) return false;
            continue;

        case E_to:
            next_token(r);
            if (false==read_color(r->token, &r->color2)) return false;
            continue;

        case E_splitFrom:
            next_token(r);
            if (false==read_color(r->token, &r->color_from)) return false;
            continue;

        case E_splitTo:
            next_token(r);
            if (false==read_color(r->token, &r->color_to)) return false;
            continue;

        case E_fg:
        case E_foreground:
            next_token(r);
            if (false==read_color(r->token, &r->modfg)) return false;
            if (r->solid && r->interlaced)
                r->color2 = r->modfg;
            continue;

        case E_gradient:
            r->gradient = 1;
            r->type = B_HORIZONTAL;
            for (;;) {
                int n, f = 0;
                s = next_token(r);
                if (E_eos == s || '-' == r->token[0]) break;

                n = findtex(r->token, 1);
                if (-1 != n) r->type = n; else ++f;

                n = findtex(r->token, 2);
                if (-1 != n) r->bevelstyle = n; else ++f;

                n = findtex(r->token, 3);
                if (-1 != n) r->bevelposition = n; else ++f;

                n = NULL != strstr(r->token, "interlaced");
                if (0 != n) r->interlaced = true; else ++f;

                if (f==4) break;
            }
            if (r->bevelstyle) {
                if (0 == r->bevelposition)
                    r->bevelposition = BEVEL1;
            } else {
                if (0 != r->bevelposition)
                    r->bevelstyle = BEVEL_RAISED;
            }
            goto cont_1;

        case E_mod:
            r->mod = 1;
            next_token(r);
            if (false == read_int(r->token, &r->modx)) return false;
            next_token(r);
            if (false == read_int(r->token, &r->mody)) return false;
            continue;

        case Einterlaced:
            r->interlaced = true;
            continue;

        case E_hue:
            next_token(r);
            if (!read_int(r->token, &r->hue)) return false;
            continue;

        case E_sat:
            next_token(r);
            if (!read_int(r->token, &r->sat)) return false;
            continue;

        case E_scale:
            next_token(r);
            if (!read_int(r->token, &r->scale)) return false;
            continue;

        case E_vdesk:
            r->vdesk = r->flag;
            continue;

        case E_quiet:
            r->quiet = r->flag;
            continue;

        case E_convert:
            r->convert = r->flag;
            goto get_img;

        case E_save:
            r->save = r->flag;
            if (r->save)
            {
                if (E_eos==next_token(r)) return false;
                unquote(strcpy(r->bsetroot_bmp, r->token));
            }
            continue;

        case E_prefix:
            if (E_eos==next_token(r)) return false;
            unquote(strcpy(r->search_base, r->token));
            continue;

        case E_path:
            if (E_eos==next_token(r)) return false;
            append_string_node(&r->paths, unquote(r->token));
            continue;
        }
    }
}