int command_unmark_special(char *text, int len, int do_log) { int i; while (isspace(*text)) text++; if(*text) { for (i = 0; i < max_mark; i ++) { if (my_strcompare(marks[i].text, text) && (marks[i].x != -1) && !marks[i].server_side) { char str[512]; marks[i].x = marks[i].y = -1; if (do_log) { safe_snprintf(str, sizeof(str), unmarked_str, marks[i].text); LOG_TO_CONSOLE(c_orange1, str); } save_markings(); load_map_marks(); // simply to compact the array and make room for new marks break; } } } return 1; }
void delete_mark_on_map_on_mouse_position() { int min_mouse_x = (window_width-hud_x)/6; int min_mouse_y = 0; int mx , my , i; int max_mouse_x = min_mouse_x+((window_width-hud_x)/1.5); int max_mouse_y = window_height - hud_y; int screen_map_width = max_mouse_x - min_mouse_x; int screen_map_height = max_mouse_y - min_mouse_y; int min_distance; marking * closest_mark; // FIXME (Malaclypse): should be moved above the screen_map_* init, to avoid additional computation if (mouse_x < min_mouse_x || mouse_x > max_mouse_x || mouse_y < min_mouse_y || mouse_y > max_mouse_y) { return; } mx = ((mouse_x - min_mouse_x) * tile_map_size_x * 6) / screen_map_width; my = (tile_map_size_y * 6) - ((mouse_y * tile_map_size_y * 6) / screen_map_height); // delete mark closest to cursor min_distance = 20*20; // only check close marks closest_mark = NULL; for ( i = 0 ; i < max_mark ; i ++ ) { int distance, dx, dy; marking * const mark = &marks[i]; // skip masked marks if (mark->x < 0 || mark->server_side) continue; // get mark to cursor distance (squared) dx = mark->x - mx; dy = mark->y - my; distance = dx*dx + dy*dy; // prefer deleting closer and newer marks if (distance <= min_distance) { // found a closer mark closest_mark = mark; min_distance = distance; } } if (closest_mark != NULL) { // we found a close mark closest_mark->x = -1 ; closest_mark->y = -1 ; } save_markings(); load_map_marks(); // simply to compact the array and make room for new marks }
void change_map (const char *mapname) { #ifndef MAP_EDITOR remove_all_bags(); remove_all_mines(); #endif //MAP_EDITOR set_all_intersect_update_needed(main_bbox_tree); object_under_mouse=-1;//to prevent a nasty crash, while looking for bags, when we change the map #ifndef MAP_EDITOR2 #ifdef EXTRA_DEBUG ERR(); #endif close_dialogue(); // close the dialogue window if open close_storagewin(); //if storage is open, close it destroy_all_particles(); ec_delete_all_effects(); #ifdef NEW_SOUND stop_all_sounds(); #endif //NEW_SOUND missiles_clear(); if (!el_load_map(mapname)) { char error[255]; safe_snprintf(error, sizeof(error), cant_change_map, mapname); LOG_TO_CONSOLE(c_red4, error); LOG_TO_CONSOLE(c_red4, empty_map_str); LOG_ERROR(cant_change_map, mapname); load_empty_map(); } else { locked_to_console = 0; } load_map_marks(); #ifdef NEW_SOUND get_map_playlist(); setup_map_sounds(get_cur_map(mapname)); #endif // NEW_SOUND have_a_map=1; //also, stop the rain weather_clear(); if ( get_show_window (map_root_win) ) { hide_window(map_root_win); show_window(game_root_win); } #else // !MAP_EDITOR2 destroy_all_particles(); #ifdef NEW_SOUND stop_all_sounds(); #endif //NEW_SOUND if (!load_map(mapname)) { char error[255]; safe_snprintf(error, sizeof(error), cant_change_map, mapname); LOG_TO_CONSOLE(c_red4, error); LOG_TO_CONSOLE(c_red4, empty_map_str); LOG_ERROR(cant_change_map, mapname); load_empty_map(); } #ifdef NEW_SOUND get_map_playlist(); setup_map_sounds(get_cur_map(mapname)); #endif // NEW_SOUND have_a_map=1; #endif //MAP_EDITOR2 change_minimap(); #ifdef PAWN run_pawn_map_function ("change_map", "s", mapname); #endif }