Пример #1
0
int
create_tile_hash(void)
{
    struct tile_head *th;
    int len,maxnamelen=0;

    tile_hash2=g_hash_table_new(g_str_hash, g_str_equal);
    th=tile_head_root;
    while (th) {
        len=add_tile_hash(th);
        if (len > maxnamelen)
            maxnamelen=len;
        th=th->next;
    }
    return maxnamelen;
}
Пример #2
0
static void
create_tile_hash_list(GList *list)
{
    GList *next;
    struct tile_head *th;

    tile_hash2=g_hash_table_new(g_str_hash, g_str_equal);

    next=g_list_first(list);
    while (next) {
        th=g_hash_table_lookup(tile_hash, next->data);
        if (!th) {
            fprintf(stderr,"No tile found for '%s'\n", (char *)(next->data));
        }
        add_tile_hash(th);
        next=g_list_next(next);
    }
}
Пример #3
0
void
load_tilesdir(FILE *in)
{
	char tile[32],subtile[32],c;
	int size,zipnum=0;
	struct tile_head **last;
	create_tile_hash();
	tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
	last=&tile_head_root;
	while (fscanf(in,"%[^:]:%d",tile,&size) == 2) {
		struct tile_head *th=malloc(sizeof(struct tile_head));
		if (!strcmp(tile,"index"))
			tile[0]='\0';
		th->num_subtiles=0;
		th->total_size=size;
		th->total_size_used=0;
		th->zipnum=zipnum++;
		th->zip_data=NULL;
		th->name=string_hash_lookup(tile);
#if 0
		printf("tile '%s' %d\n",tile,size);
#endif
		while (fscanf(in,":%[^:\n]",subtile) == 1) {
#if 0
			printf("subtile '%s'\n",subtile);
#endif
			th=realloc(th, sizeof(struct tile_head)+(th->num_subtiles+1)*sizeof(char*));
			*th_get_subtile( th, th->num_subtiles ) = string_hash_lookup(subtile);
			th->num_subtiles++;
		}
		*last=th;
		last=&th->next;
		add_tile_hash(th);
		g_hash_table_insert(tile_hash, th->name, th);
		if (fread(&c, 1, 1, in) != 1 || c != '\n') {
			printf("syntax error\n");
		}
	}
	*last=NULL;
}