From 37e207260774f520c77b3f3481160d07e38fd4db Mon Sep 17 00:00:00 2001 From: habu Date: Fri, 1 Feb 2013 04:35:24 +0000 Subject: [PATCH] Define constant reference table as const --- src/cmd1.c | 2 +- src/cmd4.c | 2 +- src/cmd5.c | 4 +- src/dungeon.c | 2 +- src/externs.h | 168 ++++++++++++++++++++++++++++----------------------------- src/hex.c | 2 +- src/spells3.c | 8 +-- src/store.c | 2 +- src/tables.c | 158 ++++++++++++++++++++++++++--------------------------- src/variable.c | 16 +++--- src/wizard2.c | 4 +- src/xtra1.c | 12 ++--- 12 files changed, 190 insertions(+), 190 deletions(-) diff --git a/src/cmd1.c b/src/cmd1.c index 1771561b8..25dfe887b 100644 --- a/src/cmd1.c +++ b/src/cmd1.c @@ -2225,7 +2225,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int { int special_effect = 0, stun_effect = 0, times = 0, max_times; int min_level = 1; - martial_arts *ma_ptr = &ma_blows[0], *old_ptr = &ma_blows[0]; + const martial_arts *ma_ptr = &ma_blows[0], *old_ptr = &ma_blows[0]; int resist_stun = 0; int weight = 8; diff --git a/src/cmd4.c b/src/cmd4.c index 1d49d7075..889255b6e 100644 --- a/src/cmd4.c +++ b/src/cmd4.c @@ -6930,7 +6930,7 @@ static void do_cmd_knowledge_spell_exp(void) int i = 0, spell_exp, exp_level; FILE *fff; - magic_type *s_ptr; + const magic_type *s_ptr; char file_name[1024]; diff --git a/src/cmd5.c b/src/cmd5.c index 066b57059..d723face7 100644 --- a/src/cmd5.c +++ b/src/cmd5.c @@ -61,7 +61,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm byte spells[64]; bool flag, redraw, okay; char choice; - magic_type *s_ptr; + const magic_type *s_ptr; char out_val[160]; cptr p; #ifdef JP @@ -1101,7 +1101,7 @@ void do_cmd_cast(void) object_type *o_ptr; - magic_type *s_ptr; + const magic_type *s_ptr; cptr q, s; diff --git a/src/dungeon.c b/src/dungeon.c index 545fb7c42..5059b18da 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -1407,7 +1407,7 @@ static void recharged_notice(object_type *o_ptr) static void check_music(void) { - magic_type *s_ptr; + const magic_type *s_ptr; int spell; s32b need_mana; u32b need_mana_frac; diff --git a/src/externs.h b/src/externs.h index 3984f621c..baae676be 100644 --- a/src/externs.h +++ b/src/externs.h @@ -39,89 +39,89 @@ extern int max_max_autopick; extern autopick_type *autopick_list; /* tables.c */ -extern s16b ddd[9]; -extern s16b ddx[10]; -extern s16b ddy[10]; -extern s16b ddx_ddd[9]; -extern s16b ddy_ddd[9]; -extern s16b cdd[8]; -extern s16b ddx_cdd[8]; -extern s16b ddy_cdd[8]; -extern char hexsym[16]; -extern char listsym[]; -extern cptr color_char; -extern byte adj_mag_study[]; -extern byte adj_mag_mana[]; -extern byte adj_mag_fail[]; -extern byte adj_mag_stat[]; -extern byte adj_chr_gold[]; -extern byte adj_int_dev[]; -extern byte adj_wis_sav[]; -extern byte adj_dex_dis[]; -extern byte adj_int_dis[]; -extern byte adj_dex_ta[]; -extern byte adj_str_td[]; -extern byte adj_dex_th[]; -extern byte adj_str_th[]; -extern byte adj_str_wgt[]; -extern byte adj_str_hold[]; -extern byte adj_str_dig[]; -extern byte adj_str_blow[]; -extern byte adj_dex_blow[]; -extern byte adj_dex_safe[]; -extern byte adj_con_fix[]; -extern byte adj_con_mhp[]; -extern byte adj_chr_chm[]; -extern byte blows_table[12][12]; -extern arena_type arena_info[MAX_ARENA_MONS + 2]; -extern owner_type owners[MAX_STORES][MAX_OWNERS]; -extern byte extract_energy[200]; -extern s32b player_exp[PY_MAX_LEVEL]; -extern s32b player_exp_a[PY_MAX_LEVEL]; -extern player_sex sex_info[MAX_SEXES]; -extern player_race race_info[MAX_RACES]; -extern player_class class_info[MAX_CLASS]; -extern magic_type technic_info[NUM_TECHNIC][32]; -extern player_seikaku seikaku_info[MAX_SEIKAKU]; -extern player_race mimic_info[]; -extern u32b fake_spell_flags[4]; -extern s32b realm_choices1[]; -extern s32b realm_choices2[]; -extern cptr realm_names[]; +extern const s16b ddd[9]; +extern const s16b ddx[10]; +extern const s16b ddy[10]; +extern const s16b ddx_ddd[9]; +extern const s16b ddy_ddd[9]; +extern const s16b cdd[8]; +extern const s16b ddx_cdd[8]; +extern const s16b ddy_cdd[8]; +extern const char hexsym[16]; +extern const char listsym[]; +extern const cptr color_char; +extern const byte adj_mag_study[]; +extern const byte adj_mag_mana[]; +extern const byte adj_mag_fail[]; +extern const byte adj_mag_stat[]; +extern const byte adj_chr_gold[]; +extern const byte adj_int_dev[]; +extern const byte adj_wis_sav[]; +extern const byte adj_dex_dis[]; +extern const byte adj_int_dis[]; +extern const byte adj_dex_ta[]; +extern const byte adj_str_td[]; +extern const byte adj_dex_th[]; +extern const byte adj_str_th[]; +extern const byte adj_str_wgt[]; +extern const byte adj_str_hold[]; +extern const byte adj_str_dig[]; +extern const byte adj_str_blow[]; +extern const byte adj_dex_blow[]; +extern const byte adj_dex_safe[]; +extern const byte adj_con_fix[]; +extern const byte adj_con_mhp[]; +extern const byte adj_chr_chm[]; +extern const byte blows_table[12][12]; +extern const arena_type arena_info[MAX_ARENA_MONS + 2]; +extern const owner_type owners[MAX_STORES][MAX_OWNERS]; +extern const byte extract_energy[200]; +extern const s32b player_exp[PY_MAX_LEVEL]; +extern const s32b player_exp_a[PY_MAX_LEVEL]; +extern const player_sex sex_info[MAX_SEXES]; +extern const player_race race_info[MAX_RACES]; +extern const player_class class_info[MAX_CLASS]; +extern const magic_type technic_info[NUM_TECHNIC][32]; +extern const player_seikaku seikaku_info[MAX_SEIKAKU]; +extern const player_race mimic_info[]; +extern const u32b fake_spell_flags[4]; +extern const s32b realm_choices1[]; +extern const s32b realm_choices2[]; +extern const cptr realm_names[]; #ifdef JP -extern cptr E_realm_names[]; +extern const cptr E_realm_names[]; #endif -extern cptr spell_names[VALID_REALM][32]; -extern int chest_traps[64]; -extern cptr player_title[MAX_CLASS][PY_MAX_LEVEL/5]; -extern cptr color_names[16]; -extern cptr stat_names[6]; -extern cptr stat_names_reduced[6]; -extern cptr window_flag_desc[32]; -extern option_type option_info[]; -extern cptr chaos_patrons[MAX_PATRON]; -extern int chaos_stats[MAX_PATRON]; -extern int chaos_rewards[MAX_PATRON][20]; -extern martial_arts ma_blows[MAX_MA]; -extern int monk_ave_damage[PY_MAX_LEVEL+1][3]; -extern cptr game_inscriptions[]; -extern kamae kamae_shurui[MAX_KAMAE]; -extern kamae kata_shurui[MAX_KATA]; -extern cptr exp_level_str[5]; -extern cptr silly_attacks[MAX_SILLY_ATTACK]; +extern const cptr spell_names[VALID_REALM][32]; +extern const int chest_traps[64]; +extern const cptr player_title[MAX_CLASS][PY_MAX_LEVEL/5]; +extern const cptr color_names[16]; +extern const cptr stat_names[6]; +extern const cptr stat_names_reduced[6]; +extern const cptr window_flag_desc[32]; +extern const option_type option_info[]; +extern const cptr chaos_patrons[MAX_PATRON]; +extern const int chaos_stats[MAX_PATRON]; +extern const int chaos_rewards[MAX_PATRON][20]; +extern const martial_arts ma_blows[MAX_MA]; +extern const int monk_ave_damage[PY_MAX_LEVEL+1][3]; +extern const cptr game_inscriptions[]; +extern const kamae kamae_shurui[MAX_KAMAE]; +extern const kamae kata_shurui[MAX_KATA]; +extern const cptr exp_level_str[5]; +extern const cptr silly_attacks[MAX_SILLY_ATTACK]; #ifdef JP -extern cptr silly_attacks2[MAX_SILLY_ATTACK]; +extern const cptr silly_attacks2[MAX_SILLY_ATTACK]; #endif -extern monster_power monster_powers[MAX_MONSPELLS]; -extern cptr monster_powers_short[MAX_MONSPELLS]; -extern cptr ident_info[]; -extern mbe_info_type mbe_info[]; -extern byte feature_action_flags[FF_FLAG_MAX]; -extern dragonbreath_type dragonbreath_info[]; -extern activation_type activation_info[]; +extern const monster_power monster_powers[MAX_MONSPELLS]; +extern const cptr monster_powers_short[MAX_MONSPELLS]; +extern const cptr ident_info[]; +extern const mbe_info_type mbe_info[]; +extern const byte feature_action_flags[FF_FLAG_MAX]; +extern const dragonbreath_type dragonbreath_info[]; +extern const activation_type activation_info[]; /* variable.c */ -extern cptr copyright[5]; +extern const cptr copyright[5]; extern byte h_ver_major; extern byte h_ver_minor; extern byte h_ver_patch; @@ -439,9 +439,9 @@ extern u32b option_mask[8]; extern u32b window_flag[8]; extern u32b window_mask[8]; extern term *angband_term[8]; -extern char angband_term_name[8][16]; +extern const char angband_term_name[8][16]; extern byte angband_color_table[256][4]; -extern char angband_sound_name[SOUND_MAX][16]; +extern const char angband_sound_name[SOUND_MAX][16]; extern cave_type *cave[MAX_HGT]; extern saved_floor_type saved_floors[MAX_SAVED_FLOORS]; extern s16b max_floor_id; @@ -463,11 +463,11 @@ extern byte tval_to_attr[128]; extern char tval_to_char[128]; extern cptr keymap_act[KEYMAP_MODES][256]; extern player_type *p_ptr; -extern player_sex *sp_ptr; -extern player_race *rp_ptr; -extern player_class *cp_ptr; -extern player_seikaku *ap_ptr; -extern player_magic *mp_ptr; +extern const player_sex *sp_ptr; +extern const player_race *rp_ptr; +extern const player_class *cp_ptr; +extern const player_seikaku *ap_ptr; +extern const player_magic *mp_ptr; extern birther previous_char; extern vault_type *v_info; extern char *v_name; diff --git a/src/hex.c b/src/hex.c index 0928493a5..5b697c713 100644 --- a/src/hex.c +++ b/src/hex.c @@ -126,7 +126,7 @@ bool stop_hex_spell(void) Called from dungeon.c */ void check_hex(void) { - magic_type *s_ptr; + const magic_type *s_ptr; int spell; s32b need_mana; u32b need_mana_frac; diff --git a/src/spells3.c b/src/spells3.c index 4a3f4876e..b5dd46cce 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -3932,7 +3932,7 @@ void display_spell_list(void) int i, j; int y, x; int m[9]; - magic_type *s_ptr; + const magic_type *s_ptr; char name[80]; char out_val[160]; @@ -4236,7 +4236,7 @@ int mod_spell_chance_2(int chance) s16b spell_chance(int spell, int use_realm) { int chance, minfail; - magic_type *s_ptr; + const magic_type *s_ptr; int need_mana; int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4; @@ -4342,7 +4342,7 @@ s16b spell_chance(int spell, int use_realm) */ bool spell_okay(int spell, bool learned, bool study_pray, int use_realm) { - magic_type *s_ptr; + const magic_type *s_ptr; /* Access the spell */ if (!is_magic(use_realm)) @@ -4389,7 +4389,7 @@ bool spell_okay(int spell, bool learned, bool study_pray, int use_realm) void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm) { int i, spell, exp_level, increment = 64; - magic_type *s_ptr; + const magic_type *s_ptr; cptr comment; char info[80]; char out_val[160]; diff --git a/src/store.c b/src/store.c index 7c13b496b..570e9414e 100644 --- a/src/store.c +++ b/src/store.c @@ -19,7 +19,7 @@ static int store_top = 0; static int store_bottom = 0; static int xtra_stock = 0; static store_type *st_ptr = NULL; -static owner_type *ot_ptr = NULL; +static const owner_type *ot_ptr = NULL; static s16b old_town_num = 0; static s16b inner_town_num = 0; #define RUMOR_CHANCE 8 diff --git a/src/tables.c b/src/tables.c index 4d5888e9b..43db8ac21 100644 --- a/src/tables.c +++ b/src/tables.c @@ -18,41 +18,41 @@ /* * Global array for looping through the "keypad directions" */ -s16b ddd[9] = +const s16b ddd[9] = { 2, 8, 6, 4, 3, 1, 9, 7, 5 }; /* * Global arrays for converting "keypad direction" into offsets */ -s16b ddx[10] = +const s16b ddx[10] = { 0, -1, 0, 1, -1, 0, 1, -1, 0, 1 }; -s16b ddy[10] = +const s16b ddy[10] = { 0, 1, 1, 1, 0, 0, 0, -1, -1, -1 }; /* * Global arrays for optimizing "ddx[ddd[i]]" and "ddy[ddd[i]]" */ -s16b ddx_ddd[9] = +const s16b ddx_ddd[9] = { 0, 0, 1, -1, 1, -1, 1, -1, 0 }; -s16b ddy_ddd[9] = +const s16b ddy_ddd[9] = { 1, -1, 0, 0, 1, 1, -1, -1, 0 }; /* * Circular keypad direction array */ -s16b cdd[8] = +const s16b cdd[8] = { 2, 3, 6, 9, 8, 7, 4, 1 }; /* * Global arrays for optimizing "ddx[cdd[i]]" and "ddy[cdd[i]]" */ -s16b ddx_cdd[8] = +const s16b ddx_cdd[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }; -s16b ddy_cdd[8] = +const s16b ddy_cdd[8] = { 1, 1, 0, -1, -1, -1, 0, 1 }; @@ -61,7 +61,7 @@ s16b ddy_cdd[8] = * Global array for converting numbers to uppercase hecidecimal digit * This array can also be used to convert a number to an octal digit */ -char hexsym[16] = +const char hexsym[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' @@ -71,7 +71,7 @@ char hexsym[16] = /* * Global array for converting numbers to a logical list symbol */ -char listsym[] = +const char listsym[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', @@ -85,13 +85,13 @@ char listsym[] = /* * Encode the screen colors */ -cptr color_char = "dwsorgbuDWvyRGBU"; +const cptr color_char = "dwsorgbuDWvyRGBU"; /* * Stat Table (INT/WIS) -- Number of half-spells per level */ -byte adj_mag_study[] = +const byte adj_mag_study[] = { 0 /* 3 */, 0 /* 4 */, @@ -137,7 +137,7 @@ byte adj_mag_study[] = /* * Stat Table (INT/WIS) -- extra 1/4-mana-points per level */ -byte adj_mag_mana[] = +const byte adj_mag_mana[] = { 0 /* 3 */, 0 /* 4 */, @@ -183,7 +183,7 @@ byte adj_mag_mana[] = /* * Stat Table (INT/WIS) -- Minimum failure rate (percentage) */ -byte adj_mag_fail[] = +const byte adj_mag_fail[] = { 99 /* 3 */, 99 /* 4 */, @@ -229,7 +229,7 @@ byte adj_mag_fail[] = /* * Stat Table (INT/WIS) -- Various things */ -byte adj_mag_stat[] = +const byte adj_mag_stat[] = { 0 /* 3 */, 0 /* 4 */, @@ -275,7 +275,7 @@ byte adj_mag_stat[] = /* * Stat Table (CHR) -- payment percentages */ -byte adj_chr_gold[] = +const byte adj_chr_gold[] = { 130 /* 3 */, 125 /* 4 */, @@ -321,7 +321,7 @@ byte adj_chr_gold[] = /* * Stat Table (INT) -- Magic devices */ -byte adj_int_dev[] = +const byte adj_int_dev[] = { 0 /* 3 */, 0 /* 4 */, @@ -367,7 +367,7 @@ byte adj_int_dev[] = /* * Stat Table (WIS) -- Saving throw */ -byte adj_wis_sav[] = +const byte adj_wis_sav[] = { 0 /* 3 */, 0 /* 4 */, @@ -413,7 +413,7 @@ byte adj_wis_sav[] = /* * Stat Table (DEX) -- disarming */ -byte adj_dex_dis[] = +const byte adj_dex_dis[] = { 0 /* 3 */, 0 /* 4 */, @@ -459,7 +459,7 @@ byte adj_dex_dis[] = /* * Stat Table (INT) -- disarming */ -byte adj_int_dis[] = +const byte adj_int_dis[] = { 0 /* 3 */, 0 /* 4 */, @@ -505,7 +505,7 @@ byte adj_int_dis[] = /* * Stat Table (DEX) -- bonus to ac (plus 128) */ -byte adj_dex_ta[] = +const byte adj_dex_ta[] = { 128 + -4 /* 3 */, 128 + -3 /* 4 */, @@ -551,7 +551,7 @@ byte adj_dex_ta[] = /* * Stat Table (STR) -- bonus to dam (plus 128) */ -byte adj_str_td[] = +const byte adj_str_td[] = { 128 + -2 /* 3 */, 128 + -2 /* 4 */, @@ -597,7 +597,7 @@ byte adj_str_td[] = /* * Stat Table (DEX) -- bonus to hit (plus 128) */ -byte adj_dex_th[] = +const byte adj_dex_th[] = { 128 + -3 /* 3 */, 128 + -2 /* 4 */, @@ -643,7 +643,7 @@ byte adj_dex_th[] = /* * Stat Table (STR) -- bonus to hit (plus 128) */ -byte adj_str_th[] = +const byte adj_str_th[] = { 128 + -3 /* 3 */, 128 + -2 /* 4 */, @@ -689,7 +689,7 @@ byte adj_str_th[] = /* * Stat Table (STR) -- weight limit in deca-pounds */ -byte adj_str_wgt[] = +const byte adj_str_wgt[] = { 10 /* 3 */, 11 /* 4 */, @@ -735,7 +735,7 @@ byte adj_str_wgt[] = /* * Stat Table (STR) -- weapon weight limit in pounds */ -byte adj_str_hold[] = +const byte adj_str_hold[] = { 4 /* 3 */, 5 /* 4 */, @@ -781,7 +781,7 @@ byte adj_str_hold[] = /* * Stat Table (STR) -- digging value */ -byte adj_str_dig[] = +const byte adj_str_dig[] = { 0 /* 3 */, 0 /* 4 */, @@ -827,7 +827,7 @@ byte adj_str_dig[] = /* * Stat Table (STR) -- help index into the "blow" table */ -byte adj_str_blow[] = +const byte adj_str_blow[] = { 3 /* 3 */, 4 /* 4 */, @@ -873,7 +873,7 @@ byte adj_str_blow[] = /* * Stat Table (DEX) -- index into the "blow" table */ -byte adj_dex_blow[] = +const byte adj_dex_blow[] = { 0 /* 3 */, 0 /* 4 */, @@ -919,7 +919,7 @@ byte adj_dex_blow[] = /* * Stat Table (DEX) -- chance of avoiding "theft" and "falling" */ -byte adj_dex_safe[] = +const byte adj_dex_safe[] = { 0 /* 3 */, 1 /* 4 */, @@ -965,7 +965,7 @@ byte adj_dex_safe[] = /* * Stat Table (CON) -- base regeneration rate */ -byte adj_con_fix[] = +const byte adj_con_fix[] = { 0 /* 3 */, 0 /* 4 */, @@ -1011,7 +1011,7 @@ byte adj_con_fix[] = /* * Stat Table (CON) -- extra 1/4-hitpoints per level (plus 128) */ -byte adj_con_mhp[] = +const byte adj_con_mhp[] = { 128 + -8 /* 3 */, 128 + -6 /* 4 */, @@ -1057,7 +1057,7 @@ byte adj_con_mhp[] = /* * Stat Table (CHR) -- charm */ -byte adj_chr_chm[] = +const byte adj_chr_chm[] = { 0 /* 3 */, 0 /* 4 */, @@ -1145,7 +1145,7 @@ byte adj_chr_chm[] = * The player gets "blows_table[P][D]" blows/round, as shown below, * up to a maximum of "num" blows/round, plus any "bonus" blows/round. */ -byte blows_table[12][12] = +const byte blows_table[12][12] = { /* P/D */ /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11+ */ @@ -1166,7 +1166,7 @@ byte blows_table[12][12] = }; -arena_type arena_info[MAX_ARENA_MONS + 2] = +const arena_type arena_info[MAX_ARENA_MONS + 2] = { { MON_NOBORTA, TV_AMULET, SV_AMULET_ADORNMENT }, { MON_MORI_TROLL, TV_FOOD, SV_FOOD_PINT_OF_WINE }, @@ -1227,7 +1227,7 @@ arena_type arena_info[MAX_ARENA_MONS + 2] = * I want to do 50k owners, but the purse is currently s16b. Perhaps * we should just store 1/10th of the purse? */ -owner_type owners[MAX_STORES][MAX_OWNERS] = +const owner_type owners[MAX_STORES][MAX_OWNERS] = { { /* General store - 32 unique names */ @@ -1976,7 +1976,7 @@ owner_type owners[MAX_STORES][MAX_OWNERS] = * the (compiled out) small random energy boost code. It may * also tend to cause more "clumping" at high speeds. */ -byte extract_energy[200] = +const byte extract_energy[200] = { /* Slow */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* Slow */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -2006,7 +2006,7 @@ byte extract_energy[200] = /* * Base experience levels, may be adjusted up for race and/or class */ -s32b player_exp[PY_MAX_LEVEL] = +const s32b player_exp[PY_MAX_LEVEL] = { 10, 25, @@ -2061,7 +2061,7 @@ s32b player_exp[PY_MAX_LEVEL] = }; -s32b player_exp_a[PY_MAX_LEVEL] = +const s32b player_exp_a[PY_MAX_LEVEL] = { 20, 50, @@ -2122,7 +2122,7 @@ s32b player_exp_a[PY_MAX_LEVEL] = * Title, * Winner */ -player_sex sex_info[MAX_SEXES] = +const player_sex sex_info[MAX_SEXES] = { { #ifdef JP @@ -2156,7 +2156,7 @@ player_sex sex_info[MAX_SEXES] = * infra, * class-choices */ -player_race race_info[MAX_RACES] = +const player_race race_info[MAX_RACES] = { { #ifdef JP @@ -2726,7 +2726,7 @@ player_race race_info[MAX_RACES] = * x_dis, x_dev, x_sav, x_stl, x_srh, x_fos, x_thn, x_thb, * HD, Exp, pet_upkeep_div */ -player_class class_info[MAX_CLASS] = +const player_class class_info[MAX_CLASS] = { { #ifdef JP @@ -3058,7 +3058,7 @@ player_class class_info[MAX_CLASS] = }, }; -player_seikaku seikaku_info[MAX_SEIKAKU] = +const player_seikaku seikaku_info[MAX_SEIKAKU] = { { #ifdef JP @@ -3183,7 +3183,7 @@ player_seikaku seikaku_info[MAX_SEIKAKU] = -player_race mimic_info[] = +const player_race mimic_info[] = { { #ifdef JP @@ -3249,7 +3249,7 @@ player_race mimic_info[] = -magic_type technic_info[NUM_TECHNIC][32] = +const magic_type technic_info[NUM_TECHNIC][32] = { { /* Music */ @@ -3374,7 +3374,7 @@ magic_type technic_info[NUM_TECHNIC][32] = * Zangband uses this array instead of the spell flags table, as there * are 5 realms of magic, each with 4 spellbooks and 8 spells per book -- TY */ -u32b fake_spell_flags[4]= +const u32b fake_spell_flags[4]= { 0x000000ff, 0x0000ff00, @@ -3383,7 +3383,7 @@ u32b fake_spell_flags[4]= }; -s32b realm_choices1[MAX_CLASS] = +const s32b realm_choices1[MAX_CLASS] = { (CH_NONE), /* Warrior */ (CH_LIFE | CH_SORCERY | CH_NATURE | @@ -3426,7 +3426,7 @@ s32b realm_choices1[MAX_CLASS] = }; -s32b realm_choices2[MAX_CLASS] = +const s32b realm_choices2[MAX_CLASS] = { (CH_NONE), /* Warrior */ (CH_LIFE | CH_SORCERY | CH_NATURE | @@ -3470,7 +3470,7 @@ s32b realm_choices2[MAX_CLASS] = #ifdef JP -cptr realm_names[] = +const cptr realm_names[] = { "ËâË¡¤Ê¤·", "À¸Ì¿", @@ -3496,9 +3496,9 @@ cptr realm_names[] = #endif #ifdef JP -cptr E_realm_names[] +const cptr E_realm_names[] #else -cptr realm_names[] +const cptr realm_names[] #endif = { "none", @@ -3531,7 +3531,7 @@ cptr realm_names[] * The "pval" of a chest determines the quality of its treasure * Note that disarming a trap on a chest also removes the lock. */ -int chest_traps[64] = +const int chest_traps[64] = { 0, /* 0 == empty */ (CHEST_POISON), @@ -3607,7 +3607,7 @@ int chest_traps[64] = * needs only ten titles total. */ #ifdef JP -cptr player_title[MAX_CLASS][PY_MAX_LEVEL / 5] = +const cptr player_title[MAX_CLASS][PY_MAX_LEVEL / 5] = { /* Warrior */ { @@ -4009,7 +4009,7 @@ cptr player_title[MAX_CLASS][PY_MAX_LEVEL / 5] = }; #else -cptr player_title[MAX_CLASS][PY_MAX_LEVEL / 5] = +const cptr player_title[MAX_CLASS][PY_MAX_LEVEL / 5] = { /* Warrior */ { @@ -4405,7 +4405,7 @@ cptr player_title[MAX_CLASS][PY_MAX_LEVEL / 5] = }; #endif -monster_power monster_powers[MAX_MONSPELLS] = +const monster_power monster_powers[MAX_MONSPELLS] = { /* level, smana, %fail, manedam, %manefail, use_stat, name */ #ifdef JP @@ -4607,7 +4607,7 @@ monster_power monster_powers[MAX_MONSPELLS] = }; -cptr monster_powers_short[MAX_MONSPELLS] = { +const cptr monster_powers_short[MAX_MONSPELLS] = { #ifdef JP "¶«¤Ö", "²¿¤«", "ËâÎϾõî", "¥í¥±¥Ã¥È", "¼Í·â", "²¿¤«", "²¿¤«", "²¿¤«", @@ -4649,7 +4649,7 @@ cptr monster_powers_short[MAX_MONSPELLS] = { /* * Hack -- the "basic" color names (see "TERM_xxx") */ -cptr color_names[16] = +const cptr color_names[16] = { #ifdef JP "¹õ", @@ -4693,7 +4693,7 @@ cptr color_names[16] = /* * Abbreviations of healthy stats */ -cptr stat_names[6] = +const cptr stat_names[6] = { #ifdef JP "ÏÓÎÏ :", "ÃÎǽ :", "¸­¤µ :", "´ïÍÑ :", "ÂÑµ× :", "Ì¥ÎÏ :" @@ -4706,7 +4706,7 @@ cptr stat_names[6] = /* * Abbreviations of damaged stats */ -cptr stat_names_reduced[6] = +const cptr stat_names_reduced[6] = { #ifdef JP "ÏÓÎÏx:", "ÃÎǽx:", "¸­¤µx:", "´ïÍÑx:", "Âѵ×x:", "Ì¥ÎÏx:" @@ -4731,7 +4731,7 @@ cptr stat_names_reduced[6] = * The "ctrl-g" command (or pseudo-command) should perhaps grab a snapshot * of the main screen into any interested windows. */ -cptr window_flag_desc[32] = +const cptr window_flag_desc[32] = { #ifdef JP "»ý¤Áʪ/ÁõÈ÷°ìÍ÷", @@ -4837,7 +4837,7 @@ cptr window_flag_desc[32] = * Available Options * */ -option_type option_info[] = +const option_type option_info[] = { /*** Input Options ***/ @@ -5783,7 +5783,7 @@ option_type option_info[] = #ifdef JP -cptr chaos_patrons[MAX_PATRON] = +const cptr chaos_patrons[MAX_PATRON] = { "¥¹¥í¡¼¥¿¡¼", "¥Þ¥Ù¥í¡¼¥É", @@ -5806,7 +5806,7 @@ cptr chaos_patrons[MAX_PATRON] = "¥«¥¤¥ó" }; #else -cptr chaos_patrons[MAX_PATRON] = +const cptr chaos_patrons[MAX_PATRON] = { "Slortar", "Mabelode", @@ -5831,7 +5831,7 @@ cptr chaos_patrons[MAX_PATRON] = #endif -int chaos_stats[MAX_PATRON] = +const int chaos_stats[MAX_PATRON] = { A_CON, /* Slortar */ A_CON, /* Mabelode */ @@ -5857,7 +5857,7 @@ int chaos_stats[MAX_PATRON] = -int chaos_rewards[MAX_PATRON][20] = +const int chaos_rewards[MAX_PATRON][20] = { /* Slortar the Old: */ { @@ -5989,7 +5989,7 @@ int chaos_rewards[MAX_PATRON][20] = } }; -martial_arts ma_blows[MAX_MA] = +const martial_arts ma_blows[MAX_MA] = { #ifdef JP { "%s¤ò²¥¤Ã¤¿¡£", 1, 0, 1, 5, 0 }, @@ -6031,7 +6031,7 @@ martial_arts ma_blows[MAX_MA] = }; -int monk_ave_damage[PY_MAX_LEVEL+1][3] = +const int monk_ave_damage[PY_MAX_LEVEL+1][3] = { {0, 0, 0}, {249, 249, 249}, @@ -6090,7 +6090,7 @@ int monk_ave_damage[PY_MAX_LEVEL+1][3] = * Table of game-generated inscriptions (indexed by the defines in * defines.h). -- RG */ -cptr game_inscriptions[] = +const cptr game_inscriptions[] = { NULL, /* FEEL_NONE */ #ifdef JP @@ -6117,7 +6117,7 @@ cptr game_inscriptions[] = }; -kamae kamae_shurui[MAX_KAMAE] = +const kamae kamae_shurui[MAX_KAMAE] = { #ifdef JP {"¸¼Éð", 25, ""}, @@ -6132,7 +6132,7 @@ kamae kamae_shurui[MAX_KAMAE] = #endif }; -kamae kata_shurui[MAX_KATA] = +const kamae kata_shurui[MAX_KATA] = { #ifdef JP {"µï¹ç", 25, ""}, @@ -6147,7 +6147,7 @@ kamae kata_shurui[MAX_KATA] = #endif }; -cptr exp_level_str[5]= +const cptr exp_level_str[5]= #ifdef JP {"[½é¿´¼Ô]", "[ÆþÌç¼Ô]", "[½ÏÎý¼Ô]", "[¥¨¥­¥¹¥Ñ¡¼¥È]", "[ã¿Í]"}; #else @@ -6156,7 +6156,7 @@ cptr exp_level_str[5]= /* Weird melee attack types when hallucinating */ #ifdef JP -cptr silly_attacks[MAX_SILLY_ATTACK] = +const cptr silly_attacks[MAX_SILLY_ATTACK] = { "¤Ë¾®Êؤò¤«¤±¤é¤ì¤¿¡£", "¤¬¤¢¤Ê¤¿¤Î²ó¤ê¤ò3²ó²ó¤Ã¤Æ¥ï¥ó¤È¸À¤Ã¤¿¡£", @@ -6202,7 +6202,7 @@ cptr silly_attacks[MAX_SILLY_ATTACK] = }; /* Note: %s for strfmt() */ -cptr silly_attacks2[MAX_SILLY_ATTACK] = +const cptr silly_attacks2[MAX_SILLY_ATTACK] = { "%s¤Ë¾®Êؤò¤«¤±¤¿¡£", "%s¤Î²ó¤ê¤ò3²ó²ó¤Ã¤Æ¥ï¥ó¤È¸À¤Ã¤¿¡£", @@ -6247,7 +6247,7 @@ cptr silly_attacks2[MAX_SILLY_ATTACK] = "¸À¤Ã¤¿¡£¡ÖÊѶòÈÚÅÜ¡¢À仿¸ø³«Ã桪¡×", }; #else -cptr silly_attacks[MAX_SILLY_ATTACK] = +const cptr silly_attacks[MAX_SILLY_ATTACK] = { "smothers", "hugs", @@ -6291,7 +6291,7 @@ cptr silly_attacks[MAX_SILLY_ATTACK] = * The table of "symbol info" -- each entry is a string of the form * "X:desc" where "X" is the trigger, and "desc" is the "info". */ -cptr ident_info[] = +const cptr ident_info[] = { #ifdef JP " :°Å°Ç", @@ -6494,7 +6494,7 @@ cptr ident_info[] = /* * The table of monsters' blow effects */ -mbe_info_type mbe_info[] = +const mbe_info_type mbe_info[] = { { 0, 0, }, /* None */ { 60, GF_MISSILE, }, /* HURT */ @@ -6536,7 +6536,7 @@ mbe_info_type mbe_info[] = /* * The table of features' actions */ -byte feature_action_flags[FF_FLAG_MAX] = +const byte feature_action_flags[FF_FLAG_MAX] = { 0, /* LOS */ 0, /* PROJECT */ @@ -6660,7 +6660,7 @@ byte feature_action_flags[FF_FLAG_MAX] = /* * Define flags, effect type, name for dragon breath activation */ -dragonbreath_type dragonbreath_info[] = { +const dragonbreath_type dragonbreath_info[] = { { TR_RES_ACID, GF_ACID, _("»À", "acid") }, { TR_RES_ELEC, GF_ELEC, _("ÅÅ·â", "lightning") }, { TR_RES_FIRE, GF_FIRE, _("²Ð±ê", "fire") }, @@ -6681,7 +6681,7 @@ dragonbreath_type dragonbreath_info[] = { /* * Define flags, levels, values of activations */ -activation_type activation_info[] = +const activation_type activation_info[] = { { "SUNLIGHT", ACT_SUNLIGHT, 10, 250, {10, 0}, _("ÂÀÍÛ¸÷Àþ", "beam of sunlight") }, diff --git a/src/variable.c b/src/variable.c index 739f1b25b..303482024 100644 --- a/src/variable.c +++ b/src/variable.c @@ -16,7 +16,7 @@ /* * Hack -- Link a copyright message into the executable */ -cptr copyright[5] = +const cptr copyright[5] = { "Copyright (c) 1989 James E. Wilson, Robert A. Keoneke", "", @@ -543,7 +543,7 @@ term *angband_term[8]; /* * Standard window names */ -char angband_term_name[8][16] = +const char angband_term_name[8][16] = { "Hengband", "Term-1", @@ -583,7 +583,7 @@ byte angband_color_table[256][4] = /* * Standard sound names */ -char angband_sound_name[SOUND_MAX][16] = +const char angband_sound_name[SOUND_MAX][16] = { "", "hit", @@ -776,11 +776,11 @@ player_type *p_ptr = &p_body; * Pointer to the player tables * (sex, race, class, magic) */ -player_sex *sp_ptr; -player_race *rp_ptr; -player_class *cp_ptr; -player_seikaku *ap_ptr; -player_magic *mp_ptr; +const player_sex *sp_ptr; +const player_race *rp_ptr; +const player_class *cp_ptr; +const player_seikaku *ap_ptr; +const player_magic *mp_ptr; /* diff --git a/src/wizard2.c b/src/wizard2.c index 7c5cdc82c..27fa4b1a9 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -1848,7 +1848,7 @@ static void do_cmd_dump_options(void) /* Check for exist option bits */ for (i = 0; option_info[i].o_desc; i++) { - option_type *ot_ptr = &option_info[i]; + const option_type *ot_ptr = &option_info[i]; if (ot_ptr->o_var) exist[ot_ptr->o_set][ot_ptr->o_bit] = i + 1; } @@ -1864,7 +1864,7 @@ static void do_cmd_dump_options(void) { if (exist[i][j]) { - option_type *ot_ptr = &option_info[exist[i][j] - 1]; + const option_type *ot_ptr = &option_info[exist[i][j] - 1]; fprintf(fff, " %d - %02d (%4d) %s\n", i, j, ot_ptr->o_page, ot_ptr->o_text); } diff --git a/src/xtra1.c b/src/xtra1.c index 4cd33543b..14dfdbc5c 100644 --- a/src/xtra1.c +++ b/src/xtra1.c @@ -2247,7 +2247,7 @@ static void calc_spells(void) int num_allowed; int num_boukyaku = 0; - magic_type *s_ptr; + const magic_type *s_ptr; int which; int bonus = 0; @@ -3185,7 +3185,7 @@ void calc_bonuses(void) bool easy_2weapon = FALSE; bool riding_levitation = FALSE; s16b this_o_idx, next_o_idx = 0; - player_race *tmp_rp_ptr; + const player_race *tmp_rp_ptr; /* Save the old vision stuff */ bool old_telepathy = p_ptr->telepathy; @@ -5878,25 +5878,25 @@ msg_print(" #if 0 if (have_dd_s && ((p_ptr->realm1 == REALM_SORCERY) || (p_ptr->realm2 == REALM_SORCERY) || (p_ptr->pclass == CLASS_SORCERER))) { - magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY-1][SPELL_DD_S]; + const magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY-1][SPELL_DD_S]; if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE; } if (have_dd_t && ((p_ptr->realm1 == REALM_TRUMP) || (p_ptr->realm2 == REALM_TRUMP) || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))) { - magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP-1][SPELL_DD_T]; + const magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP-1][SPELL_DD_T]; if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE; } #endif if (have_sw && ((p_ptr->realm1 == REALM_NATURE) || (p_ptr->realm2 == REALM_NATURE) || (p_ptr->pclass == CLASS_SORCERER))) { - magic_type *s_ptr = &mp_ptr->info[REALM_NATURE-1][SPELL_SW]; + const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE-1][SPELL_SW]; if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE; } if (have_kabe && ((p_ptr->realm1 == REALM_CRAFT) || (p_ptr->realm2 == REALM_CRAFT) || (p_ptr->pclass == CLASS_SORCERER))) { - magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT-1][SPELL_KABE]; + const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT-1][SPELL_KABE]; if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE; } } -- 2.11.0