From a01f15e08da3b2e0e326b2a94100e17962136741 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 7 Apr 2012 14:50:36 +0200 Subject: Lua: Refactor all the corruption code into C --- src/files.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index 56e57975..96ee66a9 100644 --- a/src/files.c +++ b/src/files.c @@ -2736,11 +2736,7 @@ errr file_character(cptr name, bool_ full) file_character_print_grid(fff, FALSE, FALSE); /* Dump corruptions */ - if (got_corruptions()) - { - fprintf(fff, "\n Corruption list:\n"); - dump_corruptions(fff, FALSE); - } + dump_corruptions(fff, FALSE, TRUE); /* Dump skills */ dump_skills(fff); -- cgit v1.2.3 From 5ea970c82ba3119ca3a5ee68037aee7cdda6dfa3 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 7 Apr 2012 20:47:47 +0200 Subject: Lua: Moved mimicry to C --- src/files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index 96ee66a9..4e1a1984 100644 --- a/src/files.c +++ b/src/files.c @@ -2644,7 +2644,7 @@ errr file_character(cptr name, bool_ full) if (p_ptr->tim_mimic) { - call_lua("get_mimic_info", "(d,s)", "s", p_ptr->mimic_form, "name", &mimic); + mimic = get_mimic_name(p_ptr->mimic_form); fprintf(fff, "\n You %s disguised as a %s.", (death ? "were" : "are"), mimic); } } -- cgit v1.2.3 From 88a95bb6561ba7474f420fee1c73eeea18dfb1e4 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 9 Apr 2012 11:44:28 +0200 Subject: Lua: Display character bonuses from gods properly --- src/files.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index 4e1a1984..c52beef9 100644 --- a/src/files.c +++ b/src/files.c @@ -1595,6 +1595,48 @@ void player_flags(u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp) if (p_ptr->grace > 10000) (*f1) |= TR1_STR; } + GOD(GOD_AULE) + { + if (p_ptr->grace > 5000) + { + (*f2) |= TR2_RES_FIRE; + } + } + + GOD(GOD_MANDOS) + { + (*f2) |= TR2_RES_NETHER; + + if ((p_ptr->grace > 10000) && + (p_ptr->praying == TRUE)) + { + (*f3) |= TR3_NO_TELE; + } + + if ((p_ptr->grace > 20000) && + (p_ptr->praying == TRUE)) + { + (*f4) |= TR4_IM_NETHER; + } + } + + GOD(GOD_ULMO) + { + (*f5) |= TR5_WATER_BREATH; + + if ((p_ptr->grace > 1000) && + (p_ptr->praying == TRUE)) + { + (*f2) |= TR2_RES_POIS; + } + + if ((p_ptr->grace > 15000) && + (p_ptr->praying == TRUE)) + { + (*f5) |= TR5_MAGIC_BREATH; + } + } + /* Classes */ for (i = 1; i <= p_ptr->lev; i++) { -- cgit v1.2.3 From 93e3dd939f24965125641ca4a08135a6e723c1a3 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 9 Apr 2012 15:41:46 +0200 Subject: Lua: Remove quests.lua and remove unnecessary dynamism for quests --- src/files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index c52beef9..f860e809 100644 --- a/src/files.c +++ b/src/files.c @@ -4329,7 +4329,7 @@ long total_points(void) temp += p_ptr->au / 5; /* Completing quest increase score */ - for (i = 0; i < max_q_idx; i++) + for (i = 0; i < MAX_Q_IDX; i++) { if (quest[i].status >= QUEST_STATUS_COMPLETED) { -- cgit v1.2.3 From fe752bb67a2a43c49c3f1b6d25eb646b1f7d9847 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 11 Jun 2012 20:16:03 +0200 Subject: Lua: Remove dead "patches" code --- src/files.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index f860e809..10617f74 100644 --- a/src/files.c +++ b/src/files.c @@ -2618,7 +2618,6 @@ errr file_character(cptr name, bool_ full) /* List the patches */ hook_file = fff; - exec_lua("patchs_list()"); fprintf(fff, "\n\n [Miscellaneous information]\n"); if (joke_monsters) -- cgit v1.2.3 From 2a2fcac0fdb76ce7481ab4ab17e6f64f3ca7bc1d Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 19 Jun 2012 18:32:22 +0200 Subject: Lua: Eliminate use of exec_lua() in files.c --- src/files.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index 10617f74..ee3bc86c 100644 --- a/src/files.c +++ b/src/files.c @@ -3523,9 +3523,9 @@ bool_ txt_to_html(cptr head, cptr foot, cptr base, cptr ext, bool_ force, bool_ /* Char array type of hyperlink info */ hyperlink_type *h_ptr; - cptr file_ext; - cptr link_prefix; - cptr link_suffix; + cptr file_ext = "html"; + cptr link_prefix = ""; + cptr link_suffix = ""; /* Pointer to general buffer in the above */ char *buf; @@ -3542,14 +3542,6 @@ bool_ txt_to_html(cptr head, cptr foot, cptr base, cptr ext, bool_ force, bool_ h_ptr->link_x[i] = -1; } - /* Parse it(yeah lua is neat :) */ - tome_dofile_anywhere(ANGBAND_DIR_HELP, "def.aux", TRUE); - - /* Ok now get the parameters */ - file_ext = string_exec_lua("return file_ext"); - link_prefix = string_exec_lua("return link_prefix"); - link_suffix = string_exec_lua("return link_suffix"); - sprintf(buf_name, "%s.%s", base, file_ext); if ((!force) && file_exist(buf_name)) return FALSE; -- cgit v1.2.3 From 67485c9c36e244861c6226a3854781d1dd16f3ca Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Jun 2012 17:22:37 +0200 Subject: Remove ANGBAND_DIR_APEX since it's not used any more --- src/files.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index ee3bc86c..01f55d7e 100644 --- a/src/files.c +++ b/src/files.c @@ -5036,7 +5036,7 @@ void display_scores(int from, int to) char buf[1024]; /* Build the filename */ - path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw"); + path_build(buf, 1024, ANGBAND_DIR_USER, "scores.raw"); /* Open the binary high score file, for reading */ highscore_fd = fd_open(buf, O_RDONLY); @@ -5108,7 +5108,7 @@ void show_highclass(int building) } /* Build the filename */ - path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw"); + path_build(buf, 1024, ANGBAND_DIR_USER, "scores.raw"); /* Open file */ highscore_fd = fd_open(buf, O_RDONLY); @@ -5199,7 +5199,7 @@ void race_score(int race_num) prt(tmp_str, 5, 3); /* Build the filename */ - path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw"); + path_build(buf, 1024, ANGBAND_DIR_USER, "scores.raw"); /* Open the highscore file */ highscore_fd = fd_open(buf, O_RDONLY); @@ -5636,7 +5636,7 @@ void close_game(void) /* Build the filename */ - path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw"); + path_build(buf, 1024, ANGBAND_DIR_USER, "scores.raw"); /* Open the high score file, for reading/writing */ highscore_fd = fd_open(buf, O_RDWR); -- cgit v1.2.3 From 758e1f85d64024dce419cfe8a1cd3315b4b58b53 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Jun 2012 19:29:01 +0200 Subject: Remove "highscore_fd" global. --- src/files.c | 219 +++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 142 insertions(+), 77 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index 01f55d7e..ba60ae29 100644 --- a/src/files.c +++ b/src/files.c @@ -4753,7 +4753,7 @@ struct high_score /* * Seek score 'i' in the highscore file */ -static int highscore_seek(int i) +static int highscore_seek(int highscore_fd, int i) { /* Seek for the requested record */ return (fd_seek(highscore_fd, (huge)(i) * sizeof(high_score))); @@ -4763,7 +4763,7 @@ static int highscore_seek(int i) /* * Read one score from the highscore file */ -static errr highscore_read(high_score *score) +static errr highscore_read(int highscore_fd, high_score *score) { /* Read the record, note failure */ return (fd_read(highscore_fd, (char*)(score), sizeof(high_score))); @@ -4773,7 +4773,7 @@ static errr highscore_read(high_score *score) /* * Write one score to the highscore file */ -static int highscore_write(high_score *score) +static int highscore_write(int highscore_fd, high_score *score) { /* Write the record, note failure */ return (fd_write(highscore_fd, (char*)(score), sizeof(high_score))); @@ -4786,7 +4786,7 @@ static int highscore_write(high_score *score) * Just determine where a new score *would* be placed * Return the location (0 is best) or -1 on failure */ -static int highscore_where(high_score *score) +static int highscore_where(int highscore_fd, high_score *score) { int i; @@ -4796,12 +4796,12 @@ static int highscore_where(high_score *score) if (highscore_fd < 0) return ( -1); /* Go to the start of the highscore file */ - if (highscore_seek(0)) return ( -1); + if (highscore_seek(highscore_fd, 0)) return ( -1); /* Read until we get to a higher score */ for (i = 0; i < MAX_HISCORES; i++) { - if (highscore_read(&the_score)) return (i); + if (highscore_read(highscore_fd, &the_score)) return (i); if (strcmp(the_score.pts, score->pts) < 0) return (i); } @@ -4814,7 +4814,7 @@ static int highscore_where(high_score *score) * Actually place an entry into the high score file * Return the location (0 is best) or -1 on "failure" */ -static int highscore_add(high_score *score) +static int highscore_add(int highscore_fd, high_score *score) { int i, slot; bool_ done = FALSE; @@ -4826,7 +4826,7 @@ static int highscore_add(high_score *score) if (highscore_fd < 0) return ( -1); /* Determine where the score should go */ - slot = highscore_where(score); + slot = highscore_where(highscore_fd, score); /* Hack -- Not on the list */ if (slot < 0) return ( -1); @@ -4838,12 +4838,12 @@ static int highscore_add(high_score *score) for (i = slot; !done && (i < MAX_HISCORES); i++) { /* Read the old guy, note errors */ - if (highscore_seek(i)) return ( -1); - if (highscore_read(&tmpscore)) done = TRUE; + if (highscore_seek(highscore_fd, i)) return ( -1); + if (highscore_read(highscore_fd, &tmpscore)) done = TRUE; /* Back up and dump the score we were holding */ - if (highscore_seek(i)) return ( -1); - if (highscore_write(&the_score)) return ( -1); + if (highscore_seek(highscore_fd, i)) return ( -1); + if (highscore_write(highscore_fd, &the_score)) return ( -1); /* Hack -- Save the old score, for the next pass */ the_score = tmpscore; @@ -4862,7 +4862,7 @@ static int highscore_add(high_score *score) * * Mega-Hack -- allow "fake" entry at the given position. */ -static void display_scores_aux(int from, int to, int note, high_score *score) +static void display_scores_aux(int highscore_fd, int from, int to, int note, high_score *score) { int i, j, k, n, place; byte attr; @@ -4882,12 +4882,12 @@ static void display_scores_aux(int from, int to, int note, high_score *score) /* Seek to the beginning */ - if (highscore_seek(0)) return; + if (highscore_seek(highscore_fd, 0)) return; /* Hack -- Count the high scores */ for (i = 0; i < MAX_HISCORES; i++) { - if (highscore_read(&the_score)) break; + if (highscore_read(highscore_fd, &the_score)) break; } /* Hack -- allow "fake" entry to be last */ @@ -4940,8 +4940,8 @@ static void display_scores_aux(int from, int to, int note, high_score *score) else { /* Read the proper record */ - if (highscore_seek(j)) break; - if (highscore_read(&the_score)) break; + if (highscore_seek(highscore_fd, j)) break; + if (highscore_read(highscore_fd, &the_score)) break; } /* Extract the race/class */ @@ -5034,6 +5034,7 @@ static void display_scores_aux(int from, int to, int note, high_score *score) void display_scores(int from, int to) { char buf[1024]; + int highscore_fd; /* Build the filename */ path_build(buf, 1024, ANGBAND_DIR_USER, "scores.raw"); @@ -5048,13 +5049,10 @@ void display_scores(int from, int to) Term_clear(); /* Display the scores */ - display_scores_aux(from, to, -1, NULL); + display_scores_aux(highscore_fd, from, to, -1, NULL); /* Shut the high score file */ - (void)fd_close(highscore_fd); - - /* Forget the high score fd */ - highscore_fd = -1; + fd_close(highscore_fd); /* Quit */ quit(NULL); @@ -5072,6 +5070,7 @@ void show_highclass(int building) int pr, pc, clev, al; high_score the_score; char buf[1024], out_val[256]; + int highscore_fd; switch (building) { @@ -5120,10 +5119,10 @@ void show_highclass(int building) return; } - if (highscore_seek(0)) return; + if (highscore_seek(highscore_fd, 0)) return; for (i = 0; i < MAX_HISCORES; i++) - if (highscore_read(&the_score)) break; + if (highscore_read(highscore_fd, &the_score)) break; m = 0; j = 0; @@ -5131,8 +5130,8 @@ void show_highclass(int building) while ((m < 9) || (j < MAX_HISCORES)) { - if (highscore_seek(j)) break; - if (highscore_read(&the_score)) break; + if (highscore_seek(highscore_fd, j)) break; + if (highscore_read(highscore_fd, &the_score)) break; pr = atoi(the_score.p_r); pc = atoi(the_score.p_c); clev = atoi(the_score.cur_lev); @@ -5172,8 +5171,8 @@ void show_highclass(int building) } } - (void)fd_close(highscore_fd); - highscore_fd = -1; + fd_close(highscore_fd); + msg_print("Hit any key to continue"); msg_print(NULL); for (j = 5; j < 18; j++) @@ -5191,6 +5190,7 @@ void race_score(int race_num) int pr, clev, lastlev; high_score the_score; char buf[1024], out_val[256], tmp_str[80]; + int highscore_fd; lastlev = 0; @@ -5211,11 +5211,11 @@ void race_score(int race_num) return; } - if (highscore_seek(0)) return; + if (highscore_seek(highscore_fd, 0)) return; for (i = 0; i < MAX_HISCORES; i++) { - if (highscore_read(&the_score)) break; + if (highscore_read(highscore_fd, &the_score)) break; } m = 0; @@ -5223,8 +5223,8 @@ void race_score(int race_num) while ((m < 10) && (j < i)) { - if (highscore_seek(j)) break; - if (highscore_read(&the_score)) break; + if (highscore_seek(highscore_fd, j)) break; + if (highscore_read(highscore_fd, &the_score)) break; pr = atoi(the_score.p_r); clev = atoi(the_score.cur_lev); if (pr == race_num) @@ -5247,8 +5247,7 @@ void race_score(int race_num) prt(out_val, (m + 8), 0); } - (void)fd_close(highscore_fd); - highscore_fd = -1; + fd_close(highscore_fd); } @@ -5287,26 +5286,34 @@ static errr top_twenty(void) time_t ct = time((time_t*)0); + char buf[1024]; - /* Clear screen */ - Term_clear(); + int highscore_fd = 0; + + /* Build the filename */ + path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "scores.raw"); + + /* Open the highscore file, for reading/writing */ + highscore_fd = fd_open(buf, O_RDWR); - /* No score file */ if (highscore_fd < 0) { msg_print("Score file unavailable."); msg_print(NULL); - return (0); + goto out; } + /* Clear screen */ + Term_clear(); + #ifndef SCORE_WIZARDS /* Wizard-mode pre-empts scoring */ if (noscore & 0x000F) { msg_print("Score not registered for wizards."); msg_print(NULL); - display_scores_aux(0, 10, -1, NULL); - return (0); + display_scores_aux(highscore_fd, 0, 10, -1, NULL); + goto out; } #endif @@ -5316,8 +5323,8 @@ static errr top_twenty(void) { msg_print("Score not registered for borgs."); msg_print(NULL); - display_scores_aux(0, 10, -1, NULL); - return (0); + display_scores_aux(highscore_fd, 0, 10, -1, NULL); + goto out; } #endif @@ -5327,8 +5334,8 @@ static errr top_twenty(void) { msg_print("Score not registered for cheaters."); msg_print(NULL); - display_scores_aux(0, 10, -1, NULL); - return (0); + display_scores_aux(highscore_fd, 0, 10, -1, NULL); + goto out; } #endif @@ -5337,8 +5344,8 @@ static errr top_twenty(void) { msg_print("Score not registered due to interruption."); msg_print(NULL); - display_scores_aux(0, 10, -1, NULL); - return (0); + display_scores_aux(highscore_fd, 0, 10, -1, NULL); + goto out; } /* Quitter */ @@ -5346,8 +5353,8 @@ static errr top_twenty(void) { msg_print("Score not registered due to quitting."); msg_print(NULL); - display_scores_aux(0, 10, -1, NULL); - return (0); + display_scores_aux(highscore_fd, 0, 10, -1, NULL); + goto out; } @@ -5404,30 +5411,30 @@ static errr top_twenty(void) sprintf(the_score.how, "%-.31s", died_from); - /* Lock (for writing) the highscore file, or fail */ - if (fd_lock(highscore_fd, F_WRLCK)) return (1); - /* Add a new entry to the score list, see where it went */ - j = highscore_add(&the_score); - - /* Unlock the highscore file, or fail */ - if (fd_lock(highscore_fd, F_UNLCK)) return (1); + j = highscore_add(highscore_fd, &the_score); /* Hack -- Display the top fifteen scores */ if (j < 10) { - display_scores_aux(0, 15, j, NULL); + display_scores_aux(highscore_fd, 0, 15, j, NULL); } /* Display the scores surrounding the player */ else { - display_scores_aux(0, 5, j, NULL); - display_scores_aux(j - 2, j + 7, j, NULL); + display_scores_aux(highscore_fd, 0, 5, j, NULL); + display_scores_aux(highscore_fd, j - 2, j + 7, j, NULL); } +out: + if (highscore_fd >= 0) + { + fd_close(highscore_fd); + } + /* Success */ return (0); } @@ -5442,16 +5449,23 @@ errr predict_score(void) high_score the_score; + char buf[1024]; + + int highscore_fd = 0; + + /* Build the filename */ + path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "scores.raw"); + + /* Open the highscore file */ + highscore_fd = fd_open(buf, O_RDONLY); - /* No score file */ if (highscore_fd < 0) { msg_print("Score file unavailable."); msg_print(NULL); - return (0); + goto out; } - /* Save the version */ sprintf(the_score.what, "%ld.%ld.%ld", (long int) VERSION_MAJOR, (long int) VERSION_MINOR, (long int) VERSION_PATCH); @@ -5498,28 +5512,91 @@ errr predict_score(void) /* See where the entry would be placed */ - j = highscore_where(&the_score); + j = highscore_where(highscore_fd, &the_score); /* Hack -- Display the top fifteen scores */ if (j < 10) { - display_scores_aux(0, 15, j, &the_score); + display_scores_aux(highscore_fd, 0, 15, j, &the_score); } /* Display some "useful" scores */ else { - display_scores_aux(0, 5, -1, NULL); - display_scores_aux(j - 2, j + 7, j, &the_score); + display_scores_aux(highscore_fd, 0, 5, -1, NULL); + display_scores_aux(highscore_fd, j - 2, j + 7, j, &the_score); } +out: + if (highscore_fd >= 0) + { + fd_close(highscore_fd); + } /* Success */ return (0); } +void predict_score_gui(bool_ *initialized_p, bool_ *game_in_progress_p) +{ + char buf[1024]; + int highscore_fd; + + /* Paranoia */ + if (!(*initialized_p) || character_icky || + !(*game_in_progress_p) || !character_generated) + { + /* Can't happen but just in case */ + plog("You may not do that right now."); + return; + } + + /* Build the pathname of the score file */ + path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "scores.raw"); + + /* Hack - open the score file for reading */ + highscore_fd = fd_open(buf, O_RDONLY); + + /* Paranoia - No score file */ + if (highscore_fd < 0) + { + msg_print("Score file is not available."); + return; + } + + /* Mega-Hack - prevent various functions XXX XXX XXX */ + *initialized_p = FALSE; + + /* Save screen */ + screen_save(); + + /* Clear screen */ + Term_clear(); + + /* Prepare scores */ + if ((*game_in_progress_p) && character_generated) + { + predict_score(); + } + + /* Close the high score file */ + (void)fd_close(highscore_fd); + + /* Forget the fd */ + highscore_fd = -1; + + /* Restore screen */ + screen_load(); + + /* Hack - Flush it */ + Term_fresh(); + + /* Mega-Hack - We are ready again */ + *initialized_p = TRUE; +} + /* * Change the player into a King! -RAK- @@ -5635,12 +5712,6 @@ void close_game(void) character_icky = TRUE; - /* Build the filename */ - path_build(buf, 1024, ANGBAND_DIR_USER, "scores.raw"); - - /* Open the high score file, for reading/writing */ - highscore_fd = fd_open(buf, O_RDWR); - /* Handle death */ if (death) { @@ -5713,12 +5784,6 @@ void close_game(void) } - /* Shut the high score file */ - (void)fd_close(highscore_fd); - - /* Forget the high score fd */ - highscore_fd = -1; - /* Allow suspending now */ signals_handle_tstp(); } -- cgit v1.2.3 From 06b20f4b9d18f0a8730707d63f9714719157a9a3 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Jun 2012 19:49:18 +0200 Subject: Remove HIGHSCORE_DATE_HACK --- src/files.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index ba60ae29..4e2ff70a 100644 --- a/src/files.c +++ b/src/files.c @@ -5377,13 +5377,8 @@ static errr top_twenty(void) sprintf(the_score.turns, "%9lu", (long)turn - (START_DAY * 10L)); the_score.turns[9] = '\0'; -#ifdef HIGHSCORE_DATE_HACK - /* Save the date in a hacked up form (9 chars) */ - sprintf(the_score.day, "%-.6s %-.2s", ctime(&ct) + 4, ctime(&ct) + 22); -#else /* Save the date in standard form (8 chars) */ strftime(the_score.day, 9, "%m/%d/%y", localtime(&ct)); -#endif /* Save the player name (15 chars) */ sprintf(the_score.who, "%-.15s", player_name); -- cgit v1.2.3 From 2b9664ae8b76dadaace0bd55f6d7b6dbe1367255 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Jun 2012 20:07:56 +0200 Subject: Remove SCORE_{BORGS,WIZARDS,CHEATERS} preprocessor defines --- src/files.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index 4e2ff70a..cd3a5bf4 100644 --- a/src/files.c +++ b/src/files.c @@ -5306,7 +5306,6 @@ static errr top_twenty(void) /* Clear screen */ Term_clear(); -#ifndef SCORE_WIZARDS /* Wizard-mode pre-empts scoring */ if (noscore & 0x000F) { @@ -5315,9 +5314,7 @@ static errr top_twenty(void) display_scores_aux(highscore_fd, 0, 10, -1, NULL); goto out; } -#endif -#ifndef SCORE_BORGS /* Borg-mode pre-empts scoring */ if (noscore & 0x00F0) { @@ -5326,9 +5323,7 @@ static errr top_twenty(void) display_scores_aux(highscore_fd, 0, 10, -1, NULL); goto out; } -#endif -#ifndef SCORE_CHEATERS /* Cheaters are not scored */ if (noscore & 0xFF00) { @@ -5337,7 +5332,6 @@ static errr top_twenty(void) display_scores_aux(highscore_fd, 0, 10, -1, NULL); goto out; } -#endif /* Interupted */ if (!total_winner && streq(died_from, "Interrupting")) -- cgit v1.2.3 From 9f4251ec8809d716eeb7930928517b9e2bcdea86 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Jun 2012 21:00:55 +0200 Subject: Remove "player_uid" global --- src/files.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index cd3a5bf4..c1ff6d36 100644 --- a/src/files.c +++ b/src/files.c @@ -4727,7 +4727,7 @@ struct high_score char who[16]; /* Player Name (string) */ - char uid[8]; /* Player UID (number) */ + char unused_1[8]; /* Kept for compatibility only */ char sex[2]; /* Player Sex (string) */ char p_r[3]; /* Player Race (number) */ @@ -4918,7 +4918,7 @@ static void display_scores_aux(int highscore_fd, int from, int to, int note, hig { int pcs, pr, ps, pc, clev, mlev, cdun, mdun; - cptr user, gold, when, aged; + cptr gold, when, aged; int in_arena, in_quest; @@ -4960,7 +4960,6 @@ static void display_scores_aux(int highscore_fd, int from, int to, int note, hig in_quest = atoi(the_score.inside_quest); /* Hack -- extract the gold and such */ - for (user = the_score.uid; isspace(*user); user++) /* loop */; for (when = the_score.day; isspace(*when); when++) /* loop */; for (gold = the_score.gold; isspace(*gold); gold++) /* loop */; for (aged = the_score.turns; isspace(*aged); aged++) /* loop */; @@ -5008,8 +5007,8 @@ static void display_scores_aux(int highscore_fd, int from, int to, int note, hig /* And still another line of info */ sprintf(out_val, - " (User %s, Date %s, Gold %s, Turn %s).", - user, when, gold, aged); + " (Date %s, Gold %s, Turn %s).", + when, gold, aged); c_put_str(attr, out_val, n*4 + 4, 0); } @@ -5378,7 +5377,6 @@ static errr top_twenty(void) sprintf(the_score.who, "%-.15s", player_name); /* Save the player info XXX XXX XXX */ - sprintf(the_score.uid, "%7u", player_uid); sprintf(the_score.sex, "%c", (p_ptr->psex ? 'm' : 'f')); sprintf(the_score.p_r, "%2d", p_ptr->prace); sprintf(the_score.p_s, "%2d", p_ptr->pracem); @@ -5455,6 +5453,9 @@ errr predict_score(void) goto out; } + /* Clear the record */ + WIPE(&the_score, high_score); + /* Save the version */ sprintf(the_score.what, "%ld.%ld.%ld", (long int) VERSION_MAJOR, (long int) VERSION_MINOR, (long int) VERSION_PATCH); @@ -5478,7 +5479,6 @@ errr predict_score(void) sprintf(the_score.who, "%-.15s", player_name); /* Save the player info XXX XXX XXX */ - sprintf(the_score.uid, "%7u", player_uid); sprintf(the_score.sex, "%c", (p_ptr->psex ? 'm' : 'f')); sprintf(the_score.p_r, "%2d", p_ptr->prace); sprintf(the_score.p_s, "%2d", p_ptr->pracem); -- cgit v1.2.3 From a76f713c5a5e164a1c78af296fc4b9afa74fb22b Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Wed, 27 Jun 2012 21:54:38 +0200 Subject: Remove SAVEFILE_MUTABLE preprocessor define --- src/files.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index c1ff6d36..ea1922a5 100644 --- a/src/files.c +++ b/src/files.c @@ -4066,13 +4066,6 @@ void process_player_name(bool_ sf) if (!player_base[0]) strcpy(player_base, "PLAYER"); -#ifdef SAVEFILE_MUTABLE - - /* Accept */ - sf = TRUE; - -#endif - /* Change the savefile name */ if (sf) { -- cgit v1.2.3 From f7e87bc98111f97ca489e1f13999058a7df8171e Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Fri, 29 Jun 2012 20:49:49 +0200 Subject: Split high score reading/writing into separate compilation unit --- src/files.c | 157 +----------------------------------------------------------- 1 file changed, 2 insertions(+), 155 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index ea1922a5..f8125148 100644 --- a/src/files.c +++ b/src/files.c @@ -12,6 +12,8 @@ #include "angband.h" +#include "hiscore.h" + /* * Extract the first few "tokens" from a buffer @@ -4693,161 +4695,6 @@ static void show_info(void) -/* - * Semi-Portable High Score List Entry (128 bytes) -- BEN - * - * All fields listed below are null terminated ascii strings. - * - * In addition, the "number" fields are right justified, and - * space padded, to the full available length (minus the "null"). - * - * Note that "string comparisons" are thus valid on "pts". - */ - -typedef struct high_score high_score; - -struct high_score -{ - char what[8]; /* Version info (string) */ - - char pts[10]; /* Total Score (number) */ - - char gold[10]; /* Total Gold (number) */ - - char turns[10]; /* Turns Taken (number) */ - - char day[10]; /* Time stamp (string) */ - - char who[16]; /* Player Name (string) */ - - char unused_1[8]; /* Kept for compatibility only */ - - char sex[2]; /* Player Sex (string) */ - char p_r[3]; /* Player Race (number) */ - char p_s[3]; /* Player Subrace (number) */ - char p_c[3]; /* Player Class (number) */ - char p_cs[3]; /* Player Class spec (number) */ - - char cur_lev[4]; /* Current Player Level (number) */ - char cur_dun[4]; /* Current Dungeon Level (number) */ - char max_lev[4]; /* Max Player Level (number) */ - char max_dun[4]; /* Max Dungeon Level (number) */ - - char arena_number[4]; /* Arena level attained -KMW- */ - char inside_arena[4]; /* Did the player die in the arena? */ - char inside_quest[4]; /* Did the player die in a quest? */ - char exit_bldg[4]; /* Can the player exit arena? Goal obtained? -KMW- */ - - char how[32]; /* Method of death (string) */ -}; - - - -/* - * Seek score 'i' in the highscore file - */ -static int highscore_seek(int highscore_fd, int i) -{ - /* Seek for the requested record */ - return (fd_seek(highscore_fd, (huge)(i) * sizeof(high_score))); -} - - -/* - * Read one score from the highscore file - */ -static errr highscore_read(int highscore_fd, high_score *score) -{ - /* Read the record, note failure */ - return (fd_read(highscore_fd, (char*)(score), sizeof(high_score))); -} - - -/* - * Write one score to the highscore file - */ -static int highscore_write(int highscore_fd, high_score *score) -{ - /* Write the record, note failure */ - return (fd_write(highscore_fd, (char*)(score), sizeof(high_score))); -} - - - - -/* - * Just determine where a new score *would* be placed - * Return the location (0 is best) or -1 on failure - */ -static int highscore_where(int highscore_fd, high_score *score) -{ - int i; - - high_score the_score; - - /* Paranoia -- it may not have opened */ - if (highscore_fd < 0) return ( -1); - - /* Go to the start of the highscore file */ - if (highscore_seek(highscore_fd, 0)) return ( -1); - - /* Read until we get to a higher score */ - for (i = 0; i < MAX_HISCORES; i++) - { - if (highscore_read(highscore_fd, &the_score)) return (i); - if (strcmp(the_score.pts, score->pts) < 0) return (i); - } - - /* The "last" entry is always usable */ - return (MAX_HISCORES - 1); -} - - -/* - * Actually place an entry into the high score file - * Return the location (0 is best) or -1 on "failure" - */ -static int highscore_add(int highscore_fd, high_score *score) -{ - int i, slot; - bool_ done = FALSE; - - high_score the_score, tmpscore; - - - /* Paranoia -- it may not have opened */ - if (highscore_fd < 0) return ( -1); - - /* Determine where the score should go */ - slot = highscore_where(highscore_fd, score); - - /* Hack -- Not on the list */ - if (slot < 0) return ( -1); - - /* Hack -- prepare to dump the new score */ - the_score = (*score); - - /* Slide all the scores down one */ - for (i = slot; !done && (i < MAX_HISCORES); i++) - { - /* Read the old guy, note errors */ - if (highscore_seek(highscore_fd, i)) return ( -1); - if (highscore_read(highscore_fd, &tmpscore)) done = TRUE; - - /* Back up and dump the score we were holding */ - if (highscore_seek(highscore_fd, i)) return ( -1); - if (highscore_write(highscore_fd, &the_score)) return ( -1); - - /* Hack -- Save the old score, for the next pass */ - the_score = tmpscore; - } - - /* Return location used */ - return (slot); -} - - - /* * Display the scores in a given range. * Assumes the high score list is already open. -- cgit v1.2.3 From 2653d949a0008b44d4a41fb52d516a7766f55928 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 30 Jun 2012 20:20:58 +0200 Subject: Remove unused variables --- src/files.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index f8125148..8e19922f 100644 --- a/src/files.c +++ b/src/files.c @@ -5521,9 +5521,6 @@ void wipe_saved() */ void close_game(void) { - char buf[1024]; - - /* Handle stuff */ handle_stuff(); -- cgit v1.2.3 From 45c2cb4e51f3683cf527598bff0554e0b1723402 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 24 Jun 2013 07:41:12 +0200 Subject: Remove HANDLE_SIGNALS and SPECIAL_BSD --- src/files.c | 126 ------------------------------------------------------------ 1 file changed, 126 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index 8e19922f..7b1d10ce 100644 --- a/src/files.c +++ b/src/files.c @@ -4236,9 +4236,6 @@ void do_cmd_save_game(void) /* The player is not dead */ (void)strcpy(died_from, "(saved)"); - /* Forbid suspend */ - signals_ignore_tstp(); - /* Save the player */ if (save_player()) { @@ -4253,9 +4250,6 @@ void do_cmd_save_game(void) remove_cave_view(FALSE); - /* Allow suspend again */ - signals_handle_tstp(); - /* Refresh */ Term_fresh(); @@ -5114,8 +5108,6 @@ void race_legends(void) /* * Enters a players name on a hi-score table, if "legal", and in any * case, displays some relevant portion of the high score list. - * - * Assumes "signals_ignore_tstp()" has been called. */ static errr top_twenty(void) { @@ -5531,9 +5523,6 @@ void close_game(void) flush(); - /* No suspending now */ - signals_ignore_tstp(); - /* Hack -- Character is now "icky" */ character_icky = TRUE; @@ -5608,10 +5597,6 @@ void close_game(void) /* Predict score (or ESCAPE) */ if (inkey() != ESCAPE) predict_score(); } - - - /* Allow suspending now */ - signals_handle_tstp(); } @@ -5865,114 +5850,3 @@ errr get_xtra_line(char *file_name, monster_type *m_ptr, char *output) /* Success */ return (0); } - - -#ifdef HANDLE_SIGNALS - - -#include - - -/* - * Handle signals -- suspend - * - * Actually suspend the game, and then resume cleanly - */ -static void handle_signal_suspend(int sig) -{ - /* Disable handler */ - (void)signal(sig, SIG_IGN); - -#ifdef SIGSTOP - - /* Flush output */ - Term_fresh(); - - /* Suspend the "Term" */ - Term_xtra(TERM_XTRA_ALIVE, 0); - - /* Suspend ourself */ - (void)kill(0, SIGSTOP); - - /* Resume the "Term" */ - Term_xtra(TERM_XTRA_ALIVE, 1); - - /* Redraw the term */ - Term_redraw(); - - /* Flush the term */ - Term_fresh(); - -#endif - - /* Restore handler */ - (void)signal(sig, handle_signal_suspend); -} - - -/* - * Ignore SIGTSTP signals (keyboard suspend) - */ -void signals_ignore_tstp(void) -{ - -#ifdef SIGTSTP - (void)signal(SIGTSTP, SIG_IGN); -#endif - -} - -/* - * Handle SIGTSTP signals (keyboard suspend) - */ -void signals_handle_tstp(void) -{ - -#ifdef SIGTSTP - (void)signal(SIGTSTP, handle_signal_suspend); -#endif - -} - - -/* - * Prepare to handle the relevant signals - */ -void signals_init(void) -{ - -#ifdef SIGHUP - (void)signal(SIGHUP, SIG_IGN); -#endif - - -#ifdef SIGTSTP - (void)signal(SIGTSTP, handle_signal_suspend); -#endif - -} - - -#else /* HANDLE_SIGNALS */ - - -/* -* Do nothing -*/ -void signals_ignore_tstp(void) -{} - -/* -* Do nothing -*/ -void signals_handle_tstp(void) -{} - -/* -* Do nothing -*/ -void signals_init(void) -{} - - -#endif /* HANDLE_SIGNALS */ -- cgit v1.2.3 From f0fd8edb1fc36fd3dbe3b7df61da91b3daf9d4c6 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 16 Jul 2013 01:06:55 +0200 Subject: Remove auto_notes and take_notes options We always set them to TRUE now. --- src/files.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index 7b1d10ce..cc209524 100644 --- a/src/files.c +++ b/src/files.c @@ -5533,11 +5533,8 @@ void close_game(void) /* Handle retirement */ if (total_winner) { - /* Write a note, if that option is on */ - if (take_notes) - { - add_note_type(NOTE_WINNER); - } + /* Make a note */ + add_note_type(NOTE_WINNER); kingly(); } @@ -5554,8 +5551,7 @@ void close_game(void) /* Show more info */ show_info(); - /* Write a note */ - if (take_notes) + /* Make a note */ { char long_day[30]; char buf[80]; @@ -5585,11 +5581,8 @@ void close_game(void) /* Save the game */ do_cmd_save_game(); - /* If note-taking enabled, write session end to notes file */ - if (take_notes) - { - add_note_type(NOTE_SAVE_GAME); - } + /* Make a note pf session end */ + add_note_type(NOTE_SAVE_GAME); /* Prompt for scores XXX XXX XXX */ prt("Press Return (or Escape).", 0, 40); -- cgit v1.2.3 From a8a33056a073cb3f4213a1e845fe036dd3d53e0b Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 15 Jul 2013 23:00:30 +0200 Subject: Remove the stupid_monsters option It's always considered FALSE from now on. --- src/files.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index cc209524..664c96d7 100644 --- a/src/files.c +++ b/src/files.c @@ -2675,9 +2675,6 @@ errr file_character(cptr name, bool_ full) if (PRACE_FLAGS(PR1_EXPERIMENTAL)) fprintf(fff, "\n You have done something experimental."); - if (stupid_monsters) - fprintf(fff, "\n Your opponents are behaving stupidly."); - { char desc[80]; cptr mimic; @@ -4286,7 +4283,6 @@ long total_points(void) if (p_ptr->preserve) mult -= 1; /* Penalize preserve, maximize modes */ if (p_ptr->maximize) mult -= 1; if (auto_scum) mult -= 4; - if (stupid_monsters) mult -= 10; if (small_levels) mult += ((always_small_level) ? 4 : 10); if (empty_levels) mult += 2; if (smart_learn) mult += 4; -- cgit v1.2.3 From eb657ada4c1ec432fc0e3aec0b9f4d796efed428 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 25 Mar 2013 13:10:24 +0100 Subject: Split hooks into separate header --- src/files.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index 664c96d7..c97315fc 100644 --- a/src/files.c +++ b/src/files.c @@ -13,6 +13,7 @@ #include "angband.h" #include "hiscore.h" +#include "hooks.h" /* -- cgit v1.2.3 From de312e85022558780a3357a655b9742793b6484f Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 25 Mar 2013 16:43:50 +0100 Subject: Remove unused second parameter for disturb() --- src/files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index c97315fc..d056c125 100644 --- a/src/files.c +++ b/src/files.c @@ -4216,7 +4216,7 @@ void do_cmd_save_game(void) if (!is_autosave) { /* Disturb the player */ - disturb(1, 0); + disturb(1); } /* Clear messages */ -- cgit v1.2.3 From 9eb646ef8c1f2824a113a111516d1c73d798746c Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Mar 2013 17:11:00 +0100 Subject: Constness fixes --- src/files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index d056c125..ad8322cf 100644 --- a/src/files.c +++ b/src/files.c @@ -5593,7 +5593,7 @@ void close_game(void) /* * Grab a randomly selected line in lib/file/file_name */ -errr get_rnd_line(char *file_name, char *output) +errr get_rnd_line(const char *file_name, char *output) { FILE *fp; -- cgit v1.2.3 From acca45d6a22406a74d5dc56e00ff0c6ad8e478b8 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Mar 2013 23:00:48 +0100 Subject: Constness fixes --- src/files.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c index ad8322cf..a599af23 100644 --- a/src/files.c +++ b/src/files.c @@ -1030,7 +1030,7 @@ static void prt_lnum(cptr header, s32b num, int row, int col, byte color) * Print number with header at given row, column */ static void prt_num(cptr header, int num, int row, int col, byte color, - char *space) + cptr space) { int len = strlen(header); char out_val[32]; @@ -5670,7 +5670,7 @@ errr get_rnd_line(const char *file_name, char *output) * * Caution: 'linbuf' should be at least 80 byte long. */ -char *get_line(char* fname, cptr fdir, char *linbuf, int line) +char *get_line(const char* fname, cptr fdir, char *linbuf, int line) { FILE* fp; int i; @@ -5718,7 +5718,7 @@ char *get_line(char* fname, cptr fdir, char *linbuf, int line) * understand such complexities -- and added extra error checkings * and made sure fd is always closed -- pelpel */ -errr get_xtra_line(char *file_name, monster_type *m_ptr, char *output) +errr get_xtra_line(const char *file_name, monster_type *m_ptr, char *output) { FILE *fp; char buf[1024]; -- cgit v1.2.3 From cbef37bd5bfb938a2303ee3887520c08be85d8e8 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Mar 2013 17:10:10 +0100 Subject: Switch almost everything over to C++ --- src/files.c | 5842 ----------------------------------------------------------- 1 file changed, 5842 deletions(-) delete mode 100644 src/files.c (limited to 'src/files.c') diff --git a/src/files.c b/src/files.c deleted file mode 100644 index a599af23..00000000 --- a/src/files.c +++ /dev/null @@ -1,5842 +0,0 @@ -/* File: files.c */ - -/* Purpose: code dealing with files (and death) */ - -/* - * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke - * - * This software may be copied and distributed for educational, research, and - * not for profit purposes provided that this copyright and statement are - * included in all such copies. - */ - -#include "angband.h" - -#include "hiscore.h" -#include "hooks.h" - - -/* - * Extract the first few "tokens" from a buffer - * - * This function uses "colon" and "slash" and delim arg as the delimeter characters. - * - * We never extract more than "num" tokens. The "last" token may include - * "delimeter" characters, allowing the buffer to include a "string" token. - * - * We save pointers to the tokens in "tokens", and return the number found. - * - * Hack -- Attempt to handle the 'c' character formalism - * - * Hack -- An empty buffer, or a final delimeter, yields an "empty" token. - * - * Hack -- We will always extract at least one token - */ -s16b tokenize(char *buf, s16b num, char **tokens, char delim1, char delim2) -{ - int i = 0; - - char *s = buf; - - - /* Process */ - while (i < num - 1) - { - char *t; - - /* Scan the string */ - for (t = s; *t; t++) - { - /* Found a delimiter */ - if ((*t == delim1) || (*t == delim2)) break; - - /* Handle single quotes */ - if (*t == '\'') - { - /* Advance */ - t++; - - /* Handle backslash */ - if (*t == '\\') t++; - - /* Require a character */ - if (!*t) break; - - /* Advance */ - t++; - - /* Hack -- Require a close quote */ - if (*t != '\'') *t = '\''; - } - - /* Handle back-slash */ - if (*t == '\\') t++; - } - - /* Nothing left */ - if (!*t) break; - - /* Nuke and advance */ - *t++ = '\0'; - - /* Save the token */ - tokens[i++] = s; - - /* Advance */ - s = t; - } - - /* Save the token */ - tokens[i++] = s; - - /* Number found */ - return (i); -} - - - -/* - * Parse a sub-file of the "extra info" (format shown below) - * - * Each "action" line has an "action symbol" in the first column, - * followed by a colon, followed by some command specific info, - * usually in the form of "tokens" separated by colons or slashes. - * - * Blank lines, lines starting with white space, and lines starting - * with pound signs ("#") are ignored (as comments). - * - * Note the use of "tokenize()" to allow the use of both colons and - * slashes as delimeters, while still allowing final tokens which - * may contain any characters including "delimiters". - * - * Note the use of "strtol()" to allow all "integers" to be encoded - * in decimal, hexidecimal, or octal form. - * - * Note that "monster zero" is used for the "player" attr/char, "object - * zero" will be used for the "stack" attr/char, and "feature zero" is - * used for the "nothing" attr/char. - * - * Parse another file recursively, see below for details - * %: - * - * Specify the attr/char values for "monsters" by race index - * R::: - * - * Specify the attr/char values for "objects" by kind index - * K::: - * - * Specify the attr/char values for "features" by feature index - * F::: - * - * Specify the attr/char values for "stores" by store index - * B::: - * - * Specify the attr/char values for unaware "objects" by kind tval - * U::: - * - * Specify the attr/char values for inventory "objects" by kind tval - * E::: - * - * Define a macro action, given an encoded macro action - * A: - * - * Create a normal macro, given an encoded macro trigger - * P: - * - * Create a command macro, given an encoded macro trigger - * C: - * - * Create a keyset mapping - * S::: - * - * Turn an option off, given its name - * X: - * - * Turn an option on, given its name - * Y: - * - * Specify visual information, given an index, and some data - * V::::: - * - * Specify squelch settings - * Q:: - */ -errr process_pref_file_aux(char *buf) -{ - int i, j, n1, n2; - - char *zz[16]; - - - /* Skip "empty" lines */ - if (!buf[0]) return (0); - - /* Skip "blank" lines */ - if (isspace(buf[0])) return (0); - - /* Skip comments */ - if (buf[0] == '#') return (0); - - /* Require "?:*" format */ - if (buf[1] != ':') return (1); - - - /* Process "%:" */ - if (buf[0] == '%') - { - /* Attempt to Process the given file */ - return (process_pref_file(buf + 2)); - } - - - /* Process "R::/" -- attr/char for monster races */ - if (buf[0] == 'R') - { - if (tokenize(buf + 2, 3, zz, ':', '/') == 3) - { - monster_race *r_ptr; - i = (huge)strtol(zz[0], NULL, 0); - n1 = strtol(zz[1], NULL, 0); - n2 = strtol(zz[2], NULL, 0); - if (i >= max_r_idx) return (1); - r_ptr = &r_info[i]; - if (n1) r_ptr->x_attr = n1; - if (n2) - { - r_ptr->x_char = n2; - } - return (0); - } - } - - - /* Process "G:::/" -- attr/char for overlay graphics */ - if (buf[0] == 'G') - { - /* Process "G:M::/" -- attr/char for ego monsters */ - if (buf[2] == 'M') - { - if (tokenize(buf + 4, 3, zz, ':', '/') == 3) - { - monster_ego *re_ptr; - i = (huge)strtol(zz[0], NULL, 0); - n1 = strtol(zz[1], NULL, 0); - n2 = strtol(zz[2], NULL, 0); - if (i >= max_re_idx) return (1); - re_ptr = &re_info[i]; - if (n1) re_ptr->g_attr = n1; - if (n2) - { - re_ptr->g_char = n2; - } - return (0); - } - } - - /* Process "G:P::/" -- attr/char for race modifiers */ - if (buf[2] == 'P') - { - if (tokenize(buf + 4, 3, zz, ':', '/') == 3) - { - player_race_mod *rmp_ptr; - i = (huge)strtol(zz[0], NULL, 0); - n1 = strtol(zz[1], NULL, 0); - n2 = strtol(zz[2], NULL, 0); - if (i >= max_rmp_idx) return (1); - rmp_ptr = &race_mod_info[i]; - if (n1) rmp_ptr->g_attr = n1; - if (n2) - { - rmp_ptr->g_char = n2; - } - return (0); - } - } - - /* Process "G:T::/" -- attr/char for traps */ - if (buf[2] == 'T') - { - if (tokenize(buf + 4, 3, zz, ':', '/') == 3) - { - trap_type *t_ptr; - i = (huge)strtol(zz[0], NULL, 0); - n1 = strtol(zz[1], NULL, 0); - n2 = strtol(zz[2], NULL, 0); - if (i >= max_t_idx) return (1); - t_ptr = &t_info[i]; - if (n1) t_ptr->g_attr = n1; - if (n2) - { - t_ptr->g_char = n2; - } - return (0); - } - } - } - - - /* Process "K::/" -- attr/char for object kinds */ - else if (buf[0] == 'K') - { - if (tokenize(buf + 2, 3, zz, ':', '/') == 3) - { - object_kind *k_ptr; - i = (huge)strtol(zz[0], NULL, 0); - n1 = strtol(zz[1], NULL, 0); - n2 = strtol(zz[2], NULL, 0); - if (i >= max_k_idx) return (1); - k_ptr = &k_info[i]; - if (n1) k_ptr->x_attr = n1; - if (n2) - { - k_ptr->x_char = n2; - } - return (0); - } - } - - - /* Process "F::/" -- attr/char for terrain features */ - else if (buf[0] == 'F') - { - if (tokenize(buf + 2, 3, zz, ':', '/') == 3) - { - feature_type *f_ptr; - i = (huge)strtol(zz[0], NULL, 0); - n1 = strtol(zz[1], NULL, 0); - n2 = strtol(zz[2], NULL, 0); - if (i >= max_f_idx) return (1); - f_ptr = &f_info[i]; - if (n1) f_ptr->x_attr = n1; - if (n2) - { - f_ptr->x_char = n2; - } - return (0); - } - } - - /* Process "B::/" -- attr/char for stores */ - else if (buf[0] == 'B') - { - if (tokenize(buf + 2, 3, zz, ':', '/') == 3) - { - store_info_type *st_ptr; - i = (huge)strtol(zz[0], NULL, 0); - n1 = strtol(zz[1], NULL, 0); - n2 = strtol(zz[2], NULL, 0); - if (i >= max_st_idx) return (1); - st_ptr = &st_info[i]; - if (n1) st_ptr->x_attr = n1; - if (n2) st_ptr->x_char = n2; - return (0); - } - } - - /* Process "S::/" -- attr/char for special things */ - else if (buf[0] == 'S') - { - if (tokenize(buf + 2, 3, zz, ':', '/') == 3) - { - j = (byte)strtol(zz[0], NULL, 0); - n1 = strtol(zz[1], NULL, 0); - n2 = strtol(zz[2], NULL, 0); - misc_to_attr[j] = n1; - misc_to_char[j] = n2; - return (0); - } - } - - /* Process "U::/" -- attr/char for unaware items */ - else if (buf[0] == 'U') - { - if (tokenize(buf + 2, 3, zz, ':', '/') == 3) - { - j = (huge)strtol(zz[0], NULL, 0); - n1 = strtol(zz[1], NULL, 0); - n2 = strtol(zz[2], NULL, 0); - for (i = 1; i < max_k_idx; i++) - { - object_kind *k_ptr = &k_info[i]; - if (k_ptr->tval == j) - { - if (n1) k_ptr->d_attr = n1; - if (n2) k_ptr->d_char = n2; - } - } - return (0); - } - } - - - /* Process "E::" -- attribute for inventory objects */ - else if (buf[0] == 'E') - { - if (tokenize(buf + 2, 2, zz, ':', '/') == 2) - { - j = (byte)strtol(zz[0], NULL, 0) % 128; - n1 = strtol(zz[1], NULL, 0); - if (n1) tval_to_attr[j] = n1; - return (0); - } - } - - - /* Process "A:" -- save an "action" for later */ - else if (buf[0] == 'A') - { - text_to_ascii(macro__buf, buf + 2); - return (0); - } - - /* Process "P:" -- normal macro */ - else if (buf[0] == 'P') - { - char tmp[1024]; - text_to_ascii(tmp, buf + 2); - macro_add(tmp, macro__buf); - return (0); - } - - /* Process "L::: -- extended command macro */ - else if (buf[0] == 'L') - { - switch (tokenize(buf + 2, 3, zz, ':', 0)) - { - case 3: - cli_add(zz[0], zz[1], zz[2]); - return 0; - case 2: - cli_add(zz[0], zz[1], 0); - return 0; - default: - return 1; - } - } - - /* Process "C:" -- create keymap */ - else if (buf[0] == 'C') - { - int mode; - - char tmp[1024]; - - if (tokenize(buf + 2, 2, zz, ':', '/') != 2) return (1); - - mode = strtol(zz[0], NULL, 0); - if ((mode < 0) || (mode >= KEYMAP_MODES)) return (1); - - text_to_ascii(tmp, zz[1]); - if (!tmp[0] || tmp[1]) return (1); - i = (byte)(tmp[0]); - - string_free(keymap_act[mode][i]); - - keymap_act[mode][i] = string_make(macro__buf); - - return (0); - } - - - /* Process "V:::::" -- visual info */ - else if (buf[0] == 'V') - { - if (tokenize(buf + 2, 5, zz, ':', '/') == 5) - { - i = (byte)strtol(zz[0], NULL, 0); - angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0); - angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0); - angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0); - angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0); - return (0); - } - } - /* set macro trigger names and a template */ - /* Process "T:::" */ - /* Process "T: