void editor_marker_update(int marker, unsigned char flags, const char *note) { editor_db_marker *marker_st = editor_db_get_item (ActiveMarkersDB, marker, 0, 0); int dirty = 0; assert(marker_st != NULL); if (note == NULL) { if (marker_st->note != ROADMAP_INVALID_STRING) { dirty++; marker_st->note = ROADMAP_INVALID_STRING; } } else if ((marker_st->note == ROADMAP_INVALID_STRING) || strcmp(editor_dictionary_get(marker_st->note), note)) { dirty++; marker_st->note = editor_dictionary_add(note); } if ((marker_st->flags & ~ED_MARKER_DIRTY) != (flags & ~ED_MARKER_DIRTY)) { dirty++; } marker_st->flags = flags; if (dirty) editor_db_update_item(ActiveMarkersDB, marker); }
int editor_marker_add(int longitude, int latitude, int steering, time_t time, unsigned char type, unsigned char flags, const char *note, const char *icon) { editor_db_marker marker; int id; while (steering < 0) { steering += 360; } while (steering >= 360) { steering -= 360; } marker.longitude = longitude; marker.latitude = latitude; marker.steering = steering; marker.time = time; marker.type = type; marker.flags = flags | ED_MARKER_DIRTY; if (note == NULL) { marker.note = ROADMAP_INVALID_STRING; } else { marker.note = editor_dictionary_add(note); } if (icon == NULL) { marker.icon = ROADMAP_INVALID_STRING; } else { marker.icon = editor_dictionary_add(icon); } id = editor_db_add_item (ActiveMarkersDB, &marker, 1); return id; }
int editor_street_create (const char *_name, const char *_type, const char *_prefix, const char *_suffix, const char *_city, const char *_t2s) { editor_db_street street; street.fename = editor_dictionary_add (_name); street.fetype = editor_dictionary_add (_type); street.fedirp = editor_dictionary_add (_prefix); street.fedirs = editor_dictionary_add (_suffix); street.city = editor_dictionary_add (_city); street.t2s = editor_dictionary_add (_t2s); //TODO optimize - this is a linear search if (street.fename != -1) { int i; for (i = editor_db_get_item_count (ActiveStreetDB) - 1; i >= 0; i--) { editor_db_street *street_ptr = (editor_db_street *) editor_db_get_item (ActiveStreetDB, i, 0, NULL); assert (street_ptr != NULL); if ((street_ptr != NULL) && !memcmp (street_ptr, &street, sizeof (editor_db_street))) { return i; } } } return editor_db_add_item (ActiveStreetDB, &street, 1); }