Break out of infinite loops!
This commit is contained in:
@@ -124,7 +124,7 @@ wanderer(struct rogue_state *rs)
|
||||
tp = new_item();
|
||||
do
|
||||
{
|
||||
find_floor((struct room *) NULL, &cp, FALSE, TRUE);
|
||||
find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE);
|
||||
} while (roomin(rs,&cp) == proom);
|
||||
new_monster(rs,tp, randmonster(TRUE), &cp);
|
||||
if (on(player, SEEMONST))
|
||||
|
||||
@@ -74,7 +74,7 @@ new_level(struct rogue_state *rs)
|
||||
*/
|
||||
do
|
||||
{
|
||||
find_floor((struct room *) NULL, &stairs, FALSE, FALSE);
|
||||
find_floor(rs,(struct room *) NULL, &stairs, FALSE, FALSE);
|
||||
} while (chat(stairs.y, stairs.x) != FLOOR);
|
||||
sp = &flat(stairs.y, stairs.x);
|
||||
*sp &= ~F_REAL;
|
||||
@@ -84,14 +84,14 @@ new_level(struct rogue_state *rs)
|
||||
/*
|
||||
* Place the staircase down.
|
||||
*/
|
||||
find_floor((struct room *) NULL, &stairs, FALSE, FALSE);
|
||||
find_floor(rs,(struct room *) NULL, &stairs, FALSE, FALSE);
|
||||
chat(stairs.y, stairs.x) = STAIRS;
|
||||
seenstairs = FALSE;
|
||||
|
||||
for (tp = mlist; tp != NULL; tp = next(tp))
|
||||
tp->t_room = roomin(rs,&tp->t_pos);
|
||||
|
||||
find_floor((struct room *) NULL, &hero, FALSE, TRUE);
|
||||
find_floor(rs,(struct room *) NULL, &hero, FALSE, TRUE);
|
||||
enter_room(rs,&hero);
|
||||
mvaddch(hero.y, hero.x, PLAYER);
|
||||
if (on(player, SEEMONST))
|
||||
@@ -153,7 +153,7 @@ put_things(struct rogue_state *rs)
|
||||
/*
|
||||
* Put it somewhere
|
||||
*/
|
||||
find_floor((struct room *) NULL, &obj->o_pos, FALSE, FALSE);
|
||||
find_floor(rs,(struct room *) NULL, &obj->o_pos, FALSE, FALSE);
|
||||
chat(obj->o_pos.y, obj->o_pos.x) = (char) obj->o_type;
|
||||
}
|
||||
/*
|
||||
@@ -173,7 +173,7 @@ put_things(struct rogue_state *rs)
|
||||
/*
|
||||
* Put it somewhere
|
||||
*/
|
||||
find_floor((struct room *) NULL, &obj->o_pos, FALSE, FALSE);
|
||||
find_floor(rs,(struct room *) NULL, &obj->o_pos, FALSE, FALSE);
|
||||
chat(obj->o_pos.y, obj->o_pos.x) = AMULET;
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ treas_room(struct rogue_state *rs)
|
||||
num_monst = nm = rnd(spots) + MINTREAS;
|
||||
while (nm--)
|
||||
{
|
||||
find_floor(rp, &mp, 2 * MAXTRIES, FALSE);
|
||||
find_floor(rs,rp, &mp, 2 * MAXTRIES, FALSE);
|
||||
//fprintf(stderr,"treas_room\n");
|
||||
tp = new_thing(rs);
|
||||
tp->o_pos = mp;
|
||||
@@ -222,7 +222,7 @@ treas_room(struct rogue_state *rs)
|
||||
while (nm--)
|
||||
{
|
||||
spots = 0;
|
||||
if (find_floor(rp, &mp, MAXTRIES, TRUE))
|
||||
if (find_floor(rs,rp, &mp, MAXTRIES, TRUE))
|
||||
{
|
||||
tp = new_item();
|
||||
new_monster(rs,tp, randmonster(FALSE), &mp);
|
||||
|
||||
@@ -422,6 +422,8 @@ get_item(struct rogue_state *rs,char *purpose, int type)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if ( rs->replaydone != 0 )
|
||||
return(NULL);
|
||||
if (!terse)
|
||||
addmsg(rs,"which object do you want to ");
|
||||
addmsg(rs,purpose);
|
||||
|
||||
@@ -130,24 +130,26 @@ int
|
||||
gethand(struct rogue_state *rs)
|
||||
{
|
||||
int c;
|
||||
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (terse)
|
||||
msg(rs,"left or right ring? ");
|
||||
else
|
||||
msg(rs,"left hand or right hand? ");
|
||||
if ((c = readchar(rs)) == ESCAPE)
|
||||
return -1;
|
||||
mpos = 0;
|
||||
if (c == 'l' || c == 'L')
|
||||
return LEFT;
|
||||
else if (c == 'r' || c == 'R')
|
||||
return RIGHT;
|
||||
if (terse)
|
||||
msg(rs,"L or R");
|
||||
else
|
||||
msg(rs,"please type L or R");
|
||||
if ( rs->replaydone != 0 )
|
||||
return(-1);
|
||||
if (terse)
|
||||
msg(rs,"left or right ring? ");
|
||||
else
|
||||
msg(rs,"left hand or right hand? ");
|
||||
if ((c = readchar(rs)) == ESCAPE)
|
||||
return -1;
|
||||
mpos = 0;
|
||||
if (c == 'l' || c == 'L')
|
||||
return LEFT;
|
||||
else if (c == 'r' || c == 'R')
|
||||
return RIGHT;
|
||||
if (terse)
|
||||
msg(rs,"L or R");
|
||||
else
|
||||
msg(rs,"please type L or R");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -612,7 +612,7 @@ void current(struct rogue_state *rs,THING *cur, char *how, char *where);
|
||||
void d_level(struct rogue_state *rs);
|
||||
void death(struct rogue_state *rs,char monst);
|
||||
char death_monst(void);
|
||||
void dig(int y, int x);
|
||||
void dig(struct rogue_state *rs,int y, int x);
|
||||
void discard(THING *item);
|
||||
void discovered(struct rogue_state *rs);
|
||||
int dist(int y1, int x1, int y2, int x2);
|
||||
@@ -620,7 +620,7 @@ int dist_cp(coord *c1, coord *c2);
|
||||
int do_chase(struct rogue_state *rs,THING *th);
|
||||
void do_daemons(struct rogue_state *rs,int flag);
|
||||
void do_fuses(struct rogue_state *rs,int flag);
|
||||
void do_maze(struct room *rp);
|
||||
void do_maze(struct rogue_state *rs,struct room *rp);
|
||||
void do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta);
|
||||
void do_move(struct rogue_state *rs,int dy, int dx);
|
||||
void do_passages(struct rogue_state *rs);
|
||||
@@ -632,7 +632,7 @@ void doadd(struct rogue_state *rs,char *fmt, va_list args);
|
||||
void door(struct room *rm, coord *cp);
|
||||
void door_open(struct rogue_state *rs,struct room *rp);
|
||||
void drain(struct rogue_state *rs);
|
||||
void draw_room(struct room *rp);
|
||||
void draw_room(struct rogue_state *rs,struct room *rp);
|
||||
void drop(struct rogue_state *rs);
|
||||
void eat(struct rogue_state *rs);
|
||||
size_t encread(char *start, size_t size, FILE *inf);
|
||||
@@ -761,7 +761,7 @@ bool chase(THING *tp, coord *ee);
|
||||
bool diag_ok(coord *sp, coord *ep);
|
||||
bool dropcheck(struct rogue_state *rs,THING *obj);
|
||||
bool fallpos(coord *pos, coord *newpos);
|
||||
bool find_floor(struct room *rp, coord *cp, int limit, bool monst);
|
||||
bool find_floor(struct rogue_state *rs,struct room *rp, coord *cp, int limit, bool monst);
|
||||
bool is_magic(THING *obj);
|
||||
bool is_symlink(char *sp);
|
||||
bool levit_check(struct rogue_state *rs);
|
||||
|
||||
@@ -112,7 +112,7 @@ do_rooms(struct rogue_state *rs)
|
||||
rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x);
|
||||
rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y);
|
||||
} until (rp->r_pos.y != 0);
|
||||
draw_room(rp);
|
||||
draw_room(rs,rp);
|
||||
/*
|
||||
* Put the gold in
|
||||
*/
|
||||
@@ -122,7 +122,7 @@ do_rooms(struct rogue_state *rs)
|
||||
|
||||
gold = new_item();
|
||||
gold->o_goldval = rp->r_goldval = GOLDCALC;
|
||||
find_floor(rp, &rp->r_gold, FALSE, FALSE);
|
||||
find_floor(rs,rp, &rp->r_gold, FALSE, FALSE);
|
||||
gold->o_pos = rp->r_gold;
|
||||
chat(rp->r_gold.y, rp->r_gold.x) = GOLD;
|
||||
gold->o_flags = ISMANY;
|
||||
@@ -136,7 +136,7 @@ do_rooms(struct rogue_state *rs)
|
||||
if (rnd(100) < (rp->r_goldval > 0 ? 80 : 25))
|
||||
{
|
||||
tp = new_item();
|
||||
find_floor(rp, &mp, FALSE, TRUE);
|
||||
find_floor(rs,rp, &mp, FALSE, TRUE);
|
||||
new_monster(rs,tp, randmonster(FALSE), &mp);
|
||||
give_pack(rs,tp);
|
||||
}
|
||||
@@ -150,12 +150,12 @@ do_rooms(struct rogue_state *rs)
|
||||
*/
|
||||
|
||||
void
|
||||
draw_room(struct room *rp)
|
||||
draw_room(struct rogue_state *rs,struct room *rp)
|
||||
{
|
||||
int y, x;
|
||||
|
||||
if (rp->r_flags & ISMAZE)
|
||||
do_maze(rp);
|
||||
do_maze(rs,rp);
|
||||
else
|
||||
{
|
||||
vert(rp, rp->r_pos.x); /* Draw left side */
|
||||
@@ -211,7 +211,7 @@ static SPOT maze[NUMLINES/3+1][NUMCOLS/3+1];
|
||||
|
||||
|
||||
void
|
||||
do_maze(struct room *rp)
|
||||
do_maze(struct rogue_state *rs,struct room *rp)
|
||||
{
|
||||
SPOT *sp;
|
||||
int starty, startx;
|
||||
@@ -232,7 +232,7 @@ do_maze(struct room *rp)
|
||||
pos.y = starty + Starty;
|
||||
pos.x = startx + Startx;
|
||||
putpass(&pos);
|
||||
dig(starty, startx);
|
||||
dig(rs,starty, startx);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -241,7 +241,7 @@ do_maze(struct room *rp)
|
||||
*/
|
||||
|
||||
void
|
||||
dig(int y, int x)
|
||||
dig(struct rogue_state *rs,int y, int x)
|
||||
{
|
||||
coord *cp;
|
||||
int cnt, newy, newx, nexty = 0, nextx = 0;
|
||||
@@ -252,6 +252,8 @@ dig(int y, int x)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if ( rs->replaydone != 0 )
|
||||
return;
|
||||
cnt = 0;
|
||||
for (cp = del; cp <= &del[3]; cp++)
|
||||
{
|
||||
@@ -291,7 +293,7 @@ dig(int y, int x)
|
||||
pos.y = nexty + Starty;
|
||||
pos.x = nextx + Startx;
|
||||
putpass(&pos);
|
||||
dig(nexty, nextx);
|
||||
dig(rs,nexty, nextx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +334,7 @@ rnd_pos(struct room *rp, coord *cp)
|
||||
* pick a new room each time around the loop.
|
||||
*/
|
||||
bool
|
||||
find_floor(struct room *rp, coord *cp, int limit, bool monst)
|
||||
find_floor(struct rogue_state *rs,struct room *rp, coord *cp, int limit, bool monst)
|
||||
{
|
||||
PLACE *pp;
|
||||
int cnt;
|
||||
@@ -346,6 +348,8 @@ find_floor(struct room *rp, coord *cp, int limit, bool monst)
|
||||
cnt = limit;
|
||||
for (;;)
|
||||
{
|
||||
if ( rs->replaydone != 0 )
|
||||
return(FALSE);
|
||||
if (limit && cnt-- == 0)
|
||||
return FALSE;
|
||||
if (pickroom)
|
||||
|
||||
@@ -158,7 +158,7 @@ do_zap(struct rogue_state *rs)
|
||||
{
|
||||
do
|
||||
{
|
||||
find_floor(NULL, &new_pos, FALSE, TRUE);
|
||||
find_floor(rs,NULL, &new_pos, FALSE, TRUE);
|
||||
} while (ce(new_pos, hero));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -81,6 +81,8 @@ do_motion(struct rogue_state *rs,THING *obj, int ydelta, int xdelta)
|
||||
obj->o_pos = hero;
|
||||
for (;;)
|
||||
{
|
||||
if ( rs->replaydone != 0 )
|
||||
return;
|
||||
/*
|
||||
* Erase the old one
|
||||
*/
|
||||
|
||||
@@ -35,19 +35,21 @@ whatis(struct rogue_state *rs,bool insist, int type)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
obj = get_item(rs,"identify", type);
|
||||
if (insist)
|
||||
{
|
||||
if (n_objs == 0)
|
||||
return;
|
||||
else if (obj == NULL)
|
||||
msg(rs,"you must identify something");
|
||||
else if (type && obj->o_type != type &&
|
||||
!(type == R_OR_S && (obj->o_type == RING || obj->o_type == STICK)) )
|
||||
msg(rs,"you must identify a %s", type_name(type));
|
||||
else
|
||||
break;
|
||||
}
|
||||
if ( rs->replaydone != 0 )
|
||||
return;
|
||||
obj = get_item(rs,"identify", type);
|
||||
if (insist)
|
||||
{
|
||||
if (n_objs == 0)
|
||||
return;
|
||||
else if (obj == NULL)
|
||||
msg(rs,"you must identify something");
|
||||
else if (type && obj->o_type != type &&
|
||||
!(type == R_OR_S && (obj->o_type == RING || obj->o_type == STICK)) )
|
||||
msg(rs,"you must identify a %s", type_name(type));
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
@@ -202,7 +204,7 @@ teleport(struct rogue_state *rs)
|
||||
static coord c;
|
||||
|
||||
mvaddch(hero.y, hero.x, floor_at());
|
||||
find_floor((struct room *) NULL, &c, FALSE, TRUE);
|
||||
find_floor(rs,(struct room *) NULL, &c, FALSE, TRUE);
|
||||
if (roomin(rs,&c) != proom)
|
||||
{
|
||||
leave_room(rs,&hero);
|
||||
|
||||
@@ -588,19 +588,18 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx
|
||||
numplayers = openslots = 0;
|
||||
if ( komodo_nextheight() <= gameht+ROGUE_MAXKEYSTROKESGAP )
|
||||
registration_open = 1;
|
||||
fprintf(stderr,"players alive\n");
|
||||
for (i=0; i<maxplayers; i++)
|
||||
{
|
||||
fprintf(stderr,"players alive %d of %d\n",i,maxplayers);
|
||||
//fprintf(stderr,"players alive %d of %d\n",i,maxplayers);
|
||||
if ( CCgettxout(gametxid,1+i,1,0) < 0 )
|
||||
{
|
||||
numplayers++;
|
||||
fprintf(stderr,"players alive %d spent baton\n",i);
|
||||
//fprintf(stderr,"players alive %d spent baton\n",i);
|
||||
if ( CCgettxout(gametxid,1+maxplayers+i,1,0) == txfee )
|
||||
{
|
||||
txid = gametxid;
|
||||
vout = 1+i;
|
||||
fprintf(stderr,"rogue_playersalive scan forward active.%s spenttxid.%s\n",gametxid.GetHex().c_str(),txid.GetHex().c_str());
|
||||
//fprintf(stderr,"rogue_playersalive scan forward active.%s spenttxid.%s\n",gametxid.GetHex().c_str(),txid.GetHex().c_str());
|
||||
n = 0;
|
||||
while ( CCgettxout(txid,vout,1,0) < 0 )
|
||||
{
|
||||
@@ -615,34 +614,29 @@ int32_t rogue_playersalive(int32_t &openslots,int32_t &numplayers,uint256 gametx
|
||||
}
|
||||
txid = spenttxid;
|
||||
vout = 0;
|
||||
fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini);
|
||||
//fprintf(stderr,"n.%d next txid.%s/v%d\n",n,txid.GetHex().c_str(),spentvini);
|
||||
if ( spentvini != 0 )
|
||||
break;
|
||||
if ( n++ > ROGUE_MAXITERATIONS )
|
||||
break;
|
||||
}
|
||||
fprintf(stderr,"out of while\n");
|
||||
if ( txid != zeroid )
|
||||
{
|
||||
fprintf(stderr,"get height of %s\n",txid.GetHex().c_str());
|
||||
if ( myGetTransaction(txid,tx,hashBlock) != 0 )
|
||||
{
|
||||
fprintf(stderr,"got tx %s\n",txid.GetHex().c_str());
|
||||
if ( (pindex= komodo_blockindex(hashBlock)) != 0 )
|
||||
{
|
||||
fprintf(stderr,"got pindex %s\n",hashBlock.GetHex().c_str());
|
||||
if ( pindex->GetHeight() <= gameht+ROGUE_MAXKEYSTROKESGAP )
|
||||
alive++;
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"got height of %s\n",txid.GetHex().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( registration_open != 0 )
|
||||
openslots++;
|
||||
}
|
||||
fprintf(stderr,"numalive.%d openslots.%d\n",alive,openslots);
|
||||
//fprintf(stderr,"numalive.%d openslots.%d\n",alive,openslots);
|
||||
return(alive);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user