From 710a8fb0e28e5c5d5e351da3e2b7d9bca341826d Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 15 Jun 2015 15:47:47 -0700 Subject: [PATCH 1/7] rising from the dead during panic Prevent rising from the dead as a giant ant if the game panics during initialization. --- src/end.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/end.c b/src/end.c index d5b8e4ed6..b422670c4 100644 --- a/src/end.c +++ b/src/end.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 end.c $NHDT-Date: 1434071495 2015/06/12 01:11:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.99 $ */ +/* NetHack 3.6 end.c $NHDT-Date: 1434408399 2015/06/15 22:46:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.100 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -979,8 +979,10 @@ die: force_launch_placement(); /* maintain ugrave_arise even for !bones_ok */ - if (how == BURNING || how == DISSOLVED) /* corpse gets burnt up too */ - u.ugrave_arise = (NON_PM - 2); /* leave no corpse */ + if (how == PANICKED) + u.ugrave_arise = (NON_PM - 3); /* no corpse, no grave */ + else if (how == BURNING || how == DISSOLVED) /* corpse burns up too */ + u.ugrave_arise = (NON_PM - 2); /* leave no corpse */ else if (how == STONING) u.ugrave_arise = (NON_PM - 1); /* statue instead of corpse */ else if (how == TURNED_SLIME) @@ -1097,16 +1099,12 @@ die: if (have_windows) { wait_synch(); display_nhwindow(WIN_MESSAGE, TRUE); - destroy_nhwindow(WIN_MAP); + destroy_nhwindow(WIN_MAP), WIN_MAP = WIN_ERR; #ifndef STATUS_VIA_WINDOWPORT - destroy_nhwindow(WIN_STATUS); -#endif - destroy_nhwindow(WIN_MESSAGE); -#ifdef STATUS_VIA_WINDOWPORT - WIN_MESSAGE = WIN_MAP = WIN_ERR; -#else - WIN_MESSAGE = WIN_STATUS = WIN_MAP = WIN_ERR; + destroy_nhwindow(WIN_STATUS), WIN_STATUS = WIN_ERR; #endif + destroy_nhwindow(WIN_MESSAGE), WIN_MESSAGE = WIN_ERR; + if (!done_stopprint || flags.tombstone) endwin = create_nhwindow(NHW_TEXT); @@ -1115,9 +1113,9 @@ die: } else done_stopprint = 1; /* just avoid any more output */ - if (u.uhave.amulet) + if (u.uhave.amulet) { Strcat(killer.name, " (with the Amulet)"); - else if (how == ESCAPED) { + } else if (how == ESCAPED) { if (Is_astralevel(&u.uz)) /* offered Amulet to wrong deity */ Strcat(killer.name, " (in celestial disgrace)"); else if (carrying(FAKE_AMULET_OF_YENDOR)) From 8848c8d7aece8deeba47789c32f48ff67801107d Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 15 Jun 2015 18:16:03 -0700 Subject: [PATCH 2/7] tribute: Lords and Ladies It's a lot of passages, even when leaving out ones about Cresote and King Midas (or whatever name his Discworld analog has), Nanny Ogg's cat, Ridcully's custom made wizard hat, and the mention of a law which requires that bystanders be warned before commencing to play folk music. --- dat/tribute | 214 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 213 insertions(+), 1 deletion(-) diff --git a/dat/tribute b/dat/tribute index 57ada0605..fdda4ab19 100644 --- a/dat/tribute +++ b/dat/tribute @@ -358,7 +358,8 @@ too, o'course. # # # -%title Lords and Ladies (1) +%title Lords and Ladies (12) +# p. 122 (Harper Torch edition) %passage 1 Elves are wonderful. They provoke wonder. Elves are marvellous. They cause marvels. @@ -366,15 +367,226 @@ Elves are fantastic. They create fantasies. Elves are glamorous. They project glamour. Elves are enchanting. They weave enchantment. Elves are terrific. They beget terror. + The thing about words is that meanings can twist just like a snake, and if you want to find snakes look for them behind words that have changed their meaning. No one ever said elves are nice. + Elves are bad. [Lords and Ladies, by Terry Pratchett] %e passage +# p. 32 +%passage 2 +"Hope she does all right as queen," said Nanny. + +"We taught her everything she knows," said Granny Weatherwax. + +"Yeah," said Nanny Ogg, as they disappeared into the bracken. "D'you +think... maybe... ?" + +"What?" + +"D'you think maybe we ought to have taught her everything /we/ know?" + + [Lords and Ladies, by Terry Pratchett] +%e passage +# p. 36 +%passage 3 +It was very hard, being a reader in Invisible Writings.(1) + +(1) The study of invisible writings was a new discipline made available by +the discovery of the bi-directional nature of Library-Space. The thaumic +mathematics are complex, but boil down to the fact that all books, +everywhere, affect all other books. This is obvious: books inspire +other books written in the future, and cite books written in the past. +But the General Theory(2) of L-Space suggests that, in that case, the +contents of books /as yet unwritten/ can be deduced from books now in +existence. + +(2) There's a Special Theory as well, but no one bothers with it much +because it's self-evidently a load of marsh gas. + + [Lords and Ladies, by Terry Pratchett] +%e passage +# p. 51 +%passage 4 +"Don't hold with schools," said Granny Weatherwax. "They get in the way +of education. All them books. Books? What good are they? There's too +much reading these days. We never had time to read when we was young, I +know that." + + [Lords and Ladies, by Terry Pratchett] +%e passage +# pp. 79-80 +%passage 5 +The highwayman stepped over the groaning body of the driver and marched +toward the door of the coach, dragging his stepladder behind him. + +He opened the door. + +"Your money or, I'm sorry to say, your--" + +A blast of octarine fire blew his hat off. + +The dwarf's expression did not change. + +"I wonder if I might be allowed to rephrase my demands?" + +Ridcully looked the elegantly dressed stranger up and down, or rather +down and further down. + +"You don't look like a dwarf," he said, "apart from the height, that is." + +"Don't look like a dwarf apart from the height?" + +I mean, the helmet and iron boots department is among those you are lacking +in," said Ridcully. + + [Lords and Ladies, by Terry Pratchett] +%e passage +# p. 95 +%passage 6 +What is magic? + +There is the wizards' explanation, which comes in two forms, depending on +the age of the wizard. Older wizards talk about candles, circles, planets, +stars, bananas, chants, runes, and the importance of having at least four +good meals every day. Younger wizards, particularly the pale ones who +spend most of their time in the High Energy Magic building,(1) chatter at +length about fluxes in the morphic nature of the universe, the essentially +impermanent quality of even the most apparently rigid time-space framework, +the impossibility of reality, and so on: what this means is that they have +got hold of something hot and are gabbling the physics as they go along. + +(1) It was here that the thaum, hitherto believed to be the smallest +possible particle of magic, was successfully demonstrated to made up of +/resons/(2) or reality fragments. Currently research indicates that each +reson is itself made up of a combination of at least five "flavors," +known as "up," "down," "sideways," "sex appeal," and "peppermint." + +(2) Lit: "Thing-ies." + + [Lords and Ladies, by Terry Pratchett] +%e passage +# p. 107 +%passage 7 +What is magic? + +Then there is the witches' explanation, which comes in two forms, depending +on the age of the witch. Older witches hardly put words to it at all, but +may suspect in their hearts that the universe really doesn't know what the +hell is going on and consists of a zillion trillion billion possibilities, +and could become any of them if a trained mind rigid with quantum certainty +was inserted in the crack and /twisted/; that, if you really had to make +someone's hat explode, all you needed to do was /twist/ into the universe +where a large number of hat molecules all decide at the same time to bounce +off in different directions. + +Younger witches, on the other hand, talk about it all the time and believe +it involves crystals, mystic forces, and dancing about without yer drawers +on. + +Everyone may to right, all at the same time. That's the thing about +quantum. + + [Lords and Ladies, by Terry Pratchett] +%e passage +# p. 114; 'colorful' & 'humor' are spelled the American way, 'or' not 'our' +%passage 8 +He knocked on the coach door. The window slid down. + +"I wouldn't like you to think of this as a robbery," he said. "I'd like +you to think of it more as a colorful anecdote you might enjoy telling your +grandchildren about." + +A voice from within said, "That's him! He stole my horse!" + +A wizard's staff poked out. The chieftain saw the knob on the end. + +"Now then," he said pleasantly. "I know the rules. Wizards aren't allowed +to use magic against civilians except in genuine life-threatening situa--" + +There was a burst of octarine light. + +"Actually, it's not a rule," said Ridcully. "It's more a guideline." He +turned to Ponder Stibbons. "Interestin' use of Stacklady's Morphic +Resonator here, I hoped you noticed." + +Ponder lookd down. + +The chieftain had been turned into a pumpkin, although, in accordance with +the rules of universal humor, he still had his hat on. + + [Lords and Ladies, by Terry Pratchett] +%e passage +# p. 149 (second half of a paragraph) +%passage 9 +Things had to balance. You couldn't set out to be a good witch or a bad +witch. It never worked for long. All you could try to be was a /witch/, +as hard as you could. + + [Lords and Ladies, by Terry Pratchett] +%e passage +# p. 162 (mid-paragraph) +%passage 10 +"I'm the head wizard now. I've only got to give an order and a thousand +wizards will... uh... disobey, come to think of it, or say 'What?', or +start to argue. But they have to take notice. + +"I've been to that University a few times," said Granny. "A bunch of fat +old men in beards." + +"That's right! That's /them/!" + + [Lords and Ladies, by Terry Pratchett] +%e passage +# p. 190 +%passage 11 +The window was no escape this time. There was the bed to hide under, and +that'd work for all of two seconds, wouldn't it? + +Her eye was drawn by some kind of horrible magic back to the room's +garderobe, lurking behind its curtain. + +Margrat lifted the lid. The shaft was definitely wide enough to admit a +body. Garderobes were notorious in that respect. Several unpopular kings +met their end, as it were, in the garderobe, at the hands of an assassin +with good climbing ability, a spear, and a fundamental approach to politics. + + [Lords and Ladies, by Terry Pratchett] +%e passage +# p. 191 ('a' historian, not 'an'; 'Ynci' is correct) +%passage 12 +Some shape, some trick of moonlight, some expression on a painted face +somehow cut through her terror and caught her eye. + +That was a portrait she'd never seen before. She'd never walked down this +far. The idiot vapidity of the assembled queens had depressed her. But +this one... + +Ths one, somehow, reached out to her. + +She stopped. + +It couldn't have been done from life. In the days of /this/ queen, the +only paint known locally was a sort of blue, and generally used on the body. +But a few generations ago King Lully I had been a bit of a historian and a +romantic. He'd researched what was known of the early days of Lancre, and +where actual evidence had been a bit sparse he had, in the best traditions +of the keen ethnic historian, inferred from revealed self-evident wisdom(1) +and extrapolated from associated sources(2). He'd commissioned the +portrait of Queen Ynci the Short-Tempered, one of the founders of the +kingdom. + +(1) Made it up. + +(2) Had read a lot of stuff that other people had made up, too. + + [Lords and Ladies, by Terry Pratchett] +%e passage %e title # # From 0353207f025295b3124c85cd8c02fbc457a68499 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 15 Jun 2015 22:22:56 -0400 Subject: [PATCH 3/7] a couple more tribute easter eggs Changes to be committed: modified: include/context.h modified: include/extern.h modified: src/files.c modified: src/invent.c modified: src/sounds.c modified: src/spell.c Add a couple more tribute easter eggs. - can lead to a remark by Death if you happen to have a pratchett book on your person, as suggested by M. Stephenson (fat chance you will, or think to #chat if you do, but it could be a tournament novelty or something obscure to strive for). - can draw some additional Death quotes from the tribute file. (There's two in there right now. If anyone wants to add or suggest some more, please go ahead. The Death quotes are at the end of the tribute file. One-liners only please or the code will only pull the last line. --- include/context.h | 5 +++-- include/extern.h | 6 ++++-- src/files.c | 48 +++++++++++++++++++++++++++++++++-------------- src/invent.c | 14 +++++++++++++- src/sounds.c | 26 +++++++++++++++++++++++-- src/spell.c | 4 ++-- 6 files changed, 80 insertions(+), 23 deletions(-) diff --git a/include/context.h b/include/context.h index 493b7a4a0..b73499f97 100644 --- a/include/context.h +++ b/include/context.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 context.h $NHDT-Date: 1432512775 2015/05/25 00:12:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.25 $ */ +/* NetHack 3.6 context.h $NHDT-Date: 1434421363 2015/06/16 02:22:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.26 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -80,8 +80,9 @@ struct tribute_info { size_t tributesz; /* make it possible to skip this in future */ boolean enabled; /* Do we have tributes turned on? */ Bitfield(bookstock, 1); /* Have we stocked the book? */ + Bitfield(Deathnotice,1); /* Did Death notice the book? */ /* Markers for other tributes can go here */ - /* 31 free bits */ + /* 30 free bits */ }; struct context_info { diff --git a/include/extern.h b/include/extern.h index 0a45129e0..a412da87c 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1434330826 2015/06/15 01:13:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.503 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1434421365 2015/06/16 02:22:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.504 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -765,7 +765,8 @@ E void NDECL(really_close); #ifdef DEBUG E boolean FDECL(debugcore, (const char *, BOOLEAN_P)); #endif -E boolean FDECL(read_tribute, (const char *, const char *, int)); +E boolean FDECL(read_tribute, (const char *, const char *, int, char *, int)); +E boolean FDECL(Death_quote, (char *, int)); /* ### fountain.c ### */ @@ -901,6 +902,7 @@ E struct obj *FDECL(sobj_at, (int, int, int)); E struct obj *FDECL(nxtobj, (struct obj *, int, BOOLEAN_P)); E struct obj *FDECL(carrying, (int)); E boolean NDECL(have_lizard); +E struct obj *NDECL(u_have_novel); E struct obj *FDECL(o_on, (unsigned int, struct obj *)); E boolean FDECL(obj_here, (struct obj *, int, int)); E boolean NDECL(wearing_armor); diff --git a/src/files.c b/src/files.c index 58310f81f..3d59f0f33 100644 --- a/src/files.c +++ b/src/files.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 files.c $NHDT-Date: 1434249087 2015/06/14 02:31:27 $ $NHDT-Branch: master $:$NHDT-Revision: 1.179 $ */ +/* NetHack 3.6 files.c $NHDT-Date: 1434421344 2015/06/16 02:22:24 $ $NHDT-Branch: master $:$NHDT-Revision: 1.180 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3392,9 +3392,10 @@ boolean wildcards; #define PASSAGESCOPE 3 boolean -read_tribute(tribsection, tribtitle, tribpassage) +read_tribute(tribsection, tribtitle, tribpassage, nowin_buf, bufsz) const char *tribsection, *tribtitle; -int tribpassage; +int tribpassage, bufsz; +char *nowin_buf; { dlb *fp; char *endp; @@ -3409,7 +3410,8 @@ int tribpassage; /* check for mandatories */ if (!tribsection || !tribtitle) { - pline("It's %s of \"%s\"!", badtranslation, tribtitle); + if (!nowin_buf) + pline("It's %s of \"%s\"!", badtranslation, tribtitle); return grasped; } @@ -3419,7 +3421,8 @@ int tribpassage; fp = dlb_fopen(TRIBUTEFILE, "r"); if (!fp) { /* this is actually an error - cannot open tribute file! */ - pline("You feel too overwhelmed to continue!"); + if (!nowin_buf) + pline("You feel too overwhelmed to continue!"); return grasped; } @@ -3494,12 +3497,14 @@ int tribpassage; passagenum = atoi(st); if (passagenum && (passagenum <= passagecnt)) { scope = PASSAGESCOPE; - if (matchedtitle && (passagenum == targetpassage)) - tribwin = create_nhwindow(NHW_MENU); + if (matchedtitle && (passagenum == targetpassage)) { + if (!nowin_buf) + tribwin = create_nhwindow(NHW_MENU); + } } } else if (!strncmpi(&line[1], "e ", sizeof("e ") - 1)) { if (matchedtitle && (scope == PASSAGESCOPE) - && tribwin != WIN_ERR) + && (!nowin_buf && tribwin != WIN_ERR)) goto cleanup; if (scope == TITLESCOPE) matchedtitle = FALSE; @@ -3516,16 +3521,21 @@ int tribpassage; /* comment only, next! */ break; default: - if (matchedtitle && scope == PASSAGESCOPE && tribwin != WIN_ERR) { - putstr(tribwin, 0, line); - Strcpy(lastline, line); + if (matchedtitle && scope == PASSAGESCOPE) { + if (!nowin_buf && tribwin != WIN_ERR) { + putstr(tribwin, 0, line); + Strcpy(lastline, line); + } else if (nowin_buf) { + if ((int)strlen(line) < bufsz-1) + Strcpy(nowin_buf, line); + } } } } cleanup: (void) dlb_fclose(fp); - if (tribwin != WIN_ERR) { + if (!nowin_buf && tribwin != WIN_ERR) { if (matchedtitle && scope == PASSAGESCOPE) { display_nhwindow(tribwin, FALSE); /* put the final attribution line into message history, @@ -3540,11 +3550,21 @@ cleanup: tribwin = WIN_ERR; grasped = TRUE; } else { - pline("It seems to be %s of \"%s\"!", badtranslation, tribtitle); + if (!nowin_buf) + pline("It seems to be %s of \"%s\"!", badtranslation, tribtitle); + else + grasped = TRUE; } - return grasped; } + +boolean +Death_quote(buf, bufsz) +char *buf; +int bufsz; +{ + return read_tribute("Death", "Death Quotes", 0, buf, bufsz); +} /* ---------- END TRIBUTE ----------- */ /*files.c*/ diff --git a/src/invent.c b/src/invent.c index cb4396d25..7b6cbf0ce 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 invent.c $NHDT-Date: 1432939569 2015/05/29 22:46:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.166 $ */ +/* NetHack 3.6 invent.c $NHDT-Date: 1434421348 2015/06/16 02:22:28 $ $NHDT-Branch: master $:$NHDT-Revision: 1.167 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -815,6 +815,18 @@ have_lizard() return (FALSE); } +/* 3.6.0 tribute */ +struct obj * +u_have_novel() +{ + register struct obj *otmp; + + for (otmp = invent; otmp; otmp = otmp->nobj) + if (otmp->otyp == SPE_NOVEL) + return otmp; + return (struct obj *)0; +} + struct obj * o_on(id, objchn) unsigned int id; diff --git a/src/sounds.c b/src/sounds.c index ff3edf815..f95f4eb74 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 sounds.c $NHDT-Date: 1432510145 2015/05/24 23:29:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */ +/* NetHack 3.6 sounds.c $NHDT-Date: 1434421352 2015/06/16 02:22:32 $ $NHDT-Branch: master $:$NHDT-Revision: 1.64 $ */ /* Copyright (c) 1989 Janet Walz, Mike Threepoint */ /* NetHack may be freely redistributed. See license for details. */ @@ -906,7 +906,29 @@ register struct monst *mtmp; : soldier_foe_msg[rn2(3)]; } break; case MS_RIDER: - if (ptr == &mons[PM_DEATH] && !rn2(10)) + /* 3.6.0 tribute */ + if (ptr == &mons[PM_DEATH] && + !context.tribute.Deathnotice && u_have_novel()) { + struct obj *book = u_have_novel(); + const char *tribtitle = (char *)0; + + if (book) { + int novelidx = book->novelidx; + tribtitle = noveltitle(&novelidx); + } + if (tribtitle) { + Sprintf(verbuf, + "Ah, so you have a copy of '%s'. I may have been misquoted there.", + tribtitle); + verbl_msg = verbuf; + context.tribute.Deathnotice = 1; + } + } else if (ptr == &mons[PM_DEATH] && + !rn2(2) && Death_quote(verbuf, BUFSZ)) { + verbl_msg = verbuf; + } + /* end of tribute addition */ + else if (ptr == &mons[PM_DEATH] && !rn2(10)) pline_msg = "is busy reading a copy of Sandman #8."; else verbl_msg = "Who do you think you are, War?"; diff --git a/src/spell.c b/src/spell.c index 384551cc2..d8c7a1b32 100644 --- a/src/spell.c +++ b/src/spell.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 spell.c $NHDT-Date: 1432512766 2015/05/25 00:12:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */ +/* NetHack 3.6 spell.c $NHDT-Date: 1434421353 2015/06/16 02:22:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.63 $ */ /* Copyright (c) M. Stephenson 1988 */ /* NetHack may be freely redistributed. See license for details. */ @@ -473,7 +473,7 @@ register struct obj *spellbook; if (booktype == SPE_NOVEL) { /* Obtain current Terry Pratchett book title */ const char *tribtitle = noveltitle(&spellbook->novelidx); - if (read_tribute("books", tribtitle, 0)) { + if (read_tribute("books", tribtitle, 0, (char *)0, 0)) { u.uconduct.literate++; check_unpaid(spellbook); if (!u.uevent.read_tribute) { From d196965397196d49c43a7c10a53a4834b3aa1be1 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 15 Jun 2015 22:44:38 -0400 Subject: [PATCH 4/7] logic bit Fix a logic mistake in the nowin_buf scenario of read_tribute. --- src/files.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/files.c b/src/files.c index 3d59f0f33..83527c17d 100644 --- a/src/files.c +++ b/src/files.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 files.c $NHDT-Date: 1434421344 2015/06/16 02:22:24 $ $NHDT-Branch: master $:$NHDT-Revision: 1.180 $ */ +/* NetHack 3.6 files.c $NHDT-Date: 1434422673 2015/06/16 02:44:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.181 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3504,7 +3504,7 @@ char *nowin_buf; } } else if (!strncmpi(&line[1], "e ", sizeof("e ") - 1)) { if (matchedtitle && (scope == PASSAGESCOPE) - && (!nowin_buf && tribwin != WIN_ERR)) + && ((!nowin_buf && tribwin != WIN_ERR) || nowin_buf)) goto cleanup; if (scope == TITLESCOPE) matchedtitle = FALSE; From 666e4976b550bbb1d7926739e2d440c5aef0935e Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 15 Jun 2015 23:28:41 -0400 Subject: [PATCH 5/7] fix another logic error for nowin_buf read_tribute --- dat/tribute | 2 +- src/files.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dat/tribute b/dat/tribute index fdda4ab19..a9b303888 100644 --- a/dat/tribute +++ b/dat/tribute @@ -186,7 +186,7 @@ effort to scratch it behind the two ragged bits on top of its head. It was a relief to find someone else besides another ghost who could see him, and Greebo, he couldn't help feeling, was a distinctly unusual cat. Most of the castle cats were either pampered pets or flat-eared -kitchen and stable habitués who generally resembled the very rodents +kitchen and stable habitues who generally resembled the very rodents they lived on. This cat, on the other hand, was its own animal. All cats give that impression, of course, but instead of the mindless animal self-absorption that passes for secret wisdom in the creatures, diff --git a/src/files.c b/src/files.c index 83527c17d..5a99cf6fa 100644 --- a/src/files.c +++ b/src/files.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 files.c $NHDT-Date: 1434422673 2015/06/16 02:44:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.181 $ */ +/* NetHack 3.6 files.c $NHDT-Date: 1434425313 2015/06/16 03:28:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.182 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3407,6 +3407,7 @@ char *nowin_buf; boolean matchedsection = FALSE, matchedtitle = FALSE; winid tribwin = WIN_ERR; boolean grasped = FALSE; + boolean foundpassage = FALSE; /* check for mandatories */ if (!tribsection || !tribtitle) { @@ -3500,11 +3501,13 @@ char *nowin_buf; if (matchedtitle && (passagenum == targetpassage)) { if (!nowin_buf) tribwin = create_nhwindow(NHW_MENU); + else + foundpassage = TRUE; } } } else if (!strncmpi(&line[1], "e ", sizeof("e ") - 1)) { if (matchedtitle && (scope == PASSAGESCOPE) - && ((!nowin_buf && tribwin != WIN_ERR) || nowin_buf)) + && ((!nowin_buf && tribwin != WIN_ERR) || (nowin_buf && foundpassage))) goto cleanup; if (scope == TITLESCOPE) matchedtitle = FALSE; @@ -3553,7 +3556,8 @@ cleanup: if (!nowin_buf) pline("It seems to be %s of \"%s\"!", badtranslation, tribtitle); else - grasped = TRUE; + if (foundpassage) + grasped = TRUE; } return grasped; } From 1547e676f345030d18d3b2d4d36c10318b24cb7d Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 16 Jun 2015 02:29:22 -0700 Subject: [PATCH 6/7] finish implementing pmatchregex I started out cleaning up a bit of lint in the recent run-time options handling and discovered that pmatchregex wasn't finished. Finish it and also deal with the version lint. Argument declarations for function definitions in pmatchregex.c have been switched to K&R style. (The ones in posixregex.c have been left in ANSI style.) There wasn't any build rule for pmatchregex.o; now there is (for Unix). posixregex.o is still the default. There isn't any build rule for cppregex.o (again, for Unix); the change to cppregex.cpp is untested. --- src/version.c | 8 +++---- sys/share/cppregex.cpp | 6 +++-- sys/share/pmatchregex.c | 52 +++++++++++++++++++++++------------------ sys/share/posixregex.c | 4 ++-- sys/unix/Makefile.src | 21 ++++++++++++----- 5 files changed, 54 insertions(+), 37 deletions(-) diff --git a/src/version.c b/src/version.c index 0d0cc7c6b..84ec78989 100644 --- a/src/version.c +++ b/src/version.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 version.c $NHDT-Date: 1434151385 2015/06/12 23:23:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.32 $ */ +/* NetHack 3.6 version.c $NHDT-Date: 1434446944 2015/06/16 09:29:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.33 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -130,9 +130,9 @@ doextversion() return 0; } -extern char regex_id[]; +extern const char regex_id[]; -static char *rt_opts[] = { +static const char *rt_opts[] = { "pattern matching via", regex_id, }; static const char indent[] = " "; @@ -150,7 +150,7 @@ char *buf; { char rtbuf[BUFSZ]; char *pd; - int l, i = 0, j = 0; + int l, i = 0; if (strlen(buf) >= BUFSZ - 3) return; diff --git a/sys/share/cppregex.cpp b/sys/share/cppregex.cpp index b2f122735..4fdd59b61 100644 --- a/sys/share/cppregex.cpp +++ b/sys/share/cppregex.cpp @@ -10,7 +10,7 @@ extern "C" { #include - char regex_id[] = "cppregex"; + const char regex_id[] = "cppregex"; struct nhregex { std::unique_ptr re; @@ -25,7 +25,9 @@ extern "C" { if (!re) return FALSE; try { - re->re.reset(new std::regex(s, std::regex::extended | std::regex::nosubs | std::regex::optimize)); + re->re.reset(new std::regex(s, (std::regex::extended + | std::regex::nosubs + | std::regex::optimize))); re->err.reset(nullptr); return TRUE; } catch (const std::regex_error& err) { diff --git a/sys/share/pmatchregex.c b/sys/share/pmatchregex.c index 10ee64b23..d41e441c1 100644 --- a/sys/share/pmatchregex.c +++ b/sys/share/pmatchregex.c @@ -1,10 +1,11 @@ -/* NetHack 3.6 posixregex.c $NHDT-Date: 1434151360 2015/06/12 23:22:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.0 $ */ +/* NetHack 3.6 posixregex.c $NHDT-Date: 1434446946 2015/06/16 09:29:06 $ $NHDT-Branch: master $:$NHDT-Revision: 1.1 $ */ /* Copyright (c) Sean Hunt 2015. */ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" /* Implementation of the regex engine using pmatch(). + * [Switched to pmatchi() so as to ignore case.] * * This is a fallback ONLY and should be avoided where possible, as it results * in regexes not behaving as POSIX extended regular expressions. As a result, @@ -12,56 +13,61 @@ * portable to ones built with an alternate regex engine. */ -/* - * NOTE: This file is untested. - */ - -char regex_id[] = "pmatchregex"; +const char regex_id[] = "pmatchregex"; struct nhregex { - const char *pat; + const char *pat; }; struct nhregex * regex_init() { - return (struct nhregex *) alloc(sizeof(struct nhregex)); + struct nhregex *re; + + re = (struct nhregex *) alloc(sizeof (struct nhregex)); + re->pat = (const char *) 0; + return re; } boolean -regex_compile(const char *s, struct nhregex *re) +regex_compile(s, re) +const char *s; +struct nhregex *re; { if (!re) return FALSE; - if (re->pat); - free(re->path); + if (re->pat) + free((genericptr_t) re->pat); - re->pat = alloc(strlen(s) + 1); - strcpy(re->pat, s); + re->pat = dupstr(s); return TRUE; } const char * -regex_error_desc(struct nhregex *re) +regex_error_desc(re) +struct nhregex *re UNUSED; { return "pattern match compilation error"; } boolean -regex_match(const char *s, struct nhregex *re) +regex_match(s, re) +const char *s; +struct nhregex *re; { if (!re || !re->pat || !s) return FALSE; - return pmatch(re->pat, s); + + return pmatchi(re->pat, s); } void -regex_free(struct nhregex *re) +regex_free(re) +struct nhregex *re; { - if (!re) - return FALSE; - - if (re->pat) - free(re->pat); - free(re); + if (re) { + if (re->pat) + free((genericptr_t) re->pat); + free((genericptr_t) re); + } } diff --git a/sys/share/posixregex.c b/sys/share/posixregex.c index 60293c76f..64ff142c8 100644 --- a/sys/share/posixregex.c +++ b/sys/share/posixregex.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 posixregex.c $NHDT-Date: 1434151361 2015/06/12 23:22:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.4 $ */ +/* NetHack 3.6 posixregex.c $NHDT-Date: 1434446947 2015/06/16 09:29:07 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */ /* Copyright (c) Sean Hunt 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -44,7 +44,7 @@ * Deallocate a regex object. */ -char regex_id[] = "posixregex"; +const char regex_id[] = "posixregex"; struct nhregex { regex_t re; diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index e3979dc56..3a9365ba4 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -1,5 +1,5 @@ # NetHack Makefile. -# NetHack 3.6 Makefile.src $NHDT-Date: 1432512789 2015/05/25 00:13:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.43 $ +# NetHack 3.6 Makefile.src $NHDT-Date: 1434446945 2015/06/16 09:29:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.44 $ # Root of source tree: NHSROOT=.. @@ -167,6 +167,11 @@ CXX=g++ #CXX=arm-linux-g++ #LINK=arm-linux-gcc +# file for regular expression matching +REGEXOBJ = posixregex.o +#REGEXOBJ = pmatchregex.o +#REGEXOBJ = cppregex.o + # Set the WINSRC, WINOBJ, and WINLIB lines to correspond to your desired # combination of windowing systems. Also set windowing systems in config.h. # Note that if you are including multiple tiled window systems, you don't @@ -337,7 +342,9 @@ HACKCSRC = allmain.c alloc.c apply.c artifact.c attrib.c ball.c bones.c \ # all operating-system-dependent .c (for dependencies and such) SYSCSRC = ../sys/atari/tos.c ../sys/share/pcmain.c ../sys/share/pcsys.c \ - ../sys/share/pctty.c ../sys/share/pcunix.c ../sys/share/posixregex.c ../sys/share/random.c \ + ../sys/share/pctty.c ../sys/share/pcunix.c \ + ../sys/share/pmatchregex.c ../sys/share/posixregex.c \ + ../sys/share/random.c \ ../sys/share/ioctl.c ../sys/share/unixtty.c ../sys/unix/unixmain.c \ ../sys/unix/unixunix.c ../sys/unix/unixres.c ../sys/be/bemain.c @@ -391,14 +398,14 @@ HOBJ = $(FIRSTOBJ) allmain.o alloc.o apply.o artifact.o attrib.o ball.o \ minion.o mklev.o mkmap.o \ mkmaze.o mkobj.o mkroom.o mon.o mondata.o monmove.o monstr.o \ mplayer.o mthrowu.o muse.o music.o o_init.o objnam.o options.o \ - pager.o pickup.o pline.o polyself.o posixregex.o potion.o pray.o priest.o \ + pager.o pickup.o pline.o polyself.o potion.o pray.o priest.o \ quest.o questpgr.o read.o rect.o region.o restore.o rip.o rnd.o \ role.o rumors.o save.o shk.o shknam.o sit.o sounds.o sp_lev.o spell.o \ sys.o \ steal.o steed.o teleport.o timeout.o topten.o track.o trap.o u_init.o \ uhitm.o vault.o vision.o vis_tab.o weapon.o were.o wield.o windows.o \ wizard.o worm.o worn.o write.o zap.o \ - $(RANDOBJ) $(SYSOBJ) $(WINOBJ) $(HINTOBJ) version.o + $(REGEXOBJ) $(RANDOBJ) $(SYSOBJ) $(WINOBJ) $(HINTOBJ) version.o # the .o files from the HACKCSRC, SYSSRC, and WINSRC lists $(GAME): $(SYSTEM) @@ -599,12 +606,14 @@ pctty.o: ../sys/share/pctty.c $(HACK_H) $(CC) $(CFLAGS) -c ../sys/share/pctty.c pcunix.o: ../sys/share/pcunix.c $(HACK_H) $(CC) $(CFLAGS) -c ../sys/share/pcunix.c +pmatchregex.o: ../sys/share/pmatchregex.c $(HACK_H) + $(CC) $(CFLAGS) -c ../sys/share/pmatchregex.c +posixregex.o: ../sys/share/posixregex.c $(HACK_H) + $(CC) $(CFLAGS) -c ../sys/share/posixregex.c random.o: ../sys/share/random.c $(HACK_H) $(CC) $(CFLAGS) -c ../sys/share/random.c ioctl.o: ../sys/share/ioctl.c $(HACK_H) ../include/tcap.h $(CC) $(CFLAGS) -c ../sys/share/ioctl.c -posixregex.o: ../sys/share/posixregex.c $(HACK_H) - $(CC) $(CFLAGS) -c ../sys/share/posixregex.c unixtty.o: ../sys/share/unixtty.c $(HACK_H) $(CC) $(CFLAGS) -c ../sys/share/unixtty.c unixmain.o: ../sys/unix/unixmain.c $(HACK_H) ../include/dlb.h From f6e46d286dcb0980ac392d7490d35b52f525e56b Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 16 Jun 2015 02:42:17 -0700 Subject: [PATCH 7/7] another recent bit of lint --- src/display.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/display.c b/src/display.c index f9db10eba..8a5489538 100644 --- a/src/display.c +++ b/src/display.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 display.c $NHDT-Date: 1433901380 2015/06/10 01:56:20 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */ +/* NetHack 3.6 display.c $NHDT-Date: 1434447701 2015/06/16 09:41:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.63 $ */ /* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */ /* and Dave Cohrs, 1990. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1707,8 +1707,13 @@ STATIC_OVL int get_bk_glyph(x,y) xchar x, y; { +#if 1 int retglyph = NO_GLYPH; - /* struct rm *lev = &levl[x][y]; */ + nhUse(x); + nhUse(y); +#else + struct rm *lev = &levl[x][y]; +#endif return retglyph; }