Fix:maptool:Another name for faroe islands
[navit-package] / navit / vehicleprofile.c
index 650e6af..e887200 100644 (file)
 
 #include <glib.h>
 #include <string.h>
+#include <stdlib.h>
 #include "debug.h"
 #include "item.h"
+#include "roadprofile.h"
 #include "vehicleprofile.h"
 
-void
+static void
 vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr)
 {
+       dbg(1,"%s:%d\n", attr_to_name(attr->type), attr->u.num);
        switch (attr->type) {
        case attr_flags:
                this_->flags=attr->u.num;
@@ -34,7 +37,7 @@ vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr)
                this_->flags_forward_mask=attr->u.num;
                break;
        case attr_flags_reverse_mask:
-               this_->flags_forward_mask=attr->u.num;
+               this_->flags_reverse_mask=attr->u.num;
                break;
        case attr_maxspeed_handling:
                this_->maxspeed_handling=attr->u.num;
@@ -42,6 +45,12 @@ vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr)
        case attr_route_mode:
                this_->mode=attr->u.num;
                break;
+       case attr_name:
+               if(this_->name)
+                       g_free(this_->name);
+               /* previously used strdupn not available on win32 */
+               this_->name = g_strdup(attr->u.str);
+               break;
        default:
                break;
        }
@@ -84,7 +93,7 @@ vehicleprofile_add_attr(struct vehicleprofile *this_, struct attr *attr)
        struct attr item_types_attr;
        switch (attr->type) {
        case attr_roadprofile:
-               if (roadprofile_get_attr(attr->u.roadprofile, attr_item_types, &item_types_attr)) {
+               if (roadprofile_get_attr(attr->u.roadprofile, attr_item_types, &item_types_attr, NULL)) {
                        enum item_type *types=item_types_attr.u.item_types;
                        while (*types != type_none) {
                                g_hash_table_insert(this_->roadprofile_hash, (void *)(long)(*types), attr->u.roadprofile);
@@ -105,8 +114,14 @@ vehicleprofile_remove_attr(struct vehicleprofile *this_, struct attr *attr)
        return 1;
 }
 
-struct roadprofile_data *
+struct roadprofile *
 vehicleprofile_get_roadprofile(struct vehicleprofile *this_, enum item_type type)
 {
        return g_hash_table_lookup(this_->roadprofile_hash, (void *)(long)type);
 }
+
+char *
+vehicleprofile_get_name(struct vehicleprofile *this_)
+{
+    return this_->name;
+}