Ticket #137: works-on-win-no-tests.diff
| File works-on-win-no-tests.diff, 110.5 kB (added by takkaria, 1 year ago) |
|---|
-
cmd4.c
old new 212 212 static void place_visual_list_cursor(int col, int row, byte a, 213 213 byte c, byte attr_top, byte char_left); 214 214 215 static void dump_pref_file(void (*dump)( FILE*), const char *title, int row);215 static void dump_pref_file(void (*dump)(ang_file *), const char *title, int row); 216 216 217 217 /* 218 218 * Clipboard variables for copy&paste in visual mode … … 2537 2537 2538 2538 2539 2539 /* 2540 * Header and footer marker string for pref file dumps2540 * Header and footer marker string for pref file dumps 2541 2541 */ 2542 2542 static cptr dump_separator = "#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#"; 2543 2543 … … 2545 2545 /* 2546 2546 * Remove old lines from pref files 2547 2547 */ 2548 static void remove_old_dump(const char * orig_file, const char *mark)2548 static void remove_old_dump(const char *cur_fname, const char *mark) 2549 2549 { 2550 FILE *tmp_fff, *orig_fff;2551 2552 char tmp_file[1024];2553 char buf[1024];2554 2550 bool between_marks = FALSE; 2555 2551 bool changed = FALSE; 2556 char expected_line[1024];2557 2552 2553 char buf[1024]; 2558 2554 2559 /* Open an old dump file in read-only mode */2560 orig_fff = my_fopen(orig_file, "r");2555 char start_line[1024]; 2556 char end_line[1024]; 2561 2557 2562 /* If original file does not exist, nothing to do */ 2563 if (!orig_fff) return; 2558 char new_fname[1024]; 2564 2559 2565 /* Open a new temporary file */2566 tmp_fff = my_fopen_temp(tmp_file, sizeof(tmp_file));2560 ang_file *new_file; 2561 ang_file *cur_file; 2567 2562 2568 if (!tmp_fff)2569 {2570 msg_format("Failed to create temporary file %s.", tmp_file);2571 msg_print(NULL);2572 return;2573 }2574 2563 2564 /* Format up some filenames */ 2565 strnfmt(new_fname, sizeof(new_fname), "%s.new", cur_fname); 2566 2575 2567 /* Work out what we expect to find */ 2576 strnfmt(expected_line, sizeof(expected_line), "%s begin %s", dump_separator, mark); 2568 strnfmt(start_line, sizeof(start_line), "%s begin %s", dump_separator, mark); 2569 strnfmt(end_line, sizeof(end_line), "%s end %s", dump_separator, mark); 2577 2570 2571 2572 2573 /* Open current file */ 2574 cur_file = file_open(cur_fname, MODE_READ, -1); 2575 if (!cur_file) return; 2576 2577 /* Open new file */ 2578 new_file = file_open(new_fname, MODE_WRITE, FTYPE_TEXT); 2579 if (!new_file) 2580 { 2581 msg_format("Failed to create file %s", new_fname); 2582 return; 2583 } 2584 2578 2585 /* Loop for every line */ 2579 while ( TRUE)2586 while (file_getl(cur_file, buf, sizeof(buf))) 2580 2587 { 2581 /* Read a line*/2582 if ( my_fgets(orig_fff, buf, sizeof(buf)))2588 /* If we find the start line, turn on */ 2589 if (!strcmp(buf, start_line)) 2583 2590 { 2584 /* End of file but no end marker */ 2585 if (between_marks) changed = FALSE; 2586 2587 break; 2591 between_marks = TRUE; 2588 2592 } 2589 2593 2590 /* I s this line a header/footer?*/2591 if (strncmp(buf, dump_separator, strlen(dump_separator)) == 0)2594 /* If we find the finish line, turn off */ 2595 else if (!strcmp(buf, end_line)) 2592 2596 { 2593 /* Found the expected line? */ 2594 if (strcmp(buf, expected_line) == 0) 2595 { 2596 if (!between_marks) 2597 { 2598 /* Expect the footer next */ 2599 strnfmt(expected_line, sizeof(expected_line), 2600 "%s end %s", dump_separator, mark); 2601 2602 between_marks = TRUE; 2603 2604 /* There are some changes */ 2605 changed = TRUE; 2606 } 2607 else 2608 { 2609 /* Expect a header next - XXX shouldn't happen */ 2610 strnfmt(expected_line, sizeof(expected_line), 2611 "%s begin %s", dump_separator, mark); 2612 2613 between_marks = FALSE; 2614 2615 /* Next line */ 2616 continue; 2617 } 2618 } 2619 2620 /* Found a different line */ 2621 else 2622 { 2623 /* Expected a footer and got something different? */ 2624 if (between_marks) 2625 { 2626 /* Abort */ 2627 changed = FALSE; 2628 break; 2629 } 2630 } 2597 between_marks = FALSE; 2598 changed = TRUE; 2631 2599 } 2632 2600 2633 2601 if (!between_marks) 2634 2602 { 2635 2603 /* Copy orginal line */ 2636 f printf(tmp_fff, "%s\n", buf);2604 file_putf(new_file, "%s\n", buf); 2637 2605 } 2638 2606 } 2639 2607 2640 2608 /* Close files */ 2641 my_fclose(orig_fff);2642 my_fclose(tmp_fff);2609 file_close(cur_file); 2610 file_close(new_file); 2643 2611 2644 /* If there are changes, overwrite the original file with the new one*/2612 /* If there are changes, move things around */ 2645 2613 if (changed) 2646 2614 { 2647 /* Copy contents of temporary file */ 2648 tmp_fff = my_fopen(tmp_file, "r"); 2649 orig_fff = my_fopen(orig_file, "w"); 2615 char old_fname[1024]; 2616 strnfmt(old_fname, sizeof(old_fname), "%s.old", cur_fname); 2650 2617 2651 while (!my_fgets(tmp_fff, buf, sizeof(buf)))2652 fprintf(orig_fff, "%s\n", buf);2653 2654 my_fclose(orig_fff);2655 my_fclose(tmp_fff);2618 if (file_move(cur_fname, old_fname)) 2619 { 2620 file_move(new_fname, cur_fname); 2621 file_delete(old_fname); 2622 } 2656 2623 } 2657 2624 2658 /* Kill the temporary file */ 2659 fd_kill(tmp_file); 2625 /* Otherwise just destroy the new file */ 2626 else 2627 { 2628 file_delete(new_fname); 2629 } 2660 2630 } 2661 2631 2662 2632 2663 2633 /* 2664 2634 * Output the header of a pref-file dump 2665 2635 */ 2666 static void pref_header( FILE*fff, const char *mark)2636 static void pref_header(ang_file *fff, const char *mark) 2667 2637 { 2668 2638 /* Start of dump */ 2669 f printf(fff, "%s begin %s\n", dump_separator, mark);2639 file_putf(fff, "%s begin %s\n", dump_separator, mark); 2670 2640 2671 f printf(fff, "# *Warning!* The lines below are an automatic dump.\n");2672 f printf(fff, "# Don't edit them; changes will be deleted and replaced automatically.\n");2641 file_putf(fff, "# *Warning!* The lines below are an automatic dump.\n"); 2642 file_putf(fff, "# Don't edit them; changes will be deleted and replaced automatically.\n"); 2673 2643 } 2674 2644 2675 2645 /* 2676 2646 * Output the footer of a pref-file dump 2677 2647 */ 2678 static void pref_footer( FILE*fff, const char *mark)2648 static void pref_footer(ang_file *fff, const char *mark) 2679 2649 { 2680 f printf(fff, "# *Warning!* The lines above are an automatic dump.\n");2681 f printf(fff, "# Don't edit them; changes will be deleted and replaced automatically.\n");2650 file_putf(fff, "# *Warning!* The lines above are an automatic dump.\n"); 2651 file_putf(fff, "# Don't edit them; changes will be deleted and replaced automatically.\n"); 2682 2652 2683 2653 /* End of dump */ 2684 f printf(fff, "%s end %s\n", dump_separator, mark);2654 file_putf(fff, "%s end %s\n", dump_separator, mark); 2685 2655 } 2686 2656 2687 2657 … … 2692 2662 * - dump(FILE *) needs to emit only the raw data for the dump. 2693 2663 * Comments are generated automatically 2694 2664 */ 2695 static void dump_pref_file(void (*dump)( FILE*), const char *title, int row)2665 static void dump_pref_file(void (*dump)(ang_file *), const char *title, int row) 2696 2666 { 2697 2667 char ftmp[80]; 2698 2668 char buf[1025]; 2699 FILE*fff;2669 ang_file *fff; 2700 2670 2701 2671 /* Prompt */ 2702 2672 prt(format("%s to a pref file", title), row, 0); … … 2713 2683 /* Build the filename */ 2714 2684 path_build(buf, 1024, ANGBAND_DIR_USER, ftmp); 2715 2685 2716 FILE_TYPE(FILE_TYPE_TEXT);2717 2718 2686 /* Remove old macros */ 2719 2687 remove_old_dump(buf, title); 2720 2688 2721 2689 /* Append to the file */ 2722 fff = my_fopen(buf, "a"); 2723 2724 /* Failure */ 2690 fff = file_open(buf, MODE_APPEND, FTYPE_TEXT); 2725 2691 if (!fff) 2726 2692 { 2727 2693 prt("", 0, 0); … … 2733 2699 pref_header(fff, title); 2734 2700 2735 2701 /* Skip some lines */ 2736 f printf(fff, "\n\n");2702 file_putf(fff, "\n\n"); 2737 2703 2738 2704 /* Start dumping */ 2739 f printf(fff, "# %s definitions\n\n", strstr(title, " "));2705 file_putf(fff, "# %s definitions\n\n", strstr(title, " ")); 2740 2706 2741 2707 dump(fff); 2742 2708 2743 2709 /* All done */ 2744 f printf(fff, "\n\n\n");2710 file_putf(fff, "\n\n\n"); 2745 2711 2746 2712 /* Output footer */ 2747 2713 pref_footer(fff, title); 2748 2714 2749 2715 /* Close */ 2750 my_fclose(fff);2716 file_close(fff); 2751 2717 2752 2718 /* Message */ 2753 2719 prt("", 0, 0); … … 2757 2723 /* 2758 2724 * Save autoinscription data to a pref file. 2759 2725 */ 2760 static void autoinsc_dump( FILE*fff)2726 static void autoinsc_dump(ang_file *fff) 2761 2727 { 2762 2728 int i; 2729 if (!inscriptions) return; 2763 2730 2764 if (!inscriptions)2765 return;2731 file_putf(fff, "# Autoinscription settings\n"); 2732 file_putf(fff, "# B:item kind:inscription\n\n"); 2766 2733 2767 /* Start dumping */2768 fprintf(fff, "# Autoinscription settings");2769 fprintf(fff, "# B:item kind:inscription\n\n");2770 2771 2734 for (i = 0; i < inscriptions_count; i++) 2772 2735 { 2773 2736 object_kind *k_ptr = &k_info[inscriptions[i].kind_idx]; 2774 2737 2775 /* Describe and write */ 2776 fprintf(fff, "# Autoinscription for %s\n", k_name + k_ptr->name); 2777 fprintf(fff, "B:%d:%s\n\n", inscriptions[i].kind_idx, 2738 file_putf(fff, "# Autoinscription for %s\n", k_name + k_ptr->name); 2739 file_putf(fff, "B:%d:%s\n\n", inscriptions[i].kind_idx, 2778 2740 quark_str(inscriptions[i].inscription_idx)); 2779 2741 } 2780 2742 2781 /* All done */ 2782 fprintf(fff, "\n"); 2743 file_putf(fff, "\n"); 2783 2744 } 2784 2745 2785 2746 /* 2786 2747 * Save squelch data to a pref file. 2787 2748 */ 2788 static void squelch_dump( FILE*fff)2749 static void squelch_dump(ang_file *fff) 2789 2750 { 2790 2751 int i; 2791 int tval, sval; 2792 bool squelch; 2752 file_putf(fff, "# Squelch settings\n"); 2793 2753 2794 /* Start dumping */2795 fprintf(fff, "\n\n");2796 fprintf(fff, "# Squelch bits\n\n");2797 2798 /* Dump squelch bits */2799 2754 for (i = 1; i < z_info->k_max; i++) 2800 2755 { 2801 tval = k_info[i].tval;2802 sval = k_info[i].sval;2803 squelch = k_info[i].squelch;2756 int tval = k_info[i].tval; 2757 int sval = k_info[i].sval; 2758 bool squelch = k_info[i].squelch; 2804 2759 2805 2760 /* Dump the squelch info */ 2806 2761 if (tval || sval) 2807 f printf(fff, "Q:%d:%d:%d:%d\n", i, tval, sval, squelch);2762 file_putf(fff, "Q:%d:%d:%d:%d\n", i, tval, sval, squelch); 2808 2763 } 2809 2764 2810 /* All done */ 2811 fprintf(fff, "\n"); 2765 file_putf(fff, "\n"); 2812 2766 } 2813 2767 2814 2768 /* 2815 2769 * Write all current options to a user preference file. 2816 2770 */ 2817 static void option_dump( FILE*fff)2771 static void option_dump(ang_file *fff) 2818 2772 { 2819 2773 int i, j; 2820 2774 … … 2825 2779 if (!name) continue; 2826 2780 2827 2781 /* Comment */ 2828 f printf(fff, "# Option '%s'\n", option_desc(i));2782 file_putf(fff, "# Option '%s'\n", option_desc(i)); 2829 2783 2830 2784 /* Dump the option */ 2831 2785 if (op_ptr->opt[i]) 2832 f printf(fff, "Y:%s\n", name);2786 file_putf(fff, "Y:%s\n", name); 2833 2787 else 2834 f printf(fff, "X:%s\n", name);2788 file_putf(fff, "X:%s\n", name); 2835 2789 2836 2790 /* Skip a line */ 2837 f printf(fff, "\n");2791 file_putf(fff, "\n"); 2838 2792 } 2839 2793 2840 2794 /* Dump window flags */ … … 2850 2804 if (!window_flag_desc[j]) continue; 2851 2805 2852 2806 /* Comment */ 2853 f printf(fff, "# Window '%s', Flag '%s'\n",2807 file_putf(fff, "# Window '%s', Flag '%s'\n", 2854 2808 angband_term_name[i], window_flag_desc[j]); 2855 2809 2856 2810 /* Dump the flag */ 2857 2811 if (op_ptr->window_flag[i] & (1L << j)) 2858 { 2859 fprintf(fff, "W:%d:%d:1\n", i, j); 2860 } 2812 file_putf(fff, "W:%d:%d:1\n", i, j); 2861 2813 else 2862 { 2863 fprintf(fff, "W:%d:%d:0\n", i, j); 2864 } 2814 file_putf(fff, "W:%d:%d:0\n", i, j); 2865 2815 2866 2816 /* Skip a line */ 2867 f printf(fff, "\n");2817 file_putf(fff, "\n"); 2868 2818 } 2869 2819 } 2870 2820 … … 2877 2827 #ifdef ALLOW_MACROS 2878 2828 2879 2829 /* 2880 * append all current macros to the given file2830 * Append all current macros to the given file 2881 2831 */ 2882 static void macro_dump( FILE*fff)2832 static void macro_dump(ang_file *fff) 2883 2833 { 2884 2834 int i; 2885 2835 char buf[1024]; … … 2888 2838 for (i = 0; i < macro__num; i++) 2889 2839 { 2890 2840 /* Start the macro */ 2891 f printf(fff, "# Macro '%d'\n\n", i);2841 file_putf(fff, "# Macro '%d'\n", i); 2892 2842 2893 2843 /* Extract the macro action */ 2894 2844 ascii_to_text(buf, sizeof(buf), macro__act[i]); 2845 file_putf(fff, "A:%s\n", buf); 2895 2846 2896 /* Dump the macro action */2897 fprintf(fff, "A:%s\n", buf);2898 2899 2847 /* Extract the macro pattern */ 2900 2848 ascii_to_text(buf, sizeof(buf), macro__pat[i]); 2849 file_putf(fff, "P:%s\n", buf); 2901 2850 2902 /* Dump the macro pattern */ 2903 fprintf(fff, "P:%s\n", buf); 2904 2905 /* End the macro */ 2906 fprintf(fff, "\n\n"); 2851 file_putf(fff, "\n"); 2907 2852 } 2908 2853 } 2909 2854 … … 3006 2951 * 3007 2952 * Hack -- We only append the keymaps for the "active" mode. 3008 2953 */ 3009 static void keymap_dump( FILE*fff)2954 static void keymap_dump(ang_file *fff) 3010 2955 { 3011 int i;2956 size_t i; 3012 2957 int mode; 3013 2958 char buf[1024]; 3014 2959 3015 /* Roguelike */3016 2960 if (rogue_like_commands) 3017 {3018 2961 mode = KEYMAP_MODE_ROGUE; 3019 }3020 3021 /* Original */3022 2962 else 3023 {3024 2963 mode = KEYMAP_MODE_ORIG; 3025 }3026 2964 3027 for (i = 0; i < (int)N_ELEMENTS(keymap_act[mode]); i++)2965 for (i = 0; i < N_ELEMENTS(keymap_act[mode]); i++) 3028 2966 { 3029 2967 char key[2] = "?"; 3030 3031 2968 cptr act; 3032 2969 3033 2970 /* Loop up the keymap */ … … 3040 2977 ascii_to_text(buf, sizeof(buf), act); 3041 2978 3042 2979 /* Dump the keymap action */ 3043 f printf(fff, "A:%s\n", buf);2980 file_putf(fff, "A:%s\n", buf); 3044 2981 3045 2982 /* Convert the key into a string */ 3046 2983 key[0] = i; … … 3049 2986 ascii_to_text(buf, sizeof(buf), key); 3050 2987 3051 2988 /* Dump the keymap pattern */ 3052 f printf(fff, "C:%d:%s\n", mode, buf);2989 file_putf(fff, "C:%d:%s\n", mode, buf); 3053 2990 3054 2991 /* Skip a line */ 3055 f printf(fff, "\n");2992 file_putf(fff, "\n"); 3056 2993 } 3057 2994 3058 2995 } … … 3098 3035 3099 3036 region loc = {0, 0, 0, 12}; 3100 3037 3101 /* Roguelike */3102 3038 if (rogue_like_commands) 3103 {3104 3039 mode = KEYMAP_MODE_ROGUE; 3105 }3106 3107 /* Original */3108 3040 else 3109 {3110 3041 mode = KEYMAP_MODE_ORIG; 3111 }3112 3042 3113 3043 3114 /* File type is "TEXT" */3115 FILE_TYPE(FILE_TYPE_TEXT);3116 3117 3044 screen_save(); 3118 3045 3119 3046 menu_layout(¯o_menu, &loc); … … 3397 3324 3398 3325 3399 3326 /* Dump monsters */ 3400 static void dump_monsters( FILE*fff)3327 static void dump_monsters(ang_file *fff) 3401 3328 { 3402 3329 int i; 3330 3403 3331 for (i = 0; i < z_info->r_max; i++) 3404 3332 { 3405 3333 monster_race *r_ptr = &r_info[i]; 3334 byte attr = r_ptr->x_attr; 3335 byte chr = r_ptr->x_char; 3406 3336 3407 3337 /* Skip non-entries */ 3408 3338 if (!r_ptr->name) continue; 3409 3339 3410 /* Dump a comment */ 3411 fprintf(fff, "# %s\n", (r_name + r_ptr->name)); 3412 3413 /* Dump the monster attr/char info */ 3414 fprintf(fff, "R:%d:0x%02X:0x%02X\n\n", i, 3415 (byte)(r_ptr->x_attr), (byte)(r_ptr->x_char)); 3340 file_putf(fff, "# Monster: %s\n", (r_name + r_ptr->name)); 3341 file_putf(fff, "R:%d:0x%02X:0x%02X\n", i, attr, chr); 3416 3342 } 3417 3343 } 3418 3344 3419 3345 /* Dump objects */ 3420 static void dump_objects( FILE*fff)3346 static void dump_objects(ang_file *fff) 3421 3347 { 3422 3348 int i; 3349 3423 3350 for (i = 0; i < z_info->k_max; i++) 3424 3351 { 3425 3352 object_kind *k_ptr = &k_info[i]; 3353 byte attr = k_ptr->x_attr; 3354 byte chr = k_ptr->x_char; 3426 3355 3427 3356 /* Skip non-entries */ 3428 3357 if (!k_ptr->name) continue; 3429 3358 3430 /* Dump a comment */ 3431 fprintf(fff, "# %s\n", (k_name + k_ptr->name)); 3432 3433 /* Dump the object attr/char info */ 3434 fprintf(fff, "K:%d:0x%02X:0x%02X\n\n", i, 3435 (byte)(k_ptr->x_attr), (byte)(k_ptr->x_char)); 3359 file_putf(fff, "# Object: %s\n", (k_name + k_ptr->name)); 3360 file_putf(fff, "K:%d:0x%02X:0x%02X\n", i, attr, chr); 3436 3361 } 3437 3362 } 3438 3363 3439 3364 /* Dump features */ 3440 static void dump_features( FILE*fff)3365 static void dump_features(ang_file *fff) 3441 3366 { 3442 3367 int i; 3368 3443 3369 for (i = 0; i < z_info->f_max; i++) 3444 3370 { 3445 3371 feature_type *f_ptr = &f_info[i]; 3372 byte attr = f_ptr->x_attr; 3373 byte chr = f_ptr->x_char; 3446 3374 3447 3375 /* Skip non-entries */ 3448 3376 if (!f_ptr->name) continue; … … 3450 3378 /* Skip mimic entries -- except invisible trap */ 3451 3379 if ((f_ptr->mimic != i) && (i != FEAT_INVIS)) continue; 3452 3380 3453 /* Dump a comment */ 3454 fprintf(fff, "# %s\n", (f_name + f_ptr->name)); 3455 3456 /* Dump the feature attr/char info */ 3457 /* Dump the feature attr/char info */ 3458 fprintf(fff, "F:%d:0x%02X:0x%02X\n\n", i, 3459 (byte)(f_ptr->x_attr), (byte)(f_ptr->x_char)); 3460 3461 3381 file_putf(fff, "# Terrain: %s\n", (f_name + f_ptr->name)); 3382 file_putf(fff, "F:%d:0x%02X:0x%02X\n", i, attr, chr); 3462 3383 } 3463 3384 } 3464 3385 3465 3386 /* Dump flavors */ 3466 static void dump_flavors( FILE*fff)3387 static void dump_flavors(ang_file *fff) 3467 3388 { 3468 3389 int i; 3390 3469 3391 for (i = 0; i < z_info->flavor_max; i++) 3470 3392 { 3471 3393 flavor_type *x_ptr = &flavor_info[i]; 3394 byte attr = x_ptr->x_attr; 3395 byte chr = x_ptr->x_char; 3472 3396 3473 /* Dump a comment */ 3474 fprintf(fff, "# %s\n", (flavor_text + x_ptr->text)); 3475 3476 /* Dump the flavor attr/char info */ 3477 fprintf(fff, "L:%d:0x%02X:0x%02X\n\n", i, 3478 (byte)(x_ptr->x_attr), (byte)(x_ptr->x_char)); 3397 file_putf(fff, "# Item flavor: %s\n", (flavor_text + x_ptr->text)); 3398 file_putf(fff, "L:%d:0x%02X:0x%02X\n\n", i, attr, chr); 3479 3399 } 3480 3400 } 3481 3401 3482 3402 /* Dump colors */ 3483 static void dump_colors( FILE*fff)3403 static void dump_colors(ang_file *fff) 3484 3404 { 3485 3405 int i; 3406 3486 3407 for (i = 0; i < MAX_COLORS; i++) 3487 3408 { 3488 3409 int kv = angband_color_table[i][0]; … … 3498 3419 /* Extract the color name */ 3499 3420 if (i < BASIC_COLORS) name = color_names[i]; 3500 3421 3501 /* Dump a comment */ 3502 fprintf(fff, "# Color '%s'\n", name); 3503 3422 file_putf(fff, "# Color: %s\n", name); 3423 file_putf(fff, "V:%d:0x%02X:0x%02X:0x%02X:0x%02X\n\n", i, kv, rv, gv, bv); 3504 3424 } 3505 3425 } 3506 3426 … … 3800 3720 int cx; 3801 3721 int cursor = 0; 3802 3722 3803 /* File type is "TEXT" */3804 FILE_TYPE(FILE_TYPE_TEXT);3805 3806 /* Save screen */3807 3723 screen_save(); 3808 3724 3809 3725 menu_layout(&color_menu, &SCREEN_REGION); … … 4439 4355 4440 4356 bool okay = TRUE; 4441 4357 4442 FILE*fp;4358 ang_file *fp; 4443 4359 4444 4360 char buf[1024]; 4445 4361 4446 4362 4447 4363 /* Build the filename */ 4448 4364 path_build(buf, 1024, ANGBAND_DIR_USER, "dump.txt"); 4449 4450 /* Open the file */ 4451 fp = my_fopen(buf, "r"); 4452 4453 /* Oops */ 4365 fp = file_open(buf, MODE_READ, -1); 4454 4366 if (!fp) return; 4455 4367 4456 4368 … … 4466 4378 for (y = 0; okay && (y < 24); y++) 4467 4379 { 4468 4380 /* Get a line of data */ 4469 if ( my_fgets(fp, buf, sizeof(buf))) okay = FALSE;4381 if (!file_getl(fp, buf, sizeof(buf))) okay = FALSE; 4470 4382 4471 4383 4472 4384 /* Show each row */ … … 4478 4390 } 4479 4391 4480 4392 /* Get the blank line */ 4481 if ( my_fgets(fp, buf, sizeof(buf))) okay = FALSE;4393 if (!file_getl(fp, buf, sizeof(buf))) okay = FALSE; 4482 4394 4483 4395 4484 4396 /* Dump the screen */ 4485 4397 for (y = 0; okay && (y < 24); y++) 4486 4398 { 4487 4399 /* Get a line of data */ 4488 if ( my_fgets(fp, buf, sizeof(buf))) okay = FALSE;4400 if (!file_getl(fp, buf, sizeof(buf))) okay = FALSE; 4489 4401 4490 4402 /* Dump each row */ 4491 4403 for (x = 0; x < 79; x++) … … 4507 4419 4508 4420 4509 4421 /* Close it */ 4510 my_fclose(fp);4422 file_close(fp); 4511 4423 4512 4424 4513 4425 /* Message */ … … 4530 4442 byte a = 0; 4531 4443 char c = ' '; 4532 4444 4533 FILE*fff;4445 ang_file *fff; 4534 4446 4535 4447 char buf[1024]; 4536 4448 4537 4449 /* Build the filename */ 4538 4450 path_build(buf, 1024, ANGBAND_DIR_USER, "dump.txt"); 4539 4540 /* File type is "DATA" -- needs to be opened in Angband to view */ 4541 FILE_TYPE(FILE_TYPE_DATA); 4542 4543 /* Append to the file */ 4544 fff = my_fopen(buf, "w"); 4545 4546 /* Oops */ 4451 fff = file_open(buf, MODE_WRITE, FTYPE_TEXT); 4547 4452 if (!fff) return; 4548 4453 4549 4454 … … 4568 4473 buf[x] = '\0'; 4569 4474 4570 4475 /* End the row */ 4571 f printf(fff, "%s\n", buf);4476 file_putf(fff, "%s\n", buf); 4572 4477 } 4573 4478 4574 4479 /* Skip a line */ 4575 f printf(fff, "\n");4480 file_putf(fff, "\n"); 4576 4481 4577 4482 4578 4483 /* Dump the screen */ … … 4592 4497 buf[x] = '\0'; 4593 4498 4594 4499 /* End the row */ 4595 f printf(fff, "%s\n", buf);4500 file_putf(fff, "%s\n", buf); 4596 4501 } 4597 4502 4598 4503 /* Skip a line */ 4599 f printf(fff, "\n");4504 file_putf(fff, "\n"); 4600 4505 4601 4506 4602 4507 /* Close it */ 4603 my_fclose(fff);4508 file_close(fff); 4604 4509 4605 4510 4606 4511 /* Message */ … … 4620 4525 { 4621 4526 size_t i; 4622 4527 4623 FILE*fff;4528 ang_file *fff; 4624 4529 char file_name[1024]; 4625 4530 char tmp_val[256]; 4626 4531 4627 typedef void (*dump_func)( FILE*);4532 typedef void (*dump_func)(ang_file *); 4628 4533 dump_func dump_visuals [] = 4629 4534 { dump_monsters, dump_features, dump_objects, dump_flavors, dump_colors }; 4630 4535 4631 /* File type is "TEXT" */4632 FILE_TYPE(FILE_TYPE_TEXT);4633 4536 4537 if (mode == 0) 4538 my_strcpy(tmp_val, "dump.html", sizeof(tmp_val)); 4539 else 4540 my_strcpy(tmp_val, "dump.txt", sizeof(tmp_val)); 4541 4634 4542 /* Ask for a file */ 4635 if (mode == 0) my_strcpy(tmp_val, "dump.html", sizeof(tmp_val));4636 else my_strcpy(tmp_val, "dump.txt", sizeof(tmp_val));4637 4543 if (!get_string("File: ", tmp_val, sizeof(tmp_val))) return; 4638 4544 4639 4545 /* Save current preferences */ 4640 4546 path_build(file_name, 1024, ANGBAND_DIR_USER, "dump.prf"); 4641 fff = my_fopen(file_name, "w");4547 fff = file_open(file_name, MODE_WRITE, (mode == 0 ? FTYPE_HTML : FTYPE_TEXT)); 4642 4548 4643 4549 /* Check for failure */ 4644 4550 if (!fff) … … 4652 4558 for (i = 0; i < N_ELEMENTS(dump_visuals); i++) 4653 4559 dump_visuals[i](fff); 4654 4560 4655 my_fclose(fff);4561 file_close(fff); 4656 4562 4657 4563 /* Dump the screen with raw character attributes */ 4658 4564 reset_visuals(FALSE); … … 4662 4568 /* Recover current graphics settings */ 4663 4569 reset_visuals(TRUE); 4664 4570 process_pref_file(file_name); 4665 f d_kill(file_name);4571 file_delete(file_name); 4666 4572 do_cmd_redraw(); 4667 4573 4668 4574 msg_print("HTML screen dump saved."); … … 4701 4607 } 4702 4608 } 4703 4609 4610 -
config.h
old new 191 191 * or "/usr/games/lib/angband/", or "/pkg/angband/lib". 192 192 */ 193 193 #ifndef DEFAULT_PATH 194 # define DEFAULT_PATH ". /lib/"194 # define DEFAULT_PATH "." PATH_SEP "lib" PATH_SEP 195 195 #endif /* DEFAULT_PATH */ 196 196 197 197 -
dungeon.c
old new 1913 1913 } 1914 1914 1915 1915 /* Check if we're overwriting a savefile */ 1916 while (!reusing_savefile && my_fexists(savefile))1916 while (!reusing_savefile && file_exists(savefile)) 1917 1917 { 1918 1918 /* Ask for confirmation */ 1919 1919 bool overwrite = get_check("Continuing will overwrite an existing savefile. Overwrite? "); -
externs.h
old new 132 132 extern s16b rating; 133 133 extern bool good_item_flag; 134 134 extern bool closing_flag; 135 extern int player_uid;136 extern int player_egid;137 135 extern char savefile[1024]; 138 136 extern s16b macro__num; 139 137 extern char **macro__pat; … … 238 236 extern bool (*get_mon_num_hook)(int r_idx); 239 237 extern bool (*get_obj_num_hook)(int k_idx); 240 238 extern void (*object_info_out_flags)(const object_type *o_ptr, u32b *f1, u32b *f2, u32b *f3); 241 extern FILE*text_out_file;239 extern ang_file *text_out_file; 242 240 extern void (*text_out_hook)(byte a, cptr str); 243 241 extern int text_out_wrap; 244 242 extern int text_out_indent; … … 725 723 * Hack -- conditional (or "bizarre") externs 726 724 */ 727 725 728 #ifdef RISCOS729 /* main-ros.c */730 extern char *riscosify_name(cptr path);731 #endif /* RISCOS */732 733 #if defined(MAC_MPW) || defined(MACH_O_CARBON)734 /* main-mac.c, or its derivatives */735 extern u32b _fcreator;736 extern u32b _ftype;737 # if defined(MAC_MPW) && defined(CARBON)738 extern void convert_pathname(char *path);739 # endif740 # if defined(MACH_O_CARBON)741 extern void fsetfileinfo(cptr path, u32b fcreator, u32b ftype);742 # endif743 #endif744 745 726 #ifdef ALLOW_DEBUG 746 727 /* wizard2.c */ 747 728 extern void do_cmd_debug(void); -
files.c
old new 854 854 */ 855 855 static errr process_pref_file_aux(cptr name) 856 856 { 857 FILE*fp;857 ang_file *fp; 858 858 859 859 char buf[1024]; 860 861 860 char old[1024]; 862 861 863 862 int line = -1; … … 868 867 869 868 870 869 /* Open the file */ 871 fp = my_fopen(name, "r"); 872 873 /* No such file */ 870 fp = file_open(name, MODE_READ, -1); 874 871 if (!fp) return (-1); 875 872 876 873 877 874 /* Process the file */ 878 while ( 0 == my_fgets(fp, buf, sizeof(buf)))875 while (file_getl(fp, buf, sizeof(buf))) 879 876 { 880 877 /* Count lines */ 881 878 line++; … … 885 882 if (!buf[0]) continue; 886 883 887 884 /* Skip "blank" lines */ 888 if (isspace((unsigned char) buf[0])) continue;885 if (isspace((unsigned char) buf[0])) continue; 889 886 890 887 /* Skip comments */ 891 888 if (buf[0] == '#') continue; … … 949 946 } 950 947 951 948 /* Close the file */ 952 my_fclose(fp);949 file_close(fp); 953 950 954 951 /* Result */ 955 952 return (err); … … 1743 1740 byte a; 1744 1741 char c; 1745 1742 1746 FILE *fff = NULL;1743 ang_file *fp; 1747 1744 1748 1745 store_type *st_ptr = &store[STORE_HOME]; 1749 1746 … … 1758 1755 /* Build the filename */ 1759 1756 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name); 1760 1757 1761 /* File type is "TEXT" */1762 FILE_TYPE(FILE_TYPE_TEXT);1763 1764 1758 /* Check if the file currently exists */ 1765 if ( my_fexists(buf))1759 if (file_exists(buf)) 1766 1760 { 1767 1761 char out_val[160]; 1768 1762
