Skip to content

Commit

Permalink
const audit round 1
Browse files Browse the repository at this point in the history
  • Loading branch information
rabidt committed Apr 25, 2020
1 parent b97f561 commit dcdca25
Show file tree
Hide file tree
Showing 29 changed files with 95 additions and 89 deletions.
4 changes: 2 additions & 2 deletions account.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void load_account_unlocks(struct account_data *account);

/**/

int locked_races_cost[NUM_RACES] = {
static const int locked_races_cost[NUM_RACES] = {
0, /*Human*/
0, /*Elf*/
0, /*Dwarf*/
Expand All @@ -53,7 +53,7 @@ int locked_races_cost[NUM_RACES] = {
1000, /*drow (advanced)*/
};

bool locked_races[NUM_RACES] = {
const bool locked_races[NUM_RACES] = {
N, /*Human*/
N, /*Elf*/
N, /*Dwarf*/
Expand Down
15 changes: 9 additions & 6 deletions act.comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ ACMD(do_say)
send_to_char(ch, "Yes, but WHAT do you want to say?\r\n");
else
{
char buf[MAX_INPUT_LENGTH + 14], *msg;
char buf[MAX_INPUT_LENGTH + 14];
const char *msg = NULL;
arg2 = strdup(argument); // make a copy to send to triggers b4 parse
struct char_data *vict;

Expand Down Expand Up @@ -148,7 +149,8 @@ ACMD(do_gsay)

static void perform_tell(struct char_data *ch, struct char_data *vict, char *arg)
{
char buf[MAX_STRING_LENGTH], *msg;
char buf[MAX_STRING_LENGTH];
const char *msg = NULL;

sentence_case(arg);
// append period if it's not already there
Expand Down Expand Up @@ -206,8 +208,8 @@ ACMD(do_tell)
{
int i = 0;
struct char_data *vict = NULL;
char buf[MAX_INPUT_LENGTH] = {'\0'}, buf2[MAX_INPUT_LENGTH] = {'\0'},
*msg = NULL;
char buf[MAX_INPUT_LENGTH] = {'\0'}, buf2[MAX_INPUT_LENGTH] = {'\0'};
const char *msg = NULL;

half_chop(argument, buf, buf2);

Expand Down Expand Up @@ -459,7 +461,8 @@ ACMD(do_gen_comm)
{
struct descriptor_data *i;
char color_on[24];
char buf1[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH], *msg = NULL;
char buf1[MAX_INPUT_LENGTH], buf2[MAX_INPUT_LENGTH];
const char *msg = NULL;
char buf3[MAX_INPUT_LENGTH];
bool emoting = FALSE;

Expand All @@ -483,7 +486,7 @@ ACMD(do_gen_comm)
* [1] name of the action
* [2] message if you're not on the channel
* [3] a color string. */
const char *com_msgs[][4] = {
const char * const com_msgs[][4] = {
{"You cannot holler!!\r\n",
"holler",
"",
Expand Down
4 changes: 2 additions & 2 deletions act.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/* from accounts.c */
ACMD(do_accexp);
bool locked_races[NUM_RACES];
extern const bool locked_races[NUM_RACES];
int has_unlocked_race(struct char_data *ch, int race);
int has_unlocked_class(struct char_data *ch, int class);
int hands_available(struct char_data *ch);
Expand Down Expand Up @@ -346,7 +346,7 @@ ACMD(do_pullswitch);
#define SWITCH_OPEN 2
/* Global variables from act.movement.c */
#ifndef __ACT_MOVEMENT_C__
extern const char *cmd_door[];
extern const char * const cmd_door[];
#endif /* __ACT_MOVEMENT_C__ */

/*****************************************************************************
Expand Down
10 changes: 5 additions & 5 deletions act.informative.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ static void list_obj_to_char(struct obj_data *list, struct char_data *ch,
static void diag_char_to_char(struct char_data *i, struct char_data *ch)
{

struct
const struct
{
byte percent;
const char *text;
Expand Down Expand Up @@ -605,7 +605,7 @@ static void list_one_char(struct char_data *i, struct char_data *ch)
{
struct obj_data *furniture;
char *short_descr;
const char *positions[NUM_POSITIONS] = {
const char * const positions[NUM_POSITIONS] = {
" is lying here, dead.",
" is lying here, mortally wounded.",
" is lying here, incapacitated.",
Expand Down Expand Up @@ -2044,7 +2044,7 @@ void free_history(struct char_data *ch, int type)

#define HIST_LENGTH 100

void add_history(struct char_data *ch, char *str, int type)
void add_history(struct char_data *ch, const char *str, int type)
{
int i = 0;
char time_str[MAX_STRING_LENGTH], buf[MAX_STRING_LENGTH];
Expand Down Expand Up @@ -2093,7 +2093,7 @@ void list_scanned_chars(struct char_data *list, struct char_data *ch, int distan
{
char buf[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH];

const char *how_far[] = {
const char * const how_far[] = {
"close by",
"a ways off",
"far off to the"};
Expand Down Expand Up @@ -3885,7 +3885,7 @@ ACMD(do_toggle)
{
char buf2[4], arg[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
int toggle, tp, wimp_lev, result = 0, len = 0, i;
const char *types[] = {"OFF", "Brief", "Normal", "ON", "\n"};
const char * const types[] = {"OFF", "Brief", "Normal", "ON", "\n"};

const struct
{
Expand Down
6 changes: 3 additions & 3 deletions act.item.c
Original file line number Diff line number Diff line change
Expand Up @@ -2655,7 +2655,7 @@ ACMD(do_pour)

static void wear_message(struct char_data *ch, struct obj_data *obj, int where)
{
const char *wear_messages[][2] = {
const char * const wear_messages[][2] = {
{"$n lights $p and holds it.",
"You light $p and hold it."},

Expand Down Expand Up @@ -2862,7 +2862,7 @@ void perform_wear(struct char_data *ch, struct obj_data *obj, int where)
ITEM_WEAR_WIELD, ITEM_WEAR_TAKE, ITEM_WEAR_FACE, ITEM_WEAR_AMMO_POUCH,
ITEM_WEAR_EAR, ITEM_WEAR_EYES, ITEM_WEAR_BADGE};

const char *already_wearing[NUM_WEARS] = {
const char * const already_wearing[NUM_WEARS] = {
"You're already using a light.\r\n", //0
"YOU SHOULD NEVER SEE THIS MESSAGE. PLEASE REPORT.\r\n", //1
"You're already wearing something on both of your ring fingers.\r\n", //2
Expand Down Expand Up @@ -3047,7 +3047,7 @@ int find_eq_pos(struct char_data *ch, struct obj_data *obj, char *arg)

/* this is lined up with equipment_types, it SHOULD be lined
up with wear_bits (constants.c) probably, but not changing the status quo */
const char *keywords[NUM_WEARS + 1] = {
const char * const keywords[NUM_WEARS + 1] = {
"!RESERVED!", //0 (takeable)
"finger",
"!RESERVED!", // (2nd finger)
Expand Down
2 changes: 1 addition & 1 deletion act.movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ int has_key(struct char_data *ch, obj_vnum key)
#define NEED_LOCKED (1 << 3)

/* cmd_door is required external from act.movement.c */
const char *cmd_door[] = {
const char * const cmd_door[] = {
"open",
"close",
"unlock",
Expand Down
10 changes: 5 additions & 5 deletions act.other.c
Original file line number Diff line number Diff line change
Expand Up @@ -5282,7 +5282,7 @@ ACMD(do_gen_tog)
int i;
char arg[MAX_INPUT_LENGTH];

const char *tog_messages[][2] = {
const char * const tog_messages[][2] = {
/*0*/
{"You are now safe from summoning by other players.\r\n",
"You may now be summoned by other players.\r\n"},
Expand Down Expand Up @@ -5577,7 +5577,7 @@ ACMD(do_gen_tog)
}

/*a general diplomacy skill - popularity increase is determined by SCMD */
struct diplomacy_data diplomacy_types[] = {
const struct diplomacy_data diplomacy_types[] = {
{SCMD_MURMUR, SKILL_MURMUR, 0.75, 1}, /**< Murmur skill, 0.75% increase, 1 tick wait */
{SCMD_PROPAGANDA, SKILL_PROPAGANDA, 2.32, 3}, /**< Propaganda skill, 2.32% increase, 3 tick wait */
{SCMD_LOBBY, SKILL_LOBBY, 6.0, 8}, /**< Lobby skill, 10% increase, 8 tick wait */
Expand Down Expand Up @@ -5717,14 +5717,12 @@ ACMD(do_happyhour)
}

/**** little hint system *******/
#define NUM_HINTS 36

/* i am surrounding hints with this:
\tR[HINT]:\tn \ty
[use nohint or prefedit to deactivate this]\tn\r\n
*/

char *hints[NUM_HINTS] = {
static const char * const hints[] = {
/* 1*/ "\tR[HINT]:\tn \ty"
"Different spell casting classes use different commands "
"to cast their spells. Typing score will show you the appropriate "
Expand Down Expand Up @@ -5959,6 +5957,8 @@ char *hints[NUM_HINTS] = {
" [use nohint or prefedit to deactivate this]\tn\r\n",
};

static const size_t NUM_HINTS = sizeof(hints)/sizeof(hints[0]);

void show_hints(void)
{
int roll = dice(1, NUM_HINTS) - 1;
Expand Down
20 changes: 10 additions & 10 deletions act.wizard.c
Original file line number Diff line number Diff line change
Expand Up @@ -3530,7 +3530,7 @@ ACMD(do_show)
#define RANGE(low, high) (value = MAX((low), MIN((high), (value))))

/* The set options available */
struct set_struct
const struct set_struct
{
const char *cmd;
const char level;
Expand Down Expand Up @@ -4308,9 +4308,9 @@ static int perform_set(struct char_data *ch, struct char_data *vict, int mode, c

void show_set_help(struct char_data *ch)
{
const char *set_levels[] = {"Imm", "God", "GrGod", "IMP"};
const char *set_targets[] = {"PC", "NPC", "BOTH"};
const char *set_types[] = {"MISC", "BINARY", "NUMBER"};
const char * const set_levels[] = {"Imm", "God", "GrGod", "IMP"};
const char * const set_targets[] = {"PC", "NPC", "BOTH"};
const char * const set_types[] = {"MISC", "BINARY", "NUMBER"};
char buf[MAX_STRING_LENGTH];
int i, len = 0, add_len = 0;

Expand Down Expand Up @@ -4677,7 +4677,7 @@ ACMD(do_links)
/* Armor class limits*/
#define TOTAL_WEAR_CHECKS (NUM_ITEM_WEARS - 1) /* no take flag */

struct zcheck_armor
const struct zcheck_armor
{
bitvector_t bitvector; /* from Structs.h */
int ac_allowed; /* Max. AC allowed for this body part */
Expand Down Expand Up @@ -4712,12 +4712,12 @@ struct zcheck_armor

/* Applies limits !! Very Important: Keep these in the same order as in Structs.h.
* To ignore an apply, set max_aff to -99. These will be ignored if MAX_APPLIES_LIMIT = 0 */
struct zcheck_affs
const struct zcheck_affs
{
int aff_type; /*from Structs.h*/
int min_aff; /*min. allowed value*/
int max_aff; /*max. allowed value*/
char *message; /*phrase for error message*/
const char *message; /*phrase for error message*/
} zaffs[NUM_APPLIES] = {
{APPLY_NONE, 0, -99, "unused0"}, //0
{APPLY_STR, -5, 9, "strength"},
Expand Down Expand Up @@ -5838,11 +5838,11 @@ ACMD(do_file)
char buf[MAX_STRING_LENGTH]; /* Display buffer for req_file. */

/* Defines which files are available to read. */
struct file_struct
const struct file_struct
{
char *cmd; /* The 'name' of the file to view */
const char *cmd; /* The 'name' of the file to view */
char level; /* Minimum level needed to view. */
char *file; /* The file location, relative to the working dir. */
const char *file; /* The file location, relative to the working dir. */
int read_backwards; /* Should the file be read backwards by default? */
} fields[] = {
{"xnames", LVL_IMMORT, XNAME_FILE, TRUE},
Expand Down
6 changes: 3 additions & 3 deletions asciimap.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static int vdoor_marks[4] = {VDOOR_NS, VDOOR_EW, VDOOR_NS, VDOOR_EW};
static void MapArea(room_rnum room, struct char_data *ch, int x, int y, int min, int max, sh_int xpos, sh_int ypos, bool worldmap);
static char *StringMap(int centre, int size);
static char *WorldMap(int centre, int size, int mapshape, int maptype);
static char *CompactStringMap(int centre, int size);
static const char *CompactStringMap(int centre, int size);

/******************************************************************************
* End Local (File Scope) Function Prototypes
Expand Down Expand Up @@ -418,7 +418,7 @@ static char *StringMap(int centre, int size) {
}

/* public function to return a string representation of the map. */
char * get_map_string(struct char_data *ch, room_vnum target_room) {
const char * get_map_string(struct char_data *ch, room_vnum target_room) {
int size, centre, x, y, min, max;
int ew_size = 0, ns_size = 0;
bool worldmap;
Expand Down Expand Up @@ -484,7 +484,7 @@ static char *WorldMap(int centre, int size, int mapshape, int maptype) {
return strmap;
}

static char *CompactStringMap(int centre, int size) {
static const char *CompactStringMap(int centre, int size) {
static char strmap[MAX_MAP * MAX_MAP * 12 + MAX_MAP * 2 + 1];
char *mp = strmap;
int x, y;
Expand Down
2 changes: 1 addition & 1 deletion asciimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool show_worldmap(struct char_data *ch);
void perform_map(struct char_data *ch, char *argument, bool worldmap);
bool can_see_map(struct char_data *ch);
void str_and_map(char *str, struct char_data *ch, room_vnum target_room);
char *get_map_string(struct char_data *ch, room_vnum target_room);
const char *get_map_string(struct char_data *ch, room_vnum target_room);

ACMD(do_map);

Expand Down
3 changes: 2 additions & 1 deletion clan.c
Original file line number Diff line number Diff line change
Expand Up @@ -3339,7 +3339,8 @@ ACMD(do_clanset)
ACMD(do_clantalk)
{
char buf[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH],
arg[MAX_INPUT_LENGTH], *msg, *arg2;
arg[MAX_INPUT_LENGTH], *arg2;
const char *msg = NULL;
clan_vnum c_id;
struct descriptor_data *i;
bool leader = FALSE, imm = FALSE;
Expand Down
2 changes: 1 addition & 1 deletion comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3355,7 +3355,7 @@ void perform_act(const char *orig, struct char_data *ch, struct obj_data *obj,
last_act_message = strdup(lbuf);
}

char *act(const char *str, int hide_invisible, struct char_data *ch,
const char *act(const char *str, int hide_invisible, struct char_data *ch,
struct obj_data *obj, void *vict_obj, int type)
{
struct char_data *to = NULL;
Expand Down
2 changes: 1 addition & 1 deletion comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void update_msdp_room(struct char_data *ch);
/* act functions */
void perform_act(const char *orig, struct char_data *ch, struct obj_data *obj,
void *vict_obj, struct char_data *to, bool carrier_return);
char *act(const char *str, int hide_invisible, struct char_data *ch, struct obj_data *obj, void *vict_obj, int type);
const char *act(const char *str, int hide_invisible, struct char_data *ch, struct obj_data *obj, void *vict_obj, int type);

/* I/O functions */
void write_to_q(const char *txt, struct txt_q *queue, int aliased);
Expand Down
2 changes: 1 addition & 1 deletion db.c
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,7 @@ void parse_mobile(FILE *mob_f, int nr)
}

/* read all objects from obj file; generate index and prototypes */
char *parse_object(FILE *obj_f, int nr)
const char *parse_object(FILE *obj_f, int nr)
{
static int i = 0;
static char line[READ_SIZE];
Expand Down
2 changes: 1 addition & 1 deletion db.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void index_boot(int mode);
void discrete_load(FILE *fl, int mode, char *filename);
void parse_room(FILE *fl, int virtual_nr);
void parse_mobile(FILE *mob_f, int nr);
char *parse_object(FILE *obj_f, int nr);
const char *parse_object(FILE *obj_f, int nr);
int is_empty(zone_rnum zone_nr);
void reset_zone(zone_rnum zone);
void reboot_wizlists(void);
Expand Down
9 changes: 5 additions & 4 deletions dg_olc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/* local functions */
static void trigedit_disp_menu(struct descriptor_data *d);
static void trigedit_disp_types(struct descriptor_data *d);
static void trigedit_create_index(int znum, char *type);
static void trigedit_create_index(int znum, const char *type);
static void trigedit_setup_new(struct descriptor_data *d);

/* Trigedit */
Expand Down Expand Up @@ -186,7 +186,7 @@ void trigedit_setup_existing(struct descriptor_data *d, int rtrg_num)
static void trigedit_disp_menu(struct descriptor_data *d)
{
struct trig_data *trig = OLC_TRIG(d);
char *attach_type;
const char *attach_type;
char trgtypes[MEDIUM_STRING];

get_char_colors(d->character);
Expand Down Expand Up @@ -685,10 +685,11 @@ void trigedit_save(struct descriptor_data *d)
trigedit_create_index(zone, "trg");
}

static void trigedit_create_index(int znum, char *type)
static void trigedit_create_index(int znum, const char *type)
{
FILE *newfile, *oldfile;
char new_name[128], old_name[128], *prefix;
char new_name[128], old_name[128];
const char *prefix;
char buf[MAX_STRING_LENGTH], buf1[MAX_STRING_LENGTH];
int num, found = FALSE;

Expand Down
2 changes: 1 addition & 1 deletion dg_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void assign_triggers(void *i, int type);
/* From dg_variables.c */
void add_var(struct trig_var_data **var_list, const char *name, const char *value, long id);
int item_in_list(char *item, obj_data *list);
char *skill_percent(struct char_data *ch, char *skill);
const char *skill_percent(struct char_data *ch, char *skill);
int char_has_item(char *item, struct char_data *ch);
void var_subst(void *go, struct script_data *sc, trig_data *trig,
int type, char *line, char *buf);
Expand Down
Loading

0 comments on commit dcdca25

Please sign in to comment.