/* * Hack -- save a screen dump to a file in html format */ static void do_cmd_save_screen_html(int mode) { size_t i; ang_file *fff; char file_name[1024]; char tmp_val[256]; typedef void (*dump_func)(ang_file *); dump_func dump_visuals [] = { dump_monsters, dump_features, dump_objects, dump_flavors, dump_colors }; if (mode == 0) my_strcpy(tmp_val, "dump.html", sizeof(tmp_val)); else my_strcpy(tmp_val, "dump.txt", sizeof(tmp_val)); /* Ask for a file */ if (!get_string("File: ", tmp_val, sizeof(tmp_val))) return; /* Save current preferences */ path_build(file_name, 1024, ANGBAND_DIR_USER, "dump.prf"); fff = file_open(file_name, MODE_WRITE, (mode == 0 ? FTYPE_HTML : FTYPE_TEXT)); /* Check for failure */ if (!fff) { msg("Screen dump failed."); message_flush(); return; } /* Dump all the visuals */ for (i = 0; i < N_ELEMENTS(dump_visuals); i++) dump_visuals[i](fff); file_close(fff); /* Dump the screen with raw character attributes */ reset_visuals(FALSE); do_cmd_redraw(); html_screenshot(tmp_val, mode); /* Recover current graphics settings */ reset_visuals(TRUE); process_pref_file(file_name, TRUE, FALSE); file_delete(file_name); do_cmd_redraw(); msg("HTML screen dump saved."); message_flush(); }
/* * Change the current body the player is using. Return FALSE if the * change was forbidden by hooks, TRUE otherwise. */ bool change_player_body(monster_type* new_body, monster_type* old_body_out) { monster_type* old_body = monster_type_dup(&p_ptr->body_monster); if (process_hooks(HOOK_BODY_CHANGE_PRE, ("(M,M)"), old_body, new_body)) { if (old_body_out != NULL) monster_type_copy(old_body_out, old_body); monster_type_del(old_body); return FALSE; } process_hooks(HOOK_BODY_CHANGE, ("(M,M)"), old_body, new_body); monster_type_copy(&p_ptr->body_monster, new_body); p_ptr->update |= (PU_BODY | PU_BONUS | PU_HP | PU_SANITY | PU_MANA | PU_SPELLS | PU_POWERS); do_cmd_redraw(); process_hooks(HOOK_BODY_CHANGE_POST, ("(M,M)"), old_body, &p_ptr->body_monster); if (old_body_out != NULL) monster_type_copy(old_body_out, old_body); monster_type_del(old_body); return TRUE; }
/* * Change various "permanent" player variables. */ static void do_cmd_wiz_change(void) { /* Interact */ do_cmd_wiz_change_aux(); /* Redraw everything */ do_cmd_redraw(); }
static int _choose_mimic_form(void) { int r_idx = -1; int i; _choice_array_t choices = {{{0}}}; /* List Known Forms */ for (i = 0; i < _MAX_FORMS; i++) { if (_forms[i]) { int j = choices.size++; _choice_t *choice = &choices.choices[j]; choice->r_idx = _forms[i]; choice->slot = i; choice->type = _TYPE_KNOWN; choice->key = I2A(j); } } /* List Visible Forms */ for (i = 1; i < m_max; i++) { monster_type *m_ptr = &m_list[i]; if (!m_ptr->r_idx) continue; if (!m_ptr->ml) continue; if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) continue; if (!r_info[m_ptr->r_idx].body.life) continue; /* Form not implemented yet ... */ _add_visible_form(&choices, m_ptr->r_idx); } /* Assign menu keys at the end due to insertion sort */ for (i = 0; i < choices.size; i++) { _choice_t *choice = &choices.choices[i]; if (choice->type == _TYPE_VISIBLE) choice->key = I2A(i); } if (choices.size) { choices.mode = _CHOOSE_MODE_MIMIC; if (_choose(&choices)) r_idx = choices.choices[choices.current].r_idx; do_cmd_redraw(); } else msg_print("You see nothing to mimic."); return r_idx; }
/** * This function loops through the level and does N iterations of * the stat calling function, assuming clearing style. */ static void clearing_stats(void) { int depth; /* Do many iterations of the game */ for (iter = 0; iter < tries; iter++) { /* Move all artifacts to uncreated */ uncreate_artifacts(); /* Move all uniques to alive */ revive_uniques(); /* Do randart regen */ if ((regen) && (iter<tries)) { /* Get seed */ int seed_randart = randint0(0x10000000); /* regen randarts */ do_randart(seed_randart,TRUE); } /* Do game iterations */ for (depth = 1 ; depth < MAX_LVL; depth++) { /* Debug msg_format("Attempting level %d",depth); */ /* Move player to that depth */ player->depth = depth; /* Get stats */ stats_collect_level(); /* Debug msg_format("Finished level %d,depth"); */ } msg("Iteration %d complete",iter); } /* Print to file */ for (depth = 0 ;depth < MAX_LVL; depth++) print_stats(depth); /* Post processing */ post_process_stats(); /* Display the current level */ do_cmd_redraw(); }
/* * Cure everything instantly */ static void do_cmd_wiz_cure_all(void) { /* Remove curses */ (void)remove_all_curse(); /* Restore stats */ (void)res_stat(A_STR); (void)res_stat(A_INT); (void)res_stat(A_WIS); (void)res_stat(A_CON); (void)res_stat(A_DEX); (void)res_stat(A_CHR); /* Restore the level */ (void)restore_level(); /* Heal the player */ p_ptr->chp = p_ptr->mhp; p_ptr->chp_frac = 0; /* Restore mana */ p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; /* Cure stuff */ (void)player_clear_timed(p_ptr, TMD_BLIND, TRUE); (void)player_clear_timed(p_ptr, TMD_CONFUSED, TRUE); (void)player_clear_timed(p_ptr, TMD_POISONED, TRUE); (void)player_clear_timed(p_ptr, TMD_AFRAID, TRUE); (void)player_clear_timed(p_ptr, TMD_PARALYZED, TRUE); (void)player_clear_timed(p_ptr, TMD_IMAGE, TRUE); (void)player_clear_timed(p_ptr, TMD_STUN, TRUE); (void)player_clear_timed(p_ptr, TMD_CUT, TRUE); (void)player_clear_timed(p_ptr, TMD_SLOW, TRUE); (void)player_clear_timed(p_ptr, TMD_AMNESIA, TRUE); /* No longer hungry */ player_set_food(p_ptr, PY_FOOD_MAX - 1); /* Redraw everything */ do_cmd_redraw(); /* Give the player some feedback */ msg("You feel *much* better!"); }
/** * Parse and execute the current command * Give "Warning" on illegal commands. */ void textui_process_command(void) { int count = 0; bool done = TRUE; ui_event e = textui_get_command(&count); struct cmd_info *cmd = NULL; unsigned char key = '\0'; int mode = OPT(rogue_like_commands) ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG; switch (e.type) { case EVT_RESIZE: do_cmd_redraw(); return; case EVT_MOUSE: textui_process_click(e); return; case EVT_BUTTON: case EVT_KBRD: done = textui_process_key(e.key, &key, count); break; default: ; } /* Null command */ if (!key && done) return; if (key == KC_ENTER) { /* Use command menus */ cmd = textui_action_menu_choose(); } else { /* Command key */ cmd = converted_list[mode][key]; } if (cmd && done) { /* Confirm for worn equipment inscriptions, check command prereqs */ if (!key_confirm_command(key) || (cmd->prereq && !cmd->prereq())) cmd = NULL; /* Split on type of command */ if (cmd && cmd->hook) /* UI command */ cmd->hook(); else if (cmd && cmd->cmd) /* Game command */ cmdq_push_repeat(cmd->cmd, count); } else /* Error */ do_cmd_unknown(); }
/** * Query ncurses for new screen size and try to resize the GCU terms. */ static void do_gcu_resize(void) { int i, rows, cols, y, x; term *old_t = Term; for (i = 0; i < term_count; i++) { /* Activate the current Term */ Term_activate(&data[i].t); /* If we can resize the curses window, then resize the Term */ get_gcu_term_size(i, &rows, &cols, &y, &x); if (wresize(data[i].win, rows, cols) == OK) Term_resize(cols, rows); /* Activate the old term */ Term_activate(old_t); } do_cmd_redraw(); }
/** * Cure everything instantly */ static void do_cmd_wiz_cure_all(void) { /* Restore stats */ (void) res_stat(A_STR); (void) res_stat(A_INT); (void) res_stat(A_WIS); (void) res_stat(A_CON); (void) res_stat(A_DEX); (void) res_stat(A_CHR); /* Restore the level */ (void) restore_level(); /* Update stuff (if needed) */ if (p_ptr->update) update_stuff(p_ptr); /* Heal the player */ p_ptr->chp = p_ptr->mhp; p_ptr->chp_frac = 0; /* Restore mana */ p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; /* Cure stuff */ (void) clear_timed(TMD_BLIND, TRUE); (void) clear_timed(TMD_CONFUSED, TRUE); (void) clear_timed(TMD_POISONED, TRUE); (void) clear_timed(TMD_AFRAID, TRUE); (void) clear_timed(TMD_PARALYZED, TRUE); (void) clear_timed(TMD_IMAGE, TRUE); (void) clear_timed(TMD_STUN, TRUE); (void) clear_timed(TMD_CUT, TRUE); (void) clear_timed(TMD_SLOW, TRUE); p_ptr->black_breath = FALSE; /* No longer hungry */ (void) set_food(PY_FOOD_MAX - 1); /* Redraw everything */ do_cmd_redraw(); }
/** * Parse and execute the current command * Give "Warning" on illegal commands. */ void textui_process_command(bool no_request) { int count = 0; bool done = TRUE; ui_event e; e = textui_get_command(&count); switch (e.type) { case EVT_RESIZE: do_cmd_redraw(); break; case EVT_MOUSE: textui_process_click(e); break; case EVT_BUTTON: case EVT_KBRD: done = textui_process_key(e.key, count); break; default: ; } if (!done) do_cmd_unknown(); }
/** * This function loops through the level and does N iterations of * the stat calling function, assuming diving style. */ static void diving_stats(void) { int depth; /* Iterate through levels */ for (depth = 0; depth < MAX_LVL; depth += 5) { player->depth = depth; if (player->depth == 0) player->depth = 1; /* Do many iterations of each level */ for (iter = 0; iter < tries; iter++) stats_collect_level(); /* Print the output to the file */ print_stats(depth); /* Show the level to check on status */ do_cmd_redraw(); } }
/* * Cure everything instantly */ static void do_cmd_wiz_cure_all(void) { /* Remove curses */ (void)remove_all_curse(); /* Restore stats */ (void)res_stat(A_STR, 200); (void)res_stat(A_INT, 200); (void)res_stat(A_WIS, 200); (void)res_stat(A_CON, 200); (void)res_stat(A_DEX, 200); (void)res_stat(A_CHR, 200); /* Restore the level */ (void)restore_level(); /* Heal the player */ p_ptr->chp = p_ptr->mhp; p_ptr->chp_frac = 0; /* Restore mana */ p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; /* Cure stuff */ (void)set_blind(0); (void)set_confused(0); (void)set_poisoned(0); (void)set_afraid(0); (void)set_paralyzed(0); (void)set_image(0); (void)set_stun(0); (void)set_cut(0); (void)set_slow(0); /* No longer hungry */ (void)set_food(PY_FOOD_MAX - 1); /* Redraw everything */ do_cmd_redraw(); }
static int _choose_new_slot(int new_r_idx) { int slot = -1; int i; _choice_array_t choices = {{{0}}}; /* Display the Newly Learned Form */ assert(new_r_idx); { _choice_t *choice = &choices.choices[choices.size++]; choice->r_idx = new_r_idx; choice->slot = -1; /* paranoia ... it should not be possible to choose this choice! */ choice->type = _TYPE_NEW; } /* List Existing Slots/Known Forms */ for (i = 0; i < _MAX_FORMS; i++) { if (_forms[i]) { int j = choices.size++; _choice_t *choice = &choices.choices[j]; choice->r_idx = _forms[i]; choice->slot = i; choice->type = _TYPE_KNOWN; choice->key = I2A(j-1); } else { /* Simply use the first empty slot */ return i; } } choices.mode = _CHOOSE_MODE_LEARN; if (_choose(&choices)) slot = choices.choices[choices.current].slot; do_cmd_redraw(); return slot; }
/* * Query ncurses for new screen size and try to resize the GCU terms. */ static void do_gcu_resize(void) { int i, rows, cols, y, x; term *old_t = Term; for (i = 0; i < MAX_TERM_DATA; i++) { /* If we're using a big screen, we only care about Term-0 */ if (use_big_screen && i > 0) break; /* Activate the current Term */ Term_activate(&data[i].t); /* If we can resize the curses window, then resize the Term */ get_gcu_term_size(i, &rows, &cols, &y, &x); if (wresize(data[i].win, rows, cols) == OK) Term_resize(cols, rows); /* Activate the old term */ Term_activate(old_t); } do_cmd_redraw(); }
/* * Cure everything instantly */ static void do_cmd_wiz_cure_all(void) { /* Remove curses */ (void)remove_curse(TRUE); /* Restore stats */ (void)res_stat(A_STR, 20); (void)res_stat(A_CON, 20); (void)res_stat(A_DEX, 20); (void)res_stat(A_GRA, 20); /* Heal the player */ p_ptr->chp = p_ptr->mhp; p_ptr->chp_frac = 0; /* Restore mana */ p_ptr->csp = p_ptr->msp; p_ptr->csp_frac = 0; /* Cure stuff */ (void)set_blind(0); (void)set_confused(0); (void)set_poisoned(0); (void)set_afraid(0); (void)set_entranced(0); (void)set_image(0); (void)set_stun(0); (void)set_cut(0); (void)set_slow(0); /* No longer hungry */ (void)set_food(PY_FOOD_FULL - 1); /* Redraw everything */ do_cmd_redraw(); }
void textui_cmd_toggle_ignore(void) { p_ptr->unignoring = !p_ptr->unignoring; p_ptr->notice |= PN_SQUELCH; do_cmd_redraw(); }
/* * This is the entry point for generation statistics. */ static void stats_collect_level(void) { static bool first = TRUE; size_t i, x, y; memset(o_count, 0, sizeof(o_count)); memset(gold_count, 0, sizeof(gold_count)); mon_gold = 0.0; mon_drop = 0.0; results_reset(); result_add("level", format("%d", p_ptr->depth)); for (i = 0; i < TRIES; i++) { generate_cave(); /* Get stats on objects */ for (y = 1; y < DUNGEON_HGT - 1; y++) { for (x = 1; x < DUNGEON_WID - 1; x++) { const object_type *obj = get_first_object(y, x); if (obj) do { if (obj->tval == TV_GOLD) gold_count[i] += obj->pval; else o_count[i]++; } while ((obj = get_next_object(obj))); } } /* Get stats on monsters */ for (y = 1; y < DUNGEON_HGT - 1; y++) { for (x = 1; x < DUNGEON_WID - 1; x++) { if (cave_m_idx[y][x]) stats_monster(&mon_list[cave_m_idx[y][x]]); } } } stats_print_o(); stats_print_m(); if (first) { /* printf("level,mon-drops"); */ results_print_csv_titles(); first = FALSE; } /* results_print_csv_pair("level", "mon-drops"); */ results_print_csv(); do_cmd_redraw(); }
/** * Display the options and redraw afterward. */ void do_cmd_xxx_options(void) { do_cmd_options(); do_cmd_redraw(); }
/** * Gather whether the dungeon has disconnects in it and whether the player * is disconnected from the stairs */ void disconnect_stats(void) { int i, y, x; int **cave_dist; bool has_dsc, has_dsc_from_stairs; static int temp; static char tmp_val[100]; static char prompt[50]; long dsc_area = 0, dsc_from_stairs = 0; /* This is the prompt for no. of tries */ strnfmt(prompt, sizeof(prompt), "Num of simulations: "); /* This is the default value (50) */ strnfmt(tmp_val, sizeof(tmp_val), "%d", tries); /* Ask for the input */ if (!get_string(prompt,tmp_val,7)) return; /* Get the new value */ temp = atoi(tmp_val); /* Try at least once */ if (temp < 1) temp = 1; /* Save */ tries = temp; for (i = 1; i <= tries; i++) { /* Assume no disconnected areas */ has_dsc = FALSE; /* Assume you can't get to stairs */ has_dsc_from_stairs = TRUE; /* Make a new cave */ cave_generate(&cave, player); /* Allocate the distance array */ cave_dist = mem_zalloc(cave->height * sizeof(int*)); for (y = 0; y < cave->height; y++) cave_dist[y] = mem_zalloc(cave->width * sizeof(int)); /* Set all cave spots to inaccessible */ for (y = 0; y < cave->height; y++) for (x = 1; x < cave->width; x++) cave_dist[y][x] = -1; /* Fill the distance array with the correct distances */ calc_cave_distances(cave_dist); /* Cycle through the dungeon */ for (y = 1; y < cave->height - 1; y++) { for (x = 1; x < cave->width - 1; x++) { /* Don't care about walls */ if (square_iswall(cave, y, x)) continue; /* Can we get there? */ if (cave_dist[y][x] >= 0) { /* Is it a down stairs? */ if (square_isdownstairs(cave, y, x)) { has_dsc_from_stairs = FALSE; /* debug msg("dist to stairs: %d",cave_dist[y][x]); */ } continue; } /* Ignore vaults as they are often disconnected */ if (square_isvault(cave, y, x)) continue; /* We have a disconnected area */ has_dsc = TRUE; } } if (has_dsc_from_stairs) dsc_from_stairs++; if (has_dsc) dsc_area++; msg("Iteration: %d",i); /* Free arrays */ for (y = 0; x < cave->height; x++) mem_free(cave_dist[y]); mem_free(cave_dist); } msg("Total levels with disconnected areas: %ld",dsc_area); msg("Total levels isolated from stairs: %ld",dsc_from_stairs); /* Redraw the level */ do_cmd_redraw(); }
/* * Prepare z-term hooks to call send_*_to_chuukei_server()'s */ void prepare_movie_hooks(void) { char buf[1024]; char tmp[80]; if (movie_mode) { movie_mode = 0; #ifdef CHUUKEI if (!chuukei_server) disable_chuukei_server(); #else disable_chuukei_server(); #endif fd_close(movie_fd); #ifdef JP msg_print("録画を終了しました。"); #else msg_print("Stopped recording."); #endif } else { sprintf(tmp, "%s.amv", player_base); #ifdef JP if (get_string("ムービー記録ファイル: ", tmp, 80)) #else if (get_string("Movie file name: ", tmp, 80)) #endif { int fd; path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp); fd = fd_open(buf, O_RDONLY); /* Existing file */ if (fd >= 0) { char out_val[160]; /* Close the file */ (void)fd_close(fd); /* Build query */ #ifdef JP (void)sprintf(out_val, "現存するファイルに上書きしますか? (%s)", buf); #else (void)sprintf(out_val, "Replace existing file %s? ", buf); #endif /* Ask */ if (!get_check(out_val)) return; movie_fd = fd_open(buf, O_WRONLY | O_TRUNC); } else { movie_fd = fd_make(buf, 0644); } if (!movie_fd) { #ifdef JP msg_print("ファイルを開けません!"); #else msg_print("Can not open file."); #endif return; } movie_mode = 1; #ifdef CHUUKEI if (!chuukei_server) prepare_chuukei_hooks(); #else prepare_chuukei_hooks(); #endif do_cmd_redraw(); } } }
void textui_cmd_toggle_ignore(void) { player->unignoring = !player->unignoring; player->upkeep->notice |= PN_IGNORE; do_cmd_redraw(); }