/[zanavi_public1]/navit/navit/maptool/misc.c
ZANavi

Diff of /navit/navit/maptool/misc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 8 Revision 31
1/**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2012 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
1/** 20/**
2 * Navit, a modular navigation system. 21 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team 22 * Copyright (C) 2005-2008 Navit Team
4 * 23 *
5 * This program is free software; you can redistribute it and/or 24 * This program is free software; you can redistribute it and/or
14 * You should have received a copy of the GNU General Public License 33 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the 34 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 35 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 36 * Boston, MA 02110-1301, USA.
18 */ 37 */
19
20 38
21#define _FILE_OFFSET_BITS 64 39#define _FILE_OFFSET_BITS 64
22#define _LARGEFILE_SOURCE 40#define _LARGEFILE_SOURCE
23#define _LARGEFILE64_SOURCE 41#define _LARGEFILE64_SOURCE
24#include <stdlib.h> 42#include <stdlib.h>
41#include "config.h" 59#include "config.h"
42#include "linguistics.h" 60#include "linguistics.h"
43#include "plugin.h" 61#include "plugin.h"
44#include "maptool.h" 62#include "maptool.h"
45 63
46struct rect world_bbox = { 64struct rect world_bbox =
65{
47 { -20000000, -20000000}, 66{ -20000000, -20000000 },
48 { 20000000, 20000000}, 67{ 20000000, 20000000 }, };
49};
50 68
51void
52bbox_extend(struct coord *c, struct rect *r) 69void bbox_extend(struct coord *c, struct rect *r)
53{ 70{
54 if (c->x < r->l.x) 71 if (c->x < r->l.x)
55 r->l.x=c->x; 72 r->l.x = c->x;
56 if (c->y < r->l.y) 73 if (c->y < r->l.y)
57 r->l.y=c->y; 74 r->l.y = c->y;
58 if (c->x > r->h.x) 75 if (c->x > r->h.x)
59 r->h.x=c->x; 76 r->h.x = c->x;
60 if (c->y > r->h.y) 77 if (c->y > r->h.y)
61 r->h.y=c->y; 78 r->h.y = c->y;
62} 79}
63 80
64void
65bbox(struct coord *c, int count, struct rect *r) 81void bbox(struct coord *c, int count, struct rect *r)
66{ 82{
67 if (! count) 83 if (!count)
68 return; 84 return;
69 r->l=*c; 85 r->l = *c;
70 r->h=*c; 86 r->h = *c;
71 while (--count) { 87 while (--count)
88 {
72 c++; 89 c++;
73 bbox_extend(c, r); 90 bbox_extend(c, r);
74 } 91 }
75} 92}
76 93
77int
78contains_bbox(int xl, int yl, int xh, int yh, struct rect *r) 94int contains_bbox(int xl, int yl, int xh, int yh, struct rect *r)
79{ 95{
80 if (r->h.x < xl || r->h.x > xh) { 96 if (r->h.x < xl || r->h.x > xh)
97 {
81 return 0; 98 return 0;
82 } 99 }
83 if (r->l.x > xh || r->l.x < xl) { 100 if (r->l.x > xh || r->l.x < xl)
101 {
84 return 0; 102 return 0;
85 } 103 }
86 if (r->h.y < yl || r->h.y > yh) { 104 if (r->h.y < yl || r->h.y > yh)
105 {
87 return 0; 106 return 0;
88 } 107 }
89 if (r->l.y > yh || r->l.y < yl) { 108 if (r->l.y > yh || r->l.y < yl)
109 {
90 return 0; 110 return 0;
91 } 111 }
92 return 1; 112 return 1;
93} 113}
94 114
95int
96bbox_contains_coord(struct rect *r, struct coord *c) 115int bbox_contains_coord(struct rect *r, struct coord *c)
97{ 116{
117
118 //fprintf(stderr,"bbox_contains_coord: rhx=%d rhy=%d rlx=%d rly=%d, cx=%d cy=%d\n", r->h.x, r->h.y, r->l.x, r->l.y,c->x, c->y);
119
98 if (r->h.x < c->x) 120 if (r->h.x < c->x)
99 return 0; 121 return 0;
100 if (r->l.x > c->x) 122 if (r->l.x > c->x)
101 return 0; 123 return 0;
102 if (r->h.y < c->y) 124 if (r->h.y < c->y)
104 if (r->l.y > c->y) 126 if (r->l.y > c->y)
105 return 0; 127 return 0;
106 return 1; 128 return 1;
107} 129}
108 130
109int
110bbox_contains_bbox(struct rect *out, struct rect *in) 131int bbox_contains_bbox(struct rect *out, struct rect *in)
111{ 132{
112 if (out->h.x < in->h.x) 133 if (out->h.x < in->h.x)
113 return 0; 134 return 0;
114 if (out->l.x > in->l.x) 135 if (out->l.x > in->l.x)
115 return 0; 136 return 0;
118 if (out->l.y > in->l.y) 139 if (out->l.y > in->l.y)
119 return 0; 140 return 0;
120 return 1; 141 return 1;
121} 142}
122 143
123long long
124bbox_area(struct rect const *r) 144long long bbox_area(struct rect const *r)
125{ 145{
126 return ((long long)r->h.x-r->l.x)*(r->h.y-r->l.y); 146 return ((long long) r->h.x - r->l.x) * (r->h.y - r->l.y);
127} 147}
128 148
129void
130phase1_map(GList *maps, FILE *out_ways, FILE *out_nodes) 149void phase1_map(GList *maps, FILE *out_ways, FILE *out_nodes)
131{ 150{
132 struct map_rect *mr; 151 struct map_rect *mr;
133 struct item *item; 152 struct item *item;
134 int count,max=16384; 153 int count, max = 16384;
135 struct coord ca[max]; 154 struct coord ca[max];
136 struct attr attr; 155 struct attr attr;
137 struct item_bin *item_bin; 156 struct item_bin *item_bin;
138 157
139 while (maps) { 158 while (maps)
159 {
140 mr=map_rect_new(maps->data, NULL); 160 mr = map_rect_new(maps->data, NULL);
141 while ((item = map_rect_get_item(mr))) { 161 while ((item = map_rect_get_item(mr)))
162 {
142 count=item_coord_get(item, ca, item->type < type_line ? 1: max); 163 count = item_coord_get(item, ca, item->type < type_line ? 1 : max);
143 item_bin=init_item(item->type); 164 item_bin = init_item(item->type, 0);
144 item_bin_add_coord(item_bin, ca, count); 165 item_bin_add_coord(item_bin, ca, count);
145 while (item_attr_get(item, attr_any, &attr)) { 166 while (item_attr_get(item, attr_any, &attr))
167 {
146 if (attr.type >= attr_type_string_begin && attr.type <= attr_type_string_end) { 168 if (attr.type >= attr_type_string_begin && attr.type <= attr_type_string_end)
169 {
147 attr.u.str=map_convert_string(maps->data, attr.u.str); 170 attr.u.str = map_convert_string(maps->data, attr.u.str);
148 if (attr.u.str) { 171 if (attr.u.str)
172 {
149 item_bin_add_attr(item_bin, &attr); 173 item_bin_add_attr(item_bin, &attr);
150 map_convert_free(attr.u.str); 174 map_convert_free(attr.u.str);
151 } 175 }
176 }
152 } else 177 else
153 item_bin_add_attr(item_bin, &attr); 178 item_bin_add_attr(item_bin, &attr);
154 } 179 }
155 if (item->type >= type_line) 180 if (item->type >= type_line)
156 item_bin_write(item_bin, out_ways); 181 item_bin_write(item_bin, out_ways);
157 else 182 else
158 item_bin_write(item_bin, out_nodes); 183 item_bin_write(item_bin, out_nodes);
159 } 184 }
160 map_rect_destroy(mr); 185 map_rect_destroy(mr);
161 maps=g_list_next(maps); 186 maps = g_list_next(maps);
162 } 187 }
163} 188}
164 189
165static void
166phase34_process_file(struct tile_info *info, FILE *in, FILE *reference) 190static void phase34_process_file(struct tile_info *info, FILE *in, FILE *reference)
167{ 191{
168 struct item_bin *ib; 192 struct item_bin *ib;
169 int max; 193 int max;
170 194
171 while ((ib=read_item(in))) { 195 while ((ib = read_item(in, 0)))
196 {
197 if (ib->type < 0x80000000)
198 {
199 processed_nodes++;
200 }
201 else
202 {
203 processed_ways++;
204 }
205
206 if (border_only_map == 1)
207 {
208 // fprintf(stderr,"max=1\n");
209 // max=1; --> shows all borders, all the time. but is too slow!
210 max = 4;
211 }
212 else
213 {
214 max = 14;
215 switch (ib->type)
216 {
217 case type_town_label_1e7:
218 case type_town_label_5e6:
219 case type_town_label_2e6:
220 case type_town_label_1e6:
221 case type_town_label_5e5:
222 case type_district_label_1e7:
223 case type_district_label_5e6:
224 case type_district_label_2e6:
225 case type_district_label_1e6:
226 case type_district_label_5e5:
227 max = 6;
228 break;
229 case type_town_label_2e5:
230 case type_town_label_1e5:
231 case type_district_label_2e5:
232 case type_district_label_1e5:
233 case type_street_n_lanes:
234 case type_highway_city:
235 case type_highway_land:
236 case type_ramp:
237 max = 8;
238 break;
239 case type_town_label_5e4:
240 case type_town_label_2e4:
241 case type_town_label_1e4:
242 case type_district_label_5e4:
243 case type_district_label_2e4:
244 case type_district_label_1e4:
245 max = 9;
246 break;
247 case type_street_4_land:
248 case type_street_4_city:
249 max = 10;
250 break;
251 case type_town_label_5e3:
252 case type_town_label_2e3:
253 case type_town_label_1e3:
254 case type_district_label_5e3:
255 case type_district_label_2e3:
256 case type_district_label_1e3:
257 case type_street_3_city:
258 case type_street_3_land:
259 max = 12;
260 break;
261 default:
262 break;
263 }
264 }
265
266 // dont write "street unknown" items to binfile, if option "to ignore unknown types" is set
267 if ((ib->type == type_street_unkn) && (ignore_unkown == 1))
268 {
269 }
270 else
271 {
272 tile_write_item_minmax(info, ib, reference, 0, max);
273 }
274 }
275}
276
277static void phase34_process_file_range(struct tile_info *info, FILE *in, FILE *reference)
278{
279 struct item_bin *ib;
280 int min, max;
281
282 while ((ib = read_item_range(in, &min, &max, 0)))
283 {
172 if (ib->type < 0x80000000) 284 if (ib->type < 0x80000000)
173 processed_nodes++; 285 processed_nodes++;
174 else 286 else
175 processed_ways++; 287 processed_ways++;
176 max=14; 288
177 switch (ib->type) { 289 if ((ib->type == type_street_unkn) && (ignore_unkown == 1))
178 case type_town_label_1e7: 290 {
179 case type_town_label_5e6:
180 case type_town_label_2e6:
181 case type_town_label_1e6:
182 case type_town_label_5e5:
183 case type_district_label_1e7:
184 case type_district_label_5e6:
185 case type_district_label_2e6:
186 case type_district_label_1e6:
187 case type_district_label_5e5:
188 max=6;
189 break;
190 case type_town_label_2e5:
191 case type_town_label_1e5:
192 case type_district_label_2e5:
193 case type_district_label_1e5:
194 case type_street_n_lanes:
195 case type_highway_city:
196 case type_highway_land:
197 case type_ramp:
198 max=8;
199 break;
200 case type_town_label_5e4:
201 case type_town_label_2e4:
202 case type_town_label_1e4:
203 case type_district_label_5e4:
204 case type_district_label_2e4:
205 case type_district_label_1e4:
206 max=9;
207 break;
208 case type_town_label_5e3:
209 case type_town_label_2e3:
210 case type_town_label_1e3:
211 case type_district_label_5e3:
212 case type_district_label_2e3:
213 case type_district_label_1e3:
214 case type_street_3_city:
215 case type_street_4_city:
216 case type_street_3_land:
217 case type_street_4_land:
218 max=12;
219 break;
220 default:
221 break;
222 } 291 }
292 else
293 {
223 tile_write_item_minmax(info, ib, reference, 0, max); 294 tile_write_item_minmax(info, ib, reference, min, max);
224 } 295 }
296 }
225} 297}
226 298
227static void 299static int phase34(struct tile_info *info, struct zip_info *zip_info, FILE **in, FILE **reference, int in_count, int with_range)
228phase34_process_file_range(struct tile_info *info, FILE *in, FILE *reference) 300{
301 int i;
302
303 processed_nodes = processed_nodes_out = processed_ways = processed_relations = processed_tiles = 0;
304
305 bytes_read = 0;
306 //sig_alrm(0);
307
308 if (!info->write)
309 {
310 tile_hash = g_hash_table_new(g_str_hash, g_str_equal);
311 }
312
313 for (i = 0; i < in_count; i++)
314 {
315 if (in[i])
316 {
317 if (with_range)
318 {
319 phase34_process_file_range(info, in[i], reference ? reference[i] : NULL);
320 }
321 else
322 {
323 phase34_process_file(info, in[i], reference ? reference[i] : NULL);
324 }
325 }
326 }
327
328 if (!info->write)
329 {
330 merge_tiles(info);
331 }
332
333 //sig_alrm(0);
334 //sig_alrm_end();
335
336 write_tilesdir(info, zip_info, info->tilesdir_out);
337
338 return 0;
339
340}
341
342void dump(FILE *in)
229{ 343{
230 struct item_bin *ib; 344 struct item_bin *ib;
231 int min,max;
232
233 while ((ib=read_item_range(in, &min, &max))) {
234 if (ib->type < 0x80000000)
235 processed_nodes++;
236 else
237 processed_ways++;
238 tile_write_item_minmax(info, ib, reference, min, max);
239 }
240}
241
242static int
243phase34(struct tile_info *info, struct zip_info *zip_info, FILE **in, FILE **reference, int in_count, int with_range)
244{
245 int i;
246
247 processed_nodes=processed_nodes_out=processed_ways=processed_relations=processed_tiles=0;
248 bytes_read=0;
249 sig_alrm(0);
250 if (! info->write)
251 tile_hash=g_hash_table_new(g_str_hash, g_str_equal);
252 for (i = 0 ; i < in_count ; i++) {
253 if (in[i]) {
254 if (with_range)
255 phase34_process_file_range(info, in[i], reference ? reference[i]:NULL);
256 else
257 phase34_process_file(info, in[i], reference ? reference[i]:NULL);
258 }
259 }
260 if (! info->write)
261 merge_tiles(info);
262 sig_alrm(0);
263 sig_alrm_end();
264 write_tilesdir(info, zip_info, info->tilesdir_out);
265
266 return 0;
267
268}
269
270
271void
272dump(FILE *in)
273{
274 struct item_bin *ib;
275 while ((ib=read_item(in))) { 345 while ((ib = read_item(in, 0)))
346 {
276 dump_itembin(ib); 347 dump_itembin(ib);
277 } 348 }
278} 349}
279 350
280int
281phase4(FILE **in, int in_count, int with_range, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info) 351int phase4(FILE **in, int in_count, int with_range, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info)
282{ 352{
283 struct tile_info info; 353 struct tile_info info;
284 info.write=0; 354 info.write = 0;
285 info.maxlen=0; 355 info.maxlen = 0;
286 info.suffix=suffix; 356 info.suffix = suffix;
287 info.tiles_list=NULL; 357 info.tiles_list = NULL;
288 info.tilesdir_out=tilesdir_out; 358 info.tilesdir_out = tilesdir_out;
289 return phase34(&info, zip_info, in, NULL, in_count, with_range); 359 return phase34(&info, zip_info, in, NULL, in_count, with_range);
290} 360}
291 361
292static int
293process_slice(FILE **in, FILE **reference, int in_count, int with_range, long long size, char *suffix, struct zip_info *zip_info) 362static int process_slice(FILE **in, FILE **reference, int in_count, int with_range, long long size, char *suffix, struct zip_info *zip_info)
294{ 363{
295 struct tile_head *th; 364 struct tile_head *th;
296 char *slice_data,*zip_data; 365 char *slice_data, *zip_data;
297 int zipfiles=0; 366 int zipfiles = 0;
298 struct tile_info info; 367 struct tile_info info;
299 int i; 368 int i;
300 369
301 slice_data=malloc(size); 370 slice_data = malloc(size);
302 assert(slice_data != NULL); 371 assert(slice_data != NULL);
303 zip_data=slice_data; 372 zip_data = slice_data;
304 th=tile_head_root; 373 th = tile_head_root;
305 while (th) { 374 while (th)
375 {
306 if (th->process) { 376 if (th->process)
377 {
307 th->zip_data=zip_data; 378 th->zip_data = zip_data;
308 zip_data+=th->total_size; 379 zip_data += th->total_size;
309 } 380 }
310 th=th->next; 381 th = th->next;
311 } 382 }
312 for (i = 0 ; i < in_count ; i++) { 383 for (i = 0; i < in_count; i++)
384 {
313 if (in[i]) 385 if (in[i])
314 fseek(in[i], 0, SEEK_SET); 386 fseek(in[i], 0, SEEK_SET);
315 if (reference && reference[i]) { 387 if (reference && reference[i])
388 {
316 fseek(reference[i], 0, SEEK_SET); 389 fseek(reference[i], 0, SEEK_SET);
317 } 390 }
318 } 391 }
319 info.write=1; 392 info.write = 1;
320 info.maxlen=zip_get_maxnamelen(zip_info); 393 info.maxlen = zip_get_maxnamelen(zip_info);
321 info.suffix=suffix; 394 info.suffix = suffix;
322 info.tiles_list=NULL; 395 info.tiles_list = NULL;
323 info.tilesdir_out=NULL; 396 info.tilesdir_out = NULL;
324 phase34(&info, zip_info, in, reference, in_count, with_range); 397 phase34(&info, zip_info, in, reference, in_count, with_range);
325 398
326 th=tile_head_root; 399 th = tile_head_root;
327 while (th) { 400 while (th)
401 {
328 if (th->process) { 402 if (th->process)
403 {
329 if (th->name[0]) { 404 if (th->name[0])
405 {
330 if (th->total_size != th->total_size_used) { 406 if (th->total_size != th->total_size_used)
407 {
331 fprintf(stderr,"Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used); 408 fprintf(stderr, "Size error '%s': %d vs %d\n", th->name, th->total_size, th->total_size_used);
332 exit(1); 409 exit(1);
333 } 410 }
334 write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size); 411 write_zipmember(zip_info, th->name, zip_get_maxnamelen(zip_info), th->zip_data, th->total_size);
335 zipfiles++; 412 zipfiles++;
413 }
336 } else 414 else
337 fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info)); 415 fwrite(th->zip_data, th->total_size, 1, zip_get_index(zip_info));
338 } 416 }
339 th=th->next; 417 th = th->next;
340 } 418 }
341 free(slice_data); 419 free(slice_data);
342 420
343 return zipfiles; 421 return zipfiles;
344} 422}
345 423
346int
347phase5(FILE **in, FILE **references, int in_count, int with_range, char *suffix, struct zip_info *zip_info) 424int phase5(FILE **in, FILE **references, int in_count, int with_range, char *suffix, struct zip_info *zip_info)
348{ 425{
349 long long size; 426 long long size;
350 int slices; 427 int slices;
351 int zipnum,written_tiles; 428 int zipnum, written_tiles;
352 struct tile_head *th,*th2; 429 struct tile_head *th, *th2;
430
431 time_t start_tt, end_tt;
432 double diff_tt;
433 double diff2_tt;
434
353 create_tile_hash(); 435 create_tile_hash();
354 436
355 th=tile_head_root; 437 th = tile_head_root;
356 size=0; 438 size = 0;
357 slices=0; 439 slices = 0;
358 fprintf(stderr, "Maximum slice size "LONGLONG_FMT"\n", slice_size); 440 fprintf(stderr, "Maximum slice size "LONGLONG_FMT"\n", slice_size);
359 while (th) { 441 while (th)
442 {
360 if (size + th->total_size > slice_size) { 443 if (size + th->total_size > slice_size)
444 {
361 fprintf(stderr,"Slice %d is of size "LONGLONG_FMT"\n", slices, size); 445 fprintf(stderr,"Slice %d is of size "LONGLONG_FMT"\n", slices, size);
362 size=0; 446 size = 0;
363 slices++; 447 slices++;
364 } 448 }
365 size+=th->total_size; 449 size += th->total_size;
366 th=th->next; 450 th = th->next;
367 } 451 }
452
368 if (size) 453 if (size)
454 {
369 fprintf(stderr,"Slice %d is of size "LONGLONG_FMT"\n", slices, size); 455 fprintf(stderr,"Slice %d is of size "LONGLONG_FMT"\n", slices, size);
456 }
457
458 int max_slices_ = slices;
370 th=tile_head_root; 459 th = tile_head_root;
371 size=0; 460 size = 0;
372 slices=0; 461 slices = 0;
462
373 while (th) { 463 while (th)
464 {
465 time(&start_tt);
466
467 fprintf(stderr,"Slice #%d of %d\n", (slices + 1), (max_slices_ + 1));
468
374 th2=tile_head_root; 469 th2 = tile_head_root;
375 while (th2) { 470 while (th2)
471 {
376 th2->process=0; 472 th2->process = 0;
377 th2=th2->next; 473 th2 = th2->next;
378 } 474 }
475
379 size=0; 476 size = 0;
380 while (th && size+th->total_size < slice_size) { 477 while (th && size + th->total_size < slice_size)
478 {
381 size+=th->total_size; 479 size += th->total_size;
382 th->process=1; 480 th->process = 1;
383 th=th->next; 481 th = th->next;
384 } 482 }
483
385 /* process_slice() modifies zip_info, but need to retain old info */ 484 /* process_slice() modifies zip_info, but need to retain old info */
386 zipnum=zip_get_zipnum(zip_info); 485 zipnum = zip_get_zipnum(zip_info);
387 written_tiles=process_slice(in, references, in_count, with_range, size, suffix, zip_info); 486 written_tiles = process_slice(in, references, in_count, with_range, size, suffix, zip_info);
388 zip_set_zipnum(zip_info, zipnum+written_tiles); 487 zip_set_zipnum(zip_info, zipnum + written_tiles);
488
489 time(&end_tt);
490 diff_tt = difftime(end_tt,start_tt);
491 char outstring[200];
492 convert_to_human_time(diff_tt, outstring);
493 fprintf(stderr, "-RUNTIME-LOOP-PHASE5: %s this loop run\n", outstring);
494 diff2_tt = diff2_tt + diff_tt;
495 if ((slices + 1) > 0)
496 {
497 double eta_time = (diff2_tt / (slices + 1)) * (max_slices_ + 1 - (slices + 1));
498 convert_to_human_time(eta_time, outstring);
499 fprintf(stderr, "-RUNTIME-LOOP-PHASE5: %s left\n", outstring);
500 }
501
389 slices++; 502 slices++;
390 } 503 }
504
391 return 0; 505 return 0;
392} 506}
393 507
394void
395process_binfile(FILE *in, FILE *out) 508void process_binfile(FILE *in, FILE *out)
396{ 509{
397 struct item_bin *ib; 510 struct item_bin *ib;
398 while ((ib=read_item(in))) { 511 while ((ib = read_item(in, 0)))
512 {
399 fwrite(ib, (ib->len+1)*4, 1, out); 513 fwrite(ib, (ib->len + 1) * 4, 1, out);
400 } 514 }
401} 515}
402 516
403void
404add_aux_tiles(char *name, struct zip_info *info) 517void add_aux_tiles(char *name, struct zip_info *info)
405{ 518{
406 char buffer[4096]; 519 char buffer[4096];
407 char *s; 520 char *s;
408 FILE *in; 521 FILE *in;
409 FILE *tmp; 522 FILE *tmp;
410 in=fopen(name,"rb"); 523 in = fopen(name, "rb");
411 if (!in) 524 if (!in)
412 return; 525 return;
413 while (fscanf(in,"%s",buffer) == 1) { 526 while (fscanf(in, "%s", buffer) == 1)
527 {
414 s=strchr(buffer,'/'); 528 s = strchr(buffer, '/');
415 if (s) 529 if (s)
416 s++; 530 s++;
417 else 531 else
418 s=buffer; 532 s = buffer;
419 tmp=fopen(buffer,"rb"); 533 tmp = fopen(buffer, "rb");
420 if (tmp) { 534 if (tmp)
535 {
421 fseek(tmp, 0, SEEK_END); 536 fseek(tmp, 0, SEEK_END);
422 add_aux_tile(info, s, buffer, ftell(tmp)); 537 add_aux_tile(info, s, buffer, ftell(tmp));
423 fclose(tmp); 538 fclose(tmp);
424 } 539 }
425 } 540 }

Legend:
Removed from v.8  
changed lines
  Added in v.31

   
Visit the ZANavi Wiki