Mercurial > hg > early-roguelike
comparison arogue5/fight.c @ 233:0990adf580ee
Declare some function arguments as const.
Some functions, mostly in fight.c, declared variables as pointers to
const char but passed them to functions that took pointers to ordinary
char. The strings did not actually get modified, so adding 'const' to
the function definitions removed the warnings.
author | John "Elwin" Edwards |
---|---|
date | Sun, 06 Mar 2016 19:32:47 -0500 |
parents | 56e748983fa8 |
children |
comparison
equal
deleted
inserted
replaced
229:50b89f165a34 | 233:0990adf580ee |
---|---|
18 #include <string.h> | 18 #include <string.h> |
19 #include "rogue.h" | 19 #include "rogue.h" |
20 | 20 |
21 bool roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, | 21 bool roll_em(struct thing *att_er, struct thing *def_er, struct object *weap, |
22 bool hurl, struct object *cur_weapon, bool back_stab); | 22 bool hurl, struct object *cur_weapon, bool back_stab); |
23 void hit(struct object *weapon, struct thing *tp, char *er, char *ee, | 23 void hit(struct object *weapon, struct thing *tp, const char *er, |
24 bool back_stab); | 24 const char *ee, bool back_stab); |
25 void miss(struct object *weapon, struct thing *tp, char *er, char *ee); | 25 void miss(struct object *weapon, struct thing *tp, const char *er, |
26 const char *ee); | |
26 int dext_plus(int dexterity); | 27 int dext_plus(int dexterity); |
27 int str_plus(short str); | 28 int str_plus(short str); |
28 int add_dam(short str); | 29 int add_dam(short str); |
29 int hung_dam(void); | 30 int hung_dam(void); |
30 void thunk(struct object *weap, struct thing *tp, char *mname); | 31 void thunk(struct object *weap, struct thing *tp, const char *mname); |
31 void m_thunk(struct object *weap, struct thing *tp, char *mname); | 32 void m_thunk(struct object *weap, struct thing *tp, const char *mname); |
32 void bounce(struct object *weap, struct thing *tp, char *mname); | 33 void bounce(struct object *weap, struct thing *tp, const char *mname); |
33 void m_bounce(struct object *weap, struct thing *tp, char *mname); | 34 void m_bounce(struct object *weap, struct thing *tp, const char *mname); |
34 struct object *wield_weap(struct object *thrown, struct thing *mp); | 35 struct object *wield_weap(struct object *thrown, struct thing *mp); |
35 void explode(struct thing *tp); | 36 void explode(struct thing *tp); |
36 | 37 |
37 #define CONF_DAMAGE -1 | 38 #define CONF_DAMAGE -1 |
38 #define PARAL_DAMAGE -2 | 39 #define PARAL_DAMAGE -2 |
1035 * prname: | 1036 * prname: |
1036 * The print name of a combatant | 1037 * The print name of a combatant |
1037 */ | 1038 */ |
1038 | 1039 |
1039 char * | 1040 char * |
1040 prname(char *who, bool upper) | 1041 prname(const char *who, bool upper) |
1041 { | 1042 { |
1042 static char tbuf[LINELEN]; | 1043 static char tbuf[LINELEN]; |
1043 | 1044 |
1044 *tbuf = '\0'; | 1045 *tbuf = '\0'; |
1045 if (who == 0) | 1046 if (who == 0) |
1060 * hit: | 1061 * hit: |
1061 * Print a message to indicate a succesful hit | 1062 * Print a message to indicate a succesful hit |
1062 */ | 1063 */ |
1063 | 1064 |
1064 void | 1065 void |
1065 hit(struct object *weapon, struct thing *tp, char *er, char *ee, bool back_stab) | 1066 hit(struct object *weapon, struct thing *tp, const char *er, const char *ee, |
1067 bool back_stab) | |
1066 { | 1068 { |
1067 register char *s = NULL; | 1069 register char *s = NULL; |
1068 char | 1070 char |
1069 att_name[80], /* Name of attacker */ | 1071 att_name[80], /* Name of attacker */ |
1070 def_name[80];/* Name of defender */ | 1072 def_name[80];/* Name of defender */ |
1117 * miss: | 1119 * miss: |
1118 * Print a message to indicate a poor swing | 1120 * Print a message to indicate a poor swing |
1119 */ | 1121 */ |
1120 | 1122 |
1121 void | 1123 void |
1122 miss(struct object *weapon, struct thing *tp, char *er, char *ee) | 1124 miss(struct object *weapon, struct thing *tp, const char *er, const char *ee) |
1123 { | 1125 { |
1124 register char *s = NULL; | 1126 register char *s = NULL; |
1125 char | 1127 char |
1126 att_name[80], /* Name of attacker */ | 1128 att_name[80], /* Name of attacker */ |
1127 def_name[80];/* Name of defender */ | 1129 def_name[80];/* Name of defender */ |
1224 * thunk: | 1226 * thunk: |
1225 * A missile hits a monster | 1227 * A missile hits a monster |
1226 */ | 1228 */ |
1227 | 1229 |
1228 void | 1230 void |
1229 thunk(struct object *weap, struct thing *tp, char *mname) | 1231 thunk(struct object *weap, struct thing *tp, const char *mname) |
1230 { | 1232 { |
1231 /* tp: Defender */ | 1233 /* tp: Defender */ |
1232 char *def_name; /* Name of defender */ | 1234 char *def_name; /* Name of defender */ |
1233 | 1235 |
1234 /* What do we call the defender? */ | 1236 /* What do we call the defender? */ |
1252 * mthunk: | 1254 * mthunk: |
1253 * A missile from a monster hits the player | 1255 * A missile from a monster hits the player |
1254 */ | 1256 */ |
1255 | 1257 |
1256 void | 1258 void |
1257 m_thunk(struct object *weap, struct thing *tp, char *mname) | 1259 m_thunk(struct object *weap, struct thing *tp, const char *mname) |
1258 { | 1260 { |
1259 char *att_name; /* Name of attacker */ | 1261 char *att_name; /* Name of attacker */ |
1260 | 1262 |
1261 /* What do we call the attacker? */ | 1263 /* What do we call the attacker? */ |
1262 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) | 1264 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) |
1279 * bounce: | 1281 * bounce: |
1280 * A missile misses a monster | 1282 * A missile misses a monster |
1281 */ | 1283 */ |
1282 | 1284 |
1283 void | 1285 void |
1284 bounce(struct object *weap, struct thing *tp, char *mname) | 1286 bounce(struct object *weap, struct thing *tp, const char *mname) |
1285 { | 1287 { |
1286 /* tp: Defender */ | 1288 /* tp: Defender */ |
1287 char *def_name; /* Name of defender */ | 1289 char *def_name; /* Name of defender */ |
1288 | 1290 |
1289 /* What do we call the defender? */ | 1291 /* What do we call the defender? */ |
1307 * m_bounce: | 1309 * m_bounce: |
1308 A missle from a monster misses the player | 1310 A missle from a monster misses the player |
1309 */ | 1311 */ |
1310 | 1312 |
1311 void | 1313 void |
1312 m_bounce(struct object *weap, struct thing *tp, char *mname) | 1314 m_bounce(struct object *weap, struct thing *tp, const char *mname) |
1313 { | 1315 { |
1314 char *att_name; /* Name of attacker */ | 1316 char *att_name; /* Name of attacker */ |
1315 | 1317 |
1316 /* What do we call the attacker? */ | 1318 /* What do we call the attacker? */ |
1317 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) | 1319 if (!cansee(tp->t_pos.y, tp->t_pos.x) || invisible(tp)) |