formatting cleanup src/*.c
Remove trailing spaces, and remove tabs from the files that had trailing spaces. Also, rndorcname() was using a random value to terminate a loop and was recalculating a new one each iteration.
This commit is contained in:
@@ -793,44 +793,42 @@ enum earlyarg e_arg;
|
||||
userea = &argv[i][1];
|
||||
}
|
||||
match = match_optname(userea, earlyopts[idx].name,
|
||||
earlyopts[idx].minlength, earlyopts[idx].valallowed);
|
||||
earlyopts[idx].minlength,
|
||||
earlyopts[idx].valallowed);
|
||||
if (match) break;
|
||||
}
|
||||
|
||||
if (match) {
|
||||
const char *extended_opt = index(userea,':');
|
||||
const char *extended_opt = index(userea, ':');
|
||||
|
||||
if (!extended_opt)
|
||||
extended_opt = index(userea, '=');
|
||||
switch(e_arg) {
|
||||
case ARG_DEBUG:
|
||||
if (extended_opt) {
|
||||
extended_opt++;
|
||||
debug_fields(extended_opt);
|
||||
}
|
||||
return 1;
|
||||
break;
|
||||
case ARG_VERSION: {
|
||||
boolean insert_into_pastebuf = FALSE;
|
||||
|
||||
if (extended_opt) {
|
||||
extended_opt++;
|
||||
if (match_optname(extended_opt, "paste",
|
||||
5, FALSE)) {
|
||||
insert_into_pastebuf = TRUE;
|
||||
} else {
|
||||
raw_printf(
|
||||
"-%sversion can only be extended with -%sversion:paste.\n",
|
||||
dashdash, dashdash);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
early_version_info(insert_into_pastebuf);
|
||||
return 2;
|
||||
break;
|
||||
case ARG_DEBUG:
|
||||
if (extended_opt) {
|
||||
extended_opt++;
|
||||
debug_fields(extended_opt);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
return 1;
|
||||
case ARG_VERSION: {
|
||||
boolean insert_into_pastebuf = FALSE;
|
||||
|
||||
if (extended_opt) {
|
||||
extended_opt++;
|
||||
if (match_optname(extended_opt, "paste", 5, FALSE)) {
|
||||
insert_into_pastebuf = TRUE;
|
||||
} else {
|
||||
raw_printf(
|
||||
"-%sversion can only be extended with -%sversion:paste.\n",
|
||||
dashdash, dashdash);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
early_version_info(insert_into_pastebuf);
|
||||
return 2;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
return FALSE;
|
||||
@@ -843,7 +841,7 @@ enum earlyarg e_arg;
|
||||
* are documented is right here. No gameplay is altered.
|
||||
*
|
||||
* test - test whether this parser is working
|
||||
* ttystatus - TTY:
|
||||
* ttystatus - TTY:
|
||||
* immediateflips - WIN32: turn off display performance
|
||||
* optimization so that display output
|
||||
* can be debugged without buffering.
|
||||
|
||||
@@ -799,7 +799,7 @@ boolean *valsetlist;
|
||||
* all of the fields when context.botlx is set. The tty port in
|
||||
* particular has a problem if that isn't done, since the core sets
|
||||
* context.botlx when a menu or text display obliterates the status
|
||||
* line.
|
||||
* line.
|
||||
*
|
||||
* For those situations, to trigger the full update of every field
|
||||
* whether changed or not, call status_update() with BL_RESET.
|
||||
@@ -817,7 +817,7 @@ boolean *valsetlist;
|
||||
else if ((windowprocs.wincap2 & WC2_FLUSH_STATUS) != 0L)
|
||||
status_update(BL_FLUSH, (genericptr_t) 0, 0, 0,
|
||||
NO_COLOR, &cond_hilites[0]);
|
||||
|
||||
|
||||
context.botl = context.botlx = 0;
|
||||
update_all = FALSE;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ const char *goal;
|
||||
}
|
||||
/* disgusting hack; the alternate selection characters work for any
|
||||
getpos call, but only matter for dowhatis (and doquickwhatis) */
|
||||
doing_what_is = (goal == what_is_an_unknown_object);
|
||||
doing_what_is = (goal == what_is_an_unknown_object);
|
||||
if (doing_what_is) {
|
||||
Sprintf(kbuf, "'%s' or '%s' or '%s' or '%s'",
|
||||
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK]),
|
||||
@@ -2071,20 +2071,17 @@ char *
|
||||
rndorcname(s)
|
||||
char *s;
|
||||
{
|
||||
int i;
|
||||
const char *v[] = {"a", "ai", "og", "u"};
|
||||
const char *snd[] = {"gor", "gris", "un", "bane", "ruk",
|
||||
"oth","ul", "z", "thos","akh","hai"};
|
||||
int vstart = rn2(2);
|
||||
|
||||
static const char *v[] = { "a", "ai", "og", "u" };
|
||||
static const char *snd[] = { "gor", "gris", "un", "bane", "ruk",
|
||||
"oth","ul", "z", "thos","akh","hai" };
|
||||
int i, iend = rn1(2, 3), vstart = rn2(2);
|
||||
|
||||
if (s) {
|
||||
*s = '\0';
|
||||
for (i = 0; i < rn2(2) + 3; ++i) {
|
||||
for (i = 0; i < iend; ++i) {
|
||||
vstart = 1 - vstart; /* 0 -> 1, 1 -> 0 */
|
||||
if (!rn2(30) && i > 0)
|
||||
(void) strcat(s, "-");
|
||||
(void) sprintf(eos(s), "%s", vstart ? v[rn2(SIZE(v))] :
|
||||
snd[rn2(SIZE(snd))]);
|
||||
Sprintf(eos(s), "%s%s", (i > 0 && !rn2(30)) ? "-" : "",
|
||||
vstart ? v[rn2(SIZE(v))] : snd[rn2(SIZE(snd))]);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
|
||||
@@ -412,7 +412,7 @@ boolean with_you;
|
||||
if (migrating_objs)
|
||||
deliver_obj_to_mon(mtmp, 0, DF_ALL);
|
||||
}
|
||||
|
||||
|
||||
if (xlocale && wander) {
|
||||
/* monster moved a bit; pick a nearby location */
|
||||
/* mnearto() deals w/stone, et al */
|
||||
|
||||
@@ -1694,7 +1694,7 @@ unsigned long deliverflags;
|
||||
where = (int) (otmp->owornmask & 0x7fffL); /* destination code */
|
||||
if ((where & MIGR_TO_SPECIES) == 0)
|
||||
continue;
|
||||
|
||||
|
||||
if ((mtmp->data->mflags2 & otmp->corpsenm) != 0) {
|
||||
obj_extract_self(otmp);
|
||||
otmp->owornmask = 0L;
|
||||
|
||||
@@ -1292,7 +1292,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
|
||||
if ((obj->oartifact == ART_MJOLLNIR && Role_if(PM_VALKYRIE))
|
||||
|| tethered_weapon) {
|
||||
if (rn2(100)) {
|
||||
if (tethered_weapon)
|
||||
if (tethered_weapon)
|
||||
tmp_at(DISP_END, BACKTRACK);
|
||||
else
|
||||
sho_obj_return_to_u(obj); /* display its flight */
|
||||
|
||||
@@ -690,7 +690,7 @@ doengrave()
|
||||
xcrypt(blengr(), buf);
|
||||
}
|
||||
dengr = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WAN_NOTHING:
|
||||
case WAN_UNDEAD_TURNING:
|
||||
|
||||
31
src/files.c
31
src/files.c
@@ -666,7 +666,7 @@ void
|
||||
really_close()
|
||||
{
|
||||
int fd;
|
||||
|
||||
|
||||
if (lftrack.init) {
|
||||
fd = lftrack.fd;
|
||||
|
||||
@@ -2156,24 +2156,27 @@ char sep;
|
||||
return (char *) 0;
|
||||
|
||||
while (*str) {
|
||||
if (*str == sep) nsep++;
|
||||
str++;
|
||||
if (*str == sep)
|
||||
nsep++;
|
||||
str++;
|
||||
}
|
||||
csep = rn2(nsep);
|
||||
str = begin;
|
||||
while ((csep > 0) && *str) {
|
||||
str++;
|
||||
if (*str == sep) csep--;
|
||||
str++;
|
||||
if (*str == sep)
|
||||
csep--;
|
||||
}
|
||||
if (*str) {
|
||||
if (*str == sep) str++;
|
||||
begin = str;
|
||||
while (*str && *str != sep) {
|
||||
str++;
|
||||
len++;
|
||||
}
|
||||
*str = '\0';
|
||||
if (len)
|
||||
if (*str == sep)
|
||||
str++;
|
||||
begin = str;
|
||||
while (*str && *str != sep) {
|
||||
str++;
|
||||
len++;
|
||||
}
|
||||
*str = '\0';
|
||||
if (len)
|
||||
return begin;
|
||||
}
|
||||
return (char *) 0;
|
||||
@@ -3582,7 +3585,7 @@ const char *reason; /* explanation */
|
||||
void
|
||||
testinglog(filenm, type, reason)
|
||||
const char *filenm; /* ad hoc file name */
|
||||
const char *type;
|
||||
const char *type;
|
||||
const char *reason; /* explanation */
|
||||
{
|
||||
FILE *lfile;
|
||||
|
||||
@@ -2592,7 +2592,7 @@ long *out_cnt;
|
||||
int unid_cnt;
|
||||
char prompt[QBUFSZ];
|
||||
|
||||
unid_cnt = count_unidentified(invent);
|
||||
unid_cnt = count_unidentified(invent);
|
||||
Sprintf(prompt, "Debug Identify"); /* 'title' rather than 'prompt' */
|
||||
if (unid_cnt)
|
||||
Sprintf(eos(prompt),
|
||||
|
||||
@@ -1391,8 +1391,8 @@ int mmflags;
|
||||
}
|
||||
|
||||
if (allow_minvent && migrating_objs)
|
||||
deliver_obj_to_mon(mtmp, 1, DF_NONE); /* in case there's waiting items */
|
||||
|
||||
deliver_obj_to_mon(mtmp, 1, DF_NONE); /* in case of waiting items */
|
||||
|
||||
if (!in_mklev)
|
||||
newsym(mtmp->mx, mtmp->my); /* make sure the mon shows up */
|
||||
|
||||
|
||||
@@ -782,13 +782,13 @@ struct attack *mattk;
|
||||
|
||||
/* Kill off aggressor if it didn't die. */
|
||||
if (!(result & MM_AGR_DIED)) {
|
||||
boolean was_leashed = (magr->mleashed);
|
||||
boolean was_leashed = (magr->mleashed != 0);
|
||||
|
||||
mondead(magr);
|
||||
if (!DEADMONSTER(magr))
|
||||
return result; /* life saved */
|
||||
result |= MM_AGR_DIED;
|
||||
|
||||
|
||||
/* mondead() -> m_detach() -> m_unleash() always suppresses
|
||||
the m_unleash() slack message, so deliver it here instead */
|
||||
if (was_leashed)
|
||||
|
||||
@@ -801,11 +801,10 @@ stolen_booty(VOID_ARGS)
|
||||
mtyp = rn2((PM_ORC_SHAMAN - PM_ORC) + 1) + PM_ORC;
|
||||
mtmp = makemon(&mons[mtyp], 0, 0, MM_NONAME);
|
||||
if (mtmp) {
|
||||
shiny_orc_stuff(mtmp);
|
||||
shiny_orc_stuff(mtmp);
|
||||
migrate_orc(mtmp, 0UL);
|
||||
}
|
||||
}
|
||||
|
||||
ransacked = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -462,7 +462,7 @@ unsigned corpseflags;
|
||||
* underneath it, you could be told the corpse type of a
|
||||
* monster that you never knew was there without this.
|
||||
* The code in hitmu() substitutes the word "something"
|
||||
* if the corpses obj->dknown is 0.
|
||||
* if the corpse's obj->dknown is 0.
|
||||
*/
|
||||
if (Blind && !sensemon(mtmp))
|
||||
obj->dknown = 0;
|
||||
|
||||
@@ -255,14 +255,12 @@ struct monst *mon;
|
||||
}
|
||||
}
|
||||
|
||||
#define flees_light(mon) ((mon)->data == &mons[PM_GREMLIN] && \
|
||||
(uwep && artifact_light(uwep) && uwep->lamplit))
|
||||
|
||||
#define flees_light(mon) ((mon)->data == &mons[PM_GREMLIN] \
|
||||
&& (uwep && artifact_light(uwep) && uwep->lamplit))
|
||||
/* we could include this in the above macro, but probably overkill/overhead */
|
||||
/* (!((which_armor((mon), W_ARMC) != 0) && ((which_armor((mon), W_ARMH) != 0))) && */
|
||||
/* && (!(which_armor((mon), W_ARMC) != 0 */
|
||||
/* && which_armor((mon), W_ARMH) != 0)) */
|
||||
|
||||
|
||||
|
||||
/* monster begins fleeing for the specified time, 0 means untimed flee
|
||||
* if first, only adds fleetime if monster isn't already fleeing
|
||||
* if fleemsg, prints a message about new flight, otherwise, caller should */
|
||||
|
||||
@@ -1390,7 +1390,7 @@ boolean without_asking;
|
||||
}
|
||||
display_nhwindow(datawin, FALSE);
|
||||
destroy_nhwindow(datawin), datawin = WIN_ERR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1470,7 +1470,7 @@ doidtrap()
|
||||
commands: basic letters vs digits, 'g' vs 'G' for '5', phone
|
||||
keypad vs normal layout of digits, and QWERTZ keyboard swap between
|
||||
y/Y/^Y/M-y/M-Y/M-^Y and z/Z/^Z/M-z/M-Z/M-^Z.)
|
||||
|
||||
|
||||
The interpretor understands
|
||||
'&#' for comment,
|
||||
'&? option' for 'if' (also '&? !option'
|
||||
@@ -1481,7 +1481,7 @@ doidtrap()
|
||||
'&:' for 'else' (also '&: #comment';
|
||||
0 or 1 instance for a given 'if'), and
|
||||
'&.' for 'endif' (also '&. #comment'; required for each 'if').
|
||||
|
||||
|
||||
The option handling is a bit of a mess, with no generality for
|
||||
which options to deal with and only a comma separated list of
|
||||
integer values for the '=value' part. number_pad is the only
|
||||
|
||||
@@ -57,7 +57,7 @@ char *buf;
|
||||
|
||||
Sprintf(eos(buf), " (");
|
||||
#if defined(RUNTIME_PORT_ID)
|
||||
tmp = get_port_id(tmpbuf);
|
||||
tmp = get_port_id(tmpbuf);
|
||||
if (tmp)
|
||||
Sprintf(eos(buf), "%s%s", c++ ? "," : "", tmp);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user