… | |
… | |
90 | } |
90 | } |
91 | |
91 | |
92 | void item_cleanup(void) |
92 | void item_cleanup(void) |
93 | { |
93 | { |
94 | if (default_flags_hash) |
94 | if (default_flags_hash) |
|
|
95 | { |
95 | g_hash_table_destroy(default_flags_hash); |
96 | g_hash_table_destroy(default_flags_hash); |
|
|
97 | } |
96 | } |
98 | } |
97 | |
99 | |
98 | void item_coord_rewind(struct item *it) |
100 | void item_coord_rewind(struct item *it) |
99 | { |
101 | { |
100 | it->meth->item_coord_rewind(it->priv_data); |
102 | it->meth->item_coord_rewind(it->priv_data); |
… | |
… | |
118 | int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel) |
120 | int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel) |
119 | { |
121 | { |
120 | int i, ret = it->meth->item_coord_get(it->priv_data, c, count); |
122 | int i, ret = it->meth->item_coord_get(it->priv_data, c, count); |
121 | struct coord_rect r; |
123 | struct coord_rect r; |
122 | struct map_selection *curr; |
124 | struct map_selection *curr; |
|
|
125 | |
123 | if (ret <= 0 || !sel) |
126 | if (ret <= 0 || !sel) |
|
|
127 | { |
124 | return ret; |
128 | return ret; |
|
|
129 | } |
|
|
130 | |
125 | r.lu = c[0]; |
131 | r.lu = c[0]; |
126 | r.rl = c[0]; |
132 | r.rl = c[0]; |
|
|
133 | |
127 | for (i = 1; i < ret; i++) |
134 | for (i = 1; i < ret; i++) |
128 | { |
135 | { |
129 | if (r.lu.x > c[i].x) |
136 | if (r.lu.x > c[i].x) |
130 | r.lu.x = c[i].x; |
137 | r.lu.x = c[i].x; |
|
|
138 | |
131 | if (r.rl.x < c[i].x) |
139 | if (r.rl.x < c[i].x) |
132 | r.rl.x = c[i].x; |
140 | r.rl.x = c[i].x; |
|
|
141 | |
133 | if (r.rl.y > c[i].y) |
142 | if (r.rl.y > c[i].y) |
134 | r.rl.y = c[i].y; |
143 | r.rl.y = c[i].y; |
|
|
144 | |
135 | if (r.lu.y < c[i].y) |
145 | if (r.lu.y < c[i].y) |
136 | r.lu.y = c[i].y; |
146 | r.lu.y = c[i].y; |
137 | } |
147 | } |
|
|
148 | |
138 | curr = sel; |
149 | curr = sel; |
|
|
150 | |
139 | while (curr) |
151 | while (curr) |
140 | { |
152 | { |
141 | struct coord_rect *sr = &curr->u.c_rect; |
153 | struct coord_rect *sr = &curr->u.c_rect; |
142 | if (r.lu.x <= sr->rl.x && r.rl.x >= sr->lu.x && r.lu.y >= sr->rl.y && r.rl.y <= sr->lu.y) |
154 | if (r.lu.x <= sr->rl.x && r.rl.x >= sr->lu.x && r.lu.y >= sr->rl.y && r.rl.y <= sr->lu.y) |
|
|
155 | { |
143 | return ret; |
156 | return ret; |
|
|
157 | } |
144 | curr = curr->next; |
158 | curr = curr->next; |
145 | } |
159 | } |
|
|
160 | |
146 | return 0; |
161 | return 0; |
147 | } |
162 | } |
148 | |
163 | |
149 | int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to) |
164 | int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to) |
150 | { |
165 | { |
151 | int ret = item_coord_get(it, c, count); |
166 | int ret = item_coord_get(it, c, count); |
152 | int i; |
167 | int i; |
153 | enum projection from = map_projection(it->map); |
168 | enum projection from = map_projection(it->map); |
|
|
169 | |
154 | if (from != to) |
170 | if (from != to) |
155 | for (i = 0; i < count; i++) |
171 | for (i = 0; i < count; i++) |
156 | transform_from_to(c + i, from, c + i, to); |
172 | transform_from_to(c + i, from, c + i, to); |
|
|
173 | |
157 | return ret; |
174 | return ret; |
158 | } |
175 | } |
159 | |
176 | |
160 | int item_coord_is_node(struct item *it) |
177 | int item_coord_is_node(struct item *it) |
161 | { |
178 | { |
162 | if (it->meth->item_coord_is_node) |
179 | if (it->meth->item_coord_is_node) |
|
|
180 | { |
163 | return it->meth->item_coord_is_node(it->priv_data); |
181 | return it->meth->item_coord_is_node(it->priv_data); |
|
|
182 | } |
|
|
183 | |
164 | return 0; |
184 | return 0; |
165 | } |
185 | } |
166 | |
186 | |
167 | void item_attr_rewind(struct item *it) |
187 | void item_attr_rewind(struct item *it) |
168 | { |
188 | { |
… | |
… | |
183 | } |
203 | } |
184 | |
204 | |
185 | int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode) |
205 | int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode) |
186 | { |
206 | { |
187 | if (!it->meth->item_attr_set) |
207 | if (!it->meth->item_attr_set) |
|
|
208 | { |
188 | return 0; |
209 | return 0; |
|
|
210 | } |
|
|
211 | |
189 | return it->meth->item_attr_set(it->priv_data, attr, mode); |
212 | return it->meth->item_attr_set(it->priv_data, attr, mode); |
190 | } |
213 | } |
191 | |
214 | |
192 | struct item * item_new(char *type, int zoom) |
215 | struct item * item_new(char *type, int zoom) |
193 | { |
216 | { |