From: nethack.rankin Date: Sat, 21 Apr 2007 01:54:56 +0000 (+0000) Subject: random initial drawbridge state (trunk only) X-Git-Tag: MOVE2GIT~625 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e7d032c79ba523ffa967405c22e2496fd22df54;p=nethack random initial drawbridge state (trunk only) Suggested by : in the special level compiler, support "random" in addition to "open" and "closed" for a drawbridge's inital state. Drawbridge shares code with door, so the necessary parsing was already present. This just treats random as valid for drawbridge instead of explicitly rejecting it, and makes the special level loader process it. He also suggested that the two drawbridges on the bottom level of the Valk's quest be changed from open to random, but this patch doesn't go that far. I think it's a good idea, but since the player can't use a musicial instrument on those bridges, this has more impact on game play than it might at first seem. I don't really want to see Valkyries be required to use magic for occasions where both bridges start out closed. --- diff --git a/src/sp_lev.c b/src/sp_lev.c index 2194b384f..2f276d683 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)sp_lev.c 3.5 2006/05/09 */ +/* SCCS Id: @(#)sp_lev.c 3.5 2007/04/20 */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -2405,7 +2405,9 @@ dlb *fd; x = tmpdb.x; y = tmpdb.y; get_location(&x, &y, DRY|WET); - if (!create_drawbridge(x, y, tmpdb.dir, tmpdb.db_open)) + typ = tmpdb.db_open; + if (typ == 127) typ = rn2(2); /* 0 => closed, 1 => open */ + if (!create_drawbridge(x, y, tmpdb.dir, typ)) impossible("Cannot create drawbridge."); } diff --git a/sys/share/lev_yacc.c b/sys/share/lev_yacc.c index cf509bbf3..d4f5ca576 100644 --- a/sys/share/lev_yacc.c +++ b/sys/share/lev_yacc.c @@ -8,7 +8,7 @@ static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #define yyerrok (yyerrflag=0) #define YYRECOVERING (yyerrflag!=0) #define YYPREFIX "yy" -/* SCCS Id: @(#)lev_yacc.c 3.5 2000/01/17 */ +/* SCCS Id: @(#)lev_yacc.c 3.5 2007/04/20 */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -1812,8 +1812,10 @@ case 151: tmpdb[ndb]->db_open = 1; else if ( yyvsp[0].i == D_CLOSED ) tmpdb[ndb]->db_open = 0; + else if (yyvsp[0].i == -1) /* RANDOM_TYPE */ + tmpdb[ndb]->db_open = 127; /* random */ else - yyerror("A drawbridge can only be open or closed!"); + yyerror("A drawbridge can only be open, closed, or random!"); ndb++; if (ndb >= MAX_OF_TYPE) { yyerror("Too many drawbridges in mazepart!"); diff --git a/util/lev_comp.y b/util/lev_comp.y index abc6233f3..2c47ecef8 100644 --- a/util/lev_comp.y +++ b/util/lev_comp.y @@ -1,5 +1,5 @@ %{ -/* SCCS Id: @(#)lev_yacc.c 3.5 2000/01/17 */ +/* SCCS Id: @(#)lev_yacc.c 3.5 2007/04/20 */ /* Copyright (c) 1989 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -1062,8 +1062,10 @@ drawbridge_detail: DRAWBRIDGE_ID ':' coordinate ',' DIRECTION ',' door_state tmpdb[ndb]->db_open = 1; else if ( $7 == D_CLOSED ) tmpdb[ndb]->db_open = 0; + else if ($7 == -1) /* RANDOM_TYPE */ + tmpdb[ndb]->db_open = 127; /* random */ else - yyerror("A drawbridge can only be open or closed!"); + yyerror("A drawbridge can only be open, closed, or random!"); ndb++; if (ndb >= MAX_OF_TYPE) { yyerror("Too many drawbridges in mazepart!");