| 2643 | | #if 0 |
|---|
| 2644 | | |
|---|
| 2645 | | /* |
|---|
| 2646 | | * Save a "bones" file for a dead character |
|---|
| 2647 | | * |
|---|
| 2648 | | * Note that we will not use these files until a later version, and |
|---|
| 2649 | | * then we will only use the name and level on which death occured. |
|---|
| 2650 | | * |
|---|
| 2651 | | * Should probably attempt some form of locking... |
|---|
| 2652 | | */ |
|---|
| 2653 | | static void make_bones(void) |
|---|
| 2654 | | { |
|---|
| 2655 | | ang_file *fp; |
|---|
| 2656 | | char str[1024]; |
|---|
| 2657 | | char tmp[128]; |
|---|
| 2658 | | |
|---|
| 2659 | | /* Ignore wizards and borgs */ |
|---|
| 2660 | | if (p_ptr->noscore & (NOSCORE_WIZARD | NOSCORE_BORG)) |
|---|
| 2661 | | return; |
|---|
| 2662 | | |
|---|
| 2663 | | /* Ignore people who die in town */ |
|---|
| 2664 | | if (!p_ptr->depth) return; |
|---|
| 2665 | | |
|---|
| 2666 | | |
|---|
| 2667 | | /* XXX XXX XXX "Bones" name */ |
|---|
| 2668 | | strnfmt(tmp, sizeof(tmp), "bone.%03d", p_ptr->depth); |
|---|
| 2669 | | |
|---|
| 2670 | | /* Build the filename */ |
|---|
| 2671 | | path_build(str, sizeof(str), ANGBAND_DIR_BONE, tmp); |
|---|
| 2672 | | |
|---|
| 2673 | | /* Do not over-write a previous ghost */ |
|---|
| 2674 | | if (file_exists(str)) return; |
|---|
| 2675 | | |
|---|
| 2676 | | /* Try to write a new "Bones File" */ |
|---|
| 2677 | | safe_setuid_grab(); |
|---|
| 2678 | | fp = file_open(str, MODE_WRITE, FTYPE_TEXT); |
|---|
| 2679 | | safe_setuid_drop(); |
|---|
| 2680 | | |
|---|
| 2681 | | /* Not allowed to write it? Weird. */ |
|---|
| 2682 | | if (!fp) return; |
|---|
| 2683 | | |
|---|
| 2684 | | /* Save the info */ |
|---|
| 2685 | | file_putf(fp, "%s\n", op_ptr->full_name); |
|---|
| 2686 | | file_putf(fp, "%d\n", p_ptr->mhp); |
|---|
| 2687 | | file_putf(fp, "%d\n", p_ptr->prace); |
|---|
| 2688 | | file_putf(fp, "%d\n", p_ptr->pclass); |
|---|
| 2689 | | |
|---|
| 2690 | | /* Close and save the Bones file */ |
|---|
| 2691 | | file_close(fp); |
|---|
| 2692 | | } |
|---|
| 2693 | | |
|---|
| 2694 | | #endif /* 0 */ |
|---|
| 2839 | | |
|---|
| 2840 | | |
|---|
| 2841 | | /* |
|---|
| 2842 | | * Display some character info |
|---|
| 2843 | | */ |
|---|
| 2844 | | static void show_info(void) |
|---|
| 2845 | | { |
|---|
| 2846 | | int i, j, k; |
|---|
| 2847 | | |
|---|
| 2848 | | object_type *o_ptr; |
|---|
| 2849 | | |
|---|
| 2850 | | store_type *st_ptr = &store[STORE_HOME]; |
|---|
| 2851 | | |
|---|
| 2852 | | |
|---|
| 2853 | | /* Display player */ |
|---|
| 2854 | | display_player(0); |
|---|
| 2855 | | |
|---|
| 2856 | | /* Prompt for inventory */ |
|---|
| 2857 | | prt("Hit any key to see more information (ESC to abort): ", 23, 0); |
|---|
| 2858 | | |
|---|
| 2859 | | /* Allow abort at this point */ |
|---|
| 2860 | | if (inkey() == ESCAPE) return; |
|---|
| 2861 | | |
|---|
| 2862 | | |
|---|
| 2863 | | /* Show equipment and inventory */ |
|---|
| 2864 | | |
|---|
| 2865 | | /* Equipment -- if any */ |
|---|
| 2866 | | if (p_ptr->equip_cnt) |
|---|
| 2867 | | { |
|---|
| 2868 | | Term_clear(); |
|---|
| 2869 | | item_tester_full = TRUE; |
|---|
| 2870 | | show_equip(); |
|---|
| 2871 | | prt("You are using: -more-", 0, 0); |
|---|
| 2872 | | if (inkey() == ESCAPE) return; |
|---|
| 2873 | | } |
|---|
| 2874 | | |
|---|
| 2875 | | /* Inventory -- if any */ |
|---|
| 2876 | | if (p_ptr->inven_cnt) |
|---|
| 2877 | | { |
|---|
| 2878 | | Term_clear(); |
|---|
| 2879 | | item_tester_full = TRUE; |
|---|
| 2880 | | show_inven(); |
|---|
| 2881 | | prt("You are carrying: -more-", 0, 0); |
|---|
| 2882 | | if (inkey() == ESCAPE) return; |
|---|
| 2883 | | } |
|---|
| 2884 | | |
|---|
| 2885 | | |
|---|
| 2886 | | |
|---|
| 2887 | | /* Home -- if anything there */ |
|---|
| 2888 | | if (st_ptr->stock_num) |
|---|
| 2889 | | { |
|---|
| 2890 | | /* Display contents of the home */ |
|---|
| 2891 | | for (k = 0, i = 0; i < st_ptr->stock_num; k++) |
|---|
| 2892 | | { |
|---|
| 2893 | | /* Clear screen */ |
|---|
| 2894 | | Term_clear(); |
|---|
| 2895 | | |
|---|
| 2896 | | /* Show 12 items */ |
|---|
| 2897 | | for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++) |
|---|
| 2898 | | { |
|---|
| 2899 | | byte attr; |
|---|
| 2900 | | |
|---|
| 2901 | | char o_name[80]; |
|---|
| 2902 | | char tmp_val[80]; |
|---|
| 2903 | | |
|---|
| 2904 | | /* Get the object */ |
|---|
| 2905 | | o_ptr = &st_ptr->stock[i]; |
|---|
| 2906 | | |
|---|
| 2907 | | /* Print header, clear line */ |
|---|
| 2908 | | strnfmt(tmp_val, sizeof(tmp_val), "%c) ", I2A(j)); |
|---|
| 2909 | | prt(tmp_val, j+2, 4); |
|---|
| 2910 | | |
|---|
| 2911 | | /* Get the object description */ |
|---|
| 2912 | | object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); |
|---|
| 2913 | | |
|---|
| 2914 | | /* Get the inventory color */ |
|---|
| 2915 | | attr = tval_to_attr[o_ptr->tval % N_ELEMENTS(tval_to_attr)]; |
|---|
| 2916 | | |
|---|
| 2917 | | /* Display the object */ |
|---|
| 2918 | | c_put_str(attr, o_name, j+2, 7); |
|---|
| 2919 | | } |
|---|
| 2920 | | |
|---|
| 2921 | | /* Caption */ |
|---|
| 2922 | | prt(format("Your home contains (page %d): -more-", k+1), 0, 0); |
|---|
| 2923 | | |
|---|
| 2924 | | /* Wait for it */ |
|---|
| 2925 | | if (inkey() == ESCAPE) return; |
|---|
| 2926 | | } |
|---|
| 2927 | | } |
|---|
| 2928 | | } |
|---|
| 2929 | | |
|---|
| 2930 | | |
|---|
| 2931 | | /* |
|---|
| 2932 | | * Special version of 'do_cmd_examine' |
|---|
| 2933 | | */ |
|---|
| 2934 | | static void death_examine(void) |
|---|
| 2935 | | { |
|---|
| 2936 | | int item; |
|---|
| 2937 | | cptr q, s; |
|---|
| 2938 | | |
|---|
| 2939 | | |
|---|
| 2940 | | /* Start out in "display" mode */ |
|---|
| 2941 | | p_ptr->command_see = TRUE; |
|---|
| 2942 | | |
|---|
| 2943 | | /* Get an item */ |
|---|
| 2944 | | q = "Examine which item? "; |
|---|
| 2945 | | s = "You have nothing to examine."; |
|---|
| 2946 | | |
|---|
| 2947 | | while (get_item(&item, q, s, (USE_INVEN | USE_EQUIP))) |
|---|
| 2948 | | { |
|---|
| 2949 | | object_type *o_ptr = &inventory[item]; |
|---|
| 2950 | | |
|---|
| 2951 | | /* "Know" */ |
|---|
| 2952 | | o_ptr->ident |= IDENT_KNOWN; |
|---|
| 2953 | | |
|---|
| 2954 | | /* Describe */ |
|---|
| 2955 | | text_out_hook = text_out_to_screen; |
|---|
| 2956 | | screen_save(); |
|---|
| 2957 | | Term_gotoxy(0, 0); |
|---|
| 2958 | | |
|---|
| 2959 | | object_info_header(o_ptr); |
|---|
| 2960 | | if (!object_info_known(o_ptr)) |
|---|
| 2961 | | text_out("This item does not possess any special abilities."); |
|---|
| 2962 | | |
|---|
| 2963 | | text_out_c(TERM_L_BLUE, "\n\n[Press any key to continue]\n"); |
|---|
| 2964 | | (void)anykey(); |
|---|
| 2965 | | |
|---|
| 2966 | | screen_load(); |
|---|
| 2967 | | } |
|---|
| 2968 | | } |
|---|
| 2969 | | |
|---|
| 2970 | | |
|---|
| 2971 | | |
|---|
| 2972 | | |
|---|
| | 2838 | |
|---|
| | 2839 | |
|---|
| | 2840 | |
|---|
| | 2841 | |
|---|
| | 2842 | |
|---|
| | 2843 | static void death_file(void *unused, const char *title) |
|---|
| | 2844 | { |
|---|
| | 2845 | char ftmp[80]; |
|---|
| | 2846 | strnfmt(ftmp, sizeof(ftmp), "%s.txt", op_ptr->base_name); |
|---|
| | 2847 | |
|---|
| | 2848 | if (!get_string("File name: ", ftmp, sizeof(ftmp))) |
|---|
| | 2849 | return; |
|---|
| | 2850 | |
|---|
| | 2851 | if (ftmp[0] && (ftmp[0] != ' ')) |
|---|
| | 2852 | { |
|---|
| | 2853 | errr err; |
|---|
| | 2854 | |
|---|
| | 2855 | /* Dump a character file */ |
|---|
| | 2856 | screen_save(); |
|---|
| | 2857 | err = file_character(ftmp, FALSE); |
|---|
| | 2858 | screen_load(); |
|---|
| | 2859 | |
|---|
| | 2860 | /* Check result */ |
|---|
| | 2861 | if (err) |
|---|
| | 2862 | msg_print("Character dump failed!"); |
|---|
| | 2863 | else |
|---|
| | 2864 | msg_print("Character dump successful."); |
|---|
| | 2865 | |
|---|
| | 2866 | /* Flush messages */ |
|---|
| | 2867 | message_flush(); |
|---|
| | 2868 | } |
|---|
| | 2869 | } |
|---|
| | 2870 | |
|---|
| | 2871 | static void death_info(void *unused, const char *title) |
|---|
| | 2872 | { |
|---|
| | 2873 | int i, j, k; |
|---|
| | 2874 | object_type *o_ptr; |
|---|
| | 2875 | store_type *st_ptr = &store[STORE_HOME]; |
|---|
| | 2876 | |
|---|
| | 2877 | |
|---|
| | 2878 | screen_save(); |
|---|
| | 2879 | |
|---|
| | 2880 | /* Display player */ |
|---|
| | 2881 | display_player(0); |
|---|
| | 2882 | |
|---|
| | 2883 | /* Prompt for inventory */ |
|---|
| | 2884 | prt("Hit any key to see more information (ESC to abort): ", 23, 0); |
|---|
| | 2885 | |
|---|
| | 2886 | /* Allow abort at this point */ |
|---|
| | 2887 | if (inkey() == ESCAPE) return; |
|---|
| | 2888 | |
|---|
| | 2889 | |
|---|
| | 2890 | /* Show equipment and inventory */ |
|---|
| | 2891 | |
|---|
| | 2892 | /* Equipment -- if any */ |
|---|
| | 2893 | if (p_ptr->equip_cnt) |
|---|
| | 2894 | { |
|---|
| | 2895 | Term_clear(); |
|---|
| | 2896 | item_tester_full = TRUE; |
|---|
| | 2897 | show_equip(); |
|---|
| | 2898 | prt("You are using: -more-", 0, 0); |
|---|
| | 2899 | if (inkey() == ESCAPE) return; |
|---|
| | 2900 | } |
|---|
| | 2901 | |
|---|
| | 2902 | /* Inventory -- if any */ |
|---|
| | 2903 | if (p_ptr->inven_cnt) |
|---|
| | 2904 | { |
|---|
| | 2905 | Term_clear(); |
|---|
| | 2906 | item_tester_full = TRUE; |
|---|
| | 2907 | show_inven(); |
|---|
| | 2908 | prt("You are carrying: -more-", 0, 0); |
|---|
| | 2909 | if (inkey() == ESCAPE) return; |
|---|
| | 2910 | } |
|---|
| | 2911 | |
|---|
| | 2912 | |
|---|
| | 2913 | |
|---|
| | 2914 | /* Home -- if anything there */ |
|---|
| | 2915 | if (st_ptr->stock_num) |
|---|
| | 2916 | { |
|---|
| | 2917 | /* Display contents of the home */ |
|---|
| | 2918 | for (k = 0, i = 0; i < st_ptr->stock_num; k++) |
|---|
| | 2919 | { |
|---|
| | 2920 | /* Clear screen */ |
|---|
| | 2921 | Term_clear(); |
|---|
| | 2922 | |
|---|
| | 2923 | /* Show 12 items */ |
|---|
| | 2924 | for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++) |
|---|
| | 2925 | { |
|---|
| | 2926 | byte attr; |
|---|
| | 2927 | |
|---|
| | 2928 | char o_name[80]; |
|---|
| | 2929 | char tmp_val[80]; |
|---|
| | 2930 | |
|---|
| | 2931 | /* Get the object */ |
|---|
| | 2932 | o_ptr = &st_ptr->stock[i]; |
|---|
| | 2933 | |
|---|
| | 2934 | /* Print header, clear line */ |
|---|
| | 2935 | strnfmt(tmp_val, sizeof(tmp_val), "%c) ", I2A(j)); |
|---|
| | 2936 | prt(tmp_val, j+2, 4); |
|---|
| | 2937 | |
|---|
| | 2938 | /* Get the object description */ |
|---|
| | 2939 | object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); |
|---|
| | 2940 | |
|---|
| | 2941 | /* Get the inventory color */ |
|---|
| | 2942 | attr = tval_to_attr[o_ptr->tval % N_ELEMENTS(tval_to_attr)]; |
|---|
| | 2943 | |
|---|
| | 2944 | /* Display the object */ |
|---|
| | 2945 | c_put_str(attr, o_name, j+2, 7); |
|---|
| | 2946 | } |
|---|
| | 2947 | |
|---|
| | 2948 | /* Caption */ |
|---|
| | 2949 | prt(format("Your home contains (page %d): -more-", k+1), 0, 0); |
|---|
| | 2950 | |
|---|
| | 2951 | /* Wait for it */ |
|---|
| | 2952 | if (inkey() == ESCAPE) return; |
|---|
| | 2953 | } |
|---|
| | 2954 | } |
|---|
| | 2955 | |
|---|
| | 2956 | screen_load(); |
|---|
| | 2957 | } |
|---|
| | 2958 | |
|---|
| | 2959 | static void death_messages(void *unused, const char *title) |
|---|
| | 2960 | { |
|---|
| | 2961 | screen_save(); |
|---|
| | 2962 | do_cmd_messages(); |
|---|
| | 2963 | screen_load(); |
|---|
| | 2964 | } |
|---|
| | 2965 | |
|---|
| | 2966 | static void death_scores(void *unused, const char *title) |
|---|
| | 2967 | { |
|---|
| | 2968 | screen_save(); |
|---|
| | 2969 | top_twenty(); |
|---|
| | 2970 | screen_load(); |
|---|
| | 2971 | } |
|---|
| | 2972 | |
|---|
| | 2973 | static void death_examine(void *unused, const char *title) |
|---|
| | 2974 | { |
|---|
| | 2975 | int item; |
|---|
| | 2976 | cptr q, s; |
|---|
| | 2977 | |
|---|
| | 2978 | |
|---|
| | 2979 | screen_save(); |
|---|
| | 2980 | Term_clear(); |
|---|
| | 2981 | |
|---|
| | 2982 | /* Start out in "display" mode */ |
|---|
| | 2983 | p_ptr->command_see = TRUE; |
|---|
| | 2984 | |
|---|
| | 2985 | /* Get an item */ |
|---|
| | 2986 | q = "Examine which item? "; |
|---|
| | 2987 | s = "You have nothing to examine."; |
|---|
| | 2988 | |
|---|
| | 2989 | while (get_item(&item, q, s, (USE_INVEN | USE_EQUIP))) |
|---|
| | 2990 | { |
|---|
| | 2991 | object_type *o_ptr = &inventory[item]; |
|---|
| | 2992 | |
|---|
| | 2993 | /* "Know" */ |
|---|
| | 2994 | o_ptr->ident |= IDENT_KNOWN; |
|---|
| | 2995 | |
|---|
| | 2996 | /* Describe */ |
|---|
| | 2997 | text_out_hook = text_out_to_screen; |
|---|
| | 2998 | screen_save(); |
|---|
| | 2999 | Term_gotoxy(0, 0); |
|---|
| | 3000 | |
|---|
| | 3001 | object_info_header(o_ptr); |
|---|
| | 3002 | if (!object_info_known(o_ptr)) |
|---|
| | 3003 | text_out("This item does not possess any special abilities."); |
|---|
| | 3004 | |
|---|
| | 3005 | text_out_c(TERM_L_BLUE, "\n\n[Press any key to continue]\n"); |
|---|
| | 3006 | (void)anykey(); |
|---|
| | 3007 | |
|---|
| | 3008 | screen_load(); |
|---|
| | 3009 | } |
|---|
| | 3010 | |
|---|
| | 3011 | screen_load(); |
|---|
| | 3012 | } |
|---|
| | 3013 | |
|---|
| | 3014 | menu_type death_menu; |
|---|
| | 3015 | |
|---|
| | 3016 | static const menu_action death_actions[] = |
|---|
| | 3017 | { |
|---|
| | 3018 | { 'i', "Information", death_info, NULL }, |
|---|
| | 3019 | { 'm', "Messages", death_messages, NULL }, |
|---|
| | 3020 | { 'f', "File dump", death_file, NULL }, |
|---|
| | 3021 | { 'v', "View scores", death_scores, NULL }, |
|---|
| | 3022 | { 'x', "Examine items", death_examine, NULL }, |
|---|
| | 3023 | { 'q', "Quit", death_examine, NULL }, |
|---|
| | 3024 | }; |
|---|
| | 3025 | |
|---|
| | 3026 | |
|---|
| | 3027 | |
|---|
| | 3028 | |
|---|
| | 3029 | static char tag_death_main(menu_type *menu, int oid) |
|---|
| | 3030 | { |
|---|
| | 3031 | if (death_actions[oid].id) |
|---|
| | 3032 | return death_actions[oid].id; |
|---|
| | 3033 | |
|---|
| | 3034 | return 0; |
|---|
| | 3035 | } |
|---|
| | 3036 | |
|---|
| | 3037 | static int valid_death_main(menu_type *menu, int oid) |
|---|
| | 3038 | { |
|---|
| | 3039 | if (death_actions[oid].name) |
|---|
| | 3040 | return 1; |
|---|
| | 3041 | |
|---|
| | 3042 | return 0; |
|---|
| | 3043 | } |
|---|
| | 3044 | |
|---|
| | 3045 | static void display_death_main(menu_type *menu, int oid, bool cursor, int row, int col, int width) |
|---|
| | 3046 | { |
|---|
| | 3047 | byte attr = curs_attrs[CURS_KNOWN][(int)cursor]; |
|---|
| | 3048 | |
|---|
| | 3049 | if (death_actions[oid].name) |
|---|
| | 3050 | c_prt(attr, death_actions[oid].name, row, col); |
|---|
| | 3051 | } |
|---|
| | 3052 | |
|---|
| | 3053 | |
|---|
| | 3054 | static const menu_iter death_iter = |
|---|
| | 3055 | { |
|---|
| | 3056 | 0, |
|---|
| | 3057 | tag_death_main, |
|---|
| | 3058 | valid_death_main, |
|---|
| | 3059 | display_death_main, |
|---|
| | 3060 | NULL |
|---|
| | 3061 | }; |
|---|
| | 3062 | |
|---|
| | 3063 | |
|---|
| | 3064 | |
|---|
| | 3065 | |
|---|
| 3064 | | /* Loop */ |
|---|
| 3065 | | while (!wants_to_quit) |
|---|
| 3066 | | { |
|---|
| 3067 | | /* Describe options */ |
|---|
| 3068 | | Term_putstr(1, 23, -1, TERM_WHITE, p); |
|---|
| 3069 | | |
|---|
| 3070 | | /* Query */ |
|---|
| 3071 | | ch = inkey(); |
|---|
| 3072 | | |
|---|
| 3073 | | switch (ch) |
|---|
| 3074 | | { |
|---|
| 3075 | | /* Exit */ |
|---|
| 3076 | | case ESCAPE: |
|---|
| 3077 | | { |
|---|
| 3078 | | if (get_check("Do you want to quit? ")) |
|---|
| 3079 | | wants_to_quit = TRUE; |
|---|
| 3080 | | |
|---|
| | 3102 | |
|---|
| | 3103 | /* Initialize the menus */ |
|---|
| | 3104 | menu_type *menu; |
|---|
| | 3105 | const char cmd_keys[] = { ARROW_LEFT, ARROW_RIGHT, '\0' }; |
|---|
| | 3106 | const region area = { 51, 2, 0, 6 }; |
|---|
| | 3107 | |
|---|
| | 3108 | int cursor = 0; |
|---|
| | 3109 | ui_event_data c = EVENT_EMPTY; |
|---|
| | 3110 | |
|---|
| | 3111 | |
|---|
| | 3112 | /* options screen selection menu */ |
|---|
| | 3113 | menu = &death_menu; |
|---|
| | 3114 | WIPE(menu, menu_type); |
|---|
| | 3115 | menu_set_id(menu, 1); |
|---|
| | 3116 | menu->menu_data = death_actions; |
|---|
| | 3117 | menu->flags = MN_CASELESS_TAGS; |
|---|
| | 3118 | menu->cmd_keys = cmd_keys; |
|---|
| | 3119 | menu->count = N_ELEMENTS(death_actions); |
|---|
| | 3120 | |
|---|
| | 3121 | menu_init2(menu, find_menu_skin(MN_SCROLL), &death_iter, &area); |
|---|
| | 3122 | |
|---|
| | 3123 | while (TRUE) |
|---|
| | 3124 | { |
|---|
| | 3125 | c = menu_select(&death_menu, &cursor, 0); |
|---|
| | 3126 | |
|---|
| | 3127 | if (c.key == ESCAPE || cursor == 5) |
|---|
| | 3128 | { |
|---|
| | 3129 | if (get_check("Do you want to quit? ")) |
|---|