summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2012-02-29 05:54:07 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2012-02-29 05:54:07 (GMT)
commit5330adf95c30d45a4fbea2e8f37e4943439814c7 (patch)
tree8d4e49d1f8624402b10af4aed5d6672914ceda57
parentcd619f94fae1040638af3cc10d480fe0fa9be2c4 (diff)
downloadgrv-5330adf95c30d45a4fbea2e8f37e4943439814c7.zip
grv-5330adf95c30d45a4fbea2e8f37e4943439814c7.tar.gz
grv-5330adf95c30d45a4fbea2e8f37e4943439814c7.tar.bz2
grv-5330adf95c30d45a4fbea2e8f37e4943439814c7.tar.xz
drawlevel: make add_write() generate a shuffled list directly
We can build the same swapping operations as for shuffling a whole list into add_white() and we get a shuffled list directly...
-rw-r--r--drawlevel.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/drawlevel.c b/drawlevel.c
index a1339e8..b9500c0 100644
--- a/drawlevel.c
+++ b/drawlevel.c
@@ -550,16 +550,18 @@ static void level_full(void)
static void add_white(int x, int y)
{
int nw = gp.nwhite++;
-
- gp.whitecherrylist[nw].x = x;
- gp.whitecherrylist[nw].y = y;
+ int xw = irnd(nw+1);
+
+ gp.whitecherrylist[nw] = gp.whitecherrylist[xw];
+ gp.whitecherrylist[xw].x = x;
+ gp.whitecherrylist[xw].y = y;
lprint(x, y, "\xeb");
}
/* Level 75: Finale */
static void level_finale(void)
{
- int i, j, e;
+ int i, e;
gp.nextwhite = gp.nwhite = 0;
color(15, gp.c);
@@ -587,23 +589,12 @@ static void level_finale(void)
}
gp.Bar = gp.nwhite;
- /* Shuffle the white cherry list */
- for ( i = gp.nwhite-1 ; i >= 0 ; i-- ) {
- struct xy tmp;
- j = irnd(i+1);
-
- tmp = gp.whitecherrylist[i];
- gp.whitecherrylist[i] = gp.whitecherrylist[j];
- gp.whitecherrylist[j] = tmp;
- }
-
- for ( e = 1 ; e <= 5 ; e++ ) {
+ for ( e = 1 ; e <= 5 ; e++ )
white2black();
- }
- if ( gp.ZLevel > 0 ) {
+ if ( gp.ZLevel > 0 )
addaction(0, 0, 10, act_droplevel); /* drop 1 reentry level */
- }
+
update_jump();
color(16, gp.c);