… | |
… | |
555 | return g_strdup_printf("%s/%s", dir, filename); |
555 | return g_strdup_printf("%s/%s", dir, filename); |
556 | } |
556 | } |
557 | |
557 | |
558 | static int binfile_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) |
558 | static int binfile_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) |
559 | { |
559 | { |
560 | #ifdef NAVIT_FUNC_CALLS_DEBUG_PRINT |
|
|
561 | dbg(0,"+#+:enter\n"); |
|
|
562 | #endif |
|
|
563 | |
|
|
564 | // try to return "0" on any problem, to avoid crash!! |
560 | // try to return "0" on any problem, to avoid crash!! |
565 | |
561 | |
566 | struct map_rect_priv *mr = priv_data; |
562 | struct map_rect_priv *mr = priv_data; |
567 | struct tile *t = mr->t; |
563 | struct tile *t = mr->t; |
568 | enum attr_type type; |
564 | enum attr_type type; |
… | |
… | |
1433 | m->download = download; |
1429 | m->download = download; |
1434 | g_free(m->progress); |
1430 | g_free(m->progress); |
1435 | if (download->mr) |
1431 | if (download->mr) |
1436 | m->progress = g_strdup_printf("Download Tile %d 0%%", download->zipfile); |
1432 | m->progress = g_strdup_printf("Download Tile %d 0%%", download->zipfile); |
1437 | else |
1433 | else |
1438 | m->progress = g_strdup_printf("Download Map Information 0%%"); |
1434 | m->progress = g_strdup("Download Map Information 0%%"); |
1439 | callback_list_call_attr_0(m->cbl, attr_progress); |
1435 | callback_list_call_attr_0(m->cbl, attr_progress); |
1440 | return NULL; |
1436 | return NULL; |
1441 | } |
1437 | } |
1442 | for (;;) |
1438 | for (;;) |
1443 | { |
1439 | { |
… | |
… | |
1493 | else |
1489 | else |
1494 | download->state = 0; |
1490 | download->state = 0; |
1495 | break; |
1491 | break; |
1496 | case 5: |
1492 | case 5: |
1497 | g_free(m->progress); |
1493 | g_free(m->progress); |
1498 | m->progress = g_strdup_printf("Download Map Information 50%%"); |
1494 | m->progress = g_strdup("Download Map Information 50%%"); |
1499 | callback_list_call_attr_0(m->cbl, attr_progress); |
1495 | callback_list_call_attr_0(m->cbl, attr_progress); |
1500 | if (download_eoc(download)) |
1496 | if (download_eoc(download)) |
1501 | download->state = 6; |
1497 | download->state = 6; |
1502 | else |
1498 | else |
1503 | { |
1499 | { |
… | |
… | |
1505 | download->state = 0; |
1501 | download->state = 0; |
1506 | } |
1502 | } |
1507 | break; |
1503 | break; |
1508 | case 6: |
1504 | case 6: |
1509 | g_free(m->progress); |
1505 | g_free(m->progress); |
1510 | m->progress = g_strdup_printf("Download Map Information 100%%"); |
1506 | m->progress = g_strdup("Download Map Information 100%%"); |
1511 | callback_list_call_attr_0(m->cbl, attr_progress); |
1507 | callback_list_call_attr_0(m->cbl, attr_progress); |
1512 | if (download_directory_start(download)) |
1508 | if (download_directory_start(download)) |
1513 | download->state = 7; |
1509 | download->state = 7; |
1514 | else |
1510 | else |
1515 | download->state = 0; |
1511 | download->state = 0; |
… | |
… | |
1823 | struct coord c[2]; |
1819 | struct coord c[2]; |
1824 | struct attr at; |
1820 | struct attr at; |
1825 | struct range mima; |
1821 | struct range mima; |
1826 | if (binfile_coord_get(mr->item.priv_data, c, 2) != 2) |
1822 | if (binfile_coord_get(mr->item.priv_data, c, 2) != 2) |
1827 | return 0; |
1823 | return 0; |
|
|
1824 | |
1828 | r.lu.x = c[0].x; |
1825 | r.lu.x = c[0].x; |
1829 | r.lu.y = c[1].y; |
1826 | r.lu.y = c[1].y; |
1830 | r.rl.x = c[1].x; |
1827 | r.rl.x = c[1].x; |
1831 | r.rl.y = c[0].y; |
1828 | r.rl.y = c[0].y; |
1832 | if (!binfile_attr_get(mr->item.priv_data, attr_order, &at)) |
1829 | if (!binfile_attr_get(mr->item.priv_data, attr_order, &at)) |
1833 | return 0; |
1830 | return 0; |
|
|
1831 | |
1834 | #if __BYTE_ORDER == __BIG_ENDIAN |
1832 | #if __BYTE_ORDER == __BIG_ENDIAN |
1835 | mima.min = le16_to_cpu(at.u.range.max); |
1833 | mima.min = le16_to_cpu(at.u.range.max); |
1836 | mima.max = le16_to_cpu(at.u.range.min); |
1834 | mima.max = le16_to_cpu(at.u.range.min); |
1837 | #else |
1835 | #else |
1838 | mima=at.u.range; |
1836 | mima=at.u.range; |
… | |
… | |
2326 | |
2324 | |
2327 | static gboolean duplicate_equal(gconstpointer a, gconstpointer b) |
2325 | static gboolean duplicate_equal(gconstpointer a, gconstpointer b) |
2328 | { |
2326 | { |
2329 | const struct duplicate *da = a; |
2327 | const struct duplicate *da = a; |
2330 | const struct duplicate *db = b; |
2328 | const struct duplicate *db = b; |
2331 | return (da->c.x == db->c.x && da->c.y == da->c.y && g_str_equal(da->str, db->str)); |
2329 | return (da->c.x == db->c.x && da->c.y == db->c.y && g_str_equal(da->str, db->str)); |
2332 | } |
2330 | } |
|
|
2331 | |
2333 | |
2332 | |
2334 | static int duplicate(struct map_search_priv *msp, struct item *item, enum attr_type attr_type) |
2333 | static int duplicate(struct map_search_priv *msp, struct item *item, enum attr_type attr_type) |
2335 | { |
2334 | { |
2336 | struct attr attr; |
2335 | struct attr attr; |
|
|
2336 | |
2337 | if (!msp->search_results) |
2337 | if (!msp->search_results) |
|
|
2338 | { |
2338 | msp->search_results = g_hash_table_new_full(duplicate_hash, duplicate_equal, g_free_func, NULL); |
2339 | msp->search_results = g_hash_table_new_full(duplicate_hash, duplicate_equal, g_free_func, NULL); |
|
|
2340 | } |
|
|
2341 | |
2339 | binfile_attr_rewind(item->priv_data); |
2342 | binfile_attr_rewind(item->priv_data); |
|
|
2343 | |
2340 | if (!item_attr_get(item, attr_type, &attr)) |
2344 | if (!item_attr_get(item, attr_type, &attr)) |
|
|
2345 | { |
2341 | return 1; |
2346 | return 1; |
|
|
2347 | } |
|
|
2348 | |
2342 | { |
2349 | { |
2343 | int len = sizeof(struct coord) + strlen(attr.u.str) + 1; |
2350 | int len = sizeof(struct coord) + strlen(attr.u.str) + 1; |
2344 | char *buffer = g_alloca(sizeof(char) * len); |
2351 | char *buffer = g_alloca(sizeof(char) * len); |
2345 | struct duplicate *d = (struct duplicate *) buffer; |
2352 | struct duplicate *d = (struct duplicate *) buffer; |
2346 | if (!item_coord_get(item, &d->c, 1)) |
2353 | if (!item_coord_get(item, &d->c, 1)) |
… | |
… | |
3084 | map_binfile_close(m); |
3091 | map_binfile_close(m); |
3085 | map_binfile_open(m); |
3092 | map_binfile_open(m); |
3086 | } |
3093 | } |
3087 | } |
3094 | } |
3088 | |
3095 | |
3089 | static struct map_priv * |
3096 | struct map_priv * |
3090 | map_new_binfile(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) |
3097 | map_new_binfile(struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) |
3091 | { |
3098 | { |
3092 | struct map_priv *m; |
3099 | struct map_priv *m; |
3093 | struct attr *data = attr_search(attrs, NULL, attr_data); |
3100 | struct attr *data = attr_search(attrs, NULL, attr_data); |
3094 | struct attr *check_version, *map_pass, *flags, *url, *download_enabled; |
3101 | struct attr *check_version, *map_pass, *flags, *url, *download_enabled; |
… | |
… | |
3142 | load_changes(m); |
3149 | load_changes(m); |
3143 | } |
3150 | } |
3144 | return m; |
3151 | return m; |
3145 | } |
3152 | } |
3146 | |
3153 | |
|
|
3154 | #ifdef PLUGSSS |
3147 | void plugin_init(void) |
3155 | void plugin_init(void) |
3148 | { |
3156 | { |
3149 | // dbg(1, "binfile: plugin_init\n"); |
3157 | // dbg(1, "binfile: plugin_init\n"); |
3150 | if (sizeof(struct zip_cd) != 46) |
3158 | if (sizeof(struct zip_cd) != 46) |
3151 | { |
3159 | { |
3152 | // dbg(0, "error: sizeof(struct zip_cd)=%d\n", sizeof(struct zip_cd)); |
3160 | // dbg(0, "error: sizeof(struct zip_cd)=%d\n", sizeof(struct zip_cd)); |
3153 | } |
3161 | } |
3154 | plugin_register_map_type("binfile", map_new_binfile); |
3162 | plugin_register_map_type("binfile", map_new_binfile); |
3155 | } |
3163 | } |
|
|
3164 | #endif |
3156 | |
3165 | |