… | |
… | |
643 | attr->u.str = mr->url; |
643 | attr->u.str = mr->url; |
644 | } |
644 | } |
645 | |
645 | |
646 | if (type == attr_flags && mr->m->map_version < 1) |
646 | if (type == attr_flags && mr->m->map_version < 1) |
647 | { |
647 | { |
648 | attr->u.num |= AF_CAR; |
648 | attr->u.num |= NAVIT_AF_CAR; |
649 | } |
649 | } |
650 | } |
650 | } |
651 | t->pos_attr += size; |
651 | t->pos_attr += size; |
652 | return 1; |
652 | return 1; |
653 | } |
653 | } |
… | |
… | |
1567 | struct map_rect_priv *mr; |
1567 | struct map_rect_priv *mr; |
1568 | |
1568 | |
1569 | binfile_check_version(map); |
1569 | binfile_check_version(map); |
1570 | // dbg(1, "map_rect_new_binfile\n"); |
1570 | // dbg(1, "map_rect_new_binfile\n"); |
1571 | if (!map->fi && !map->url) |
1571 | if (!map->fi && !map->url) |
|
|
1572 | { |
1572 | return NULL; |
1573 | return NULL; |
|
|
1574 | } |
1573 | map_binfile_http_close(map); |
1575 | map_binfile_http_close(map); |
1574 | mr=g_new0(struct map_rect_priv, 1); |
1576 | mr=g_new0(struct map_rect_priv, 1); |
1575 | mr->m = map; |
1577 | mr->m = map; |
1576 | mr->sel = sel; |
1578 | mr->sel = sel; |
1577 | mr->item.id_hi = 0; |
1579 | mr->item.id_hi = 0; |
… | |
… | |
2868 | woffset+=cdisize; |
2870 | woffset+=cdisize; |
2869 | |
2871 | |
2870 | } |
2872 | } |
2871 | #endif |
2873 | #endif |
2872 | |
2874 | |
|
|
2875 | |
|
|
2876 | static int string_endswith(const char* ending, const char* instring) |
|
|
2877 | { |
|
|
2878 | int l1; |
|
|
2879 | int l2; |
|
|
2880 | |
|
|
2881 | if (!ending) |
|
|
2882 | { |
|
|
2883 | return 0; |
|
|
2884 | } |
|
|
2885 | |
|
|
2886 | if (!instring) |
|
|
2887 | { |
|
|
2888 | return 0; |
|
|
2889 | } |
|
|
2890 | |
|
|
2891 | l1 = strlen(ending); |
|
|
2892 | l2 = strlen(instring); |
|
|
2893 | |
|
|
2894 | if (l1 < 1) |
|
|
2895 | { |
|
|
2896 | return 0; |
|
|
2897 | } |
|
|
2898 | |
|
|
2899 | if (l1 > l2) |
|
|
2900 | { |
|
|
2901 | return 0; |
|
|
2902 | } |
|
|
2903 | |
|
|
2904 | int ret = strcmp(ending, instring + (l2 - l1)); |
|
|
2905 | //dbg(0, "ending=%s in=%s ret=%d\n", ending, instring + (l2 - l1), (ret == 0)); |
|
|
2906 | return (ret == 0); |
|
|
2907 | } |
|
|
2908 | |
|
|
2909 | |
2873 | static int map_binfile_open(struct map_priv *m) |
2910 | static int map_binfile_open(struct map_priv *m) |
2874 | { |
2911 | { |
2875 | int *magic; |
2912 | int *magic; |
|
|
2913 | int version_exception = 0; |
2876 | struct map_rect_priv *mr; |
2914 | struct map_rect_priv *mr; |
2877 | struct item *item; |
2915 | struct item *item; |
2878 | struct attr attr; |
2916 | struct attr attr; |
|
|
2917 | |
2879 | struct attr readwrite = |
2918 | struct attr readwrite = |
2880 | { attr_readwrite, |
2919 | { attr_readwrite, |
2881 | { (void *) 1 } }; |
2920 | { (void *) 1 } }; |
|
|
2921 | |
2882 | struct attr *attrs[] = |
2922 | struct attr *attrs[] = |
2883 | { &readwrite, NULL }; |
2923 | { &readwrite, NULL }; |
2884 | |
2924 | |
2885 | // dbg(0, "file_create %s\n", m->filename); |
2925 | // dbg(0, "file_create %s\n", m->filename); |
2886 | m->fi = file_create(m->filename, m->url ? attrs : NULL); |
2926 | m->fi = file_create(m->filename, m->url ? attrs : NULL); |
2887 | if (!m->fi && m->url) |
2927 | if (!m->fi && m->url) |
2888 | { |
2928 | { |
2889 | return 0; |
2929 | return 0; |
2890 | } |
2930 | } |
|
|
2931 | |
2891 | if (!m->fi) |
2932 | if (!m->fi) |
2892 | { |
2933 | { |
2893 | // dbg(0, "Failed to load '%s'\n", m->filename); |
2934 | // dbg(0, "Failed to load '%s'\n", m->filename); |
2894 | return 0; |
2935 | return 0; |
2895 | } |
2936 | } |
|
|
2937 | |
2896 | if (m->check_version) |
2938 | if (m->check_version) |
2897 | { |
2939 | { |
2898 | m->version = file_version(m->fi, m->check_version); |
2940 | m->version = file_version(m->fi, m->check_version); |
2899 | } |
2941 | } |
2900 | |
2942 | |
… | |
… | |
2950 | if (item && item->type == type_map_information) |
2992 | if (item && item->type == type_map_information) |
2951 | { |
2993 | { |
2952 | if (binfile_attr_get(item->priv_data, attr_version, &attr)) |
2994 | if (binfile_attr_get(item->priv_data, attr_version, &attr)) |
2953 | { |
2995 | { |
2954 | m->map_version = attr.u.num; |
2996 | m->map_version = attr.u.num; |
2955 | dbg(0, "map_version=%d\n", m->map_version); |
2997 | dbg(0, "map version=%d\n", m->map_version); |
2956 | } |
2998 | } |
|
|
2999 | |
2957 | if (binfile_attr_get(item->priv_data, attr_map_release, &attr)) |
3000 | if (binfile_attr_get(item->priv_data, attr_map_release, &attr)) |
2958 | { |
3001 | { |
2959 | m->map_release = g_strdup(attr.u.str); |
3002 | m->map_release = g_strdup(attr.u.str); |
2960 | dbg(0, "map_release=%s\n", m->map_release); |
3003 | dbg(0, "maptool version used=%s\n", m->map_release); |
2961 | } |
3004 | } |
2962 | if (m->url && binfile_attr_get(item->priv_data, attr_url, &attr)) |
3005 | |
|
|
3006 | if (string_endswith("borders.bin", m->filename) == 1) |
2963 | { |
3007 | { |
2964 | //dbg(0, "url config %s map %s\n", m->url, attr.u.str); |
3008 | dbg(0, "map exception added!\n"); |
2965 | if (strcmp(m->url, attr.u.str)) |
3009 | version_exception = 1; |
2966 | { |
|
|
2967 | m->update_available = 1; |
|
|
2968 | } |
|
|
2969 | g_free(m->url); |
|
|
2970 | m->url = g_strdup(attr.u.str); |
|
|
2971 | } |
3010 | } |
|
|
3011 | |
|
|
3012 | if (string_endswith("coastline.bin", m->filename) == 1) |
|
|
3013 | { |
|
|
3014 | dbg(0, "map exception added!\n"); |
|
|
3015 | version_exception = 1; |
|
|
3016 | } |
|
|
3017 | |
|
|
3018 | //if (m->url && binfile_attr_get(item->priv_data, attr_url, &attr)) |
|
|
3019 | //{ |
|
|
3020 | // dbg(0, "url config %s map %s\n", m->url, attr.u.str); |
|
|
3021 | // if (strcmp(m->url, attr.u.str)) |
|
|
3022 | // { |
|
|
3023 | // m->update_available = 1; |
|
|
3024 | // } |
|
|
3025 | // g_free(m->url); |
|
|
3026 | // m->url = g_strdup(attr.u.str); |
|
|
3027 | //} |
2972 | } |
3028 | } |
2973 | |
3029 | |
2974 | map_rect_destroy_binfile(mr); |
3030 | map_rect_destroy_binfile(mr); |
2975 | |
3031 | |
2976 | if (m->map_version >= 16) |
3032 | if (version_exception == 0) |
|
|
3033 | { |
|
|
3034 | if (m->map_version < (int)NEED_MIN_BINFILE_MAPVERSION) |
2977 | { |
3035 | { |
2978 | dbg(0, "Warning: This map is incompatible with your versionof ZANavi. Please update ZANavi.\n"); |
3036 | dbg(0, "!!**Warning**!!: This map is too old for your version of ZANavi. You need at least a version %d map\n", (int)NEED_MIN_BINFILE_MAPVERSION); |
2979 | return 0; |
3037 | return 0; |
|
|
3038 | } |
2980 | } |
3039 | } |
2981 | } |
3040 | } |
2982 | return 1; |
3041 | return 1; |
2983 | } |
3042 | } |
2984 | |
3043 | |
… | |
… | |
2988 | file_data_free(m->fi, (unsigned char *) m->index_cd); |
3047 | file_data_free(m->fi, (unsigned char *) m->index_cd); |
2989 | file_data_free(m->fi, (unsigned char *) m->eoc); |
3048 | file_data_free(m->fi, (unsigned char *) m->eoc); |
2990 | file_data_free(m->fi, (unsigned char *) m->eoc64); |
3049 | file_data_free(m->fi, (unsigned char *) m->eoc64); |
2991 | g_free(m->cachedir); |
3050 | g_free(m->cachedir); |
2992 | g_free(m->map_release); |
3051 | g_free(m->map_release); |
|
|
3052 | |
2993 | if (m->fis) |
3053 | if (m->fis) |
2994 | { |
3054 | { |
2995 | for (i = 0; i < m->eoc->zipedsk; i++) |
3055 | for (i = 0; i < m->eoc->zipedsk; i++) |
2996 | { |
3056 | { |
2997 | file_destroy(m->fis[i]); |
3057 | file_destroy(m->fis[i]); |
2998 | } |
3058 | } |
2999 | } |
3059 | } |
3000 | else |
3060 | else |
|
|
3061 | { |
3001 | file_destroy(m->fi); |
3062 | file_destroy(m->fi); |
|
|
3063 | } |
3002 | } |
3064 | } |
3003 | |
3065 | |
3004 | static void map_binfile_destroy(struct map_priv *m) |
3066 | static void map_binfile_destroy(struct map_priv *m) |
3005 | { |
3067 | { |
3006 | g_free(m->filename); |
3068 | g_free(m->filename); |
… | |
… | |
3044 | m->cbl = cbl; |
3106 | m->cbl = cbl; |
3045 | m->id = ++map_id; |
3107 | m->id = ++map_id; |
3046 | m->filename = g_strdup(data->u.str); |
3108 | m->filename = g_strdup(data->u.str); |
3047 | // file_wordexp_destroy(wexp); |
3109 | // file_wordexp_destroy(wexp); |
3048 | check_version = attr_search(attrs, NULL, attr_check_version); |
3110 | check_version = attr_search(attrs, NULL, attr_check_version); |
|
|
3111 | |
3049 | if (check_version) |
3112 | if (check_version) |
3050 | m->check_version = check_version->u.num; |
3113 | m->check_version = check_version->u.num; |
|
|
3114 | |
3051 | map_pass = attr_search(attrs, NULL, attr_map_pass); |
3115 | map_pass = attr_search(attrs, NULL, attr_map_pass); |
|
|
3116 | |
3052 | if (map_pass) |
3117 | if (map_pass) |
3053 | m->passwd = g_strdup(map_pass->u.str); |
3118 | m->passwd = g_strdup(map_pass->u.str); |
|
|
3119 | |
3054 | flags = attr_search(attrs, NULL, attr_flags); |
3120 | flags = attr_search(attrs, NULL, attr_flags); |
|
|
3121 | |
3055 | if (flags) |
3122 | if (flags) |
3056 | m->flags = flags->u.num; |
3123 | m->flags = flags->u.num; |
|
|
3124 | |
3057 | url = attr_search(attrs, NULL, attr_url); |
3125 | url = attr_search(attrs, NULL, attr_url); |
|
|
3126 | |
3058 | if (url) |
3127 | if (url) |
3059 | m->url = g_strdup(url->u.str); |
3128 | m->url = g_strdup(url->u.str); |
|
|
3129 | |
3060 | download_enabled = attr_search(attrs, NULL, attr_update); |
3130 | download_enabled = attr_search(attrs, NULL, attr_update); |
|
|
3131 | |
3061 | if (download_enabled) |
3132 | if (download_enabled) |
3062 | m->download_enabled = download_enabled->u.num; |
3133 | m->download_enabled = download_enabled->u.num; |
3063 | |
3134 | |
3064 | if (!map_binfile_open(m) && !m->check_version && !m->url) |
3135 | if (!map_binfile_open(m) && !m->check_version && !m->url) |
3065 | { |
3136 | { |