Style cleanup.
This fixes indentation and spacing issues. Some too-long lines were kept because I didn't want to wokr on reorganizing the code to make them wrap.
This commit is contained in:
+180
-169
@@ -619,7 +619,7 @@ fixup_special()
|
|||||||
baalz_fixup();
|
baalz_fixup();
|
||||||
}
|
}
|
||||||
#ifdef CONWAY
|
#ifdef CONWAY
|
||||||
if(level.flags.conway){
|
if (level.flags.conway) {
|
||||||
conway_setup();
|
conway_setup();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1635,15 +1635,20 @@ conway_islive(lvlp, x, y)
|
|||||||
struct monst *mhere;
|
struct monst *mhere;
|
||||||
/* Hero's levels don't count here since it's likely to be
|
/* Hero's levels don't count here since it's likely to be
|
||||||
* much larger than the surrounding life. */
|
* much larger than the surrounding life. */
|
||||||
if(u.ux == x && u.uy == y){
|
if (u.ux == x && u.uy == y)
|
||||||
if(Upolyd && nonliving(youmonst.data)) return 0;
|
{
|
||||||
return 1;
|
|
||||||
|
return !(Upolyd && nonliving(youmonst.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
mhere = m_at(x,y);
|
mhere = m_at(x,y);
|
||||||
if(!mhere) return 0;
|
|
||||||
if(nonliving(mhere->data)) return 0;
|
if (!mhere || nonliving(mhere->data))
|
||||||
if(lvlp) *lvlp += mhere->m_lev;
|
return 0;
|
||||||
|
|
||||||
|
if (lvlp)
|
||||||
|
*lvlp += mhere->m_lev;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1654,7 +1659,7 @@ static struct lifelimits {
|
|||||||
|
|
||||||
/* Find the bounds of the rectangular area where we will play life. */
|
/* Find the bounds of the rectangular area where we will play life. */
|
||||||
static void
|
static void
|
||||||
conway_findactive(){
|
conway_findactive() {
|
||||||
lls.xmin = 0;
|
lls.xmin = 0;
|
||||||
lls.ymin = 0;
|
lls.ymin = 0;
|
||||||
lls.xmax = COLNO-1;
|
lls.xmax = COLNO-1;
|
||||||
@@ -1671,14 +1676,14 @@ conway_findactive(){
|
|||||||
while(CONWAY_WALL(COLNO/2, lls.ymax) && lls.ymax > ROWNO/2)
|
while(CONWAY_WALL(COLNO/2, lls.ymax) && lls.ymax > ROWNO/2)
|
||||||
lls.ymax--;
|
lls.ymax--;
|
||||||
#undef CONWAY_WALL
|
#undef CONWAY_WALL
|
||||||
if(lls.xmin > COLNO/2 || lls.ymin > ROWNO/2 ||
|
if (lls.xmin > COLNO/2 || lls.ymin > ROWNO/2
|
||||||
lls.xmax < COLNO/2 || lls.ymax < ROWNO/2)
|
|| lls.xmax < COLNO/2 || lls.ymax < ROWNO/2)
|
||||||
panic("can't find active area in level");
|
panic("can't find active area in level");
|
||||||
#ifdef CONWAY_DEBUG
|
#ifdef CONWAY_DEBUG
|
||||||
{
|
{
|
||||||
char b[100];
|
char b[100];
|
||||||
sprintf(b, "lls.x(%d-%d) .y(%d-%d)",lls.xmin,lls.xmax,lls.ymin,lls.ymax);
|
sprintf(b, "lls.x(%d-%d) .y(%d-%d)",lls.xmin,lls.xmax,lls.ymin,lls.ymax);
|
||||||
paniclog("trace",b);
|
paniclog("trace",b);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1687,22 +1692,22 @@ static void NDECL((*helddroplevel)) = 0;
|
|||||||
|
|
||||||
/* Leaving the level - get rid of our scratchpad. */
|
/* Leaving the level - get rid of our scratchpad. */
|
||||||
static void
|
static void
|
||||||
conway_cleanup(){
|
conway_cleanup() {
|
||||||
#ifdef CONWAY_DEBUG
|
#ifdef CONWAY_DEBUG
|
||||||
paniclog("trace","conway_cleanup()");
|
paniclog("trace","conway_cleanup()");
|
||||||
#endif
|
#endif
|
||||||
if(ls){
|
if (ls) {
|
||||||
free(ls);
|
free(ls);
|
||||||
}
|
}
|
||||||
if(lslev){
|
if (lslev) {
|
||||||
free(lslev);
|
free(lslev);
|
||||||
}
|
}
|
||||||
DROPLEVEL_UNWIND(helddroplevel);
|
DROPLEVEL_UNWIND(helddroplevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Entering / reentering the level. */
|
/* Entering / reentering the level. */
|
||||||
void
|
void
|
||||||
conway_restore(){
|
conway_restore() {
|
||||||
#ifdef CONWAY_DEBUG
|
#ifdef CONWAY_DEBUG
|
||||||
paniclog("trace","conway_restore()");
|
paniclog("trace","conway_restore()");
|
||||||
#endif
|
#endif
|
||||||
@@ -1714,7 +1719,7 @@ conway_restore(){
|
|||||||
|
|
||||||
/* First entry into the level. */
|
/* First entry into the level. */
|
||||||
static void
|
static void
|
||||||
conway_setup(){
|
conway_setup() {
|
||||||
int cnt;
|
int cnt;
|
||||||
int subtype = rn2(3);
|
int subtype = rn2(3);
|
||||||
char *force = nh_getenv("SPLEVTYPE2");
|
char *force = nh_getenv("SPLEVTYPE2");
|
||||||
@@ -1722,18 +1727,19 @@ conway_setup(){
|
|||||||
paniclog("trace","conway_setup()");
|
paniclog("trace","conway_setup()");
|
||||||
#endif
|
#endif
|
||||||
conway_restore();
|
conway_restore();
|
||||||
if(force){
|
if (force) {
|
||||||
int tmp = atoi(force);
|
int tmp = atoi(force);
|
||||||
if(tmp>=0 && tmp <=2) subtype = tmp;
|
if (tmp>=0 && tmp <=2)
|
||||||
|
subtype = tmp;
|
||||||
}
|
}
|
||||||
switch(subtype){
|
switch(subtype) {
|
||||||
case 0: /* just the normal bigroom population */
|
case 0: /* just the normal bigroom population */
|
||||||
break;
|
break;
|
||||||
case 1: /* extra mildews to start */
|
case 1: /* extra mildews to start */
|
||||||
/* TUNE ME! */
|
/* TUNE ME! */
|
||||||
cnt = (lls.xmax-lls.xmin+1) * (lls.ymax-lls.ymin+1) / 32;
|
cnt = (lls.xmax-lls.xmin+1) * (lls.ymax-lls.ymin+1) / 32;
|
||||||
|
|
||||||
while(cnt--){
|
while(cnt--) {
|
||||||
/* XXX is flags correct? */
|
/* XXX is flags correct? */
|
||||||
(void) makemon(&mons[PM_MILDEW], 0, 0, MM_NOCOUNTBIRTH);
|
(void) makemon(&mons[PM_MILDEW], 0, 0, MM_NOCOUNTBIRTH);
|
||||||
}
|
}
|
||||||
@@ -1760,14 +1766,14 @@ LIMIT(n, lbound, ubound)
|
|||||||
int lbound, ubound;
|
int lbound, ubound;
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
if(n<lbound){
|
if (n<lbound) {
|
||||||
rv = ubound;
|
rv = ubound;
|
||||||
} else {
|
} else {
|
||||||
if(n>ubound){
|
if (n>ubound) {
|
||||||
rv = lbound;
|
rv = lbound;
|
||||||
} else {
|
} else {
|
||||||
rv = n;
|
rv = n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@@ -1787,17 +1793,17 @@ static struct monst *
|
|||||||
conway_random_neighbor(x,y)
|
conway_random_neighbor(x,y)
|
||||||
int x,y;
|
int x,y;
|
||||||
{
|
{
|
||||||
#define LRN(a,b) if(conway_islive_wrap(NULL, a, b))return m_at(a,b);
|
#define LRN(a,b) if (conway_islive_wrap(NULL, a, b)) return m_at(a,b);
|
||||||
int mutation[8];
|
int mutation[8];
|
||||||
int ndx;
|
int ndx;
|
||||||
int last=8;
|
int last=8;
|
||||||
for(ndx=0;ndx<8;ndx++)mutation[ndx] = ndx;
|
for(ndx=0;ndx<8;ndx++)mutation[ndx] = ndx;
|
||||||
for(ndx=0;ndx<8;ndx++){
|
for(ndx=0;ndx<8;ndx++) {
|
||||||
int entry = rn2(last);
|
int entry = rn2(last);
|
||||||
int pick = mutation[entry];
|
int pick = mutation[entry];
|
||||||
last--;
|
last--;
|
||||||
mutation[entry] = mutation[last];
|
mutation[entry] = mutation[last];
|
||||||
switch(pick){
|
switch(pick) {
|
||||||
case 0: LRN(x-1, y-1); break;
|
case 0: LRN(x-1, y-1); break;
|
||||||
case 1: LRN(x, y-1); break;
|
case 1: LRN(x, y-1); break;
|
||||||
case 2: LRN(x+1, y-1); break;
|
case 2: LRN(x+1, y-1); break;
|
||||||
@@ -1820,24 +1826,27 @@ Blob) and not just continued into the next generation. This of course includes
|
|||||||
the hero.
|
the hero.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
conway_update(){
|
conway_update() {
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if(!lslev) panic("conway_update: lslev=null");
|
if (!lslev)
|
||||||
|
panic("conway_update: lslev=null");
|
||||||
|
|
||||||
/* Be unpredictable: Life updates about half of the time, but not on
|
/* Be unpredictable: Life updates about half of the time, but not on
|
||||||
alternate moves. */
|
alternate moves. */
|
||||||
if(monstermoves % 16 < 5) return;
|
if (monstermoves % 16 < 5)
|
||||||
if(rn2(11) < 3) return;
|
return;
|
||||||
|
if (rn2(11) < 3)
|
||||||
|
return;
|
||||||
/* first, figure out what changes are needed for the next generation */
|
/* first, figure out what changes are needed for the next generation */
|
||||||
for(x=lls.xmin; x<=lls.xmax; x++){
|
for(x=lls.xmin; x<=lls.xmax; x++) {
|
||||||
for(y=lls.ymin; y<=lls.ymax; y++){
|
for(y=lls.ymin; y<=lls.ymax; y++) {
|
||||||
*lslev[x][y] = 0; /* total levels of live neighbors */
|
*lslev[x][y] = 0; /* total levels of live neighbors */
|
||||||
#ifdef notyet
|
#ifdef notyet
|
||||||
/*
|
/*
|
||||||
This isn't needed unless there are interior wall features or other places
|
This isn't needed unless there are interior wall features or other places
|
||||||
we don't want to put a monster.
|
we don't want to put a monster.
|
||||||
if( this is not a legal position for a monster){
|
if( this is not a legal position for a monster) {
|
||||||
ls[x][y] = 99; /* flag for no action */
|
ls[x][y] = 99; /* flag for no action */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1872,138 +1881,140 @@ we don't want to put a monster.
|
|||||||
#define DO_DIE_CROWD 2
|
#define DO_DIE_CROWD 2
|
||||||
#define DO_LIVE 3
|
#define DO_LIVE 3
|
||||||
|
|
||||||
for(x=lls.xmin; x<=lls.xmax; x++){
|
for(x=lls.xmin; x<=lls.xmax; x++) {
|
||||||
for(y=lls.ymin; y<=lls.ymax; y++){
|
for(y=lls.ymin; y<=lls.ymax; y++) {
|
||||||
struct monst *mhere;
|
struct monst *mhere;
|
||||||
int action = DO_DIE_NOTHING;
|
int action = DO_DIE_NOTHING;
|
||||||
#ifdef LDEBUG
|
#ifdef LDEBUG
|
||||||
counts[ls[x][y]]++;
|
counts[ls[x][y]]++;
|
||||||
#endif
|
#endif
|
||||||
switch(*ls[x][y]){
|
switch(*ls[x][y]) {
|
||||||
#ifdef notyet
|
#ifdef notyet
|
||||||
case 99: /* special case: forced no action */
|
case 99: /* special case: forced no action */
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
/* die of loneliness */
|
/* die of loneliness */
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
action = DO_DIE_LONELY;
|
action = DO_DIE_LONELY;
|
||||||
break;
|
break;
|
||||||
/* make/continue life */
|
/* make/continue life */
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
action = DO_LIVE;
|
action = DO_LIVE;
|
||||||
break;
|
break;
|
||||||
/* die of overcrowding */
|
/* die of overcrowding */
|
||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
case 7:
|
case 7:
|
||||||
case 8:
|
case 8:
|
||||||
action = DO_DIE_CROWD;
|
action = DO_DIE_CROWD;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
panic("bad neighbor count");
|
panic("bad neighbor count");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(action){
|
switch(action) {
|
||||||
case DO_DIE_NOTHING:
|
case DO_DIE_NOTHING:
|
||||||
break;
|
break;
|
||||||
case DO_DIE_LONELY:
|
case DO_DIE_LONELY:
|
||||||
case DO_DIE_CROWD:
|
case DO_DIE_CROWD:
|
||||||
if(MON_AT(x,y)){
|
if (MON_AT(x,y)) {
|
||||||
struct monst *mp = m_at(x,y);
|
struct monst *mp = m_at(x,y);
|
||||||
if(mp->data == &mons[PM_MILDEW]){
|
if (mp->data == &mons[PM_MILDEW]) {
|
||||||
/* mildew: just play life */
|
/* mildew: just play life */
|
||||||
monkilled(mp, NULL, AD_ANY);
|
monkilled(mp, NULL, AD_ANY);
|
||||||
} else {
|
} else {
|
||||||
/* others get drained first */
|
/* others get drained first */
|
||||||
struct monst *dummy_m;
|
struct monst *dummy_m;
|
||||||
struct attack dummy_a = { AT_ANY, AD_DRLI, 0, 0 };
|
struct attack dummy_a = { AT_ANY, AD_DRLI, 0, 0 };
|
||||||
if(action == DO_DIE_CROWD){
|
if (action == DO_DIE_CROWD) {
|
||||||
dummy_m = conway_random_neighbor(x,y);
|
dummy_m = conway_random_neighbor(x,y);
|
||||||
} else {
|
} else {
|
||||||
dummy_m = newmonst();
|
dummy_m = newmonst();
|
||||||
(void) memset( (genericptr_t)dummy_m, 0, sizeof(*dummy_m));
|
(void) memset((genericptr_t) dummy_m, 0,
|
||||||
dummy_m->data = &mons[PM_MILDEW];
|
sizeof(*dummy_m));
|
||||||
}
|
dummy_m->data = &mons[PM_MILDEW];
|
||||||
(void)mdamagem(dummy_m, mp, &dummy_a);
|
}
|
||||||
if(action != DO_DIE_CROWD){
|
(void)mdamagem(dummy_m, mp, &dummy_a);
|
||||||
free(dummy_m);
|
if (action != DO_DIE_CROWD) {
|
||||||
}
|
free(dummy_m);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if(HERO_AT(x,y)){
|
} else {
|
||||||
/* hero takes damage - modified drain level
|
if (HERO_AT(x,y)) {
|
||||||
* from mhitu.c:hitmu(): */
|
/* hero takes damage - modified drain level
|
||||||
if (rn2(100) < 10 && !Drain_resistance) {
|
* from mhitu.c:hitmu(): */
|
||||||
if(action == DO_DIE_CROWD){
|
if (rn2(100) < 10 && !Drain_resistance) {
|
||||||
/* XXX these messages could be expanded */
|
if (action == DO_DIE_CROWD) {
|
||||||
if(Hallucination){
|
/* XXX these messages could be expanded */
|
||||||
if(Role_if(PM_SAMURAI))
|
if (Hallucination) {
|
||||||
pline("This is just like the Tokyo subway.");
|
if (Role_if(PM_SAMURAI))
|
||||||
else
|
pline("This is just like the Tokyo subway.");
|
||||||
pline("You are too near the madding crowd.");
|
else
|
||||||
} else {
|
pline("You are too near the madding crowd.");
|
||||||
pline("You feel crowded here.");
|
} else {
|
||||||
}
|
pline("You feel crowded here.");
|
||||||
} else {
|
}
|
||||||
if(Hallucination){
|
} else {
|
||||||
pline("I feel so lonely, I could die."); /* Elvis */
|
if (Hallucination) {
|
||||||
} else {
|
pline("I feel so lonely, I could die."); /* Elvis */
|
||||||
pline("It seems lonely here.");
|
} else {
|
||||||
}
|
pline("It seems lonely here.");
|
||||||
}
|
}
|
||||||
losexp("Life drainage");
|
}
|
||||||
}
|
losexp("Life drainage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case DO_LIVE:
|
break;
|
||||||
/* continue(2/3) or create(3) */
|
case DO_LIVE:
|
||||||
mhere = m_at(x,y);
|
/* continue(2/3) or create(3) */
|
||||||
if(mhere){
|
mhere = m_at(x,y);
|
||||||
/*
|
if(mhere) {
|
||||||
Check the level of the surrounding monsters that are life vs the level
|
/*
|
||||||
of the monster at this point (which may be the hero). If the current
|
Check the level of the surrounding monsters that are life vs
|
||||||
monster is lower level, get absorbed by the borg else (maybe) gain level.
|
the level of the monster at this point (which may be the
|
||||||
*/
|
hero). If the current monster is lower level, get absorbed
|
||||||
if(mhere->data != &mons[PM_MILDEW]){
|
by the borg else (maybe) gain level.
|
||||||
/* The only justification for this intrinsic
|
*/
|
||||||
* polymorph resistance is to avoid
|
if (mhere->data != &mons[PM_MILDEW]) {
|
||||||
* insta-death for pets. */
|
/* The only justification for this intrinsic
|
||||||
if(*lslev[x][y] > mhere->m_lev && rn2(100) < 20){
|
* polymorph resistance is to avoid
|
||||||
newcham(mhere, &mons[PM_MILDEW], FALSE, TRUE);
|
* insta-death for pets. */
|
||||||
}
|
if (*lslev[x][y] > mhere->m_lev && rn2(100) < 20) {
|
||||||
} else {
|
newcham(mhere, &mons[PM_MILDEW], FALSE, TRUE);
|
||||||
/* Use rn2() instead of keeping track of
|
}
|
||||||
* the age of each mildew. */
|
} else {
|
||||||
if(rn2(100) < 40) grow_up(mhere, NULL);
|
/* Use rn2() instead of keeping track of
|
||||||
}
|
* the age of each mildew. */
|
||||||
} else {
|
if (rn2(100) < 40)
|
||||||
if(HERO_AT(x,y) && !Upolyd && (u.umonnum != PM_MILDEW)){
|
grow_up(mhere, NULL);
|
||||||
if(*lslev[x][y] > u.ulevel){
|
}
|
||||||
if( (Unchanging && rn2(3)) || (rn2(100) < 50)
|
} else {
|
||||||
){
|
if (HERO_AT(x,y) && !Upolyd && (u.umonnum != PM_MILDEW)) {
|
||||||
pline("You resist the urge to regress.");
|
if (*lslev[x][y] > u.ulevel) {
|
||||||
} else {
|
if ((Unchanging && rn2(3)) || (rn2(100) < 50)) {
|
||||||
polymon(PM_MILDEW);
|
pline("You resist the urge to regress.");
|
||||||
/* polymorph will always time out so hero
|
} else {
|
||||||
* isn't stuck if sitting in a stable life
|
polymon(PM_MILDEW);
|
||||||
* configuration */
|
/* polymorph will always time out so hero
|
||||||
}
|
* isn't stuck if sitting in a stable life
|
||||||
}
|
* configuration */
|
||||||
} else {
|
}
|
||||||
/* Nothing is here - birth. */
|
}
|
||||||
if(*ls[x][y] == 3)
|
} else {
|
||||||
(void) makemon(&mons[PM_MILDEW], x, y, MM_NOCOUNTBIRTH);
|
/* Nothing is here - birth. */
|
||||||
}
|
if (*ls[x][y] == 3)
|
||||||
}
|
(void) makemon(&mons[PM_MILDEW], x, y, MM_NOCOUNTBIRTH);
|
||||||
break;
|
}
|
||||||
default:
|
}
|
||||||
impossible("conway action");
|
break;
|
||||||
}
|
default:
|
||||||
}
|
impossible("conway action");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef LDEBUG
|
#ifdef LDEBUG
|
||||||
pline("[%d %d %d %d %d %d %d %d %d %d] ",
|
pline("[%d %d %d %d %d %d %d %d %d %d] ",
|
||||||
|
|||||||
Reference in New Issue
Block a user