Esempio n. 1
0
static int editor_override_find (int line, editor_db_override **data, int *create) {

   int id;
   int count;
   int square = roadmap_square_active ();
   editor_db_override *rec;
   
   count = editor_db_get_item_count (ActiveOverridesDB);

	for (id = 0; id < count; id++) {
		
		rec = (editor_db_override *)editor_db_get_item (ActiveOverridesDB, id, 0, NULL);
		if (rec->square == square && rec->line == line) {
			if (create) *create = 0;
			break;
		}
	}
	
	if (id == count) {
		if (!create) return -1;
		
		id = editor_db_add_item (ActiveOverridesDB, NULL, 0); 
		if (id >= 0) {
			rec = (editor_db_override *)editor_db_get_item (ActiveOverridesDB, id, 0, NULL);
			rec->square = square;
			rec->line = line;
			rec->flags = 0;
			rec->direction = roadmap_line_route_get_direction (line, ROUTE_CAR_ALLOWED);
			*create = 1;
		}
	}
	
	if (data) *data = rec;
	return id;
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
int  editor_marker_count(void) {

    if (!ActiveMarkersDB) return 0;

    return editor_db_get_item_count (ActiveMarkersDB);
}
Esempio n. 4
0
int editor_line_get_count (void) {
   
   return editor_db_get_item_count (ActiveLinesDB);
}