Ticket #272: mg-alignment

File mg-alignment, 3.9 KB (added by Pini, 14 years ago)

Alignment patch for the MG plugin

Line 
1Alignment fix for mg plugin.
2Index: navit-0.1.1.~svn2067/navit/map/mg/mg.h
3===================================================================
4--- navit-0.1.1.~svn2067.orig/navit/map/mg/mg.h 2009-03-01 18:34:09.000000000 +0100
5+++ navit-0.1.1.~svn2067/navit/map/mg/mg.h      2009-03-01 19:12:05.000000000 +0100
6@@ -151,6 +151,11 @@
7        int tmp_len;
8        unsigned char *tmp_data;
9 };
10+static inline void street_name_numbers_get_coord(struct street_name_numbers * str, struct coord * c) {
11+       unsigned char *p=(unsigned char *)str->c;
12+       c->x=get_u32_unal(&p);
13+       c->y=get_u32_unal(&p);
14+}
15 
16 struct street_name_number {
17         int len;
18@@ -239,10 +244,12 @@
19 };
20 
21 struct block_offset {
22-       unsigned short offset;
23-       unsigned short block;
24+/*     unsigned short offset;
25+       unsigned short block;*/
26+       unsigned char p[4];
27 };
28-
29+static inline unsigned short block_offset_get_offset(struct block_offset * blk) { unsigned char *p = blk->p; return get_u16_unal(&p); }
30+static inline unsigned short block_offset_get_block(struct block_offset * blk) { unsigned char *p = blk->p+2; return get_u16_unal(&p); }
31 
32 struct tree_search_node {
33        struct tree_hdr *hdr;
34Index: navit-0.1.1.~svn2067/navit/map/mg/town.c
35===================================================================
36--- navit-0.1.1.~svn2067.orig/navit/map/mg/town.c       2009-03-01 18:34:09.000000000 +0100
37+++ navit-0.1.1.~svn2067/navit/map/mg/town.c    2009-03-01 19:08:51.000000000 +0100
38@@ -275,9 +275,9 @@
39        }
40        if (! mr->search_blk_count)
41                return NULL;
42-       dbg(1,"block 0x%x offset 0x%x\n", mr->search_blk_off->block, mr->search_blk_off->offset);
43-       block_get_byindex(mr->m->file[mr->current_file], mr->search_blk_off->block, &mr->b);
44-       mr->b.p=mr->b.block_start+mr->search_blk_off->offset;
45+       dbg(1,"block 0x%x offset 0x%x\n", block_offset_get_block(mr->search_blk_off), block_offset_get_offset(mr->search_blk_off));
46+       block_get_byindex(mr->m->file[mr->current_file], block_offset_get_block(mr->search_blk_off), &mr->b);
47+       mr->b.p=mr->b.block_start+block_offset_get_offset(mr->search_blk_off);
48        town_get(mr, &mr->town, &mr->item);
49        mr->search_blk_off++;
50        mr->search_blk_count--;
51Index: navit-0.1.1.~svn2067/navit/map/mg/street.c
52===================================================================
53--- navit-0.1.1.~svn2067.orig/navit/map/mg/street.c     2009-03-01 18:34:10.000000000 +0100
54+++ navit-0.1.1.~svn2067/navit/map/mg/street.c  2009-03-01 19:08:51.000000000 +0100
55@@ -52,8 +52,8 @@
56        name_numbers->dist=get_u32_unal(p);
57        name_numbers->country=get_u32_unal(p);
58        name_numbers->c=coord_get(p);
59-       name_numbers->first=get_u24(p);
60-       name_numbers->last=get_u24(p);
61+       name_numbers->first=get_u24_unal(p);
62+       name_numbers->last=get_u24_unal(p);
63        name_numbers->segment_count=get_u32_unal(p);
64        name_numbers->segments=(struct street_name_segment *)(*p);
65        (*p)+=sizeof(struct street_name_segment)*name_numbers->segment_count;
66@@ -71,8 +71,8 @@
67         name_number->len=get_u16_unal(p);
68         name_number->tag=get_u8(p);
69         name_number->c=coord_get(p);
70-        name_number->first=get_u24(p);
71-        name_number->last=get_u24(p);
72+        name_number->first=get_u24_unal(p);
73+        name_number->last=get_u24_unal(p);
74         name_number->segment=(struct street_name_segment *)p;
75        *p=start+name_number->len;
76 }
77@@ -627,7 +627,7 @@
78        dbg(1,"aux_data=%p\n", p);
79        if (count) {
80                street_name_numbers_get(&snns, &p);
81-               *c=*(snns.c);
82+               street_name_numbers_get_coord(&snns, c);
83                return 1;
84        }
85       
86Index: navit-0.1.1.~svn2067/navit/data.h
87===================================================================
88--- navit-0.1.1.~svn2067.orig/navit/data.h      2009-03-01 18:34:10.000000000 +0100
89+++ navit-0.1.1.~svn2067/navit/data.h   2009-03-01 19:08:51.000000000 +0100
90@@ -53,6 +53,15 @@
91 
92 
93 static inline unsigned int
94+get_u24_unal(unsigned char **p) {
95+       unsigned long ret;
96+       ret=get_u16_unal(p);
97+       ret|=*((*p)++) << 16;
98+       return ret;
99+}
100+
101+
102+static inline unsigned int
103 get_u32(unsigned char **p) {
104        unsigned long ret;
105        ret=*((unsigned int *)*p);