summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-02-23 09:12:00 +0100
committerBardur Arantsson <bardur@scientician.net>2015-02-23 09:12:00 +0100
commit91964ee9dd97c6c41a3551aba5af6fae67989e4f (patch)
tree172bf3be7fbe25042c8664bc210c1b03b6cc37eb
parentb94e14c35d91ec5c99a208e9ddf84f81f9b84013 (diff)
Move cmd7.cc function declarations to separate header file
Make a few of the functions static while we're at it.
-rw-r--r--src/cmd6.cc1
-rw-r--r--src/cmd7.cc470
-rw-r--r--src/cmd7.hpp25
-rw-r--r--src/externs.h36
-rw-r--r--src/lua_bind.cc1
-rw-r--r--src/powers.cc1
-rw-r--r--src/skills.cc1
-rw-r--r--src/spells2.cc1
-rw-r--r--src/wizard1.cc1
-rw-r--r--src/xtra1.cc1
10 files changed, 263 insertions, 275 deletions
diff --git a/src/cmd6.cc b/src/cmd6.cc
index 0cd052e2..349b9598 100644
--- a/src/cmd6.cc
+++ b/src/cmd6.cc
@@ -11,6 +11,7 @@
#include "angband.h"
#include "cave.hpp"
#include "cmd1.hpp"
+#include "cmd7.hpp"
#include "corrupt.hpp"
#include "hooks.h"
#include "lua_bind.hpp"
diff --git a/src/cmd7.cc b/src/cmd7.cc
index 3b26c83c..71f77028 100644
--- a/src/cmd7.cc
+++ b/src/cmd7.cc
@@ -2335,7 +2335,7 @@ void do_cmd_create_artifact(object_type *q_ptr)
* recipes as a createable item. Used to determine if we
* should extract from it.
*/
-bool_ alchemist_exists(int tval, int sval, int ego, int artifact)
+static bool_ alchemist_exists(int tval, int sval, int ego, int artifact)
{
int al_idx;
@@ -2522,7 +2522,7 @@ bool_ item_tester_hook_empower(object_type *o_ptr)
}
/* Extract a rod tip from a rod */
-void rod_tip_extract(object_type *o_ptr)
+static void rod_tip_extract(object_type *o_ptr)
{
object_type *q_ptr;
object_type forge;
@@ -2552,7 +2552,7 @@ void rod_tip_extract(object_type *o_ptr)
/* Begin & finish an art */
-void do_cmd_toggle_artifact(object_type *o_ptr)
+static void do_cmd_toggle_artifact(object_type *o_ptr)
{
char o_name[80];
@@ -2627,7 +2627,7 @@ void do_cmd_toggle_artifact(object_type *o_ptr)
* if tocreate=0, will return true if the player has enough
* in their p_ptr->inventory to empower that item.
*/
-bool_ alchemist_items_check(int tval, int sval, int ego, int tocreate, bool_ message)
+static bool_ alchemist_items_check(int tval, int sval, int ego, int tocreate, bool_ message)
{
int al_idx, j;
bool_ exists = FALSE;
@@ -2722,7 +2722,7 @@ bool_ alchemist_items_check(int tval, int sval, int ego, int tocreate, bool_ mes
/* This function lists all the ingredients
* needed to create something.
*/
-void alchemist_display_recipe(int tval, int sval, int ego)
+static void alchemist_display_recipe(int tval, int sval, int ego)
{
int al_idx;
int row = 1, col = 15;
@@ -2772,14 +2772,6 @@ void alchemist_display_recipe(int tval, int sval, int ego)
}
/*
- *
- * The alchemist_recipe_select was copied from
- * wiz_create_itemtype
- * and then changed quite a bit.
- *
- */
-
-/*
The select array is a simple array of 'use this char to select item x'
It has 88 items (three columns of 20 each)
selectitem is initilized with the reverse mappings:
@@ -2835,11 +2827,235 @@ void strip_and_print(const char *str, int color, int num)
c_prt(color, format("[%c] %s", ch, string), row, col);
}
+/* Display a list of known recipies that can be made with
+ * materials on hand (including the passed tval). Also
+ * calls the recipe_display function, if requested by the
+ * player or there aren't enough essences to make the
+ * requested object.
+ *
+ * Note: sval is ignored if !ego, tval is the only determinant
+ * of what recipies are available otherwise.
+ *
+ * This function needs to be able to scroll a list, because
+ * there are SO MANY potions. :)
+ */
+static int alchemist_recipe_select(int *tval, int sval, int ego, bool_ recipe)
+{
+ int i, mod40 = 0, num, max_num = 0;
+
+ cptr tval_desc2 = "";
+ char ch;
+ bool_ done = FALSE;
+
+ int choice[60];
+ int validc[60];
+
+ const char *string;
+
+
+ /* Save and clear the screen */
+ character_icky = TRUE;
+ Term_save();
+ Term_clear();
+
+ /* Base object type chosen, fill in tval */
+ for ( num = 0 ; num < 40 ; num ++)
+ if (tvals[num].tval == *tval)
+ {
+ tval_desc2 = tvals[num].desc;
+ }
+
+ while (!done)
+ {
+ Term_clear();
+ if (ego)
+ {
+ /* Find matching ego items */
+ for (num = 0, i = 1; (num < 40) && (i < max_e_idx) ; i++)
+ {
+ int j;
+ ego_item_type *e_ptr = &e_info[i];
+
+ /* Skip if unknown ego type */
+ if ( !(alchemist_known_egos[i / 32] & (1 << (i % 32))))
+ continue;
+
+ /* search in permitted tvals/svals for allowed egos */
+ for ( j = 0 ; j < 6 ; j ++ )
+ if ( e_ptr->tval[j] == *tval
+ && sval >= e_ptr->min_sval[j]
+ && sval <= e_ptr->max_sval[j])
+ {
+ int color = TERM_GREEN;
+
+ /*Reject if not opposite end of name
+ prefixes only on postfix egos,
+ postfixes only on prefix egos.
+ */
+ if (ego != -1 && e_ptr->before == e_info[ego].before)
+ continue;
+
+ /*Color it red of the alchemist doesn't have the essences to create it*/
+ if (!alchemist_items_check(*tval, 0, i, 0, TRUE))
+ color = TERM_RED;
+
+ /* add this ego to the list*/
+ strip_and_print(e_info[i].name, color, num);
+ validc[num] = color;
+ choice[num++] = i;
+ break;
+ }
+ }
+ }
+ else
+ {
+ char skipped = 0;
+ num = 0;
+ if (mod40 != 0)
+ {
+ strip_and_print("--MORE--", TERM_WHITE, num);
+ validc[num] = TERM_WHITE;
+ choice[num++] = -1;
+ }
+
+ for (i = 1; (num < 39) && (i < max_k_idx); i++)
+ {
+ object_kind *k_ptr = &k_info[i];
+
+ /* Analyze matching items */
+ if (k_ptr->tval == *tval || (k_ptr->tval == TV_POTION2 && *tval == TV_POTION))
+ {
+ char color = TERM_GREEN;
+ /* Hack -- Skip instant artifacts */
+ if (k_ptr->flags3 & (TR3_INSTA_ART)) continue;
+
+ /*Don't display recipes that the alchemist doesn't know about*/
+ if (!k_ptr->know && !wizard) continue;
+
+ /*Skip recipes that are somehow known, but don't exist*/
+ if (!alchemist_exists(k_ptr->tval, k_ptr->sval, 0, 0))
+ continue;
+
+ /* Skip the first 39 if they hit 'more' */
+ if (skipped++ < mod40*39)
+ continue;
+
+ /* Color 'unable to create' items different */
+ if (!alchemist_items_check(k_ptr->tval, k_ptr->sval, 0, 0, TRUE))
+ color = TERM_RED;
+
+ /* Acquire the "name" of object "i" */
+ /* and print it in it's place */
+ strip_and_print(k_ptr->name, color, num);
+
+ /* Remember the object index */
+ validc[num] = color;
+ choice[num++] = i;
+ }
+ }
+ if (num == 39)
+ {
+ strip_and_print("--MORE--", TERM_WHITE, num);
+ validc[num] = TERM_WHITE;
+ choice[num++] = -1;
+ }
+ }
+
+ /* We need to know the maximal possible remembered object_index */
+ max_num = num;
+ string = "What Kind of %s? (* to see recipe) [%c-%c,*]";
+ num = 0xff;
+
+ /* Pretend they're all undoable if we where called to display recipes */
+ if (recipe)
+ {
+ for ( num = 0 ; num < max_num ; num++)
+ if (validc[num] != TERM_WHITE) validc[num] = TERM_RED;
+ string = "show which %s recipe? [%c-%c]";
+ }
+
+ while (num == 0xff || num >= max_num)
+ {
+ ch = selectchar[max_num - 1];
+ /* Choose! */
+ if ( max_num == 0 || !get_com(format(string, tval_desc2, selectchar[0], ch), &ch))
+ {
+ break;
+ }
+
+ /* Extra breaks for recipe */
+ if (recipe && (ch == '\r' || ch == ' ' || ch == ESCAPE ))
+ break;
+
+ /* Analyze choice */
+ num = selectitem[(byte)ch];
+
+ /* Pretend that we don't have enough essences for anything */
+ if (ch == '*' )
+ {
+ for ( num = 0 ; num < max_num ; num++)
+ if (validc[num] != TERM_WHITE) validc[num] = TERM_RED;
+ string = "Show which %s recipe? [%c-%c]";
+ }
+ }
+ if ( num == 0xff || max_num == 0 || num >= max_num)
+ break;
+
+ if ( validc[num] == TERM_WHITE )
+ {
+ if (num == 0)
+ mod40--;
+ else
+ mod40++;
+ if ( mod40 < 0)
+ mod40 = 0;
+ continue;
+ }
+
+ /* If we don't have enough essences, or user asked for recipes */
+ if ( validc[num] != TERM_GREEN )
+ {
+ /* Display the recipe */
+ if (ego)
+ alchemist_display_recipe(*tval, sval, choice[num]);
+ else
+ alchemist_display_recipe(k_info[choice[num]].tval, k_info[choice[num]].sval, 0);
+ }
+ else
+ done = TRUE;
+
+ }/*while(!done)*/
+
+ /* Restore screen contents */
+ Term_load();
+ character_icky = FALSE;
+
+ /* User abort, or no choices */
+ if (max_num == 0 || num == 0xff || num >= max_num)
+ {
+ if (max_num == 0)
+ msg_print("You don't know of anything you can make using that.");
+ return ( -1);
+ }
+ if ( validc[num] != TERM_GREEN )
+ return ( -1);
+
+ /* And return successful */
+ if ( ego )
+ return choice[num];
+
+ /* Set the tval, should be the same unless they selected a potion2 */
+ if (*tval != k_info[choice[num]].tval && *tval != TV_POTION)
+ msg_print("Coding error: tval != TV_POTION");
+ *tval = k_info[choice[num]].tval;
+ return ( k_info[choice[num]].sval );
+}
+
/* Display a list of recipes that need a particular essence.
* Note that we display a list of essences first,
* so in effect, this is the alchemist's recipe book.
*/
-void alchemist_recipe_book(void)
+static void alchemist_recipe_book(void)
{
int num, max_num, i, al_idx, bat, kidx;
int choice[61], choice2[61];
@@ -3115,230 +3331,6 @@ void alchemist_recipe_book(void)
character_icky = FALSE;
}
-/* Display a list of known recipies that can be made with
- * materials on hand (including the passed tval). Also
- * calls the recipe_display function, if requested by the
- * player or there aren't enough essences to make the
- * requested object.
- *
- * Note: sval is ignored if !ego, tval is the only determinant
- * of what recipies are available otherwise.
- *
- * This function needs to be able to scroll a list, because
- * there are SO MANY potions. :)
- */
-int alchemist_recipe_select(int *tval, int sval, int ego, bool_ recipe)
-{
- int i, mod40 = 0, num, max_num = 0;
-
- cptr tval_desc2 = "";
- char ch;
- bool_ done = FALSE;
-
- int choice[60];
- int validc[60];
-
- const char *string;
-
-
- /* Save and clear the screen */
- character_icky = TRUE;
- Term_save();
- Term_clear();
-
- /* Base object type chosen, fill in tval */
- for ( num = 0 ; num < 40 ; num ++)
- if (tvals[num].tval == *tval)
- {
- tval_desc2 = tvals[num].desc;
- }
-
- while (!done)
- {
- Term_clear();
- if (ego)
- {
- /* Find matching ego items */
- for (num = 0, i = 1; (num < 40) && (i < max_e_idx) ; i++)
- {
- int j;
- ego_item_type *e_ptr = &e_info[i];
-
- /* Skip if unknown ego type */
- if ( !(alchemist_known_egos[i / 32] & (1 << (i % 32))))
- continue;
-
- /* search in permitted tvals/svals for allowed egos */
- for ( j = 0 ; j < 6 ; j ++ )
- if ( e_ptr->tval[j] == *tval
- && sval >= e_ptr->min_sval[j]
- && sval <= e_ptr->max_sval[j])
- {
- int color = TERM_GREEN;
-
- /*Reject if not opposite end of name
- prefixes only on postfix egos,
- postfixes only on prefix egos.
- */
- if (ego != -1 && e_ptr->before == e_info[ego].before)
- continue;
-
- /*Color it red of the alchemist doesn't have the essences to create it*/
- if (!alchemist_items_check(*tval, 0, i, 0, TRUE))
- color = TERM_RED;
-
- /* add this ego to the list*/
- strip_and_print(e_info[i].name, color, num);
- validc[num] = color;
- choice[num++] = i;
- break;
- }
- }
- }
- else
- {
- char skipped = 0;
- num = 0;
- if (mod40 != 0)
- {
- strip_and_print("--MORE--", TERM_WHITE, num);
- validc[num] = TERM_WHITE;
- choice[num++] = -1;
- }
-
- for (i = 1; (num < 39) && (i < max_k_idx); i++)
- {
- object_kind *k_ptr = &k_info[i];
-
- /* Analyze matching items */
- if (k_ptr->tval == *tval || (k_ptr->tval == TV_POTION2 && *tval == TV_POTION))
- {
- char color = TERM_GREEN;
- /* Hack -- Skip instant artifacts */
- if (k_ptr->flags3 & (TR3_INSTA_ART)) continue;
-
- /*Don't display recipes that the alchemist doesn't know about*/
- if (!k_ptr->know && !wizard) continue;
-
- /*Skip recipes that are somehow known, but don't exist*/
- if (!alchemist_exists(k_ptr->tval, k_ptr->sval, 0, 0))
- continue;
-
- /* Skip the first 39 if they hit 'more' */
- if (skipped++ < mod40*39)
- continue;
-
- /* Color 'unable to create' items different */
- if (!alchemist_items_check(k_ptr->tval, k_ptr->sval, 0, 0, TRUE))
- color = TERM_RED;
-
- /* Acquire the "name" of object "i" */
- /* and print it in it's place */
- strip_and_print(k_ptr->name, color, num);
-
- /* Remember the object index */
- validc[num] = color;
- choice[num++] = i;
- }
- }
- if (num == 39)
- {
- strip_and_print("--MORE--", TERM_WHITE, num);
- validc[num] = TERM_WHITE;
- choice[num++] = -1;
- }
- }
-
- /* We need to know the maximal possible remembered object_index */
- max_num = num;
- string = "What Kind of %s? (* to see recipe) [%c-%c,*]";
- num = 0xff;
-
- /* Pretend they're all undoable if we where called to display recipes */
- if (recipe)
- {
- for ( num = 0 ; num < max_num ; num++)
- if (validc[num] != TERM_WHITE) validc[num] = TERM_RED;
- string = "show which %s recipe? [%c-%c]";
- }
-
- while (num == 0xff || num >= max_num)
- {
- ch = selectchar[max_num - 1];
- /* Choose! */
- if ( max_num == 0 || !get_com(format(string, tval_desc2, selectchar[0], ch), &ch))
- {
- break;
- }
-
- /* Extra breaks for recipe */
- if (recipe && (ch == '\r' || ch == ' ' || ch == ESCAPE ))
- break;
-
- /* Analyze choice */
- num = selectitem[(byte)ch];
-
- /* Pretend that we don't have enough essences for anything */
- if (ch == '*' )
- {
- for ( num = 0 ; num < max_num ; num++)
- if (validc[num] != TERM_WHITE) validc[num] = TERM_RED;
- string = "Show which %s recipe? [%c-%c]";
- }
- }
- if ( num == 0xff || max_num == 0 || num >= max_num)
- break;
-
- if ( validc[num] == TERM_WHITE )
- {
- if (num == 0)
- mod40--;
- else
- mod40++;
- if ( mod40 < 0)
- mod40 = 0;
- continue;
- }
-
- /* If we don't have enough essences, or user asked for recipes */
- if ( validc[num] != TERM_GREEN )
- {
- /* Display the recipe */
- if (ego)
- alchemist_display_recipe(*tval, sval, choice[num]);
- else
- alchemist_display_recipe(k_info[choice[num]].tval, k_info[choice[num]].sval, 0);
- }
- else
- done = TRUE;
-
- }/*while(!done)*/
-
- /* Restore screen contents */
- Term_load();
- character_icky = FALSE;
-
- /* User abort, or no choices */
- if (max_num == 0 || num == 0xff || num >= max_num)
- {
- if (max_num == 0)
- msg_print("You don't know of anything you can make using that.");
- return ( -1);
- }
- if ( validc[num] != TERM_GREEN )
- return ( -1);
-
- /* And return successful */
- if ( ego )
- return choice[num];
-
- /* Set the tval, should be the same unless they selected a potion2 */
- if (*tval != k_info[choice[num]].tval && *tval != TV_POTION)
- msg_print("Coding error: tval != TV_POTION");
- *tval = k_info[choice[num]].tval;
- return ( k_info[choice[num]].sval );
-}
-
/* Set the 'known' flags for all objects with a level <= lev
* This lets the budding alchemist create basic items.
*/
@@ -3446,7 +3438,7 @@ int alchemist_learn_object(object_type *o_ptr)
/* Alchemist has gained a level - set the ego flags
* for all egos <= lev/4.
*/
-void alchemist_gain_level(int lev)
+static void alchemist_gain_level(int lev)
{
object_type forge;
object_type *o_ptr = &forge;
diff --git a/src/cmd7.hpp b/src/cmd7.hpp
index 84484a30..27935fa7 100644
--- a/src/cmd7.hpp
+++ b/src/cmd7.hpp
@@ -1,3 +1,28 @@
#pragma once
+#include "angband.h"
+
extern void do_cmd_pray(void);
+extern void do_cmd_create_boulder(void);
+extern int rune_exec(rune_spell *spell, int cost);
+extern void necro_info(char *p, int power);
+extern void mindcraft_info(char *p, int power);
+extern void symbiotic_info(char *p, int power);
+extern void mimic_info(char *p, int power);
+extern void do_cmd_summoner(void);
+extern void do_cmd_mindcraft(void);
+extern void do_cmd_mimic(void);
+extern void use_ability_blade(void);
+extern int alchemist_learn_object(object_type *o_ptr);
+extern void do_cmd_alchemist(void);
+extern void do_cmd_beastmaster(void);
+extern void do_cmd_powermage(void);
+extern void do_cmd_possessor(void);
+extern void do_cmd_archer(void);
+extern void do_cmd_set_piercing(void);
+extern void do_cmd_necromancer(void);
+extern void do_cmd_unbeliever(void);
+extern void do_cmd_runecrafter(void);
+extern void do_cmd_symbiotic(void);
+extern s32b sroot(s32b n);
+extern int clamp_failure_chance(int chance, int minfail);
diff --git a/src/externs.h b/src/externs.h
index 2f7be555..7df3ec28 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -462,42 +462,6 @@ extern const char *get_version_string();
/* birth.c */
extern bool_ no_begin_screen;
-/* cmd7.c */
-extern void do_cmd_create_boulder(void);
-extern int rune_exec(rune_spell *spell, int cost);
-extern void necro_info(char *p, int power);
-extern void mindcraft_info(char *p, int power);
-extern void symbiotic_info(char *p, int power);
-extern void mimic_info(char *p, int power);
-extern void cast_magic_spell(int spell, byte level);
-extern void do_cmd_summoner(void);
-extern void do_cmd_mindcraft(void);
-extern void do_cmd_mimic(void);
-extern void use_ability_blade(void);
-extern bool_ alchemist_exists(int tval, int sval, int ego, int artifact);
-extern void rod_tip_extract(object_type *o_ptr);
-extern void do_cmd_toggle_artifact(object_type *o_ptr);
-extern bool_ alchemist_items_check(int tval, int sval, int ego, int tocreate, bool_ message);
-extern void alchemist_display_recipe(int tval, int sval, int ego);
-extern void alchemist_recipe_book(void);
-extern int alchemist_recipe_select(int *tval, int sval, int ego, bool_ recipe);
-extern int alchemist_learn_object(object_type *o_ptr);
-extern void alchemist_gain_level(int lev);
-extern void do_cmd_alchemist(void);
-extern void do_cmd_beastmaster(void);
-extern void do_cmd_powermage(void);
-extern void do_cmd_possessor(void);
-extern void do_cmd_archer(void);
-extern void do_cmd_set_piercing(void);
-extern void do_cmd_necromancer(void);
-extern void do_cmd_unbeliever(void);
-extern void cast_daemon_spell(int spell, byte level);
-extern void do_cmd_unbeliever(void);
-extern void do_cmd_runecrafter(void);
-extern void do_cmd_symbiotic(void);
-extern s32b sroot(s32b n);
-extern int clamp_failure_chance(int chance, int minfail);
-
/* dungeon.c */
extern void play_game(bool_ new_game);
extern void sense_inventory();
diff --git a/src/lua_bind.cc b/src/lua_bind.cc
index c20a7861..624e7e09 100644
--- a/src/lua_bind.cc
+++ b/src/lua_bind.cc
@@ -12,6 +12,7 @@
#include "lua_bind.hpp"
#include "angband.h"
+#include "cmd7.hpp"
#include "corrupt.hpp"
#include "skills.hpp"
#include "spell_type.hpp"
diff --git a/src/powers.cc b/src/powers.cc
index 0af9a761..c9db0925 100644
--- a/src/powers.cc
+++ b/src/powers.cc
@@ -10,6 +10,7 @@
#include "cave.hpp"
#include "cmd1.hpp"
#include "cmd2.hpp"
+#include "cmd7.hpp"
#include "quark.h"
#include "hooks.h"
#include "mimic.hpp"
diff --git a/src/skills.cc b/src/skills.cc
index 4c8a3601..88549078 100644
--- a/src/skills.cc
+++ b/src/skills.cc
@@ -11,6 +11,7 @@
#include "cmd2.hpp"
#include "cmd3.hpp"
#include "cmd5.hpp"
+#include "cmd7.hpp"
#include "gods.hpp"
#include "help.hpp"
#include "hooks.h"
diff --git a/src/spells2.cc b/src/spells2.cc
index 04b62bc2..8357d83c 100644
--- a/src/spells2.cc
+++ b/src/spells2.cc
@@ -9,6 +9,7 @@
#include "angband.h"
#include "cave.hpp"
#include "cmd1.hpp"
+#include "cmd7.hpp"
#include "hooks.h"
#include "notes.hpp"
#include "skills.hpp"
diff --git a/src/wizard1.cc b/src/wizard1.cc
index f28cdea1..53312975 100644
--- a/src/wizard1.cc
+++ b/src/wizard1.cc
@@ -3,6 +3,7 @@
/* Purpose: Spoiler generation -BEN- */
#include "angband.h"
+#include "cmd7.hpp"
#include <vector>
diff --git a/src/xtra1.cc b/src/xtra1.cc
index 24381afe..b23b06d1 100644
--- a/src/xtra1.cc
+++ b/src/xtra1.cc
@@ -11,6 +11,7 @@
#include "angband.h"
#include "cave.hpp"
#include "corrupt.hpp"
+#include "cmd7.hpp"
#include "gods.hpp"
#include "hooks.h"
#include "messages.h"